Revision: 200948
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 23 Nov 2009 14:46:41 +0200
changeset 0 dab8a81a92de
child 1 95fdac6ccb5c
Revision: 200948
contentctrl_plat/group/bld.inf
contentctrl_plat/oma_ds_presync_plugin_api/group/bld.inf
contentctrl_plat/oma_ds_presync_plugin_api/inc/CPreSyncPlugin.h
contentctrl_plat/oma_ds_presync_plugin_api/inc/CPreSyncPlugin.inl
contentctrl_plat/oma_ds_presync_plugin_api/oma_ds_presync_plugin_api.metaxml
dsdcmoadapter/conf/dsdcmocontrol.confml
dsdcmoadapter/conf/dsdcmocontrol_20022FC0.crml
dsdcmoadapter/data/20022FBC.rss
dsdcmoadapter/group/bld.inf
dsdcmoadapter/group/nsmldsctrldcmoadapter.mmp
dsdcmoadapter/inc/nsmldsctrldcmoadapter.h
dsdcmoadapter/rom/dsdcmoadapter.iby
dsdcmoadapter/src/nsmldsctrldcmoadapter.cpp
dsdcmoadapter/src/nsmldsctrldcmodapterproxy.cpp
group/bld.inf
layers.sysdef.xml
omads/group/bld.inf
omads/omadsappui/AiwSyncProvider/group/ABLD.BAT
omads/omadsappui/AiwSyncProvider/group/AiwSyncProvider.mmp
omads/omadsappui/AiwSyncProvider/group/bld.inf
omads/omadsappui/AiwSyncProvider/inc/AiwSyncProvider.h
omads/omadsappui/AiwSyncProvider/inc/AiwSyncProvider.rh
omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderDebug.h
omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderUids.hrh
omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderUtil.h
omads/omadsappui/AiwSyncProvider/src/101F871F.rss
omads/omadsappui/AiwSyncProvider/src/AiwSyncProvider.cpp
omads/omadsappui/AiwSyncProvider/src/AiwSyncProvider.rss
omads/omadsappui/AspPreSyncPlugin/data/AspPreSyncDefault.rss
omads/omadsappui/AspPreSyncPlugin/group/ABLD.BAT
omads/omadsappui/AspPreSyncPlugin/group/AspPreSyncDefault.mmp
omads/omadsappui/AspPreSyncPlugin/group/bld.inf
omads/omadsappui/AspPreSyncPlugin/inc/AspPreSyncDefaultPlugin.h
omads/omadsappui/AspPreSyncPlugin/src/AspPreSyncDefaultPlugin.cpp
omads/omadsappui/AspPreSyncPlugin/src/proxy.cpp
omads/omadsappui/AspScheduleHandler/group/aspschedulehandler.mmp
omads/omadsappui/AspScheduleHandler/group/bld.inf
omads/omadsappui/AspScheduleHandler/inc/AspDebug.h
omads/omadsappui/AspScheduleHandler/src/aspschedulehandler.cpp
omads/omadsappui/AspSyncUtil/BWINS/AspSyncUtilu.def
omads/omadsappui/AspSyncUtil/eabi/AspSyncUtilu.def
omads/omadsappui/AspSyncUtil/group/ABLD.BAT
omads/omadsappui/AspSyncUtil/group/AspSyncUtil.mmp
omads/omadsappui/AspSyncUtil/group/aspsyncutil_icons.mk
omads/omadsappui/AspSyncUtil/group/aspsyncutil_icons_dc.mk
omads/omadsappui/AspSyncUtil/group/bld.inf
omads/omadsappui/AspSyncUtil/inc/AspAdvanceSettingsDialog.h
omads/omadsappui/AspSyncUtil/inc/AspAutoSyncHandler.h
omads/omadsappui/AspSyncUtil/inc/AspContentDialog.h
omads/omadsappui/AspSyncUtil/inc/AspContentListDialog.h
omads/omadsappui/AspSyncUtil/inc/AspDbNotifier.h
omads/omadsappui/AspSyncUtil/inc/AspDebug.h
omads/omadsappui/AspSyncUtil/inc/AspDefines.h
omads/omadsappui/AspSyncUtil/inc/AspDialogUtil.h
omads/omadsappui/AspSyncUtil/inc/AspFilter.h
omads/omadsappui/AspSyncUtil/inc/AspFilterDialog.h
omads/omadsappui/AspSyncUtil/inc/AspLogDialog.h
omads/omadsappui/AspSyncUtil/inc/AspPreSyncPluginInterface.h
omads/omadsappui/AspSyncUtil/inc/AspProfile.h
omads/omadsappui/AspSyncUtil/inc/AspProfileDialog.h
omads/omadsappui/AspSyncUtil/inc/AspProfileSelectionDialog.h
omads/omadsappui/AspSyncUtil/inc/AspProfileWizard.h
omads/omadsappui/AspSyncUtil/inc/AspProfileWizardDialog.h
omads/omadsappui/AspSyncUtil/inc/AspProgressDialog.h
omads/omadsappui/AspSyncUtil/inc/AspResHandler.h
omads/omadsappui/AspSyncUtil/inc/AspSchedule.h
omads/omadsappui/AspSyncUtil/inc/AspScheduleDialog.h
omads/omadsappui/AspSyncUtil/inc/AspSettingDialog.h
omads/omadsappui/AspSyncUtil/inc/AspSettingViewDialog.h
omads/omadsappui/AspSyncUtil/inc/AspState.h
omads/omadsappui/AspSyncUtil/inc/AspSyncHandler.h
omads/omadsappui/AspSyncUtil/inc/AspSyncUtil.h
omads/omadsappui/AspSyncUtil/inc/AspSyncUtil.rh
omads/omadsappui/AspSyncUtil/inc/AspSyncUtilApi.h
omads/omadsappui/AspSyncUtil/inc/AspUtil.h
omads/omadsappui/AspSyncUtil/inc/xxxxAspDebug.h
omads/omadsappui/AspSyncUtil/loc/NSmlDSSync.loc
omads/omadsappui/AspSyncUtil/loc/NSmlSyncProfiles.loc
omads/omadsappui/AspSyncUtil/src/AspAdvanceSettingsDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspAutoSyncHandler.cpp
omads/omadsappui/AspSyncUtil/src/AspContentDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspContentListDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspDbNotifier.cpp
omads/omadsappui/AspSyncUtil/src/AspDialogUtil.cpp
omads/omadsappui/AspSyncUtil/src/AspFilter.cpp
omads/omadsappui/AspSyncUtil/src/AspFilterDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspLogDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspPreSyncPluginInterface.cpp
omads/omadsappui/AspSyncUtil/src/AspProfile.cpp
omads/omadsappui/AspSyncUtil/src/AspProfileDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspProfileSelectionDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspProfileWizard.cpp
omads/omadsappui/AspSyncUtil/src/AspProfileWizardDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspProgressDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspResHandler.cpp
omads/omadsappui/AspSyncUtil/src/AspSchedule.cpp
omads/omadsappui/AspSyncUtil/src/AspScheduleDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspSettingDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspSettingViewDialog.cpp
omads/omadsappui/AspSyncUtil/src/AspState.cpp
omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp
omads/omadsappui/AspSyncUtil/src/AspSyncUtil.cpp
omads/omadsappui/AspSyncUtil/src/AspSyncUtil.rss
omads/omadsappui/AspSyncUtil/src/AspSyncUtilApi.cpp
omads/omadsappui/AspSyncUtil/src/AspUtil.cpp
omads/omadsappui/OmaDsAppUiPlugin/BWinscw/OmaDsAppUiPluginu.def
omads/omadsappui/OmaDsAppUiPlugin/data/102833A1.rss
omads/omadsappui/OmaDsAppUiPlugin/data/NsmlDSGSPluginResource.rss
omads/omadsappui/OmaDsAppUiPlugin/eabi/OmaDsAppUiPluginu.def
omads/omadsappui/OmaDsAppUiPlugin/group/OmaDsAppUiPlugin.mmp
omads/omadsappui/OmaDsAppUiPlugin/group/OmaDsAppUiPlugin_icons_dc.mk
omads/omadsappui/OmaDsAppUiPlugin/group/bld.inf
omads/omadsappui/OmaDsAppUiPlugin/inc/OmaDsAppUiPluginInterface.h
omads/omadsappui/OmaDsAppUiPlugin/src/OmaDsAppUiPluginInterface.cpp
omads/omadsappui/OmaDsAppUiPlugin/src/OmaDsAppUiPluginProxy.cpp
omads/omadsappui/cenrep/keys_omadsui.xls
omads/omadsappui/conf/omadsui.confml
omads/omadsappui/conf/omadsui_101F9A1D.crml
omads/omadsappui/group/ABLD.BAT
omads/omadsappui/group/bld.inf
omads/omadsappui/help/data/xhtml.zip
omads/omadsappui/help/group/bld.inf
omads/omadsappui/help/inc/ds.hlp.hrh
omads/omadsappui/help/rom/omadsappuihelps_variant.iby
omads/omadsappui/rom/AspSyncProvider.iby
omads/omadsappui/rom/AspSyncProvider_Resources.iby
omads/omadsappui/rom/AspSyncUtil.iby
omads/omadsappui/rom/AspSyncUtil_Resources.iby
omads/omadsappui/rom/OmaDsAppUi.iby
omads/omadsappui/rom/OmaDsAppUiResources.iby
omads/omadsappui/ui/aif/NSmlDSSyncaif.rss
omads/omadsappui/ui/aif/context_pane_icon.bmp
omads/omadsappui/ui/aif/context_pane_icon_mask.bmp
omads/omadsappui/ui/aif/list_icon.bmp
omads/omadsappui/ui/aif/list_icon_mask.bmp
omads/omadsappui/ui/group/ABLD.BAT
omads/omadsappui/ui/group/NSmlDSSync.mmp
omads/omadsappui/ui/group/aiwtestapp.SIS
omads/omadsappui/ui/group/bld.inf
omads/omadsappui/ui/group/omadsappui_icons.mk
omads/omadsappui/ui/group/omadsappui_icons_aif_bitmaps.mk
omads/omadsappui/ui/group/omadsappui_icons_aif_bitmaps_dc.mk
omads/omadsappui/ui/group/omadsappui_icons_aif_scalable.mk
omads/omadsappui/ui/group/omadsappui_icons_aif_scalable_dc.mk
omads/omadsappui/ui/group/omadsappui_icons_dc.mk
omads/omadsappui/ui/inc/NSmlDSSync.hrh
omads/omadsappui/ui/inc/NSmlDSSyncApp.h
omads/omadsappui/ui/inc/NSmlDSSyncAppServer.h
omads/omadsappui/ui/inc/NSmlDSSyncAppUi.h
omads/omadsappui/ui/inc/NSmlDSSyncContainer.h
omads/omadsappui/ui/inc/NSmlDSSyncDocument.h
omads/omadsappui/ui/src/NSmlDSSync.rss
omads/omadsappui/ui/src/NSmlDSSyncApp.cpp
omads/omadsappui/ui/src/NSmlDSSyncAppServer.cpp
omads/omadsappui/ui/src/NSmlDSSyncAppUi.cpp
omads/omadsappui/ui/src/NSmlDSSyncContainer.cpp
omads/omadsappui/ui/src/NSmlDSSyncDocument.cpp
omads/omadsappui/ui/src/NSmlDSSync_caption.rss
omads/omadsappui/ui/src/NSmlDSSync_reg.rss
omads/omadsappui/ui/src/NSmlDSSyncaif.rss
omads/omadsextensions/adapters/agenda/bld/bld.inf
omads/omadsextensions/adapters/agenda/bld/def/bwinscwnsmlagendadataprovideru.def
omads/omadsextensions/adapters/agenda/bld/def/eabinsmlagendadataprovideru.def
omads/omadsextensions/adapters/agenda/bld/nsmlagendadataprovider.mmp
omads/omadsextensions/adapters/agenda/inc/nsmlagendadataprovider.h
omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h
omads/omadsextensions/adapters/agenda/inc/nsmlagendadefines.hrh
omads/omadsextensions/adapters/agenda/loc/101F6DD7.loc
omads/omadsextensions/adapters/agenda/src/101F6DD7.rss
omads/omadsextensions/adapters/agenda/src/NSmlAgendaDataStore_1_1_2.rss
omads/omadsextensions/adapters/agenda/src/NSmlAgendaDataStore_1_2.rss
omads/omadsextensions/adapters/agenda/src/nsmlagendadataprovider.cpp
omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp
omads/omadsextensions/adapters/agenda/src/nsmlagendaprogressview.cpp
omads/omadsextensions/adapters/bld/bld.inf
omads/omadsextensions/adapters/bookmark/group/102751BA.XML
omads/omadsextensions/adapters/bookmark/group/bld.inf
omads/omadsextensions/adapters/bookmark/group/bookmarkdataprovider.mmp
omads/omadsextensions/adapters/bookmark/group/bookmarkdsa_stub.pkg
omads/omadsextensions/adapters/bookmark/group/bookmarkdsa_stub.sis
omads/omadsextensions/adapters/bookmark/inc/bookmarkdataprovider.h
omads/omadsextensions/adapters/bookmark/inc/bookmarkdataproviderdefs.h
omads/omadsextensions/adapters/bookmark/inc/bookmarkdatastore.h
omads/omadsextensions/adapters/bookmark/inc/changefinder.h
omads/omadsextensions/adapters/bookmark/inc/conversionutil.h
omads/omadsextensions/adapters/bookmark/inc/logger.h
omads/omadsextensions/adapters/bookmark/inc/omadsfolderobject.h
omads/omadsextensions/adapters/bookmark/inc/snapshotitem.h
omads/omadsextensions/adapters/bookmark/inc/vbookmarkconverter.h
omads/omadsextensions/adapters/bookmark/loc/bookmarkdsa.loc
omads/omadsextensions/adapters/bookmark/rom/bookmarkdsa.iby
omads/omadsextensions/adapters/bookmark/src/bookmarkdataprovider.cpp
omads/omadsextensions/adapters/bookmark/src/bookmarkdataprovider.rss
omads/omadsextensions/adapters/bookmark/src/bookmarkdatastore.cpp
omads/omadsextensions/adapters/bookmark/src/bookmarkdatastore.rss
omads/omadsextensions/adapters/bookmark/src/bookmarkdsa.rss
omads/omadsextensions/adapters/bookmark/src/changefinder.cpp
omads/omadsextensions/adapters/bookmark/src/conversionutil.cpp
omads/omadsextensions/adapters/bookmark/src/omadsfolderobject.cpp
omads/omadsextensions/adapters/bookmark/src/snapshotitem.cpp
omads/omadsextensions/adapters/bookmark/src/vbookmarkconverter.cpp
omads/omadsextensions/adapters/contacts/bld/bld.inf
omads/omadsextensions/adapters/contacts/bld/def/bwinscwcontactsdataprovideru.def
omads/omadsextensions/adapters/contacts/bld/def/eabicontactsdataprovideru.def
omads/omadsextensions/adapters/contacts/bld/nsmldscontactsdataprovider.mmp
omads/omadsextensions/adapters/contacts/inc/NSmlContactsDataProvider.h
omads/omadsextensions/adapters/contacts/inc/NSmlContactsDataStore.h
omads/omadsextensions/adapters/contacts/inc/NSmlContactsModsFetcher.h
omads/omadsextensions/adapters/contacts/inc/nsmlcontactsdefs.h
omads/omadsextensions/adapters/contacts/loc/101F6DD6.loc
omads/omadsextensions/adapters/contacts/src/101F6DD6.rss
omads/omadsextensions/adapters/contacts/src/NSmlContactsDataProvider.cpp
omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStore.cpp
omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStoreFormat_1_1_2.rss
omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStoreFormat_1_2.rss
omads/omadsextensions/adapters/contacts/src/NSmlContactsModsFetcher.cpp
omads/omadsextensions/adapters/inc/nsmldsimpluids.h
omads/omadsextensions/adapters/mms/group/101FB0E9.XML
omads/omadsextensions/adapters/mms/group/bld.inf
omads/omadsextensions/adapters/mms/group/mmsdataprovider.mmp
omads/omadsextensions/adapters/mms/group/mmsdsa_stub.pkg
omads/omadsextensions/adapters/mms/group/mmsdsa_stub.sis
omads/omadsextensions/adapters/mms/inc/changefinder.h
omads/omadsextensions/adapters/mms/inc/logger.h
omads/omadsextensions/adapters/mms/inc/mmsadaptermsvapi.h
omads/omadsextensions/adapters/mms/inc/mmsdataprovider.h
omads/omadsextensions/adapters/mms/inc/mmsdataproviderdefs.h
omads/omadsextensions/adapters/mms/inc/mmsdatastore.h
omads/omadsextensions/adapters/mms/inc/omadsfolderobject.h
omads/omadsextensions/adapters/mms/inc/snapshotitem.h
omads/omadsextensions/adapters/mms/rom/mmsdsa.iby
omads/omadsextensions/adapters/mms/src/changefinder.cpp
omads/omadsextensions/adapters/mms/src/mmsadaptermsvapi.cpp
omads/omadsextensions/adapters/mms/src/mmsdataprovider.cpp
omads/omadsextensions/adapters/mms/src/mmsdataprovider.rss
omads/omadsextensions/adapters/mms/src/mmsdatastore.cpp
omads/omadsextensions/adapters/mms/src/mmsdatastore.rss
omads/omadsextensions/adapters/mms/src/omadsfolderobject.cpp
omads/omadsextensions/adapters/mms/src/snapshotitem.cpp
omads/omadsextensions/adapters/sms/group/10206B5C.XML
omads/omadsextensions/adapters/sms/group/SmsDataProvider.mmp
omads/omadsextensions/adapters/sms/group/bld.inf
omads/omadsextensions/adapters/sms/group/smsdsa_stub.pkg
omads/omadsextensions/adapters/sms/group/smsdsa_stub.sis
omads/omadsextensions/adapters/sms/inc/ChangeFinder.h
omads/omadsextensions/adapters/sms/inc/Logger.h
omads/omadsextensions/adapters/sms/inc/OMADSFolderObject.h
omads/omadsextensions/adapters/sms/inc/SMSAdapterMsvApi.h
omads/omadsextensions/adapters/sms/inc/SmsDataProvider.h
omads/omadsextensions/adapters/sms/inc/SmsDataProviderDefs.h
omads/omadsextensions/adapters/sms/inc/SmsDataStore.h
omads/omadsextensions/adapters/sms/inc/SnapshotItem.h
omads/omadsextensions/adapters/sms/inc/VMessageParser.h
omads/omadsextensions/adapters/sms/rom/smsdsa.iby
omads/omadsextensions/adapters/sms/src/ChangeFinder.cpp
omads/omadsextensions/adapters/sms/src/OMADSFolderObject.cpp
omads/omadsextensions/adapters/sms/src/SMSAdapterMsvApi.cpp
omads/omadsextensions/adapters/sms/src/SmsDataProvider.cpp
omads/omadsextensions/adapters/sms/src/SmsDataProvider.rss
omads/omadsextensions/adapters/sms/src/SmsDataStore.cpp
omads/omadsextensions/adapters/sms/src/SmsDataStore.rss
omads/omadsextensions/adapters/sms/src/SnapshotItem.cpp
omads/omadsextensions/adapters/sms/src/VMessageParser.cpp
omads/omadsextensions/datamod/bld/bld.inf
omads/omadsextensions/datamod/bld/def/bwinscwdatamodu.def
omads/omadsextensions/datamod/bld/def/eabidatamodu.def
omads/omadsextensions/datamod/bld/nsmldatamod.mmp
omads/omadsextensions/datamod/inc/NSmlDataModBase.h
omads/omadsextensions/datamod/src/NSmlProperty.cpp
omads/omadsextensions/datamod/src/NSmlVCalMod.cpp
omads/omadsextensions/datamod/src/NSmlVCardMod.cpp
omads/omadsextensions/datamod/src/nsmldatamodbase.cpp
omads/omadsextensions/dsutils/cgiscriptutils/bld/bld.inf
omads/omadsextensions/dsutils/cgiscriptutils/bld/def/bwinscwcgiscriptparseru.def
omads/omadsextensions/dsutils/cgiscriptutils/bld/def/eabicgiscriptparseru.def
omads/omadsextensions/dsutils/cgiscriptutils/bld/nsmlCGIScriptParser.mmp
omads/omadsextensions/dsutils/cgiscriptutils/inc/nsmlcgiscriptparser.h
omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScript.cpp
omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScriptParseData.cpp
omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScriptParseStateInfo.cpp
omads/omadsextensions/dsutils/cgiscriptutils/src/nsmlcgiscriptparser.cpp
omads/omadsextensions/dsutils/emailxmlutils/bld/bld.inf
omads/omadsextensions/dsutils/emailxmlutils/bld/def/bwinscwxmlparseru.def
omads/omadsextensions/dsutils/emailxmlutils/bld/def/eabixmlparseru.def
omads/omadsextensions/dsutils/emailxmlutils/bld/nsmlxmlparser.mmp
omads/omadsextensions/dsutils/emailxmlutils/inc/nsmlxmlparser.h
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlEmailFileParser.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlEmailParser.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlExtData.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlFolderAttributeData.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlFolderParser.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/NSmlTruncatedData.cpp
omads/omadsextensions/dsutils/emailxmlutils/src/nsmlxmlparser.cpp
omads/omadsextensions/group/bld.inf
package_definition.xml
sysdef_1_4_0.dtd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentctrl_plat/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  Includes all the Domain API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+//#include "../syncml_notifier_roaming_api/group/bld.inf"
+//#include "../sync_service_api/group/bld.inf"
+#include "../oma_ds_presync_plugin_api/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentctrl_plat/oma_ds_presync_plugin_api/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                OMA DS PreSync Plugin API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/CPreSyncPlugin.h    APP_LAYER_PLATFORM_EXPORT_PATH(CPreSyncPlugin.h)
+../inc/CPreSyncPlugin.inl     APP_LAYER_PLATFORM_EXPORT_PATH(CPreSyncPlugin.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentctrl_plat/oma_ds_presync_plugin_api/inc/CPreSyncPlugin.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECom search interface definition
+*
+*/
+
+
+#ifndef CPRESYNC_PLUGIN_H
+#define CPRESYNC_PLUGIN_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <s32mem.h>
+#include <ecom/ecom.h>
+#include <SyncMLDef.h>
+
+/**
+* CenRep key for storing the roaming setting.
+* 
+*
+* Possible integer values:
+* 
+* 0 Always Ask
+* 1 Always Allow
+* 2 Never Allow
+* 3 Block
+* Default value: 0 (Always Ask)
+*
+*/
+const TUint32 KNSmlRoamingSettingKey = 0x00000005;
+
+/**
+* CenRep key for storing the roaming setting feature.
+* 
+*
+* Possible integer values:
+* 
+* 0 Feature disabled
+* 1 Feature enabled
+*
+*/
+const TUint32 KNSmlDSRoamingFeature = 0x00000006;
+
+
+/**
+ * Constant:    KPreSyncPluginInterfaceUid
+ *
+ * Description: UID of this ECOM interface. 
+ */
+const TUid KPreSyncPluginInterfaceUid = {0x2001955C};
+
+enum TASpRoamingSettingFeature
+    {
+    EAspRoamingSettingFeatureDisabled = 0,
+    EAspRoamingSettingFeatureEnabled = 1
+    };
+
+/**
+ * Class:       MSyncExtObserver
+ *
+ * Description:  
+ */
+
+class MSyncExtObserver
+{
+        public: // Public pure virtual functions.
+
+        /**
+         * Function:    SyncCompleted
+         *
+         */
+        virtual void SyncCompleted(TInt err) = 0;
+ };
+
+
+/**
+ * Class:       CPreSyncPlugin
+ *
+ * Description: Custom ECOM interface definition. This interface is used by
+ *              clients to handle roamong . 
+ */
+class CPreSyncPlugin: public CBase
+{
+public: 
+    /**
+     * Function   :   NewL(TUid aImplementationUid);
+     * Description:   Implementation created based on implementation ID
+     */
+    static CPreSyncPlugin* NewL(TUid aImplementationUid);
+    
+    /**
+     * Function   :   NewL(const TDesC8& aParam);
+     * Description:   Implementation created based Implemetation resolution parameter
+     */
+    static CPreSyncPlugin* NewL(const TDesC8& aParam);
+
+
+    /**
+     * Function:   ~CPreSyncPlugin
+     *
+     * Description: Wraps ECom object destruction. Notifies the ECOM
+     *              framework that specific instance is being destroyed.
+     */
+    virtual ~CPreSyncPlugin();
+
+
+    public: // Public pure virtual functions.
+
+    /**
+     * Function:    IsSupported
+     *
+     */
+    virtual TBool IsSupported() = 0;
+    
+    /**
+     * Function:    CanSync
+     *
+     */
+    virtual TBool CanSyncL() = 0;
+    
+    /**
+     * Function:    SetProfile  
+     *
+     */
+    virtual TBool SetProfile(const TSmlProfileId& aProfileId) = 0;
+    
+    /**
+     * Function:    SyncNow  
+     *
+     */   
+    virtual TInt SyncNow(MSyncExtObserver* aObserver) = 0 ;
+    
+public: 
+
+        /** iDtor_ID_Key Instance identifier key. When instance of an
+             *               implementation is created by ECOM framework, the
+             *               framework will assign UID for it. The UID is used in
+             *               destructor to notify framework that this instance is
+             *               being destroyed and resources can be released.
+             */
+        TUid iDtor_ID_Key;
+
+        
+};
+
+#include "CPreSyncPlugin.inl" // Own base implementations for ECOM
+
+#endif		// CPCS_PLUGIN_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentctrl_plat/oma_ds_presync_plugin_api/inc/CPreSyncPlugin.inl	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2008-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:  ECom search interface definition
+*
+*/
+
+// Interface's (abstract base class's) destructor
+
+inline CPreSyncPlugin::~CPreSyncPlugin()
+    {
+ 
+       REComSession::DestroyedImplementation(iDtor_ID_Key);
+    }
+
+inline CPreSyncPlugin*
+CPreSyncPlugin::NewL(TUid aImplementationUid)
+    {
+    TAny* ptr = REComSession::CreateImplementationL(
+            aImplementationUid,_FOFF(CPreSyncPlugin,iDtor_ID_Key));
+    // The type of TAny* ptr should be CPreSyncPlugin.
+    return REINTERPRET_CAST(CPreSyncPlugin*, ptr);
+    }
+
+inline CPreSyncPlugin* CPreSyncPlugin::NewL(const TDesC8& aParam)
+    {
+    // Define options, how the default resolver will find appropriate
+    // implementation.
+    TEComResolverParams resolverParams;
+    resolverParams.SetDataType(aParam);
+    resolverParams.SetWildcardMatch(ETrue);     // Allow wildcard matching
+
+    TAny* ptr = REComSession::CreateImplementationL(
+            KPreSyncPluginInterfaceUid,
+        _FOFF(CPreSyncPlugin,iDtor_ID_Key),resolverParams);
+
+    // The type of TAny* ptr should be CTmoPhonebookSyncInterfaceDefinitionDlg.
+    return REINTERPRET_CAST(CPreSyncPlugin*, ptr);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentctrl_plat/oma_ds_presync_plugin_api/oma_ds_presync_plugin_api.metaxml	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0" ?>
+<api id="a3db4638620fe5970d01d2487f001745" dataversion="1.0">
+<name>OMA DS PreSync Plugin API</name>
+<description>OMA DS PreSync Plugin Interface. Used for operator customization.</description>
+<type>c++</type>
+<subsystem>omads</subsystem>
+<libs></libs>
+<release category="domain" sinceversion="3.2"/>
+<attributes>
+<htmldocprovided>no</htmldocprovided>
+<adaptation>no</adaptation>
+</attributes>
+</api>
Binary file dsdcmoadapter/conf/dsdcmocontrol.confml has changed
Binary file dsdcmoadapter/conf/dsdcmocontrol_20022FC0.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/data/20022FBC.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file for Desktop Sync Control Interface Implementation.
+*
+*/
+
+#include "registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x20022FBC;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x2001FD40;
+			implementations = 
+				{
+				// Info for DSDCMOAdapter
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x20022FBD;
+					version_no = 1;
+					display_name = "DSDCMOAdapter";
+					default_data = "text/wml||This is the type of data that this implementation understands. (Can be anything which will allow the resolver to identify this implementation as the correct one at run time. In this case it is a mime type).";
+					opaque_data = "DesktopSync";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file provides building information for Desktop Sync Ctrl.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+// Generic configuration interface for component cenrep settings  
+../conf/dsdcmocontrol.confml APP_LAYER_CONFML(dsdcmocontrol.confml)
+../conf/dsdcmocontrol_20022FC0.crml APP_LAYER_CRML(dsdcmocontrol_20022FC0.crml)
+../rom/dsdcmoadapter.iby      CORE_APP_LAYER_IBY_EXPORT_PATH(dsdcmoadapter.iby)
+
+PRJ_MMPFILES
+nsmldsctrldcmoadapter.mmp
+
+// End Of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/group/nsmldsctrldcmoadapter.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DS plug-in adapter for DCMO
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET nsmldsctrldcmoadapter.dll
+TARGETTYPE PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID 0x10009D8D 0x20022FBC
+VENDORID VID_DEFAULT
+CAPABILITY  CAP_ECOM_PLUGIN
+
+SOURCEPATH ../src
+SOURCE nsmldsctrldcmodapterproxy.cpp nsmldsctrldcmoadapter.cpp
+
+USERINCLUDE 		../inc 
+
+APP_LAYER_SYSTEMINCLUDE
+
+
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+SOURCEPATH			../data
+start resource 20022FBC.rss
+TARGET nsmldsctrldcmoadapter.rsc
+LANGUAGE_IDS
+end
+
+
+LIBRARY 				euser.lib ECom.lib efsrv.lib 
+LIBRARY         centralrepository.lib
+LIBRARY					commonengine.lib  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/inc/nsmldsctrldcmoadapter.h	Mon Nov 23 14:46:41 2009 +0200
@@ -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:  header file for DSCtrl plug-in adapter
+*
+*/
+
+#ifndef _NSMLDSCTRLDCMOADAPTER__
+#define _NSMLDSCTRLDCMOADAPTER__
+
+// Header needed for our CDCMO interface
+#include "dcmointerface.h"
+
+/** 
+ * An implementation of the CDCMOInterface definition
+ * Provides methods to read/write the properties of DCMO Plugin
+ * @lib nsmldsctrldcmoadapter.dll
+ */
+class CNsmlDsCtrlDCMOAdapter : public CDCMOInterface
+	{
+
+public:
+	/**
+	* Two phase construction
+	* Standardised safe construction which leaves nothing the cleanup stack.
+    */
+	static CNsmlDsCtrlDCMOAdapter* NewL(TAny* aInitParams);
+	
+	/**
+    * Destructor
+    */
+	~CNsmlDsCtrlDCMOAdapter();
+
+	// Implementation of CDCMOInterface
+	
+	/**
+    * Get DCMO Plug-in's attribute value which are integers
+    * 
+    * @param aId, it refer to the attributes of the capability
+    * @param aValue, it refer to the value of the attribute to be fetched
+    * @return status, It returns DCMO request success or failure
+    */
+	TDCMOStatus  GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue);
+	
+	/**
+    * Get DCMO Plug-in's attribute value which are strings
+    * 
+    * @param aId, it refer to the attributes of the capability
+    * @param aValue, it refer to the value of the attribute to be fetched
+    * @return status, It returns DCMO request success or failure
+    */
+	TDCMOStatus  GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue);
+	
+	/**
+    * Set DCMO Plug-in's attribute value which are integers
+    * 
+    * @param aId, it refer to the attributes of the capability
+    * @param aValue, it refer to the value of the attribute to be set
+    * @return status, It returns DCMO request success or failure
+    */
+	TDCMOStatus  SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue);
+	
+	/**
+    * Set DCMO Plug-in's attribute value which are strings
+    * 
+    * @param aId, it refer to the attributes of the capability
+    * @param aValue, it refer to the value of the attribute to be set
+    * @return status, It returns DCMO request success or failure
+    */
+	TDCMOStatus  SetDCMOPluginStrAttributeValueL(TDCMONode aId, const TDes& aStrValue);
+	
+	/**
+    * Get localised name of the Plug-in
+    * 
+    * @param aLocName, member to store the name of Plugin
+    */
+	void GetLocalizedNameL (HBufC*& aLocName);    
+	
+private:
+	/**
+    * Construction
+    */
+    CNsmlDsCtrlDCMOAdapter(TAny* aInitParams);
+  
+    /**
+	* Second Phase constructor
+	*/
+	void ConstructL();
+
+private:
+	// Data to pass back from implementation to client
+	
+	/**
+	* Member to store the Property Attribute of the Plug-in
+	* It will be sent back to the client
+	*/
+	HBufC* iProperty;
+	
+	/**
+	* Member to store the Description Attribute of the Plug-in
+	* It will be sent back to the client
+	*/
+	HBufC* iDescription;
+	
+	/**
+	* Parameters taken from client
+	*/
+	TDCMOInterfaceInitParams* iInitParams;
+	};  
+
+#endif //_NSMLDSCTRLDCMOADAPTER__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/rom/dsdcmoadapter.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  iby file for DS DCMO adapter binaries
+*
+*/
+
+
+#ifndef __DSDCMOADAPTER_IBY__
+#define __DSDCMOADAPTER_IBY__
+
+#ifdef FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION
+ECOM_PLUGIN(nsmldsctrldcmoadapter.dll, nsmldsctrldcmoadapter.rsc)
+#endif
+
+#endif //__DSDCMOADAPTER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/src/nsmldsctrldcmoadapter.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,228 @@
+/*
+* 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:  Implementation of DSCtrl plug-in adapter for DCMO
+*
+*/
+
+//SYSTEM INCLUDES
+#include <centralrepository.h>
+#include <dcmo.rsg>
+#include <e32base.h>
+#include <stringresourcereader.h> 
+#include <f32file.h> 
+#include <data_caging_path_literals.hrh>
+
+//USER INCLUDES
+#include "nsmldsctrldcmoadapter.h"
+
+// CONSTANTS
+const TUid KCRUidDSDCMOConfig = { 0x20022FC0 };
+const TInt KNsmlDesktopSync = 0; // 0x0000000 defined in DS cenrep
+
+// Name of the Plug-in adapter
+_LIT(KNsmlDesktopSyncTitle, "Desktop Sync"); 
+// Description for Desktop Sync adapter
+_LIT(KNsmlDSDCMODescription, "Used to enable/disable the Desktop Sync." ); //use Nsml?????
+// Path used for fetching the string to be displayed
+_LIT( KRuntimeResourceFileName, "z:dcmo.rsc" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CNsmlDsCtrlDCMOAdapter* CNsmlDsCtrlDCMOAdapter::NewL(TAny* aParams)
+	{
+	CNsmlDsCtrlDCMOAdapter* self=new(ELeave) CNsmlDsCtrlDCMOAdapter(aParams);  
+	CleanupStack::PushL(self);
+	self->ConstructL(); 
+	CleanupStack::Pop();
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::~CNsmlDsCtrlDCMOAdapter()
+// Destructor.
+// -----------------------------------------------------------------------------
+CNsmlDsCtrlDCMOAdapter::~CNsmlDsCtrlDCMOAdapter()
+	{	
+	delete iProperty;
+	delete iDescription;
+	}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::CNsmlDsCtrlDCMOAdapter
+// Constructor.
+// -----------------------------------------------------------------------------
+CNsmlDsCtrlDCMOAdapter::CNsmlDsCtrlDCMOAdapter(TAny* aInitParams)
+:  iInitParams((CDCMOInterface::TDCMOInterfaceInitParams*)aInitParams)
+	{
+	// See ConstructL() for initialisation completion.
+	}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::ConstructL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+void CNsmlDsCtrlDCMOAdapter::ConstructL()
+    // Safely complete the initialization of the constructed object	
+	{	
+	// Set up the data to pass back
+	if(iInitParams->descriptor)
+	    {
+            iProperty = (iInitParams->descriptor)->AllocL();
+	    }
+	else
+	    {
+            iProperty = KNsmlDesktopSyncTitle().AllocL();
+	    }
+	iDescription = KNsmlDSDCMODescription().AllocL();
+	}
+
+
+// Implementation of CDCMOInterface
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL
+// - Get the Value of any attribute which is an integer
+// - If its existing attribute, then success is returned. Else Failure.
+// -----------------------------------------------------------------------------
+//
+TDCMOStatus CNsmlDsCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue)
+{
+	TDCMOStatus status(EDcmoSuccess);
+	TInt err(KErrNone);
+	
+	switch(aId)
+	{
+        case EGroup:              {
+            		                  aValue = ESoftware;
+            		              }
+            		              break;
+        case ENotifyUser:         {
+            		                  aValue = 0;
+            		              }
+								  break;
+        case EAttached:           { 
+								  status = EDcmoNotSupported;
+        		                  }
+								  break;
+        case EEnabled:	          {
+            						  CRepository * rep = CRepository::NewLC( KCRUidDSDCMOConfig );
+            						  err = rep->Get( KNsmlDesktopSync, aValue );
+            						  if(err != KErrNone)
+	   										 	{
+														status = EDcmoFail;
+	   										 	}
+            						  CleanupStack::PopAndDestroy( rep );
+            					  }
+            					  break;
+		case EDenyUserEnable:     {
+		                              aValue = 1; // DenyUserEnable
+		                          }
+						          break;
+        default:                  {
+                                      status = EDcmoNotFound;
+                                  }						          
+	}
+	
+	return status;
+}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL
+// - Get the Value of any attribute which is a string
+// - If its existing attribute, then success is returned. Else Failure.
+// -----------------------------------------------------------------------------
+//
+TDCMOStatus CNsmlDsCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue) 
+{
+	TDCMOStatus status(EDcmoSuccess);
+	switch(aId)
+	{
+		case EProperty: 	{
+		                        aStrValue = *iProperty;
+		                    }
+							break;
+		
+		case EDescription:	{
+                    		    aStrValue = *iDescription;
+                    		}
+						    break;
+		default:			{
+                    		    status = EDcmoNotFound;
+                    		}
+	}
+	return status;
+}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL
+// - Set the Value of any attribute which is an integer
+// - If its existing attribute, then success is returned. Else Failure.
+// -----------------------------------------------------------------------------
+//
+TDCMOStatus CNsmlDsCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue)
+{
+	TDCMOStatus status(EDcmoFail);
+	TInt err(KErrNone);
+	switch(aId)
+	{
+		case EDenyUserEnable:
+		case ENotifyUser:
+							 break;
+        case EEnable:	     {
+                                 CRepository * rep = CRepository::NewLC( KCRUidDSDCMOConfig );
+                                 rep->Set( KNsmlDesktopSync, aValue );
+                                 CleanupStack::PopAndDestroy( rep );
+                             }
+                             break;
+	}
+	if(err == KErrNone)
+	    {
+		    status = EDcmoSuccess;
+	    }
+	return status;
+}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL
+// - Set the Value of any attribute which is a string
+// - Here no Attribute comes as we dont have any String value to be set
+// -----------------------------------------------------------------------------
+//
+TDCMOStatus CNsmlDsCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL(TDCMONode /*aId */, const TDes& /*aStrValue */)
+{
+	// Nothing to do
+	return EDcmoNotSupported;	
+}
+
+// -----------------------------------------------------------------------------
+// CNsmlDsCtrlDCMOAdapter::GetLocalizedNameL
+// - Get localised name of the Plug-in
+// -----------------------------------------------------------------------------
+//
+void CNsmlDsCtrlDCMOAdapter::GetLocalizedNameL (HBufC*& aLocName)
+{
+	TFileName myFileName;
+	TParse parseObj;
+	parseObj.Set( KRuntimeResourceFileName(), &KDC_RESOURCE_FILES_DIR,NULL );
+	myFileName = parseObj.FullName();
+	CStringResourceReader* readPluginName = CStringResourceReader::NewL( myFileName );
+	CleanupStack::PushL(readPluginName);
+	TPtrC buf;
+	buf.Set(readPluginName->ReadResourceString(R_DM_RUN_TIME_VAR_DESKTOP_SYNC));
+	aLocName = buf.AllocL() ; 
+	CleanupStack::PopAndDestroy(readPluginName);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsdcmoadapter/src/nsmldsctrldcmodapterproxy.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DSCtrl plug-in adapter proxy for DCMO
+*
+*/
+
+// USER INCLUDES
+#include <e32std.h>
+#include <implementationproxy.h>
+
+#include "nsmldsctrldcmoadapter.h"
+
+// This is the implementation proxy table for the plugin-adapter
+// which is the entry point to the adapter
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+		IMPLEMENTATION_PROXY_ENTRY(0x20022FBD,	CNsmlDsCtrlDCMOAdapter::NewL),
+	};
+
+// Exported proxy for instantiation method resolution
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: bld file for contentcontrol component
+* 	This is part of contentcontrol.
+*
+*/
+
+
+// App layer
+// contentcontrol ADO
+
+//Componets:
+
+//omads
+#include "../omads/group/bld.inf"
+
+//contentctrl_plat
+#include "../contentctrl_plat/group/bld.inf"
+
+//ds dcmo adapter
+#include "../dsdcmoadapter/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/app/contentcontrol" >
+]>
+
+<SystemDefinition name="contentcontrol" schema="1.4.0">
+  <systemModel>
+    <layer name="app_layer">
+      <module name="contentcontrol">
+        <unit unitID="spdo.contentcontrol" mrp="" bldFile="&layer_real_source_path;/group" name="contentcontrol" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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 "../omadsappui/group/bld.inf"
+#include "../omadsextensions/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/group/ABLD.BAT	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+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 the License "Symbian Foundation License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\s60\app\contentcontrol\omads\OmaDsAppUi\AiwSyncProvider\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/group/AiwSyncProvider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Project specification file.
+*
+*/
+
+
+#include "../inc/AiwSyncProviderUids.hrh"
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET		AiwSyncProvider.dll
+TARGETTYPE	PLUGIN
+
+VENDORID VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+// uid for aiwsyncprovider 0x101F871F
+// #define KEComRecognitionUID2 0x10009D8D
+UID	0x10009D8D KAspSyncProviderDllUid
+
+
+USERINCLUDE	../inc
+
+// for AspSyncUtilApi.h
+USERINCLUDE     ../../../omadsappui/AspSyncUtil/inc
+
+// for nsmldssync.loc
+USERINCLUDE     ../../../omadsappui/AspSyncUtil/src
+
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE	/epoc32/include/ecom
+
+SOURCEPATH	../src
+SOURCE		AiwSyncProvider.cpp
+
+
+START RESOURCE  101F871F.rss
+TARGET          AiwSyncProvider
+TARGETPATH ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  AiwSyncProvider.rss
+HEADER
+TARGET          AiwSyncProvider
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+
+LIBRARY	euser.lib
+LIBRARY ServiceHandler.lib
+LIBRARY aspsyncutil.lib
+
+LIBRARY	efsrv.lib
+LIBRARY avkon.lib
+
+DEBUGLIBRARY flogger.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Provides information for building aiwsynprovider.
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+AiwSyncProvider.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/inc/AiwSyncProvider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: AIW provider plugin for data sync 
+*
+*/
+
+
+#ifndef AIWSYNCPROVIDER_H
+#define AIWSYNCPROVIDER_H
+
+//  INCLUDES
+#include <AiwServiceIfMenu.h>
+#include "AspSyncUtilApi.h"
+
+
+// CONSTANTS
+const TInt KBufSize = 128;
+const TInt KSyncApplicationId = 0;
+
+
+
+// CLASS DECLARATION
+
+
+/**
+* CAspSyncProvider
+*  
+* CAspSyncProvider implements CAiwServiceIfMenu interface to
+* allow synchronize functionality to be called via AIW.
+*
+* @lib syncservice.lib
+* @since Series 60 3.0
+*/
+class CAspSyncProvider : public CAiwServiceIfMenu 
+	{
+	public:
+        /**
+        * Two-phased constructor.
+        */
+		static CAspSyncProvider* NewL();
+
+        /**
+        * Destructor.
+        */
+		~CAspSyncProvider();
+
+	public:		
+        /**
+        * From the base class.
+		* Not implemented.
+        */
+		virtual void InitialiseL(MAiwNotifyCallback& aFrameworkCallback,
+			                     const RCriteriaArray& aInterest);
+
+        /**
+        * From the base class.
+		* Not implemented.
+        */
+		virtual void HandleServiceCmdL(const TInt& aCmdId,
+                                       const CAiwGenericParamList& aInParamList,
+                                       CAiwGenericParamList& aOutParamList,
+                                       TUint aCmdOptions = 0,
+                                       const MAiwNotifyCallback* aCallback = NULL);
+
+
+     	 /**
+         * Initialises menu pane by adding provider specific menu items.
+	     * The AIW Framework gives the parameters to be used in addition.
+	     * @param aMenuPane Menu pane handle
+	     * @param aIndex position of item where to add menu items.
+	     * @param aCascadeId ID of cascade menu item.
+	     * @param aInParamList input parameter list for provider's parameters checking
+	     */
+		virtual void InitializeMenuPaneL(CAiwMenuPane& aMenuPane,
+                                         TInt aIndex,
+                                         TInt aCascadeId,
+                                         const CAiwGenericParamList& aInParamList);
+
+        /**
+        * Handle a menu command invoked by the Handler.
+        * @param aMenuCmdId Command ID for the menu command,
+        *        defined by the provider when adding the menu commands.
+        * @param aInParamList Input parameters, could be empty list
+        * @param aOutParamList Output parameters, could be empty list
+        * @param aCmdOptions Options for the command, see KAiwCmdOpt* constants.
+        * @param aCallback callback if asynchronous command handling is wanted by consumer.
+        *    The provider may or may not support this, leaves with KErrNotSupported, it not.
+        */
+		virtual void HandleMenuCmdL(TInt aMenuCmdId,
+                                    const CAiwGenericParamList& aInParamList,
+                                    CAiwGenericParamList& aOutParamList,
+                                    TUint aCmdOptions = 0,
+                                    const MAiwNotifyCallback* aCallback = NULL);
+
+	private:
+        /**
+        * C++ default constructor.
+        */
+		CAspSyncProvider();
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+
+	
+	private:
+        /**
+		* Gets service command id from AIW parameter list.
+        * @param aInParamList AIW parameter list.
+		* @return Service command id.
+        */
+		TInt GetServiceCommandId(const CAiwGenericParamList& aInParamList);
+
+        /**
+		* Gets calling application id from AIW parameter list.
+        * @param aInParamList AIW parameter list.
+		* @return Application id.
+        */
+	    TInt GetApplicationId(const CAiwGenericParamList& aInParamList);
+
+        /**
+		* Gets sync file name from AIW parameter list.
+        * @param aInParamList AIW parameter list.
+        * @param aText File name.
+		* @return None.
+        */
+	    void GetFileName(const CAiwGenericParamList& aInParamList, TDes& aText);
+	    
+	private:
+        /**
+		* Displays information note.
+        * @param aText Information note text.
+		* @return None.
+        */
+	    void ShowInformationNoteL(const TDesC& aText);
+
+        /**
+		* Gets this plugin resource file name.
+        * @param aText Resource file name.
+		* @return None.
+        */
+		void GetResFileName(TDes& aText);
+		
+        /**
+		* Copies strings.
+        * @param aTarget.
+        * @param aSource.
+		* @return None.
+        */
+    	void StrCopy(TDes& aTarget, const TDesC& aSource);
+
+	private:
+	
+		// CSyncUtilApi handles synchronize operations. 
+		CSyncUtilApi* iSyncUtilApi;
+	};	
+
+#endif  // AIWSYNCPROVIDER_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/inc/AiwSyncProvider.rh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or 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: AIW sync plugin resource header
+*     
+*
+*/
+
+#ifndef _AIW_SYNCPROVIDER_RH
+#define _AIW_SYNCPROVIDER_RH
+
+enum
+	{
+	EAspSyncProviderCmdSynchronize = 1,
+	EAspSyncProviderCmdStart = 2,
+        EAspSyncProviderCmdSettings = 3,
+        EAspSyncProviderCmdRetrieve = 4
+	};
+
+
+#endif  // _AIW_SYNCPROVIDER_RH
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderDebug.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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: AIW sync plugin debug definition 
+*
+*/
+
+
+#ifndef _AIW_SYNCPROVIDER_DEBUG_H
+#define _AIW_SYNCPROVIDER_DEBUG_H
+
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"aiwsyncprovider.txt");
+_LIT(KLogDirFullName,"c:\\logs\\");
+_LIT(KLogDir,"aiwsyncprovider");
+
+// Declare the FPrint function
+inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // _AIW_SYNCPROVIDER_DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderUids.hrh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* 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: AIW sync plugin constants declaration
+*
+*/
+
+#ifndef _ASP_SYNPROVIDER_UIDS_HRH
+#define _ASP_SYNPROVIDER_UIDS_HRH
+
+//
+// Series60 Bulletin Board/Module Uids for Series60 - Part III
+// 270501663/101F871F AiwSyncProvider.dll
+// 270501664/101F8720 AspSyncUtil.dll
+//
+// 0x101F8721 AiwImplemetationUid
+
+// dll uid
+#define KAspSyncProviderDllUid   0x101F871F
+
+// aiw service class uid
+#define KAspSyncProviderIfaceUid 0x101F8652    // KAiwClassMenu (aiw	common.hrh)
+
+// aiw service command uid
+#define KAspSyncProviderImplUid  0x101F8721
+
+
+
+#endif  // _ASP_SYNPROVIDER_UIDS_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/inc/AiwSyncProviderUtil.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Utility classes.
+*
+*/
+
+
+#ifndef _AIW_SYNCPROVIDER_H
+#define _AIW_SYNCPROVIDER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <eikenv.h>
+
+
+// CONSTANTS
+
+const TInt KBufSize = 128;
+
+
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+* TAspUtil 
+* 
+*/
+class TUtil
+	{
+    public:
+        static void Panic(TInt aReason);
+		static void StrCopy(TDes& aTarget, const TDesC& aSource);
+		static TInt StrToInt(const TDesC& aText, TInt& aNum);
+		static void Print(const TDesC& aText);
+		static void Print(const TDesC& aText, TInt aNum);
+	};
+
+
+/**
+* TFileLog 
+* 
+*/
+class TFileLog
+    {
+    public:
+        static void Log(const TDesC& aText);
+		static void Log(const TDesC& aText1, const TDesC& aText2);
+		static void GetDateTime(TDes& aStr, TTime aTimeNum, TBool aDate, TBool aTime);
+		static void GetMediumType(TDes& aText, TInt aType);
+    };
+
+
+
+#endif  // _AIW_SYNCPROVIDER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/src/101F871F.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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: 
+*     Declares Base service API for all providers to implement in order to
+*     offer services to Application Interworking Framework.
+*
+*/
+
+
+#include <eikon.rh>
+#include "registryinfov2.rh" 
+#include "AiwSyncProvider.rh"
+#include "AiwSyncProviderUids.hrh"
+#include <AiwCommon.hrh>
+
+//
+// plugin resources are placed in z:/system/libs/plugins
+//
+// this resource is needed by CAiwServiceHandler/ECom for
+// finding out what plugins exist
+//
+//
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	resource_format_version = RESOURCE_FORMAT_VERSION_2; 
+	dll_uid = KAspSyncProviderDllUid;  // dll id
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+
+			// aiw service class (menu/base)
+			interface_uid = KAiwClassMenu;
+
+			implementations = 
+				{
+				  IMPLEMENTATION_INFO
+					{
+
+					// unique aiw service id that identifies the exact service 
+					implementation_uid = KAspSyncProviderImplUid;
+
+					version_no = 1;
+					display_name = "AIW Sync Provider";
+					default_data = "*";
+					opaque_data = KAiwCmdSynchronizeStr "||" KAiwCmdSynchronizeSelectedStr;
+					}
+				};
+			}
+
+		};
+	}
+
+
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/src/AiwSyncProvider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,483 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 <AiwMenu.h>
+#include <AiwGenericParam.hrh>
+#include <AiwCommon.hrh>
+
+#include <implementationproxy.h>
+
+#include <data_caging_path_literals.hrh>  // for resource and bitmap directories
+
+#include <AiwSyncProvider.rsg>
+#include "AiwSyncProvider.h"
+#include "AiwSyncProviderUids.hrh"
+#include "AiwSyncProvider.rh"
+#include "AiwSyncProviderDebug.h"
+
+#include <aknnotewrappers.h>    // CAknInformationNote
+
+
+
+
+_LIT( KResFileName, "z:AiwSyncProvider.rsc" );
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncProvider* CAspSyncProvider::NewL()
+	{
+    FLOG( _L("CAspSyncProvider::NewL START") );
+
+	CAspSyncProvider* self = new (ELeave) CAspSyncProvider();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    
+    FLOG( _L("CAspSyncProvider::NewL END") );
+	return self;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::Constructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncProvider::CAspSyncProvider()
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncProvider::~CAspSyncProvider()
+	{
+	FLOG( _L("~CAspSyncProvider START") );
+	
+	delete iSyncUtilApi;
+	
+	FLOG( _L("~CAspSyncProvider END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::ConstructL()
+    {
+    FLOG( _L("CAspSyncProvider::ConstructL START") );
+ 
+	iSyncUtilApi = CSyncUtilApi::NewL();
+
+    FLOG( _L("CAspSyncProvider::ConstructL END") );
+    } 
+
+
+ 
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::InitialiseL (from CAiwServiceIfBase)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::InitialiseL(MAiwNotifyCallback& /*aFrameworkCallback*/,
+	    						   const RCriteriaArray& /*aInterest*/)
+	{
+	// Not implemented
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::HandleServiceCmdL (from CAiwServiceIfBase)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::HandleServiceCmdL(const TInt& aCmdId,
+                                         const CAiwGenericParamList& aInParamList,
+                                         CAiwGenericParamList& /*aOutParamList*/,
+                                         TUint /*aCmdOptions*/,
+                                         const MAiwNotifyCallback* /*aCallback*/)
+	{
+	TInt jobId = KErrNotFound;
+	TInt info1 = KErrNotFound;
+	TBuf<KBufSize> info2(KNullDesC);
+	TInt applicationId = GetApplicationId(aInParamList);
+
+	if (aCmdId != KAiwCmdSynchronize)
+		{
+		return;
+		}
+		
+   	if (applicationId == EGenericParamMessageItemEMail)
+		{
+	    GetFileName(aInParamList, info2);
+	    if (info2.Length() == 0)
+	    	{
+	    	FLOG( _L("### mailbox name not found ###") );
+	    	return; // email sync requires mailbox name
+	    	}
+	    info1 = EGenericParamMessageItemEMail;
+		}
+		
+	iSyncUtilApi->SynchronizeL(applicationId, jobId, info1, info2); 
+		
+    
+        
+    // R&D solution: Remove constness.
+    //MAiwNotifyCallback* callback = 
+    //    const_cast< MAiwNotifyCallback* >(aCallback);
+
+	//CAiwGenericParamList* dummyParamList = NULL;
+	
+	//callback->HandleNotifyL(0, 0, *dummyParamList, *dummyParamList);
+	}
+
+
+
+ 
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::InitializeMenuPaneL (from CAiwServiceIfMenu)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::InitializeMenuPaneL(CAiwMenuPane& aMenuPane,
+											  TInt aIndex,
+											  TInt /*aCascadeId*/,
+											  const CAiwGenericParamList& aInParamList)
+	{
+	FLOG( _L("CAspSyncProvider::InitializeMenuPaneL START") );
+	
+	
+	TFileName resFile;
+	GetResFileName(resFile);
+	
+	FTRACE( RDebug::Print(_L("resfile= '%S'  index= %d"), &resFile, aIndex) );
+
+    TInt serviceCommand = GetServiceCommandId(aInParamList);
+    
+    if (serviceCommand == KErrNotFound)
+    	{
+    	FLOG( _L("### service command not found ###") );
+    	FLOG( _L("CAspSyncProvider::InitializeMenuPaneL END") );
+    	return;
+    	}
+    
+    if (serviceCommand == KAiwCmdSynchronizeSelected)
+    	{
+        TRAPD(ignoreError, aMenuPane.AddMenuItemsL(resFile, R_ASPSYNCPROVIDER_MENU_4, KAiwCmdSynchronizeSelected, aIndex));
+        if (ignoreError != KErrNone)
+        	{
+        	FTRACE( RDebug::Print(_L("### CAiwMenuPane::AddMenuItemsL failed (%d) ###"), ignoreError) );
+        	}
+       	}
+       	
+    if (serviceCommand == KAiwCmdSynchronize)
+    	{
+    	TRAPD(ignoreError, aMenuPane.AddMenuItemsL(resFile, R_ASPSYNCPROVIDER_SUBMENU, KAiwCmdSynchronize, aIndex));
+        if (ignoreError != KErrNone)
+        	{
+        	FTRACE( RDebug::Print(_L("### CAiwMenuPane::AddMenuItemsL failed (%d) ###"), ignoreError) );
+        	}
+    	}
+    	
+    FLOG( _L("CAspSyncProvider::InitializeMenuPaneL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::HandleMenuCmdL (from CAiwServiceIfMenu)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::HandleMenuCmdL(TInt aMenuCmdId, 
+                                      const CAiwGenericParamList& aInParamList,
+                                      CAiwGenericParamList& /*aOutParamList*/,
+                                      TUint /*aCmdOptions*/,
+                                      const MAiwNotifyCallback* /*aCallback*/)
+	{
+	FLOG( _L("CAspSyncProvider::HandleMenuCmdL START") );
+    
+	TInt jobId = KErrNotFound;
+	TInt info1 = KErrNotFound;
+	TBuf<KBufSize> info2(KNullDesC);
+	TInt applicationId = GetApplicationId(aInParamList);
+	
+	if (applicationId == KErrNotFound)
+		{
+    	FLOG(_L("### application id not found ###"));
+		return; // must have consumer app id
+		}
+	
+	switch (aMenuCmdId)
+		{
+		case EAspSyncProviderCmdStart:
+			if (applicationId == EGenericParamMessageItemEMail)
+				{
+			    GetFileName(aInParamList, info2);
+			    if (info2.Length() == 0)
+			    	{
+			    	FLOG( _L("### mailbox name not found ###") );
+			    	return; // email sync requires mailbox name
+			    	}
+				}
+		
+			iSyncUtilApi->SynchronizeL(applicationId, jobId, info1, info2); 
+            break;
+
+		case EAspSyncProviderCmdSettings:
+		    iSyncUtilApi->ShowSettingsL(applicationId, info1, info2);
+            break;
+            
+		case EAspSyncProviderCmdRetrieve:
+		    applicationId = EGenericParamMessageItemEMail;
+		    info1 = KAiwCmdSynchronizeSelected;
+		    GetFileName(aInParamList, info2);
+		    if (info2.Length() == 0)
+		    	{
+		    	FLOG( _L("### mailbox name not found ###") );
+		    	return; // email sync requires mailbox name
+		    	}
+		    
+		    iSyncUtilApi->SynchronizeL(applicationId, jobId, info1, info2);
+            break; 
+            
+		default:
+		    FTRACE( RDebug::Print(_L("### unknown menu command (%d) ###"), aMenuCmdId) );
+			break;
+		}
+		
+	FLOG( _L("CAspSyncProvider::HandleMenuCmdL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::GetApplicationIdL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSyncProvider::GetApplicationId(const CAiwGenericParamList& aInParamList)
+	{
+	_LIT(KSyncApplicationName, "sync");
+	
+	TInt index = 0;
+	
+	const TAiwGenericParam* param = aInParamList.FindFirst(index, EGenericParamContactItem);
+	if (index >= 0)
+		{
+    	return EGenericParamContactItem;
+		}
+		
+	index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamCalendarItem);
+	if (index >= 0)
+		{
+    	return EGenericParamCalendarItem;
+		}
+
+    index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamMessageItemEMail);
+	if (index >= 0)
+		{
+    	return EGenericParamMessageItemEMail;
+		}
+		
+	index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamNoteItem);
+	if (index >= 0)
+		{
+    	return EGenericParamNoteItem;
+		}
+   
+    index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamMessageItemMMS);
+	if (index >= 0)
+		{
+    	return EGenericParamMessageItemMMS;
+		}
+
+    index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamEmailAddress);
+	if (index >= 0)
+		{
+    	return EGenericParamEmailAddress;
+		}
+
+	// this is for starting Sync application - not used at the moment
+	index = 0;
+	param = aInParamList.FindFirst(index, EGenericParamApplication);
+	if (index >= 0)
+		{
+   	    TPtrC ptr;
+    	const TAiwVariant& val = param->Value();
+	    if (val.Get(ptr))
+		    {
+		    if (ptr.Compare(KSyncApplicationName) == 0)
+		    	{
+		    	return KSyncApplicationId;
+		    	}
+		    }
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::GetFileName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::GetFileName(const CAiwGenericParamList& aInParamList, TDes& aText)
+	{
+	aText = KNullDesC;
+	TInt index = 0;
+	const TAiwGenericParam* param = aInParamList.FindFirst(index, EGenericParamMessageItemMbox);
+	if (index < 0)
+		{
+		return;
+		}
+
+    TPtrC ptr;
+	const TAiwVariant& val = param->Value();
+	if (!val.Get(ptr))
+		{
+		FLOG(_L("### CAspSyncProvider::GetFileName: param value not found ###"));
+		return;
+		}
+	
+	StrCopy(aText, ptr);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::GetServiceCommandId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSyncProvider::GetServiceCommandId(const CAiwGenericParamList& aInParamList)
+	{
+	TInt index = 0;
+	const TAiwGenericParam* param = aInParamList.FindFirst(index, EGenericParamServiceCommand);
+	if (index < 0)
+		{
+    	return KErrNotFound;
+		}
+
+    TInt32 num = 0;
+	const TAiwVariant& val = param->Value();
+	if (!val.Get(num))
+		{
+		FLOG(_L("CAspSyncProvider::GetServiceCommandId: param value not found"));
+		return KErrNotFound;
+		}
+	return num;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncProvider::GetResFileName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncProvider::GetResFileName(TDes& aText)
+	{
+	TParse parse;
+	parse.Set(KResFileName, &KDC_RESOURCE_FILES_DIR, NULL);
+	StrCopy(aText, parse.FullName());
+	}
+
+
+// -------------------------------------------------------------------------------
+// CAspSyncProvider::StrCopy
+//
+// String copy with lenght check.
+// -------------------------------------------------------------------------------
+//
+void CAspSyncProvider::StrCopy(TDes& aTarget, const TDesC& aSource)
+    {
+	TInt len = aTarget.MaxLength();
+    if(len < aSource.Length()) 
+	    {
+		aTarget.Copy(aSource.Left(len));
+		return;
+	    }
+	aTarget.Copy(aSource);
+    }
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowInformationNoteL
+//
+//------------------------------------------------------------------------------
+//
+void CAspSyncProvider::ShowInformationNoteL(const TDesC& aText)
+	{
+	CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote(ETrue);
+	queryDialog->ExecuteLD(aText);
+	}
+
+
+
+
+
+//
+// Rest of the file is for ECom initialization. 
+//
+
+
+
+
+// -----------------------------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+//
+// -----------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KAspSyncProviderImplUid,	CAspSyncProvider::NewL)
+    };
+
+
+// -----------------------------------------------------------------------------
+// Exported proxy for instantiation method resolution
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+    return ImplementationTable;
+}
+
+
+
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AiwSyncProvider/src/AiwSyncProvider.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 <eikon.rh>
+#include "registryinfov2.rh" 
+#include "AiwSyncProvider.rh"
+#include<NSmlDSSync.loc>
+#include "AiwCommon.hrh"
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+
+
+
+//  RESOURCE IDENTIFIER
+//NAME MTMU
+
+NAME ASPP
+
+RESOURCE RSS_SIGNATURE { }
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_menu
+{
+    items=
+		{
+		MENU_ITEM { cascade=r_aspsyncprovider_submenu; command=EAspSyncProviderCmdSynchronize; txt=qtn_ds_options_sync; }
+		};
+}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_menu_2
+{
+    items=
+		{
+		MENU_ITEM { cascade=r_aspsyncprovider_submenu_2; command=EAspSyncProviderCmdSynchronize; txt=qtn_ds_options_sync; }
+		};
+}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_menu_3
+{
+    items=
+		{
+		MENU_ITEM { cascade=r_aspsyncprovider_submenu_3; command=EAspSyncProviderCmdSynchronize; txt=qtn_ds_options_sync; }
+		};
+}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_menu_4
+	{
+	items =
+		{
+		MENU_ITEM { command=EAspSyncProviderCmdRetrieve; txt=qtn_ds_options_sync_retrieve; }
+		};
+	}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_submenu
+	{
+	items =
+		{
+		MENU_ITEM { command=AIW_SUBMENU_TITLE; txt=qtn_ds_options_sync; },
+		MENU_ITEM { command=EAspSyncProviderCmdStart;	 txt=qtn_ds_options_sync_start; },
+		MENU_ITEM { command=EAspSyncProviderCmdSettings; txt=qtn_ds_options_sync_settings; }
+		};
+	}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_submenu_2
+	{
+	items =
+		{
+		MENU_ITEM { command=AIW_SUBMENU_TITLE; txt=qtn_ds_options_sync; },
+		MENU_ITEM { command=EAspSyncProviderCmdStart;	 txt=qtn_ds_options_sync_start; }
+		};
+	}
+
+
+RESOURCE MENU_PANE r_aspsyncprovider_submenu_3
+	{
+	items =
+		{
+		MENU_ITEM { command=AIW_SUBMENU_TITLE; txt=qtn_ds_options_sync; },
+		MENU_ITEM { command=EAspSyncProviderCmdSettings; txt=qtn_ds_options_sync_settings; }
+		};
+	}
+
+
+
+
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/data/AspPreSyncDefault.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <ecom/registryinfov2.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+{
+    resource_format_version = RESOURCE_FORMAT_VERSION_2; 
+	// UID for the DLL
+	dll_uid = 0x2001955E;
+	
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			
+			// UID of interface that is implemented
+			interface_uid = 0x2001955C;
+			
+			implementations = 
+				{
+				
+				// Info for all implementations					
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2001955D;
+					version_no         = 1;
+					display_name       = "DEFAULT"; 
+					default_data       = "";    
+					opaque_data        = ""; 
+					}
+					
+				};
+			}
+		};
+}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/group/ABLD.BAT	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+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 the License "Symbian Foundation License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\s60\app\contentcontrol\omads\OmaDsAppUi\AspPreSyncPlugin\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/group/AspPreSyncDefault.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c)  Nokia Corporation and/or 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 <platform_paths.hrh>
+#include <defaultcaps.hrh>
+
+
+TARGET AspPreSyncDefault.dll
+TARGETTYPE PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID 0x10009D8D 0x2001955E
+//SECUREID 0xE01F614F
+
+
+VENDORID VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+START  RESOURCE ../data/AspPreSyncDefault.rss
+TARGET          AspPreSyncDefault.rsc
+END
+
+SOURCEPATH      ../src
+SOURCE      proxy.cpp 
+SOURCE      AspPreSyncDefaultPlugin.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE      ../../AspSyncUtil/inc
+APP_LAYER_SYSTEMINCLUDE   
+
+
+LIBRARY avkon.lib
+LIBRARY commonengine.lib //For String loader
+LIBRARY	centralrepository.lib //For Centralrepository
+LIBRARY euser.lib ECom.lib
+LIBRARY cone.lib                  // Symbian OS framework libraries
+LIBRARY bafl.lib                            // Basic Application Framework Library
+LIBRARY charconv.lib                        // Character conversion library
+LIBRARY eikcoctl.lib eiksrv.lib             // Eikon libraries
+LIBRARY eikdlg.lib                          // Eikon libraries
+LIBRARY eikcore.lib                         // Library for eikonEnv static functions (BringForwards)
+LIBRARY eiksrvui.lib                        // Eikon server ui (for suppressing app -key)
+LIBRARY esock.lib                           // Sockects library for host resolver
+LIBRARY AknSkins.lib                        // Skinned icons
+LIBRARY aknNotifierWrapper.lib
+LIBRARY ConnMon.lib
+LIBRARY aknnotify.lib efsrv.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+
+PRJ_PLATFORMS
+
+
+PRJ_MMPFILES
+    AspPreSyncDefault.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/inc/AspPreSyncDefaultPlugin.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the default plugin which will be called before starting
+*                the snchronization.
+*
+*/
+
+
+#ifndef ASPPRESYNCDEFAULTPLUGIN_H
+#define ASPPRESYNCDEFAULTPLUGIN_H
+
+// INCLUDES
+#include <e32cmn.h>
+#include <s32mem.h>
+#include <e32hashtab.h>
+#include <e32property.h>
+#include <centralrepository.h>
+#include <ConeResLoader.h> 
+#include <bautils.h>
+#include <eikenv.h>
+#include "CPreSyncPlugin.h"
+#include <AknQueryDialog.h>
+
+//  INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+class CAknGlobalMsgQuery;
+
+class CRoamingCheck : public CBase
+	{
+	public:
+    /*!
+    @function NewL
+    */
+    static CRoamingCheck* NewL();
+    
+      /*!
+      @function NewLC
+      */
+    static CRoamingCheck* NewLC();
+    
+      /*!
+      @function ConstructL
+      
+      @discussion Perform the second phase construction of a CRoamingCheck object
+      this needs to be public 
+      */
+     void ConstructL();
+
+      /*!
+      @function CRoamingCheck
+      
+      @discussion Perform the first phase of two phase construction.
+      This needs to be public 
+      */
+     CRoamingCheck(CEikonEnv* aEikEnv);
+     /*!
+      @function ~CRoamingCheck
+      @discussion Destroy the object and release all memory objects
+      */
+    ~CRoamingCheck();
+    void ShowGlobalNoteL(TInt aSoftKeyId, 
+              const HBufC* aMessage, TInt& status);
+	private:
+    CAknGlobalMsgQuery* iGlobalNote;
+    CEikonEnv* iEnv;
+    RConeResourceLoader iResLoader;
+    };
+
+
+// FORWARD DECLARATION
+
+// CLASS DECLARATION
+class CPreSyncDefaultPlugin : public CPreSyncPlugin
+{
+	public: 
+	
+		/**
+		* Two phase construction
+		*/
+		static CPreSyncDefaultPlugin* NewL();
+
+		/**
+		* Destructor
+		*/
+		virtual ~CPreSyncDefaultPlugin();
+
+
+     public:
+
+         /**
+          * Function:    IsSupported
+          *
+          */
+         virtual TBool IsSupported();
+         
+         /**
+          * Function:    CanSync
+          *
+          */
+         virtual TBool CanSyncL();
+         
+         /**
+          * Function:    SetProfile  
+          *
+          */
+         virtual TBool SetProfile(const TSmlProfileId& aProfileId);
+         
+         /**
+          * Function:    SyncNow  
+          *
+          */   
+         virtual TInt SyncNow(MSyncExtObserver* aObserver);
+
+		
+	private:
+	    void  ReadRepositoryL(TInt aKey, TInt& aValue);
+	    
+	    
+		/**
+		* Constructor
+		*/
+		CPreSyncDefaultPlugin();
+
+		/**
+		* 2nd phase construtor
+		*/
+		void ConstructL();
+		
+	private:
+	    TSmlProfileId iSyncProfileId;
+};
+	
+
+#endif // ASPPRESYNCDEFAULTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/src/AspPreSyncDefaultPlugin.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,286 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implements the default plugin
+*
+*/
+
+
+// INCLUDES
+#include "AspPreSyncDefaultPlugin.h"
+
+#include <ConeResLoader.h> 
+#include <bautils.h>
+#include <eikenv.h>
+#include <AknGlobalNote.h>
+#include <StringLoader.h>
+#include <avkon.rsg>
+#include <avkon.hrh>
+#include <AknGlobalMsgQuery.h>
+#include <rconnmon.h>
+
+
+#include <AknQueryDialog.h>
+#include <AspSyncUtil.rsg>
+#include <StringLoader.h> 
+#include <aspdefines.h> //For enum TRoamingSettings
+#include <centralrepository.h> //For central Repository
+
+// ============================== MEMBER FUNCTIONS ============================
+
+_LIT(KDC_RESOURCE_FILES_DIR,"\\resource\\");
+_LIT(KResourceFile,        "z:AspSyncUtil.rsc");
+
+
+// -------------------------------------------------------------------------------
+// CRoamingCheck::NewL
+//
+// 
+// -------------------------------------------------------------------------------
+//
+CRoamingCheck* CRoamingCheck::NewL()
+    {
+    CRoamingCheck* self = CRoamingCheck::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -------------------------------------------------------------------------------
+// CRoamingCheck::NewLC
+//
+// 
+// -------------------------------------------------------------------------------
+//
+CRoamingCheck* CRoamingCheck::NewLC()
+    {
+    CRoamingCheck* self = new (ELeave) CRoamingCheck(CEikonEnv::Static());
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// -------------------------------------------------------------------------------
+// CRoamingCheck::CRoamingCheck
+//
+// 
+// -------------------------------------------------------------------------------
+//
+CRoamingCheck::CRoamingCheck(CEikonEnv* aEikEnv) 
+        : iEnv(aEikEnv),iResLoader (*aEikEnv)
+	{
+	}
+
+// -------------------------------------------------------------------------------
+// CRoamingCheck::~CRoamingCheck
+//
+// 
+// -------------------------------------------------------------------------------
+//
+CRoamingCheck::~CRoamingCheck()
+	{    
+    iResLoader.Close();
+	delete iGlobalNote;
+	
+	}
+
+// -------------------------------------------------------------------------------
+// CRoamingCheck::ConstructL
+//
+// 
+// -------------------------------------------------------------------------------
+//
+void CRoamingCheck::ConstructL()
+    {    
+    iGlobalNote = CAknGlobalMsgQuery::NewL();
+    
+    // Resolve resource file path
+    TFileName fileName(0);
+    TParse parse;
+    parse.Set(KResourceFile,&KDC_RESOURCE_FILES_DIR,NULL);
+    fileName.Append( parse.FullName() );
+    // Get language of resource file
+    BaflUtils::NearestLanguageFile(iEnv->FsSession(), fileName );
+    // Open resource file
+    TInt err = iResLoader.Open( fileName );            
+  	}
+    
+// -------------------------------------------------------------------------------
+// CRoamingCheck::ShowGlobalNoteL
+//
+// 
+// -------------------------------------------------------------------------------
+//
+void CRoamingCheck::ShowGlobalNoteL(TInt aSoftKeyId, 
+                  const HBufC* aMessage, TInt& status)
+	{
+    iGlobalNote->CancelMsgQuery();
+	TRequestStatus GlobalNotestatus = KErrNone;
+	iGlobalNote->ShowMsgQueryL( GlobalNotestatus, *aMessage, aSoftKeyId, KNullDesC , KNullDesC ); 
+	User::WaitForRequest(GlobalNotestatus);
+	iGlobalNote->CancelMsgQuery();
+	status=GlobalNotestatus.Int();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::NewL
+// Two Phase Construction
+// ----------------------------------------------------------------------------
+CPreSyncDefaultPlugin* CPreSyncDefaultPlugin::NewL()
+{
+	CPreSyncDefaultPlugin* self = new ( ELeave ) CPreSyncDefaultPlugin();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+
+	return self;
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::CPreSyncDefaultPlugin
+// Two Phase Construction
+// ----------------------------------------------------------------------------
+CPreSyncDefaultPlugin::CPreSyncDefaultPlugin()
+{		
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::ConstructL
+// Two Phase Construction
+// ----------------------------------------------------------------------------
+void CPreSyncDefaultPlugin::ConstructL()
+{
+} 
+	
+	
+// ----------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::~CPreSyncDefaultPlugin
+// Destructor
+// ----------------------------------------------------------------------------
+CPreSyncDefaultPlugin::~CPreSyncDefaultPlugin()
+{
+}
+
+
+// -------------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::IsSupported
+//
+// 
+// -------------------------------------------------------------------------------
+//
+TBool CPreSyncDefaultPlugin::IsSupported()
+    {
+    return ETrue;
+    }
+
+// -------------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::CanSyncL
+//
+// 
+// -------------------------------------------------------------------------------
+//
+TBool CPreSyncDefaultPlugin::CanSyncL()
+    {
+    TBool ret = ETrue;
+    TInt value(0);
+    
+    ReadRepositoryL(KNSmlRoamingSettingKey, value);    
+    CRoamingCheck* roamingCheck = CRoamingCheck::NewL();
+    CleanupStack::PushL(roamingCheck);
+    
+	HBufC* hBuf = NULL;
+	CAknQueryDialog* queryDialog = NULL;
+    
+    switch(value)
+        {
+        case ERoamingSettingAlwaysAsk:
+			hBuf = StringLoader::LoadLC(R_ASP_NOTE_NETWORK_CONFIRMATION);
+			queryDialog = new (ELeave) CAknQueryDialog;
+			ret = queryDialog->ExecuteLD(R_ASP_ROAMING_CONFIRMATION_QUERY, hBuf->Des());
+			if(ret)
+				{
+				ret = ETrue;
+				}
+			else
+				{
+				ret = EFalse;
+				}
+			CleanupStack::PopAndDestroy(hBuf);
+            break;
+        case ERoamingSettingAlwaysAllow:
+            break;
+        case ERoamingSettingNeverAllow:
+     		hBuf = StringLoader::LoadLC(R_ASP_NOTE_NETWORK_NOT_ALLOWED);
+			queryDialog = new (ELeave) CAknQueryDialog;
+			ret = queryDialog->ExecuteLD(R_ASP_INFORMATION_QUERY, hBuf->Des());
+			CleanupStack::PopAndDestroy(hBuf);
+
+            ret = EFalse;
+            break;
+        case ERoamingSettingBlock:
+			hBuf = StringLoader::LoadLC(R_ASP_NOTE_NOT_HOME_NETWORK);
+			queryDialog = new (ELeave) CAknQueryDialog;
+			ret = queryDialog->ExecuteLD(R_ASP_INFORMATION_QUERY, hBuf->Des());
+			CleanupStack::PopAndDestroy(hBuf);
+
+            ret = EFalse;
+            break;
+        default:
+            break;
+        }
+    
+    CleanupStack::PopAndDestroy(roamingCheck);
+    return ret;
+    }
+
+// -------------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::ReadRepositoryL
+//
+// 
+// -------------------------------------------------------------------------------
+//
+void CPreSyncDefaultPlugin::ReadRepositoryL(TInt aKey, TInt& aValue)
+    {
+    CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp);
+    TInt err = rep->Get(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+    }
+
+
+// -------------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::SetProfile
+//
+// 
+// -------------------------------------------------------------------------------
+//
+TBool CPreSyncDefaultPlugin::SetProfile(const TSmlProfileId& aProfileId)
+    {
+    iSyncProfileId = aProfileId;
+    return ETrue;
+    }
+
+// -------------------------------------------------------------------------------
+// CPreSyncDefaultPlugin::SyncNow
+//
+// 
+// -------------------------------------------------------------------------------
+//
+TInt CPreSyncDefaultPlugin::SyncNow(MSyncExtObserver* aObserver)
+    {
+    TInt retValue = 1;
+    return retValue;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspPreSyncPlugin/src/proxy.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "AspPreSyncDefaultPlugin.h"
+
+// Map the interface implementation UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] =
+    {
+            IMPLEMENTATION_PROXY_ENTRY(0x2001955D,  CPreSyncDefaultPlugin::NewL)
+    };
+
+
+// Exported proxy for instantiation method resolution.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+    TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspScheduleHandler/group/aspschedulehandler.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+// 0x101F99FA  uid for AspScheduleHandler
+// 0x101F99FB  uid for repository id
+// 0x101F99FC
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          	AspScheduleHandler.exe
+TARGETTYPE		EXE
+UID 0x100039CE 0x101F99FA
+
+VENDORID VID_DEFAULT
+
+CAPABILITY  CAP_APPLICATION
+
+
+SOURCEPATH ../src
+
+SOURCE				aspschedulehandler.cpp
+
+USERINCLUDE . 
+USERINCLUDE ../inc
+
+// for AspSyncUtilApi.h
+USERINCLUDE     ../../../omadsappui/AspSyncUtil/inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY	euser.lib
+LIBRARY	efsrv.lib
+LIBRARY	estor.lib
+LIBRARY	schsvr.lib
+LIBRARY aspsyncutil.lib
+DEBUGLIBRARY flogger.lib
+
+
+//VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspScheduleHandler/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+
+
+aspschedulehandler.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspScheduleHandler/inc/AspDebug.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 NSMLDSSYNC__DEBUG_H
+#define NSMLDSSYNC__DEBUG_H
+
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"smlsync.txt");
+_LIT(KLogDirFullName,"c:\\logs\\");
+_LIT(KLogDir,"smlsync");
+
+
+// Declare the FPrint function
+inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+//#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // NSMLDSSYNC__DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspScheduleHandler/src/aspschedulehandler.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 <schinfo.h>
+#include <schtask.h>
+#include <s32file.h>
+#include <e32math.h>
+#include <e32cons.h>
+
+#include "AspSyncUtilApi.h"
+#include "AspDebug.h"
+
+
+
+// -----------------------------------------------------------------------------
+// SynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+LOCAL_D void SynchronizeL(RFile& aTaskFile)
+	{
+	CSyncUtilApi* syncUtilApi = CSyncUtilApi::NewL();
+	CleanupStack::PushL(syncUtilApi);
+	
+	syncUtilApi->SynchronizeL(aTaskFile);
+	
+	CleanupStack::PopAndDestroy(syncUtilApi);
+	}
+
+
+// -----------------------------------------------------------------------------
+// ExecuteL
+//
+// -----------------------------------------------------------------------------
+//
+LOCAL_D TInt ExecuteL()
+	{
+	TInt err = KErrNoMemory;
+		
+	RFile file;
+		
+	// Adopt the task file from the Task Scheduler
+	err = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(),
+									TScheduledTaskFile::FileHandleIndex());
+	User::LeaveIfError(err);
+	
+	TRAP(err, SynchronizeL(file));
+	
+	file.Close();
+	
+	User::LeaveIfError(err);		
+	return err;
+	}
+
+
+// -----------------------------------------------------------------------------
+// Execute
+//
+// -----------------------------------------------------------------------------
+//
+LOCAL_D TInt Execute()
+	{
+	TInt err = KErrNoMemory;
+	
+	// construct and install active scheduler
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (!scheduler)
+		{
+		return err;
+		}
+	CActiveScheduler::Install(scheduler);
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	
+	if (cleanupStack)
+		{
+        TRAP(err, ExecuteL());
+		delete cleanupStack;
+		}
+
+    delete scheduler;
+    
+	return err;
+	}
+
+
+// -----------------------------------------------------------------------------
+// E32Main
+//
+// -----------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+	{
+	return Execute();
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/BWINS/AspSyncUtilu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,6 @@
+EXPORTS
+	?NewL@CSyncUtilApi@@SAPAV1@XZ @ 1 NONAME ; class CSyncUtilApi * CSyncUtilApi::NewL(void)
+	?ShowSettingsL@CSyncUtilApi@@QAEXHHAAVTDes16@@@Z @ 2 NONAME ; void CSyncUtilApi::ShowSettingsL(int, int, class TDes16 &)
+	?SynchronizeL@CSyncUtilApi@@QAEXAAVRFile@@@Z @ 3 NONAME ; void CSyncUtilApi::SynchronizeL(class RFile &)
+	?SynchronizeL@CSyncUtilApi@@QAEXHHHAAVTDes16@@@Z @ 4 NONAME ; void CSyncUtilApi::SynchronizeL(int, int, int, class TDes16 &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/eabi/AspSyncUtilu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN12CSyncUtilApi12SynchronizeLER5RFile @ 1 NONAME
+	_ZN12CSyncUtilApi12SynchronizeLEiiiR6TDes16 @ 2 NONAME
+	_ZN12CSyncUtilApi13ShowSettingsLEiiR6TDes16 @ 3 NONAME
+	_ZN12CSyncUtilApi4NewLEv @ 4 NONAME
+	_ZTI12CSyncUtilApi @ 5 NONAME DATA 12 ; #<TI>#
+	_ZTV12CSyncUtilApi @ 6 NONAME DATA 20 ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/group/ABLD.BAT	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+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 the License "Symbian Foundation License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\s60\app\contentcontrol\omads\OmaDsAppUi\AspSyncUtil\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/group/AspSyncUtil.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Project specification file.
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+#include <bldvariant.hrh>
+
+TARGET        AspSyncUtil.dll
+TARGETTYPE    dll
+
+// 0x101F8720 AspSyncUtil.dll
+UID	0x10009D8D 0x101F8720
+
+VENDORID VID_DEFAULT
+
+CAPABILITY CAP_GENERAL_DLL
+
+
+USERINCLUDE	../inc
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE	/epoc32/include/ecom
+
+
+SOURCEPATH	../src
+SOURCE		AspSyncUtilApi.cpp
+SOURCE		AspSyncHandler.cpp
+SOURCE		AspUtil.cpp
+SOURCE		AspState.cpp
+SOURCE		AspResHandler.cpp
+SOURCE		AspDbNotifier.cpp
+SOURCE		AspSyncUtil.cpp
+SOURCE		AspProfile.cpp
+SOURCE		AspProgressDialog.cpp
+SOURCE		AspContentDialog.cpp
+SOURCE		AspSettingDialog.cpp
+SOURCE		AspProfileDialog.cpp
+SOURCE		AspDialogUtil.cpp
+SOURCE		AspProfileWizard.cpp
+SOURCE		AspProfileWizardDialog.cpp
+SOURCE		AspLogDialog.cpp
+SOURCE		AspScheduleDialog.cpp
+SOURCE		AspSchedule.cpp
+SOURCE          AspSettingViewDialog.cpp
+SOURCE          AspAutoSyncHandler.cpp
+SOURCE		AspAdvanceSettingsDialog.cpp AspPreSyncPluginInterface.cpp
+
+
+//SOURCE		AspProfileSelectionDialog.cpp
+//SOURCE		AspFilterDialog.cpp
+//SOURCE		AspFilter.cpp
+
+// other resources must be placed in z:/system/data
+START RESOURCE ../src/AspSyncUtil.rss
+TARGETPATH      RESOURCE_FILES_DIR
+HEADER
+LANGUAGE_IDS
+END
+
+
+LIBRARY	euser.lib
+LIBRARY cone.lib 
+
+LIBRARY eikcore.lib 
+LIBRARY avkon.lib
+LIBRARY eikctl.lib
+LIBRARY ecom.lib
+LIBRARY eikdlg.lib
+LIBRARY bafl.lib
+LIBRARY commonengine.lib
+LIBRARY eikcoctl.lib
+LIBRARY estor.lib
+LIBRARY edbms.lib
+LIBRARY AknSkins.lib
+LIBRARY aknicon.lib
+LIBRARY fbscli.lib
+LIBRARY egul.lib
+LIBRARY etext.lib
+LIBRARY gdi.lib
+LIBRARY cdlengine.lib
+LIBRARY AknLayout2Scalable.lib
+
+
+LIBRARY	FeatMgr.lib
+LIBRARY commdb.lib
+LIBRARY apengine.lib
+LIBRARY	efsrv.lib
+LIBRARY commondialogs.lib
+LIBRARY	hlplch.lib
+LIBRARY	apsettingshandlerui.lib
+LIBRARY ConnectionUiUtilities.lib
+LIBRARY Muiu.lib
+LIBRARY ws32.lib
+
+LIBRARY	schsvr.lib
+LIBRARY	centralrepository.lib
+LIBRARY	connmon.lib
+
+LIBRARY	cmmanager.lib
+//LIBRARY SmlClient.lib
+LIBRARY SyncMLClientAPI.lib
+//LIBRARY syncmldatafilter.lib
+LIBRARY nsmltransporthandler.lib
+
+LIBRARY	 centralrepository.lib
+
+//#ifdef __SAP_POLICY_MANAGEMENT
+LIBRARY	policyengine.lib
+//#endif
+
+
+//LIBRARY nsmlxml.lib
+//LIBRARY nsmlwbxml.lib
+//LIBRARY nsmltransport.lib
+//LIBRARY nsmlhistorylog.lib
+//LIBRARY nsmldshostserver.lib
+//LIBRARY nsmldshostclient.lib
+//LIBRARY NSmlDSSettings.lib
+//LIBRARY nsmlagentcommon.lib
+
+//LIBRARY nsmldebug.lib
+DEBUGLIBRARY flogger.lib
+
+//EXPORTUNFROZEN
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/group/aspsyncutil_icons.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,87 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\SYSTEM\APPS\aspsyncutil
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\aspsyncutil.mif
+HEADERFILENAME=$(HEADERDIR)\aspsyncutil.mbg
+
+
+do_nothing : 
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	/c8,8 qgn_prop_sml_http.bmp \
+	/c8,8 qgn_prop_sml_http_off.bmp \
+	/c8,8 qgn_prop_sml_bt.bmp \
+	/c8,8 qgn_prop_sml_bt_off.bmp \
+	/c8,8 qgn_prop_sml_usb.bmp \
+	/c8,8 qgn_prop_sml_usb_off.bmp \
+	/c8,8 qgn_prop_sml_ir.bmp \
+	/c8,8 qgn_prop_sml_ir_off.bmp \
+	/c8,8 qgn_menu_sml_cxt.bmp \
+	/c8,8 qgn_note_sml.bmp \
+	/c8,8 qgn_note_sml_server.bmp \
+	/c8,8 qgn_prop_sml_sync_server.bmp \
+	/c8,8 qgn_prop_sml_sync_to_server.bmp \
+	/c8,8 qgn_prop_sml_sync_from_server.bmp \
+	/c8,8 qgn_prop_sml_sync_off.bmp \
+
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/group/aspsyncutil_icons_dc.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\aspsyncutil.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\aspsyncutil.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	/c8,8 qgn_prop_sml_http.bmp \
+	/c8,8 qgn_prop_sml_http_off.bmp \
+	/c8,8 qgn_prop_sml_bt.bmp \
+	/c8,8 qgn_prop_sml_bt_off.bmp \
+	/c8,8 qgn_prop_sml_usb.bmp \
+	/c8,8 qgn_prop_sml_usb_off.bmp \
+	/c8,8 qgn_prop_sml_ir.bmp \
+	/c8,8 qgn_prop_sml_ir_off.bmp \
+	/c8,8 qgn_menu_sml_cxt.bmp \
+	/c8,8 qgn_note_sml.bmp \
+	/c8,8 qgn_note_sml_server.bmp \
+	/c8,8 qgn_prop_sml_sync_server.bmp \
+	/c8,8 qgn_prop_sml_sync_to_server.bmp \
+	/c8,8 qgn_prop_sml_sync_from_server.bmp \
+	/c8,8 qgn_prop_sml_sync_off.bmp \
+	/c8,8 qgn_indi_sync_set_add.bmp \
+	/c8,8 qgn_indi_sett_protected_add.bmp \
+	/c8,8 qgn_prop_sml_new.bmp\
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../loc/NSmlDSSync.loc		APP_LAYER_LOC_EXPORT_PATH(NSmlDSSync.loc)
+../loc/NSmlSyncProfiles.loc      APP_LAYER_LOC_EXPORT_PATH(NSmlSyncProfiles.loc)
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+  OPTION TARGETFILE aspsyncutil.mif
+  OPTION HEADERFILE aspsyncutil.mbg
+  OPTION SOURCES 	\
+    -c8,8 qgn_prop_sml_http -c8,8 qgn_prop_sml_http_off -c8,8 qgn_prop_sml_bt \
+	  -c8,8 qgn_prop_sml_bt_off -c8,8 qgn_prop_sml_usb -c8,8 qgn_prop_sml_usb_off \
+	  -c8,8 qgn_prop_sml_ir -c8,8 qgn_prop_sml_ir_off -c8,8 qgn_menu_sml_cxt \
+	  -c8,8 qgn_note_sml -c8,8 qgn_note_sml_server -c8,8 qgn_prop_sml_sync_server \
+	  -c8,8 qgn_prop_sml_sync_to_server -c8,8 qgn_prop_sml_sync_from_server -c8,8 qgn_prop_sml_sync_off \
+	  -c8,8 qgn_indi_sync_set_add -c8,8 qgn_indi_sett_protected_add -c8,8 qgn_prop_sml_new
+END
+
+PRJ_MMPFILES
+
+//gnumakefile aspsyncutil_icons_dc.mk
+
+
+AspSyncUtil.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspAdvanceSettingsDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,388 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 ASPADVANCESETTINGSDIALOG_H
+#define ASPADVANCESETTINGSDIALOG_H
+
+
+//  INCLUDES
+
+#include "AspDialogUtil.h"
+
+#include <e32base.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+
+
+
+
+
+// CLASS DECLARATION
+
+
+/**
+*  CAspAdvanceSettingsDialog
+*
+* CAspAdvanceSettingsDialog is used for editing sync connection data.
+*/
+NONSHARABLE_CLASS (CAspAdvanceSettingsDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+    public:
+    
+    
+	public:
+	    /**
+        * Launches dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL();
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+		static CAspAdvanceSettingsDialog* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspAdvanceSettingsDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspAdvanceSettingsDialog();
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param aType.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework when dialog is activated.
+        * @param None.
+		* @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+    private:
+		/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+
+	
+	public:  // common editors
+							
+		/**
+		* Shows editor for list type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		static TBool EditSettingItemListL(CAspListItemData& aItem);
+ 		/**
+		* Checks whether MSK label and menu command are correct for the context
+		* @param aKeyEvent
+		* @return None.
+		*/
+ 		void CheckContentSettingL(const TKeyEvent& aKeyEvent);
+ 		/**
+		* Checks whether MSK label and menu command are correct for the context 
+		* @param None
+		* @return None.
+		*/
+ 		void CheckContentSettingL();
+        /**
+		* Utility function, updates dialog cba.
+		* @param aResourceId.
+		* @return None.
+		*/
+		void UpdateCbaL(TInt aResourceId);
+		
+		/**
+		* Utility function, updates menu bar.
+		* @param aResource.
+		* @return None.
+		*/
+		
+		void UpdateMenuL(TInt aResource);
+		
+		
+    
+    private:
+    
+		/**
+		* Handles setting item editing.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemL(CAspListItemData& aItem);
+								
+		/**
+		* Set the MSK empty.
+		* @param None.
+		* @return None.
+		*/
+		void SetEmptyMiddleSoftKeyLabelL();
+
+    private:
+		 		        
+        /**
+		* Check setting values before dialog close.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool CheckSettingValuesL(TInt aButtonId);
+
+        /**
+		* Check setting values before dialog close.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool CheckSettingValues(TInt aButtonId);
+
+
+	private:
+		/**
+        * Create one CNSmlDSProfileData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		void InitSettingItemL(CAspListItemData* aItem);
+		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aHeaders Array of item headers.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, CDesCArray* aHeaders);
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aResourceId.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, TInt aResourceId);
+
+		/**
+        * Set setting item visibility (normal/readonly/hidden).
+        * @param None.
+		* @return None.
+        */
+		void SetVisibility();		
+		
+    private:
+
+        void  WriteRepositoryL(TInt aKey, const TInt& aValue);
+        
+        void  ReadRepositoryL(TInt aKey, TInt& aValue);
+        
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+		/**
+		* Returns setting item with listbox position aIndex.
+		* @param aIndex Listbox index.
+		* @return Pointer to setting item.
+        */
+		CAspListItemData* GetItemForIndex(TInt aIndex);
+
+		/**
+        * Returns setting item with id aItemId.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+
+		/**
+		* Returns listbox.
+		* @param None.
+		* @return Pointer to listbox.
+		*/
+		CAknSettingStyleListBox* ListBox();
+
+		/**
+		* Returns profile.
+		* @param None.
+		* @return Pointer to sync profile.
+		*/
+		//CAspProfile* Profile();
+		
+
+	private:
+		// setting list
+		CAknSettingStyleListBox* iSettingListBox;
+
+		// list of setting items
+		CAspSettingList *iSettingList;
+		
+   		// list that contains all contents (applications)
+		//CAspContentList* iContentList;
+
+		// profile data
+		CAspProfile* iProfile;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// resource handler
+		CAspResHandler* iResHandler;
+
+		// dialog edit mode
+		TInt iEditMode;
+
+		// for bearer type list construction
+		CAspBearerHandler* iBearerHandler;
+		
+		// for access point selection
+		CAspAccessPointHandler* iApHandler;
+		
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+		
+		// list that contains all profiles
+		CAspProfileList* iProfileList;
+
+		// id of the calling application
+		TInt iApplicationId;
+		
+		// is setting database in read only state
+		TBool iSettingEnforcement;
+		// profile's server id
+		TBuf<KAspMaxServerIdLength> iOldServerId;
+    	// id of current cba resource
+		TInt iCommandSetId;
+		// is  MSK empty
+		TBool iDefConnSupported;
+		TBool iMSKEmpty;
+    };
+
+
+#endif      // ASPPROFILEDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspAutoSyncHandler.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Manages schedules using Symbian Task scheduler  
+*
+*/
+
+
+#ifndef ASPAUTOSYNCHANDLER_H
+#define ASPAUTOSYNCHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <SyncMLClient.h>    // for RSyncMLSession
+#include <SyncMLObservers.h>
+#include <schtask.h>
+
+#include "AspDefines.h"
+#include "AspUtil.h"
+#include "AspSchedule.h"
+
+
+// CLASS DECLARATION
+
+/**
+* CAspAutoSyncHandler
+*  
+*/
+NONSHARABLE_CLASS (CAspAutoSyncHandler) : public CBase,
+                                          public MSyncMLEventObserver,
+						                  public MSyncMLProgressObserver
+    {
+    public:
+    enum TAutoSyncError
+        {
+	    EOtherSyncRunning      = -100,
+	    EIncorrectProfile      = -101,
+	    EIncorrectSchedule     = -102
+        };
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspAutoSyncHandler* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspAutoSyncHandler();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */	
+        CAspAutoSyncHandler();
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+		
+    
+    public:
+        void SynchronizeL(RFile& aTaskFile);
+
+		void DoSynchronizeL();
+        
+    private:
+        void OpenSyncSessionL();
+        void CloseSyncSession();
+        TInt CheckMandatoryDataL(TInt aProfileId);
+        TBool IsRoamingL();
+        TBool IsRoaming();
+                
+
+    private: // from MSyncMLEventObserver
+        
+        void OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier,
+                                  TInt aError, TInt aAdditionalData);
+	
+    private: //from MSyncMLProgressObserver
+	    
+	    void OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt aInfo2);
+	    void OnSyncMLDataSyncModifications(TInt aTaskId, 
+        const TSyncMLDataSyncModifications& aClientModifications,
+        const TSyncMLDataSyncModifications& aServerModifications);
+	    void OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError,
+	                           TInt aTaskId, TInt aInfo1, TInt aInfo2);
+
+   
+		
+    private:
+		
+		// sync session
+		RSyncMLSession iSyncSession;
+
+		// sync job
+		RSyncMLDataSyncJob iSyncJob;
+
+		// is sync currently running
+		TBool iSyncRunning;
+		
+    	// sync error code
+		TInt iSyncError;
+		
+		// is sync session open
+		TBool iSyncSessionOpen;
+		
+		// for stopping code until sync is finished
+		CActiveSchedulerWait* iWait;
+		
+		// for reading auto sync settings
+		CAspSchedule* iSchedule;
+	};
+
+
+/**
+* CAspSyncSchedule
+*  
+*/
+NONSHARABLE_CLASS (CAspSyncSchedule) : public CBase
+    {
+
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspSyncSchedule* NewL();
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CAspSyncSchedule* NewLC();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAspSyncSchedule();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */	
+        CAspSyncSchedule();
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	public:
+
+		/**
+        * Delete existing schedule.Called before creating a new schedule 
+        */
+        void DeleteScheduleL(CAspSchedule* aAspSchedule);
+        void DoDeleteScheduleL(CAspSchedule* aAspSchedule);
+
+		/**
+        * Create a new schedule based on changed settings
+        */
+		void CreatePeakScheduleL(CAspSchedule* aAspSchedule);
+		void CreateOffPeakScheduleL(CAspSchedule* aAspSchedule);
+
+		/**
+        * Edit the schedule to start after 15 min/30 mins.This is needed as task scheduler does not support 
+        * schedulling interval less than a hour
+        */
+	
+		void EditPeakScheduleL(CAspSchedule* aAspSchedule);
+		void EditOffPeakScheduleL(CAspSchedule* aAspSchedule);	
+
+		/**
+        *  Post pone the scheduled sync in till next valid time
+        */
+
+		void UpdatePeakScheduleL(CAspSchedule* aAspSchedule);
+		void UpdateOffPeakScheduleL(CAspSchedule* aAspSchedule);
+
+		/**
+        *  Enable schedules
+        */
+		void EnableSchedule(CAspSchedule* aAspSchedule);
+		
+#ifdef _DEBUG
+    public:
+        void LogScheduleL(CAspSchedule* aAspSchedule);
+        TInt LogSchedule(CAspSchedule* aAspSchedule);
+        static void LogIntervalType(TScheduleEntryInfo2& aInfo, TDes& aText);
+        static void LogInterval(TScheduleEntryInfo2& aInfo, TDes& aText);
+        static void LogTsTime(TTsTime aTsTime, TDes& aText);
+        static void LogTaskInfo(TTaskInfo& aInfo, TDes& aText);
+#endif        
+        
+    public:
+
+		/**
+        *  Get next sync time.Reads due time from task scheduler.
+        */       
+		void GetPeakStartTimeL(CAspSchedule* aAspSchedule, TTime& aTime, TBool aHomeTime);
+        void GetOffPeakStartTimeL(CAspSchedule* aAspSchedule, TTime& aTime, TBool aHomeTime);
+        
+    public:
+        TIntervalType IntervalType(TInt aInterval);
+        TTsTime StartTime(TInt aStartHour, TInt aInterval);
+        TInt Interval(TInt aInterval);
+        
+		
+    private:
+		//task scheduler server session
+		RScheduler iScheduler;
+
+
+		// schedule entry list
+		CArrayFixFlat<TScheduleEntryInfo2>* ipeakEntryList;
+		CArrayFixFlat<TScheduleEntryInfo2>* ioffPeakEntryList;
+
+		// schedule entry list
+		CArrayFixFlat<TTaskInfo>* ipeakTaskList;
+		CArrayFixFlat<TTaskInfo>* ioffPeakTaskList;
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+	};
+
+
+
+#endif  // ASPAUTOSYNCHANDLER_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspContentDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,399 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Editing content settings 
+*
+*/
+
+
+#ifndef ASPCONTENTDIALOG_H
+#define ASPCONTENTDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <eiklbo.h>
+#include <aknlists.h>
+#include <aknnavide.h>
+#include <AknDialog.h>
+
+#include <CAknCommonDialogsBase.h>  // TCommonDialogType
+
+#include "AspDialogUtil.h"
+
+
+
+// CLASS DECLARATION
+
+
+/**
+* CAspContentDialog
+* 
+* Content dialog is used to edit sync content (sync task) data.
+*/
+NONSHARABLE_CLASS (CAspContentDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+	public:
+	    /**
+        * Launches content dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(TAspParam& aParam);
+
+	private:
+
+		/**
+		* C++ default constructor.
+		* @param aParam Class that contains dialog parameters.
+		* @return None.
+		*/
+		CAspContentDialog(TAspParam& aParam);
+
+						
+        /**
+        * Two-phased constructor.
+		* @param aParam Class that contains dialog parameters.
+        */
+		static CAspContentDialog* NewL(TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+
+	    /**
+        * Destructor.
+        */
+		virtual ~CAspContentDialog();
+		
+		/**
+		* Check if the MSK label is correct for the context
+		* @param aKeyEvent Key code.
+	    */	
+		void CheckContentSettingL(const TKeyEvent& aKeyEvent);
+		
+		/**
+		* Update the MSK Label
+		* @param aCommandId command id.
+		* @param aResourceId resource id .
+	    */
+		void UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId);
+		
+
+	private:	
+
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+
+		/**
+		* From the base class.
+        * Handles key presses.
+        * @param aKeyEvent Key code.
+		* @param aType Key type.
+        * @return Result code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	
+		
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		virtual void ProcessCommandL(TInt aCommandId);
+
+		/**
+        * From the base class
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* Handle content parameter editing.
+		* @return None.
+		*/
+		void HandleOKL();
+
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+	
+		/**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Id of the pressed button
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+	
+		/**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+		* @return None.
+        */
+		void PreLayoutDynInitL();
+
+		/**
+        * From MEikListBoxObserver.
+		* Handle listbox events.
+        * @param aListBox Pointer to used listbox.
+		* @param aEventType Event type.
+        * @return None.
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+        
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+        
+
+	private:
+
+		/**
+		* Check that mandatory fields are set
+		* @return Index of the invalid mandatory item.
+		*/
+		TInt CheckMandatoryFields();
+	
+		/**
+		* Save content parameters into profile.
+    	* @return None.
+		*/
+		void SaveSettingsL();
+
+		/**
+		* Set filter type setting visibility.
+		* @param None.
+		* @return None.
+		*/
+		void SetFilterVisibility(TInt aVisibility);
+    
+    private:
+    		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+		
+		/**
+        * Create one CAspListItemData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aResourceId.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, TInt aResourceId);
+		
+		/**
+        * Adds one setting item into item list.
+        * @param aDataProviderId.
+		* @return None.
+        */
+		void AddRemoteDatabaseL(TInt aDataProviderId);
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		void InitSettingItemL(CAspListItemData* aItem);
+
+
+    private:
+
+		/**
+		* Handles setting item editing.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemL(CAspListItemData& aItem);
+
+		/**
+		* Change Yes/No value without showing edit dialog.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemYesNoL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for text type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemTextL(CAspListItemData& aItem);
+
+		/**
+		* Shows editor for list type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TBool EditSettingItemLocalDatabaseL(CAspListItemData& aItem);
+    
+		/**
+		* Shows editor for list type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		static TBool EditSettingItemListL(CAspListItemData& aItem);
+  
+  
+    private:
+		/**
+		* Utility function.
+		* @param aIndex Listbox index.
+		* @return setting item with listbox position aIndex.
+        */
+		CAspListItemData* GetItemForIndex(TInt aIndex);
+
+		/**
+        * Utility function.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+		
+		/**
+		* Finds out sync data provider type.
+		* @param None.
+		* @return Data provider type.
+		*/
+		TInt DataProviderType() const;
+		
+		/**
+        * Set setting item visibility (normal/readonly/hidden).
+        * @param None.
+		* @return None.
+        */
+		void SetVisibility();
+		
+		/**
+        * Set all settings to read-only state.
+        * @param None.
+		* @return None.
+        */
+		void SetAllReadOnly();
+		
+		/**
+        * Read sync profile task data.
+        * @param None.
+		* @return None.
+        */
+		void InitTaskDataL();
+		
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+
+	private:
+		// id of the calling application
+		TInt iApplicationId;
+
+		// list box for setting items 
+		CAknSettingStyleListBox* iListBox;
+		
+		// setting items
+		CAspSettingList *iSettingList;
+		
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// session with sync server
+		RSyncMLSession* iSyncSession;
+		
+		// sync profile
+		CAspProfile* iProfile;
+
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// is setting database in read only state
+		TBool iSettingEnforcement;
+		
+		// has user changed sync content local or remote datastore
+		TBool iDataStoreChanged;
+		
+		
+    private:
+		
+		// dialog parameters
+		TAspParam* iDialogParam;
+	
+		// sync data provider
+		TInt iDataProviderId;
+
+		// is content included in sync
+		TBool iTaskEnabled;
+		
+		// sync type
+		TInt iSyncDirection;
+
+		// needed for finding out whether user changed db name
+		TBuf<KBufSize> iLocalDatabase;
+		
+		// needed for finding out whether user changed db name
+		TBuf<KBufSize> iRemoteDatabase;
+		
+		// names of all available local data stores
+		CDesCArray* iLocalDataStores;
+		//is MSK Empty	
+		TBool iMskEmpty;
+	};
+
+
+
+
+#endif      // ASPCONTENTDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspContentListDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,237 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Editing Content list (not used anymore) 
+*
+*/
+
+
+#ifndef ASPCONTENTLISTDIALOG_H
+#define ASPCONTENTLISTDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <eikdialg.h>
+#include <eiklbo.h>
+#include <aknlists.h>
+
+#include "aspdefines.h"
+#include "asputil.h"
+#include "aspdialogutil.h"
+#include "aspreshandler.h"
+
+#include <aknlistquerydialog.h>
+
+
+
+// CLASS DECLARATION
+
+/**
+* CAspContentListDialog
+*  
+* Content list dialog shows all available sync contents (sync data providers).
+*/
+NONSHARABLE_CLASS (CAspContentListDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+    enum TAspContentListDialogIconIndex
+		{
+	    EIconBothDirections = 0,
+	    EIconDeviceToServer = 1,
+	    EIconServerToDevice = 2,
+	    EIconNotDefined     = 3
+		};
+
+	public:
+
+	    /**
+        * Launches setting dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(const TAspParam& aParam);
+
+    public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspContentListDialog* NewL(const TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspContentListDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspContentListDialog(const TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+
+	private:
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PreLayoutDynInitL();
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+		
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param TEventCode.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID,	CEikMenuPane* aMenuPane);
+
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+    private: // from MEikListBoxObserver
+
+	    /**
+        * From MEikListBoxObserver
+        * @param aListBox Pointer to listbox.
+		* @param aEventType Event type.
+        * @return None.
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+	
+    private:
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+
+
+		/**
+        * Updates listbox items.
+        * @param None.
+        * @return None.
+        */
+		void UpdateListBoxL();
+
+		/**
+        * Shows content dialog.
+        * @param None.
+        * @return None.
+        */
+		void ShowContentL();
+
+    private:
+		/**
+		* Utility function.
+		* @return Sync session.
+        */
+		RSyncMLSession& Session();
+
+		/**
+        * Utility function.
+        * @return Dialog list box.
+        */
+		CAknDoubleLargeStyleListBox* ListBox();
+
+		/**
+        * Utility function.
+        * @return Currently selected list box item.
+        */
+		TAspProviderItem& SelectedProvider();
+
+
+    private:
+		// id of the calling application
+		TInt iApplicationId;
+
+		// sync profile
+		CAspProfile* iProfile;
+		
+		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// list box that contains all contents (applications)
+		CAknDoubleLargeStyleListBox* iSettingListBox;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+    	// resource handler
+		CAspResHandler* iResHandler;
+
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+    };
+
+
+#endif    // ASPCONTENTLISTDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspDbNotifier.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,305 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Used by UI to update settings based on DB changes 
+*
+*/
+
+
+#ifndef ASPDBNOTIFIER_H
+#define ASPDBNOTIFIER_H
+
+#include <e32std.h>
+#include <SyncMLObservers.h>
+
+#include "AspUtil.h"
+
+
+// CLASS DECLARATION
+
+
+/**
+* TAspDbEvent
+*
+* TAspDbEvent represents sync event that is sent to UI.
+*/
+NONSHARABLE_CLASS (TAspDbEvent)
+	{
+	public:
+		TInt iType;	
+		TInt iProfileId;
+		TInt iError;
+
+    public:
+		/**
+        * Constructor
+        * @param aType Event type.
+        * @return None. 
+        */
+    	TAspDbEvent(TInt aType);
+	};
+
+
+
+/**
+* MAspDbEventHandler
+*
+* Observer interface function.
+*/
+NONSHARABLE_CLASS (MAspDbEventHandler)
+	{
+	public:
+		/**
+        * CAspDbNotifier calls this to inform that database has changed.
+        * @param aEvent Database event.
+        * @return None. 
+        */
+		virtual void HandleDbEventL(TAspDbEvent aEvent) = 0;
+	};
+
+
+/**
+* CAspDbNotifier
+* 
+* CAspDbNotifier is used to observe sync database events. These events
+* are used to update UI.
+*/
+NONSHARABLE_CLASS (CAspDbNotifier) : public CBase,
+                                     public MAspActiveCallerObserver,
+                                     public MSyncMLEventObserver
+	{
+    public:
+	    enum TEventType
+			{
+			EUpdate,
+			EUpdateAll,
+			EDelete,
+	        EClose
+			};
+
+	public:
+		/**
+        * Two-phased constructor
+        * @param aDatabase Reference to RDbDatabase instance.
+		* @param aHandler Pointer to MAspDbEventHandler instance.
+        * @return None. 
+        */
+		static CAspDbNotifier* NewL(const TAspParam& aParam, MAspDbEventHandler* aHandler);
+
+        /**
+        * Destructor.
+        */
+		virtual ~CAspDbNotifier();
+
+	private:
+
+		/**
+        * Constructor
+        * @param aParam.
+		* @param aHandler Pointer to event handler.
+        * @return None. 
+        */
+		CAspDbNotifier(const TAspParam& aParam, MAspDbEventHandler* aHandler);
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+
+	public:
+		/**
+		* Start requesting events from db.
+        * @param None. 
+        * @return None. 
+        */
+		void RequestL();
+
+   
+	private:   // from MAspActiveCallerObserver
+	
+		/**
+        * From MAspActiveCallerObserver
+		* Called when CAspActiveCaller completes.
+        * @param aCallId.
+        * @return None.
+        */
+		void HandleActiveCallL(TInt aCallId);
+
+    private:    // from MSyncMLEventObserver
+        
+		/**
+        * Called when SyncML session events oocur.
+        * @param aEvent Event type.
+        * @param aIdentifier Object id.
+        * @param aError Error code.
+        * @param aAdditionalData Additional data.
+        * @return None.
+        */
+        void OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt aAdditionalData);
+        
+		/**
+        * Called when SyncML session events oocur.
+        * @param aEvent Event type.
+        * @param aIdentifier Object id.
+        * @param aError Error code.
+        * @param aAdditionalData Additional data.
+        * @return None.
+        */
+        void HandleSessionEventL(TEvent aEvent, TInt aIdentifier, TInt aError, TInt aAdditionalData);
+
+    public:
+		/**
+        * Calls database event observer with delay.
+        * @param None.
+        * @return None.
+        */
+		void CallObserverWithDelay();
+
+		/**
+        * Calls database event observer.
+        * @param None.
+        * @return None.
+        */
+		void CallObserver();
+		
+		/**
+        * Disable/enable observer calling.
+        * @param aDisable.
+        * @return None.
+        */
+		void SetDisabled(TBool aDisable);
+
+		/**
+        * Finds out how many profiles have changed.
+        * @param None.
+        * @return Profile count.
+        */
+		TInt ChangedProfileCount();
+		
+		/**
+        * Get one database event from event array.
+        * @param aIndex.
+        * @return Database event.
+        */
+        TAspDbEvent Event(TInt aIndex);
+        
+		/**
+        * Return number of received database events.
+        * @param None.
+        * @return Event count.
+        */
+		TInt EventCount();
+
+		/**
+        * Reset event array.
+        * @param None.
+        * @return None.
+        */
+		void Reset();
+
+		/**
+        * Find out whether event array contains event that causes UI to close.
+        * @param None.
+        * @return Array index.
+        */
+		TInt FindCloseEvent();
+
+		/**
+        * Find out whether event array contains events for one profile only.
+        * @param None.
+        * @return Array index.
+        */
+		TInt FindSingleProfileEvent();
+		
+		/**
+        * Find out whether event array contains profile event.
+        * @param None.
+        * @return Array index.
+        */
+		TInt FindProfileEvent();
+		
+		/**
+        * Find out whether event array only contains events with same profile id.
+        * @param aId Profile id.
+        * @return Boolean.
+        */
+		TBool IsUniqueProfileId(TInt aId);
+		
+		/**
+        * Creates one update event.
+        * @param aIdentifier Profile id.
+        * @param aError Error code.
+        * @return None.
+        */
+		void CreateUpdateEventL(TInt aIdentifier, TInt aError);
+		
+		/**
+        * Find out whether event array contains delete event.
+        * @param None.
+        * @return Boolean.
+        */
+		TBool ProfileDeleted();
+		
+		/**
+        * Call event observer if event array contains update event.
+        * @param None.
+        * @return None.
+        */
+        void CheckUpdateEventL();
+		
+		/**
+		* Utility function.
+		* @return Sync session.
+        */
+		RSyncMLSession& Session();
+		
+		
+#ifdef _DEBUG
+    private:
+        void GetSyncEventText(TDes& aText, MSyncMLEventObserver::TEvent aEvent);
+        void LogSessionEvent(TEvent& aEvent, TInt aIdentifier, TInt aError);
+#endif
+		
+
+
+	private:  
+		// sync session
+		RSyncMLSession* iSyncSession;
+	
+		// Pointer to event handler
+		MAspDbEventHandler* iHandler;
+
+		// for making function call via active scheduler
+		CAspActiveCaller* iActiveCaller;
+
+		// for storing ids of changed profiles
+		RArray<TAspDbEvent> iList;
+
+		// can observer be called
+		TBool iDisabled;
+
+		// is synchronizing going on
+		//TBool iSyncRunning;
+		
+		// have sync session events been requested from RSyncMLSession
+		TBool iSessionEventRequested;
+		
+		// is this object destroyed
+		TBool* iDestroyedPtr;
+	};
+
+
+#endif   // ASPDBNOTIFIER_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspDebug.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Debug macros definition and constant declaration 
+*
+*/
+
+
+
+#ifndef NSMLDSSYNC__DEBUG_H
+#define NSMLDSSYNC__DEBUG_H
+
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"smlsync.txt");
+_LIT(KLogDirFullName,"c:\\logs\\");
+_LIT(KLogDir,"smlsync");
+
+// Declare the FPrint function
+inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(arg...)   { FPrint(arg); }
+//#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+//#define FLOG(arg...) { RDebug::Print(arg);  }
+#define FLOG(arg...)   { FPrint(arg); }
+#define FTRACE(a) { a; }
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(arg...)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // NSMLDSSYNC__DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspDefines.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,305 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 general data definitions for AspSyncUtil.
+*
+*/
+
+
+#ifndef ASPDEFINES_H
+#define ASPDEFINES_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <AiwGenericParam.hrh>
+
+
+
+// CONSTANTS
+
+// resource files
+_LIT( KResFileName, "z:aspsyncutil.rsc" );
+_LIT( KBitmapFileName, "z:AspSyncUtil.mbm" );
+
+
+_LIT(KHttpHeader, "http://");
+
+// central repository uid for scheduled sync settings
+const TUid KCRUidNSmlDSApp       = { 0x101F9A1D };
+
+//unicode value for clock icon
+const TUint KClockCharacter = 0xF815 ;
+
+// consumer app uids
+const TUid KUidAppSync       = { 0x101F6DE4 };
+const TUid KUidAppPhonebook  = { 0x101F4CCE };
+const TUid KUidAppCalendar   = { 0x10005901 };
+const TUid KUidAppMessages   = { 0x100058C5 };
+const TUid KUidAppNotepad    = { 0x10005907 };
+const TUid KUidAppTest       = { 0x0995CDE9 };
+const TUid KUidAppMailEditor = { 0x101F4CD6 };
+
+
+
+// medium type uids
+const TUid KUidNSmlMediumTypeInternet  = { 0x101F99F0 };
+const TUid KUidNSmlMediumTypeBluetooth = { 0x101F99F1 };
+const TUid KUidNSmlMediumTypeUSB       = { 0x101F99F2 };
+const TUid KUidNSmlMediumTypeIrDA      = { 0x101F99F3 };
+
+
+// medium type uids for convergence
+//const TUid KUidNSmlMediumTypeInternet  = { 0x10009F76 };
+//const TUid KUidNSmlMediumTypeBluetooth = { 0x10009F79 };
+//const TUid KUidNSmlMediumTypeUSB       = { 0x10009FB5 };
+//const TUid KUidNSmlMediumTypeIrDA      = { 0x10009F78 };
+//const TUid KUidNSmlMediumTypeWSP       = { 0x10009F77 };
+//const TUid KUidNSmlMediumTypeNSmlUSB   = { 0x101F9A04 };
+
+
+
+// sync adapder uids
+const TUid KUidNSmlAdapterCalendar  = { 0x101F6DDE };
+const TUid KUidNSmlAdapterContact   = { 0x101F6DDD };
+const TUid KUidNSmlAdapterEMail     = { 0x101F6DDF };
+const TUid KUidNSmlAdapterNote      = { 0x101F8612 };
+const TUid KUidNSmlAdapterSms       = { 0x10206B5C };
+const TUid KUidNSmlAdapterMMS       = { 0x101FB0E9 };
+const TUid KUidNSmlAdapterBookmarks = { 0x102751BA };
+
+// convergence sync adapder uids
+//const TUid KUidNSmlAdapterCalendar  = { 0x10009FD1 };
+//const TUid KUidNSmlAdapterContact   = { 0x10009FD3 };
+
+
+// sync application uid
+const TUid KUidSmlSyncApp             = { 0x101F6DE4 };
+
+// password editor constatnts
+_LIT(KSecretEditorMask, "*");
+const TInt KSecretEditorMaskLength = 4;
+
+// string sizes
+const TInt KBufSize = 128;
+const TInt KBufSize255 = 255;
+const TInt KBufSize16 = 16;
+const TInt KBufSize64 = 64;
+const TInt KBufSize32 = 32;
+
+const TInt KDefaultArraySize = 10;
+
+
+//
+// text editor max sizes (from nsmlconstantdefs.h)
+//
+const TInt KAspMaxProfileNameLength         = 50;
+const TInt KAspMaxUsernameLength            = 80;
+const TInt KAspMaxPasswordLength            = 22;
+const TInt KAspMaxLocalNameLength           = 255;
+const TInt KAspMaxAdapterDisplayNameLength  = 50;
+const TInt KAspMaxServerIdLength            = 150;
+const TInt KAspMaxURILength                 = 144;
+const TInt KAspMaxRemoteNameLength          = 125;
+
+// max number of profiles
+const TInt KMaxProfileCount = 50;
+
+// setting dialog listbox update delay after db event
+const TInt KListBoxUpdateDelay = 250;
+
+
+
+// DATA TYPES
+
+enum TAspApplicationIds
+	{
+	EApplicationIdSync = 0,
+	EApplicationIdBookmarks = 1,//value not available in AiwGenericParam.hrh
+	EApplicationIdContact = EGenericParamContactItem,    // 20
+	EApplicationIdCalendar = EGenericParamCalendarItem,  // 21
+	EApplicationIdEmail = EGenericParamMessageItemEMail, // 31
+	EApplicationIdNote = EGenericParamNoteItem,          // 23
+	EApplicationIdMms = EGenericParamMessageItemMMS,     // 32
+	EApplicationIdSms = EGenericParamMessageItemSMS      // 30
+	};
+
+enum TASpSettingValue
+	{
+	EAspSettingDisabled = 0,
+	EAspSettingEnabled = 1
+	};
+
+// NOTE: do not change these enums. They are also used in sync app
+enum TAspDialogMode
+	{
+	EModeDialogWait = 3,
+	EModeDialogNoWait = 4
+	};
+
+enum TDialogMode
+	{
+	EDialogModeEdit,
+	EDialogModeEditMandatory,
+	EDialogModeReadOnly,
+	EDialogModeSettingEnforcement
+	};
+
+enum TAspMandatoryProfileData
+	{
+	EMandatoryOk,
+	EMandatoryNoProfileName,
+    EMandatoryNoHostAddress,
+    EMandatoryIncorrectBearerType,
+    EMandatoryIncorrectAccessPoint,
+
+    EMandatoryNoContent,
+	EMandatoryNoLocalDatabase,
+	EMandatoryNoRemoteDatabase,
+	EMandatoryNoSyncType
+	};
+
+enum TAspSettingItemVisibility
+	{
+	EVisibilityNormal,
+	EVisibilityReadOnly,
+	EVisibilityHidden
+	};
+
+enum TASpBearerType
+	{
+	EAspBearerInternet = 0,
+	EAspBearerUsb = 1,
+	EAspBearerBlueTooth = 2,
+	EAspBearerIrda = 3,
+	EAspBearerWsp = 4,
+	EAspBearerSmlUsb = 5,
+    EAspBearerLast = 6
+	};
+
+
+
+//
+// NOTE: this enum must match to resource r_asp_connection_dialog_setting_items
+//
+enum TAspConnectionSettingItem
+	{
+	EAspProfileName = 0,
+	EAspServerId = 1,
+	EAspConnType = 2,
+	EAspAccessPoint = 3,
+	EAspHostAddress = 4,
+	EAspPort = 5,
+	EAspUsername = 6,
+	EAspPassword = 7,
+	EAspServerAlert = 8,
+	EAspHttpsUsername = 9,
+	EAspHttpsPassword = 10,
+    EAspSyncDirection = 11,
+	EAspProtocolVersion = 12,
+	EAspSyncContent = 13,
+	EAspSchedulingSetting = 14,
+	EAspProfileSetting = 15
+	};
+
+
+enum TAspContentSettingItem
+	{
+	EAspLocalDatabase = 0,
+	EAspRemoteDatabase = 1,
+	EAspUseFilters = 2
+	};
+
+enum TAspAutoSyncSettingItem
+	{
+    EAspAutoSyncProfile = 0,
+    EAspAutoSyncContents,
+    EAspAutoSyncFrequency,
+    EAspAutoSyncPeakSchedule,
+    EAspAutoSyncOffPeakSchedule,
+    EAspAutoSyncScheduleTime,
+    EAspAutoSyncPeakStartTime,
+    EAspAutoSyncPeakEndTime,
+    EAspAutoSyncPeakDays,
+    EAspAutoSyncRoamingStatus
+	};
+
+
+// NOTE: This enum must match with r_asp_sync_type
+enum TAspSyncDirection
+	{
+	ESyncDirectionTwoWay,
+	ESyncDirectionOneWayFromDevice,
+	ESyncDirectionOneWayIntoDevice,
+	ESyncDirectionRefreshFromServer
+	};
+
+// NOTE: This enum must match with r_asp_server_alert_type
+enum TAspSASyncState
+	{
+	ESASyncStateEnable = 0,
+	ESASyncStateConfirm = 1,
+	ESASyncStateDisable = 2
+	};
+
+
+
+// NOTE: this enum must match with property array described in 
+// SyncML_Sync_Agent_Client_API_Specification.doc.
+
+// transport property setting ids
+enum TAspTransportProperties
+	{
+	EPropertyIntenetAccessPoint = 0,
+	EPropertyHttpUsed = 5,
+	EPropertyHttpUserName = 6,
+	EPropertyHttpPassword = 7
+	};
+
+/*
+// transport property setting ids for convergence
+enum TNSmlSyncTransportProperties
+	{
+	EPropertyIntenetAccessPoint = 3,
+	//EPropertyHttpUsed = 0,
+	EPropertyHttpUserName = 0,
+	EPropertyHttpPassword = 1
+	};
+*/
+
+enum TASpProtocolType
+	{
+	EAspProtocol_1_1 = 0,
+	EAspProtocol_1_2 = 1
+	};
+
+// Roaming Settings
+enum TRoamingSettings
+    {
+    ERoamingSettingAlwaysAsk = 0,
+    ERoamingSettingAlwaysAllow = 1,
+    ERoamingSettingNeverAllow = 2,
+    ERoamingSettingBlock = 3
+    };
+
+
+
+
+enum TAdvanceSettingsItem
+    {
+    ERoamingSettings = 0
+    };
+
+#endif  // ASPDEFINES_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspDialogUtil.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,874 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 general data definitions for AspSyncUtil.
+*
+*/
+
+
+#ifndef ASPDIALOGUTIL_H
+#define ASPDIALOGUTIL_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <aknlistquerycontrol.h>
+#include <aknnavi.h>
+#include <aknnavide.h>
+#include <AknQueryDialog.h>
+
+#include <SyncMLHistory.h>
+
+#include <AknIndicatorContainer.h>      // CAknIndicatorContainer
+#include <aknEditStateIndicator.h>      // MAknEditingStateIndicator
+#include <akncheckboxsettingpage.h>     // CSelectionItemList
+#include <aknradiobuttonsettingpage.h>  // CAknRadioButtonSettingPage
+#include <akntextsettingpage.h>         // CaknTextSettingPage
+#include <aknpasswordsettingpage.h>     // CAknAlphaPasswordSettingPage
+
+#include "AspDefines.h"
+#include "AspProfile.h"
+#include "AspResHandler.h"
+
+
+
+#ifdef RD_DSUI_TIMEDSYNC 
+
+#include <akntabgrp.h>
+#include <akntabobserver.h>
+
+#endif
+
+/**
+* TDialogUtil
+* 
+* TDialogUtil contains general dialog utilities.
+*/
+NONSHARABLE_CLASS (TDialogUtil)
+	{
+    public:
+		/**
+		* Shows text query.
+		* @param aTitle Title text.
+		* @param aText Message text.
+		* @param aMaxLength Max text length.
+		* @return None.
+		*/
+        static void ShowTextQueryL(const TDesC& aTitle, TDes& aText, TInt aMaxLength);
+		
+		/**
+		* Shows message query (title, text and Ok button).
+		* @param aTitle Title text.
+		* @param aText Message text.
+		* @return None.
+		*/
+		static void ShowMessageQueryL(const TDesC& aTitle, const TDesC& aText);
+
+		/**
+		* Shows message query (title, text and Ok button).
+		* @param aTitle Title text.
+		* @param aResourcet Mssage text resource id.
+		* @return None.
+		*/
+		static void ShowMessageQueryL(const TDesC& aTitle, TInt aResource);
+
+		static void ShowAutoSyncMessageQueryL(const TDesC& aText);
+		/**
+		* Shows yes/no question.
+		* @param aText Question text.
+		* @return ETrue if user selected yes, EFalse otherwise..
+		*/
+		static TBool ShowConfirmationQueryL(const TDesC& aText);
+
+		/**
+		* Shows yes/no question.
+		* @param aText Question text.
+		* @return ETrue if user selected yes, EFalse otherwise..
+		*/
+		static TBool ShowRoamingConfirmationQueryL(const TDesC& aText);
+		        
+		/**
+        * Shows ok/cancel question.
+        * @param aResource Question text.
+        * @return ETrue if user selected ok, EFalse otherwise..
+        */
+        static TBool ShowRoamingConfirmationQueryL(TInt aResource);
+
+		/**
+		* Shows yes/no question.
+		* @param aResource Question text.
+		* @return ETrue if user selected yes, EFalse otherwise..
+		*/
+		static TBool ShowConfirmationQueryL(TInt aResource);
+
+		/**
+		* Shows information text.
+		* @param aText Information text.
+		* @return None.
+		*/
+        static void ShowInformationQueryL(const TDesC& aText);
+        
+		/**
+		* Shows information text.
+		* @param aResource Information text.
+		* @return None.
+		*/
+        static void ShowInformationQueryL(TInt aResource);
+		
+		/**
+		* Shows information text.
+		* @param aResource Information text.
+		* @return None.
+		*/
+		static void ShowInformationNoteL(TInt aResource);
+
+		/**
+		* Shows information text.
+		* @param aText Information text.
+		* @return None.
+		*/
+		static void ShowInformationNoteL(const TDesC& aText);
+
+		/**
+		* Shows error text.
+		* @param aResource Error text.
+		* @return None.
+		*/
+		static void ShowErrorNoteL(TInt aResource);
+
+		/**
+		* Shows error text.
+		* @param aText Error text.
+		* @return None.
+		*/
+		static void ShowErrorNoteL(const TDesC& aText);
+		
+		/**
+		* Shows error text.
+		* @param aResource Error text.
+		* @return None.
+		*/
+		static void ShowErrorQueryL(TInt aResource);
+
+		/**
+		* Shows error text.
+		* @param aText Error text.
+		* @return None.
+		*/
+		static void ShowErrorQueryL(const TDesC& aText);
+
+		/**
+		* Shows dialog with selection list.
+		* @param aTitle Dialog title.
+		* @param aList List of selection items.
+		* @param aSelectedIndex Index of selected item.
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowListQueryL(const TDesC& aTitle, CDesCArray* aList, TInt* aSelectedIndex);
+		/**
+		* Shows dialog with selection list other than sync application
+		* @param aTitle Dialog title.
+		* @param aList List of selection items.
+		* @param aSelectedIndex Index of selected item.
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowListQueryIconL(const TDesC& aTitle, CDesCArray* aList, TInt* aSelectedIndex);
+		/**
+		* Shows dialog with selection list.
+		* @param aTitle Dialog title.
+		* @param aList List of selection items.
+		* @param aSelectedIndex Index of selected item.
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowListQueryL(TInt aTitle, CDesCArray* aList, TInt* aSelectedIndex);
+		/**
+		* Shows dialog with selection list opened from other than sync application
+		* @param aTitle Dialog title.
+		* @param aList List of selection items.
+		* @param aSelectedIndex Index of selected item.
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowListQueryIconL(TInt aTitle, CDesCArray* aList, TInt* aSelectedIndex);
+
+		/**
+		* Shows dialog with profile list.
+		* @param aList Profile list.
+		* @param aId Id of selected profile.
+		* @param aResource Dialog title resource id.
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowProfileQueryL(CAspProfileList* aList, TInt& aId, TInt aResource);
+		/**
+		* Shows dialog with profile list displayed other than sync application
+		* @param aList Profile list.
+		* @param aId Id of selected profile.
+		* @param aResource Dialog title resource id.
+		* @param aIndex to know the selected index
+		* @return EFalse if user canceled, ETrue otherwise.
+		*/
+		static TBool ShowProfileQueryAppL(CAspProfileList* aList, TInt& aId, TInt aResource,TInt &aIndex);
+		
+		/**
+		* Deletes menu item.
+		* @param aMenuPane.
+		* @param aCommandId Id of deleted menu.
+		* @return None.
+		*/
+		static void DeleteMenuItem(CEikMenuPane* aMenuPane, TInt aCommandId);
+
+		/**
+		* Constructs an independent CGulIcon object.
+		* @param aID Item ID of the masked bitmap to be created.
+        * @param aFilename Filename to be used to construct the item, 
+        * @param aFileBitmapId Id (for bitmap) in the file. 
+        * @param aFileMaskId Id (for mask) in the file.
+        * @return Pointer to the newly created CGulIcon object.
+        *         Ownership of the object is transferred to the caller.
+		*/
+		static CGulIcon* CreateIconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId);
+
+		/**
+		* Constructs an image.
+		* @param aID Item ID of the masked bitmap to be created.
+        * @param aFilename Filename to be used to construct the item, 
+        * @param aFileBitmapId Id (for bitmap) in the file. 
+        * @param aFileMaskId Id (for mask) in the file.
+        * @return Pointer to the newly created 	CEikImage object.
+		*/
+		static CEikImage* CreateImageLC(TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId);
+		
+		/**
+		* Constructs an list box item for CAknDoubleLargeStyleListBox.
+		* @param aFirstLine.
+        * @param aSecondLine 
+        * @param aIndex1. 
+        * @param aIndex2.
+        * @return Pointerto the newly created list box item.
+		*/
+        static HBufC* ConstructListBoxItemLC(const TDesC& aFirstLine, const TDesC& aSecondLine, TInt aIndex);
+        
+		/**
+		* Shows time editor page.
+		* @param aTime.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+		static TBool ShowTimeEditorL(TTime& aTime, const TDesC& aTitle);
+
+		/**
+		* Shows date editor page.
+		* @param aTime.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+		static TBool ShowDateEditorL(TTime& aTime, const TDesC& aTitle);
+		
+		/**
+		* Shows list editor page.
+		* @param aList.
+		* @param aTitle.
+		* @param aCurrent.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+		static TBool ShowListEditorL(CDesCArray* aList, const TDesC& aTitle, TInt& aCurrent);
+		
+		/**
+		* Shows list editor page.
+		* @param aResourceId.
+		* @param aList.
+		* @param aTitle.
+		* @param aCurrent.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+		static TBool ShowListEditorL(TInt aResourceId, CDesCArray* aList, const TDesC& aTitle, TInt& aCurrent);
+		
+		
+		/**
+		* Shows text editor page.
+		* @param aRessourceId.
+		* @param aText.
+		* @param aTitle.
+    	* @param aMandatory.
+		* @param aLatinInput.
+		* @param aMaxLength.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+		static TBool ShowTextEditorL(TInt aResourceId, TDes& aText, const TDesC& aTitle, TBool aMandatory, TBool aLatinInput, TInt aMaxLength);
+		
+		/**
+		* Shows text editor page.
+		* @param aText.
+		* @param aTitle.
+    	* @param aMandatory.
+		* @param aLatinInput.
+		* @param aMaxLength.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+        static TBool ShowTextEditorL(TDes& aText, const TDesC& aTitle, TBool aMandatory, TBool aLatinInput, TInt aMaxLength);		
+
+		/**
+		* Shows integer editor page.
+		* @param aNumber.
+		* @param aTitle.
+    	* @param aMin.
+		* @param aMax.
+		* @param aLatinInput.
+        * @return ETrue if not canceled, EFalse otherwise.
+		*/
+        static TBool ShowIntegerEditorL(TInt& aNumber, const TDesC& aTitle, TInt aMin, TInt aMax, TBool aLatinInput);
+        
+		/**
+		* Shows popup dialog.
+		* @param aText Popup title.
+		* @param aArray Popup lines.
+        * @return None.
+		*/
+        static void ShowPopupDialogL(const TDesC& aText, CDesCArray* aArray);	
+
+		/**
+		* Shows popup dialog.
+		* @param aText Popup title.
+		* @param aArray Popup lines.
+        * @return None.
+		*/
+        static void ShowPopupDialog2L(const TDesC& aText, CDesCArray* aArray);	
+        
+        /**
+		*
+		* Does Descriptor contain string "PC Suite"
+		* Its NOT case sensitive
+		*
+		*/
+		static TBool IsPCSuiteDesC(const TDesC& des);
+		
+		static TInt ShowAutoSyncLogL(TAny* /*aAny*/);
+
+	};
+
+
+
+/**
+* CAspIndicatorHandler
+* 
+* This class is used for changing indicator state.
+*/
+NONSHARABLE_CLASS (CAspIndicatorHandler) : public CBase
+	{
+    public:
+        /**
+        * Destructor.
+        */
+		virtual ~CAspIndicatorHandler();
+
+        /**
+        * C++ default constructor.
+        */
+        CAspIndicatorHandler::CAspIndicatorHandler(MAknEditingStateIndicator* aIndicator);
+
+	public:
+
+		/**
+		* Sets navi pane title.
+		* @param aTitle.
+		* @return None.
+		*/
+		void SetIndicatorStateL(TInt aIndicatorType, const TDesC& aTitle);
+
+	private:
+		// status pane
+		//CEikStatusPane* iStatusPane;
+	
+	    // edit state indicator
+	    MAknEditingStateIndicator* iIndicator;
+        
+        // indicator container
+        CAknIndicatorContainer* iIndicatorContainer;
+        
+        // indicator type
+        TInt iIndicatorType;
+        
+        // has indicator been modified
+        TBool iIndicatorModified;
+        
+        // indicator type
+        TInt iPreviousIndicatorType;
+	};
+
+
+
+/**
+* CAspNaviPaneHandler
+* 
+* This class is used for changing navipane title.
+*/
+NONSHARABLE_CLASS (CAspNaviPaneHandler) : public CBase
+	{
+    public:
+        /**
+        * Destructor.
+        */
+		virtual ~CAspNaviPaneHandler();
+
+        /**
+        * C++ default constructor.
+        */
+		CAspNaviPaneHandler(CEikStatusPane* aStatusPane);
+
+	public:
+
+		/**
+		* Sets navi pane title.
+		* @param aTitle.
+		* @return None.
+		*/
+		void SetNaviPaneTitleL(const TDesC& aTitle);
+		
+		/**
+		* Store navi pane.
+		* @param None.
+		* @return None.
+		*/
+		void StoreNavipaneL();
+
+	private:
+		// status pane
+		CEikStatusPane* iStatusPane;
+	
+	    // navi Pane
+	    CAknNavigationControlContainer* iNaviPane;
+        
+        // navi decorator
+        CAknNavigationDecorator* iNaviDecorator;
+        
+        // has Navidecorator been pushed into navi pane
+        TBool iNavidecoratorPushed;
+        
+        // has navi pane been pushed into navigation pane's object stack
+        TBool iNavipanePushed;
+	};
+
+
+#ifdef RD_DSUI_TIMEDSYNC 
+
+class CAspSettingDialog;
+
+/**
+* CAspTabbedNaviPaneHandler
+* 
+* This class is used for changing tab group.
+*/
+NONSHARABLE_CLASS (CAspTabbedNaviPaneHandler) : public CBase, public MAknTabObserver
+	{
+    public:
+        /**
+        * Destructor.
+        */
+		virtual ~CAspTabbedNaviPaneHandler();
+
+        /**
+        * C++ default constructor.
+        */
+		CAspTabbedNaviPaneHandler(CEikStatusPane* aStatusPane ,CAspSettingDialog *aDialog);
+
+
+		
+	public:
+   		void StoreNavipaneL();
+	    void SetTabTextL(const TDesC& aText, TInt aTabId);
+	    void AddTabL(const TDesC& aText, TInt aTabId);
+	    void DeleteTabsL();
+	    void SetActiveTabL(TInt aTabId);
+		TInt TabIndex(TInt aTabId);
+		void SetTabWidthL();
+	    
+	    
+	private: // from  MAknTabObserver
+	    void TabChangedL(TInt aIndex);
+
+	private:
+		// status pane
+		CEikStatusPane* iStatusPane;
+	
+	    // navi Pane
+	    CAknNavigationControlContainer* iNaviPane;
+        
+        // navi decorator
+        CAknNavigationDecorator* iNaviDecorator;
+        
+       	// Tab group owned by the navigation decorator.
+        CAknTabGroup* iTabGroup;
+
+        
+        // has Navidecorator been pushed into navi pane
+        TBool iNavidecoratorPushed;
+        
+        // has navi pane been pushed into navigation pane's object stack
+        TBool iNavipanePushed;
+        
+        CAspSettingDialog *iDialog;
+	};
+
+#endif 
+
+/**
+* CStatusPaneHandler
+* 
+* This class is used for changing dialog title and image.
+*/
+NONSHARABLE_CLASS (CStatusPaneHandler) : public CBase
+	{
+    public:
+        /**
+        * Two-phased constructor.
+        */
+		static CStatusPaneHandler* NewL(CAknAppUi* aAppUi);
+
+        /**
+        * Destructor.
+        */
+		virtual ~CStatusPaneHandler();
+
+    private:
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+		CStatusPaneHandler(CAknAppUi* aAppUi);
+
+	public:
+		/**
+		* Stores original title so it can be restored when dialog closes.
+		* @param  None.
+		* @return None.
+		*/
+        void StoreOriginalTitleL();
+
+		/**
+		* Restores original title.
+		* @param  None.
+		* @return None.
+		*/
+		void RestoreOriginalTitleL();
+
+		/**
+		* Sets dialog title.
+		* @param  aText.
+		* @return None.
+		*/
+		void SetTitleL(const TDesC& aText);
+
+		/**
+		* Sets dialog title.
+		* @param  aResourceId.
+		* @return None.
+		*/
+		void SetTitleL(TInt aResourceId);
+
+	public:
+		/**
+		* Sets dialog title.
+		* @param aAppUi.
+		* @param aText.
+		* @return Return code.
+		*/
+		static TBool SetTitleL(CAknAppUi* aAppUi, const TDesC& aText);
+
+		/**
+		* Gets dialog title.
+		* @param aAppUi.
+		* @param aText.
+		* @return Return code.
+		*/
+		static TBool GetTitleL(CAknAppUi* aAppUi, TDes& aText);
+		
+		/**
+		* Sets dialog image.
+		* @param aFilename.
+		* @param aMainId.
+		* @param aMaskId.
+		* @return None.
+		*/
+		void SetNewImageL(const TDesC& aFilename,TInt aMainId,TInt aMaskId);
+
+		/**
+		* Restores original image.
+		* @param  None.
+		* @return None.
+		*/
+		void RestoreOriginalImageL();
+
+		/**
+		* Sets dialog image.
+		* @param aAppUi.
+		* @param aIcon.
+		* @return Return code.
+		*/
+		static CEikImage* SetImageL(CAknAppUi* aAppUi, CEikImage* aIcon);
+
+		/**
+		* Sets navi pane title.
+		* @param aTitle.
+		* @return None.
+		*/
+		void SetNaviPaneTitleL(const TDesC& aTitle);
+		
+		/**
+		* Sets navi pane title.
+		* @param aTitle.
+		* @return None.
+		*/
+		void SetNaviPaneTitle(const TDesC& aTitle);
+		
+		/**
+		* Sets navi pane title.
+		* @param aTitle.
+		* @return None.
+		*/
+		void SetNaviPaneTitleL(TInt aResource);
+		
+		/**
+		* Store navi pane.
+		* @param None.
+		* @return None.
+		*/
+		void StoreNavipaneL();
+
+	private:
+		// access to app ui
+		CAknAppUi* iAppUi;
+
+		// original status pane title
+		TBuf<KBufSize> iOriginalTitle;
+		
+		// is original status pane title stored
+		TBool iOriginalTitleStored;
+
+		// original context pane image
+		CEikImage* iOriginalImage;
+		
+   	    CAspNaviPaneHandler* iNaviPaneHandler;
+	};
+
+
+
+
+/**
+* CAspSelectionItemList
+*
+* Needed for using cleanupstack with CSelectionItemList.
+*/
+NONSHARABLE_CLASS (CAspSelectionItemList) : public CSelectionItemList
+	{
+    public:
+	    /**
+        * C++ default constructor.
+        */
+	    CAspSelectionItemList(TInt aGranularity);
+
+	    /**
+         * Callback for operator TCleanupItem().
+         */
+	    static void Cleanup(TAny* aObj);
+	};
+
+
+
+
+/**
+*  CAspListItemData
+*  
+*  CAspListItemData represents one setting item in UI setting list
+*/
+NONSHARABLE_CLASS (CAspListItemData) : public CBase
+	{
+	public:
+		enum TAspListItemType
+			{
+			ETypeInternetAccessPoint,
+			ETypeList,
+			ETypeBearerList,
+			ETypeProtocolList,
+			ETypeLocalDatabase,
+			ETypeListYesNo,
+			ETypeSecret,
+			ETypeHostAddress,
+			ETypeFilter,
+			ETypeUseFilters,
+			ETypeSyncContent,
+			ETypeAutoSyncProfile,
+			ETypeAutoSyncContent,
+			ETypeAutoSyncFrequency,
+			ETypeAutoSyncDays,
+			ETypeAutoSyncPeakSchedule,
+			ETypeAutoSyncOffPeakSchedule,
+			ETypeAutoSyncTime,
+			ETypeNumber,
+			ETypeBoolean,
+			ETypeText,
+			ETypeText8,
+			ETypeDate,
+			ETypeTime,
+			ETypeSchedulingSetting,
+			ETypeProfileSetting
+			
+			};
+			
+	public:
+		static CAspListItemData* NewLC();
+    	CAspListItemData();
+		virtual ~CAspListItemData();
+		void ConstructL();
+
+	public:	
+		void SetHeaderL(const TDesC& aText);
+		void SetHeaderL(TInt aResourceId);
+		void SetValueL(const TDesC& aText);
+		void SetValueL(TInt aNumber);
+		void SetDisplayValueL(const TDesC& aText);
+		void SetDisplayValueL(TInt aResource);
+		const TDesC& Header();
+		const TDesC& Value();
+		HBufC* ListItemTextL(TBool aConvert);
+		void Init();
+		TBool IsEmpty();
+
+	public:
+		// number type setting data
+		TInt iNumberData;
+		
+		// date type setting
+		TTime iDate;
+		
+		// time type setting
+		TTime iTime;
+
+		// setting item type
+		TInt iItemType;
+    	
+    	// is setting shown in UI
+		TInt iHidden;
+		
+		// max length for text type setting
+		TInt iMaxLength;
+		
+		// setting editor resource id
+		TInt iResource;
+
+		// list index
+		TInt iIndex;	
+
+		// item id
+		TInt iItemId;
+
+        // is settimg mandatory
+		TBool iMandatory;
+		
+		// is latin input needed ???
+		TBool iLatinInput;
+		
+		// min number type setting value
+		TInt iMinValue;
+
+		// max number type setting value
+		TInt iMaxValue;
+		
+		// filter item - used only in CAspFilterDialog
+		//CAspFilter* iFilter;
+		
+		// did user press "Select" key or "Change" menu option
+		TBool iSelectKeyPressed;
+
+	private:
+		// used in UI when value is empty
+		HBufC*  iDisplayValue;
+		
+		// setting header (title)		
+		HBufC* iHeader;
+
+	    // text type setting value
+	    HBufC* iValue;
+	};
+
+
+
+
+typedef CArrayPtr<CAspListItemData> CAspSettingList; //setting item list for profile page
+
+/**
+* CAspRadioButtonSettingPageEditor
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspRadioButtonSettingPageEditor) : public CAknRadioButtonSettingPage
+	{
+    public:
+        CAspRadioButtonSettingPageEditor(TInt aResourceID, TInt& aCurrentSelectionIndex, 
+		                           const MDesCArray* aItemArray);
+        ~CAspRadioButtonSettingPageEditor();            
+        
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	};
+
+
+/**
+* CAspTextSettingPagePageEditor
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspTextSettingPageEditor) : public CAknTextSettingPage
+	{
+    public:
+        CAspTextSettingPageEditor(TInt aResourceID,TDes& aText,TInt aTextSettingPageFlags);                                                    
+                                                     
+        ~CAspTextSettingPageEditor();            
+        
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	};
+
+
+/**
+* CAspAlphaPasswordSettingPageEditor
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspAlphaPasswordSettingPageEditor) : public CAknAlphaPasswordSettingPage
+	{
+    public:
+        CAspAlphaPasswordSettingPageEditor(TInt aResourceID, TDes& aNewPassword,const TDesC& aOldPassword);                                                    
+                                                     
+        ~CAspAlphaPasswordSettingPageEditor();            
+        
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	};
+
+/**
+* CAspAlphaPasswordSettingPageEditor
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspIntegerSettingPageEditor) : public CAknIntegerSettingPage
+	{
+    public:
+        CAspIntegerSettingPageEditor(TInt aResourceID, TInt& aValue, TInt aTextSettingPageFlags);                                                    
+                                                     
+        ~CAspIntegerSettingPageEditor();            
+        
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	};
+
+
+#endif      // ASPDIALOGUTIL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspFilter.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,311 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 general data definitions for AspSyncUtil.
+*
+*/
+
+
+
+#ifndef ASPFILTER_H
+#define ASPFILTER_H
+
+
+// INCLUDES
+#include <e32base.h>
+#include <ecom.h>
+
+#include <SyncMLClient.h>    // RSyncMLSession
+#include <SyncMLClientDS.h>  // RSyncMLDataSyncProfile
+
+#include <syncmldatafilter.h>
+//#include <syncmldatafilter.hrh>
+
+
+#include <AknCheckBoxSettingPage.h>  // CSelectionItemList
+
+
+#include "aspdefines.h"
+#include "asputil.h"
+
+
+
+
+
+// CONSTANTS
+
+const TInt KFilterBaseId = 1000;
+const TInt KFilterItemBaseId = 2000;
+
+
+// FORWARD DECLARATIONS
+class CAspFilterItem;
+
+
+// CLASS DECLARATION
+
+
+
+/**
+* CAspFilterList
+*
+* CAspFilterList is used for sync filter operations.
+*/
+NONSHARABLE_CLASS (CAspFilterList) : public CBase
+    {
+
+    public:
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspFilterList* NewL(const TAspParam& aParam, RPointerArray<CSyncMLFilter>& aArray);
+
+	    /**
+        * Destructor.
+        */
+        ~CAspFilterList();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspFilterList(const TAspParam& aParam, RPointerArray<CSyncMLFilter>& aArray);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+	    
+    public:
+        //void InitAllFiltersL();
+        void InitFiltersL();
+        TInt Count();
+        void SetFiltersEnabledL(TBool aEnable);
+        TBool FiltersEnabled();
+        CAspFilter* Item(TInt aIndex);
+        CAspFilter* ItemForId(TInt aId);
+        void SaveL();
+    
+    private:
+		// application id
+		TInt iApplicationId;
+		
+		// sync task
+		//CAspTask* iAspTask;
+		
+		// list of filters
+		RPointerArray<CAspFilter> iFilterList;
+		
+		// is filter feature enabled
+		TBool iFiltersEnabled;
+		
+		RPointerArray<CSyncMLFilter> iArray;
+     };
+
+
+
+
+/**
+* CAspFilter
+*
+* CAspTask is used for sync filter operations.
+*/
+NONSHARABLE_CLASS (CAspFilter) : public CBase
+    {
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspFilter* NewLC(CSyncMLFilter* aSyncFilter, TInt aId);
+
+
+	    /**
+        * Destructor.
+        */
+        ~CAspFilter();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspFilter(CSyncMLFilter* aSyncFilter, TInt aId);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+	    
+    public:
+        void SaveL();
+        const TDesC& DisplayName();
+        TInt Id();
+        void GetDisplayValueL(TDes& aText);
+        const TDesC& DisplayValueL();
+        TInt ItemCount();
+        CAspFilterItem* Item(TInt aIndex);
+        CAspFilterItem* ItemForId(TInt aId);
+        TBool Enabled();
+        void SetEnabledL(TBool aEnable);
+        
+    private:
+        void InitFilterItemsL();
+        
+   
+    private:
+		// application id
+		TInt iApplicationId;
+		
+		// temporary filter id
+		TInt iId;
+		
+		// sync filter
+		CSyncMLFilter* iSyncFilter;
+		
+		// list of filters
+		RPointerArray<CAspFilterItem> iFilterItemList;
+    };
+
+
+
+
+/**
+* CAspFilterItem
+*
+* CAspFilterItem is used for sync filter operations.
+*/
+NONSHARABLE_CLASS (CAspFilterItem) : public CBase
+    {
+    public:
+	enum TListType
+		{
+		ETypeQuery,
+	    ETypeSingleSelection,
+	    ETypeSingleSelectionUserDefined,
+	    ETypeMultipleSelection,
+	    ETypeMultipleSelectionUserDefined
+		};
+    
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspFilterItem* NewLC(CSyncMLFilterProperty* aProperty, TInt aId);
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspFilterItem* NewL(CSyncMLFilterProperty* aProperty, TInt aId);
+
+	    /**
+        * Destructor.
+        */
+        ~CAspFilterItem();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspFilterItem(CSyncMLFilterProperty* aProperty, TInt aId);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+	    
+    public:
+    
+        TInt ListType();
+        TInt DataType();
+        const TDesC& DisplayName();
+        const TDesC& DisplayValueL();
+        void GetDisplayValueL(TDes& aText);
+        void GetSelectionL(CSelectionItemList* aList);
+        void SetSelectionL(CSelectionItemList* aList);
+        void CheckEmptySelectionL();
+        TInt Id();
+        TBool IsMandatory();
+        TInt MaxLength();
+        
+    public:
+        void SetBoolL(TBool aBool);
+        TBool BoolL();
+        void SetTextL(const TDesC& aText);
+        void GetTextL(TDes& aText);
+        void GetText(TDes& aText);
+        TTime DateL();
+        void SetDateL(TTime aTime);
+        TTime TimeL();
+        void SetTimeL(TTime aTime);
+        TInt IntL();
+        void SetIntL(TInt aInt);
+
+
+    private:
+        void InitListTypeL();
+        void InitDataTypeL();
+
+        TInt SelectionAndQueryCount();
+        TInt SelectionIndex();
+        TBool QueryValueSelected();
+        
+        void GetQueryValueTextL(TDes& aText);
+        void SetQueryValueTextL(const TDesC& aText);
+        void GetListValueTextL(TDes& aText);
+        void GetListValueTextL(TDes& aText, TInt aIndex);
+
+        TBool IsMultipleSelection();
+        void UpdateQueryValueL(CSelectionItemList* aList);
+        void AddQueryValueL(CSelectionItemList* aList);
+        TInt SelectionCount();
+
+        
+        
+    private:
+		// application id
+		TInt iApplicationId;
+		
+		// filter item id
+		TInt iId;
+		
+		// editor type
+		TInt iListType;
+		
+		// data type
+		TInt iDataType;
+		
+		// temp buffer
+		TBuf<KBufSize> iBuf;
+
+		// temp buffer
+		TBuf8<KBufSize> iBuf8;
+		
+		// temp buffer
+		TBuf<KBufSize> iDisplayValueBuf;
+		
+		// sync filter propperty
+		CSyncMLFilterProperty* iProperty;
+     };
+
+
+
+
+
+
+
+#endif  // ASPFILTER_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspFilterDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,490 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 general data definitions for AspSyncUtil.
+*
+*/
+
+
+#ifndef ASPFILTERDIALOG_H
+#define ASPFILTERDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <eiklbo.h>
+#include <aknlists.h>
+#include <aknnavide.h>
+#include <AknDialog.h>
+
+#include <CAknCommonDialogsBase.h>  // TCommonDialogType
+#include <AknRadioButtonSettingPage.h>  // CAknRadioButtonSettingPage
+#include <AknCheckBoxSettingPage.h>  // CAknRadioButtonSettingPage
+
+
+#include "AspDialogUtil.h"
+
+
+
+
+// CLASS DECLARATION
+
+
+/**
+* CAspFilterDialog
+* 
+* CAspFilterDialog shows list of sync filter items. 
+*/
+NONSHARABLE_CLASS (CAspFilterDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+	public:
+	    /**
+        * Launches content dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(TAspParam& aParam);
+
+	private:
+
+		/**
+		* C++ default constructor.
+		* @param aParam Class that contains dialog parameters.
+		* @return None.
+		*/
+		CAspFilterDialog(TAspParam& aParam);
+
+						
+        /**
+        * Two-phased constructor.
+		* @param aParam Class that contains dialog parameters.
+        */
+		static CAspFilterDialog* NewL(TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+
+	    /**
+        * Destructor.
+        */
+		~CAspFilterDialog();
+
+	private:	
+
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+
+		/**
+		* From the base class.
+        * Handles key presses.
+        * @param aKeyEvent Key code.
+		* @param aType Key type.
+        * @return Result code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	
+		
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		virtual void ProcessCommandL(TInt aCommandId);
+
+		/**
+        * From the base class
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* Handle content parameter editing.
+		* @return None.
+		*/
+		void HandleOKL();
+
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+		
+	
+		/**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Id of the pressed button
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+	
+		/**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+		* @return None.
+        */
+		void PreLayoutDynInitL();
+
+		/**
+        * From MEikListBoxObserver.
+		* Handle listbox events.
+        * @param aListBox Pointer to used listbox.
+		* @param aEventType Event type.
+        * @return None.
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+	private:
+
+		/**
+		* Check that mandatory fields are set
+		* @return Index of the invalid mandatory item.
+		*/
+		TInt CheckMandatoryFieldsL();
+	
+		/**
+		* Save content parameters into profile.
+    	* @return None.
+		*/
+		void SaveSettingsL();
+
+		/**
+
+
+		/**
+		* Set filter type setting visibility.
+		* @param aVisible Visibility.
+		* @return None.
+		*/
+		void SetFilterSettingsVisibility(TBool aVisible);
+    
+    private:
+    		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+		
+		/**
+        * Create one CAspListItemData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Adds one setting item into item list.
+        * @param aItem.
+		* @return None.
+        */
+		void AddItemL(CAspFilterItem* aFilterItem);
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		static void InitSettingItemL(CAspListItemData* aItem);
+
+
+    public:
+        static TBool EditFilterL(CAspListItemData& aItem);
+        
+    private:
+		static TBool EditSettingItemL(CAspListItemData& aItem);
+        static TBool EditSettingItemQueryL(CAspListItemData& aItem);
+
+        static TBool EditSettingItemTextL(CAspListItemData& aItem);
+        static TBool EditSettingItemListL(CAspListItemData& aItem);
+        static TBool EditSettingItemBooleanL(CAspListItemData& aItem);
+        static TBool EditSettingItemNumberL(CAspListItemData& aItem);
+        static TBool EditSettingItemDateL(CAspListItemData& aItem);
+        static TBool EditSettingItemTimeL(CAspListItemData& aItem);
+
+        
+        static TBool EditMultiChoiceListL(CAspListItemData& aItem);
+        static TBool EditSingleChoiceListL(CAspListItemData& aItem);
+
+	 
+    private:
+		/**
+		* Utility function.
+		* @param aIndex Listbox index.
+		* @return setting item with listbox position aIndex.
+        */
+		CAspListItemData* ItemForIndex(TInt aIndex);
+
+		/**
+        * Utility function.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+
+  
+		/**
+		* Utility function.
+		* @param None.
+		* @return Sync profile.
+        */
+		RSyncMLDataSyncProfile& Profile();
+
+		/**
+		* Utility function.
+		* @param None.
+		* @return Sync task.
+        */
+		//RSyncMLTask& Task();
+
+		/**
+		* Utility function.
+		* @param None.
+		* @return Listbox.
+        */
+		CAknSettingStyleListBox* ListBox();
+		
+		/**
+		* Utility function.
+		* @param None.
+		* @return Pointer to resource handler.
+		*/
+		CAspResHandler* ResHandler();
+		
+		
+		/**
+        * Set setting item visibility (normal/readonly/hidden).
+        * @param None.
+		* @return None.
+        */
+		void SetVisibility();
+
+		
+		
+
+	private:
+		// id of the calling application
+		TInt iApplicationId;
+
+		// list box for setting items 
+		CAknSettingStyleListBox* iListBox;
+		
+		// setting items
+		CAspSettingList *iSettingList;
+		
+		// CEikStatusPane contains dialog title and image
+		CEikStatusPane* iStatusPane;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// session with sync server
+		RSyncMLSession* iSyncSession;
+		
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// sync task
+		CAspFilter* iFilter;
+		
+		// dialog parameters
+		TAspParam* iDialogParam;
+		
+		// resource handler
+		CAspResHandler* iResHandler;
+	};
+
+
+/**
+* MAspChoiceListObserver
+*
+* MAspChoiceListObserver is for handling choice list events.
+*/
+class MAspChoiceListObserver
+    {
+    public:
+	    virtual TBool HandleChoiceListEventL(TInt aEvent, TInt aListType) = 0;
+    };
+
+
+/**
+* CAspChoiceListSettingPage
+*
+* Radio button setting page that contains "User defined" option.
+*/
+NONSHARABLE_CLASS (CAspChoiceListSettingPage) : public CAknRadioButtonSettingPage
+	{
+    public:
+	enum TEditorType
+		{
+		ETypeNormal,
+	    ETypeUserDefined
+		};
+	
+    public: 
+	    CAspChoiceListSettingPage(TInt aResourceID, TInt& aCurrentSelectionIndex,
+                                  const MDesCArray* aItemArray, 
+                                  MAspChoiceListObserver* aObserver, TInt aType);
+        ~CAspChoiceListSettingPage();            
+	
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+	    
+	private:
+	    MAspChoiceListObserver* iObserver;
+	    TInt iType;
+	};
+
+
+/**
+* CAspMultiChoiceListSettingPage
+*
+* Check box button setting page that contains "User defined" option.
+*/
+NONSHARABLE_CLASS (CAspMultiChoiceListSettingPage) : public CAknCheckBoxSettingPage
+	{
+    public:
+	enum TEditorType
+		{
+		ETypeNormal,
+	    ETypeUserDefined
+		};
+	
+    public: 
+	    CAspMultiChoiceListSettingPage(TInt aResourceID, CSelectionItemList* aItemArray, 
+                                  MAspChoiceListObserver* aObserver, TInt aType);
+        ~CAspMultiChoiceListSettingPage();            
+	
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+	    
+	private:
+	    MAspChoiceListObserver* iObserver;
+	    TInt iType;
+	    CSelectionItemList* iSelectionList;
+	};
+
+
+
+/**
+* CAspChoiceList
+*
+* CAspChoiceList implemets choicelist with "User defined" item.
+*/
+NONSHARABLE_CLASS (CAspChoiceList) : public CBase, public MAspChoiceListObserver
+    {
+    public:
+	enum TListType
+		{
+		ETypeNormal,
+		ETypeTextUserDefined,
+	    ETypeIntegerUserDefined,
+	    ETypeDateUserDefined,
+	    ETypeTimeUserDefined
+		};
+
+    public:
+		static CAspChoiceList* NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength);
+		~CAspChoiceList();
+	private:
+		CAspChoiceList(const TDesC& aTitle, CSelectionItemList* iList, TInt aType, TInt aMaxLength);
+		void ConstructL();
+    
+    public:
+        TBool ShowListL();
+      
+    public:
+        void AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable);
+        void AddItemL(TDes& aText, TBool aEnable);
+        void AddItemL(TInt aNumber, TBool aEnable);
+        void AddUserDefinedL();
+        void RemoveUserDefinedL();
+        CDesCArray* DesArrayLC(CSelectionItemList* aList);
+        void SetSelectedIndex(CSelectionItemList* aList, TInt aIndex);
+        TInt SelectedIndex(CSelectionItemList* aList);
+        TBool EditTextL(TDes& aText, const TDesC& aTitle);
+
+
+    private: // from MAspChoiceListObserver
+	    TBool HandleChoiceListEventL(TInt aEvent, TInt aListType);
+
+
+	private:
+	    TInt  iUserDefinedInt;
+	    TBuf<KBufSize>  iUserDefinedText;
+	    TInt iMaxTextLength;
+	    
+	    TInt iListType;
+        TBuf<KBufSize> iTitle;
+        CSelectionItemList* iSelectionList;
+    };
+
+
+
+/**
+* CAspMultiChoiceList
+*
+* CAspChoiceList implemets multiple selection choicelist with "User defined" item.
+*/
+NONSHARABLE_CLASS (CAspMultiChoiceList) : public CBase, public MAspChoiceListObserver
+    {
+    public:
+		static CAspMultiChoiceList* NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength);
+		~CAspMultiChoiceList();
+	private:
+		CAspMultiChoiceList(const TDesC& aTitle, CSelectionItemList* iList, TInt aType, TInt aMaxLength);
+		void ConstructL();
+    
+    public:
+        TBool ShowListL();
+
+    
+    public:
+        void AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable);
+        void AddItemL(TDes& aText, TBool aEnable);
+        void AddItemL(TInt aNumber, TBool aEnable);
+        void AddUserDefinedL();
+        void RemoveUserDefinedL();
+        TBool EditTextL(TDes& aText, const TDesC& aTitle);
+    
+    private: // from MAspChoiceListObserver
+	    TBool HandleChoiceListEventL(TInt aEvent, TInt aListType);
+
+	private:
+	    TInt  iUserDefinedInt;
+	    TBuf<KBufSize>  iUserDefinedText;
+	    TInt iMaxTextLength;
+	    
+	    TInt iListType;
+        TBuf<KBufSize> iTitle;
+        CSelectionItemList* iSelectionList;
+    };
+
+
+
+#endif      // ASPFILTERDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspLogDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 general data definitions for AspSyncUtil.
+*
+*/
+
+
+#ifndef ASPLOGDIALOG_H
+#define ASPLOGDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <SyncMLHistory.h>
+
+#include "AspDefines.h"
+#include "AspProfile.h"
+#include "AspResHandler.h"
+
+
+
+
+/**
+* CAspLogDialog
+*  
+* CAspLogDialog shows sync log information.
+*/
+NONSHARABLE_CLASS (CAspLogDialog) : public CBase
+    {
+	
+	enum TLogItemType
+		{
+	    ELogAddedPhone,
+	    ELogUpdatedPhone,
+	    ELogDeletedPhone,
+	    ELogDiscardedPhone,
+	    ELogMovedPhone,
+	    ELogAddedServer,
+	    ELogUpdatedServer,
+	    ELogDeletedServer,
+	    ELogDiscardedServer,
+	    ELogMovedServer
+		};
+
+	public:
+	    /**
+        * Launches log dialog.
+		* @param None.
+        * @return None.
+        */
+		void ShowDialogL();
+
+    
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspLogDialog* NewL(const TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspLogDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspLogDialog(const TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+
+		/**
+        * Creates text lines that are shown in log dialog.
+		* @param aList.
+		* @param aProfile.
+		* @param aTaskList.
+        * @return None.
+        */
+		void CreateListL(CDesCArray* aList, CAspProfile* aProfile, CAspContentList* aTaskList);
+       
+		/**
+        * Adds one line into listbox array.
+    	* @param aList.
+		* @param aHistoryJob.
+		* @param aTaskList.
+        * @param aType.
+        * @return None.
+        */
+        void AddLogItemsL(CDesCArray* aList, const CSyncMLHistoryJob* aHistoryJob, 
+                                CAspContentList* aTaskList, TInt aType);
+                                
+		/**
+        * Adds one line into listbox array.
+    	* @param aList.
+		* @param aHistoryJob.
+		* @param aTaskList.
+        * @return None.
+        */
+        void AddTaskErrorsL(CDesCArray* aList, const CSyncMLHistoryJob* aHistoryJob, 
+                                CAspContentList* aTaskList);
+                                
+		/**
+        * Gets number of synced items.
+		* @param aTaskInfo.
+		* @param aType.
+        * @return Item count.
+        */
+        TInt SyncedItemCount(const CSyncMLHistoryJob::TTaskInfo& aTaskInfo, TInt aType);
+                                 
+		/**
+        * Get log item text.
+    	* @param aType.
+		* @param aDataProviderId
+		* @param aDisplayName
+        * @return None.
+        */
+        HBufC* LogItemTextLC(TInt aType, TInt aDataProviderId, const TDesC& aDisplayName);
+        
+		/**
+        * Add one line into log item list.
+    	* @param aList.
+		* @param aText
+        * @return None.
+        */
+        void AddLineL(CDesCArray* aList, TDes& aText);
+        
+		/**
+        * Gets latest history (sync) job.
+		* @param aHistoryLog.
+        * @return History job.
+        */
+        CSyncMLHistoryJob* LatestHistoryJob(RSyncMLHistoryLog& aHistoryLog);
+ 
+		/**
+        * Has server been modified during sync.
+    	* @param aHistoryJob.
+        * @return TBool.
+        */
+        TBool ServerModified(const CSyncMLHistoryJob* aHistoryJob);
+
+		/**
+        * Has phone been modified during sync.
+    	* @param aHistoryJob.
+        * @return TBool.
+        */
+        TBool PhoneModified(const CSyncMLHistoryJob* aHistoryJob);
+        
+		/**
+        * Has there been task errors during sync.
+    	* @param aHistoryJob.
+        * @return TBool.
+        */
+        TBool HasTaskErrors(const CSyncMLHistoryJob* aHistoryJob);
+
+
+	private:
+        // profile id
+		TInt iProfileId;
+		
+    	// session with sync server - only used in ConstructL
+		RSyncMLSession* iSyncSession;
+	
+		// resource handler
+		CAspResHandler* iResHandler;
+		
+        // for string handling
+		TBuf<KBufSize255> iBuf;
+		
+        // for string handling
+		TBuf<KBufSize255> iBuf2;
+
+		// list of text lines that are shown in log dialog
+		CDesCArrayFlat* iList;
+	};
+
+
+
+
+
+#endif      // ASPLOGDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspPreSyncPluginInterface.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Roaming warning plugin interface implementation 
+*
+*/
+
+#ifndef ASPPRESYNCPLUGININTERFACE_H
+#define ASPPRESYNCPLUGININTERFACE_H
+
+// INCLUDE FILES
+#include <s32mem.h>
+#include <coemain.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationinformation.h>
+#include <SyncMLDef.h>
+
+class CPreSyncPlugin;
+
+/**
+* Class is used to instantiate the required plugins when the search has been
+* asked. Acts as interface to all Plugins.
+*/
+
+class CPreSyncPluginInterface: public CBase 
+{
+	public:
+
+		/** 
+		* Symbian OS 2 phased constructor.
+		* @return	A pointer to the created instance of CPreSyncPluginInterface.
+		*/
+		static CPreSyncPluginInterface* NewL();
+
+		/** 
+		* Symbian OS 2 phased constructor.
+		* @return	A pointer to the created instance of CPreSyncPluginInterface.
+		*/
+		static CPreSyncPluginInterface* NewLC();
+
+		/**
+		* Destructor.
+		*/      
+		virtual ~CPreSyncPluginInterface();
+
+		/**
+		* Instantiates the required search plug-ins known by the ecom framework.
+		* basically this function first calls ListAllImplementationsL()
+		* and then checks them one by one to match the algorithm name
+		*/
+		void InstantiatePluginL();
+		
+		CPreSyncPlugin* InstantiateRoamingPluginLC( TSmlProfileId aProfileId );
+
+		/**
+		* Unloads all plugins
+		* This should internally call  REComSession::DestroyedImplementation( iDtor_ID_Key )
+		* and then REComSession::FinalClose()
+		*/
+		void UnloadPlugIns(); 
+
+		/**
+		* Lists all implementations which satisfy this ecom interface
+		*
+		* @param aImplInfoArray On return, contains the list of available implementations
+		* 
+		*/   
+		void ListAllImplementationsL( RImplInfoPtrArray& aImplInfoArray );
+		
+
+		/**
+		* Forwards the request to check if language is supported
+		* to the algorithm instance
+		*/
+		TBool IsDefault();   
+		              
+		/**
+		* Forwards the request to recover data fields order for a URI
+		* to the algorithm instance
+		*/
+		TBool IsProfileYours(TSmlProfileId aProfileId);
+
+		/**
+		* Forwards the request to recover sort order for a URI
+		* to the algorithm instance
+		*/
+		void Handle(TSmlProfileId aProfileId); 
+
+	private: 
+
+		/** 
+		* Performs the first phase of two phase construction.
+		*/
+		CPreSyncPluginInterface();  
+
+		/** 
+		* Symbian OS 2 phased constructor.
+		*/
+		void ConstructL();
+
+		/**
+		* Instantiates a PCS plug-in, knowing the implementation uid.
+		* @param aImpUid imp uID
+		*/
+		CPreSyncPlugin* InstantiatePlugInFromImpUidLC( const TUid& aImpUid );
+
+
+	private: 
+
+	    /** iDtor_ID_Key Instance identifier key. When instance of an
+	         *               implementation is created by ECOM framework, the
+	         *               framework will assign UID for it. The UID is used in
+	         *               destructor to notify framework that this instance is
+	         *               being destroyed and resources can be released.
+	         */
+	    TUid iDtor_ID_Key;
+
+		// List of plugins that this interface will interact with
+		RPointerArray<CPreSyncPlugin>  iPluginInstances; 
+
+		// Uid of the algorithm in use
+		TUid iPluginInUse;
+};
+
+#endif // ASPPRESYNCPLUGININTERFACE_H
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfile.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1287 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Profile structure mapped to server side data sync profile 
+*
+*/
+
+
+#ifndef ASPPROFILE_H
+#define ASPPROFILE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <ecom.h>
+
+#include <SyncMLClient.h>    // for RSyncMLSession
+#include <SyncMLClientDS.h>  // for RSyncMLDataSyncProfile
+
+#include "AspDefines.h"
+#include "AspUtil.h"
+
+//For Error EAZG-7KGAK8. Language definiton not found in elang.h 
+const TInt ELangIndon_Apac=327;
+const TUid KCRUidDSDefaultProfileInternalKeys  = { 0x20021338 };
+const TInt KNsmlDsDefaultProfile = 0x0;
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CAspProfile;
+
+
+// CLASS DECLARATION
+
+
+
+/**
+* TAspProfileItem
+*
+* TAspProfileItem contains sync profile data.
+*/
+NONSHARABLE_CLASS (TAspProfileItem)
+	{
+	public:
+		/**
+		* Get profile name.
+		* @param None.
+        * @return Profile name.
+        */
+		const TDesC& Name();
+
+		/**
+		* Get profile name.
+		* @param None.
+        * @return Profile name.
+        */
+		HBufC* NameLC();
+
+		/**
+		* Set profile name.
+		* @param aName.
+        * @return None.
+        */
+		void SetName(const TDesC& aName);
+		
+		/**
+		* Initalize object data.
+		* @param None.
+        * @return None.
+        */
+		void Init();
+
+	public:
+		/**
+		* Compare two profile items.
+		* @param aFirst.
+		* @param aSecond.		
+        * @return Compare result.
+        */
+		static TInt CompareItems(const TAspProfileItem& aFirst, const TAspProfileItem& aSecond);
+
+	public:
+		// profile name
+		TBuf<KBufSize> iProfileName;	
+		
+		// profile id 
+		TInt iProfileId;
+		
+		// is profile synced
+		TInt iSynced;
+		
+		// last sync time
+		TTime iLastSync;
+		
+		// bearer type
+		TInt iBearer;
+		
+		// is server alert sync activated
+		TInt iActive;
+		
+		// can profile be deleted
+		TBool iDeleteAllowed;
+		
+		// application id
+		TInt iApplicationId;
+
+		// is all mandatory data found 
+		TInt iMandatoryCheck;
+		
+		// number of sync tasks
+		TInt iTaskCount;
+		
+		// application specific sync task id
+		TInt iTaskId;
+		
+		// server id check sum
+		TUint16 iServerIdCheckSum;
+
+	};
+
+
+
+/**
+* TAspTaskItem
+* 
+* TAspTaskItem contains sync task data.
+*/
+NONSHARABLE_CLASS (TAspTaskItem)
+	{
+	public:
+	    // task id
+    	TInt  iTaskId;
+    	
+    	// sync direction
+		TInt  iSyncDirection;
+		
+		// is remote database defined
+		TBool iRemoteDatabaseDefined;
+		
+		// is local database defined
+		TBool iLocalDatabaseDefined;
+		
+		// is task included in sync
+		TBool iEnabled;
+		
+		// id of data provider that this task uses
+		TInt  iDataProviderId;
+		
+		// last sync time
+		TTime	 iLastSync;
+
+		// task display name
+	    TBuf<KBufSize> iDisplayName;
+	    TBuf<KBufSize> iClientDataSource;
+    };
+
+
+/**
+* TAspDataProviderItem
+* 
+* TAspDataProviderItem contains data provider data.
+*/
+NONSHARABLE_CLASS (TAspProviderItem)
+	{
+    enum TProviderListSortOrder
+	    {
+	    EOrderContact = 4,
+	    EOrderCalendar = 3,
+	    EOrderNotes = 2,
+	    EOrderEmail = 1,
+	    EOrderOther = 0
+    	};
+	
+	public:
+		/**
+		* Compare two profile items.
+		* @param aFirst.
+		* @param aSecond.		
+        * @return Compare result.
+        */
+		static TInt CompareItems(const TAspProviderItem& aFirst, const TAspProviderItem& aSecond);
+		static TInt SortOrder(TInt aDataProviderId);
+	
+	public:
+	    // data provider id
+		TInt  iDataProviderId;
+		
+		// can more than one database be synced 
+		TBool iAllowMultipleDataStores;
+		
+		// is default data store defined
+		TBool iHasDefaultDataStore;
+		
+		// sync protocol
+		TInt  iSyncProtocol;
+
+        // id of sync task that is using this data provider
+		TBool iTaskId;
+		
+		// display name
+	    TBuf<KBufSize> iDisplayName;
+	    
+	   	// default data store name
+		TBuf<KBufSize> iDefaultDataStore;
+		
+		// is this provider included in sync (profile specific)
+		TBool iIsIncludedInSync;
+	};
+
+
+/**
+* TAspFilterInfo
+* 
+* TAspFilterInfo contains profile list filtering data.
+*/
+NONSHARABLE_CLASS (TAspFilterInfo)
+	{
+	public:
+	enum TFilterType
+		{
+	    EIncludeDeletableProfile,
+	    EIncludeRemoteProfile
+		};
+
+	public:
+	    // filter type
+		TInt iFilterType;
+		
+		// filter id (eg. application id 
+		TBool iFilterId;
+		
+		// filter text
+		TBuf<KBufSize>  iFilterText;
+	};
+
+
+/**
+* CAspContentList 
+*
+* CAspContentList contains sync task list and data provider list.
+*/
+NONSHARABLE_CLASS (CAspContentList): public CBase
+    {
+    public:
+
+	enum TListMode
+		{
+	    EInitDataProviders,
+	    EInitTasks,
+	    EInitAll
+		};
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspContentList* NewLC(const TAspParam& aParam);
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspContentList* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspContentList();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspContentList(const TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	public:
+		/**
+		* Sets sync profile.
+		* @param aProfile.
+        * @return None.
+        */
+		void SetProfile(CAspProfile* aProfile);
+		
+		/**
+		* Find out whether iProfile has been set.
+		* @param None.
+        * @return TBool.
+        */
+		TBool IsLocked();
+	
+		/**
+		* Returns data provider count.
+		* @param None.
+        * @return Data provider count.
+        */
+		TInt ProviderCount();
+
+		/**
+		* Returns Data provider.
+        * @param aIndex List index.
+		* @return Data provider.
+        */
+		TAspProviderItem& ProviderItem(TInt aIndex);
+		
+		/**
+		* Returns list index.
+        * @param aId.
+		* @return List index.
+        */
+        TInt FindProviderIndex(TInt aId);		
+
+		/**
+		* Returns list index.
+        * @param aId.
+		* @return List index.
+        */
+        TInt FindProviderIndexForTask(TInt aId);		
+
+		/**
+		* Returns task count.
+        * @return Task count.
+        */
+		TInt TaskCount();
+		
+		/**
+		* Returns task item.
+        * @param aIndex.
+		* @return Task item.
+        */
+		TAspTaskItem& TaskItem(TInt aIndex);
+		
+		/**
+		* Returns list index.
+        * @param aId.
+		* @return List index.
+        */
+        TInt FindTaskIndex(TInt aId);		
+
+		/**
+		* Returns list index.
+        * @param aId.
+		* @return List index.
+        */
+        TInt FindTaskIndexForProvider(TInt aId);		
+
+		/**
+		* Returns task id.
+        * @param aId.
+		* @return Task id.
+        */
+        TInt FindTaskIdForProvider(TInt aId);		
+		
+		/**
+		* Checks that data provider has default local database.
+		* @param aDataProviderId.
+		* @return ETrue if database exists, EFalse otherwise.
+        */
+		//TBool DefaultLocalDatabaseExist(TInt aDataProviderId);
+		
+		/**
+		* Checks that all content items are valid.
+		* @param aContentCount.
+		* @return Return code.
+        */
+		TInt CheckMandatoryDataL(TInt& aContentCount);
+        
+	public:
+
+		/**
+		* Read sync data providers from RSyncMLSession.
+		* @return None.
+        */
+		void InitDataProvidersL();
+		
+		/**
+		* Read sync data providers from RSyncMLSession.
+		* @return None.
+        */
+		void DoInitDataProvidersL();
+
+		/**
+		* Read all tasks from profile into task list.
+		* @return None.
+        */
+		void InitAllTasksL();
+
+		/**
+		* Read one task from profile into task list.
+		* @return None.
+        */
+		void InitTaskL(TInt aTaskId);
+		
+		/**
+		* Remove task that uses dataprovider aDataProviderId.
+		* @param aDataProviderId.
+		* @return None.
+        */
+		void RemoveTask(TInt aDataProviderId);
+		
+		/**
+		* Remove all tasks from task list.
+		* @param None.
+		* @return None.
+        */
+		void RemoveAllTasks();
+
+		/**
+		* Remove data provider with id aDataProviderId.
+		* @param aDataProviderId.
+		* @return None.
+        */
+		void RemoveDataProvider(TInt aDataProviderId);
+
+		/**
+		* Read one task item from profile.
+        * @param aProfile.
+        * @param aTaskId.
+		* @return Task item.
+        */
+		static TAspTaskItem ReadTaskItemL(RSyncMLDataSyncProfile& aProfile, TInt aTaskId);
+		
+		
+		TInt CreateTaskL(TAspProviderItem& aDataProvider);
+        void CreateTaskL(TInt aDataProviderId, const TDesC& aLocalDatabase,
+                         const TDesC& aRemoteDatabase, TBool aEnabled, TInt aSyncDirection);
+        void CreateTask(TInt aDataProviderId, const TDesC& aLocalDatabase,
+                         const TDesC& aRemoteDatabase, TBool aEnabled, TInt aSyncDirection);
+
+
+        void ReadTaskL(TInt aDataProviderId, TDes& aLocalDatabase, TDes& aRemoteDatabase, TBool& aEnable, TInt& aSyncDirection);
+
+ 
+		void IncludeTaskL(TAspProviderItem& aDataProvider);
+		void IncludeTasks(const CArrayFix<TInt>* aIncludedProviderList);
+		
+		void ModifyTaskIncludedL(TInt aDataProviderId, TBool aIsIncluded, const TDesC& aLocalDatabase);
+		void ModifyTaskIncludedL(TAspProviderItem& aProvider, TBool aIsIncluded, const TDesC& aLocalDatabase);
+		void ModifyTaskDirectionL(TAspProviderItem& aProvider, TInt aDirection);
+		void ModifyTaskDirectionsL(TInt aSyncDirection);
+		TBool CheckTaskDirectionsL();
+		
+		void SetIncludedProviders(const CArrayFix<TInt>* aIncludedProviderList);
+		void GetIncludedProviders(CArrayFix<TInt>* aIncludedProviderList);
+		
+
+		
+		void GetLocalDatabaseList(TInt aDataProviderId, CDesCArray* aList);
+		void GetLocalDatabaseListL(TInt aDataProviderId, CDesCArray* aList);
+		void UpdateLocalDatabaseL();
+		TInt SyncDirection();
+		TSmlSyncType SmlSyncDirection();
+		TBool TaskEnabled(TInt aDataProviderId);
+    	void Sort();
+    	void UpdateDataProviderL(TInt aDataProviderId);
+    	void ReadDataProviderItemL(RSyncMLDataProvider& aProvider, TAspProviderItem& aItem);
+
+
+		
+		
+    private:
+    
+		/**
+		* Utility function.
+		* @return Sync session.
+        */
+		RSyncMLSession& Session();
+
+		/**
+		* Returns sync profile.
+		* @param None.
+		* @return Sync profile.
+        */
+		RSyncMLDataSyncProfile* Profile();
+		
+		
+#ifdef _DEBUG
+    public:
+        void LogL(const TDesC& aText);
+    private:
+    
+        void LogTasksL();
+        void LogDataProvidersL();
+        void GetTaskLogText(TDes& aText, TAspTaskItem& aTask);
+        void GetDataProviderIdText(TDes& aText, TInt aId);
+#endif
+		
+
+
+    private:
+		// id of the calling application
+		TInt iApplicationId;
+    
+		// sync session
+		RSyncMLSession* iSyncSession;
+		
+		// sync profile
+		CAspProfile* iProfile;
+
+		// sync list type
+		TInt iListMode;
+        
+		// data provider list
+		RArray<TAspTaskItem> iTaskList;
+
+		// data provider id list
+		RArray<TAspProviderItem> iProviderList;
+    };
+
+
+
+/**
+* CAspProfileList 
+*
+* CAspProfileList is a list of sync profiles,
+*/
+NONSHARABLE_CLASS (CAspProfileList) : public CBase
+    {
+    public:
+
+	enum TListMode
+		{
+	    EBasePropertiesOnly,
+	    ENoMandatoryCheck,
+	    EMandatoryCheck,
+	    EMandatoryCheckEx,
+	    EEMailRetrieve,
+	    EEMailSync,
+		};
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfileList* NewLC(const TAspParam& aParam);
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfileList* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspProfileList();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspProfileList(const TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	public:
+		/**
+		* Returns profile count.
+        * @param None.
+        * @return Profile count.
+        */
+		TInt Count();
+
+		/**
+		* Returns profile count.
+        * @param aApplicationId.
+        * @return Profile count.
+        */
+		TInt Count(TInt aApplicationId);
+
+		/**
+		* Returns profile from list.
+        * @param aIndex List index.
+		* @return Profile.
+        */
+		TAspProfileItem& Item(TInt aIndex);
+
+		/**
+		* Finds profile with name aProfileName.
+		* @param aProfileName Profile name.
+		* @return Profile index or KErrNotFound.
+        */
+		TInt FindProfileIndex(const TDesC& aProfileName);
+		
+		/**
+		* Gets the Default Profile ID from the Cenrep
+		* @param aValue ProfileID read from the Cenrep
+     */
+		void GetDefaultProfileIdL(TInt& aValue);
+		
+		/**
+		* Finds last synced profile index.
+		* @param aProfileName Profile name.
+		* @return Profile index or KErrNotFound.
+        */
+		TInt FindLastSyncedProfileIndexL();
+		
+		/**
+		* Read one profile from database.
+		* @param aProfile.
+		* @param aItem.
+		* @return None.
+        */
+        void ReadProfileItemL(CAspProfile* aProfile, TAspProfileItem& aItem);
+
+		/**
+		* Reads all profiles from database.
+		* @param aListMode.
+		* @return None.
+        */
+		void ReadAllProfilesL(TInt aListMode);
+		
+		/**
+		* Reads all profiles that contain EMail task that uses aLocalDatabase.
+		* @param aLocalDatabase.
+		* @param aListMode.
+		* @return None.
+        */
+		void ReadEMailProfilesL(const TDesC& aLocalDatabase,  TInt aListMode);
+
+		/**
+		* Reads one profile from database.
+		* @param aProfileId.
+		* @return None.
+        */
+		void ReadProfileL(TInt aProfileId);
+
+		/**
+		* Sorts profile list.
+		* @param None.
+		* @return None.
+        */
+    	void Sort();
+
+		/**
+		* Removes profile from profile list.
+		* @param aProfileId.
+		* @return None.
+        */
+		void Remove(TInt aProfileId);
+		
+		/**
+		* Adds profile into profile list.
+		* @param aProfileItem.
+		* @return None.
+        */
+		void AddL(TAspProfileItem& aProfileItem);
+		
+		/**
+		* Constructs filtered profile list.
+		* @param aFilterInfo.
+		* @return Profile list.
+        */
+		CAspProfileList* FilteredListL(TAspFilterInfo& aFilterInfo);
+
+		/**
+		* Replaces profile item.
+		* @param aProfileItem.
+		* @return None.
+        */
+		void ReplaceProfileItemL(TAspProfileItem& aProfileItem);
+
+		/**
+		* Returns profile's list position.
+		* @param aProfileId.
+		* @return List index.
+        */
+		TInt ListIndex(TInt aProfileId);
+		
+		/**
+		* Returns sync session.
+		* @param None.
+		* @return Sync session.
+        */
+		RSyncMLSession& Session();
+		
+		/**
+		* Returns number of profiles that can be deleted.
+		* @param None.
+		* @return Profile count.
+        */
+		TInt DeletableProfileCount();
+		
+		TBool IsAutoSyncProfile(CAspProfile* aProfile);
+		
+	public:
+                             
+		/**
+		* Checks if aServerId is unique in setting databse.
+		* @param aServerId.
+		* @param aProfileId.
+		* @return Return code.
+        */
+        TBool IsUniqueServerId(const TDesC& aServerId, TInt aProfileId);                             
+
+		
+
+	private:
+   		// sync session
+		RSyncMLSession* iSyncSession;
+        
+		// list of profiles
+		RArray<TAspProfileItem> iList;
+
+		// needed for filtering unwanted profiles
+		TInt iApplicationId;
+		
+		// long buffer for string handling 
+		TBuf<KBufSize255> iBuf;
+    };
+
+
+
+/**
+* CAspProfile 
+*
+* CAspProfile is used for getting/setting sync profile settings.
+*/
+NONSHARABLE_CLASS (CAspProfile) : public CBase
+    {
+    
+    public:
+	enum TOpenMode
+		{
+	    EOpenReadWrite,
+	    EOpenRead,
+	    EBaseProperties,
+	    EAllProperties
+		};
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfile* NewLC(const TAspParam& aParam);
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfile* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspProfile();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspProfile(const TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+	    
+    public:
+		/**
+		* Open profile.
+		* @param aProfileId.
+		* @param aReadWrite.
+		* @param aOpenMode.
+		* @return None.
+        */
+        void OpenL(TInt aProfileId, TInt aReadWrite, TInt aOpenMode);
+        
+		/**
+		* Create profile.
+		* @param aOpenMode.
+		* @return None.
+        */
+        void CreateL(TInt aOpenMode);
+
+		/**
+		* Create copy profile.
+		* @param aProfileId.
+		* @return None.
+        */
+        void CreateCopyL(TInt aProfileId);
+        
+		/**
+		* Save profile.
+		* @param None.
+		* @return None.
+        */
+        void SaveL();
+        
+		/**
+		* Save profile.
+		* @param None.
+		* @return None.
+        */
+        void Save();
+
+	public:
+		/**
+		* Set profile name.
+		* @param aText.
+		* @return None.
+        */
+        void SetNameL(const TDesC& aText);
+
+		/**
+		* Get profile name.
+		* @param aText.
+		* @return None.
+        */
+        void GetName(TDes& aText);
+
+		/**
+		* Get profile name.
+		* @param None.
+		* @return Profile name.
+        */
+        HBufC* NameL();
+        
+		/**
+		* Set creator id.
+		* @param aCreatorId.
+		* @return None.
+        */
+        void SetCreatorId(TInt aCreatorId);
+        
+		/**
+		* Get creator id.
+		* @param None.
+		* @return Creator id.
+        */
+        TInt CreatorId();
+        
+		/**
+		* Get profile id.
+		* @param None.
+		* @return Profile id.
+        */
+        TInt ProfileId();
+        
+		/**
+		* Can profile be deleted.
+		* @param None.
+		* @return Boolean.
+        */
+        TBool DeleteAllowed();
+
+		/**
+		* Has profile been synced.
+		* @param None.
+		* @return Boolean.
+        */
+		TBool IsSynced();
+
+		/**
+		* Last sync time.
+		* @param None.
+		* @return Sync time.
+        */
+		TTime LastSync();
+    
+		/**
+		* Last sync time.
+		* @param aTaskId.
+		* @return Sync time.
+        */
+		TTime LastSync(TInt aTaskId);
+
+    
+    // settings that connection dialog displays
+    public:
+		/**
+		* Set server id.
+		* @param aText.
+		* @return None.
+        */
+        void SetServerIdL(const TDesC& aText);
+
+		/**
+		* Get server id.
+		* @param aText.
+		* @return None.
+        */
+        void GetServerId(TDes& aText);
+
+		/**
+		* Get protocol version.
+		* @param None.
+		* @return aProtocolVersion.
+        */
+        TInt ProtocolVersion();
+
+		/**
+		* Set protocol version.
+		* @param aProtocolVersion.
+		* @return None.
+        */
+        void SetProtocolVersionL(TInt aProtocolVersion);
+
+		/**
+		* Get bearer type.
+		* @param None.
+		* @return Bearer type.
+        */
+        TInt BearerType();
+        
+		/**
+		* Set bearer type.
+		* @param aId.
+		* @return None.
+        */
+        void SetBearerTypeL(TInt aId);
+
+		/**
+		* Get access point.
+		* @param None.
+		* @return Access point.
+        */
+        TInt AccessPointL();
+        
+		/**
+		* Set access point.
+		* @param aId.
+		* @return None.
+        */
+        void SetAccessPointL(const TInt aId);
+
+		/**
+		* Get host address.
+		* @param aText.
+		* @param aPort.		
+		* @return None.
+        */
+        void GetHostAddress(TDes& aText, TInt& aPort);
+
+		/**
+		* Set host address.
+		* @param aText.
+		* @param aPort.		
+		* @return None.
+        */
+        void SetHostAddressL(const TDesC& aText, const TInt aPort);
+         
+		/**
+		* Get user name.
+		* @param aText.
+		* @return None.
+        */
+        void GetUserName(TDes& aText);
+
+		/**
+		* Set user name.
+		* @param aText.
+		* @return None.
+        */
+        void SetUserNameL(const TDesC& aText);
+        
+		/**
+		* Get password.
+		* @param aText.
+		* @return None.
+        */
+        void GetPassword(TDes& aText);
+
+		/**
+		* Set password.
+		* @param aText.
+		* @return None.
+        */
+        void SetPasswordL(const TDesC& aText);
+        
+		/**
+		* Set server alert sync state.
+		* @param aState.
+		* @return None.
+        */
+        void SetSASyncStateL(TInt aState);
+
+		/**
+		* Get server alert sync state.
+		* @param None.
+		* @return Server alert sync state.
+        */
+        TInt SASyncState();
+
+		/**
+		* Set http authentication state.
+		* @param aEnable.
+		* @return None.
+        */
+        void SetHttpUsedL(TBool aEnable);
+
+		/**
+		* Get http authentication state.
+		* @param aEnable.
+		* @return Boolean.
+        */
+        TBool HttpUsedL();
+         
+		/**
+		* Get http user name.
+		* @param aText.
+		* @return None.
+        */
+        void GetHttpUserNameL(TDes& aText);
+
+		/**
+		* Set http user name.
+		* @param aText.
+		* @return None.
+        */
+        void SetHttpUserNameL(const TDesC& aText);
+ 
+		/**
+		* Get http password.
+		* @param aText.
+		* @return None.
+        */
+        void GetHttpPasswordL(TDes& aText);
+        
+		/**
+		* Set http password.
+		* @param aText.
+		* @return None.
+        */
+        void SetHttpPasswordL(const TDesC& aText);
+ 
+               
+    public:
+  		/**
+		* Open history log.
+		* @param None.
+		* @return None.
+        */
+        void OpenHistoryLog();
+        
+  		/**
+		* Open connection.
+		* @param None.
+		* @return None.
+        */
+        void OpenConnection();
+
+  		/**
+		* Get RSyncMLDataSyncProfile.
+		* @param None.
+		* @return RSyncMLDataSyncProfile.
+        */
+        RSyncMLDataSyncProfile& Profile();
+        
+  		/**
+		* Get RSyncMLSession.
+		* @param None.
+		* @return RSyncMLSession.
+        */
+        RSyncMLSession& Session();
+        
+  		/**
+		* Get application id.
+		* @param None.
+		* @return Application id.
+        */
+        TInt ApplicationId();
+        
+    public:
+  		/**
+		* Get connection property name.
+		* @param aText.
+		* @param aPropertyPos.
+		* @return None.
+        */
+        void GetConnectionPropertyNameL(TDes8& aText, TInt aPropertyPos);
+
+  		/**
+		* Get sync type.
+		* @param aSyncTask.
+		* @return Sync type.
+        */
+        static TInt SyncType(RSyncMLTask& aSyncTask);
+
+  		/**
+		* Set default bearer.
+		* @param None.
+		* @return None.
+        */
+        void SetDefaultBearerL();
+        
+  		/**
+		* Get latest history job.
+		* @param None.
+		* @return History job.
+        */
+        const CSyncMLHistoryJob* LatestHistoryJob();
+        
+  		/**
+		* Get latest history job.
+		* @param aTaskId.
+		* @return History job.
+        */
+        const CSyncMLHistoryJob* LatestHistoryJob(TInt aTaskId);
+
+ 		/**
+		* Find out whether history job contains a task.
+		* @param aHistoryJob.
+		* @return Boolean.
+        */
+        TBool TaskExist(const CSyncMLHistoryJob* aHistoryJob, TInt aTaskId);
+        
+  		/**
+		* Copy values from another profile.
+		* @param aSource.
+		* @return None.
+        */
+        void CopyValuesL(CAspProfile* aSource);
+        
+  		/**
+		* Get default transport id.
+		* @param None.
+		* @return Transport id.
+        */
+        TInt DefaultTransportIdL();
+        
+  		/**
+		* Delete all connections.
+		* @param aId.
+		* @return None.
+        */
+        //void DeleteConnectionsL();
+        
+    public:
+  		/**
+		* Get new profile name.
+		* @param aList.
+		* @param aApplicationId.
+		* @return Profile name.
+        */
+        static HBufC* GetNewProfileNameLC(CAspProfileList* aList, TInt aApplicationId);
+        
+  		/**
+		* Set default values.
+		* @param aProfile.
+		* @return None.
+        */
+        static void SetDefaultValuesL(CAspProfile* aProfile);
+        
+  		/**
+		* Is other sync running.
+		* @param aSyncSession.
+		* @return Boolean.
+        */
+        static TBool OtherSyncRunning(RSyncMLSession* aSyncSession);
+
+  		/**
+		* Get current sync job.
+		* @param aSyncSession.
+		* @return Sync job.
+        */
+        static TInt CurrentJob(RSyncMLSession* aSyncSession);
+        
+  		/**
+		* Is this profile PCSuite profile.
+		* @param aProfile.
+		* @return Boolean.
+        */
+        static TBool IsPCSuiteProfile(CAspProfile* aProfile);
+        
+    public:
+  		/**
+		* Check mandatory task data.
+		* @param aProfile.
+		* @param aContentCount.
+		* @return Mandatory data status code.
+        */
+        static TInt CheckMandatoryTaskDataL(CAspProfile* aProfile, TInt& aContentCount);
+ 
+  		/**
+		* Check mandatory task data.
+		* @param aProfile.
+		* @param aContentCount.
+		* @return Mandatory data status code.
+        */
+        static TInt CheckMandatoryTaskData(CAspProfile* aProfile, TInt& aContentCount);
+        
+ 		/**
+		* Check mandatory data.
+		* @param aProfile.
+		* @param aContentCount.
+		* @return Mandatory data status code.
+        */
+        static TInt CheckMandatoryData(CAspProfile* aProfile, TInt& aContentCount);
+ 
+  		/**
+		* Check mandatory connection data.
+		* @param aProfile.
+		* @return Mandatory data status code.
+        */
+        static TInt CheckMandatoryConnData(CAspProfile* aProfile);
+    
+    	/**
+		* Delete sync history for a profile
+		* @param None
+		* @return None
+        */
+ 		void DeleteHistory();
+ 	public:
+	    // -----------------------------------------------------------------------------
+		// CAspProfile::GetLocalisedPCSuite
+		//
+		// Returns "PC Suite" string localised to specific language
+		// 
+		// Current requirement is to localise to 2 languages TaiwanChinese and ELangHongKongChinese
+		// For all the rest it will be mapped to "PC suite" only
+		// -----------------------------------------------------------------------------
+		//
+	    void GetLocalisedPCSuite(TDes& aText);
+       
+    //public:
+        //HBufC* HistoryJobsLC();
+
+	private:
+        // historylog open state
+        TBool iHistoryLogOpen;
+        
+        // connection open state
+        TBool iConnectionOpen;
+          
+   		// needed for setting creator id
+		TInt iApplicationId;
+		
+		// long buffer for string handling 
+		TBuf<KBufSize255> iBuf;
+		
+		// long buffer for string handling 
+		TBuf8<KBufSize255> iBuf8;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+		
+		// sync profile
+		RSyncMLDataSyncProfile iProfile;
+		
+		// history log
+		RSyncMLHistoryLog iHistoryLog;
+				
+		// sync connection
+		RSyncMLConnection iConnection;
+    };
+
+
+/**
+* CAspTask
+*
+* TAspTask is used for sync task operations.
+*/
+NONSHARABLE_CLASS (TAspTask) : public CBase
+    {
+    public:
+		static TInt SyncDirection(TSmlSyncType aSmlSyncDirection);
+		static TSmlSyncType SmlSyncDirection(TInt aSyncDirection);
+        static TInt FindTaskIdL(CAspProfile* aProfile, TInt aDataProviderId, const TDesC& aLocalDatabase);
+        static TBool CheckLocalDatabaseL(CAspProfile* aProfile, TInt& aDataProviderId);
+        static TBool CheckLocalDatabase(CAspProfile* aProfile, TInt& aDataProviderId);
+    };
+
+
+
+
+
+
+
+#endif  // ASPPROFILE_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfileDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,493 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Dialog to edit profile setting 
+*
+*/
+
+
+
+#ifndef ASPPROFILEDIALOG_H
+#define ASPPROFILEDIALOG_H
+
+
+//  INCLUDES
+
+#include "AspDialogUtil.h"
+
+#include <e32base.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+
+
+
+
+
+// CLASS DECLARATION
+
+
+/**
+*  CAspProfileDialog
+*
+* CAspProfileDialog is used for editing sync connection data.
+*/
+NONSHARABLE_CLASS (CAspProfileDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+    public:
+    
+    
+	public:
+	    /**
+        * Launches dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(const TAspParam& aParam);
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+		static CAspProfileDialog* NewL(const TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProfileDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspProfileDialog(const TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param aType.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework when dialog is activated.
+        * @param None.
+		* @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+    private:
+		/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+
+	
+	public:  // common editors
+	
+		/**
+		* Shows editor for text type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemTextL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for number type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		static TBool EditSettingItemNumberL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for secret type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		static TBool EditSettingItemSecretL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for list type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		static TBool EditSettingItemListL(CAspListItemData& aItem);
+ 		/**
+		* Checks whether MSK label and menu command are correct for the context
+		* @param aKeyEvent
+		* @return None.
+		*/
+ 		void CheckContentSettingL(const TKeyEvent& aKeyEvent);
+ 		/**
+		* Checks whether MSK label and menu command are correct for the context 
+		* @param None
+		* @return None.
+		*/
+ 		void CheckContentSettingL();
+        /**
+		* Utility function, updates dialog cba.
+		* @param aResourceId.
+		* @return None.
+		*/
+		void UpdateCbaL(TInt aResourceId);
+		
+		/**
+		* Utility function, updates menu bar.
+		* @param aResource.
+		* @return None.
+		*/
+		
+		void UpdateMenuL(TInt aResource);
+    
+    private:
+    
+		/**
+		* Handles setting item editing.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemL(CAspListItemData& aItem);
+
+		/**
+		* Change Yes/No setting in place without showing editor.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemYesNoL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for bearer type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemBearerListL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for protocol version setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemProtocolListL(CAspListItemData& aItem);
+
+		/**
+		* Shows editor for text type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemHostAddressL(CAspListItemData& aItem);
+
+		/**
+		* Shows dialog for access point selection.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemAccessPointL(CAspListItemData& aItem);
+		
+    	/**
+		* Opens content dialog.
+		* @param None.
+		* @return Return code.
+		*/
+		TInt EditSettingItemSyncContentL(CAspListItemData& aItem);
+		
+		/**
+		* Set the MSK empty.
+		* @param None.
+		* @return None.
+		*/
+		void SetEmptyMiddleSoftKeyLabelL();
+
+    private:
+
+		/**
+		* Checks that all mandatory data is found.
+		* @param None.
+		* @return Return code.
+		*/
+		TInt CheckMandatoryFields();
+		
+		/**
+		* Checks that all mandatory data is found.
+		* @param aListItem.
+		* @return Return code.
+		*/
+		TBool CheckMandatoryContentFields(CAspListItemData* aListItem);
+		
+		/**
+		* Checks that server id is unique.
+		* @param None.
+		* @return Return code.
+		*/
+		TInt CheckUniqueServerId();
+
+		/**
+		* Saves profile.
+		* @param None.
+		* @return Return code.
+		*/
+		void SaveSettingsL();
+        
+        /**
+		* Check setting values before dialog close.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool CheckSettingValuesL(TInt aButtonId);
+
+        /**
+		* Check setting values before dialog close.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool CheckSettingValues(TInt aButtonId);
+
+		/**
+		* Check if the profile is selected for auto sync ,and if selected check for mandatory settings
+      		* @return None
+        */
+		void CheckAutoSyncSetttigsL();
+
+	private:
+		/**
+        * Create one CNSmlDSProfileData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		void InitSettingItemL(CAspListItemData* aItem);
+		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aHeaders Array of item headers.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, CDesCArray* aHeaders);
+
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aResourceId.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, TInt aResourceId);
+
+		/**
+        * Set setting item visibility (normal/readonly/hidden).
+        * @param None.
+		* @return None.
+        */
+		void SetVisibility();
+		
+        /**
+        * Set all settings to read-only state.
+        * @param None.
+		* @return None.
+        */
+		void SetAllReadOnly();
+		
+		
+		/**
+        * Adds sync contents into item list.
+        * @param None.
+		* @return None.
+        */
+		void AddContentItemsL();
+
+    private:
+
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+		/**
+		* Returns setting item with listbox position aIndex.
+		* @param aIndex Listbox index.
+		* @return Pointer to setting item.
+        */
+		CAspListItemData* GetItemForIndex(TInt aIndex);
+
+		/**
+        * Returns setting item with id aItemId.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+
+		/**
+		* Returns listbox.
+		* @param None.
+		* @return Pointer to listbox.
+		*/
+		CAknSettingStyleListBox* ListBox();
+
+		/**
+		* Returns profile.
+		* @param None.
+		* @return Pointer to sync profile.
+		*/
+		//CAspProfile* Profile();
+		
+
+	private:
+		// setting list
+		CAknSettingStyleListBox* iSettingListBox;
+
+		// list of setting items
+		CAspSettingList *iSettingList;
+		
+   		// list that contains all contents (applications)
+		//CAspContentList* iContentList;
+
+		// profile data
+		CAspProfile* iProfile;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// resource handler
+		CAspResHandler* iResHandler;
+
+		// dialog edit mode
+		TInt iEditMode;
+
+		// for bearer type list construction
+		CAspBearerHandler* iBearerHandler;
+		
+		// for access point selection
+		CAspAccessPointHandler* iApHandler;
+		
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+		
+		// list that contains all profiles
+		CAspProfileList* iProfileList;
+
+		// id of the calling application
+		TInt iApplicationId;
+		
+		// is setting database in read only state
+		TBool iSettingEnforcement;
+		// profile's server id
+		TBuf<KAspMaxServerIdLength> iOldServerId;
+    	// id of current cba resource
+		TInt iCommandSetId;
+		// is  MSK empty
+		TBool iMSKEmpty;
+    };
+
+
+#endif      // ASPPROFILEDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfileSelectionDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,243 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Dialog to select profile to be used for scheduled sync 
+*
+*/
+
+
+
+#ifndef ASPPROFILESELECTIONDIALOG_H
+#define ASPPROFILESELECTIONDIALOG_H
+
+
+//  INCLUDES
+
+#include "AspDialogUtil.h"
+
+#include <e32base.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+#include <aknselectionlist.h>
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATION
+
+
+/**
+*  CAspProfileSelectionDialog
+*
+* CAspProfileSelectionDialog is used for selecting auto sync profile.
+*/
+NONSHARABLE_CLASS (CAspProfileSelectionDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+    
+	public:
+	    /**
+        * Launches dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(TAspParam& aParam);
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+		static CAspProfileSelectionDialog* NewL(TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProfileSelectionDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspProfileSelectionDialog(TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param aType.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework when dialog is activated.
+        * @param None.
+		* @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+    private:
+		/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+		
+		/**
+		* Shown sync profile content list.
+		* @param None.
+		* @return None.
+		*/
+		void ShowContentListL();
+
+
+    private:
+		
+		/**
+        * Add settings titles into listbox.
+        * @param None.
+        * @return None.
+        */
+		void UpdateListBoxL();
+		
+		/**
+		* Utility function, updates dialog cba.
+		* @param None.
+		* @return None.
+		*/
+		void UpdateCbaL();
+		
+
+    private:
+
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+
+
+	private:
+		// dialog parameter for returning value to caller
+		TAspParam* iDialogParam;
+
+  		// id of the calling application
+		TInt iApplicationId;
+		
+		// currently selected profile
+		TInt iProfileId;
+
+		// setting list
+		CAknSingleGraphicStyleListBox* iListBox;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// list that contains all profiles
+		CAspProfileList* iProfileList;
+		
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+		
+		// id of current cba resource
+		TInt iCommandSetId;
+    };
+
+
+#endif      // ASPPROFILESELECTIONDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfileWizard.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,308 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Used to save setting entered by user in profile creation wizard 
+*
+*/
+
+
+#ifndef ASPPROFILEWIZARD_H
+#define ASPPROFILEWIZARD_H
+
+
+//  INCLUDES
+#include "AspDialogUtil.h"
+
+
+// CONSTANTS
+
+
+
+
+/**
+* CAspWizardItem
+* 
+* CAspWizardItem contains one setting item data.
+*/
+NONSHARABLE_CLASS (CAspWizardItem) : public CBase
+	{
+    public:
+	enum TSettingType
+		{
+	    ETypeStart,
+	    ETypeProfileName,
+	    ETypeProtocolVersion,
+	    ETypeHostAddress,
+	    ETypeServerId,
+	    ETypeBearerType,
+	    ETypeUserName,
+		ETypePassword,
+		ETypeSyncType,
+		ETypeContentSelection,
+		ETypeSyncContent,
+		ETypeSyncContentLocalDatabase,
+		ETypeEnd
+		};
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspWizardItem* NewL();
+        
+        /**
+        * Destructor.
+        */
+        ~CAspWizardItem();
+        
+    private:
+        /**
+        * C++ default constructor.
+        */
+        CAspWizardItem();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+	
+	
+	public:
+        /**
+        * Set string type value.
+        * @param aTex.
+        * @return None.
+        */
+        void SetValueL(const TDesC& aText);
+
+        /**
+        * Get string type value.
+        * @param None. 
+        * @return String type value.
+        */
+		const TDesC& Value();
+
+        /**
+        * Set content name.
+        * @param aTex.
+        * @return None.
+        */
+        void SetContentNameL(const TDesC& aText);
+
+        /**
+        * Get content name.
+        * @param None. 
+        * @return Content name.
+        */
+		const TDesC& ContentName();
+
+        /**
+        * Set header.
+        * @param aTex.
+        * @return None.
+        */
+        void SetHeaderL(const TDesC& aText);
+
+        /**
+        * Set header.
+        * @param aResourceId.
+        * @return None.
+        */
+        void SetHeaderL(TInt aResourceId);
+
+        /**
+        * Get header.
+        * @param None. 
+        * @return Content name.
+        */
+		const TDesC& Header();
+
+        /**
+        * Initalizes setting item.
+        * @param None. 
+        * @return None.
+        */
+		void InitL();
+	
+	public:
+    	// setting type
+		TInt  iSettingType;
+		
+		// identifies settings that have same setting type
+		TInt  iSettingId;
+
+    	// setting editor title resource id
+		TInt iResourceId;
+		
+    	// popup note resource id
+		TInt iPopupNoteResourceId;
+
+    	// error note resource id
+		TInt iErrorNoteResourceId;
+
+		// is this setting included in sync wizard
+		TBool iEnabled;
+
+		// max text length
+		TInt iMaxLength;
+
+		// is setting mandatory
+		TBool iMandatory;
+		
+		// are only western characters allowed
+		TInt iLatinInput;
+		
+		// integer type value
+		TInt iNumber;
+		
+    private:
+		// string type setting value
+	    HBufC* iValue;
+	
+   		// content display name
+	    HBufC* iContentName;
+
+   		// editor header
+	    HBufC* iHeader;
+    };
+
+
+
+
+/**
+* CAspProfileWizard
+*  
+* CAspProfileWizard creates new profile.
+*/
+NONSHARABLE_CLASS (CAspProfileWizard) : public CBase
+    {
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfileWizard* NewL(TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProfileWizard();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspProfileWizard(TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+	    /**
+        * Creates setting item list.
+		* @param None.
+        * @return None.
+        */
+	    void CreateSettingListL();
+
+    public:
+        void GetContentSelectionL(CSelectionItemList* aList);
+        void SetContentSelectionL(CSelectionItemList* aList);
+        void SetContentEnabled(const TDesC& aText, TBool aEnabled);
+        void SetContentEnabled(TInt aApplicationId);
+        void SetEnabled(TInt aSettingType, TBool aEnabled);
+        void SetContentLocalDatabaseEnabled(TInt aDataproviderId, TBool aEnabled);
+        void SetContentEnabled(TInt aDataproviderId, TBool aEnabled);
+        TBool ContentEnabled(TInt aDataproviderId);
+        
+        void SetContentEnabled(RArray<TInt>& aDataProviderArray);
+        void GetContentEnabled(RArray<TInt>& aDataProviderArray);
+        void GetContentName(TDes& aText);
+        TInt ContentId(const TDesC& aText);
+    
+    public:
+        CAspWizardItem* CurrentItem();
+        void CreateProfileL();
+        void DeleteProfile();
+        void MoveToNext();
+        void MoveToPrevious();
+        void MoveToStart();
+        TInt CurrentItemType();
+        TInt NumOfCurrentItem(CAspWizardItem* aItem);
+        TInt NumOfEnabledItems();
+        TInt NumOfEnabledContentItems();
+        TInt NumOfContentItems();
+        void SetStringValueL(const TDesC& aValue, TInt aSettingType, TInt aSettingId);
+        void SetStringValueL(const TDesC& aValue, TInt aSettingType);
+        void SetNumberValue(TInt& aValue, TInt aSettingType);
+        TInt CreatedProfileId(void);
+        TInt NumberValue(TInt aSettingType);
+        CDesCArray* LocalDatabaseList(const TInt aDataproviderId);
+
+        
+    private:
+        void GetStringValue(TDes& aValue, TInt aSettingType);
+        void GetStringValue(TDes& aValue, TInt aSettingType, TInt aSettingId);
+        void GetNumberValue(TInt& aValue, TInt aSettingType);
+        TInt IncreaseCurrentIndex(const TInt aIndex);
+        TInt DecreaseCurrentIndex(const TInt aIndex);
+        TBool CheckHostAddress(const TDesC& aText);
+        TInt ContentPopupNoteResourceId(TInt aDataProviderId);
+        //TInt ContentHeaderResourceId(TInt aDataProviderId);
+       
+    private:
+        //TInt ShowTextEditorL(TInt aResourceId, TDes& aText, const TDesC& aTitle, TBool aMandatory, TBool aLatinInput, TInt aMaxLength);
+        
+	private:
+   		// dialog parameter for returning value to caller
+		TAspParam* iDialogParam;
+
+		// id of the calling application
+		TInt iApplicationId;
+		
+		// id of the created profile
+		TInt iProfileId;
+	
+    	// session with sync server
+		RSyncMLSession* iSyncSession;
+	
+   		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+
+        // for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// list index of current profile setting
+		TInt iCurrentItemIndex;
+		
+    private:
+	
+		// names of all available local data stores
+		CDesCArray* iLocalDataStores;
+		
+		// list of sync contents
+		RPointerArray<CAspWizardItem> iSettingList;
+	};
+
+
+
+
+
+
+#endif      // ASPPROFILEWIZARD_h
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfileWizardDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,565 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Dialog to create to profile using wizard 
+*
+*/
+
+
+#ifndef ASPPROFILEWIZARDDIALOG_H
+#define ASPPROFILEWIZARDDIALOG_H
+
+// BackGround Context
+#include <AknsBasicBackgroundControlContext.h>
+
+//  INCLUDES
+#include <e32base.h>
+#include <akntextsettingpage.h>         // CAknIntegerSettingPage
+#include <aknpasswordsettingpage.h>     // CAknAlphaPasswordSettingPage
+#include <aknradiobuttonsettingpage.h>  // CAknRadioButtonSettingPage
+#include <AknInfoPopupNoteController.h> // CAknInfoPopupNoteController
+
+#include "AspProfileWizard.h"
+
+
+// CONSTANTS
+
+//const TInt KMsToWaitBeforePopup = 1000;
+const TInt KMsToWaitBeforePopup = 3000;
+const TInt KMsToWaitBeforeRePopup = 6000;
+const TInt KMsTimePopupInView = 60*1000;
+
+/**
+* MAspEditorPageObserver
+*
+* Observer interface function.
+*/
+NONSHARABLE_CLASS (MAspEditorPageObserver)
+	{
+    public:
+	enum TEditorEventType
+		{
+	    EKeyEvent,
+	    EContentCountEvent
+		};
+	
+	public:
+		/**
+        * Editor page call this when editor is about to close.
+        * @param aText Editor text.
+        * @return ETrue if input is ok, EFalse otherwise. 
+        */
+		virtual TBool CheckValidity(const TDesC& aText, TInt aSettingType) = 0;
+
+		/**
+        * Editor page call this to inform observer about editor event.
+        * @param aEvent.
+        * @param aValue.
+        * @return None. 
+        */
+		virtual void HandleEditorEvent(TInt aEvent, TInt aValue) = 0;
+
+		/**
+        * Editor page call this to inform observer about editor event.
+        * @param aEvent.
+        * @param aValue.
+        * @return None. 
+        */
+		virtual void GetNavipaneText(TDes& aText, TInt aContentCount) = 0;
+	};
+
+
+/**
+* TAspSettingPageParam
+*
+* This class is used as general parameter type.
+*/
+NONSHARABLE_CLASS (TAspSettingPageParam)
+	{
+	public:
+	    TInt iCommandId;
+	    TBuf<KBufSize> iPageText;
+	    MAspEditorPageObserver* iObserver;
+	    TInt iSettingType;
+	};
+
+
+/**
+* CAspTextSettingPage
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspTextSettingPage) : public CAknTextSettingPage                                          
+	{
+    public:
+        CAspTextSettingPage(TInt aResourceID, TDes& aText, TInt aTextSettingPageFlags,
+                            TAspSettingPageParam& aParam);
+        ~CAspTextSettingPage();            
+        
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+	    TBool PostDisplayCheckL();
+	    TBool OkToExitL(TBool aAccept);
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+
+	private:
+	    void UpdateNaviPaneL();
+	    
+	private:
+	    TAspSettingPageParam& iParam;
+	    CAspIndicatorHandler* iIndicatorHandler;
+	};
+
+
+/**
+* CAspRadioButtonSettingPage
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspRadioButtonSettingPage) : public CAknRadioButtonSettingPage ,public MEikListBoxObserver
+	{
+    public:
+        CAspRadioButtonSettingPage(TInt aResourceID, TInt& aCurrentSelectionIndex, 
+		                           const MDesCArray* aItemArray, TAspSettingPageParam& aParam);
+        ~CAspRadioButtonSettingPage();            
+        
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+	    TBool PostDisplayCheckL();
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	    //from MEikListBoxObserver for Touch event Handling
+	    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+	    
+	private:
+	    void UpdateNaviPaneL();
+	    
+	private:
+	    TAspSettingPageParam& iParam;
+	    CAspNaviPaneHandler* iNaviPaneHandler;
+	    const MDesCArray* iItemArray;
+	};
+	
+
+/**
+* CAspCheckBoxSettingPage
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspCheckBoxSettingPage) : public CAknCheckBoxSettingPage,public MEikListBoxObserver
+	{
+    public:
+        CAspCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray, TAspSettingPageParam& aParam);
+
+        ~CAspCheckBoxSettingPage();            
+        
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+   	    TBool PostDisplayCheckL();
+   	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+   	    //from MEikListBoxObserver for touch event handling
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+    
+	private:
+	    void UpdateNaviPaneL();
+
+	private:
+	    TAspSettingPageParam& iParam;
+   	    CAspNaviPaneHandler* iNaviPaneHandler;
+   	    TInt iSelectionCount;
+   	    CSelectionItemList* iSelectionItemList;
+	};
+
+
+/**
+* CAspAlphaPasswordSettingPage
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAspAlphaPasswordSettingPage) : public CAknAlphaPasswordSettingPage
+	{
+    public:
+        CAspAlphaPasswordSettingPage(TInt aResourceID, TDes& aNewPassword, const TDesC& aOldPassword, TAspSettingPageParam& aParam);
+
+        ~CAspAlphaPasswordSettingPage();            
+        
+    protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+   	    TBool PostDisplayCheckL();
+   	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	    
+	private:
+	    void UpdateNaviPaneL();
+
+	private:
+	    TAspSettingPageParam& iParam;
+	    //CAspNaviPaneHandler* iNaviPaneHandler;
+	    CAspIndicatorHandler* iIndicatorHandler;
+	};
+
+
+// Forward Declaration 
+class CAknsBasicBackgroundControlContext;
+
+/**
+*  CAspProfileWizardDialog
+*
+* Dialog for editing profile name, data and connection.
+*/
+NONSHARABLE_CLASS (CAspProfileWizardDialog) : public CAknDialog,
+                                              public MAspActiveCallerObserver,
+                                              public MAspEditorPageObserver
+    {
+	enum TAspProfileDialogListIndex
+		{
+	    EIndexProfileName = 0,
+        EIndexProfileContent = 1,
+	    EIndexProfileConnection = 2
+		};
+
+	public:
+	    /**
+        * Launches profile dialog for editing profile name, data and connection.
+		* @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(TAspParam& aParam);
+
+    
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProfileWizardDialog* NewL(TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProfileWizardDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspProfileWizardDialog(TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+
+	private:
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+	   
+	   /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PreLayoutDynInitL();
+		
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param TEventCode.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		//void GetHelpContext(TCoeHelpContext& aContext) const;
+		
+    	/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+        
+
+	private:   // from MAspActiveCallerObserver
+	
+		/**
+        * From MAspActiveCallerObserver
+		* Called when CAspActiveCaller completes.
+        * @param aCallId.
+        * @return None.
+        */
+		void HandleActiveCallL(TInt aCallId);
+		
+	
+	private:   // from MAspEditorPageObserver
+	
+		/**
+        * From MAspEditorPageObserver
+		* Check setting page input.
+        * @param aText.
+        * @param aSettingType.
+        * @return ETrue is input is valid, EFalse othherwise.
+        */
+		TBool CheckValidity(const TDesC& aText, TInt aSettingType);
+        
+		/**
+        * Check setting page input.
+        * @param aText.
+        * @param aSettingType.
+        * @return ETrue is input is valid, EFalse othherwise.
+        */
+		TBool CheckValidityL(const TDesC& aText, TInt aSettingType);
+		
+		/**
+        * Handle editor event.
+        * @param aEvent.
+        * @param aValue.
+        * @return None.
+        */
+		void HandleEditorEvent(TInt aEvent, TInt aValue);
+		
+		/**
+        * Get navipane text.
+        * @param aText.
+        * @param aContentCount.
+        * @return None.
+        */
+		void GetNavipaneText(TDes& aText, TInt aContentCount);
+
+        
+    private:
+   		/**
+		* Utility function, updates dialog cba.
+		* @param aResourceId.
+		* @return None.
+		*/
+		void UpdateCbaL(TInt aResourceId);
+		
+   		/**
+		* Utility function, sets text editor text.
+		* @param aResourceId.
+		* @return None.
+		*/
+		void SetTextEditorTextL(TInt aResource);
+		
+		/**
+        * For setting the background Screen
+		*/
+    	void SetBackgroundContextL();
+    	
+    	/**
+        * Update color and font
+		*/
+    	void UpdateTextColorL();
+    	
+
+    private:
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemTextL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemBearerTypeL(CAspWizardItem* aItem);
+        
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemProtocolVersionL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemLocalDatabaseL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemSecretL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemProfileNameL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemHostAddressL(CAspWizardItem* aItem);
+
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt EditSettingItemContentSelectionL(CAspWizardItem* aItem);
+        
+   		/**
+		* Edit setting item.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+        TInt ShowTextEditorL(TInt aResourceId, TDes& aText, const TDesC& aTitle,
+                             TBool aMandatory, TBool aLatinInput, TInt aMaxLength, TInt aSettingType);
+
+    private:
+        
+   		/**
+		* Get navi pane text.
+		* @param aText.
+		* @param aCurrent.
+		* @param aFinal.
+		* @return Return code.
+		*/
+        void GetNaviPaneText(TDes& aText, TInt aCurrent, TInt aFinal);
+
+   		/**
+		* Get navi pane text.
+		* @param aText.
+		* @param aItem.
+		* @return Return code.
+		*/
+        void GetNaviPaneText(TDes& aText, CAspWizardItem* aItem);
+        
+		/**
+        * Set default setting values.
+        * @param None.
+        * @return None.
+        */
+		void SetDefaultValuesL();
+        
+        
+   		/**
+		* Show one proifle wizard editor.
+		* @param None.
+		* @return Return code.
+		*/
+        void RunWizardL();
+
+   		/**
+		* Show one proifle wizard editor.
+		* @param None.
+		* @return Return code.
+		*/
+        TInt RunWizard();
+        
+        void ShowPopupNoteL(TInt aResource, TInt aDelay);
+        void HidePopupNote();
+        void ShowErrorNoteL(TInt aError);
+
+       
+    private:
+        // text editor 
+        CEikRichTextEditor* iTextEditor;
+        
+   		// text editor text
+   		HBufC* iTextEditorText;
+		
+  		// handles profile setting data and profile creation
+  		CAspProfileWizard* iWizard;
+  		
+  		// dialog parameter for returning value to caller
+		TAspParam* iDialogParam;
+
+		// id of the calling application
+		TInt iApplicationId;
+
+		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+		
+		// for making function call via active scheduler
+		CAspActiveCaller* iActiveCaller;
+		
+		// for bearer type list construction
+		CAspBearerHandler* iBearerHandler;
+		
+		// format string from resource file
+		TBuf<KBufSize> iNaviPaneTextFormat;
+		
+		// popup note
+		CAknInfoPopupNoteController* iPopupNote;
+		
+		// needed for unique server id check
+		CAspProfileList* iProfileList;
+		
+		// Background context
+	    CAknsBasicBackgroundControlContext* iBgContext;
+	    
+	    // Flag for checking whether moving in Backward direction or not 
+	    TBool iMoveBack;
+    };
+
+
+
+
+
+#endif      // ASPPROFILEWIZARDDIALOG_h
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProgressDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,261 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: sync progress indication 
+*
+*/
+
+
+#ifndef ASPPROGRESSDIALOG_H
+#define ASPPROGRESSDIALOG_H
+
+
+//  INCLUDES
+#include    <e32base.h>
+#include    <AknWaitDialog.h>
+#include    <AknProgressDialog.h>
+
+#include    "AspDefines.h"
+#include    "AspResHandler.h"
+
+
+// CLASS DECLARATIONS
+
+
+/**
+* MAspProgressDialogObserver
+* 
+* Observer interface function for observing progress dialog.
+*/
+NONSHARABLE_CLASS (MAspProgressDialogObserver)
+    {
+    public:
+        /**
+        * Callback method
+        * Get's called when a dialog is dismissed.
+        */
+        virtual void HandleDialogEventL(TInt aButtonId) = 0;
+    };
+
+
+
+/**
+* CAspProgressDialog2
+*
+* CAspProgressDialog2 is needed to modify CAknProgressDialog::OkToExitL. 
+*/
+NONSHARABLE_CLASS (CAspProgressDialog2) : public CAknProgressDialog
+    {
+	public:
+        /**
+        * C++ default constructor.
+        */
+		CAspProgressDialog2(CEikDialog** aSelfPtr, TInt aApplicationId);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProgressDialog2();
+        
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+        
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param TEventCode.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+		
+	private:
+   		// has dialog received close event (eg. end key) 
+		TBool iCloseEventReceived;
+
+		// has cancel key been pressed 
+		TBool iCancelEventReceived;
+
+        // has sync been closed
+        TBool iClosed;
+        
+        // has sync been canceled
+        TBool iCanceled;
+		
+  		// id of the calling application
+		TInt iApplicationId;
+    };
+
+
+
+/**
+* CAspProgressDialog
+*  
+* CAspProgressDialog show sync progress dialog.
+*/
+NONSHARABLE_CLASS (CAspProgressDialog) : public CBase, public MProgressDialogCallback
+    {
+
+    public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspProgressDialog* NewL(MAspProgressDialogObserver* aObserver);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspProgressDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspProgressDialog(MAspProgressDialogObserver* aObserverPtr);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+        
+		/**
+		* From MProgressDialogCallback.
+        * Called by the framework when dialog is dismissed.
+        * @param aButtonId
+        * @return None
+        */
+        void DialogDismissedL(TInt aButtonId);
+
+    public:        
+        
+        /**
+        * Launches progress dialog with custom bitmap.
+        * @param aLabel.
+        * @param aId.
+        * @param aFileName.
+        * @param aFileBitmapId.
+        * @param aFileMaskId.
+        * @return None.
+        */
+        void LaunchProgressDialogL(const TDesC& aLabel, TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId);
+
+        
+        /**
+        * Closes progress dialog.
+        * @param None
+        * @return None
+        */
+        void CancelProgressDialogL();
+        
+        /**
+        * Update dialog label text.
+        * @param aText.
+        * @return None.
+        */
+        void UpdateTextL(const TDesC& aText);
+
+        /**
+        * Set progress bar state.
+        * @param aValue.
+        * @return None
+        */
+        void SetProgress(TInt aValue);
+
+        /**
+        * Set progress bar state.
+        * @param aFinalValue.
+        * @return None
+        */
+        void SetFinalProgress(TInt aFinalValue);
+
+        /**
+        * Gets CAknNoteControl from CAknProgressDialog.
+        * @param None
+        * @return CAknNoteControl.
+        */
+		CAknNoteControl* NoteControl();
+
+       /**
+        * Cancels animation.
+        * @param None.
+        * @return None.
+        */
+		void CancelAnimation();
+        
+		/**
+        * Starts animation.
+        * @param None
+        * @return None.
+        */
+		void StartAnimationL();
+		
+		/**
+        * Hides cancel button.
+        * @param None
+        * @return None.
+        */
+		void HideButtonL();
+
+		/**
+        * Set application id.
+        * @param aApplicationId
+        * @return None.
+        */
+		void SetApplicationId(TInt aApplicationId);
+
+		/**
+        * Returns progress dialog
+        * @param None
+        * @return CAspProgressDialog2*
+        */
+		CAspProgressDialog2* ProgressDialog();
+
+    private:
+ 		// id of the calling application
+		TInt iApplicationId;
+    
+        // progress dialog
+		CAspProgressDialog2*	iProgressDialog;
+		
+		// is dialog running
+		TBool iProgressDialogRunning;
+
+        // progress dialog info
+        CEikProgressInfo* iProgressInfo;
+
+		// last label text
+		TBuf<KBufSize> iLastText;
+
+		// animation state
+		TBool iAnimation;
+
+		// resource handler
+		CAspResHandler* iResHandler;
+
+		// dialog observer
+        MAspProgressDialogObserver*	iObserver;
+    };
+
+
+
+
+#endif      // ASPPROGRESSDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspResHandler.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Utility methods to handle resources 
+*
+*/
+
+
+#ifndef ASPRESHANDLER_H
+#define ASPRESHANDLER_H
+
+
+// INCLUDES
+#include <e32base.h>
+#include <eikenv.h>
+#include <aknenv.h>
+#include <StringLoader.h>
+
+#include "AspDefines.h"
+#include <AspSyncUtil.rsg>
+
+
+
+
+// CLASS DECLARATION
+
+
+
+/**
+* CAspResHandler
+*
+* This class is used for reading aspsyncutil resources.
+*/
+NONSHARABLE_CLASS (CAspResHandler) : public CBase
+    {
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspResHandler* NewL();
+
+	    /**
+        * Destructor.
+        */
+        ~CAspResHandler();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspResHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	
+    public:
+	   /**
+        * Finds out aspsyncutil resource file name.
+        * @param aText.
+		* @return None.
+        */
+        static void GetResFileName(TDes& aText);
+
+	   /**
+        * Finds out aspsyncutil bitmap file name.
+        * @param aText.
+		* @return None.
+        */
+        static void GetBitmapFileName(TDes& aText);
+        
+	   /**
+        * Reads string from resource file.
+        * @param aText Text read from resource file.
+		* @param aResourceId Resource id.
+		* @return None.
+        */
+		static void ReadL(TDes& aText, TInt aResourceId);
+
+	   /**
+        * Reads string from resource file.
+        * @param aText Text read from resource file.
+		* @param aResourceId Resource id.
+		* @param aSubString Substring that is added into read resource.
+		* @return None.
+        */
+		static void ReadL(TDes& aText, TInt aResourceId, const TDesC& aSubString);
+
+	   /**
+        * Reads string from resource file.
+    	* @param aResourceId Resource id.
+		* @return Text read from resource file.
+        */
+		static HBufC* ReadLC(TInt aResourceId);
+
+	   /**
+        * Reads string from resource file.
+    	* @param aResourceId Resource id.
+		* @return Text read from resource file.
+        */
+		static HBufC* ReadL(TInt aResourceId);
+
+	   /**
+        * Reads string from resource file.
+		* @param aResourceId Resource id.
+		* @param aSubString Substring that is added into read resource.
+		* @return Text read from resource file.
+        */
+		static HBufC* ReadLC(TInt aResourceId, const TDesC& aSubString);
+
+	   /**
+        * Reads string from resource file.
+		* @param aResourceId Resource id.
+		* @param aNumber Number that is added into read resource.
+		* @return Text read from resource file.
+        */
+		static HBufC* ReadLC(TInt aResourceId, TInt aNumber);
+		
+	   /**
+        * Reads array of strings from resource file.
+    	* @param aResourceId Resource id.
+		* @return String array.
+        */
+		CDesCArrayFlat* ReadDesArrayLC(TInt aResourceId);
+
+	   /**
+        * Reads array of strings from resource file.
+    	* @param aResourceId Resource id.
+		* @return String array.
+        */
+		CDesCArrayFlat* ReadDesArrayL(TInt aResourceId);
+
+	   /**
+        * Reads array of strings from resource file.
+    	* @param aResourceId Resource id.
+		* @return String array.
+        */
+		static CDesCArrayFlat* ReadDesArrayStaticLC(TInt aResourceId);
+
+	   /**
+        * Reads progress dialog progress text from resource file.
+		* @param aContent Content name.
+		* @param aCurrent Currently processed sync item.
+    	* @param aFinal Number of sync items.
+		* @param aSend ETrue is sync phase is "sending".
+		* @return Progress text.
+        */
+		//HBufC* ReadProgressTextLC(const TDesC& aContent, TInt aCurrent, TInt aFinal, TInt aPhase);
+		
+	   /**
+        * Reads progress dialog progress text from resource file.
+		* @param aContent.
+		* @param aPhase.
+		* @return Progress text.
+        */
+		HBufC* ReadProgressTextLC(const TDesC& aContent, TInt aPhase);
+		
+	   /**
+        * Reads progress dialog progress text from resource file.
+        * Buffers the last aResource to minimize file operations.
+        * @param aResourceId Resource id.
+		* @param aContent Content name.
+		* @return Progress text.
+        */
+		HBufC* ReadProgressTextLC(TInt aResourceId, const TDesC& aContent);
+
+	   /**
+        * Reads default profile name from resource file.
+		* @param aIndex Number that is added to proile name (eg. "New Profile(1)").
+		* @param aApplicationId.
+		* @return Profile name.
+        */
+		static HBufC* GetNewProfileNameLC(TInt aIndex, TInt aApplicationId);
+		
+	   /**
+        * Reads sync content name.
+		* @param aDataProviderId.
+		* @param aDefaultText.
+		* @return Content name.
+        */
+		static HBufC* GetContentNameLC(TInt aDataProviderId, const TDesC& aDefaultText);
+		
+	   /**
+        * Reads sync content title.
+		* @param aDataProviderId.
+		* @param aDefaultText.
+		* @return Content title.
+        */
+		static HBufC* GetContentTitleLC(TInt aDataProviderId, const TDesC& aDefaultText);
+
+	   /**
+        * Reads sync content setting text.
+		* @param aDataProviderId.
+		* @param aDefaultText.
+		* @return Content title.
+        */
+		static HBufC* GetContentSettingLC(TInt aDataProviderId, const TDesC& aDefaultText);
+		
+	   /**
+        * Reads remote database setting header rersource id.
+		* @param aDataProviderId.
+		* @return Resource id.
+        */
+		static TInt RemoteDatabaseHeaderId(TInt aDataProviderId);
+		
+	   /**
+        * Reads profile info text.
+		* @param aProfile.
+		* @param aBearer.
+		* @return Profile info text.
+        */
+		static HBufC* ReadProfileInfoTextLC(const TDesC& aProfile, const TDesC& aBearer);
+
+	   /**
+        * Reads profile info text.
+		* @param aProfile.
+		* @param aBearer.
+		* @param aHours.
+		* @param aMinutes.
+		* @return Profile info text.
+        */
+		static HBufC* ReadProfileInfoTextLC(const TDesC& aProfile, const TDesC& aBearer,
+		                                    TInt aHours, TInt aMinutes);
+
+		  /**
+        * Reads profile info text.
+		* @param aProfile.
+		* @param aTime.
+			*/
+		static HBufC* ReadAutoSyncInfoTextLC(const TDesC& aProfile, TTime aTIme);
+		
+    private:
+		//  sync app resource file id
+		TInt iResId;
+
+		// pointer to CEikonEnv
+		CEikonEnv* iEikEnv;
+
+		// progress text format (from resource file)
+		HBufC* iProgressTextFormat;
+		
+		// progress text format id
+		TInt iProgressTextFormatId;
+    };
+
+
+
+#endif  // ASPRESHANDLER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSchedule.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,412 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Scheduled sync implementation and setting access 
+*
+*/
+
+
+#ifndef ASPSCHEDULE_H
+#define ASPSCHEDULE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <SyncMLClient.h>    // for RSyncMLSession
+#include <SyncMLObservers.h>
+
+#include "AspDefines.h"
+#include "AspUtil.h"
+
+
+// CONSTANTS
+const TInt KDefaultStartHour = 12; // 12 noon
+const TInt KStartPeakHour = 8;
+const TInt KStartPeakMin = 00;
+const TInt KEndPeakHour = 17;
+const TInt KEndPeakMin = 00;
+_LIT(KAutoSyncProfileName, "AutoSync Profile");
+
+
+// FORWARD DECLARATIONS
+class CAspProfile;
+class CAspFilterItem;
+
+
+/**
+* CAspSchedule
+*  
+*/
+NONSHARABLE_CLASS (CAspSchedule) : public CBase
+    {
+    private:
+	enum TRepositoryKey
+		{
+	   // ERepositoryKeyInt = 1,
+	    ERepositoryKeyBin = 1
+		};
+		
+    public:
+		
+    enum TWeekdayFlags
+        {
+	    EFlagMonday      = 0x00000001,
+	    EFlagTuesday     = 0x00000002,
+	    EFlagWednesday   = 0x00000004,
+	    EFlagThursday    = 0x00000008,
+	    EFlagFriday      = 0x00000010,
+	    EFlagSaturday    = 0x00000020,
+	    EFlagSunday      = 0x00000040
+        };
+
+	enum TSyncInterval
+		{
+		EIntervalManual = 0,
+		EInterval15Mins,
+		EInterval30Mins,
+		EInterval1hour,
+		EInterval2hours,
+		EInterval4hours,
+		EInterval8hours,
+		EInterval12hours,
+		EManyTimesPerDay,
+		EInterval24hours,
+		EInterval2days,
+		EInterval4days,
+		EInterval7days,
+		EInterval14days,
+		EInterval30days
+		};
+	
+  
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspSchedule* NewL();
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CAspSchedule* NewLC();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAspSchedule();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */	
+        CAspSchedule();
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	public:
+
+		/**
+        *  auto sync error
+        */	
+	    TInt Error();
+	    void SetError(TInt aError);
+
+		/**
+        *  Profile selected for auto sync
+        */	
+	    TInt ProfileId();
+	    void SetProfileId(TInt aProfileId);
+
+		/**
+        *  week day selection 
+        */	
+	    TBool WeekdayEnabled(TInt aWeekday);
+	    void SetWeekdayEnabled(TInt aWeekday, TBool aEnabled);
+	    
+	    TBool RoamingAllowed();
+	    void SetRoamingAllowed(TBool aAllowed);
+	    
+	    void SelectedDayInfo(TInt& aDayCount, TInt& aWeekday);
+
+		/**
+        * Save all settings using a cenrep key
+        */	
+        void SaveL();
+
+		/**
+        * Auto sync content selection
+        */	
+		void SetContentEnabled(TInt aContent, TInt aEnabled);
+	    TBool ContentEnabled(TInt aContent);
+	    void ContentSelectionInfo(TInt& aContentCnt, TInt& aContent);
+
+		/**
+        * Auto sync interval
+        */	
+        void SetSyncFrequency(TInt aSchedule);
+		void SetSyncPeakSchedule(TInt aSchedule);
+		void SetSyncOffPeakSchedule(TInt aSchedule);
+		TInt SyncFrequency();
+		TInt SyncPeakSchedule();
+		TInt SyncOffPeakSchedule();
+
+		/**
+        * Peak time definition
+        */	
+		void SetStartPeakTime(TTime aStartTime);
+		void SetEndPeakTime(TTime aEndTime);
+		TTime StartPeakTime();
+		TTime EndPeakTime();
+
+		/**
+        * Auto sync enabled/disabled
+        */	
+		void SetDailySyncEnabled(TBool aSyncEnabled);
+		TBool DailySyncEnabled();
+		void SetPeakSyncEnabled(TBool aSyncEnabled);
+		TBool PeakSyncEnabled();
+		void SetOffPeakSyncEnabled(TBool aSyncEnabled);
+		TBool OffPeakSyncEnabled();
+
+		/**
+        * Sync time for intervals >= a day
+        */	
+		void SetAutoSyncScheduleTime(TTime aSchedule);
+		TTime AutoSyncScheduleTime();	
+
+		/**
+        * Schedule handle returned by task scheduler during schedule creation
+        */	
+		void SetPeakScheduleHandle(TInt aHandle);
+		TInt PeakScheduleHandle();
+		void SetOffPeakScheduleHandle(TInt aHandle);
+		TInt OffPeakScheduleHandle();
+
+		/**
+        * A hidden profile used for auto sync.Contents are set as the content selected in auto sync settings
+        *
+        */	
+
+		void CreateAutoSyncProfileL();
+		TInt AutoSyncProfileId();
+		void SetAutoSyncProfileId(TInt aProfileId);
+		void CopyAutoSyncContentsL();
+		void UpdateProfileSettingsL();
+		
+		/**
+        * Check validity of shedule based on current time and user defined peak time
+        *
+        */					
+		TInt IsValidPeakScheduleL();
+		TInt IsValidOffPeakScheduleL();
+
+		TBool IsValidNextPeakScheduleL();
+		TBool IsValidNextOffPeakScheduleL();
+
+		/**
+        * Post pone schedule until next valid time
+        */
+		void UpdatePeakScheduleL();
+		void UpdateOffPeakScheduleL();
+		TIntervalType IntervalType(TInt aInterval);
+
+		void EnableScheduleL();
+
+		/**
+        * Check if any valid mail box exists
+        */
+		TBool MailboxExistL();
+
+		/**
+        * Check mandatory settings for the selected profile
+        */
+		TInt CheckMandatoryDataL(TInt& count,TInt& firstItem);
+
+		/**
+        * Log view opened by clicking View Details link in auto sync error note
+        */
+		void ShowAutoSyncLogL();
+
+		/**
+        *SyncML sever version of selected profile
+        */
+		TInt ProtocolL();
+
+		/**
+        *Server Id modifications so that SAN selects correct profile
+        */
+		void UpdateServerIdL();
+
+		/**
+        *Check if atleast one valid content selected
+        */
+		TBool IsContentSelected();
+		
+		/**
+        *Check if auto sync is enabled
+        */
+		TBool IsAutoSyncEnabled();
+
+		/**
+        *Initialize contents
+        */
+		void InitializeContentsL();
+
+		
+		/**
+        *Check the validity of email selection.
+        */
+		void CheckEmailSelectionL();
+
+				
+    public:
+
+		/**
+        *Update the schedule settings with symbian task scheduler
+        */
+        void UpdateSyncScheduleL();
+        void UpdateSyncSchedule();
+        void GetStartTimeL(TTime& aTime, TBool aHomeTime);
+               
+      
+#ifdef _DEBUG
+		void LogSettings();
+#endif
+
+
+    public:
+   	    TBool CanSynchronizeL();
+		
+	private:
+	    void InitializeL();
+	
+	public:
+        static TTime UniversalStartTime(TInt& aStartHour);
+        static TTime LocalStartTime(TInt aStartHour);
+        
+	
+	private:
+	    void InternalizeL();
+		void DoInternalizeL();
+		void InternalizeL(RReadStream& aStream);
+		void ExternalizeL();
+		void ExternalizeL(RWriteStream& aStream);
+		void WriteRepositoryL(TInt aKey, const TDesC8& aValue);
+		void ReadRepositoryL(TInt aKey, TDes8& aValue);
+		void ResetRepositoryL();
+		
+	private:
+		TInt WeekdayFlag(TInt aWeekday);
+		TBool IsDaySelected(TTime aTime);
+	
+		void OpenSyncSessionL();
+		void CloseSyncSession();
+
+		
+#ifdef _DEBUG        
+	public:
+	    void LogScheduleL();
+	    void LogSyncDays();
+	    void LogSyncInterval();	
+
+
+    public:
+        static void PrintTimeL(TTime aTime);
+        void TestL();
+        void DoTestL();
+        void UpdateValuesL(TInt aCount);
+        CAspSchedule* CreateCopyLC();
+        void CompareValues(CAspSchedule* aSchedule);
+        void AssertEqual(TInt aValue1, TInt aValue2);
+#endif
+
+        	    
+		
+    private:
+   
+         // error code
+        TInt iError;
+
+		// profile id
+		TInt iProfileId;
+		
+		// selected days
+		TUint32 iWeekdayFlags;
+		
+		// start hour
+		TInt iStartHour;
+
+		// is roaming allowed
+		TBool iRoamingAllowed;
+		
+		// data provider id list
+		RArray<TInt> iList;
+		
+        // long buffer for string handling 
+		TBuf<KBufSize255> iBuf;
+		
+		// have settings changed
+		TBool iSettingChanged;
+
+		//content selection flags
+		TUint32 iContentFlags;
+		
+		TInt iStartPeakTimeHr;
+		TInt iStartPeakTimeMin;
+		TInt iEndPeakTimeHr;
+        TInt iEndPeakTimeMin;		
+
+		//peak interval
+		TInt iSyncPeakSchedule;
+
+		//off-peak interval
+		TInt iSyncOffPeakSchedule;
+
+		
+		TBool iPeakSyncEnabled;
+		TBool iOffPeakSyncEnabled;
+
+		//A new RSyncMLProfileBase profile is created for auto sync
+		//Selected Auto sync contents are set as the task items for this profile
+		//All the settings for this profie are copied from the profile selected by user.
+		
+		TInt iAutoSyncProfileId;
+		
+        //Sync time for once a day sync
+		TInt iAutoSyncScheduleTimeHr;
+		TInt iAutoSyncScheduleTimeMin;
+
+		//schedule handles.
+        TInt iPeakScheduleHandle;
+		TInt iOffPeakScheduleHandle;
+
+		// sync session
+		RSyncMLSession iSyncSession;
+
+		// is sync session open
+		TBool iSyncSessionOpen;
+
+		// Daily sync setting
+		TBool iDailySyncEnabled;
+		TInt iSyncFrequency;
+
+		
+    };
+
+#endif  // ASPSCHEDULE_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspScheduleDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,686 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Scheduled sync UI 
+*
+*/
+
+
+
+#ifndef ASPSCHEDULEDIALOG_H
+#define ASPSCHEDULEDIALOG_H
+
+
+//  INCLUDES
+
+#include "AspDialogUtil.h"
+
+#include <e32base.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+
+
+// FORWARD DECLARATIONS
+
+class CAspSchedule;
+class CAspProfileWizard;
+
+
+// CLASS DECLARATION
+/**
+* MAuotSyncEditorPageObserver
+*
+* Observer interface function.
+*/
+
+NONSHARABLE_CLASS (MAutoSyncEditorPageObserver)
+	{
+  	
+	public:
+		/**
+        * Editor page call this when editor is about to close.
+        * @param aText Editor text.
+        * @return ETrue if input is ok, EFalse otherwise. 
+        */
+		virtual TBool CheckValidityL() = 0;
+
+		/**
+	*Return the index of email item in provider list
+	*/
+		virtual TInt EmailIndex() = 0;
+
+	};
+
+
+/**
+* TAutoSyncSettingPageParam
+*
+* This class is used as general parameter type.
+*/
+NONSHARABLE_CLASS (TAutoSyncSettingPageParam)
+	{
+	public:
+	    TInt iCommandId;
+	    TBuf<KBufSize> iPageText;
+	    MAutoSyncEditorPageObserver* iObserver;
+	    TInt iSettingType;
+	};
+
+
+/**
+* CAspAutoCheckBoxSettingPage
+*
+* Setting page that returns command button id.
+*/
+NONSHARABLE_CLASS (CAutoSyncCheckBoxSettingPage) : public CAknCheckBoxSettingPage,public MEikListBoxObserver
+	{
+    public:
+        CAutoSyncCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray, TAutoSyncSettingPageParam& aParam);
+
+        ~CAutoSyncCheckBoxSettingPage();            
+        
+	public:
+
+		void UpdateCbaL(TInt aResourceId);
+		void DynamicInitL();
+
+	protected: // From CCoeControl
+	    void ProcessCommandL(TInt aCommandId);
+	    
+	    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	    //from MEikListBoxObserver for touch event handling
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+		
+	private:
+	    TAutoSyncSettingPageParam& iParam;
+   	    TInt iSelectionCount;
+   	    CSelectionItemList* iSelectionItemList;
+		
+	};
+
+
+
+/**
+*  CAspScheduleDialog
+*
+* CAspScheduleDialog is used for editing sync connection data.
+*/
+NONSHARABLE_CLASS (CAspScheduleDialog) : public CAknDialog, public MEikListBoxObserver,
+																	  public MAutoSyncEditorPageObserver
+    {
+    private:
+		
+	enum TRepositoryKey
+		{
+	    EKeySyncFrequency = 2,
+	    EKeyPeakSyncInterval,
+	    EKeyOffPeakSyncInterval
+		};
+    
+    
+	public:
+	    /**
+        * Launches dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(const TAspParam& aParam);
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+		static CAspScheduleDialog* NewL(const TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspScheduleDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspScheduleDialog(const TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param aType.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework when dialog is activated.
+        * @param None.
+		* @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+		/**
+		* From TAutoSyncSettingPageParam
+		* Checks validity content selected
+		* @param  None
+		* @return ETrue/EFalse.
+		*/
+
+		TBool CheckValidityL();
+
+		TInt EmailIndex();
+		
+		/**
+		* Checks remote databse settings for the profile
+		* @param  None
+		* @return None.
+		*/
+
+		void CheckMandatoryDataL();
+
+		/**
+		* Checks remote databse settings for the profile
+		* @param  None
+		* @return ETrue/EFalse.
+		*/
+		TBool CheckBearerType();
+
+		
+
+    private:
+		/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+
+	
+	public:  // common editors
+	
+		/**
+		* Shows editor for text type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemTextL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for number type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemNumberL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for list type setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		//TBool EditSettingItemListL(CAspListItemData& aItem);
+ 
+    private:
+    
+		/**
+		* Handles setting item editing.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemL(CAspListItemData& aItem);
+
+		/**
+		* Change Yes/No setting in place without showing editor.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemYesNoL(CAspListItemData& aItem);
+	
+		/**
+		* Shows editor for profile setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemProfileL(CAspListItemData& aItem);
+
+		/**
+		* Shows editor for content setting.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemContentL(CAspListItemData& aItem);
+
+		/**
+		* Shows setting editor.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemWeekdaysL(CAspListItemData& aItem);
+		
+		/**
+		* Shows setting editor.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemTimeL(CAspListItemData& aItem);
+		
+		/**
+		* Shows editor for peak schedule selection
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemPeakScheduleL(CAspListItemData& aItem);
+
+		/**
+		* Shows editor for off-peak schedule selection
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+		TBool EditSettingItemOffPeakScheduleL(CAspListItemData& aItem);
+
+		/**
+		* Shows editor for sync frequency selection
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+
+		TBool EditSettingItemSyncFrequencyL(CAspListItemData& aItem);
+	
+
+    private:
+
+		/**
+		* Checks that all mandatory data is found.
+		* @param None.
+		* @return Return code.
+		*/
+		TInt CheckMandatoryFields();
+		
+		/**
+		* Saves profile.
+		* @param None.
+		* @return None.
+		*/
+		void SaveSettingsL();
+
+	private:
+		/**
+        * Create one CNSmlDSProfileData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		void InitSettingItemL(CAspListItemData* aItem);
+		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+
+		/**
+        * Adds one setting item into item list.
+        * @param aItemId Item id.
+        * @param aHeaders Array of item headers.
+		* @return None.
+        */
+		void AddItemL(TInt aItemId, TInt aResourceId);
+
+		/**
+        * Set setting item visibility (normal/readonly/hidden).
+        * @param None.
+		* @return None.
+        */
+		void SetVisibility();
+		
+        /**
+        * Set all settings to read-only state.
+        * @param None.
+		* @return None.
+        */
+		void SetAllReadOnly();
+		
+
+    private:
+
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+		/**
+		* Returns setting item with listbox position aIndex.
+		* @param aIndex Listbox index.
+		* @return Pointer to setting item.
+        */
+		CAspListItemData* GetItemForIndex(TInt aIndex);
+
+		/**
+        * Returns setting item with id aItemId.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+
+		/**
+		* Get profile name.
+		* @param aProfileId.
+		* @param aText.
+		* @return None.
+		*/
+		void GetProfileName(TInt& aProfileId, TDes& aText);
+
+		/**
+		* Get content name.
+		* @param aProfileId.
+		* @param aText.
+		* @return None.
+		*/
+		//void GetContentName(TDes& aText);
+
+		/**
+		* Get day name.
+		* @param aProfileId.
+		* @param aText.
+		* @return None.
+		*/
+		void GetWeekdayNameL(TDes& aText);
+
+		/**
+		* Update content list from schedule settings.
+		* @param None.
+		* @return None.
+		*/
+		//void GetContentSelectionL();
+		
+		/**
+		* Get content list from sync profile.
+		* @param aList.
+		* @return None.
+		*/
+		//void GetContentSelection2L(CSelectionItemList* aList);
+		
+		/**
+		* Write selected contents into schedule settings.
+		* @param None.
+		* @return None.
+		*/
+		//void SetContentSelectionL();
+
+		/**
+		* Construct CSelectionItemList.
+		* @param aList.
+		* @return None.
+		*/
+		void GetWeekdaySelectionL(CSelectionItemList* aList);
+
+		/**
+		* Construct CSelectionItemList.
+		* @param aList.
+		* @return None.
+		*/
+		void SetWeekdaySelectionL(CSelectionItemList* aList);
+		
+			/**
+		* Set default day selection
+		* @param None
+		* @return None.
+		*/
+		void SetDefaultdaySelectionL();
+		/**
+		* Construct time text.
+		* @param aText.
+		* @param aTime.
+		* @return None.
+		*/
+		void GetTimeTextL(TDes& aText, TTime aTime);
+		
+   
+       /**
+		*Get content name 
+		* @param aText.
+		* @return None.
+		*/
+        void GetContentsNameL(TDes& aText);
+
+	   /**
+		*Get content selection
+		* @param aList
+		* @return None.
+		*/	   
+        void GetContentSelectionL(CSelectionItemList* aList);
+
+	   /**
+		*Set content selection
+		* @param aList.
+		* @return None.
+		*/
+        void SetContentSelectionL(CSelectionItemList* aList);
+
+		CDesCArray* GetSyncFrequencyListLC();
+		void GetSyncFrequencyValueL(TInt schedule, TDes& aBuf);
+		TInt SyncFrequencyL(const TDesC& aBuf);
+		TInt GetSyncFrequencyPositionL(CDesCArray* arr, TInt aInterval);
+
+		/**
+		*Check if the profile has access point selected
+		* @param aProfileId
+		* @return None.
+		*/
+ 		void CheckAccessPointSelectionL(TInt aProfileId);
+
+		/**
+		*Get list of peak schedule intervals
+		* @return CDesCArray*
+		*/
+		CDesCArray* GetPeakScheduleListLC();
+
+		/**
+		*Get list of peak schedule intervals
+		* @return CDesCArray*
+		*/
+		CDesCArray* GetOffPeakScheduleListLC();
+
+			/**
+		*Get time interval string corresponding to a schedule no
+		* @return CDesCArray*
+		*/
+		void GetPeakScheduleValueL(TInt schedule, TDes& aBuf);
+		void GetOffPeakScheduleValueL(TInt schedule, TDes& aBuf);
+
+			/**
+		*Get time interval value for the string
+		* @return CDesCArray*
+		*/
+		TInt PeakScheduleL(const TDesC& aBuf);
+		TInt OffPeakScheduleL(const TDesC& aBuf);
+
+			/**
+		*Position of selected interval in the list
+		* @return CDesCArray*
+		*/
+		TInt GetPeakPositionL(CDesCArray* arr, TInt aInterval);
+		TInt GetOffPeakPositionL(CDesCArray* arr, TInt aInterval);
+
+			/**
+		*Show auto sync info
+		* @return CDesCArray*
+		*/
+		void ShowAutoSyncInfoL();
+
+			/**
+		*Set default content selection
+		* 
+		*/
+		void SetDefaultContentL();
+			
+			/**
+		*Read cenrep for operator configured sync interval values
+		* 
+		*/
+		void ReadRepositoryL(TInt aKey, TInt& aValue);
+			
+			/**
+		*Create content list
+		* 
+		*/
+		void CreateContentListL();
+
+			/**
+		*Check if time definition is valid.
+		* 
+		*/
+		TBool CheckPeakTime();
+
+	private:
+		// setting list
+		CAknSettingStyleListBox* iSettingListBox;
+
+		// list of setting items
+		CAspSettingList *iSettingList;
+
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// resource handler
+		CAspResHandler* iResHandler;
+
+		// dialog edit mode
+		TInt iEditMode;
+
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+		
+		// list that contains all profiles
+		CAspProfileList* iProfileList;
+		
+		// for storing auto sync settings
+		CAspSchedule* iSchedule;
+
+		// profile data
+		CAspProfile* iProfile;
+
+		// id of the calling application
+		TInt iApplicationId;
+		
+		// weekday names
+		CDesCArray* iWeekdayList;
+		
+		// have settings changed
+		TBool iSettingChanged;
+		
+		// Content names
+		CDesCArray* iContentsList;
+
+		TBool iDoCleanUp;
+
+		// is setting database in read only state
+		TBool iSettingEnforcement;
+		
+		
+    };
+
+
+#endif      // ASPSCHEDULEDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSettingDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,692 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 view setting dialog 
+*
+*/
+
+
+#ifndef ASPSETTINGDIALOG_H
+#define ASPSETTINGDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <eikdialg.h>
+#include <eiklbo.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+#include <aknnavi.h>
+#include <AknInfoPopupNoteController.h> // CAknInfoPopupNoteController
+
+#include "AspDefines.h"
+#include "AspDialogUtil.h"
+#include "AspResHandler.h"
+#include "AspDbNotifier.h"
+#include "AspSyncHandler.h"
+
+
+// FORWARD DECLARATIONS
+
+// CONSTANTS
+
+const TInt KSettingDialogPopupDisplayTime = 3*1000;
+
+
+
+// CLASS DECLARATION
+
+/**
+*  CAspSettingDialog
+*
+* This is sync app  main dialog.
+*/
+NONSHARABLE_CLASS (CAspSettingDialog) : public CAknDialog, public MEikListBoxObserver,
+                                        public MAspDbEventHandler, public MAspSyncObserver
+	{
+	
+	enum TAspSettingDialogIconIndex
+		{
+	    EIconIndexHTTP = 0,
+        EIconIndexBT   = 1,
+	    EIconIndexUSB  = 2,
+	    EIconIndexIrda = 3,
+	    EIconIndexSyncOff = 4,
+		EIconIndexMultipleContent = 5
+		};
+
+	public:
+
+	    /**
+        * Launches setting dialog.
+		* @param aParam Class that contains dialog parameters.
+        * @return Return code.
+        */
+		static TBool ShowDialogL(TAspParam& aParam);
+		
+    public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CAspSettingDialog* NewL(TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspSettingDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspSettingDialog(TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+       
+        /**
+        * Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PostLayoutDynInitL();
+
+        /**
+        * Called by framework after the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PreLayoutDynInitL();
+
+		/**
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+	
+		/**
+		* Handles menu events, ProcessCommandL calls this.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void DoProcessCommandL(TInt aCommandId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param TEventCode.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL(TInt aResourceID,	CEikMenuPane* aMenuPane);
+
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+		
+		/**
+		* Called when display resolution changes.
+        * @param aType.
+		* @return None.
+        */
+		void HandleResourceChange(TInt aType);
+		
+		/**
+		* Sets settings dialog icons.
+        * @param None.
+		* @return None.
+        */
+		void SetIconsL();
+		
+
+    private: // from MEikListBoxObserver
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+	
+    private:  // from MAspDbEventHandler
+		/**
+        * From MAspDbEventHandler
+        * @param aStatus EClose, EUnlock, ECommit, ERollback, or ERecover (d32dbms.h).
+        * @return None. 
+        */
+		void HandleDbEventL(TAspDbEvent aEvent);
+
+	private: // from MAspActiveCallerObserver
+		/**
+        * From MAspActiveCallerObserver
+		* Called when CAspActiveCaller completes.
+        * @param aCallId.
+        * @return None.
+        */
+		void HandleActiveCallL(TInt aCallId);
+
+	private: // from MAspSyncObserver
+		/**
+        * From MAspSyncObserver
+		* Called when synchronization completes.
+        * @param aError.
+        * @param aInfo1.
+        * @return None.
+        */
+		void HandleSyncEventL(TInt aError, TInt aInfo1);
+
+
+    private:
+    
+    
+        	/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+
+		/**
+        * Creates set type profile.
+		* @param None.
+        * @return None.
+        */
+		void CreateProfileL();
+
+		/**
+        * Creates application type profile.
+		* @param None.
+        * @return None.
+        */
+		void CreateAppProfileL();
+
+		/**
+        * Creates application type profile for sync app.
+		* @param None.
+        * @return None.
+        */
+		TBool CreateAppProfileFromSyncAppL();
+        		
+		/**
+        * Changes active profile.
+		* @param None.
+        * @return None.
+        */
+        void ChangeProfileL();
+        
+		/**
+        * Shows profile dialog.
+		* @param aEditMode.
+		* @param aFocus 
+        * @return None.
+        */
+		void EditProfileL(TInt aEditMode ,TInt aFocus);
+
+		/**
+        * Shows profile dialog.
+		* @param TInt aEditMode.
+		* @param TInt aFocus.
+        * @return None.
+        */
+		void DoEditProfileL(TInt aEditMode ,TInt aFocus);
+
+		/**
+        * Syncs selected profile.
+		* @param None.
+        * @return None.
+        */
+		void SyncProfileL();
+
+		/**
+        * Syncs selected profile.
+		* @param None.
+        * @return None.
+        */
+		void CopyFromServerL();
+
+		/**
+        * Syncs selected profile.
+		* @param aSyncType.
+        * @return None.
+        */
+		void DoSyncProfileL(TInt aSyncType);
+
+		/**
+        * Shows context menu.
+		* @param aResource.
+        * @return None.
+        */
+        void ShowContextMenuL(TInt aResource);
+        
+		/**
+		* Initialilzes context menu.
+		* @param aMenuPane.
+		* @return None.
+		*/
+		void InitContextMenuL(CEikMenuPane* aMenuPane);
+
+		/**
+		* Initialilzes options menu.
+		* @param aMenuPane.
+		* @return None.
+		*/
+		void InitOptionsMenuL(CEikMenuPane* aMenuPane);
+		
+		/**
+		* Deletes sync profile.
+		* @param None.
+		* @return None.
+		*/
+		void DeleteProfileL();
+        
+		/**
+		* Shows log dialog.
+		* @param None.
+		* @return None.
+		*/
+		void ShowLogDialogL();
+
+		/**
+		* Shows auto sync dialog.
+		* @param None.
+		* @return None.
+		*/
+		void ShowAutoSyncDialogL();
+		
+		/**
+		* Shows popup info note about current profile.
+		* @param None.
+		* @return None.
+		*/
+		void ShowCurrentProfileInfoL();
+
+		/**
+		* Shows popup info note about current profile.
+		* @param None.
+		* @return None.
+		*/
+		void ShowCurrentProfileInfo();
+
+		/**
+		* Shows popup info note about current profile.
+		* @param aProfileId.
+		* @return Boolean.
+		*/
+		TBool ShowAutoSyncProfileInfoL();
+
+		/**
+		* Shows popup info note about current profile.
+		* @param aProfileId.
+		* @return Boolean.
+		*/
+		TBool ShowAutoSyncProfileInfo();
+		/**
+		* Update the MSK Label
+		* @param aCommandId command id.
+		* @param aResourceId resource id .
+	    */
+		void UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId);
+
+		void ShowAutoSyncLog(TAny* /*aAny*/);
+
+    private:
+
+		/**
+		* Utility function.
+		* @param None.
+		* @return Dialog listbox.
+		*/
+		CAknDoubleLargeStyleListBox* ListBox();
+		
+	   /**
+		* Utility function.
+		* @param None.
+		* @return None
+		* To toggle Syncmlmail checkbox in profile settings
+		*/
+		void CancelMailBoxForEnterL();
+
+		/**
+		* Utility function.
+		* @param None.
+		* @return Sync handler.
+		*/
+        TBool SyncRunning();
+
+		/**
+		* Utility function.
+		* @param aProfileId.
+		* @return Profile's listbox index.
+		*/
+		TInt ProfileIndex(TInt aProfileId);
+
+		/**
+		* Utility function, sets listbox current item.
+		* @param None.
+		* @return None.
+		*/
+		void SetCurrentIndex();
+
+		/**
+		* Utility function, stores listbox current item.
+		* @param aIndex.
+		* @return Selected item index.
+		*/
+		void SetCurrentIndex(TInt aIndex);
+
+		/**
+		* Utility function, gets listbox current item.
+		* @param None.
+		* @return Current index.
+		*/
+		TInt CurrentIndex();
+		
+		/**
+		* Utility function, updates dialog cba.
+		* @param aResourceId.
+		* @return None.
+		*/
+		void UpdateCbaL(TInt aResourceId);
+
+		/**
+		* Sets currrent profile.
+		* @param aProfileId.
+		* @return None.
+		*/
+		void DoSetCurrentProfileL(TInt aProfileId);
+
+		/**
+		* Sets currrent profile.
+		* @param None.
+		* @return None.
+		*/
+		void SetCurrentProfileL();
+
+		/**
+		* Utility function.
+		* @param None.
+		* @return Selected profile.
+		*/
+		TAspProfileItem& CurrentProfileL();
+		
+		/**
+		* Utility function.
+		* @param None.
+		* @return ETrue if current profile exists, EFalse otherwise.
+		*/
+		TBool HasCurrentProfile();
+		
+		/**
+		* Utility function.
+		* @param aProfileId.
+		* @return ETrue if current profile has id aProfileId, EFalse otherwise.
+		*/
+		TBool IsCurrentProfile(TInt aProfileId);
+
+		/**
+		* Save current profile.
+		* @param None.
+		* @return None.
+		*/
+		void DoSaveCurrentProfileL();
+
+		/**
+		* Save current profile.
+		* @param None.
+		* @return None.
+		*/
+		TInt SaveCurrentProfile();
+		
+		/**
+		* Update content selection.
+		* @param None.
+		* @return None.
+		*/
+		void UpdateContentSelectionL();
+		
+		/**
+		* Update profile name.
+		* @param None.
+		* @return None.
+		*/
+		void UpdateProfileNameL();
+		
+		/**
+		* Check profile mandatory data
+		* @param None.
+		* @return Return code.
+		*/
+		TInt CheckMandatoryDataL();
+
+		/**
+		* Check profile mandatory data
+		* @param None.
+		* @return Return code.
+		*/
+		TInt DoCheckMandatoryDataL();
+
+		/**
+		* Update navi pane text.
+		* @param aText.
+		* @return None.
+		*/
+        void UpdateNavipaneL(const TDesC& aText);
+        
+		/**
+		* Show popup note.
+		* @param aText.
+		* @return None.
+		*/
+        void ShowPopupNoteL(const TDesC& aText);
+        
+		/**
+		* Cancels checkbox select/unselect.
+		* @param None.
+		* @return None.
+		*/
+        void CancelCheckboxEventL();
+        
+		/**
+		* Cancels checkbox select/unselect.
+		* @param None.
+		* @return None.
+		*/
+        void CancelCheckboxEvent();
+
+		/**
+		* Checks whether email content can be selected.
+		* @param None.
+		* @return EFalse if selection is not possible.
+		*/
+        TBool CheckEmailSelectionL();
+
+		/**
+		* Checks whether email content can be selected.
+		* @param None.
+		* @return EFalse if selection is not possible.
+		*/
+        TBool CheckEmailSelection();
+        
+      public:
+      
+        /**
+        * Updates listbox items.
+        * @param aUpdateProfileList.
+        * @return None.
+        */
+		void UpdateListBoxL();
+		
+        
+        /**
+		* Sets currrent profile.
+		* @param aProfileId.
+		* @return None.
+		*/
+		void SetCurrentProfile(TInt aProfileId);
+		
+		/**
+		* Delete Auto sync history
+		* @param None.
+		* @return None.
+		*/
+		void DeleteAutoSyncHistory();   
+		
+#ifdef RD_DSUI_TIMEDSYNC 
+
+		void SetNextProfileL();
+        void SetPreviousProfileL();
+        void UpdateTabsL();
+        
+#endif
+		void UpdateMarkMenuItem(CEikMenuPane* aMenuPane);
+		void SaveSelectionL();
+
+
+		
+    /**
+		* Checks whether the profile is already opened in another application.
+		* @param aProfileId.
+		* @return ETrue if profile locked ,else EFalse.
+		*/        
+        TBool IsProfileLockedL(TInt aProfileId);
+     
+     
+     /**
+		* Checks whether sync is ongoing for a profile
+		* @param aProfileId.
+		* @return ETrue if sync ongoing ,else EFalse.
+		*/        
+        TBool IsSyncOnGoingL(TInt aProfileId);
+
+#ifdef _DEBUG
+    private: 
+        void TestL();
+        void LogDatabaseEvent(TAspDbEvent aEvent);
+#endif
+
+		
+
+    private:
+   		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+
+		// id of the calling application
+		TInt iApplicationId;
+
+		// id of the dialog mode
+		TInt iDialogMode;
+
+        // profile list (from CNSmlDSSettings)
+		CAspProfileList* iProfileList;
+
+		// list of profiles
+		CAknDoubleLargeStyleListBox* iSettingListBox;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+		
+		// for hiding tabs
+		CAknNavigationControlContainer* iNaviPane;
+
+    	// resource handler
+		CAspResHandler* iResHandler;
+
+		// for getting settings database notifications 
+		CAspDbNotifier* iDbNotifier;
+
+		// currently selected listbox item
+		TInt iCurrentListBoxIndex;
+
+		// performs sync operation, uses CNSmlAppEngine
+		CAspSyncHandler* iSyncHandler;
+		
+		// session with sync server
+		RSyncMLSession* iSyncSession;
+		
+		// is setting database in read only state
+		TBool iSettingEnforcement;
+		
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+
+		// currently open profile id
+		TInt iCurrentProfileId;
+
+		// current profile name
+		TBuf<KAspMaxProfileNameLength> iCurrentProfileName;
+		
+		// popup note
+        CAknInfoPopupNoteController* iPopupNote;
+        
+		// for bearer type list construction
+		CAspBearerHandler* iBearerHandler;
+
+#ifdef RD_DSUI_TIMEDSYNC	
+		// Tab group owned by the navigation decorator.
+        CAspTabbedNaviPaneHandler* iTabHandler;
+
+		//Set if any profile is edited or profile count changed
+		TBool iUpdateTabGroup;
+#endif
+
+		
+    };
+
+
+#endif    // ASPSETTINGDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSettingViewDialog.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,332 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Edit view setting dialog 
+*
+*/
+
+
+
+#ifndef ASPSETTINGVIEWDIALOG_H
+#define ASPSETTINGVIEWDIALOG_H
+
+
+//  INCLUDES
+
+#include "AspDialogUtil.h"
+
+#include <e32base.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+
+#include <AknInfoPopupNoteController.h> // CAknInfoPopupNoteController
+
+
+
+// CLASS DECLARATION
+
+
+/**
+*  CAspSettingViewDialog
+*
+* CAspSettingViewDialog is used for editing various settings.
+*/
+NONSHARABLE_CLASS (CAspSettingViewDialog) : public CAknDialog, public MEikListBoxObserver
+    {
+    public:
+    
+    
+	public:
+	    /**
+        * Launches dialog.
+        * @param aParam Class that contains dialog parameters.
+        * @return Completion code.
+        */
+		static TBool ShowDialogL(const TAspParam& aParam);
+
+	public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+		static CAspSettingViewDialog* NewL(const TAspParam& aParam);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CAspSettingViewDialog();
+    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CAspSettingViewDialog(const TAspParam& aParam);
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+        /**
+        * From the base class.
+		* Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param aButtonId Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+        TBool OkToExitL(TInt aButtonId);
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param aType.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+        /**
+        * From the base class.
+		* Called by framework when dialog is activated.
+        * @param None.
+		* @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext(TCoeHelpContext& aContext) const;
+
+
+		/**
+		* From the base class.
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL(TInt aCommandId);
+		
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+
+    private:
+		/**
+		* Handles setting item editing.
+		* @param None.
+		* @return None.
+		*/
+		void HandleOKL();
+		
+		/**
+		* Set setting list icons.
+		* @param None.
+		* @return None.
+		*/
+		void SetIconsL();
+
+	
+	public:  // common editors
+	
+    
+    private:
+    
+		/**
+		* Handles setting item editing.
+		* @param aItem Setting item data.
+		* @return Return code.
+		*/
+	   void EditSettingItemL(CAspListItemData& aItem);
+		
+		/**
+		* Opens profile setting dialog.
+		* @param None.
+		* @return Return code.
+		*/
+	  TInt EditSettingItemProfileSettingL();
+	  
+	  	/**
+		* Opens schedule dialog.
+		* @param None.
+		* @return Return code.
+		*/
+	  TInt EditSettingItemSchedulingSettingL();
+    	/**
+		* Opens content dialog.
+		* @param None.
+		* @return Return code.
+		*/
+	  TInt EditSettingItemSyncContentL(CAspListItemData& aItem);
+
+
+    private:
+
+		
+
+	private:
+		/**
+        * Create one CNSmlDSProfileData for each setting.
+        * @param None.
+        * @return None.
+        */
+		void CreateSettingsListL();
+		
+		/**
+        * Initalizes setting item needed for listbox handling.
+        * @param aItem.
+        * @return None.
+        */
+		void InitSettingItemL(CAspListItemData* aItem);
+		
+		/**
+        * Add settings titles into listbox.
+        * @param aListBox.
+        * @param aItemList List of setting items.
+        * @return None.
+        */
+		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
+
+		/**
+        * Adds profile setting into item list.
+        * @param None.
+		* @return None.
+        */
+		void AddProfileSettingItemL();
+		/**
+        * Adds scheduling setting into item list.
+        * @param None.
+		* @return None.
+        */
+		void AddSchedulingSettingItemL();
+		/**
+        * Adds sync contents into item list.
+        * @param None.
+		* @return None.
+        */
+		void AddContentItemsL();
+		
+		
+
+    private:
+
+		/**
+        * Creates icon.
+		* @param aId.
+        * @param aFileName.
+		* @param aFileIndex.
+		* @param aFileMaskIndex.
+        * @return Created icon.
+        */
+		CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex);
+		
+		/**
+		* Returns setting item with listbox position aIndex.
+		* @param aIndex Listbox index.
+		* @return Pointer to setting item.
+        */
+		CAspListItemData* GetItemForIndex(TInt aIndex);
+
+		/**
+        * Returns setting item with id aItemId.
+        * @param aItemId Item id.
+        * @return Pointer to setting item.
+        */
+		CAspListItemData* Item(TInt aItemId);
+
+		/**
+		* Returns listbox.
+		* @param None.
+		* @return Pointer to listbox.
+		*/
+		CAknSettingStyleListBox* ListBox();
+
+		/**
+		* Returns profile.
+		* @param None.
+		* @return Pointer to sync profile.
+		*/
+		//CAspProfile* Profile();
+
+		TInt GetIndexFromProvider(TInt aDataProvider);
+
+		void SetVisibility();
+
+	private:
+		// setting list
+		CAknSettingStyleListBox* iSettingListBox;
+
+		// list of setting items
+		CAspSettingList *iSettingList;
+		
+     	// profile data
+		CAspProfile* iProfile;
+
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// for title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+
+		// resource handler
+		CAspResHandler* iResHandler;
+
+		// dialog edit mode
+		TInt iEditMode;
+
+		// long buffer for string handling
+		TBuf<KBufSize255> iBuf;
+
+		TInt iDataProviderId;
+		
+		// list that contains all contents (applications)
+		CAspContentList* iContentList;
+		
+		// list that contains all profiles
+		CAspProfileList* iProfileList;
+
+		// id of the calling application
+		TInt iApplicationId;
+
+		CAspSchedule* iSchedule;
+
+				
+		};
+
+
+#endif      // ASPSETTINGVIEWIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspState.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Utility class to handle sync phases during progress 
+*
+*/
+
+
+#ifndef ASPSTATE_H
+#define ASPSTATE_H
+
+
+//  INCLUDES
+#include <e32base.h>
+
+
+// CONSTANTS
+
+const TInt KTotalProgressUnknown = -1;
+const TInt KTotalProgress = 100;
+
+
+/**
+* CAspState
+*
+* CAspState contains sync state information.
+*/
+NONSHARABLE_CLASS (CAspState) : public CBase
+    {
+    public:
+		enum TSyncPhase
+			{
+			EPhaseConnecting = 0,
+			EPhaseInitialising,
+			EPhaseSending,
+			EPhaseReceiving,
+			EPhaseSynchronizing,
+			EPhaseDisconnecting,
+			EPhaseCanceling,
+			EPhaseNone
+			};
+
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspState* NewL();
+        
+        /**
+        * Destructor.
+        */
+        ~CAspState();
+        
+    private:
+        /**
+        * C++ default constructor.
+        */
+        CAspState();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+    public:
+        /**
+        * Reset state variables.
+        * @param None.
+        * @return None.
+        */
+        void Reset();
+        
+    public:
+        /**
+        * Set synchronization phase.
+        * @param aPhase synchronization phase.
+        * @return None.
+        */
+        void SetSyncPhase(TInt aPhase);
+        
+        /**
+        * Get synchronization phase.
+        * @param None.
+        * @return Synchronization phase.
+        */
+        TInt SyncPhase();
+
+        /**
+        * Set total sync progress.
+        * @param aCount Progress count.
+        * @return None.
+        */
+		void SetTotalProgress(TInt aCount);
+
+        /**
+        * Set sync progress.
+        * @param aCount Progress count.
+        * @return None.
+        */
+		//void SetProgress(TInt aCount);
+
+        /**
+        * Get total sync progress.
+        * @param None. 
+        * @return Progress count.
+        */
+		TInt TotalProgress();
+
+        /**
+        * Increase sync progress.
+        * @param None.
+        * @return None.
+        */
+        void IncreaseProgress();
+        
+        /**
+        * Increase sync progress.
+        * @param aCount.
+        * @return None.
+        */
+        void IncreaseProgress(TInt aCount);
+        
+        /**
+        * Get sync progress.
+        * @param None. 
+        * @return Progress count.
+        */
+		TInt Progress();
+
+        /**
+        * Has IncreaseProgress been called once.
+        * @param None. 
+        * @return Boolean.
+        */
+		TBool FirstProgress();
+
+        /**
+        * Set sync content name.
+        * @param aText Content name.
+        * @return None.
+        */
+        void SetContentL(const TDesC& aText);
+
+        /**
+        * Get sync content name.
+        * @param None. 
+        * @return Content name.
+        */
+		const TDesC& Content();
+
+        /**
+        * Resets progress state.
+        * @param None. 
+        * @return None.
+        */
+		void ResetProgress();
+		
+        /**
+        * Finds out whether total progress count is known.
+        * @param None. 
+        * @return ETrue if total progress count is known, EFalse otherwise.
+        */
+		TBool ProgressKnown();
+        
+    private:
+        // synchronization phase
+		TInt iSyncPhase;
+
+		// total number of sent/received sync items
+		TInt iTotalProgressCount;
+
+		// number of sent/received sync items
+		TInt iProgressCount;
+		
+		// number of increase progress calls, can different than iProgressCount
+		TInt iProgressCount2;
+
+		// name of the content being synced
+		HBufC* iSyncContent;
+    };
+
+#endif  // ASPSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSyncHandler.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Creates sync job and receives progress events 
+*
+*/
+
+
+#ifndef ASPSYNCHANDLER_H
+#define ASPSYNCHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <SyncMLObservers.h>
+#include <textresolver.h>
+
+
+#include "AspProgressDialog.h"
+#include "AspState.h"
+#include "AspProfile.h"
+
+
+
+// CLASS DECLARATION
+
+
+/**
+* MAspProgressDialogObserver
+* 
+* Observer interface function for observing sync events.
+*/
+NONSHARABLE_CLASS (MAspSyncObserver)
+    {
+    public:
+        /**
+        * Callback method
+        * Get's called when a synchronization has completed.
+        */
+        virtual void HandleSyncEventL(TInt aError, TInt aInfo1) = 0;
+    };
+
+
+/**
+* TAspSyncParam
+*
+* This class is used as sync parameter type.
+*/
+NONSHARABLE_CLASS (TAspSyncParam)
+	{
+    public:
+    	TAspSyncParam(TInt aApplicationId);
+        
+    public:
+		// calling application id
+		TInt iApplicationId;
+
+		// profile id
+		TInt iProfileId;
+
+		// job id
+		TInt iJobId;
+
+		// taskId
+		TInt iTaskId;
+
+        // sync direction
+		TInt iSyncDirection;
+		
+		// progress dialog modality
+		TInt iDialogMode;
+	};
+
+
+/**
+* CAspSyncHandler
+* 
+* CAspSyncHandler handles data synchronizing.
+*/
+NONSHARABLE_CLASS (CAspSyncHandler) : public CBase, 
+                        public MAspProgressDialogObserver,
+						public MAspActiveCallerObserver,
+						public MSyncMLEventObserver,
+						public MSyncMLProgressObserver
+						
+	{
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+	    static CAspSyncHandler* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+	    virtual ~CAspSyncHandler();
+
+    private:
+	    /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	    /**
+        * C++ default constructor.
+        */
+	    CAspSyncHandler(const TAspParam& aParam);
+
+		
+	private:	
+        /**
+        * From MAspProgressDialogObserver
+    	* Gets called when sync progress dialog closes.
+        * @param aButtonId Button id.
+        * @return None
+        */
+		void HandleDialogEventL(TInt aButtonId);
+
+    
+	private: // from MAspActiveCallerObserver
+		/**
+        * From MAspActiveCallerObserver
+		* Called when CAspActiveCaller completes.
+        * @param aCallId.
+        * @return None.
+        */
+		void HandleActiveCallL(TInt aCallId);
+
+
+    private:    // from MSyncMLEventObserver
+        
+		/**
+        * From MSyncMLEventObserver
+		* Called when SyncML session events oocur.
+        * @param aEvent.
+        * @param aIdentifier.
+        * @param aError.
+        * @param aAdditionalData.
+        * @return None.
+        */
+        void OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt aAdditionalData);
+	
+	
+    private:  //from MSyncMLProgressObserver
+	    
+	    /**
+	    * Receives notification of a synchronisation error.
+        * @param aErrorLevel  The error level.
+	    * @param aError		  The type of error. This is one of the SyncMLError error values.	
+	    * @param aTaskId      The ID of the task for which the error occurred.
+	    * @param aInfo1       An integer that can contain additional information about the error. Normally 0.
+	    * @param aInfo2       An integer that can contain additional information about the error. Normally 0.
+	    * @return             None.
+	    */
+	    void OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError, TInt aTaskId, TInt aInfo1, TInt aInfo2);
+       	
+       	/**
+	    * Receives notification of synchronisation progress.
+	    * @param aStatus	The current status, e.g. 'Connecting'.
+	    * @param aInfo1	An integer that can contain additional information about the progress.
+	    * @param aInfo2	An integer that can contain additional information about the progress.
+	    */
+	    void OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt aInfo2);
+	    
+	    /**
+	    * Receives notification of modifications to synchronisation tasks.
+        * @param aTaskId               The ID of the task.
+	    * @param aClientModifications  Modifications made on the clients Data Store.
+	    * @param aServerModifications  Modifications made on the server Data Store.
+	    */
+	    void OnSyncMLDataSyncModifications(TInt aTaskId, const TSyncMLDataSyncModifications& aClientModifications, const TSyncMLDataSyncModifications& aServerModifications);
+
+	private:
+	    void OnSyncMLDataSyncModificationsL(TInt aTaskId, const TSyncMLDataSyncModifications& aClientModifications, const TSyncMLDataSyncModifications& aServerModifications);
+	    
+	    
+	private:
+        /**
+        * Shows progress dialog.
+		* @param None.
+        * @return Error code.
+        */
+        void ShowProgressDialogL();
+
+        /**
+        * Shows error dialog.
+		* @param None.
+        * @return Error code.
+        */
+        void ShowErrorNote();
+        
+        /**
+        * Completes sync operation.
+		* @param aError.
+        * @return None.
+        */
+        void SynchronizeCompleted(TInt aError);
+	
+	public:
+	
+        /**
+        * Performs synchronization.
+		* @param aSyncParam.
+        * @return None
+        */
+        void SynchronizeL(TAspSyncParam& aSyncParam);
+        
+        /**
+        * Sets sync observer.
+		* @param aObserevr.
+        * @return None
+        */
+        void SetObserver(MAspSyncObserver* aObserver);
+
+    
+    private:
+        /**
+        * Performs synchronization.
+		* @param aSyncParam.
+        * @return None
+        */
+        void DoSynchronizeL(TAspSyncParam& aSyncParam);
+
+	private:
+		/**
+        * Utility function.
+        * @return CAspResHandler.
+        */
+		CAspResHandler* ResHandlerL();
+		
+		/**
+        * Utility function.
+        * @return Progress dialog.
+        */
+		CAspProgressDialog* Dialog();
+
+		/**
+        * Utility function.
+        * @return Sync state.
+        */
+		CAspState* State();
+
+    public:
+
+		/**
+        * Utility function.
+        * @return ETrue if sync is currently running, EFalse otherwise.
+        */
+		TBool SyncRunning();
+
+    private:
+		/**
+        * Updates progress dialog.
+        * @param None.
+    	* @return None.
+        */
+		void UpdateDialogL();
+
+		/**
+        * Updates progress dialog.
+        * @param None.
+    	* @return None.
+        */
+		void UpdateDialog();
+
+		/**
+        * Get list profiles that can be used for syncing.
+        * @param aApplicationId Application (sync content) id.
+    	* @return None.
+        */
+		CAspProfileList* GetProfileListLC(TInt aApplicationId);
+		
+		/**
+        * Utility function.
+        * @param None.
+        * @return None.
+        */
+        void CreateContentListL();
+
+		/**
+        * Utility function.
+        * @param None.
+        * @return ETrue if server alert sync, EFalse otherwise.
+        */
+        TBool IsServerAlertSync();
+
+		/**
+        * Opens sync session.
+        * @param None.
+        * @return None.
+        */
+        void OpenSyncSessionL();
+
+		/**
+        * Closes sync session.
+        * @param None.
+        * @return None.
+        */
+        void CloseSyncSession();
+        
+		/**
+        * Calculates progress count.
+        * @param aC Phone side sync events.
+        * @param aS Server side sync events.
+        * @return Progress count.
+        */
+        TInt ProgressCount(const TSyncMLDataSyncModifications& aC,
+                           const TSyncMLDataSyncModifications& aS);
+                           
+		/**
+        * Checks that sync profile has valid local database.
+        * @param aProfileId.
+        * @return None.
+        */
+        void CheckLocalDatabaseL(TInt aProfileId);
+        
+		/**
+        * Checks whether progress dialog needs to be updated.
+        * @param None.
+        * @return Boolean.
+        */
+        TBool UpdateRequired();
+        
+		/**
+        * Completes sync with short delay.
+        * @param aError.
+        * @return None.
+        */
+        void CompleteWithDelay(TInt aError);
+        
+        TBool IsRoamingL();
+        
+        void ReadRepositoryL(TInt aKey, TInt& aValue);
+        
+        TInt BearerTypeL(TInt aProfileId);
+        
+#ifdef _DEBUG
+    private:  // debug code
+        void GetSyncStatusText(TDes& aText, MSyncMLProgressObserver::TStatus aStatus);
+        void GetSyncEventText(TDes& aText, MSyncMLEventObserver::TEvent aEvent);
+        void LogSessionEvent(TEvent& aEvent, TInt aIdentifier, TInt aError);
+        void LogProgressEvent(TStatus& aStatus, TInt aInfo1);
+        void LogErrorEvent(TErrorLevel aErrorLevel, TInt aError);
+        void LogModificationEvent(TInt aTaskId, const TSyncMLDataSyncModifications& aC, const TSyncMLDataSyncModifications& aS);
+        void LogModificationEvent(TInt aTaskId, const TDesC& aText);
+#endif
+
+    private:
+		// id of the calling application
+		TInt iApplicationId;
+
+		// profile id
+		TInt iProfileId;
+		
+		// sync session
+		RSyncMLSession iSyncSession;
+
+		// sync job
+		RSyncMLDataSyncJob iSyncJob;
+		
+		// needed for getting data provider names
+		CAspContentList* iContentList;
+		
+		// shows sync progress dialog
+		CAspProgressDialog* iProgressDialog;
+
+		// sync handler state
+		CAspState* iState;
+
+		// reads strings
+		CAspResHandler* iResHandler;
+
+		// for making function call via active scheduler
+		CAspActiveCaller* iActiveCaller;
+
+		// is sync currently running
+		TBool iSyncRunning;
+		
+		// is current sync servert alert sync
+		TBool iServerAlertSync;
+
+		// is sync session open
+		TBool iSyncSessionOpen;
+		
+		// sync error code
+		TInt iSyncError;
+		
+		// current sync job id
+		TInt iCurrentSyncJobId;
+		
+		// sync observer, used for sending sync completion event
+		MAspSyncObserver* iSyncObserver;
+
+        // for converting error code to error string
+        CTextResolver* iTextResolver;
+        
+		// has "sync completed" event arrived 
+		TBool iCompleteEventReceived;
+		
+		// has "sync stopped" event arrived 
+		TBool iStopEventReceived;
+		
+		// sync modality 
+		TBool iIsSynchronousOperation;
+		
+	    // for stopping code until sync is finished
+    	CActiveSchedulerWait* iWait;
+		
+	};
+	
+	
+
+
+	
+#endif  // ASPSYNCHANDLER_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSyncUtil.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,248 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Utility methods 
+*
+*/
+
+
+#ifndef ASPSYNCUTIL_H
+#define ASPSYNCUTIL_H
+
+
+// INCLUDES
+#include <e32base.h>
+#include "AspSyncHandler.h"
+#include "AspSettingDialog.h"
+
+
+
+// CLASS DECLARATION
+
+
+/**
+* CAspSyncUtil class
+*
+* CAspSyncUtil implements functionality that is exported in CSyncUtilApi. 
+*/
+NONSHARABLE_CLASS(CAspSyncUtil) : public CBase 
+	{
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+	    static CAspSyncUtil* NewL();
+
+	    /**
+        * Destructor.
+        */
+	    virtual ~CAspSyncUtil();
+
+    private:
+	    /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	    /**
+        * C++ default constructor.
+        */
+	    CAspSyncUtil();
+
+	
+	public:
+		
+        /**
+        * Performs automatic (scheduled) data synchronization. Does not create 
+        * any UI.Gets synchronization data from central repository.
+        * @param aScheduleTaskFile File that contains sync scheduling task. 
+	    * @return None.
+        */
+        void SynchronizeL(RFile& aScheduleTaskFile);        
+        
+        /**
+        * Performs synchronization.
+		* @param aApplicationId Id of calling application.
+		* @param aInfo1.
+		* @param aInfo2.
+        * @return None
+        */
+		void DoSynchronizeL(TInt aApplicationId, TInt aInfo1, const TDesC& aInfo2);
+		
+        /**
+        * Performs synchronization. Creates necessary UI.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh. 
+        * @param aJobId Sync task id, KErrNotFound if not used. 
+        * @param aInfo1 Extra information, KErrNotFound if not used. 
+        * @param aInfo2 Extra information, KNullDesC if not used. 
+	    * @return None.
+        */
+		void SynchronizeL(TInt aApplicationId, TInt aJobId, TInt aInfo1, TDes& aInfo2);
+
+        /**
+        * Performs synchronization. Creates necessary UI.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh. 
+        * @param aJobId Sync task id, KErrNotFound if not used. 
+        * @param aInfo1 Extra information, KErrNotFound if not used. 
+        * @param aInfo2 Extra information, KNullDesC if not used. 
+	    * @return None.
+        */
+		void DoSynchronizeL(TInt aApplicationId, TInt aJobId, TInt aInfo1, TDes& aInfo2);
+
+        /**
+        * Shows settings dialog for changing sync settings.
+		* @param aApplicationId Calling application id.
+		* @param aProfileId Profile id.
+		* @param aDialogMode Dialog mode.
+        * @return None.
+        */
+		void ShowSettingsDialogL(TInt aApplicationId, TInt aProfileId, TInt aDialogMode);
+		
+        /**
+        * Shows settings dialog for changing sync settings.
+		* @param aApplicationId Calling application id.
+        * @return None.
+        */
+		void ShowProfileDialogL(TInt aApplicationId);
+		
+        /**
+        * Shows UI for editing synchronization settings.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh.
+        * @param aInfo1 Extra information, KErrNotFound if not used. 
+        * @param aInfo2 Extra information, KNullDesC if not used.
+	    * @return None.
+        */
+		void ShowSettingsL(TInt aApplicationId, TInt aInfo1, TDes& aInfo2);
+ 		
+        /**
+        * Shows UI for editing synchronization profile.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh.
+  	    * @return None.
+        */
+		void EditProfileL(TInt aApplicationId);
+		
+        /**
+        * Shows UI for editing synchronization profile.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh.
+        * @param aProfileId.
+  	    * @return None.
+        */
+		void DoEditProfileL(TInt aAplicationId, TInt aProfileId, TInt aDialogMode);
+
+        /**
+        * Shows UI for editing synchronization profile.
+        * @param aApplicationId Calling application id from AiwGenericParam.hrh.
+        * @param aProfileId.
+  	    * @return None.
+        */
+		void DoEditReadOnlyProfileL(TInt aAplicationId, TInt aProfileId, 
+		                            TInt aDialogMode);
+
+    private:
+
+		/**
+        * Checks profile mandatory fields.
+        * @param aProfileId.
+    	* @return ETrue if mandatory fields are ok, EFalse otherwise.
+        */
+		TBool CheckMandatoryL(TInt aProfileId);
+		
+		/**
+        * Checks already selected profile for mandatory content and correct protocol version
+        * @param aProfileId 
+        * @param aLocalDatabase SyncML mail details name for Email app ,KNullDesC otherwise
+  	    * @return ETrue if task exists and correct protocol selected, EFalse otherwise.
+        */
+		
+		TBool CheckTaskAndProtocolL(TInt aProfileId ,const TDesC& aLocalDatabase);
+
+		/**
+        * Find out whether sync data provider exists.
+        * @param aApplicationId.
+    	* @return ETrue if provider exists, EFalse otherwise.
+        */
+		TBool DataProviderExist(TInt aApplicationId);
+		
+		/**
+        * Checks that app id is valid and data provider exists.
+        * @param aApplicationId.
+    	* @return None.
+        */
+		void CheckAppAndProviderL(TInt aApplicationId);
+		
+		/**
+        * Opens session with sync server.
+        * @param None.
+    	* @return None.
+        */
+		void OpenSyncSessionL();
+
+		/**
+        * Closes session with sync server.
+        * @param None.
+    	* @return None.
+        */
+		void CloseSyncSession();
+		
+		/**
+        * Creates contentlist.
+        * @param None.
+    	* @return None.
+        */
+		void CreateContentListL();
+		
+		/**
+        * Selects profile.
+        * @param aProfileId.
+        * @param aTaskId.
+    	* @param aResourceId.
+    	* @param aLocalDatabase
+    	* @param aCheckId 
+    	* @return None.
+        */
+        TBool SelectProfileL(TInt& aProfileId, TInt& aTaskId, 
+                             TInt aResourceId, const TDesC& aLocalDatabase,TBool aCheckId);
+
+    private:
+		// id of the calling application
+		TInt iApplicationId;
+
+   		// sync session
+		RSyncMLSession iSyncSession;
+		
+		// is sync session open
+		TBool iSyncSessionOpen;
+		
+		// performs sync operation, uses CNSmlAppEngine
+		CAspSyncHandler* iSyncHandler;
+
+		// sync data provider list
+		CAspContentList* iContentList;
+		
+		// settings dialog
+		CAspSettingDialog* iSettingDialog;
+		
+    	// is setting database in read only state
+		TBool iSettingEnforcement;
+		
+    	// resource handler
+		CAspResHandler* iResHandler;
+    };
+
+
+
+#endif  // ASPSYNCUTIL_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSyncUtil.rh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or 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: Resource header 
+*
+*/
+
+#ifndef _ASP_SYNCUTL_RH
+#define _ASP_SYNCUTL_RH
+
+
+
+ 
+
+enum TDialogControlIds
+    {
+    EAspSyncProgressNote = 1,
+    EAspProfileDialogList = 2,
+	EAspSettingDialogList = 3,
+    EAspConnectionDialogList = 4,
+    EAspAutoSyncDialogList = 5,
+    EAspProfileWizardDialogList = 6,
+    EAspProfileWizardDialogList2 = 7,
+    EAspAutoSyncProfileDialogList = 8,
+    EAspSettingViewDialogList = 9,
+    EAdvanceSettingsDialogList = 10
+
+    };
+
+
+enum TAspSettingListIcons
+	{
+	EAspHttpIcon,
+	EAspHttpIconMask,
+	EAspHttpOffIcon,
+	EAspHttpOffIconMask,
+	EAspBTIcon,
+	EAspBTIconMask,
+	EAspBTOffIcon,
+	EAspBTOffIconMask,
+	EAspUSBIcon,
+	EAspUSBIconMask,
+	EAspUSBOffIcon,
+	EAspUSBOffIconMask
+	};
+
+
+enum TAspDialogs
+	{
+	EAspProfileListDialog = 1,
+    EAspProfileDialog = 2,
+    EAspContentDialog = 3,
+	EAspSettingDialog = 4,
+    EAspConnectionDialog = 5,
+    EAspFilterDialog = 6
+	};
+
+enum TAspMenuCommands
+	{
+	EAspMenuCmdSync = 1,
+	EAspMenuCmdEdit = 2,
+	EAspMenuCmdNew = 3,
+	EAspMenuCmdNewApplication = 4,
+	EAspMenuCmdNewSet = 5,
+	EAspMenuCmdDelete = 6,
+    EAspMenuCmdViewLog = 7,
+	EAspMenuCmdHelp = 8,
+	EAspMenuCmdExit = 9,
+    EAspMenuCmdChange = 10,
+    EAspMenuCmdEnable = 11,
+    EAspMenuCmdDisable = 12,
+    EAspMenuCmdChangeProfile = 13,
+    EAspMenuCmdCopyFromServer = 14,
+    EAspMenuCmdAutoSync = 15,
+    EAspMenuCmdView = 16,
+    EAspMenuCmdSelect = 17,
+    EAspMenuCmdUnselect = 18,
+    EAspMenuCmdOpen = 19,
+    EAspMenuCmdMark = 20,
+    EAspMenuCmdUnmark = 21,
+    EAspMenuCmdAdvanceSettings = 22,
+    EAspMenuCmdRoamingSettings = 23,
+    EAspMenuCmdAlwaysAsk = 24,
+    EAspMenuCmdAlwaysAllow = 25,
+    EAspMenuCmdNeverAllow = 26
+
+
+	};
+
+
+enum
+	{
+	EAspSyncProviderCmdSynchronize = 1,
+    EAspSyncProviderCmdSettings
+	};
+
+
+enum
+	{
+	EAspMaxProfileNameLength = 50,
+        EAspMaxPasswordLength = 22
+	};
+
+
+
+#endif  // _ASP_SYNCUTL_RH
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspSyncUtilApi.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 functions that are exported from AspSyncUtil for
+*                performing data synchronization.
+*
+*/
+
+
+#ifndef ASPSYNCUTILAPI_H
+#define ASPSYNCUTILAPI_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <s32file.h>
+
+
+// FORWARD DECLARATIONS
+class CAspSyncUtil;
+
+
+
+// CLASS DECLARATION
+
+/**
+*  Public API for executing sync ui library functions. 
+* 
+*  @lib aspsyncutil.lib
+*  @since Series60_3.0
+*  
+*/
+class CSyncUtilApi : public CBase
+    {
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+	    IMPORT_C static CSyncUtilApi* NewL();
+
+	    /**
+        * Destructor.
+        */
+	    virtual ~CSyncUtilApi();
+
+    private:
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+	    CSyncUtilApi();
+
+    public:
+
+       /**
+        * Shows UI for editing data synchronization settings.
+        * @since Series60_3.0
+        * @param aAppId Calling application id from AiwGenericParam.hrh.
+        * @param aInfo1 Extra information, KErrNotFound if not used. 
+        * @param aInfo2 Extra information, KNullDesC if not used.
+	    * @return None.
+        */
+		IMPORT_C void ShowSettingsL(TInt aAppId, TInt aInfo1, TDes& aInfo2);
+
+
+        /**
+        * Performs data synchronization. Creates necessary UI.
+        * @since Series60_3.0
+        * @param aAppId Calling application id from AiwGenericParam.hrh. 
+        * @param aJobId Sync job id, KErrNotFound if not used. 
+        * @param aInfo1 Extra information, KErrNotFound if not used. 
+        * @param aInfo2 Extra information, KNullDesC if not used. 
+	    * @return None.
+        */
+        IMPORT_C  void SynchronizeL(TInt aAppId, TInt aJobId, TInt aInfo1, TDes& aInfo2);
+
+ 
+        /**
+        * Performs automatic (scheduled) data synchronization. Does not create 
+        * any UI.Gets synchronization data from central repository.
+        * @since Series60_3.0
+        * @param aScheduleTaskFile File that contains sync scheduling task. 
+	    * @return None.
+        */
+		IMPORT_C void SynchronizeL(RFile& aScheduleTaskFile);
+
+    private:
+		CAspSyncUtil* iSyncUtil;
+    };
+
+
+#endif  // ASPSYNCUTILAPI_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/AspUtil.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,688 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: General utilities 
+*
+*/
+
+
+
+#ifndef ASPUTIL_H
+#define ASPUTIL_H
+
+// INCLUDES
+#include <e32base.h>
+#include <ecom.h>
+#include <eikenv.h> 
+
+
+#include <ApSettingsHandlerUI.h>
+
+#include <SyncMLClient.h>    // for RSyncMLSession
+#include <SyncMLClientDS.h>  // for RSyncMLDataSyncProfile
+
+#include <csch_cli.h> // RScheduler
+
+
+#include "AspDefines.h"
+
+
+// CONSTANTS
+
+
+
+// FORWARD DECLARATIONS
+class CAspProfile;
+class CAspProfileList;
+class CAspContentList;
+class CAspTask;
+class CAspFilter;
+class CAspSchedule;
+
+// CLASS DECLARATION
+
+
+/**
+* TAspParam
+*
+* This class is used as general parameter type.
+*/
+NONSHARABLE_CLASS (TAspParam)
+	{
+    public:
+		// calling application id
+		TInt iApplicationId;
+
+		// profile id
+		TInt iProfileId;
+
+		// dialog mode
+		TInt iMode;
+
+		// general id number
+		TInt iId;
+
+		// return value to caller.
+		TInt iReturnValue;
+		
+		// data provider id
+		TInt  iDataProviderId;
+		
+		// sync task id
+		TInt  iSyncTaskId;
+		
+		// sync profile
+		CAspProfile* iProfile;
+		
+		// sync task
+		CAspTask* iSyncTask;
+		
+		// sync filter
+		CAspFilter* iSyncFilter;
+		
+		// session with sync server
+		RSyncMLSession* iSyncSession;
+		
+		// profile list
+		CAspProfileList* iProfileList;
+		
+		// content list
+		CAspContentList* iContentList;
+
+		//auto sync schedule setting
+		CAspSchedule* iSchedule;
+		
+
+    public:
+    	TAspParam(TInt aApplicationId);
+		TAspParam(TInt aApplicationId, RSyncMLSession* aSyncSession);
+	};
+
+
+
+
+
+/**
+* TAspUtil
+* 
+* This class contains general utility functions. 
+*/
+NONSHARABLE_CLASS (TUtil)
+	{
+    public:
+        static void Panic(TInt aReason);
+		static void StrCopy(TDes& aTarget, const TDesC& aSource);
+		static void StrCopy(TDes& aTarget, const TDesC8& aSource);
+		static void StrCopy(TDes8& aTarget, const TDesC& aSource);
+		static HBufC* StrConversion(const TDesC& aText);
+		
+		static void StrAppend(TDes& aTarget, const TDesC& aSource);
+		static void StrInsert(TDes& aTarget, const TDesC& aSource);
+		static void Fill(TDes& aTarget, const TDesC& aOneCharStr, TInt aLength);
+		static TInt StrToInt(const TDesC& aText, TInt& aNum);
+		static TInt AddResFileL(const TDesC& aFile);
+		static TBool IsEmpty(const TDesC& aText);
+		
+		static TInt ProviderIdFromAppId(TInt aApplicationId);
+		static TInt AppIdFromProviderId(TInt aAdapterId);
+		static TBool IsValidAppId(TInt aApplicationId);
+		static TBool IsValidSID(TInt aApplicationId);
+		
+		static void GetDateTextL(TDes& aText, TTime aDateTime);
+		static void GetTimeTextL(TDes& aText, TTime aDateTime);
+		static HBufC* SyncTimeLC(TTime aLastSync);
+		static void GetDateTimeTextL(TDes& aText, TTime aDateTime);
+		static TBool IsToday(TTime aTime);
+		static TTime ConvertUniversalToHomeTime(const TTime& aUniversalTime);
+		static void LaunchHelpAppL();
+		static void LaunchHelpAppL(CEikonEnv* aEikonkEnv);
+		static TBool SettingEnforcementStateL();
+		static TBool SettingEnforcementState();
+		static CDesCArray* NumberConversionLC(CDesCArray* aList);
+		
+		
+
+
+#ifdef _DEBUG		
+    public:		
+		static void GetMandatoryFieldText(TDes& aText, TInt aStatus);
+		static void Print(const TDesC& aText);
+		static void Print(const TDesC& aText, TInt aNum);
+		
+		static TTime TimeBefore();
+		static TInt TimeAfter(TTime aBefore);
+		static void TimeAfter(TTime aBefore, const TDesC& aText);
+		static void GetApplicationName(TDes& aText, TInt aApplicationId);
+#endif		
+	};
+
+
+
+/**
+*  TStr contains descriptor operations with range checking.
+*/
+NONSHARABLE_CLASS (TStr)
+    {
+    public:
+        TStr(const TDesC& aStr);
+       
+    public:
+        TPtrC Mid(TInt aPos, TInt aLen);
+        TPtrC Mid(TInt aPos);
+        TPtrC Left(TInt aPos);
+        TPtrC Right(TInt aPos);
+        TPtrC Trim();
+        TPtrC SubStr(TInt aStartPos, TInt aEndPos);
+        TPtrC SubStrEx(TInt aStartPos, TInt aEndPos);
+        TInt LastPos();
+        TInt Len();
+        TBool Compare(TInt aPos, TChar aChar);
+        TInt Find(TInt aPos, TChar aChar);
+        
+    public:	
+        TInt FirstNonSpace();
+        TInt LastNonSpace();
+        
+    private:
+        // reference to descriptor
+		const TDesC& iStr;
+    };
+
+
+/**
+*  TURIParser is used for parsing URI.
+*/
+NONSHARABLE_CLASS (TURIParser)
+    {
+    public:
+    enum TDefaultPortNumber
+	    {
+	    EDefaultHttpPort = 80,
+        EDefaultHttpsPort = 443
+    	};
+
+    enum TPortNumberRange
+	    {
+        EMinURIPortNumber = 1,
+        EMaxURIPortNumber = 65535
+    	};
+
+    public:
+        TURIParser(const TDesC& aStr);
+       
+    public:
+        void GetUriWithoutPort(TDes& aText);
+        void GetUriWithPort(TDes& aText, const TInt aPort);
+        TInt Port();
+        TInt DefaultPort();
+        static TBool IsValidUri(const TDesC& aText);
+        static TBool IsValidBluetoothHostAddress(const TDesC& aText);
+        static TBool IsValidPort(const TInt aPort);
+        
+    private:
+        TPtrC ParseHttp();
+        TPtrC ParseAddress();
+        TPtrC ParseDocument();
+        TInt ParsePort(TInt& aPortNumber);
+        TPtrC ParsePort();
+        
+     private:
+        void GetHttpPos(TInt& aStartPos, TInt& aEndPos);
+        void SkipHttp();
+  
+    private:
+        // reference to original URI text
+		const TDesC& iOriginalStr;
+		
+		// pointer to original URI text
+		TPtrC iPtr;
+		
+    };
+
+
+/**
+*  TFlag contains integer flag operations.
+*/
+class TFlag
+    {
+    public:
+        /**
+        * C++ default constructor.
+        */
+        TFlag(TUint32& aFlag);
+    public:
+        /**
+        * Turns given bit(s) on.
+        * @since 2.5
+        * @param aValue Bits to be turned on.
+        * @return None.
+        */
+        void SetOn(const TUint32 aValue);
+
+        /**
+        * Turns given bit(s) off.
+        * @since 2.5
+        * @param aValue Bits to be turned off.
+        * @return None.
+        */
+        void SetOff(const TUint32 aValue);
+
+        /**
+        * Checks if given bit(s) is/are set.
+        * @since 2.5
+        * @param aValue Bitmap to be checked.
+        * @return None.
+        */
+        TBool IsOn(const TUint32 aValue) const;
+        
+    private:
+		// reference to flag (integer)
+        TUint32& iFlag;
+    };
+
+
+/**
+* CAspIdleWait
+* 
+* This class is used for waiting synchronously until
+* active scheduler has completed all pending events.
+*/
+NONSHARABLE_CLASS (CAspIdleWait) : public CBase
+	{
+    public:
+        /**
+        * Two-phased constructor.
+        */
+		static CAspIdleWait* NewL();
+
+        /**
+        * Destructor.
+        */
+		virtual ~CAspIdleWait();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+		CAspIdleWait();
+
+	public:
+		/**
+		* Waits until active schedure has nothing to do.
+		* @param  None.
+		* @return None.
+		*/
+		static void CAspIdleWait::WaitL();
+		
+    private:
+        static TInt IdleCallback(TAny* aThisPtr);        
+
+	private:
+		CActiveSchedulerWait iWait;
+	};
+
+
+
+
+/**
+* MAspActiveCallerObserver
+*
+* MAspActiveCallerObserver is for observing CAspActiveCaller.
+*/
+class MAspActiveCallerObserver
+    {
+    public:
+	    virtual void HandleActiveCallL(TInt aCallId) = 0;
+    };
+
+
+/**
+* CAspActiveCaller
+*
+* CAspActiveCaller is used for generating a call from active scheduler.
+*/
+NONSHARABLE_CLASS (CAspActiveCaller) : public CActive
+    {
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspActiveCaller* NewL(MAspActiveCallerObserver* aObserver);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspActiveCaller();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspActiveCaller(MAspActiveCallerObserver* aObserver);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	public:
+        /**
+        * Calls observer using active object framework.
+        * @param aCallId.
+		* @param aMilliseconds Delay before observer is called.
+        * @return None
+        */
+		void Start(TInt aCallId, TInt aMilliseconds);
+
+        /**
+        * Make active scheduler call RunL.
+        * @param None
+        * @return None
+        */
+		void Request();
+
+    private:
+        /**
+        * From CActive. Called when asynchronous request completes.
+        * @param None
+        * @return None
+        */
+	    void RunL();
+
+        /**
+        * From CActive. Cancels asynchronous request.
+        * @param None
+        * @return None
+        */
+	    void DoCancel();
+        
+    private:
+		// call that is passed to observer
+		TInt iCallId;
+
+		// timer
+		RTimer iTimer;
+
+		// observer that gets called
+		MAspActiveCallerObserver* iObserver;
+    };
+
+
+
+
+
+/**
+* TAspBearerItem 
+*
+*/
+NONSHARABLE_CLASS (TAspBearerItem)
+	{
+	public:
+		TInt iBearerType;
+    	TBuf<KBufSize> iBearerName;
+	};
+
+
+
+/**
+* CAspBearerHandler 
+*
+* CAspBearerHandler is for constructing list control for selecting
+* bearer type (internet, bluetooth etc.)
+*/
+NONSHARABLE_CLASS (CAspBearerHandler) : public CBase
+    {
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspBearerHandler* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspBearerHandler();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspBearerHandler(const TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+	public:
+	    /**
+        * Finds out whether bearer type is supported.
+		* @param aBearer Bearer type.
+        * @return ETrue if supported, EFalse otherwise.
+        */
+		TBool IsSupported(TInt aBearer);
+
+	    /**
+        * Finds out bearer type for list item.
+		* @param aIndex List index.
+        * @return Bearer type.
+        */
+		TInt BearerForListIndex(TInt aIndex);
+
+		/**
+        * Finds out list position for aBearer.
+		* @param aBearer.
+        * @return List array index.
+        */
+		TInt ListIndexForBearer(TInt aBearer);
+
+		/**
+        * Creates supported bearer list.
+		* @param None.
+        * @return None.
+        */
+		void CreateSupportedBearerListL();
+
+	    /**
+        * Finds out default bearer for a device.
+		* @param None.
+        * @return Bearer type.
+        */
+		TInt DefaultBearer();
+
+	    /**
+        * Gets bearer name string.
+		* @param aText.
+		* @param aBearer.
+        * @return None.
+        */
+		void GetBearerName(TDes& aText, TInt aBearerType);
+
+	    /**
+        * Builds array of bearer names for ui list control.
+		* @param None.
+        * @return Bearer name array.
+        */
+		CDesCArray* BuildBearerListLC();
+
+	    /**
+        * Finds out how many bearer types are supported.
+		* @param None.
+        * @return Bearer count.
+        */
+		TInt SupportedBearerCount();
+		
+	    /**
+        * Convert asp bearer id to sml beareer id.
+		* @param aId.
+        * @return Bearer id.
+        */
+		static TInt SmlBearerId(const TInt aId);
+
+	    /**
+        * Convert sml bearer id to asp beareer id.
+		* @param aId.
+        * @return Bearer id.
+        */
+		static TInt AspBearerId(const TInt aId);
+
+    private:
+   		// sync session
+		RSyncMLSession* iSyncSession;
+
+		// list of bearers that can shown in ui list
+		RArray<TAspBearerItem> iList;
+    };
+
+
+/**
+* TAspAccessPointItem 
+*
+*/
+NONSHARABLE_CLASS (TAspAccessPointItem)
+	{
+	public:
+		TInt  iUid;
+    	TBuf<KBufSize> iName;
+    	
+    	TInt  iUid2;
+	};
+
+
+
+/**
+* CAspAccessPointHandler 
+*
+* CAspAccessPointHandler is for setting internet access points.
+*/
+NONSHARABLE_CLASS (CAspAccessPointHandler) : public CBase
+    {
+    public:
+	enum TExitMode
+		{
+	    EAspDialogSelect,
+	    EAspDialogCancel,
+	    EAspDialogExit
+		};
+		
+	// when ap is set to -1, ap is always asked before sync
+    static const TInt KAskAlways = -1;
+
+	static const TInt KDefaultConnection = -2;
+    
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CAspAccessPointHandler* NewL(const TAspParam& aParam);
+
+	    /**
+        * Destructor.
+        */
+        virtual ~CAspAccessPointHandler();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CAspAccessPointHandler(const TAspParam& aParam);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+    public:
+	    /**
+        * Displays dialog for selecting one access point.
+		* @param aItem.
+        * @return ETrue if user selected access point, EFalse otherwise.
+        */
+        TInt ShowApSelectDialogL(TAspAccessPointItem& aItem);
+        
+	    /**
+        * Gets access point info.
+		* @param aItem.
+        * @return Error value.
+        */
+		TInt GetInternetApInfo(TAspAccessPointItem& aItem);
+
+	private:
+	    /**
+        * Gets access point info.
+		* @param aItem.
+        * @return Error value.
+        */
+		TInt GetApInfo(TAspAccessPointItem& aItem);
+
+	    /**
+        * Gets access point info.
+		* @param aItem.
+        * @return Error value.
+        */
+		TInt GetApInfoL(TAspAccessPointItem& aItem);
+
+        /**
+        * Utility function.
+		* @param None.
+        * @return Bearer flags.
+        */
+		TInt BearerFlags();
+
+
+    private:
+    
+   		// communications database
+		CCommsDatabase* iCommDb;
+
+    	//access point utilities
+    	CApUtils* iApUtil;
+    	
+    	// access point selection utility
+    	CApSelect* iApSelect;
+    	
+    	// dialog parameters
+    	TAspParam* iParam;
+    	
+    };
+
+
+
+/**
+* TAspSyncError 
+*
+* TAspSyncError is used for error code handling.
+*/
+NONSHARABLE_CLASS (TAspSyncError)
+    {
+    
+    public:
+        static HBufC* GetSmlErrorTextL(TInt aErrorCode, TInt aTransport);
+        static HBufC* GetSmlErrorText(TInt aErrorCode, TInt aTransport);
+      	static TInt GetSmlErrorValue(TInt aErrorCode);
+        
+#ifdef _DEBUG        
+    public:
+        static void GetSyncMLErrorText(TDes& aText, TInt aError);
+#endif
+     
+    };
+
+
+
+
+#endif  // ASPUTIL_H
+
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/inc/xxxxAspDebug.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Debug constants definition 
+*
+*/
+
+
+
+#ifndef NSMLDSSYNC__DEBUG_H
+#define NSMLDSSYNC__DEBUG_H
+
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"smlsync.txt");
+_LIT(KLogDirFullName,"c:\\logs\\");
+_LIT(KLogDir,"smlsync");
+
+// Declare the FPrint function
+inline void FPrint(TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, TPtrC(aFmt), list);
+    }
+
+
+//#ifdef __WINS__     // File logging for WINS
+
+//#ifndef __GNUC__          
+//    #define FLOG            RDebug::Print
+//#else   // __GNUC__       
+//    #define FLOG(arg...)    RDebug::Print(arg);
+//#endif // __GNUC__        
+
+
+#ifndef __GNUC__          
+    #define FLOG            FPrint
+#else   // __GNUC__       
+    #define FLOG(arg...)    FPrint(arg);
+#endif // __GNUC__        
+
+//#define FLOG   FPrint
+//#define FLOG(a)   { FPrint(a); }
+//#define FMTLOG(arg...)   { FPrint(arg); }
+//#define FMTLOG(arg...)    RDebug::Print(arg);
+
+//#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+
+//#else               // RDebug logging for target HW
+
+//#define FLOG(a) { RDebug::Print(a);  }
+//#define FTRACE(a) { a; }
+
+//#endif //__WINS__
+
+
+#else // No loggings --> Reduced binary size
+
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // NSMLDSSYNC__DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/loc/NSmlDSSync.loc	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2022 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  Localisation file for OmaDSAppUi/AspSyncUtil
+*
+*/
+
+
+
+
+// -----------------------------------------------------------------------------
+// main view strings
+// -----------------------------------------------------------------------------
+
+//d:Title of the application on the title pane
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_apps_syncml_title		"Sync"
+
+//d:Title of the application on the application shell list
+//d: used in app shell
+//l:list_single_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_apps_sml_list			"Sync"
+
+//d:Title of the application on the application shell grid
+//d: used in app shell
+//l:cell_app_pane_t1
+//r:3.0
+//
+#define qtn_apps_sml_grid	"Sync"
+
+//d:Navipane texts on the mainview
+//d:Profile has not been synchronised
+//l:navi_navi_text_pane_t1
+//r:3.0
+//
+#define qtn_sml_main_sync_no_last	"Not synchronised"
+
+//d:Text for empty profile
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_apps_emptyprofile	"<unnamed set>"
+
+//d:Command in options list.
+//d:Selects the content
+//l:list_single_pane_t1_cp2
+//r:5.0
+//
+#define qtn_sml_cmd_mark		"Mark"
+
+//d:Command in options list.
+//d:Unselects the content
+//l:list_single_pane_t1_cp2
+//r:5.0
+//
+#define qtn_sml_cmd_unmark		"Unmark"
+
+
+//d:Command in options list to open advanced setting
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_advanced_settings		"Advanced settings"
+
+//d:Roaming setting item (radio button list) 
+//l:list_setting_pane_t1
+//r:3.2
+//
+#define qtn_ds_set_roaming		"Roaming settings"
+
+//d:Used in qtn_ds_set_roaming
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_always_ask		"Always ask"
+
+//d:Used in qtn_ds_set_roaming
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_always_allow		"Always allow"
+
+//d:Used in qtn_ds_set_roaming
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_never_allow		"Never allow"
+
+//d:Command in options list.
+//d:Starts the syncronisation
+//l:list_single_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_cmd_sync		"Synchronise"
+
+//d:Command in options list.
+//d:Opens dialog for creating new sync set.
+//l:list_single_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_cmd_create_new "Create new"
+
+//d:Command in options list.
+//d:Opens settings view with existing profile values
+//l:list_single_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_cmd_edit		"Edit"
+
+//d:Command in options list.
+//d:Deletes currently selected profile
+//l:list_single_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_cmd_delete		"Delete"
+
+//d:Command in options list.
+//d:Opens the profile's last synchronisation log for viewing
+//l:list_single_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_cmd_view_log	"View log"
+
+//d:Command in options list.
+//d:Deletes phone data and then copies all sync data from server to phone
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_slow_sync	"Copy all from server"
+
+//d:Command in options list.
+//d:Opens selection list for changing active profile.
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_change_profile "Change"
+
+//d:Command in options list.
+//d:Opens automatic sync dialog.
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_automatic_sync "Automatic sync"
+
+//d:this message is shown when user tries to start sync using profile that misses 
+//d:some mandatory data.
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_query_mandatory_missing "Some compulsory settings are not defined and synchronisation cannot be started. Define now?"
+
+//d:this message is shown when user tries to start sync and there are no sync profiles. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_query_no_profiles "No sync profiles defined. Define now?"
+
+//d:Title for dialog that shows profile selection list for deleting one profile.
+//l:heading_pane_t1
+//r:3.2
+//
+#define qtn_sml_query_title_delete_profile "Delete profile"
+
+//d:Title for dialog that shows profile selection list for changing active profile.
+//l:heading_pane_t1
+//r:3.2
+//
+#define qtn_sml_query_title_change_profile "Change profile"
+
+//d:Error confirmation dialog
+//d:Shown when user starts synchronization and profile has no contents selected
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_err_nocontent "Profile has no content selected"
+
+//d:This yes/no question is shown to verify command qtn_sml_cmd_slow_sync.
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_query_slow_sync_conf "This operation replaces all phone data with data from the server. Do you want to continue?"
+
+//d:Dialog title. Dialog is used for selecting set (from selection list) for syncing. 
+//l:heading_pane_t1
+//r:3.0
+//
+#define qtn_sml_apps_select_set "Select set for sync:"
+
+//d:This note is shown when user tries to modify read-only profile.
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_main_locked "This sync profile is read-only and cannot be edited."
+
+//d:popup note text that is shown when user changes currently open profile
+//l:popup_preview_text_window/opt6
+//r:3.2
+//
+#define qtn_sml_main_info "profile: %0U, connection method: %1U"
+
+
+
+// -----------------------------------------------------------------------------
+// sync strings needed in other applications
+// -----------------------------------------------------------------------------
+
+
+//d:Menu command in other application's options menu (not Sync app).
+//d:Opens submenu that contains items qtn_ds_options_sync_settings and qtn_sml_cmd_start.
+//l:list_single_pane_t1_cp2/opt3
+//r:3.0
+//
+#define qtn_ds_options_sync "Synchronization"
+
+
+//d:Command in other application (not Sync app) Synchronization sub menu.
+//d:Opens dialog for editing sync settings.
+//l:list_single_popup_submenu_pane_t1
+//r:3.0
+//
+#define qtn_ds_options_sync_settings "Settings"
+
+
+//d:Command in other application (not Sync app) Synchronization sub menu.
+//d:Starts synchronization.
+//l:list_single_popup_submenu_pane_t1
+//r:3.0
+//
+#define qtn_ds_options_sync_start "Start"
+
+//d:Command in other application(not sync app) Default dialog list item for qtn_ds_options_sync_settings
+//d:Starts the Profile wizard
+//l:list_single_pane_t1_cp2/opt1
+//r:5.0
+#define qtn_sml_apps_select_profile_create_new "Create new profile"
+
+//d:this message is shown when user tries to start sync using profile that misses 
+//d:some mandatory data.
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_tarm_mandatory_missing "Unable to synchronise. Profile is locked and mandatory settings are missing."
+
+
+
+
+// -----------------------------------------------------------------------------
+// setting view strings
+// -----------------------------------------------------------------------------
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state 
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_list_profile	"Sync set name"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state 
+//l:list_setting_pane_t1/opt1 
+//r:3.0
+//
+#define qtn_sml_set_list_server_id "Server Id"
+
+//d:Title of settings item
+ //l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_bearertype "Bearer type"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_list_access		"Access point"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1 
+//r:3.0
+//
+#define qtn_sml_set_list_host		"Host address"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_list_port		"Port"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_list_username	"User name"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_set_list_password	"Password"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state 
+//l:list_setting_pane_t1
+//r:3.0
+//
+#define qtn_ds_set_lbl_active "Allow sync request"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1 
+//r:3.0
+//
+#define qtn_sml_set_list_https_username	"Https user name"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+ //l:list_setting_pane_t1/opt1 
+//r:3.0
+//
+#define qtn_sml_set_list_https_password	"Https password"
+
+//d:Application dialog setting item for selecting sync type (eg. One-way into device)
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_sync_type "Sync type"
+
+//d:Value used in qtn_ds_set_lbl_active
+//d:Auto-accept means that server alerts are automatically accepted
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_set_sync_req_auto "Auto-accept"
+
+//d:Value used in qtn_ds_set_lbl_active
+//d:Ask first means server alerts are always confirmed
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_set_sync_req_ask_always "Ask first"
+
+//d:Value used in qtn_ds_set_lbl_active
+//d:Not allowed means server alerts are never accepted
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_set_sync_req_never "Not allowed"
+
+//d:This yes/no question is shown when user has given profile server id that already exists.
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_query_serverid_exists "There is already a profile created for this server. Exit anyway ?"
+
+//d:Value used in qtn_sml_sync_type list.
+//d:Normal sync. Sync items (eg. contatcs) are send from phone to sync server
+//d: and from sync server to phone.
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_sml_sync_type_normal "Normal"
+
+//d:Value used in qtn_sml_sync_type list
+//d:Sync items (eg. contatcs) are send from phone to sync server.
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_sml_sync_type_one_way_dev_to_srv "One-way from device"
+
+//d:Value used in qtn_sml_sync_type list
+//d:Sync items (eg. contatcs) are send from sync server to phone.
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_sml_sync_type_one_way_srv_to_dev "One-way into device"
+
+//d:NOTE: This is defined in "s60\ConnectionUiUtilities\inc\ConnectionUiUtilities.loc"
+//d:(qtn_netw_sett_iap_pref_prompt)
+//d:This string is used as connection dialog access point (qtn_sml_set_list_access)
+//d:setting value when user has selected "Always ask" option in access point selection dialog.
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_ds_sett_always_ask		"Always ask"
+
+//d:this message is shown when user tries to start sync when sync is already running. 
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_ds_note_hidden_ongoing "Unable to start synchronisation. Other sync process already ongoing."
+
+//d:Text on the information note that is shown when user tries to edit setting that is 
+//d:read-only. 
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_ds_note_read_only "This is read-only setting and cannot be edited"
+
+//d:This yes/no question is shown if user has not filled mandatory field(s) in a dialog.
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_ds_conf_mandatory_missing "Some settings are compulsory and must be defined. Exit anyway?"
+
+//d:One of the setting items in settings view
+//d:Used also as a title in editing state
+//l:list_setting_pane_t1/opt1 
+//r:3.0
+#define qtn_sml_set_list_protocol_version "SyncML version"
+
+//d:Value used in setting view's protocol version list
+//l:list_set_graphic_pane_t1
+//r:3.0
+#define qtn_sml_syncml_1_1 "SyncML 1.1"
+
+//d:Value used in setting view's protocol version list
+//l:list_set_graphic_pane_t1
+//r:3.0
+#define qtn_sml_syncml_1_2 "SyncML 1.2"
+
+//d:Text on the information note that is shown when user changes sync protocol 
+//d:from 1.2 to 1.1. and sync set includes email application.
+//d:This is needed because SyncML version 1.1 does not support email sync.
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_sml_info_proc_change "You cannot synchronise email with SyncML version 1.1"
+
+
+
+// -----------------------------------------------------------------------------
+// setting wizard strings
+// -----------------------------------------------------------------------------
+
+
+//d:Setting item (profile name) title.
+//l:list_setting_pane_t1
+//r:3.2
+//
+#define qtn_sml_set_list_destination_name	"Destinations's name"
+
+//d:Setting item (profile name) title. (new)
+//l:list_setting_pane_t1
+//r:3.2
+//
+#define qtn_sml_set_list_content_selection	"Sync contents"
+
+//d:This Start/Cancel note is shown when user starts profile wizard.
+//l:popup_info_list_pane_t1
+//r:3.2
+//
+#define qtn_ds_conf_profile_wizard_start "This wizard will guide you to create the basic settings for a new synchronisation profile."
+
+//d:Profile wizard's last page text when wizard is launched from sync app (cba Activate/Later).
+//l:popup_info_list_pane_t1
+//r:3.2
+//
+#define qtn_ds_conf_profile_wizard_end "New profile settings saved. For details, see Options and Edit. Activate new profile now?"
+
+//d:Profile wizard's last page text when wizard is launched from other application (cba Ok).
+//l:popup_info_list_pane_t1
+//r:3.2
+//
+#define qtn_ds_conf_profile_wizard_end_app "New profile settings saved. Select Options/Synchronisation/Start to synchronise."
+
+//d:Profile wizard's last page text when wizard is launched from other application (cba Ok).
+//l:popup_info_list_pane_t1
+//r:3.2
+//
+#define qtn_ds_conf_profile_wizard_end_email "New profile settings saved. Start synchronisation from options menu."
+
+//d:Setting item (profile name) title.
+//l:navi_text_pane_t1
+//r:3.2
+//
+#define qtn_sml_wizard_page_counter "Page %0N/%1N"
+
+//d:this message is shown in profile wizard when user does not enter profile name and 
+//d:presses "Next" in profile name editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_profile_name_missing "Profile name must be defined."
+
+//d:this message is shown in profile wizard when user does not enter host address and 
+//d:presses "Next" in host address editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_host_address_missing "Host address must be defined."
+
+//d:this message is shown in profile wizard when user enters incorrect host address. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_incorrect_host_address "Incorrect host address."
+
+//d:this message is shown in profile wizard when user does not enter remote 
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_remote_database_missing "Remote database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter MMS
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_mms_db_missing "MMS database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter SMS
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_sms_db_missing "SMS database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter Bookmark
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_bkm_db_missing "Bookmark database must be defined."
+//d:this message is shown in profile wizard when user does not enter remote Contacts 
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_contacts_db_missing "Contacts database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter remote Calendar
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_calendar_db_missing "Calendar database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter remote Notes
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_notes_db_missing  "Notes database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter remote Email
+//d:database and presses "Next" in remote database editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_email_db_missing  "Email database must be defined."
+
+//d:this message is shown in profile wizard when user does not enter user 
+//d:name and presses "Next" in user name editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_username_missing "User name must be defined."
+
+//d:this message is shown in profile wizard when user does not enter password 
+//d:and presses "Next" in password editor. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_password_missing "Password must be defined."
+
+//d:this message is shown in profile wizard when user enters server id that 
+//d:is already used by another profile. 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_incorrect_server_id "There is already a profile created for this server."
+
+//d:Profile wizard editor title. Editor is for Contact remote database name.
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_remote_database_cnt "Contacts database"
+
+//d:Profile wizard editor title. Editor is for Calendar remote database name.
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_remote_database_agn "Calendar database"
+
+//d:Profile wizard editor title. Editor is for Notes remote database name.
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_remote_database_npd "Notes database"
+
+//d:Profile wizard editor title. Editor is for SyncML EMail remote database name.
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_remote_database_eml "SyncML EMail database"
+
+//d:Profile wizard editor title. Editor is for SyncML EMail remote database name.
+ //l:list_setting_pane_t1/opt1 
+//r:3.2
+//
+#define qtn_sml_local_database_eml "SyncML EMail mailbox"
+
+//d:Profile wizard editor title. Editor is for SyncML Sms remote database name.
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_remote_database_sms "SyncML Sms database"
+
+//d:Profile wizard editor title. Editor is for Multimedia messages remote database name.
+//l:list_setting_pane_t1/opt1
+//r:5.0
+//
+#define qtn_sml_remote_database_mms "MMS database"
+
+//d:Profile wizard editor title. Editor is for Bookmarks remote database name.
+//l:list_setting_pane_t1/opt1
+//r:5.0
+//
+#define qtn_sml_remote_database_bkm "Bookmarks database"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_profile_name "Key in the name for the new sync profile"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_protocol_version "Select the right SyncML version for the sync server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_content_selection "Select the contents you want to synchronise with this profile"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_contacts_db "Key in the name of the Contacts database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_calendar_db "Key in the name of the Calendar database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_notes_db "Key in the name of the Notes database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_email_db "Key in the name of the DS Email database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_mailbox "Select the mailbox you want to synchronise"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_sms_db "Key in the name of the DS Sms database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l: popup_preview_text_window/opt3
+//r:5.0
+//
+#define qtn_ds_wizard_popup_mms_db "Type in the MMS database name"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l: popup_preview_text_window/opt3
+//r:5.0
+//
+#define qtn_ds_wizard_popup_bkm_db "Type in the Bookmarks database name"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_remote_db "Key in the name of the remote database on the server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_connection_type "Select the connection type you want to synchronise by"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_host_address "Key in the host address for the used sync server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_server_id "Key in the ID of the sync server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_username "Key in the user name for the used sync server"
+
+//d:Synchronisation settings wizard info popup note text. 
+//l:popup_preview_text_window/opt3
+//r:3.2
+//
+#define qtn_ds_wizard_popup_password "Key in the password for the used sync server"
+
+
+//d:General error text indicating that profile wizard could not create new profile
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_log_err_profile_wizard "Profile creation failed"
+
+//d:Default title of the new profile 
+//l:list_single_large_graphic_pane_t1_cp2
+//r3.2
+//
+#define qtn_apps_newprofile		"New set (%N)"
+
+//d:Default title of the new set created in Phonebook application 
+//l:list_single_large_graphic_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_apps_content_pb "Phonebook sync (%N)"
+
+
+//d:Default title of the new set created in Calendar application 
+//l:list_single_large_graphic_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_apps_content_cal "Calendar sync (%N)"
+
+
+//d:Default title of the new set created in Email application 
+//l:list_single_large_graphic_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_apps_content_syncml "SyncmlEmail sync (%N)"
+
+
+//d:Default title of the new set created in Note application 
+//l:list_single_large_graphic_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_apps_content_notes "Note sync (%N)"
+
+//cba button text.
+//d:Starts profile wizard
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_start "Start"
+
+//cba button text.
+//d:Cancels starting profile wizard
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_cancel "Cancel"
+
+//cba button text.
+//d:Moves to next setting editor in profile wizard
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_next "Next"
+
+//cba button text.
+//d:Moves to previous setting editor in profile wizard
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_back "Back"
+
+//cba button text.
+//d:Activates just created (in profile wizard) profile
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_activate "Activate"
+
+//cba button text.
+//d:Does not activate just created (in profile wizard) profile
+//l:control_pane_t1/opt7
+//r:3.2
+//
+#define qtn_sml_cba_later "Later"
+
+// -----------------------------------------------------------------------------
+// automatic sync setting strings
+// -----------------------------------------------------------------------------
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting profile that is used in auto sync (radio button list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_profile "Automatic sync profile"
+
+//d:Default value for qtn_sml_sett_auto_sync_profile
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_value_not_defined "Not defined"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting contents to be synchronized (multi selection list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_contents "Automatic sync contents"
+
+//d:Used in qtn_sml_sett_auto_sync_contents
+//d:Setting value when user has selected all contents
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_value_all_contents "All"
+
+//d:Used in qtn_sml_sett_auto_sync_contents
+//d:Setting value when user has selected more than one but not all contents
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_value_selected_contents "Selected Contents"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting sync interval (radio button list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_freq "Sync frequency"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_freq_value_manual "Manual"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_freq_many_a_day "Many times per day"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_24_hours "Once a day"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_2_days "Every 2 days"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_4_days "Every 4 days"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_7_days "Once a week"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_14_days "Every 2 weeks"
+
+//d:Used in qtn_sml_sett_auto_sync_freq
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_30_days "Once a month"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting peak sync interval (radio button list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_peak_schedule "Peak sync interval"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_manual "Manual"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_15_mins "Every 15 minutes"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_30_mins "Every 30 minutes"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_1_hour "Every 1 hour"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_2_hours "Every 2 hours"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_4_hours "Every 4 hours"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_8_hours "Every 8 hours"
+
+//d:Used in qtn_sml_sett_auto_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_12_hours "Every 12 hours"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting off-peak sync interval (radio button list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_offpeak_schedule "Off-peak sync interval"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_manual "Manual"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_15_mins "Every 15 minutes"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_30_mins "Every 30 minutes"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_1_hour "Every 1 hour"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_2_hours "Every 2 hours"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_4_hours "Every 4 hours"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_8_hours "Every 8 hours"
+
+//d:Used in qtn_sml_sett_auto_off_peak_schedule
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_value_off_12_hours "Every 12 hours"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting sync days (multi selection list) 
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_days "Peak days"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//d:Setting value when user has selected all days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_all_days "All days"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//d:Setting value when user has selected more than one but not all days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_sel_days "Selected days"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_mon "Monday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_tue "Tuesday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_wed "Wednesday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_thu "Thursday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_fri "Friday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_sat "Saturday"
+
+//d:Used in qtn_sml_sett_auto_sync_days
+//l:list_set_graphic_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_sun "Sunday"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting sync time when sync interval is >= 1 day
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_time "Synchronisation time"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting peak start time
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_peak_start "Peak start time"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting peak end time
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_sett_auto_peak_end "Peak end time"
+
+//d:Title of the automatic profile setting dialog
+//l:title_pane_t2/opt9
+//r:5.0
+//
+#define qtn_sml_title_profile_settings "Profile settings"
+
+//d:Title of the automatic sync setting dialog
+//l:title_pane_t2/opt9
+//r:5.0
+//
+#define qtn_sml_title_automatic_sync_settings "Scheduling settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_setting_folder_profile "Profile settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1
+//r:5.0
+//
+#define qtn_sml_setting_folder_schedule "Scheduling settings"
+
+//d:this message is shown when user tries to delete a profile that is selected for auto sync
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_ds_conf_query_delete_auto_sync_profile "Deleting this profile will end automatic synchronisation. Continue?"
+
+//d:this message is shown when user tries to edit profile settings for a profile that is selected for auto sync
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_sml_note_modify_auto_sync_settings "Modifying this setting may prevent automatic synchronisation with this profile"
+
+//d:this message is shown when user tries to edit scheduling settings from a profile
+//d:and auto sync is set for another profile
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_sml_query_auto_sync_on "Scheduled sync is currently set for another profile. Cancel schedule and define settings for this profile?"
+
+//d:this message is shown when user tries to select a profile that has access point in "ask always" 
+//d;state for auto sync ,or when user edits access point for a profile that is selected for auto sync
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_sml_query_iap_no_ask_always "Automatic synchronisation will not be possible without selecting an access point for profile. Select now?"
+
+//d:this message is shown when sync application is launched ,if auto sync is enabled 
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_sml_main_note_auto_on "Next sync:   %0U ,profile:   %1U"
+
+//d:this message is shown while closing auto sync setting dialog
+//l:popup_note_window/opt2
+//r:5.0
+//
+#define qtn_sml_sett_auto_sync_done "Automatic sync is now on. Next sync will happen at %U."
+
+//d:this message is shown when user tries to save auto sync setting ,without defining
+//d:content setting
+//l:popup_note_window
+//r:5.0
+//
+#define qtn_sml_note_auto_contents_missing_settings "Some compulsory settings missing for selected contents. Define now?"
+
+//d:this message is shown as a link to log view in the auto sync error note.
+//l:popup_info_list_pane_t1
+//r:5.0
+//
+#define qtn_sml_main_auto_error_log_link "View details"
+
+//d:this message is shown when auto sync profile is set active profile
+//d:and there has been error in automatic sync. 
+//l:popup_info_list_pane_t1
+//r:3.2
+//
+#define qtn_sml_main_info_error "An error has occurred in automatic synchronization. Please check sync log for more details."
+
+//d:this message is shown when auto sync setting page is tried to save with an invalid peak time definition 
+//l:popup_note_window/opt2
+//r:5.0
+//
+#define qtn_sml_incorrect_peak_time "Incorrect peak time definition"
+
+//d:this message is shown during application launch, if auto sync has been failed for a profile because of on going manual sync
+//d:for another profile 
+//l:popup_note_window/opt2
+//r:5.0
+//
+#define qtn_sml_manual_sync_override "Auto sync cancelled. Manual sync in progress"
+
+//d:One of the setting items in automatic sync settings dialog
+//d:Setting for selecting whether user wants to synchronize while roaming
+//d:(phone is not within home network) 
+//l:list_setting_pane_t1
+//r:3.2
+//
+#define qtn_sml_sett_auto_sync_roaming "Sync while roaming"
+
+//d:Used in qtn_sml_sett_auto_sync_interval
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_sett_auto_sync_roaming_on "Yes"
+
+//d:Used in qtn_sml_sett_auto_sync_interval
+//l:list_set_graphic_pane_t1
+//r:3.2
+//
+#define qtn_sml_sett_auto_sync_roaming_off "Only in home network"
+
+//d:Title of the content list
+//l:heading_pane_t1
+//r:3.2
+//
+#define qtn_sml_auto_sync_view_contents_head  "Contents"
+
+//d:Command in options list.
+//d:Opens selected profile's content list
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_view_contents		"View contents"
+
+//d:Command in options list.
+//d:Selects profile for automatic sync
+//l:list_single_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_cmd_select		"Select"
+
+//d:msk button text.
+//d:Selects profile for auto sync
+//l:control_pane_t3/opt7
+//r:3.2
+//
+#define qtn_msk_select		"Select"
+
+//d:msk button text.
+//d:View selected profile's contents
+//l:control_pane_t3/opt7 
+//r:3.2
+//*
+#define qtn_msk_view_contents "View contents"
+
+//d:this message is shown when auto sync profile is set active profile 
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_main_info_auto_on "Current profile:%0U, connection method: %1U. Next sync in %0N hours %1N minutes."
+
+// -----------------------------------------------------------------------------
+// application specific setting strings
+// -----------------------------------------------------------------------------
+
+//d:Application dialog setting item for selecting database (selection list)
+//d:that is synced.
+//l:list_setting_pane_t1
+//r:3.0
+//
+#define qtn_sml_local_database "Local database"
+
+//d:Application dialog setting item for selecting remote database for syncing.
+//l:list_setting_pane_t1/opt1
+//r:3.0
+//
+#define qtn_sml_remote_database "Remote database"
+
+//d:Application dialog setting item (Yes/No) for selecting whether sync filters
+//d:should be used in syncing.
+//l:list_setting_pane_t1
+//r:3.0
+//
+#define qtn_nsml_eml_use_filters "Use filters"
+
+//d:Value used in qtn_nsml_eml_use_filters setting (Yes/No).
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_eml_use_filters_yes "Yes"
+
+//d:Value used in qtn_nsml_eml_use_filters setting (Yes/No).
+//l:list_set_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_eml_use_filters_no	"No"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_content_settings_pb	"Phonebook settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_content_settings_cal	"Calendar settings"
+ 
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_content_settings_notes	"Notes settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_content_settings_email	"Email settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1
+//r:3.2
+//
+#define qtn_sml_content_settings_sms	"Sms settings"
+
+//d:One of the setting items in settings view
+//l:list_setting_pane_t1/opt1 
+//r:5.0
+//
+#define qtn_sml_content_settings_mms	"MMS settings"
+
+//d:One of the setting items in settings view
+ //l:list_setting_pane_t1/opt1
+//r:5.0
+//
+#define qtn_sml_content_settings_bkm	"Bookmarks settings"
+
+//d:Display name for Contact content. Used eg. in sync progress text
+//d:"Sending Contacts 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_cnt_display_name "Contacts"
+
+//d:Display name for Calendar content. Used eg. in sync progress text
+//d:"Sending Calendar 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_agn_display_name "Calendar"
+
+//d:Display name for Notes content. Used eg. in sync progress text
+//d:"Sending Notes 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_npd_display_name "Notes"
+
+//d:Display name for EMail content. Used eg. in sync progress text
+//d:"Sending EMail 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_eml_display_name "SyncML Email"
+
+//d:Display name for Sms content. Used eg. in sync progress text
+//d:"Sending EMail 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:3.0
+//
+#define qtn_nsml_sms_display_name "Sms"
+
+//d:Display name for MMS. Used eg. in sync progress text
+//d:"Sending MMS 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:5.0
+//
+#define qtn_nsml_mms_display_name "MMS"
+
+//d:Display name for Bookmarks content. Used eg. in sync progress text
+//d:"Sending Bookmarks 5/10" 
+//l:list_double_large_graphic_pane_t1
+//r:5.0
+//
+#define qtn_nsml_bkm_display_name "Bookmarks"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_sml_title_contacts "Contacts"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_sml_title_calendar "Calendar"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_sml_title_notes "Notes"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_sml_title_email "SyncML EMail"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:3.0
+//
+#define qtn_sml_title_sms "Sms"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:5.0
+//
+#define qtn_sml_title_mms "MMS"
+
+//d:Application dialog title. 
+//l:title_pane_t2/opt9
+//r:5.0
+//
+#define qtn_sml_title_bookmarks "Bookmarks"
+
+//d:Text on the information note that is shown when user tries to set email mailbox
+//d:in application dialog but no email mailboxes exist. 
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_sml_info_no_mailboxes "No mailboxes defined. Check your mailbox settings in Messaging Centre."
+
+// -----------------------------------------------------------------------------
+// sync progress dialog strings
+// -----------------------------------------------------------------------------
+
+//d:progress note window which shows the synchronistion progress
+//d:changing text displayed at connect stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_conn		"Connecting\n"
+
+//d:changing text displayed at initialising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_init		"Initialising\n"
+
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_sync		"Synchronising\n"
+
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_sending	"Sending %0U"
+
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_receiving	"Receiving %0U"
+
+//d:changing text displayed at disconnect stage
+//d:Image replaced by animation
+//l:popup_note_wait_window 
+//r:3.0
+//
+#define qtn_sml_sync_disconn	"Disconnecting\n"
+
+//d:changing text displayed after succesful synchronisation
+//d:Image replaced by animation
+//l:popup_note_wait_window 
+//r:3.0
+//
+#define qtn_sml_sync_end_done	"Completed\n\n"
+
+//d:changing text displayed at cancelling stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_sml_sync_cancel		"Cancelling\n"
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// sync log dialog strings
+// -----------------------------------------------------------------------------
+
+
+//d:texts for the log view window
+//d:heading for the log view window list
+//l:heading_pane_t1
+//r:3.0
+//
+#define qtn_sml_log_synclog_title	"Sync log" 
+
+//d:texts for the log view window
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_profile			"Set name" 
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_date			"Date"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_time			"Time"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_remote			"Remote server"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_status			"Status"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_phone			"Phone"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.0
+//
+#define qtn_sml_log_server			"Server"
+
+//d:heading for the log view window list
+//l:list_double_pane_t1_cp2
+//r:3.2
+//
+#define qtn_sml_log_error			"Errors:"
+
+//d:heading for the log view window list
+//l:list_single_heading_pane_t1
+//r:3.0
+//
+#define qtn_sml_log_ok				"Complete"
+
+//d:heading for the log view window list
+//l:list_single_heading_pane_t1
+//r:3.2
+//
+#define qtn_sml_log_cancelled		"Cancelled"	
+
+//d:heading for the log view window list
+//l:list_single_heading_pane_t1
+//r:3.2
+//
+#define qtn_sml_log_err				"Incomplete"
+
+//d:item in the sync log view
+//d:%U refers to content name
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_content "Added %U:" 
+
+//d:item in the sync log view
+//d:%U refers to content name
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_content	"Updated %U:" 
+
+//d:item in the sync log view
+//d:%U refers to content name
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_content	"Deleted %U:"
+
+//d:item in the sync log view
+//d:%U refers to content name
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_content "Discarded %U:"
+
+//d:item in the sync log view
+//d:%U refers to content name
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_content "Moved %U:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_contacts "Added contacts:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_contacts	"Updated contacts:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_contacts	"Deleted contacts:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_contacts "Discarded contacts:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_contacts "Moved contacts:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_calendar "Added calendar:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_calendar	"Updated calendar:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_calendar	"Deleted calendar:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_calendar "Discarded calendar:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_calendar "Moved calendar:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_notes "Added notes:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_notes	"Updated notes:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_notes	"Deleted notes:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_notes "Discarded notes:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_notes "Moved notes:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_email "Added email:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_email	"Updated email:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_email	"Deleted email:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_email "Discarded email:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_email "Moved email:"
+
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_added_sms "Added Sms:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_updated_sms	"Updated Sms:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_deleted_sms	"Deleted sms:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_discarded_sms "Discarded sms:"
+
+//d:item in the sync log view
+//l:list_double_pane_t2_cp2 
+//r:3.2
+//
+#define qtn_sml_log_moved_sms "Moved sms:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_added_mms "Added MMS:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_updated_mms	"Updated MMS:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_deleted_mms	"Deleted MMS:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_discarded_mms "Discarded MMS:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_moved_mms "Moved MMS:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_added_bkm "Added Bookmarks:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_updated_bkm	"Updated Bookmarks:" 
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_deleted_bkm	"Deleted Bookmarks:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_discarded_bkm "Discarded Bookmarks:"
+
+//d:item in the sync log view
+//l:list_double_pane_t1_cp2 
+//r:5.0
+//
+#define qtn_sml_log_moved_bkm "Moved Bookmarks:"
+
+// -----------------------------------------------------------------------------
+// error strings
+// -----------------------------------------------------------------------------
+
+
+//d:Error confirmation dialog
+//d:Message in log if system error occured
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_systemerror "System Error"
+
+//d:Error confirmation dialog
+//d:Message in log if system error occured in server
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_servererror "Error in sync server"
+
+//d:Error confirmation dialog
+//d:Message in log if SyncML protocol error occured
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_protocol "Unable to synchronise with server"
+
+//d:Error confirmation dialog
+//d:Message in log if command sent to server was not supported 
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_cmdnotsupported "Unsupported SyncML software version in server"
+
+//d:Error confirmation dialog
+//d:Message in log if server has unsupported version
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_versionnotsupported "Unsupported SyncML software version in server"
+
+//d:Error confirmation dialog
+//d:Message in log if content type is not supported by server
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_contentnotsupported "Unsupported content type"
+
+//d:Error confirmation dialog
+//d:Message in log if client authentication failed
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_clientauth "Invalid user name or password"
+
+//d:Error confirmation dialog
+//d:Message in log if client authentication failed
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_httpauth "Http authentication failed"
+
+//d:Error confirmation dialog
+//d:Message in log if server was busy
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_serverbusy "Synchronisation server was busy"
+
+//d:Error confirmation dialog
+//d:Message in log if opening local database fails
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_localdatabase "Unable to open database"
+
+//d:Error confirmation dialog
+//d:Message in log if local database has changed
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_localdbchanged "Database changed. Synchronization interrupted."
+
+//d:Error confirmation dialog
+//d:Message in log if remote database name is invalid
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_remotedatabase "Invalid remote database"
+
+//d:Error confirmation dialog
+//d:Message in log if databases cannot be found (?)
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_invaliddatabase "Invalid database"
+
+//d:Error confirmation dialog
+//d:Message in log if server is not responding
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_servernotresponding "Server is not responding"
+
+//d:Error confirmation dialog
+//d:Message in log if server is not responding
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_invalidsynctype "Sync type was not allowed"
+
+//d:Error confirmation dialog
+//d:Message in log if communication error occured
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_comm "Error in communication"
+
+//d:Error confirmation dialog
+//d:Message in log if uri is invalid
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_log_err_uriinvalid "Invalid host address"
+
+//d:Error confirmation dialog
+//d:Message when user tries to simultaneously edit one sync set in more 
+//d:than one application (eg. Phonebook and Sync)
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_nsml_locked_profile "Sync set already in use by another application"
+
+//d:Error confirmation dialog
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_log_err_untrusted_certificate "Server has untrusted certificate"
+
+
+//d:lText of Data synchronization list item in  Control panel Device management view
+//d:Item opens Data sync application
+//l:list_single_large_graphic_pane_t1
+//r:5.0
+//
+#define qtn_cp_folder_data_sync "Sync"
+
+//d: radio button popup menu text
+//l: list_set_graphic_pane_t1
+//w: 
+//r: 3.2
+//
+#define qtn_netw_conset_sett_default_connection "Default Connection"
+
+//d: radio button popup menu title text
+//l: list_setting_pane_t1
+//w: 
+//r: 3.2
+//
+#define qtn_netw_conset_sett_destination "Network connection"
+
+//d: radio button popup menu text
+//l: list_set_graphic_pane_t1
+//w: 
+//r: 3.2
+//
+#define qtn_netw_conset_sett_user_defined "User Defined"
+
+//d:this message is shown when sync is attempted while 'Always ask' is selected and user is in roaming
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_network_confirmation "Foreign network used. Extra costs may exist. Continue sync?"
+
+//d:this message is shown when sync is attempted while 'never allow' is selected and user is in roaming
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_network_not_allowed "Foreign network used. Sync not allowed"
+
+//d:this message is shown when sync is attempted while roaming setting is blocked
+//l:popup_note_window
+//r:3.2
+//
+#define qtn_sml_note_not_home_network "Sync not allowed until in home network"
+
+//d:Title of the advanced settings in options
+//l:title_pane_t2/opt9
+//r:3.2
+//
+#define qtn_sml_title_adv_settings  "Advanced settings"
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/loc/NSmlSyncProfiles.loc	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  Localisation file for OmaDSAppUi/AspSyncUtil
+*
+*/
+
+
+//d:PC Suite profile
+//d: PC Suite profile
+//l:navi_text_pane_t1 
+//r:3.1
+//
+#define qtn_sml_pc_suite_profile "PC Suite"
+
+//d:PC Suite Plus profile
+//d:PC Suite Plus profile
+//l:navi_text_pane_t1 
+//r:5.0
+//
+#define qtn_sml_pc_suite_plus_profile "PC Suite Plus"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspAdvanceSettingsDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1010 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspAdvanceSettingsDialog.h"
+#include "AspContentDialog.h"
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+#include <AknIconArray.h>   // for GulArray
+#include <aknpasswordsettingpage.h>     // CAknAlphaPasswordSettingPage
+#include <ConnectionUiUtilities.h>      // CConnectionUiUtilities
+#include <featmgr.h>   // FeatureManager
+#include <AspDefines.h> //For enum TRoamingSettings
+#include <centralrepository.h> //For central Repository
+#include "CPreSyncPlugin.h"
+
+const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspAdvanceSettingsDialog::ShowDialogL()
+	{
+	CAspAdvanceSettingsDialog* dialog = CAspAdvanceSettingsDialog::NewL();
+
+	TBool ret = dialog->ExecuteLD(R_ASP_ADVANCE_SETTINGS_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspAdvanceSettingsDialog* CAspAdvanceSettingsDialog::NewL()
+    {
+    FLOG( _L("CAspAdvanceSettingsDialog::NewL START") );
+
+    CAspAdvanceSettingsDialog* self = new ( ELeave ) CAspAdvanceSettingsDialog();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspAdvanceSettingsDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CAspAdvanceSettingsDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspAdvanceSettingsDialog::CAspAdvanceSettingsDialog()
+	{
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::ConstructL()
+    {
+    FLOG( _L("CAspAdvanceSettingsDialog::ConstructL START") );
+	
+	// contruct menu for our dialog
+	CAknDialog::ConstructL(R_ADVANCE_SETTINGS_DIALOG_MENU);
+
+	iResHandler = CAspResHandler::NewL();
+
+	iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(1);
+	
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	// store current navi pane
+	iStatusPaneHandler->StoreNavipaneL();
+
+	FLOG( _L("CAspAdvanceSettingsDialog::ConstructL END") );
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog()
+    {
+    FLOG( _L("CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog START") );
+
+	delete iResHandler;
+	
+	if (iSettingList)
+		{
+		iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+		}
+
+	delete iStatusPaneHandler;
+	
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	FLOG( _L("CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::ActivateL
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	aContext.iContext = KDS_HLP_MAIN_VIEW;    
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::HandleListBoxEventL
+// 
+// -----------------------------------------------------------------------------
+#ifdef RD_SCALABLE_UI_V2
+void CAspAdvanceSettingsDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                            TListBoxEvent aEventType)
+	{
+	if( AknLayoutUtils::PenEnabled() )  
+	  {
+	   switch ( aEventType )
+        {
+         case EEventItemDoubleClicked:
+              HandleOKL();
+              break;
+         case EEventEnterKeyPressed :
+         case EEventItemClicked :
+         case EEventItemDraggingActioned :
+         case EEventPenDownOnItem :
+        	  if(iEditMode != EDialogModeSettingEnforcement)
+				    {
+				    TRAPD(err ,CheckContentSettingL());//folder
+		         	User::LeaveIfError(err);
+				    }
+              break;
+         default:
+              break;
+        }
+		
+	  }
+    
+	}
+#else
+void CAspAdvanceSettingsDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                            TListBoxEvent /*aEventType*/)
+{
+	
+}
+#endif
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::PreLayoutDynInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAdvanceSettingsDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+    
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	
+	// create array of setting items (iSettingList)
+	CreateSettingsListL();
+
+	// add setting headers into listbox
+	UpdateListBoxL(iSettingListBox, iSettingList);
+		
+	iStatusPaneHandler->SetNaviPaneTitleL(R_ASP_TITLE_ADVANCED_SETTINGS);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::SetMiddleSoftKeyLabelL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::SetEmptyMiddleSoftKeyLabelL()
+    {
+    ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,EAknSoftkeyOpen );
+    HBufC* middleSKText = StringLoader::LoadLC( R_TEXT_SOFTKEY_EMPTY );
+
+    ButtonGroupContainer().AddCommandToStackL(
+        KMSKControlId,
+        EAknSoftkeyEmpty,
+        *middleSKText );
+    iMSKEmpty= ETrue;
+    CleanupStack::PopAndDestroy( middleSKText );
+    }
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::SetIconsL()
+    {
+    if (!iSettingListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr =
+    iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspAdvanceSettingsDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::DynInitMenuPaneL(TInt /*aResourceID*/, CEikMenuPane* aMenuPane)
+	{   
+	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		}
+	
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdHelp);
+		}
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAspMenuCmdHelp:
+			{
+			TUtil::LaunchHelpAppL(iEikonEnv);
+            break;
+			}
+
+		case EAspMenuCmdChange:
+		case EAspMenuCmdOpen:
+			{				
+    		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+
+			if (item->iItemType == CAspListItemData::ETypeListYesNo)
+				{
+				// open editor for Yes/No setting
+				if (EditSettingItemListL(*item))
+					{
+					SetVisibility();
+					UpdateListBoxL(ListBox(), iSettingList);
+					}
+				}				
+			else
+				{
+				HandleOKL();
+				}
+
+			break;
+			}
+		    
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:			
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspAdvanceSettingsDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+		// save silently and close dialog
+		
+		CheckSettingValues(aButtonId);
+
+		return ETrue; // close dialog
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+        TBool ret = CheckSettingValues(aButtonId);
+        if (!ret)
+        	{
+        	return EFalse; // leave dialog open
+        	}
+        	
+		return ETrue; // close dialog
+		}
+		
+	if (aButtonId == EAknSoftkeyOpen || aButtonId == EAknSoftkeyEmpty)  // MSK
+        {
+		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+		if (item->iHidden == EVisibilityReadOnly)
+			{
+    		if(iEditMode == EDialogModeSettingEnforcement)
+    		{
+    			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+    		}
+     		else
+     		{
+			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+     		}
+			return EFalse;
+			}
+
+        HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+		
+	if (aButtonId == EAknSoftkeyOptions)	
+		{
+		if (iCommandSetId == R_ASP_CBA_OPTIONS_BACK_OPEN)
+			{
+			UpdateMenuL(R_ADVANCE_SETTINGS_DIALOG_MENU);
+			}	
+		else 
+			{
+			UpdateMenuL(R_ASP_PROFILE_DIALOG_MENU);	
+			}
+		return EFalse;
+		}
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CheckSettingValuesL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspAdvanceSettingsDialog::CheckSettingValuesL(TInt /* aButtonId */)
+	{
+	
+    if (iEditMode == EDialogModeReadOnly || 
+        iEditMode == EDialogModeSettingEnforcement)
+    	{
+    	return ETrue;
+    	}
+	
+    return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CheckSettingValues
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspAdvanceSettingsDialog::CheckSettingValues(TInt aButtonId)
+	{
+	TBool ret = EFalse;
+	
+	TRAPD(err, ret = CheckSettingValuesL(aButtonId));
+	if (err != KErrNone)
+		{
+		return ETrue;
+		}
+
+	return ret;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspAdvanceSettingsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEnter:
+			case EKeyOK:
+				{
+					OkToExitL(EAknSoftkeyOpen);
+					return EKeyWasConsumed;
+				}
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+			case EKeyUpArrow:
+			case EKeyDownArrow:
+			    {
+			    	if(iEditMode != EDialogModeSettingEnforcement)
+				    {
+				    TRAPD(err ,CheckContentSettingL(aKeyEvent));//folder
+		         	User::LeaveIfError(err);
+				    }
+			    break;
+			    }
+            default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+// ---------------------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CheckContentSetting
+// modifies MSK and menu item depending on the item in the list box when touch events are handled
+// ----------------------------------------------------------------------------------------------
+//
+
+void CAspAdvanceSettingsDialog::CheckContentSettingL()
+{
+	TInt curIndex = ListBox()->CurrentItemIndex();
+	TInt count = iSettingList->Count();
+	CAspListItemData* lastItem = (*iSettingList)[--count];
+	
+
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	//TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+	//if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly))
+    if(curItem->iHidden == EVisibilityReadOnly)
+	{
+   		SetEmptyMiddleSoftKeyLabelL();
+   		return;
+	}
+	if(curItem->iItemId != EAspSyncContent)
+		{
+		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
+			{
+			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
+		
+			}
+		return;		
+		}
+	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
+
+}
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CheckContentSetting
+// modifies MSK based on the item
+// ----------------------------------------------------------------------------
+//
+
+void CAspAdvanceSettingsDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent)
+	{
+	
+	TInt curIndex = ListBox()->CurrentItemIndex();
+	TInt count = iSettingList->Count();
+	CAspListItemData* lastItem = (*iSettingList)[--count];
+	
+	switch (aKeyEvent.iCode)
+		{
+		case EKeyUpArrow:
+			{
+				if (curIndex)
+				{
+					curIndex--;
+				}
+				else
+				{
+				    curIndex = lastItem->iIndex;
+				}
+			break;
+			}
+		case EKeyDownArrow:
+			{
+				if (curIndex == lastItem->iIndex)
+				{
+				curIndex = 0;
+				}
+				else
+				{
+				curIndex++;
+				}
+			break;
+			}
+		}
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	//TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+	//if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly))
+	if(curItem->iHidden == EVisibilityReadOnly)
+	{
+   		SetEmptyMiddleSoftKeyLabelL();
+   		return;
+	}
+	if(curItem->iItemId != EAspSyncContent)
+		{
+		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
+			{
+			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
+		
+			}
+		return;		
+		}
+	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
+
+	}
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::HandleOKL
+//
+//------------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::HandleOKL()
+	{
+	
+	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+			if(iEditMode == EDialogModeSettingEnforcement)
+      		{
+    			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+    		}
+     		else
+     		{
+			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+     		}
+		return;
+		}
+
+	if (EditSettingItemL(*item))
+		{
+		SetVisibility();
+		UpdateListBoxL(ListBox(), iSettingList);
+		}
+		
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::CreateSettingsListL
+// 
+// Function creates setting list array (iSettingsList).
+// Note: enum TAspConnectionSettings must match with string array
+// (R_ASP_CONNECTION_DIALOG_SETTING_ITEMS).
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::CreateSettingsListL()
+	{
+	// read setting headers from resource
+	CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ADVANCE_SETTINGS_DIALOG_ITEMS);
+	
+	// add one CAspListItemData for each setting
+	AddItemL(ERoamingSettings, arr);
+
+	// write setting data into each CAspListItemData
+	TInt count=iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		InitSettingItemL((*iSettingList)[i]);
+		}
+
+	SetVisibility();  // find out what setting appear on UI
+
+	CleanupStack::PopAndDestroy(arr);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::AddItemL(TInt aItemId, CDesCArray* aHeaders)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL((*aHeaders)[aItemId]);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::AddItemL(TInt aItemId, TInt aResourceId)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(aResourceId);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+// ----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::UpdateListBoxL(CEikTextListBox* aListBox,
+                                       CAspSettingList* aItemList)
+	{
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt i=0; i<count; i++ )
+		{	
+		CAspListItemData* item = (*aItemList)[i];		
+		TInt aValue = 0;
+		ReadRepositoryL(KNSmlRoamingSettingKey, aValue);
+		if(aValue != ERoamingSettingBlock)
+		{
+		WriteRepositoryL(KNSmlRoamingSettingKey, item->iNumberData);
+		}
+		else
+		{
+		SetEmptyMiddleSoftKeyLabelL();
+		}
+		    		
+		TBool convert = ETrue;
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+			
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	ListBox()->HandleItemAdditionL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::SetVisibility()
+	{
+    TInt aValue(0);
+    TRAPD(err ,ReadRepositoryL(KNSmlRoamingSettingKey, aValue));
+    if(aValue == ERoamingSettingBlock)
+    {
+	Item(ERoamingSettings)->iHidden = EVisibilityReadOnly;
+	}
+	else
+	{
+	Item(ERoamingSettings)->iHidden = EVisibilityNormal;
+	}
+	}
+
+void CAspAdvanceSettingsDialog::ReadRepositoryL(TInt aKey, TInt& aValue)
+    {
+    CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp);
+    TInt err = rep->Get(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+    }
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::InitSettingItemL
+// 
+// Constructs CAspListItemData for one connection setting.
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::InitSettingItemL(CAspListItemData* aItem)
+	{
+	__ASSERT_ALWAYS(aItem, TUtil::Panic(KErrGeneral));	
+	
+	iBuf = KNullDesC;  // reset common buffer
+	
+	switch (aItem->iItemId)
+		{		
+        case ERoamingSettings:
+            {
+            CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_ROAMING_SETTINGS);
+            TInt aValue(0);
+            ReadRepositoryL(KNSmlRoamingSettingKey, aValue);
+
+            if(aValue == ERoamingSettingBlock)
+                {
+                aItem->iNumberData = ERoamingSettingAlwaysAsk;
+                }
+            else
+                {
+                aItem->iNumberData = aValue;
+                }
+            //aItem->iNumberData = iProfile->SASyncState();
+            aItem->iResource = R_ASP_ROAMING_SETTINGS;
+            aItem->SetValueL((*arr)[aItem->iNumberData]);
+            aItem->iItemType = CAspListItemData::ETypeList;
+            
+            CleanupStack::PopAndDestroy(arr);
+            break;
+            }
+			
+        default:
+           	__ASSERT_DEBUG(EFalse, TUtil::Panic(KErrGeneral));
+			break;
+		
+		}
+	}
+	
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TBool CAspAdvanceSettingsDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	TInt ret = EFalse;
+	
+	switch (aItem.iItemType)
+		{
+
+		case CAspListItemData::ETypeList:
+			ret = EditSettingItemListL(aItem);
+		    break;
+		
+
+		default:
+		    break;
+		}
+	
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::EditSettingItemListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspAdvanceSettingsDialog::EditSettingItemListL(CAspListItemData& aItem)
+	{
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = curSelection; 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+//-----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::GetItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspAdvanceSettingsDialog::GetItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::Item
+// 
+// Find item with aItemId (TAspConnectionSettingItem).
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspAdvanceSettingsDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::ListBox
+// 
+// -----------------------------------------------------------------------------
+//
+CAknSettingStyleListBox* CAspAdvanceSettingsDialog::ListBox()
+	{
+	return iSettingListBox;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::UpdateCbaL(TInt aResourceId)
+	{
+	CEikButtonGroupContainer& cba = ButtonGroupContainer();
+	cba.SetCommandSetL(aResourceId);
+	iCommandSetId = aResourceId;
+	iMSKEmpty = EFalse;
+	cba.DrawDeferred();
+	}
+
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::UpdateMenuL
+// 
+// -----------------------------------------------------------------------------
+//
+
+void CAspAdvanceSettingsDialog::UpdateMenuL(TInt aResource)
+	{
+	CEikMenuBar* menuBar = iMenuBar; // from CAknDialog
+	menuBar->SetMenuTitleResourceId(aResource);
+
+	TRAPD(err, menuBar->TryDisplayMenuBarL());
+    		
+	User::LeaveIfError(err);
+	
+			
+	}
+	
+// -----------------------------------------------------------------------------
+// CAspAdvanceSettingsDialog::UpdateMenuL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAdvanceSettingsDialog::WriteRepositoryL(TInt aKey, const TInt& aValue)
+    {
+    const TUid KCRRoamingSettingUID = {0x101F9A1D};
+    const TUid KRepositoryId = KCRRoamingSettingUID;
+
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Set(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+    }
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspAutoSyncHandler.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1597 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "AspAutoSyncHandler.h"
+#include "AspUtil.h"
+#include "AspDialogUtil.h"
+#include "AspDebug.h"
+
+#include <schinfo.h> // TScheduleEntryInfo2
+#include <s32mem.h>  // RDesWriteStream
+#include <s32file.h> // RFileReadStream
+//#include <centralrepository.h>  // CRepository
+#include <rconnmon.h>
+
+
+
+
+_LIT(KPeakTaskData, "aspschedulehandler peak task");
+_LIT(KOffPeakTaskData, "aspschedulehandler off-peak task");
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+	
+/*******************************************************************************
+ * class CAspAutoSyncHandler
+ *******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspAutoSyncHandler* CAspAutoSyncHandler::NewL()
+    {
+    CAspAutoSyncHandler* self = new (ELeave) CAspAutoSyncHandler();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::CAspAutoSyncHandler
+// 
+// -----------------------------------------------------------------------------
+//
+CAspAutoSyncHandler::CAspAutoSyncHandler()
+	{
+	iSyncError = KErrNone;
+	iSyncSessionOpen = EFalse;
+	iSyncRunning = EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::ConstructL()
+    {
+    iWait = new (ELeave) CActiveSchedulerWait();
+    
+    iSchedule = CAspSchedule::NewL();
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspAutoSyncHandler::~CAspAutoSyncHandler()
+    {
+    if (iWait && iWait->IsStarted())
+        {
+        iWait->AsyncStop();
+        }
+    delete iWait;
+    
+    delete iSchedule;
+    
+    CloseSyncSession();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::OnSyncMLSessionEvent (from MSyncMLEventObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::OnSyncMLSessionEvent(TEvent aEvent, TInt /*aIdentifier*/,
+                                           TInt aError, TInt /*aAdditionalData*/)
+	{
+	FLOG( _L("CAspAutoSyncHandler::OnSyncMLSessionEvent START") );
+	
+	if (aEvent == EJobStart)
+		{
+        FLOG( _L("EJobStart") );
+		}
+
+	if (aEvent == EJobStop)
+		{
+    	if (aError != KErrNone)
+			{
+			iSyncError = aError;
+    		}
+
+        FLOG( _L("EJobStop") );
+        
+    	iWait->AsyncStop();
+		}
+    	
+	if (aEvent == EJobStartFailed || aEvent == EJobRejected || aEvent == EServerTerminated)
+		{
+		FLOG( _L("EJobStartFailed or EJobRejected or EServerTerminated") );
+		iWait->AsyncStop();
+		}
+		
+	FLOG( _L("CAspAutoSyncHandler::OnSyncMLSessionEvent END") );
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::OnSyncMLSyncError (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::OnSyncMLSyncError(TErrorLevel aErrorLevel,
+                                                TInt aError, TInt /*aTaskId*/,
+                                                TInt /*aInfo1*/, TInt /*aInfo2*/)
+	{
+	FLOG( _L("CAspAutoSyncHandler::OnSyncMLSyncError START") );
+	
+	if (aErrorLevel == ESmlFatalError)
+		{
+		iSyncError = aError;
+		iWait->AsyncStop();
+		}
+
+	FLOG( _L("CAspAutoSyncHandler::OnSyncMLSyncError END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::OnSyncMLSyncProgress (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::OnSyncMLSyncProgress(TStatus /*aStatus*/,
+                                                   TInt /*aInfo1*/, TInt /*aInfo2*/)
+	{
+	// not needed in scheduled sync
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::OnSyncMLDataSyncModifications (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::OnSyncMLDataSyncModifications(TInt /*aTaskId*/, 
+	         const TSyncMLDataSyncModifications& /*aClientModifications*/,
+	         const TSyncMLDataSyncModifications& /*aServerModifications*/)
+	{
+	// not needed in scheduled sync
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::OpenSyncSessionL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::OpenSyncSessionL()
+	{
+	if (!iSyncSessionOpen)
+		{
+        TRAPD(err, iSyncSession.OpenL());
+        
+        if (err != KErrNone)
+        	{
+        	FLOG( _L("### CAspAutoSyncHandler: RSyncMLSession::OpenL failed (%d) ###"), err );
+        	User::Leave(err);
+        	}
+
+		iSyncSessionOpen = ETrue;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CloseSyncSession
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::CloseSyncSession()
+	{
+	if (iSyncSessionOpen)
+		{
+		iSyncJob.Close(); // this can be done when job has not been opened
+		iSyncSession.Close();
+		iSyncSessionOpen = EFalse;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::CheckMandatoryData
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspAutoSyncHandler::CheckMandatoryDataL(TInt aProfileId)
+	{
+    TAspParam param(EApplicationIdSync, &iSyncSession);
+
+    CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+    
+	param.iProfile = profile;
+	param.iMode = CAspContentList::EInitAll;
+	CAspContentList* list = CAspContentList::NewLC(param);
+
+   	//TInt contentCount = 0;
+	TInt mandatoryConnectionData = CAspProfile::CheckMandatoryConnData(profile);
+	//TInt mandatoryContentData    = list->CheckMandatoryDataL(contentCount);
+	
+	TInt mandatoryBearerType = EMandatoryOk;
+	if (profile->BearerType() != EAspBearerInternet)
+		{
+		mandatoryBearerType = EMandatoryIncorrectBearerType;
+		}
+		
+	TInt mandatoryAccessPoint = EMandatoryOk;
+	/*if (profile->AccessPointL() == CAspAccessPointHandler::KAskAlways)
+		{
+		mandatoryAccessPoint = EMandatoryIncorrectAccessPoint;
+		}*/
+	
+	CleanupStack::PopAndDestroy(list);
+	CleanupStack::PopAndDestroy(profile);
+	
+	if (mandatoryBearerType != EMandatoryOk)
+		{
+		return mandatoryBearerType;
+		}
+
+	if (mandatoryAccessPoint != EMandatoryOk)
+		{
+		return mandatoryAccessPoint;
+		}
+
+	if (mandatoryConnectionData != EMandatoryOk)
+		{
+		return mandatoryConnectionData;
+		}
+		
+	return EMandatoryOk;//mandatoryContentData;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::SynchronizeL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::SynchronizeL(RFile& aTaskFile)
+	{
+	
+	FLOG( _L("CAspAutoSyncHandler::SynchronizeL START") );
+
+	CFileStore*         store;
+    RStoreReadStream    instream;
+    // Get tasks from scheduler's store
+    store = CDirectFileStore::FromLC(aTaskFile);
+    instream.OpenLC(*store,store->Root());
+    TInt count = instream.ReadInt32L();
+
+	CScheduledTask* task = CScheduledTask::NewLC(instream);
+    HBufC* taskData = const_cast<HBufC*>(&(task->Data()));
+    TPtr ptr = taskData->Des();
+    TBool doCleanUp = ETrue;
+
+	if (ptr.Compare(KPeakTaskData) == 0)
+		{
+	 FLOG( _L("Peak Sync Scheduled") );
+		TInt interval = iSchedule->SyncPeakSchedule();
+		if (iSchedule->IntervalType(interval) == EHourly
+					&& interval != CAspSchedule::EIntervalManual)
+			{
+			if (iSchedule->IsValidPeakScheduleL() != 0)
+				{
+				//postpone peak schedule until next peak start
+				iSchedule->UpdatePeakScheduleL();
+				CleanupStack::PopAndDestroy(task);
+    			CleanupStack::PopAndDestroy( &instream ); 
+				CleanupStack::PopAndDestroy( store ); 
+				doCleanUp = EFalse;
+				return;
+				}
+			else
+				{
+				//schedule next sync
+				if(!iSchedule->IsValidNextPeakScheduleL())
+					{
+					iSchedule->UpdatePeakScheduleL();
+					}
+				else 
+					{
+					CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+					syncSchedule->EditPeakScheduleL(iSchedule);
+					CleanupStack::PopAndDestroy(syncSchedule);
+					}
+				}
+			}
+		else
+			{
+			//schedule next sync
+			CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+			syncSchedule->EditPeakScheduleL(iSchedule);
+			CleanupStack::PopAndDestroy(syncSchedule);
+			}
+		}
+			
+	if (ptr.Compare(KOffPeakTaskData) == 0)
+		{
+		FLOG( _L("Off-Peak Sync Scheduled") );
+		TInt interval = iSchedule->SyncOffPeakSchedule();
+		if (iSchedule->IntervalType(interval) == EHourly)
+			{
+			if (iSchedule->IsValidOffPeakScheduleL() != 0)
+				{
+				//postpone off-schedule until next off-peak start
+				iSchedule->UpdateOffPeakScheduleL();
+				CleanupStack::PopAndDestroy(task);
+				CleanupStack::PopAndDestroy( &instream ); 
+				CleanupStack::PopAndDestroy( store ); 
+				doCleanUp = EFalse;
+				return;
+				}
+			else
+				{
+				//schedule next sync
+				if(!iSchedule->IsValidNextOffPeakScheduleL())
+					{
+					iSchedule->UpdateOffPeakScheduleL();
+					}
+				else
+					{
+					CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+					syncSchedule->EditOffPeakScheduleL(iSchedule);
+					CleanupStack::PopAndDestroy(syncSchedule);
+					}
+				}
+		
+			}
+		}
+
+	if(doCleanUp)	
+		{
+			CleanupStack::PopAndDestroy(task);
+			CleanupStack::PopAndDestroy( &instream ); 
+			CleanupStack::PopAndDestroy( store ); 
+			doCleanUp = EFalse;
+		}
+	
+	iSchedule->SetError(KErrNone);
+	iSchedule->SaveL();
+	
+	TRAPD (err, DoSynchronizeL());
+	User::LeaveIfError(err);
+
+}
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::DoSynchronizeL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspAutoSyncHandler::DoSynchronizeL()
+{
+	
+	OpenSyncSessionL();
+	
+	if (CAspProfile::OtherSyncRunning(&iSyncSession))
+		{
+		FLOG( _L("### other sync running ###") );
+		TInt currentJobId = CAspProfile::CurrentJob(&iSyncSession);
+		if (currentJobId != KErrNotFound)
+			{
+			iSyncJob.OpenL(iSyncSession, currentJobId);
+			if (iSchedule->ProfileId() != iSyncJob.Profile())
+				{
+				FLOG( _L("CAspAutoSyncHandler::SynchronizeL Set Error") );
+				iSchedule->SetError(EOtherSyncRunning);
+				iSchedule->SaveL();
+				}
+			iSyncJob.Close();
+			}
+		FLOG( _L("CAspAutoSyncHandler::SynchronizeL END") );
+		return;
+		}
+	
+    TInt profileId = iSchedule->AutoSyncProfileId();
+	iSchedule->UpdateProfileSettingsL();
+	iSchedule->SaveL();
+
+	
+#ifdef _DEBUG
+	iSchedule->LogScheduleL();
+#endif
+	
+	if (!iSchedule->CanSynchronizeL())
+		{
+		FLOG( _L("### incorrect auto sync settings ###") );
+		FLOG( _L("CAspAutoSyncHandler::SynchronizeL END") );
+	    //iSchedule->SetError(EIncorrectSchedule);
+		//iSchedule->SaveL();
+		return;
+		}
+
+#if 0 //roaming check not supported		
+	if (!iSchedule->RoamingAllowed())
+		{
+		if (IsRoaming())
+			{
+		    FLOG( _L("### cannot sync when roaming ###") );
+		    FLOG( _L("CAspAutoSyncHandler::SynchronizeL END") );
+		    return;
+			}
+		}
+#endif
+
+	
+		
+	if (CheckMandatoryDataL(profileId) != EMandatoryOk)
+		{
+		FLOG( _L("### incorrect sync profile settings ###") );
+		FLOG( _L("CAspAutoSyncHandler::SynchronizeL END") );
+		//iSchedule->SetError(EIncorrectProfile);
+		//iSchedule->SaveL();
+		return;
+		}
+
+
+    iSyncSession.RequestEventL(*this);     // for MSyncMLEventObserver events
+    iSyncSession.RequestProgressL(*this);  // for MSyncMLProgressObserver events
+    
+
+    iSyncJob.CreateL(iSyncSession, profileId);  // start sync
+    
+    iSyncRunning = ETrue;
+    
+    iWait->Start();  // stop here until sync has completed
+    
+   	iSyncRunning = EFalse;
+
+	iSchedule->UpdateServerIdL();
+   	
+   	if (iSyncError != KErrNone)
+		{
+		iSchedule->SetError(iSyncError);
+		iSchedule->SaveL();
+     	FLOG(_L("### auto sync failed (%d) ###"), iSyncError);
+		}
+	
+    FLOG( _L("CAspAutoSyncHandler::SynchronizeL END") );
+
+}
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::IsRoamingL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspAutoSyncHandler::IsRoamingL()
+	{
+	RConnectionMonitor conMon;
+	
+	conMon.ConnectL();
+
+    TRequestStatus status;
+    TInt registrationStatus(0);
+
+    //check network status
+    conMon.GetIntAttribute(EBearerIdGSM, 0, KNetworkRegistration, 
+                            registrationStatus, status);
+
+    User::WaitForRequest(status);
+    conMon.Close();
+    
+    if (registrationStatus == ENetworkRegistrationRoaming)
+    	{
+    	return ETrue;	
+    	}
+    	
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAutoSyncHandler::IsRoaming
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspAutoSyncHandler::IsRoaming()
+	{
+	TBool ret = EFalse;
+	TRAPD(err, ret = IsRoamingL());
+	
+	if (err != KErrNone)
+		{
+		ret = EFalse; // default is not roaming	
+		}
+		
+	return ret;
+    }
+
+
+
+/*******************************************************************************
+ * class CAspSyncSchedule
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncSchedule* CAspSyncSchedule::NewL()
+    {
+    CAspSyncSchedule* self = new (ELeave) CAspSyncSchedule();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncSchedule* CAspSyncSchedule::NewLC()
+    {
+    CAspSyncSchedule* self = new (ELeave) CAspSyncSchedule();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::CAspSyncSchedule
+// 
+// -----------------------------------------------------------------------------
+//
+CAspSyncSchedule::CAspSyncSchedule()
+	{
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::ConstructL()
+    {
+        
+    _LIT(KScheduleHandler, "z:\\sys\\bin\\aspschedulehandler.exe");
+    const TInt KDefaultSchedulePriority = 1;
+    
+    TInt err = iScheduler.Connect();
+	User::LeaveIfError(err);
+	
+    TFileName name(KScheduleHandler);
+    err = iScheduler.Register(name, KDefaultSchedulePriority);
+    User::LeaveIfError(err);
+    
+   	ipeakEntryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
+	ioffPeakEntryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
+   	ipeakTaskList  = new (ELeave) CArrayFixFlat<TTaskInfo>(1);
+	ioffPeakTaskList  = new (ELeave) CArrayFixFlat<TTaskInfo>(1);
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspSyncSchedule::~CAspSyncSchedule()
+    {
+    delete ipeakEntryList;
+	delete ioffPeakEntryList;
+    delete ipeakTaskList;
+    delete ioffPeakTaskList;
+	
+    iScheduler.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::DoDeleteScheduleL
+// - Delete schedules if exist
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::DoDeleteScheduleL(CAspSchedule* aAspSchedule)
+	{
+	ipeakEntryList->Reset();
+	ioffPeakEntryList->Reset();
+	ipeakTaskList->Reset();
+    ioffPeakTaskList->Reset();
+	
+    TScheduleState2 state;
+    TTsTime time;
+    
+    TInt peakHandle = aAspSchedule->PeakScheduleHandle();
+	TInt offPeakHandle = aAspSchedule->OffPeakScheduleHandle();
+	
+    if (peakHandle == KErrNotFound && offPeakHandle == KErrNotFound)
+    	{
+    	return; // nothing to delete
+    	}
+    if (peakHandle != KErrNotFound)
+    	{
+    	
+    	TInt err = iScheduler.GetScheduleL(peakHandle, state,
+                                  *ipeakEntryList, *ipeakTaskList, time);
+
+    	TInt count = ipeakTaskList->Count();
+
+		for (TInt i=0; i<count; i++)
+    		{
+    		TTaskInfo& task = (*ipeakTaskList)[i];
+    		err = iScheduler.DeleteTask(task.iTaskId);
+    		User::LeaveIfError(err);
+    		}
+    	
+    	err = iScheduler.DeleteSchedule(peakHandle);
+		aAspSchedule->SetPeakScheduleHandle(KErrNotFound);
+		aAspSchedule->SetDailySyncEnabled(EFalse);
+		aAspSchedule->SetPeakSyncEnabled(EFalse);
+		
+    	User::LeaveIfError(err);
+    	}
+
+	if (offPeakHandle != KErrNotFound)
+    	{
+    	
+    	TInt err = iScheduler.GetScheduleL(offPeakHandle, state,
+                                  *ioffPeakEntryList, *ioffPeakTaskList, time);
+
+    	TInt count = ioffPeakTaskList->Count();
+
+		for (TInt i=0; i<count; i++)
+    		{
+    		TTaskInfo& task = (*ioffPeakTaskList)[i];
+    		err = iScheduler.DeleteTask(task.iTaskId);
+    		User::LeaveIfError(err);
+    		}
+    	
+    	err = iScheduler.DeleteSchedule(offPeakHandle);
+		aAspSchedule->SetOffPeakScheduleHandle(KErrNotFound);
+		aAspSchedule->SetOffPeakSyncEnabled(EFalse);
+    	User::LeaveIfError(err);
+    	}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::DeleteScheduleL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::DeleteScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	TRAPD(err, DoDeleteScheduleL(aAspSchedule));
+	
+	if (err == KErrNone)
+		{
+		FLOG( _L("CAspSyncSchedule::DeleteScheduleL ok"));
+		}
+	else
+		{
+		FLOG( _L("CAspSyncSchedule::DeleteSchedule failed ,err: %d"), err );
+		}
+		
+	if (err != KErrNone && err != KErrNotFound)
+		{
+		User::Leave(err);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::CreatePeakScheduleL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::CreatePeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+	
+	const TInt KRepeatForever = -1;
+	const TInt KTaskPriority = 2;
+		
+	CAspSchedule* schedule = aAspSchedule;
+	schedule->SetPeakScheduleHandle(KErrNotFound);
+	
+	TTsTime startTime;
+	TIntervalType intervalType;
+	TInt interval;
+	TTime now;
+	now.HomeTime();
+	TInt peakschedule;
+    TInt peakStatus = schedule->IsValidPeakScheduleL();
+
+	TDateTime startday;
+	TInt syncFrequency = schedule->SyncFrequency();
+
+	//Daily schedule can be done using peak schedule
+	if (IntervalType(syncFrequency) == EDaily)
+		{
+		   	startday = now.DateTime();
+			TTime start = schedule->AutoSyncScheduleTime();
+			TDateTime date = start.DateTime();
+			TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+			TTime syncTime(time);
+			startTime.SetLocalTime(syncTime);
+		}
+	else
+		{
+		TInt dayCount = 0;
+	    TInt dayIndex = 0;
+        schedule->SelectedDayInfo(dayCount, dayIndex); 
+		if (dayCount == 0)
+			{
+			//no need to schedule if peak days are not selected
+			schedule->SetPeakSyncEnabled(EFalse);
+			return;
+			}
+
+		if(schedule->WeekdayEnabled(now.DayNoInWeek()))
+			{
+			startday = now.DateTime();
+			//If the current time is peak, start now
+			if (peakStatus == 0)
+				{
+				startTime.SetLocalTime(now);
+				}
+			//current time is before peak
+			else if (peakStatus > 0)
+				{
+				TTime start = schedule->StartPeakTime();
+				TDateTime date = start.DateTime();
+				TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+				TTime syncTime(time);
+				startTime.SetLocalTime(syncTime);
+				}
+			//current time is after peak.
+			else if (peakStatus < 0)
+				{
+				TTime start = schedule->StartPeakTime();
+				TDateTime date = start.DateTime();
+				now = now + (TTimeIntervalDays)1;
+				while(!schedule->WeekdayEnabled(now.DayNoInWeek()))
+		 			{
+					now = now + (TTimeIntervalDays)1;
+		 			}
+				startday = now.DateTime();
+				TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+				TTime syncTime(time);
+				startTime.SetLocalTime(syncTime);
+				}
+			}
+			
+		else
+			{
+			//find the next day selected for sync
+		 	while(!schedule->WeekdayEnabled(now.DayNoInWeek()))
+		 		{
+				now = now + (TTimeIntervalDays)1;
+		 		}
+		 
+		 	startday = now.DateTime();
+		 	TTime start = schedule->StartPeakTime();
+			TDateTime date = start.DateTime();
+			TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+			TTime syncTime(time);
+			startTime.SetLocalTime(syncTime);
+		 	}
+
+		}
+	
+	TInt validityPeriod = KMaxTInt;
+	if (schedule->DailySyncEnabled())
+		{
+		peakschedule = schedule->SyncFrequency();
+		}
+	else
+		{
+	 	peakschedule = schedule->SyncPeakSchedule();
+		}
+    intervalType = IntervalType(peakschedule);
+	interval = Interval(peakschedule);
+
+	TScheduleEntryInfo2 peakEntry(startTime, intervalType, interval, (TTimeIntervalMinutes)validityPeriod);
+	
+	
+	#ifdef _DEBUG
+	TBuf<64> buf;
+	LogTsTime(startTime, buf);
+	FLOG(_L("Auto sync start time: %S"), &buf);
+	#endif
+    
+	
+	ipeakEntryList->Reset();
+	ipeakEntryList->AppendL(peakEntry);
+	
+	TSchedulerItemRef ref;
+	TInt err = iScheduler.CreatePersistentSchedule(ref, *ipeakEntryList);
+	User::LeaveIfError(err);
+	
+	//keep the scheduler disabled until settings are saved
+	iScheduler.DisableSchedule(ref.iHandle);
+	
+	schedule->SetPeakScheduleHandle(ref.iHandle);
+	
+	HBufC* hBuf = HBufC::NewMaxLC(KBufSize);
+	hBuf->Des() = KPeakTaskData;
+	
+	TTaskInfo taskInfo;
+	taskInfo.iName = KPeakTaskData;
+	taskInfo.iRepeat = KRepeatForever;
+	taskInfo.iPriority = KTaskPriority;
+
+    err = iScheduler.ScheduleTask(taskInfo, *hBuf, ref.iHandle);
+    User::LeaveIfError(err);
+	
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::CreateOffPeakScheduleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::CreateOffPeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+	
+	const TInt KRepeatForever = -1;
+	const TInt KTaskPriority = 1;
+		
+	CAspSchedule* schedule = aAspSchedule;
+	schedule->SetOffPeakScheduleHandle(KErrNotFound);
+	
+	TTime opStart= schedule->EndPeakTime()+ (TTimeIntervalMinutes)1;
+	TDateTime opStartDate = opStart.DateTime();
+	TTime pStart = schedule->StartPeakTime();
+	TDateTime pStartDate = pStart.DateTime();
+	
+	//Dont create off-peak schedule if the duration is zero
+	if (opStartDate.Hour() == pStartDate.Hour()
+						&& opStartDate.Minute() == pStartDate.Minute())
+		{
+		schedule->SetOffPeakSyncEnabled(EFalse);
+		return;
+		}
+	
+	TTsTime startTime;
+	TIntervalType intervalType;
+	TInt interval;
+
+	TTime now;
+	now.HomeTime();
+	
+	TInt offpeakschedule = schedule->SyncOffPeakSchedule();
+	intervalType = IntervalType(offpeakschedule);
+
+	TInt offPeakStatus = schedule->IsValidOffPeakScheduleL();
+	TDateTime startday;
+	
+	startday = now.DateTime();
+	//If the current time is off peak, start now
+	if (offPeakStatus == 0)
+		{
+		startTime.SetLocalTime(now);
+		}
+	//current time is peak
+	else if (offPeakStatus > 0)
+		{
+		TTime start= schedule->EndPeakTime()+ (TTimeIntervalMinutes)1;
+		TDateTime date = start.DateTime();
+		TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+		TTime syncTime(time);
+		startTime.SetLocalTime(syncTime);
+		}
+	
+	TInt validityPeriod = KMaxTInt;
+	
+	interval = Interval(offpeakschedule);
+	
+	TScheduleEntryInfo2 offPeakEntry(startTime, intervalType, interval, (TTimeIntervalMinutes)validityPeriod);
+	
+	#ifdef _DEBUG
+	TBuf<64> buf;
+	LogTsTime(startTime, buf);
+	FLOG(_L("Auto sync start time: %S"), &buf);
+	#endif
+    
+	ioffPeakEntryList->Reset();
+	ioffPeakEntryList->AppendL(offPeakEntry);
+	
+	TSchedulerItemRef ref;
+	TInt err = iScheduler.CreatePersistentSchedule(ref, *ioffPeakEntryList);
+	User::LeaveIfError(err);
+
+	//keep the scheduler disabled until settings are saved
+	iScheduler.DisableSchedule(ref.iHandle);
+	
+	schedule->SetOffPeakScheduleHandle(ref.iHandle);
+	
+	HBufC* hBuf = HBufC::NewMaxLC(KBufSize);
+	hBuf->Des() = KOffPeakTaskData;
+	
+	TTaskInfo taskInfo;
+	taskInfo.iName = KOffPeakTaskData;
+	taskInfo.iRepeat = KRepeatForever;
+	taskInfo.iPriority = KTaskPriority;
+
+    err = iScheduler.ScheduleTask(taskInfo, *hBuf, ref.iHandle);
+    User::LeaveIfError(err);
+	
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::EnableSchedule()
+// -Enable schedules after settings are saved.
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::EnableSchedule(CAspSchedule* aAspSchedule)
+	{
+	TInt peakHandle = aAspSchedule->PeakScheduleHandle();
+	TInt offPeakHandle = aAspSchedule->OffPeakScheduleHandle();
+
+	if (peakHandle != KErrNotFound)
+		{
+		iScheduler.EnableSchedule(peakHandle);
+		}
+	if (offPeakHandle != KErrNotFound)
+		{
+		iScheduler.EnableSchedule(offPeakHandle);
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::EditPeakScheduleL
+// -Edit peak schedule entry
+// -----------------------------------------------------------------------------
+//
+
+void CAspSyncSchedule::EditPeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	ipeakEntryList->Reset();
+	ipeakTaskList->Reset();
+
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt peakHandle = aAspSchedule->PeakScheduleHandle();
+		
+	if (peakHandle == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);	
+		}
+	
+	TInt err = iScheduler.GetScheduleL(peakHandle, state, *ipeakEntryList, *ipeakTaskList, tsTime);
+	
+	User::LeaveIfError(err);
+	
+	TInt count = ipeakEntryList->Count();
+	__ASSERT_DEBUG(count == 1, TUtil::Panic(KErrArgument));
+
+	TInt peakInterval;
+	if (aAspSchedule->DailySyncEnabled())
+		{
+		peakInterval = aAspSchedule->SyncFrequency();
+		}
+	else
+		{
+	 	peakInterval = aAspSchedule->SyncPeakSchedule();
+		}
+	TInt interval = Interval(peakInterval);
+	TIntervalType intervalType = IntervalType(peakInterval);
+	TTime now;
+	now.HomeTime();
+	TTsTime startTime ;
+	if (intervalType == EHourly)
+		{
+		if (peakInterval == CAspSchedule::EInterval15Mins
+				       		|| peakInterval == CAspSchedule::EInterval30Mins)
+			{
+			now = now + (TTimeIntervalMinutes)interval ;
+			}
+		else
+			{
+			now = now + (TTimeIntervalHours)interval ;
+			}
+		startTime.SetLocalTime(now);
+		}
+	else
+		{
+		now = now + (TTimeIntervalDays)interval;
+		TDateTime startday = now.DateTime();
+		TTime start = aAspSchedule->AutoSyncScheduleTime();
+		TDateTime date = start.DateTime();
+		TDateTime time(startday.Year(), startday.Month(), startday.Day(), date.Hour(), date.Minute(), 0, 0);
+		TTime syncTime(time);
+		startTime.SetLocalTime(syncTime);
+		}
+	
+	TScheduleEntryInfo2& info = (*ipeakEntryList)[0];
+
+	info.SetStartTime(startTime);
+	info.SetInterval(interval);
+	info.SetIntervalType(intervalType);
+	
+	err = iScheduler.EditSchedule(peakHandle, *ipeakEntryList);
+	User::LeaveIfError(err);
+	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::EditOffPeakScheduleL
+// -Edit off-peak schedule entry
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::EditOffPeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	ioffPeakEntryList->Reset();
+	ioffPeakTaskList->Reset();
+
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt offPeakHandle = aAspSchedule->OffPeakScheduleHandle();
+		
+	if (offPeakHandle == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);	
+		}
+	
+	TInt err = iScheduler.GetScheduleL(offPeakHandle, state, *ioffPeakEntryList, *ioffPeakTaskList, tsTime);
+	
+	User::LeaveIfError(err);
+	
+	TInt count = ioffPeakEntryList->Count();
+	__ASSERT_DEBUG(count == 1, TUtil::Panic(KErrArgument));
+	
+	TInt offPeakInterval = aAspSchedule->SyncOffPeakSchedule();
+	TInt interval = Interval(offPeakInterval);
+	TIntervalType intervalType = IntervalType(offPeakInterval);
+	TTime now;
+	now.HomeTime();
+	TTsTime startTime ;
+	
+	if (offPeakInterval == CAspSchedule::EInterval15Mins
+				       		|| offPeakInterval == CAspSchedule::EInterval30Mins)
+		{
+		now = now + (TTimeIntervalMinutes)interval ;
+		}
+	else
+		{
+		now = now + (TTimeIntervalHours)interval ;
+		}
+	startTime.SetLocalTime(now);
+	
+	
+	TScheduleEntryInfo2& info = (*ioffPeakEntryList)[0];
+
+	info.SetStartTime(startTime);
+	info.SetInterval(interval);
+	info.SetIntervalType(intervalType);
+	
+	err = iScheduler.EditSchedule(offPeakHandle, *ioffPeakEntryList);
+	User::LeaveIfError(err);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::UpdatePeakScheduleL
+// -Postpone peak schedule till next peak start
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::UpdatePeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	ipeakEntryList->Reset();
+	ipeakTaskList->Reset();
+
+	TTime startPeak = aAspSchedule->StartPeakTime();
+		
+	TTime now;
+	now.HomeTime();
+
+		
+	TDateTime startDate = startPeak.DateTime();
+	
+	TDateTime day = now.DateTime();
+	if (day.Hour() > KStartPeakHour)
+		{
+		now = now + (TTimeIntervalDays)1;
+		}
+	TDateTime tomorrow = now.DateTime();
+	
+    TDateTime time(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(), startDate.Hour(), startDate.Minute(), 0, 0);
+	TTime nextPeakStart(time);
+	
+	while(!aAspSchedule->WeekdayEnabled(nextPeakStart.DayNoInWeek()))
+		{
+		nextPeakStart = nextPeakStart + (TTimeIntervalDays)1;
+		}
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt peakHandle = aAspSchedule->PeakScheduleHandle();
+		
+	if (peakHandle == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);	
+		}
+	
+	TInt err = iScheduler.GetScheduleL(peakHandle, state, *ipeakEntryList, *ipeakTaskList, tsTime);
+	
+	User::LeaveIfError(err);
+	
+	TInt count = ipeakEntryList->Count();
+	__ASSERT_DEBUG(count == 1, TUtil::Panic(KErrArgument));
+
+	
+	TTsTime startTime ;
+	startTime.SetLocalTime(nextPeakStart);
+	TIntervalType intervalType = IntervalType(aAspSchedule->SyncPeakSchedule());
+	TInt interval = Interval(aAspSchedule->SyncPeakSchedule());	
+	
+	TScheduleEntryInfo2& info = (*ipeakEntryList)[0];
+
+	info.SetStartTime(startTime);
+	info.SetInterval(interval);
+	info.SetIntervalType(intervalType);
+	
+	err = iScheduler.EditSchedule(peakHandle, *ipeakEntryList);
+	User::LeaveIfError(err);
+	
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::UpdateOffPeakScheduleL
+// -Postpone off-peak schedule till next off-peak start
+// -----------------------------------------------------------------------------
+//
+
+void CAspSyncSchedule::UpdateOffPeakScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	ioffPeakEntryList->Reset();
+	ioffPeakTaskList->Reset();
+
+	TTime startoffPeak = aAspSchedule->EndPeakTime() + (TTimeIntervalMinutes)1;
+		
+	TTime now;
+	now.HomeTime();
+
+	TInt interval = aAspSchedule->SyncOffPeakSchedule();
+	TIntervalType intervalType = IntervalType(interval);
+	TInt intervalVal = Interval(interval);
+
+	if (interval == CAspSchedule::EInterval15Mins
+				|| interval == CAspSchedule::EInterval30Mins)
+
+		{
+		now = now + (TTimeIntervalMinutes)intervalVal;
+		}
+	else if (intervalType == EHourly)
+		{
+		now = now + (TTimeIntervalHours)intervalVal;
+		}
+	
+	TDateTime startday = startoffPeak.DateTime();
+	TDateTime today = now.DateTime();
+	
+    TDateTime time(today.Year(), today.Month(), today.Day(), startday.Hour(), startday.Minute(), 0, 0);
+	
+	TTime nextOffPeakStart(time);
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt offpeakHandle = aAspSchedule->OffPeakScheduleHandle();
+		
+	if (offpeakHandle == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);	
+		}
+	
+	TInt err = iScheduler.GetScheduleL(offpeakHandle, state, *ioffPeakEntryList, *ioffPeakTaskList, tsTime);
+	
+	User::LeaveIfError(err);
+	
+	TInt count = ioffPeakEntryList->Count();
+	__ASSERT_DEBUG(count == 1, TUtil::Panic(KErrArgument));
+
+	
+	TTsTime startTime ;
+	startTime.SetLocalTime(nextOffPeakStart);
+	TScheduleEntryInfo2& info = (*ioffPeakEntryList)[0];
+
+	info.SetStartTime(startTime);
+	info.SetInterval(interval);
+	info.SetIntervalType(intervalType);
+	
+	err = iScheduler.EditSchedule(offpeakHandle, *ioffPeakEntryList);
+	User::LeaveIfError(err);
+	
+	
+	}
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::IntervalType
+// Return  interval type
+// ----------------------------------------------------------------------------
+//
+TIntervalType CAspSyncSchedule::IntervalType(TInt aInterval)
+	{
+	if (aInterval == CAspSchedule::EInterval24hours
+			  || aInterval == CAspSchedule::EInterval2days
+			  || aInterval == CAspSchedule::EInterval4days
+			  || aInterval == CAspSchedule::EInterval7days
+			  || aInterval == CAspSchedule::EInterval14days
+			  || aInterval == CAspSchedule::EInterval30days)
+		{
+		return EDaily;
+		}
+		
+	return EHourly;
+	}
+	
+	
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::Interval
+// Return  interval value
+// ----------------------------------------------------------------------------
+//
+TInt CAspSyncSchedule::Interval(TInt aInterval)
+	{
+	const TInt KIntervalManual  = 0;
+	const TInt KInterval15Mins  = 15;
+	const TInt KInterval30Mins  = 30;
+	const TInt KInterval1hour   = 1;
+	const TInt KInterval2hours  = 2;
+	const TInt KInterval4hours  = 4;
+	const TInt KInterval8hours  = 8;
+	const TInt KInterval12hours = 12;		
+	const TInt KInterval24hours = 1;
+	const TInt KInterval2days   = 2;
+	const TInt KInterval4days   = 4;
+	const TInt KInterval7ays    = 7;
+	const TInt KInterval14days  = 14;
+	const TInt KInterval30days  = 30;
+	
+	    TInt ret = KIntervalManual;
+    
+    switch (aInterval)
+    	{
+    	case CAspSchedule::EIntervalManual:
+    	    ret = KIntervalManual;
+    	    break;
+    	case CAspSchedule::EInterval15Mins:
+    	    ret = KInterval15Mins;
+    	    break;
+    	case CAspSchedule::EInterval30Mins:
+    	    ret = KInterval30Mins;
+    	    break;
+    	case CAspSchedule::EInterval1hour:
+    	    ret = KInterval1hour;
+    	    break;
+    	case CAspSchedule::EInterval2hours:
+    	    ret = KInterval2hours;
+    	    break;
+    	case CAspSchedule::EInterval4hours:
+    	    ret = KInterval4hours;
+    	    break;
+		case CAspSchedule::EInterval8hours:
+    	    ret = KInterval8hours;
+    	    break;
+		case CAspSchedule::EInterval12hours:
+    	    ret = KInterval12hours;
+    	    break;
+		case CAspSchedule::EInterval24hours:
+    	    ret = KInterval24hours;
+    	    break;
+		case CAspSchedule::EInterval2days:
+    	    ret = KInterval2days;
+    	    break;
+		case CAspSchedule::EInterval4days:
+    	    ret = KInterval4days;
+    	    break;
+		case CAspSchedule::EInterval7days:
+    	    ret = KInterval7ays;
+    	    break;
+		case CAspSchedule::EInterval14days:
+    	    ret = KInterval14days;
+    	    break;
+		case CAspSchedule::EInterval30days:	
+    	    ret = KInterval30days;
+    	    break;
+
+			
+        default:
+            break;
+    	}
+    	
+    return ret;	
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::StartTime
+//
+// ----------------------------------------------------------------------------
+//
+TTsTime CAspSyncSchedule::StartTime(TInt aStartHour, TInt aInterval)
+	{
+
+	if (IntervalType(aInterval) == EDaily)
+		{
+	    TTime time = CAspSchedule::LocalStartTime(aStartHour);
+	    TTsTime tsTime(time, EFalse);
+        return tsTime;
+		}
+	
+	TTime time = CAspSchedule::UniversalStartTime(aStartHour);
+    TTsTime tsTime(time, ETrue);
+    return tsTime;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::GetPeakStartTimeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::GetPeakStartTimeL(CAspSchedule* aAspSchedule, TTime& aTime, TBool aHomeTime)
+	{
+
+	ipeakEntryList->Reset();
+	ipeakTaskList->Reset();
+	
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt peakHandle = aAspSchedule->PeakScheduleHandle();
+	
+	TInt err = iScheduler.GetScheduleL(peakHandle, state, *ipeakEntryList, *ipeakTaskList, tsTime);
+	User::LeaveIfError(err);
+	if (aHomeTime)
+		{
+		aTime = tsTime.GetLocalTime();	
+		}
+	else
+		{
+	    aTime = tsTime.GetUtcTime();		
+		}
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncSchedule::GetOffPeakStartTimeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::GetOffPeakStartTimeL(CAspSchedule* aAspSchedule, TTime& aTime, TBool aHomeTime)
+	{
+
+	ioffPeakEntryList->Reset();
+	ioffPeakTaskList->Reset();
+	
+	TTsTime tsTime;
+	TScheduleState2 state;
+	TInt offPeakHandle = aAspSchedule->OffPeakScheduleHandle();
+	
+	TInt err = iScheduler.GetScheduleL(offPeakHandle, state, *ioffPeakEntryList, *ioffPeakTaskList, tsTime);
+	User::LeaveIfError(err);
+	if (aHomeTime)
+		{
+		aTime = tsTime.GetLocalTime();	
+		}
+	else
+		{
+	    aTime = tsTime.GetUtcTime();		
+		}
+
+	}
+
+
+#ifdef _DEBUG
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogScheduleL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::LogScheduleL(CAspSchedule* aAspSchedule)
+	{
+
+	FLOG( _L("---- scheduler settings ----") );
+
+	TTsTime tsTime;
+	TTime time;
+	TScheduleState2 state;
+	TInt peakhandle = aAspSchedule->PeakScheduleHandle();
+	if (peakhandle != KErrNotFound )
+		{
+		FLOG( _L("---- Peak Time Sync Enabled -> Settings") );
+		ipeakEntryList->Reset();
+		ipeakTaskList->Reset();
+		TInt err = iScheduler.GetScheduleL(peakhandle, state, *ipeakEntryList, *ipeakTaskList, tsTime);
+		User::LeaveIfError(err);
+	
+		TScheduleEntryInfo2 info = (*ipeakEntryList)[0];
+	
+		TBuf<KBufSize> buf;
+	
+		FLOG(_L("peak schedule handle: %d"), peakhandle);
+	
+		LogInterval(info, buf);
+		FLOG(_L("peak interval: %S"), &buf);
+
+		LogIntervalType(info, buf);
+		FLOG(_L("peak interval type: %S"), &buf);
+	
+		LogTsTime(tsTime, buf);
+		FLOG(_L("peak sync start time: %S"), &buf);
+			
+		TTaskInfo taskInfo = (*ipeakTaskList)[0];
+		LogTaskInfo(taskInfo, buf);
+		FLOG(_L("peak task info: %S"), &buf);
+
+		}
+	TInt offPeakhandle = aAspSchedule->OffPeakScheduleHandle();
+	if (offPeakhandle != KErrNotFound )
+		{
+		FLOG( _L("---- Off-Peak Time Sync Enabled -> Settings") );
+		ioffPeakEntryList->Reset();
+	    ioffPeakTaskList->Reset();
+		TInt err = iScheduler.GetScheduleL(offPeakhandle, state, *ioffPeakEntryList, *ioffPeakTaskList, tsTime);
+		User::LeaveIfError(err);
+	
+		TScheduleEntryInfo2 info = (*ioffPeakEntryList)[0];
+	
+		TBuf<KBufSize> buf;
+	
+		FLOG(_L("off-peak schedule handle: %d"), peakhandle);
+	
+		LogInterval(info, buf);
+		FLOG(_L("off-peak interval: %S"), &buf);
+
+		LogIntervalType(info, buf);
+		FLOG(_L("off-peak interval type: %S"), &buf);
+	
+		LogTsTime(tsTime, buf);
+		FLOG(_L("off-peak sync start time: %S"), &buf);
+			
+		TTaskInfo taskInfo = (*ioffPeakTaskList)[0];
+		LogTaskInfo(taskInfo, buf);
+		FLOG(_L("off-peak task info: %S"), &buf);
+
+		}
+		
+	
+		
+	
+	FLOG( _L("---- scheduler settings ----") );
+
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogSchedule
+//
+// ----------------------------------------------------------------------------
+//
+TInt CAspSyncSchedule::LogSchedule(CAspSchedule* aAspSchedule)
+	{
+	TInt err = KErrNone;
+	TRAP(err, LogScheduleL(aAspSchedule));
+	
+	return err;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogTaskInfo
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::LogTaskInfo(TTaskInfo& aInfo, TDes& aText)
+	{
+	aText.Format(_L("name: %S, repeat: %d, id: %d, priority: %d"), 
+	             &aInfo.iName, aInfo.iRepeat, aInfo.iTaskId, aInfo.iPriority);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogIntervalType
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::LogIntervalType(TScheduleEntryInfo2& aInfo, TDes& aText)
+	{
+	aText = _L("unknown");
+	
+	TIntervalType type = aInfo.IntervalType();
+	
+	if (type == EDaily)
+		{
+		aText = _L("EDaily");
+		}
+	if (type == EHourly)
+		{
+		aText = _L("EHourly");
+		}
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogInterval
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSyncSchedule::LogInterval(TScheduleEntryInfo2& aInfo, TDes& aText)
+	{
+	TInt num = aInfo.Interval();
+	aText.Format(_L("interval: %d"), num);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSyncSchedule::LogTime
+//
+// ----------------------------------------------------------------------------
+//
+
+void CAspSyncSchedule::LogTsTime(TTsTime aTsTime, TDes& aText)
+	{
+	TBuf<64> buf1; TBuf<64> buf2;
+
+	TTime time = aTsTime.GetLocalTime();
+	TRAP_IGNORE(TUtil::GetDateTimeTextL(buf1, time));
+	time = aTsTime.GetUtcTime();
+	TRAP_IGNORE(TUtil::GetDateTimeTextL(buf2, time));
+	
+	aText.Format(_L("local: %S  utc: %S"), &buf1, &buf2);
+    }
+
+#endif //  _DEBUG
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspContentDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1203 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "AspContentDialog.h"
+#include "AspUtil.h"
+#include "AspDefines.h"
+#include "AspDialogUtil.h"
+#include "AspResHandler.h"
+#include "AspDebug.h"
+#include "AspSyncUtil.rh"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+#include <AknIconArray.h>   // for GulArray
+#include <featmgr.h>   // FeatureManager
+#include "AspSchedule.h"
+
+const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspContentDialog::ShowDialogL(TAspParam& aParam)
+	{
+	CAspContentDialog* dialog = CAspContentDialog::NewL(aParam);
+
+	return dialog->ExecuteLD(R_ASP_CONTENT_DIALOG);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspContentDialog* CAspContentDialog::NewL(TAspParam& aParam)
+    {
+    FLOG( _L("CAspContentDialog::NewL START") );
+    
+    CAspContentDialog* self = new (ELeave) CAspContentDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspContentDialog::NewL END") );
+    return(self);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::CAspContentDialog
+//
+//------------------------------------------------------------------------------
+//
+CAspContentDialog::CAspContentDialog(TAspParam& aParam)
+	{
+	iApplicationId = aParam.iApplicationId;
+	iProfile = aParam.iProfile;
+	iSyncSession = aParam.iSyncSession;
+	iContentList = aParam.iContentList;
+	iDialogParam = &aParam;
+	iDataProviderId = aParam.iDataProviderId;
+	
+	iDataStoreChanged = EFalse;
+	iMskEmpty = EFalse;
+	
+    __ASSERT_ALWAYS(iDataProviderId != KErrNotFound, TUtil::Panic(KErrGeneral));	
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iContentList, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+//
+//------------------------------------------------------------------------------
+//
+CAspContentDialog::~CAspContentDialog()
+	{
+    FLOG( _L("CAspContentDialog::~CAspContentDialog START") );
+	    
+    if (iSettingList)
+    	{
+    	iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+    	}
+
+	delete iStatusPaneHandler;
+	delete iLocalDataStores;
+	
+	if (iAvkonAppUi)
+		{
+		iAvkonAppUi->RemoveFromStack(this);
+		}
+		
+    FLOG( _L("CAspContentDialog::~CAspContentDialog END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentDialog::ConstructL()
+    {
+    FLOG( _L("CAspContentDialog::ConstructL START") );
+    
+	CAknDialog::ConstructL(R_ASP_CONTENT_DIALOG_MENU);
+	
+	iSettingEnforcement = TUtil::SettingEnforcementState();
+	
+    iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(KDefaultArraySize);
+	
+	iLocalDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	iContentList->GetLocalDatabaseList(iDataProviderId, iLocalDataStores);
+	
+	TInt count = iLocalDataStores->Count();
+	if (count == 0)
+		{
+		if (iDataProviderId == KUidNSmlAdapterEMail.iUid)
+			{
+			TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+			}
+		else
+			{
+			TDialogUtil::ShowErrorNoteL(R_ASP_LOG_ERR_LOCALDATABASE);
+			User::Leave(KErrNotFound);
+			}
+		}
+		
+	InitTaskDataL();
+
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	// store current navi pane
+    iStatusPaneHandler->StoreNavipaneL();
+
+	FLOG( _L("CAspContentDialog::ConstructL END") );
+    } 
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::ActivateL (from CCoeControl)
+//
+// Called by system when dialog is activated
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::CheckContentSettingL
+//
+// Check if the MSK label is correct for the context
+//------------------------------------------------------------------------------
+
+void CAspContentDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent)
+	{
+	
+	TInt curIndex = iListBox->CurrentItemIndex();
+	TInt count = iSettingList->Count();
+	CAspListItemData* lastItem = (*iSettingList)[--count];
+	
+	switch (aKeyEvent.iCode)
+		{
+		case EKeyUpArrow:
+			{
+				if (curIndex)
+				{
+					curIndex--;
+				}
+				else
+				{
+				    curIndex = lastItem->iIndex;
+				}
+			break;
+			}
+		case EKeyDownArrow:
+			{
+				if (curIndex == lastItem->iIndex)
+				{
+				curIndex = 0;
+				}
+				else
+				{
+				curIndex++;
+				}
+			break;
+			}
+		}	
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	if(curItem->iHidden == EVisibilityReadOnly)
+	{
+		UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY);
+	   	iMskEmpty = ETrue;
+	   	return;	
+	}
+	if(iMskEmpty)
+	{
+		UpdateMiddleSoftKeyLabelL(EAknSoftkeyEmpty,R_QTN_MSK_CHANGE);
+	   	iMskEmpty = EFalse;
+	}
+
+	}
+	
+//------------------------------------------------------------------------------
+// CAspContentDialog::UpdateMiddleSoftKeyLabelL 
+//
+// Update the MSK 
+//------------------------------------------------------------------------------
+	void CAspContentDialog::UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId)
+	{
+		ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,aCommandId );
+		HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
+
+		ButtonGroupContainer().AddCommandToStackL(
+		KMSKControlId,
+		aCommandId,
+		*middleSKText );
+		CleanupStack::PopAndDestroy( middleSKText );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+    
+	TInt dataProvider = DataProviderType();
+	if (dataProvider == EApplicationIdContact)
+		{
+		aContext.iContext = KDS_HLP_SETTINGS_CNT;
+		}
+	else if (dataProvider == EApplicationIdCalendar)
+		{
+		aContext.iContext = KDS_HLP_SETTINGS_CAL;
+		}
+	else if (dataProvider == EApplicationIdNote)
+		{
+		aContext.iContext = KDS_HLP_SETTINGS_NOTES;
+		}
+	else if (dataProvider == EApplicationIdSms)
+		{
+		aContext.iContext = KDS_HLP_SETTINGS_SMS;
+		}
+	else
+		{
+		aContext.iContext = KDS_HLP_MAIN_VIEW;  // unknown application
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::ProcessCommandL
+//
+// Handle menu commands.
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::ProcessCommandL( TInt aCommandId )
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+
+		case EAknCmdHelp:
+			{
+			TUtil::LaunchHelpAppL(iEikonEnv);
+            break;
+			}
+
+		case EAspMenuCmdChange:
+			{				
+			HandleOKL();
+
+			break;
+			}
+
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+
+		default:
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::OfferKeyEventL
+//
+// Handle key events.
+//------------------------------------------------------------------------------
+//
+TKeyResponse CAspContentDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+			case EKeyEnter:
+			case EKeyOK: // OK button
+				{
+				HandleOKL();
+				return EKeyWasConsumed;
+				}
+			case EKeyUpArrow:
+			case EKeyDownArrow:
+			    {
+			    	if(!iSettingEnforcement)
+				    {
+				    TRAPD(err ,CheckContentSettingL(aKeyEvent));
+		         	User::LeaveIfError(err);
+				    }
+			    break;
+			    }
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+		// save silently and quit application
+		TRAP_IGNORE(SaveSettingsL());
+		return ETrue;
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+		TInt index = CheckMandatoryFields();
+		if (index != KErrNotFound)
+			{
+			if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY))
+				{
+				iListBox->SetCurrentItemIndexAndDraw(index);
+				return EFalse; // leave dialog open
+				}
+			}
+		
+		TRAP_IGNORE(SaveSettingsL());
+		
+		return ETrue;
+		}
+		
+	if (aButtonId == EAknSoftkeyOpen||aButtonId == EAknSoftkeyEmpty )  // MSK
+        {
+        HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+		
+
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::PreLayoutDynInitL
+//
+// Called by system before the dialog is shown.
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::PreLayoutDynInitL()
+	{
+	iListBox = (CAknSettingStyleListBox*)Control(EAspContentDialog);
+	
+   	__ASSERT_ALWAYS(iListBox, TUtil::Panic(KErrGeneral));
+	
+	iListBox->SetListBoxObserver(this);
+	iListBox->CreateScrollBarFrameL(ETrue);
+	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                   CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	                   
+   	SetIconsL();	                   
+	
+    CreateSettingsListL();
+    UpdateListBoxL(iListBox, iSettingList);
+	TInt curIndex = iListBox->CurrentItemIndex();
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+	
+	if(iSettingEnforcement || curItem->iHidden == EVisibilityReadOnly)
+	{
+	UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY);	
+   		
+	}
+	
+	//Set title pane text
+	TInt index = iContentList->FindProviderIndex(iDataProviderId);
+	if (index != KErrNotFound)
+		{
+		TAspProviderItem& item = iContentList->ProviderItem(index);
+    	HBufC* hBuf = CAspResHandler::GetContentTitleLC(iDataProviderId, 
+    	                                                item.iDisplayName);
+	    iStatusPaneHandler->SetTitleL(hBuf->Des());
+	    CleanupStack::PopAndDestroy(hBuf);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::SetIconsL()
+    {
+    if (!iListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName, 
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspContentDialog::IconL(TAknsItemID aId, const TDesC& aFileName,
+                                   TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::DynInitMenuPaneL( TInt aResourceID, CEikMenuPane* aMenuPane)
+	{
+    if (aResourceID != R_ASP_CONTENT_DIALOG_MENU_PANE)
+		{
+		return;
+		}
+
+	if (iListBox->Model()->NumberOfItems() == 0)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		}
+		
+	CAspListItemData* item = GetItemForIndex(iListBox->CurrentItemIndex());
+
+	if (item->iHidden == EVisibilityReadOnly)
+	    {
+	    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+	    }
+	    
+	TInt provider = DataProviderType();
+
+	if (provider == KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
+		}
+	
+    if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
+		}
+
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::HandleListBoxEventL
+//
+// Handle listbox events.
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
+                                            TListBoxEvent aEventType)
+	{
+    switch ( aEventType )
+        {
+        case EEventItemDoubleClicked:
+            HandleOKL();
+            break;
+        default:
+           break;
+        }
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspContentDialog::HandleOKL
+//
+// Handle content parameter editing.
+//-----------------------------------------------------------------------------
+//
+void CAspContentDialog::HandleOKL()
+	{
+	CAspListItemData* item = GetItemForIndex(iListBox->CurrentItemIndex());
+	if (item->iHidden == EVisibilityReadOnly)
+    	{
+    	if(!iSettingEnforcement)
+    	{
+     	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+    	}
+     	else
+     	{
+     		TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);	
+     	}
+  		return;
+     	}
+
+	if (EditSettingItemL(*item))
+		{
+		SetVisibility();
+		UpdateListBoxL(iListBox, iSettingList);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::InitTaskDataL
+//
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::InitTaskDataL()
+	{
+	iContentList->ReadTaskL(iDataProviderId, iLocalDatabase, iRemoteDatabase,
+		                    iTaskEnabled, iSyncDirection);
+		                        
+   	if (iSettingEnforcement)
+		{
+		return;
+		}
+
+    // check that local database exists
+    if (iLocalDatabase.Length() > 0)
+    	{
+    	TInt pos = 0;
+    	if (iLocalDataStores->Find(iLocalDatabase, pos) != 0)
+    		{
+    		iLocalDatabase = KNullDesC; // local database not found
+    		iDataStoreChanged = ETrue;
+    		}
+    	}
+
+    if (iLocalDatabase.Length() == 0)
+    	{
+    	if (iDataProviderId == KUidNSmlAdapterEMail.iUid)
+    		{
+    		iContentList->UpdateDataProviderL(iDataProviderId);
+    		}
+    		
+	    TInt index = iContentList->FindProviderIndex(iDataProviderId);
+	    if (index != KErrNotFound)
+		    {
+		    TAspProviderItem& item = iContentList->ProviderItem(index);
+     		if (item.iDefaultDataStore.Length() > 0)
+			    {
+			    iLocalDatabase = item.iDefaultDataStore;
+			    iDataStoreChanged = ETrue;
+			    }
+		    }
+    	}
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::UpdateListBoxL(CEikTextListBox* aListBox,
+                                       CAspSettingList* aItemList)
+	{
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt index=0; index<count; index++ )
+		{
+	   	TBool convert = ETrue;
+	   	TBool isPCSuite=CAspProfile::IsPCSuiteProfile(iProfile);
+	   	TBool readOnly = iProfile->DeleteAllowed();
+
+		CAspListItemData* item = (*aItemList)[index];
+		TInt id=item->iItemId;
+		if(iSettingEnforcement)
+		{
+			if(id==EAspLocalDatabase ||id==EAspRemoteDatabase )
+			convert=EFalse;
+		}
+		else
+		{
+ 			   if(isPCSuite|| !readOnly)
+				{
+					if(id==EAspRemoteDatabase)
+					convert=EFalse;
+				}
+	
+		}
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	aListBox->HandleItemAdditionL();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::CreateSettingsListL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::CreateSettingsListL()
+	{
+	AddItemL(EAspLocalDatabase, R_ASP_SETT_LOCAL_DATABASE);
+	AddRemoteDatabaseL(iDataProviderId);
+
+	// write setting data into each CAspListItemData
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		InitSettingItemL((*iSettingList)[i]);
+		}
+
+    SetVisibility();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::AddItemL(TInt aItemId, TInt aResourceId)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(aResourceId);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentDialog::AddRemoteDatabaseL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspContentDialog::AddRemoteDatabaseL(TInt aDataProviderId)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+    TInt resId = CAspResHandler::RemoteDatabaseHeaderId(aDataProviderId);
+	item->SetHeaderL(resId);
+	item->iItemId = EAspRemoteDatabase;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentDialog::SetVisibility()
+	{
+    TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+    TBool readOnly = iProfile->DeleteAllowed();
+    	
+	Item(EAspLocalDatabase)->iHidden = EVisibilityNormal;
+	if (iLocalDataStores->Count() < 2)
+		{
+		if (iDialogParam->iDataProviderId != KUidNSmlAdapterEMail.iUid)
+			{
+			Item(EAspLocalDatabase)->iHidden = EVisibilityHidden;
+			}
+		}
+		
+	if (isPCSuite)
+		{
+		if (Item(EAspLocalDatabase)->iHidden == EVisibilityNormal)
+			{
+			if (iDialogParam->iDataProviderId != KUidNSmlAdapterEMail.iUid)
+				{
+				Item(EAspLocalDatabase)->iHidden = EVisibilityReadOnly;
+				}
+			}
+		
+		TInt provider = DataProviderType();
+	    if (provider != KErrNotFound)
+		    {
+		    Item(EAspRemoteDatabase)->iHidden = EVisibilityReadOnly;    
+		    }
+		}
+
+	if(!readOnly)
+		{
+		TInt provider = DataProviderType();
+	    if (provider != KErrNotFound)
+		    {
+		    Item(EAspRemoteDatabase)->iHidden = EVisibilityReadOnly;    
+		    }
+		}
+		
+    if (iSettingEnforcement)
+    	{
+    	SetAllReadOnly(); // profile database is locked
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::SetAllReadOnly
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentDialog::SetAllReadOnly()
+	{
+	TInt count = iSettingList->Count();
+
+	for (TInt i=0; i<count; i++ )
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		if (item->iHidden != EVisibilityHidden)
+			{
+			item->iHidden = EVisibilityReadOnly;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::InitSettingItemL
+// 
+// Constructs CAspListItemData for one setting.
+// -----------------------------------------------------------------------------
+//
+void CAspContentDialog::InitSettingItemL(CAspListItemData* aItem)
+	{
+	iBuf = KNullDesC;  // reset common buffer
+	
+	switch (aItem->iItemId)
+		{
+		case EAspLocalDatabase:
+			{
+    		aItem->SetValueL(iLocalDatabase);
+    		aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+    		
+    		aItem->iMaxLength = KAspMaxLocalNameLength;
+    		aItem->iLatinInput = ETrue;
+    		aItem->iItemType = CAspListItemData::ETypeLocalDatabase;
+			break;
+			}
+
+		case EAspRemoteDatabase:
+			{
+			aItem->SetValueL(iRemoteDatabase);
+			aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
+			
+			aItem->iMaxLength = KAspMaxRemoteNameLength;
+			aItem->iLatinInput = ETrue;
+			aItem->iMandatory = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeText;
+			break;
+			}
+
+        default:
+			break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::SaveSettingsL
+//
+// Save content settings.
+//------------------------------------------------------------------------------
+//
+void CAspContentDialog::SaveSettingsL()
+	{
+	if (iSettingEnforcement)
+		{
+		return;
+		}
+    	
+	TBool localDatabaseChanged = EFalse;
+	TBool remoteDatabaseChanged = EFalse;
+
+	TPtrC ptr1 = Item(EAspLocalDatabase)->Value();
+	if (ptr1.Compare(iLocalDatabase) != 0)
+		{
+		localDatabaseChanged = ETrue;
+		}
+		
+	TPtrC ptr2 = Item(EAspRemoteDatabase)->Value();
+	if (ptr2.Compare(iRemoteDatabase) != 0)
+		{
+		remoteDatabaseChanged = ETrue;
+		}
+	
+	if (remoteDatabaseChanged || localDatabaseChanged || iDataStoreChanged)
+		{
+		iLocalDatabase = Item(EAspLocalDatabase)->Value();
+	    iRemoteDatabase = Item(EAspRemoteDatabase)->Value();
+        
+   	    iContentList->CreateTaskL(iDataProviderId, iLocalDatabase, iRemoteDatabase,
+	                              iTaskEnabled, iSyncDirection);
+		                          
+        iContentList->InitAllTasksL(); // iContentList comes from main view		                          
+		}
+		
+#ifdef RD_DSUI_TIMEDSYNC
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	TInt profileId = schedule->ProfileId();
+	if (profileId == iProfile->ProfileId())
+		{
+		schedule->UpdateProfileSettingsL();
+		}
+	CleanupStack::PopAndDestroy(schedule);
+#endif
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::CheckMandatoryFields
+//
+// Check that mandatory fields are filled correctly.
+//------------------------------------------------------------------------------
+//
+TInt CAspContentDialog::CheckMandatoryFields()
+	{
+	if (iSettingEnforcement)
+		{
+		return KErrNotFound;
+		}
+
+    if (!iContentList->TaskEnabled(iDataProviderId))
+    	{
+   		return KErrNotFound; // not part of sync - no need to check mandatory
+    	}
+	
+    TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		if (item->iMandatory && item->IsEmpty() && (item->iHidden == EVisibilityNormal))
+			{
+			return item->iIndex;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	TBool ret = EFalse;
+	
+	switch (aItem.iItemType)
+		{
+		case CAspListItemData::ETypeText:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeList:
+			ret = EditSettingItemListL(aItem);
+		    break;
+		
+		case CAspListItemData::ETypeLocalDatabase:
+			ret = EditSettingItemLocalDatabaseL(aItem);
+			break;
+
+		default:
+		    break;
+
+		}
+
+    return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::EditSettingItemListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::EditSettingItemListL(CAspListItemData& aItem)
+	{
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = curSelection; 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::EditSettingItemTextL
+//
+// Edit text setting item.
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::EditSettingItemTextL(CAspListItemData& aItem)
+	{
+	TUtil::StrCopy(iBuf, aItem.Value());
+	
+    TBool ret = TDialogUtil::ShowTextEditorL(iBuf, aItem.Header(), 
+                aItem.iMandatory, aItem.iLatinInput, aItem.iMaxLength);
+   	if (ret)
+		{
+		aItem.SetValueL(iBuf);
+		}
+		
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::EditSettingItemLocalDatabaseL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::EditSettingItemLocalDatabaseL(CAspListItemData& aItem)
+	{
+	if (iLocalDataStores->Count() < 1)
+		{
+		if (iDataProviderId == KUidNSmlAdapterEMail.iUid)
+			{
+			TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+			}
+			
+		return EFalse;
+		}
+	
+	TInt curSelection = 0;
+	TInt countDatabase = iLocalDataStores->Count();
+	
+	while (iLocalDataStores->Find(iLocalDatabase, curSelection) && (curSelection < countDatabase))
+		{
+		curSelection++;
+		}
+	if (TDialogUtil::ShowListEditorL(iLocalDataStores, aItem.Header(), curSelection))
+		{
+		aItem.SetValueL((*iLocalDataStores)[curSelection]);
+		return ETrue;
+		}
+
+	return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentDialog::EditSettingItemYesNoL
+//
+// Change Yes/No value straight if ok key is pressed.
+//------------------------------------------------------------------------------
+//
+TBool CAspContentDialog::EditSettingItemYesNoL(CAspListItemData& aItem)
+	{
+	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	
+	if (aItem.iNumberData == EAspSettingDisabled)
+		{
+		aItem.iNumberData = EAspSettingEnabled;
+		}
+	else
+		{
+		aItem.iNumberData = EAspSettingDisabled;
+		}
+	
+	
+	// store localized setting text (Yes/No)
+	aItem.SetValueL( (*arr)[aItem.iNumberData] );
+
+	CleanupStack::PopAndDestroy(arr);
+	return ETrue;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspContentDialog::GetItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspContentDialog::GetItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspContentDialog::Item
+// 
+// Find item with aItemId (TAspConnectionSettingItem).
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspContentDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::DataProviderType
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentDialog::DataProviderType() const
+    {
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterContact.iUid)
+    	{
+    	return EApplicationIdContact;
+    	}
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterCalendar.iUid)
+    	{
+    	return EApplicationIdCalendar;
+    	}
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterEMail.iUid)
+    	{
+    	return EApplicationIdEmail;
+    	}
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterNote.iUid)
+    	{
+    	return EApplicationIdNote;
+    	}
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterSms.iUid)
+    	{
+    	return EApplicationIdSms;
+    	}
+	if (iDialogParam->iDataProviderId == KUidNSmlAdapterMMS.iUid)
+    	{
+    	return EApplicationIdMms;
+    	}
+    if (iDialogParam->iDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+    	{
+    	return EApplicationIdBookmarks;
+    	}
+
+    return KErrNotFound;
+    } 
+
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspContentListDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,493 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+#include "AspContentListDialog.h"
+#include "AspContentDialog.h"
+#include "AspDialogUtil.h"
+#include "AspSyncUtil.rh"  // for menu command ids
+#include "AspUtil.h"
+#include "AspDebug.h"
+#include "AspDefines.h"
+#include "AspResHandler.h"
+#include <csxhelp/ds.hlp.hrh>
+
+
+#include <AspSyncUtil.mbg>  // for bitmap enumerations
+#include <akniconarray.h>  // GulArray
+#include <FeatMgr.h>   // FeatureManager
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspContentListDialog::ShowDialogL(const TAspParam& aParam)
+	{
+    CAspContentListDialog* dialog = CAspContentListDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_CONTENT_LIST_DIALOG);
+
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspContentListDialog* CAspContentListDialog::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspContentListDialog::NewL START") );
+
+    CAspContentListDialog* self = new (ELeave) CAspContentListDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspContentListDialog::NewL END") );
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::CAspContentListDialog
+// 
+// -----------------------------------------------------------------------------
+CAspContentListDialog::CAspContentListDialog(const TAspParam& aParam) 
+    {
+	iApplicationId = aParam.iApplicationId;
+	iProfile = aParam.iProfile;
+	iSyncSession = aParam.iSyncSession;
+	
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));		
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+void CAspContentListDialog::ConstructL()
+    {
+    FLOG( _L("CAspContentListDialog::ConstructL START" ) );
+
+	// contruct menu for our dialog
+	CAknDialog::ConstructL(R_ASP_CONTENT_LIST_DIALOG_MENU);
+
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+
+
+    TAspParam param(iApplicationId, iSyncSession);
+	param.iProfile = iProfile;
+	param.iMode = CAspContentList::EInitAll;
+
+	iContentList = CAspContentList::NewL(param);
+
+    iStatusPaneHandler->SetTitleL(R_ASP_CONTENT_LIST_DIALOG_TITLE);
+
+	FLOG( _L("CAspContentListDialog::ConstructL END") );
+    } 
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+CAspContentListDialog::~CAspContentListDialog()
+    {
+    FLOG( _L("CAspContentListDialog::~CAspContentListDialog START") );
+    
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	delete iStatusPaneHandler;
+	delete iContentList;
+	
+	FLOG( _L("CAspContentListDialog::~CAspContentListDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::ActivateL (from CCoeControl)
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspContentListDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspContentListDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	//aContext.iContext = KDS_HLP_APPS_VIEW;    
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspContentListDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+        case EAspMenuCmdEdit:
+			{
+			ShowContentL();
+			break;
+			}
+        
+        case EAspMenuCmdHelp:
+			{
+			TUtil::LaunchHelpAppL(iEikonEnv);
+			break;
+			}
+
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:
+			{
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspContentListDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+		// exit going on - must return true.
+		return ETrue;
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+		return ETrue;
+		}
+
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentListDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspContentListDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyOK:
+				{
+				ShowContentL();
+				return EKeyWasConsumed;
+				}
+    		
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+			    return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+				}
+ 
+			default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::PreLayoutDynInitL
+//
+// Called by framework before dialog is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspContentListDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknDoubleLargeStyleListBox*) ControlOrNull (EAspContentListDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+	
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+
+	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+
+ 	// NOTE: icons must be appended in correct order (TAspContentListDialogIconIndex)
+ 	icons->AppendL(IconL(KAknsIIDQgnPropSmlSyncServer, bitmapName, EMbmAspsyncutilQgn_prop_sml_sync_server, EMbmAspsyncutilQgn_prop_sml_sync_server_mask));
+	icons->AppendL(IconL(KAknsIIDQgnPropSmlSyncToServer, bitmapName, EMbmAspsyncutilQgn_prop_sml_sync_to_server, EMbmAspsyncutilQgn_prop_sml_sync_to_server_mask));
+	icons->AppendL(IconL(KAknsIIDQgnPropSmlSyncFromServer, bitmapName, EMbmAspsyncutilQgn_prop_sml_sync_from_server, EMbmAspsyncutilQgn_prop_sml_sync_from_server_mask));
+	icons->AppendL(IconL(KAknsIIDQgnPropSmlSyncOff, bitmapName, EMbmAspsyncutilQgn_prop_sml_sync_off, EMbmAspsyncutilQgn_prop_sml_sync_off_mask));
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+
+	UpdateListBoxL();
+	
+	iSettingListBox->UpdateScrollBarsL();
+	iSettingListBox->ScrollBarFrame()->MoveVertThumbTo(0);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspContentListDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::DynInitMenuPaneL
+//
+// Called by framework before menu is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspContentListDialog::DynInitMenuPaneL(TInt aResourceID, 	CEikMenuPane* /*aMenuPane*/)
+	{
+    if (aResourceID != R_ASP_CONTENT_LIST_DIALOG_MENU_PANE)
+		{
+		return;
+		}
+
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdHelp);
+		}
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::HandleListBoxEventL (from MEikListBoxObserver)
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentListDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/)
+	{
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspContentListDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspContentListDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::UpdateListBoxL
+//	
+// -----------------------------------------------------------------------------
+//
+void CAspContentListDialog::UpdateListBoxL()
+	{
+	TInt iconIndex = EIconNotDefined;
+	
+	CAknDoubleLargeStyleListBox* listBox = ListBox();
+	CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray();
+	items->Reset();
+    listBox->ItemDrawer()->ClearAllPropertiesL();
+	
+	TInt count = iContentList->ProviderCount();
+
+	for (TInt i=0; i<count; i++)
+		{
+		HBufC* firstLine = NULL;
+		HBufC* secondLine = NULL;
+				
+		iconIndex = EIconNotDefined;
+		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
+		
+		firstLine = CAspResHandler::GetContentNameLC(providerItem.iDataProviderId, providerItem.iDisplayName);
+		
+		TInt index = iContentList->FindTaskIndexForProvider(providerItem.iDataProviderId);
+		
+		if (index != KErrNotFound)
+			{
+			TAspTaskItem& task = iContentList->TaskItem(index);
+			TInt status = iContentList->CheckMandatoryTaskDataL(task.iTaskId);
+	        if (status == EMandatoryOk)
+			    {
+			    secondLine = CAspResHandler::ReadLC(R_ASP_DEFINED);
+                if (task.iSyncDirection == ESyncDirectionTwoWay)
+				    {
+				    iconIndex = EIconBothDirections;
+				    }
+			    if (task.iSyncDirection == ESyncDirectionOneWayFromDevice)
+				    {
+				    iconIndex = EIconDeviceToServer;
+				    }
+			    if (task.iSyncDirection == ESyncDirectionOneWayIntoDevice)
+				    {
+				    iconIndex = EIconServerToDevice;
+				    }
+			    }
+			else
+				{
+				secondLine = CAspResHandler::ReadLC(R_ASP_NOT_DEFINED);
+				}
+			}
+		else
+			{
+			secondLine = CAspResHandler::ReadLC(R_ASP_NOT_DEFINED);
+			}
+		
+		TPtr ptr1 = firstLine->Des();
+		AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr1);
+		TPtr ptr2 = secondLine->Des();
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr2);
+
+		HBufC* hBuf = NULL;
+		hBuf = TDialogUtil::ConstructListBoxItemLC(firstLine->Des(), secondLine->Des(), iconIndex);
+
+		items->AppendL(hBuf->Des());
+		
+		CleanupStack::PopAndDestroy(hBuf);
+		CleanupStack::PopAndDestroy(secondLine);
+		CleanupStack::PopAndDestroy(firstLine);
+		}
+
+	listBox->HandleItemAdditionL();
+
+	if (listBox->Model()->NumberOfItems() == 0)
+		{
+		User::Leave(KErrNotFound);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::ShowContentL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentListDialog::ShowContentL()
+	{
+ 	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfile = iProfile;
+    param.iDataProviderId = SelectedProvider().iDataProviderId;
+    param.iSyncTaskId = KErrNotFound;
+
+    CAspContentDialog::ShowDialogL(param);
+     
+    iContentList->InitAllTasksL();
+    
+	UpdateListBoxL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::ListBox
+//
+// -----------------------------------------------------------------------------
+//
+CAknDoubleLargeStyleListBox* CAspContentListDialog::ListBox()
+	{
+	__ASSERT_DEBUG(iSettingListBox, TUtil::Panic(KErrGeneral));
+
+	return iSettingListBox;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::SelectedProvider
+//
+// -----------------------------------------------------------------------------
+//
+TAspProviderItem& CAspContentListDialog::SelectedProvider()
+	{
+	TInt index = ListBox()->CurrentItemIndex();
+
+	return iContentList->ProviderItem(index);
+	}
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspDbNotifier.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,586 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 "AspDbNotifier.h"
+#include "AspDebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+/******************************************************************************
+ * class TAspDbEvent
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// TAspDbEvent::TAspDbEvent
+//
+// -----------------------------------------------------------------------------
+//
+TAspDbEvent::TAspDbEvent(TInt aType)
+ : iType(aType), iProfileId(KErrNotFound), iError(KErrNone)
+	 {
+	 }
+
+
+
+/******************************************************************************
+ * class CAspDbNotifier
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::CAspDbNotifier
+//
+// -----------------------------------------------------------------------------
+//
+CAspDbNotifier::CAspDbNotifier(const TAspParam& aParam, MAspDbEventHandler* aHandler)
+ : iSyncSession(aParam.iSyncSession), iHandler(aHandler)
+ 	{
+ 	iSessionEventRequested = EFalse;
+ 	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspDbNotifier* CAspDbNotifier::NewL(const TAspParam& aParam, MAspDbEventHandler* aHandler)
+	{
+	CAspDbNotifier* self = new (ELeave) CAspDbNotifier(aParam, aHandler);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::ConstructL()
+	{
+    FLOG( _L("CAspDbNotifier::ConstructL START") );
+    
+	iActiveCaller = CAspActiveCaller::NewL(this);
+    
+    FLOG( _L("CAspDbNotifier::ConstructL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspDbNotifier::~CAspDbNotifier()
+	{		
+    FLOG( _L("CAspDbNotifier::~CAspDbNotifier START") );
+    
+	delete iActiveCaller;
+	iList.Close();
+    
+    if (iSessionEventRequested)
+    	{
+    	Session().CancelEvent();
+    	}
+    	
+    if (iDestroyedPtr)
+        {
+        *iDestroyedPtr = ETrue;
+        iDestroyedPtr = NULL;
+        }
+
+    FLOG( _L("CAspDbNotifier::~CAspDbNotifier END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::RequestL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::RequestL()
+	{
+	if (!iSessionEventRequested)
+		{
+		Session().RequestEventL(*this);  // request MSyncMLEventObserver events
+		iSessionEventRequested = ETrue;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::OnSyncMLSessionEvent (from MSyncMLEventObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt aAdditionalData)
+	{
+    FLOG( _L("CAspDbNotifier::OnSyncMLSessionEvent START") );
+
+#ifdef _DEBUG
+    LogSessionEvent(aEvent, aIdentifier, aError);
+#endif
+
+    TRAP_IGNORE(HandleSessionEventL(aEvent, aIdentifier, aError, aAdditionalData));
+	
+    FLOG( _L("CAspDbNotifier::OnSyncMLSessionEvent END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::HandleSessionEventL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::HandleSessionEventL(TEvent aEvent, TInt aIdentifier, TInt aError, TInt /*aAdditionalData*/)
+	{
+	if (aEvent != MSyncMLEventObserver::EProfileCreated &&
+	    aEvent != MSyncMLEventObserver::EProfileChanged &&
+	    aEvent != MSyncMLEventObserver::EProfileDeleted &&
+	    aEvent != MSyncMLEventObserver::EServerTerminated)
+		{
+		return; // setting dialog does not need this event
+		}
+	
+	TAspDbEvent event(aEvent);
+
+    event.iError = aError;
+		
+	if (aEvent == MSyncMLEventObserver::EProfileCreated || 
+	    aEvent == MSyncMLEventObserver::EProfileChanged ||
+	    aEvent == MSyncMLEventObserver::EProfileDeleted )
+		{
+		event.iProfileId = aIdentifier;
+		}
+	else
+		{
+		event.iProfileId = KErrNotFound;
+		}
+	
+	iList.AppendL (event);
+	
+	CallObserverWithDelay();
+	RequestL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::CreateUpdateEventL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::CreateUpdateEventL(TInt aIdentifier, TInt aError)
+	{
+	TAspDbEvent event(MSyncMLEventObserver::EProfileChanged);
+	event.iProfileId = aIdentifier;
+    event.iError = aError;
+	
+	iList.Reset();
+	iList.AppendL (event);
+	
+	CallObserverWithDelay();
+	RequestL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::CheckUpdateEventL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::CheckUpdateEventL()
+	{
+	if (iList.Count() == 0)
+		{
+		return; // no database events - no need to update UI
+		}
+		
+	CallObserverWithDelay();
+	RequestL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::SetDisabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::SetDisabled(TBool aDisable)
+	{
+    iDisabled = aDisable;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::Reset
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::Reset()
+	{
+    iDisabled = EFalse;
+	iList.Reset();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::EventCount
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspDbNotifier::EventCount()
+	{
+	return iList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::Event
+//
+// -----------------------------------------------------------------------------
+//
+TAspDbEvent CAspDbNotifier::Event(TInt aIndex)
+	{
+	__ASSERT_DEBUG(aIndex>=0 && aIndex<iList.Count(), TUtil::Panic(KErrGeneral));
+
+	return iList[aIndex];
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::Session
+// 
+// -----------------------------------------------------------------------------
+//
+RSyncMLSession& CAspDbNotifier::Session()
+	{
+	__ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrGeneral));
+	
+	return *iSyncSession;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::CallObserverWithDelay
+//
+// This is needed to avoid unnecessary observer calls (eg. in case 10 events are
+// reported in short time only last is reported to observer). 
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::CallObserverWithDelay(void)
+	{
+    FLOG( _L("CAspDbNotifier::CallObserverWithDelay START") );
+    
+    iActiveCaller->Cancel();
+	iActiveCaller->Start(KErrNone, KListBoxUpdateDelay);
+		
+    FLOG( _L("CAspDbNotifier::CallObserverWithDelay END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::CallObserver
+//
+// this function investigates received events from last observer call
+// and calls observer to inform UI what to do. 
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::CallObserver()
+	{
+    FLOG( _L("CAspDbNotifier::CallObserver START") );
+	
+	TAspDbEvent event(EUpdateAll);
+
+	//
+	// check for critical error
+	//
+	if (FindCloseEvent() != KErrNotFound)
+		{
+		event.iType = EClose;
+		TRAP_IGNORE(iHandler->HandleDbEventL(event));
+		
+		FLOG( _L("CAspDbNotifier::CallObserver END") );
+		return; // some database problem - UI should close
+		}
+	
+	
+	//
+	// check if only one profile has changed
+	//
+	TInt index = FindSingleProfileEvent();
+	if (index != KErrNotFound)
+		{
+		TAspDbEvent& e = iList[index];
+        event.iProfileId = e.iProfileId; 
+        
+        event.iType = EUpdate;
+        if (ProfileDeleted())
+			{
+			event.iType = EDelete;
+			}
+	
+		TRAP_IGNORE(iHandler->HandleDbEventL(event));
+		
+        FLOG( _L("CAspDbNotifier::CallObserver END") );
+        return;
+		}
+	
+		
+	//
+	// check if 2 or more profiles have changed
+	//
+	if (FindProfileEvent() != KErrNotFound)
+		{
+	    event.iType = EUpdateAll;
+    	TRAP_IGNORE(iHandler->HandleDbEventL(event));
+	
+        FLOG( _L("CAspDbNotifier::CallObserver END") );
+        return;
+    	}
+    
+    FLOG( _L("CAspDbNotifier::CallObserver END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::FindCloseEvent
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspDbNotifier::FindCloseEvent()
+	{
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspDbEvent& event = iList[i];
+		if (event.iType == MSyncMLEventObserver::EServerTerminated)
+			{
+			return i;
+			}
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::FindProfileEvent
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspDbNotifier::FindProfileEvent()
+	{
+	TInt count = iList.Count();
+
+    for (TInt i=0; i<count; i++)
+		{
+		TAspDbEvent& event = iList[i];
+		if (event.iProfileId != KErrNotFound)
+			{
+			return i;
+			}
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::FindSingleProfileEvent
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspDbNotifier::FindSingleProfileEvent()
+	{
+	TInt count = iList.Count();
+
+	// find out whether list contains update events for one profile only
+	for (TInt i=0; i<count; i++)
+		{
+		TAspDbEvent& event = iList[i];
+		if (event.iProfileId != KErrNotFound && IsUniqueProfileId(event.iProfileId))
+			{
+			return i;
+        	}
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::ProfileDeleted
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspDbNotifier::ProfileDeleted()
+	{
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspDbEvent& event = iList[i];
+		if (event.iType == MSyncMLEventObserver::EProfileDeleted)
+			{
+			return ETrue;
+			}
+		}
+
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::IsUniqueProfileId
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspDbNotifier::IsUniqueProfileId(TInt aId)
+	{
+	TInt count = iList.Count();
+
+    for (TInt i=0; i<count; i++)
+		{
+		TAspDbEvent& event = iList[i];
+		if (event.iProfileId != KErrNotFound && event.iProfileId != aId)
+			{
+			return EFalse;
+			}
+		}
+
+	return ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspDbNotifier::HandleActiveCallL (from MAspActiveCallerObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::HandleActiveCallL(TInt /*aCallId*/)
+	{
+    FLOG( _L("CAspDbNotifier::HandleActiveCallL START") );
+
+	if (iDisabled)
+		{
+		FLOG( _L("CAspDbNotifier::HandleActiveCallL: event observing disabled") );
+		FLOG( _L("CAspDbNotifier::HandleActiveCallL END") );
+		return;  // UI has disabled notifications
+		}
+
+    TBool destroyed(EFalse);
+    iDestroyedPtr = &destroyed;
+
+	CallObserver();
+	
+    if (!destroyed)   // destructor sets this to ETrue
+        {
+    	Reset();
+    	iDestroyedPtr = NULL;
+        }
+	
+    FLOG( _L("CAspDbNotifier::HandleActiveCallL END") );
+	}
+
+
+
+#ifdef _DEBUG
+
+// -----------------------------------------------------------------------------
+// LogSessionEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::LogSessionEvent(TEvent& aEvent, TInt aIdentifier, TInt aError)
+	{
+    TBuf<KBufSize> eventStr;
+    GetSyncEventText(eventStr, aEvent);
+
+	if (aError == KErrNone)
+		{
+		FTRACE( RDebug::Print(_L("event='%S' id=%d"), &eventStr, aIdentifier) );
+		}
+	else
+		{
+		FTRACE( RDebug::Print(_L("### event='%S' id=%d err=%d ###"), &eventStr, aIdentifier, aError) );
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// GetSyncEventText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspDbNotifier::GetSyncEventText(TDes& aText, MSyncMLEventObserver::TEvent aEvent)
+	{
+    aText = _L("Unknown");
+    		
+	if (aEvent == MSyncMLEventObserver::EJobStart)
+		{
+		aText = _L("EJobStart");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobStartFailed)
+		{
+		aText = _L("EJobStartFailed");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobStop)
+		{
+		aText = _L("EJobStop");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobRejected)
+		{
+		aText = _L("EJobRejected");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileCreated)
+		{
+		aText = _L("EProfileCreated");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileChanged)
+		{
+		aText = _L("EProfileChanged");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileDeleted)
+		{
+		aText = _L("EProfileDeleted");
+		}
+	if (aEvent == MSyncMLEventObserver::ETransportTimeout)
+		{
+		aText = _L("ETransportTimeout");
+		}
+	if (aEvent == MSyncMLEventObserver::EServerSuspended)
+		{
+		aText = _L("EServerSuspended");
+		}
+	if (aEvent == MSyncMLEventObserver::EServerTerminated)
+		{
+		aText = _L("EServerTerminated");
+		}
+	}
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspDialogUtil.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1955 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspDialogUtil.h"
+#include "AspUtil.h"
+#include "AspSchedule.h"
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+
+#include <aknnavilabel.h>
+#include <akntitle.h>           // CAknTitlePane
+#include <akncontext.h>         // CAknTitlePane
+#include <aknnotewrappers.h>    // CAknInformationNote
+#include <eikmenup.h>           // CEikMenuPane
+#include <aknlists.h>           // CAknSingleHeadingPopupMenuStyleListBox
+
+#include <aknmfnesettingpage.h>         // CAknDateSettingPage
+#include <aknradiobuttonsettingpage.h>  // CAknRadioButtonSettingPage
+#include <akntextsettingpage.h>         // CAknIntegerSettingPage
+#include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
+#include <AknIndicatorContainer.h>
+
+#include <AknIconArray.h>   // for GulArray
+#include <gulicon.h>
+
+#include "AspSettingDialog.h"
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+
+/*******************************************************************************
+ * class TDialogUtil
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowTextQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowTextQueryL(const TDesC& aTitle, TDes& aText, TInt aMaxLength)
+	{
+	CAknTextQueryDialog* query = CAknTextQueryDialog::NewL(aText);
+	CleanupStack::PushL(query);
+	query->SetPromptL(aTitle);
+	if (aMaxLength > 0)
+		{
+		query->SetMaxLength(aMaxLength);
+		}
+    CleanupStack::Pop(query);		
+
+	query->ExecuteLD(R_ASP_TEXT_QUERY);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowMessageQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowMessageQueryL(const TDesC& aTitle, const TDesC& aText)
+	{
+	TPtrC ptr = aText;
+	CAknMessageQueryDialog* query = CAknMessageQueryDialog::NewL(ptr);
+	query->PrepareLC(R_ASP_MESSAGE_QUERY);
+	_LIT(KEmpty, " ");
+	if (aTitle.Compare(KEmpty) != 0 )
+		{
+		CAknPopupHeadingPane* headingPane = query->Heading();
+		headingPane->SetTextL(aTitle);
+		}
+	query->RunLD();
+	}
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowAutoSyncMessageQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowAutoSyncMessageQueryL(const TDesC& aText)
+	{
+	TPtrC ptr = aText;
+	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_MAIN_AUTO_ERROR_LOG_LINK);
+	CAknMessageQueryDialog* query = CAknMessageQueryDialog::NewL(ptr);
+	CleanupStack::PushL(query);
+
+	TCallBack LogView(TDialogUtil::ShowAutoSyncLogL);
+	query->SetLink(LogView);
+    query->SetLinkTextL(hBuf->Des());
+	
+	//CAknPopupHeadingPane* headingPane = query->Heading();
+	//headingPane->SetTextL(aTitle);
+
+	CleanupStack::Pop(query);
+	query->ExecuteLD(R_ASP_MESSAGE_QUERY);
+
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowMessageQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowMessageQueryL(const TDesC& aTitle, TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+	ShowMessageQueryL(aTitle, hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+	
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowConfirmationQueryL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowConfirmationQueryL(const TDesC& aText)
+	{
+	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
+	TBool ret = queryDialog->ExecuteLD(R_ASP_CONFIRMATION_QUERY, aText);
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowRoamingConfirmationQueryL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowRoamingConfirmationQueryL(const TDesC& aText)
+    {
+    CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
+    TBool ret = queryDialog->ExecuteLD(R_ASP_ROAMING_CONFIRMATION_QUERY, aText);
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowRoamingConfirmationQueryL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowRoamingConfirmationQueryL(TInt aResource)
+    {
+    HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+    TBool ret = ShowRoamingConfirmationQueryL(hBuf->Des());
+    CleanupStack::PopAndDestroy(hBuf);
+    return ret;
+    }
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowConfirmationQueryL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowConfirmationQueryL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+	TBool ret = ShowConfirmationQueryL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowInformationQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowInformationQueryL(const TDesC& aText)
+	{
+	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
+	queryDialog->ExecuteLD(R_ASP_INFORMATION_QUERY, aText);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowInformationQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowInformationQueryL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+	ShowInformationQueryL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowInformationNoteL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowInformationNoteL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+    ShowInformationNoteL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowInformationNoteL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowInformationNoteL(const TDesC& aText)
+	{
+	CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote(ETrue);
+	queryDialog->ExecuteLD(aText);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowErrorNoteL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowErrorNoteL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+	ShowErrorNoteL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowErrorNoteL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowErrorNoteL(const TDesC& aText)
+	{
+	CAknErrorNote* errorNote = new (ELeave) CAknErrorNote(ETrue);
+	errorNote->ExecuteLD(aText);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowErrorQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowErrorQueryL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+	ShowErrorQueryL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowErrorQueryL
+//
+//------------------------------------------------------------------------------
+//
+void TDialogUtil::ShowErrorQueryL(const TDesC& aText)
+	{
+	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
+	queryDialog->ExecuteLD(R_ASP_ERROR_QUERY, aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowListQueryL
+// 
+// -----------------------------------------------------------------------------
+TBool TDialogUtil::ShowListQueryL(const TDesC& aTitle, CDesCArray* aList, TInt* aSelectedIndex)
+	{
+	CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog(aSelectedIndex);
+	CleanupStack::PushL(query);
+
+	query->PrepareLC(R_ASP_LIST_QUERY);
+	query->SetItemTextArray(aList);
+	query->SetOwnershipType(ELbmDoesNotOwnItemArray);
+	CAknPopupHeadingPane* headingPane = query->QueryHeading();
+	headingPane->SetTextL(aTitle);
+	
+	CleanupStack::Pop(query);
+
+	return query->RunLD();
+	}
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowListQueryIconL
+//
+//------------------------------------------------------------------------------
+TBool TDialogUtil::ShowListQueryIconL(const TDesC& aTitle, CDesCArray* aList, TInt* aSelectedIndex)
+	{
+	  
+	 CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog(aSelectedIndex);
+	 CleanupStack::PushL(query);
+	 query->PrepareLC(R_ASP_LIST_APP_QUERY);
+	 
+	 
+	 query->SetItemTextArray(aList);
+	 query->SetOwnershipType(ELbmOwnsItemArray);
+	 
+	 CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(1);
+	 CleanupStack::PushL(iconList);
+	 
+ 	 TFileName bitmapName;
+ 	 CAspResHandler::GetBitmapFileName(bitmapName);
+ 	 //renders Qgn_Prop_Sml_New icon
+	 iconList->AppendL(CreateIconL(KAknsIIDQgnPropSmlNew, bitmapName, 
+	                     EMbmAspsyncutilQgn_prop_sml_new,
+	                     EMbmAspsyncutilQgn_prop_sml_new_mask) );
+	 query->SetIconArrayL(iconList);
+	 CAknPopupHeadingPane* headingPane = query->QueryHeading();
+ 	 headingPane->SetTextL(aTitle);
+ 	  
+	 CleanupStack::Pop(iconList);
+	 CleanupStack::Pop(query);
+	 return query->RunLD();
+	}
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowListQueryL
+// 
+// -----------------------------------------------------------------------------
+TBool TDialogUtil::ShowListQueryL(TInt aTitle, CDesCArray* aList, TInt* aSelectedIndex)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aTitle);
+
+    TBool ret = ShowListQueryL(hBuf->Des(), aList, aSelectedIndex);
+   	CleanupStack::PopAndDestroy(hBuf);
+   	
+   	return ret;
+	}
+
+//------------------------------------------------------------------------------
+//TDialogUtil::ShowListQueryIconL
+//
+//------------------------------------------------------------------------------
+TBool TDialogUtil::ShowListQueryIconL(TInt aTitle, CDesCArray* aList, TInt* aSelectedIndex)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aTitle);
+
+    TBool ret = ShowListQueryIconL(hBuf->Des(), aList, aSelectedIndex);
+   	CleanupStack::PopAndDestroy(hBuf);
+   	
+   	return ret;
+	}
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowProfileQueryL
+// 
+// -----------------------------------------------------------------------------
+TBool TDialogUtil::ShowProfileQueryL(CAspProfileList* aList, TInt& aId, TInt aResource)
+	{
+	aId = KErrNotFound;
+	
+	CDesCArray* arr = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	CleanupStack::PushL(arr);
+
+	TInt count = aList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& profile = aList->Item(i);
+		arr->AppendL(profile.iProfileName);
+		}
+
+    TInt index=KErrNotFound;
+	TBool ret = ShowListQueryL(aResource, arr, &index);
+	
+	if (ret)
+		{
+	    TAspProfileItem& profile = aList->Item(index);
+	    aId = profile.iProfileId;
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+//------------------------------------------------------------------------------
+//TDialogUtil::ShowProfileQueryAppL
+//
+//-----------------------------------------------------------------------------
+
+TBool TDialogUtil::ShowProfileQueryAppL(CAspProfileList* aList, TInt& aId, TInt aResource,TInt &index1)
+{
+	aId = KErrNotFound;
+	
+	CDesCArray* arr = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	CleanupStack::PushL(arr);
+      
+    
+	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_SELECT_PROFILE_CREATE_NEW);
+    TPtr ptr = hBuf->Des();
+  
+    //"%d\t%S" for formatting the icon and text data in the query dialog 
+   	 _LIT(KListItemFormat,"%d\t%S");
+	 TBuf<KBufSize> item;
+     item.Format(KListItemFormat,0 , &ptr);
+	 arr->AppendL(item);
+   	 CleanupStack::PopAndDestroy(hBuf);
+       
+    
+	 TInt count = aList->Count();
+	 for (TInt i=0; i< count; i++)
+		{
+		TAspProfileItem& profile = aList->Item(i);
+		//"\t%S" no need of keeping icon for profile list
+		_LIT(KListItemFormat,"\t%S");
+		HBufC* hBuf1=TUtil::StrConversion(profile.iProfileName);
+		TPtr ptr1=hBuf1->Des();
+		item.Format(KListItemFormat,&ptr1);
+		CleanupStack::PopAndDestroy(hBuf1);
+	    arr->AppendL(item);
+		}
+		
+	
+	TInt index=KErrNotFound;
+	TBool ret = ShowListQueryIconL(aResource, arr, &index);
+
+	if (ret)
+		{
+		
+		  if(index==0) //to check if R_ASP_SELECT_PROFILE_CREATE_NEW is selected
+				{
+	   				 ret=EFalse;
+	   				 index1=1;
+	    			 CleanupStack::Pop(arr);
+					 return ret;
+				}
+		
+	    TAspProfileItem& profile = aList->Item(index-1);
+	    aId = profile.iProfileId;
+	    
+		}
+
+	CleanupStack::Pop(arr);
+	return ret;
+}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::DeleteMenuItem
+//
+// -----------------------------------------------------------------------------
+//
+void TDialogUtil::DeleteMenuItem(CEikMenuPane* aMenuPane, TInt aCommandId)
+	{
+	TInt pos=KErrNotFound;
+    if (aMenuPane->MenuItemExists(aCommandId, pos))
+		{
+		aMenuPane->DeleteMenuItem(aCommandId);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::CreateIconL
+//
+// Constructs an independent CGulIcon object with fallback support.
+// If no matching item (aId) is found in the currently active skin,
+// attempts to construct the item using the given file (last 3 parameters).
+// -----------------------------------------------------------------------------
+//
+CGulIcon* TDialogUtil::CreateIconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId)
+	{
+    CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aId, aFileName, aFileBitmapId, aFileMaskId);
+	return icon;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::CreateImageL
+//
+// -----------------------------------------------------------------------------
+//
+CEikImage* TDialogUtil::CreateImageLC(TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId)
+	{
+	CFbsBitmap* bitmap1 = NULL;
+	CFbsBitmap* bitmap2 = NULL;
+	
+	CEikImage* image = new (ELeave) CEikImage;
+	CleanupStack::PushL(image);
+
+	AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), aId, bitmap1, bitmap2, aFileName, aFileBitmapId, aFileMaskId);
+	image->SetPicture(bitmap1, bitmap2);
+	CleanupStack::Pop(2); // bitmap1 bitmap2
+
+	return image;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ConstructListBoxItemL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* TDialogUtil::ConstructListBoxItemLC(const TDesC& aFirstLine, const TDesC& aSecondLine, TInt /*aIndex*/)
+	{
+    _LIT(KFormat, "%d\t%S\t%S");
+	
+	TInt len = aFirstLine.Length() + aSecondLine.Length() + KBufSize16;
+	
+	HBufC* hBuf = HBufC::NewLC(len);
+	TPtr ptr = hBuf->Des();
+	
+	ptr.Format(KFormat, 1, &aFirstLine, &aSecondLine);
+	
+	
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowTimeEditorL
+//
+// -----------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowTimeEditorL(TTime& aTime, const TDesC& aTitle)
+	{
+    CAknTimeSettingPage* dlg = new (ELeave) CAknTimeSettingPage(R_ASP_SETTING_TIME, aTime);
+    
+   	CleanupStack::PushL(dlg);
+	dlg->ConstructL();
+	dlg->SetSettingTextL(aTitle);
+	CleanupStack::Pop(dlg);
+
+    
+    if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenAccepted))
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowDateEditorL
+//
+// -----------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowDateEditorL(TTime& aTime, const TDesC& aTitle)
+	{
+    CAknDateSettingPage* dlg = new (ELeave) CAknDateSettingPage(R_ASP_SETTING_DATE, aTime);
+    
+   	CleanupStack::PushL(dlg);
+	dlg->ConstructL();
+	dlg->SetSettingTextL(aTitle);
+	CleanupStack::Pop(dlg);
+
+    if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenAccepted))
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowListEditorL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowListEditorL(CDesCArray* aList, const TDesC& aTitle, TInt& aCurrent)
+	{
+
+	CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
+	                                       R_ASP_SETTING_RADIO, aCurrent, aList);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(aTitle); 
+	CleanupStack::Pop(dlg);
+
+	return dlg->ExecuteLD();
+	}
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowListEditorL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowListEditorL(TInt aResourceId, CDesCArray* aList, const TDesC& aTitle, TInt& aCurrent)
+	{
+	CAspRadioButtonSettingPageEditor* dlg = new (ELeave) CAspRadioButtonSettingPageEditor(
+	                                       aResourceId, aCurrent, aList);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(aTitle); 
+	CleanupStack::Pop(dlg);
+
+	return dlg->ExecuteLD();
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowTextEditorL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowTextEditorL(TInt aResourceId, TDes& aText, const TDesC& aTitle, TBool aMandatory, TBool aLatinInput, TInt aMaxLength)
+	{
+	TInt flags(CAknTextSettingPage::EZeroLengthAllowed);
+
+	if (aMandatory)
+		{
+		flags = CAknTextSettingPage::EZeroLengthNotOffered;
+		}
+
+	CAspTextSettingPageEditor * dlg = new (ELeave) CAspTextSettingPageEditor(aResourceId, aText, flags);
+	CleanupStack::PushL(dlg);
+
+	dlg->SetSettingTextL(aTitle); 
+	dlg->ConstructL();
+	dlg->TextControl()->SetTextLimit(aMaxLength);
+
+	if (aLatinInput)
+		{		
+		dlg->TextControl()->SetAvkonWrap(ETrue);
+		dlg->TextControl()->SetAknEditorCase(EAknEditorLowerCase);
+		dlg->TextControl()->SetAknEditorFlags(EAknEditorFlagNoT9 | EAknEditorFlagLatinInputModesOnly);
+		}
+	
+	CleanupStack::Pop(dlg);
+
+	// CAknTextSettingPage::ExecuteLD only return boolean. See CAknSettingPage::ProcessCommandL
+	// what softkey values map to ETrue and EFalse.
+	TInt ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+	if (ret)
+		{
+    	return ETrue;
+		}
+
+	return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowTextEditorL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowTextEditorL(TDes& aText, const TDesC& aTitle, TBool aMandatory, TBool aLatinInput, TInt aMaxLength)
+	{
+	return ShowTextEditorL(R_ASP_SETTING_TEXT, aText, aTitle, aMandatory, aLatinInput, aMaxLength);
+	}
+
+
+//------------------------------------------------------------------------------
+// TDialogUtil::ShowIntegerEditorL
+//
+//------------------------------------------------------------------------------
+//
+TBool TDialogUtil::ShowIntegerEditorL(TInt& aNumber, const TDesC& aTitle, TInt aMin, TInt aMax, TBool aLatinInput)
+	{
+	CAspIntegerSettingPageEditor* dlg = new (ELeave) CAspIntegerSettingPageEditor(
+	                              R_ASP_SETTING_NUMBER, aNumber,
+	                              CAknIntegerSettingPage::EInvalidValueNotOffered);
+	CleanupStack::PushL(dlg);
+	dlg->ConstructL();
+	dlg->SetSettingTextL(aTitle);
+	CleanupStack::Pop(dlg);
+	
+	CAknIntegerEdwin* editor = dlg->IntegerEditorControl();
+	if (aMin != KErrNotFound)
+		{
+		editor->SetMinimumIntegerValue(aMin);
+		}
+	if (aMax != KErrNotFound)
+		{
+		editor->SetMaximumIntegerValue(aMax);
+		}
+
+	editor->SetAknEditorNumericKeymap(EAknEditorPlainNumberModeKeymap);
+	
+	if (aLatinInput)
+		{
+		editor->SetAknEditorFlags(EAknEditorFlagLatinInputModesOnly);
+		editor->SetValueL(aNumber);
+		}
+
+	if (dlg->ExecuteLD(CAknIntegerSettingPage::EUpdateWhenChanged))
+		{
+		return ETrue;
+		}
+
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowPopupDialogL
+// 
+// -----------------------------------------------------------------------------
+void TDialogUtil::ShowPopupDialogL(const TDesC& aText, CDesCArray* aArray)
+	{
+	CAknSingleHeadingPopupMenuStyleListBox* listBox = new (ELeave) CAknSingleHeadingPopupMenuStyleListBox;
+	CleanupStack::PushL(listBox);
+
+
+	CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY, AknPopupLayouts::EMenuWindow);
+	CleanupStack::PushL(popupList);
+
+	listBox->ConstructL(popupList, EAknListBoxViewerFlags);
+	
+	CDesCArray* array = (CDesCArray*) listBox->Model()->ItemTextArray();
+	listBox->CreateScrollBarFrameL(ETrue); 
+	listBox->ScrollBarFrame()->	SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    
+	TInt count = aArray->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TPtrC ptr = (*aArray)[i];
+		array->AppendL(ptr);
+		}
+	
+	popupList->SetTitleL(aText);
+
+	popupList->ExecuteLD();
+
+	CleanupStack::Pop(popupList);
+	CleanupStack::PopAndDestroy(listBox);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowPopupDialog2L
+// 
+// -----------------------------------------------------------------------------
+void TDialogUtil::ShowPopupDialog2L(const TDesC& aText, CDesCArray* aArray)
+	{
+    CAknDoublePopupMenuStyleListBox* listBox = new(ELeave) CAknDoublePopupMenuStyleListBox;
+    
+    CleanupStack::PushL(listBox);
+
+    // Avkon popup list with heading
+    CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY, AknPopupLayouts::EMenuDoubleWindow);
+    CleanupStack::PushL(popupList);
+    
+    // Set listbox properties and create item array
+    listBox->ConstructL(popupList, EAknListBoxViewerFlags);
+    listBox->CreateScrollBarFrameL(ETrue);
+    listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    
+   	CDesCArray* array = (CDesCArray*) listBox->Model()->ItemTextArray();
+	TInt count = aArray->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TPtrC ptr = (*aArray)[i];
+		array->AppendL(ptr);
+		}
+    popupList->SetTitleL(aText);
+    	
+    popupList->ExecuteLD();
+
+    CleanupStack::Pop(popupList);
+    CleanupStack::PopAndDestroy(listBox);
+	}
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ShowAutoSyncLogL
+// 
+// -----------------------------------------------------------------------------
+TInt TDialogUtil::ShowAutoSyncLogL(TAny* /*aAny*/)
+	{
+
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	TRAPD (err,schedule->ShowAutoSyncLogL());
+	CleanupStack::PopAndDestroy(schedule);
+
+	if (err == KErrNone)
+		{
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+//-----------------------------------------------------------------------------
+//
+//Does Descriptor contain string "PC Suite"
+//Its NOT case sensitive
+//
+//-----------------------------------------------------------------------------
+TBool TDialogUtil::IsPCSuiteDesC(const TDesC& des)
+{
+	_LIT(KPCSuite, "pc suite");
+	TPtrC pcSuitePtr(KPCSuite);
+	
+	TBuf<KBufSize64> buf;
+	TUtil::StrCopy(buf,des);
+	buf.LowerCase();
+	if (buf.Match(pcSuitePtr) == 0)
+	{
+		return ETrue;
+	}
+		
+	return EFalse;
+}
+	    		
+
+/*******************************************************************************
+ * class CAspIndicatorHandler
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspIndicatorHandler::~CAspIndicatorHandler()
+    {
+    if (iIndicator && iIndicatorContainer && iIndicatorModified)
+    	{
+        if (iPreviousIndicatorType == EAknNaviPaneEditorIndicatorMessageLength)
+        	{
+        	TRAP_IGNORE( iIndicatorContainer->SetIndicatorValueL(
+                      TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), KNullDesC) );
+            }
+
+        iIndicatorContainer->SetIndicatorState(TUid::Uid(iIndicatorType), EAknIndicatorStateOff);
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspIndicatorHandler::CAspIndicatorHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspIndicatorHandler::CAspIndicatorHandler(MAknEditingStateIndicator* aIndicator) : iIndicator(aIndicator)
+	{
+	iIndicatorContainer = iIndicator->IndicatorContainer();
+    iIndicatorModified = EFalse;
+    iPreviousIndicatorType = KErrNotFound;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspIndicatorHandler::SetIndicatorStateL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspIndicatorHandler::SetIndicatorStateL(TInt aIndicatorType, const TDesC& aText)
+	{
+    if (iIndicator && iIndicatorContainer)
+    	{
+   	
+        if (iPreviousIndicatorType == EAknNaviPaneEditorIndicatorMessageLength)
+        	{
+        	iIndicatorContainer->SetIndicatorValueL(
+                      TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), KNullDesC);
+            }
+
+    	iIndicatorContainer->SetIndicatorState(TUid::Uid(aIndicatorType),
+                                               EAknIndicatorStateOn);
+                                               
+        iIndicatorModified = ETrue;
+        iPreviousIndicatorType = aIndicatorType;
+        
+                                               
+        if (aIndicatorType == EAknNaviPaneEditorIndicatorMessageLength)
+        	{
+        	iIndicatorContainer->SetIndicatorValueL(
+                                 TUid::Uid(EAknNaviPaneEditorIndicatorMessageLength), aText);
+            iPreviousIndicatorType = aIndicatorType;
+            }
+    	}
+	
+	}
+
+
+
+/*******************************************************************************
+ * class CAspNaviPaneHandler
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspNaviPaneHandler::~CAspNaviPaneHandler()
+    {
+   	if (iNaviDecorator)
+		{
+		if (iNaviPane && iNavidecoratorPushed)
+			{
+			iNaviPane->Pop(iNaviDecorator);
+			}
+	
+		delete iNaviDecorator;
+		}
+		
+	if (iNaviPane && iNavipanePushed)
+		{
+		iNaviPane->Pop(); // restore previous navi pane
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspNaviPaneHandler::CAspNaviPaneHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspNaviPaneHandler::CAspNaviPaneHandler(CEikStatusPane* aStatusPane) : iStatusPane(aStatusPane)
+	{
+	iNavidecoratorPushed = EFalse;
+	iNavipanePushed = EFalse;
+	
+	if (iStatusPane)
+		{
+		TRAP_IGNORE( iNaviPane = (CAknNavigationControlContainer*)iStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi)) );
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspNaviPaneHandler::SetNaviPaneTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspNaviPaneHandler::SetNaviPaneTitleL(const TDesC& aTitle)
+	{
+	if (!iStatusPane || !iNaviPane)
+		{
+		return;
+		}
+
+    if (iNaviDecorator)
+        {
+        CAknNaviLabel* naviLabel = static_cast<CAknNaviLabel*>(iNaviDecorator->DecoratedControl());
+        if (naviLabel)
+        	{
+        	naviLabel->SetTextL(aTitle);
+        	iNaviDecorator->DrawDeferred();
+        	}
+        }
+     else
+    	{
+    	iNaviDecorator = iNaviPane->CreateNavigationLabelL(aTitle);
+    	iNaviPane->PushL(*iNaviDecorator); // activate navi label in navi pane
+    	iNavidecoratorPushed = ETrue;
+    	}
+    	
+    //CFbsBitmap* bitmap = NULL;
+    //CFbsBitmap* bitmapMask = NULL;
+    //AknsUtils::CreateIconL(AknsUtils::SkinInstance(), KAknsIIDQgnPropSmlHttp,
+    //                       bitmap, bitmapMask, bitmapName,
+    //                       EMbmAspsyncutilQgn_prop_sml_http, EMbmAspsyncutilQgn_prop_sml_http_mask);
+    //iNaviDecorator = naviPane->CreateNavigationImageL(bitmap, bitmapMask);
+    //naviPane->PushL(*iNaviDecorator);
+    	
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspNaviPaneHandler::StoreNavipaneL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspNaviPaneHandler::StoreNavipaneL()
+	{
+	if (!iNaviPane || !iStatusPane || iNavipanePushed)
+		{
+		return;
+		}
+
+	if (iStatusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
+		{
+		iNaviPane->PushDefaultL();
+		iNavipanePushed = ETrue;
+		}
+	}
+
+#ifdef RD_DSUI_TIMEDSYNC
+
+/*******************************************************************************
+ * class CAspTabbedNaviPaneHandler
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspTabbedNaviPaneHandler::~CAspTabbedNaviPaneHandler()
+    {
+   	if (iNaviDecorator)
+		{
+		if (iNaviPane && iNavidecoratorPushed)
+			{
+			iNaviPane->Pop(iNaviDecorator);
+			}
+	
+		delete iNaviDecorator;
+		}
+		
+	if (iNaviPane && iNavipanePushed)
+		{
+		iNaviPane->Pop(); // restore previous navi pane
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::CAspTabbedNaviPaneHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspTabbedNaviPaneHandler::CAspTabbedNaviPaneHandler(CEikStatusPane* aStatusPane ,CAspSettingDialog *aDialog) 
+						  : iStatusPane(aStatusPane)
+	{
+	iNavidecoratorPushed = EFalse;
+	iNavipanePushed = EFalse;
+	
+	iDialog = aDialog;
+	
+	if (iStatusPane)
+		{
+		TRAP_IGNORE( iNaviPane = (CAknNavigationControlContainer*)iStatusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi)) );
+		}
+		
+    if (iNaviPane)
+        {
+        TRAP_IGNORE(iNaviDecorator = iNaviPane->CreateTabGroupL(this));    
+        }
+    
+	if (iNaviDecorator)
+	    {
+       	TRAP_IGNORE(iNaviPane->PushL(*iNaviDecorator));
+    	iNavidecoratorPushed = ETrue;
+
+	    iTabGroup = static_cast<CAknTabGroup*>( iNaviDecorator->DecoratedControl() );
+	    }
+	}
+
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::SetTabWidthL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::SetTabWidthL()
+{
+	
+	if (iTabGroup)
+	    {
+	     if (iTabGroup->TabCount() == 1)
+	         {
+	         iTabGroup->SetTabFixedWidthL(KTabWidthWithOneTab);     	
+	         }
+	     else if (iTabGroup->TabCount() == 2)
+	         {
+	         iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs);     	
+	         }
+	     else
+	         {
+	         iTabGroup->SetTabFixedWidthL(KTabWidthWithThreeLongTabs);     		
+	         }
+	      }
+}
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::SetTabTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::SetTabTextL(const TDesC& aText, TInt aTabId)
+	{
+	if (iTabGroup)
+	    {
+	    iTabGroup->ReplaceTabTextL(aTabId, aText);
+	    }
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::AddTabL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::AddTabL(const TDesC& aText, TInt aTabId)
+	{
+	if (iTabGroup)
+	    {
+	    iTabGroup->AddTabL(aTabId, aText);
+	    }
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::DeleteTabsL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::DeleteTabsL()
+	{
+	if (iTabGroup)
+	    {
+	    TInt count = iTabGroup->TabCount();
+	    for (TInt i=0; i<count; i++)
+	        {
+	        TInt id = iTabGroup->TabIdFromIndex(0);
+	        iTabGroup->DeleteTabL(id);
+	        }
+	    }
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::SetActiveTabL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::SetActiveTabL(TInt aTabId)
+	{
+	if (iTabGroup)
+	    {
+	    TInt index = iTabGroup->TabIndexFromId(aTabId);
+	    if (index != KErrNotFound)
+	        {
+	        iTabGroup->SetActiveTabById(aTabId);    
+	        }
+	    }
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::StoreNavipaneL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::StoreNavipaneL()
+	{
+	if (!iNaviPane || !iStatusPane || iNavipanePushed)
+		{
+		return;
+		}
+
+	if (iStatusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
+		{
+		iNaviPane->PushDefaultL();
+		iNavipanePushed = ETrue;
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::TabIndex
+// 
+// ----------------------------------------------------------------------------
+//
+TInt CAspTabbedNaviPaneHandler::TabIndex(TInt aTabId)
+	{
+	return iTabGroup->TabIndexFromId(aTabId);
+	}
+
+// ----------------------------------------------------------------------------
+// CAspTabbedNaviPaneHandler::TabChangedL (from MAknTabObserver)
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspTabbedNaviPaneHandler::TabChangedL(TInt aIndex)
+	{
+	TInt profileId = iTabGroup->TabIdFromIndex(aIndex );
+	iDialog->SetCurrentProfile(profileId);
+	iDialog->UpdateTabsL();
+	iDialog->UpdateListBoxL();
+	}
+
+#endif
+
+
+
+
+/*******************************************************************************
+ * class CStatusPaneHandler
+ *******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler* CStatusPaneHandler::NewL(CAknAppUi* aAppUi)
+    {
+    CStatusPaneHandler* self = new (ELeave) CStatusPaneHandler(aAppUi);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler::~CStatusPaneHandler()
+    {
+	TRAP_IGNORE(RestoreOriginalTitleL());
+	TRAP_IGNORE(RestoreOriginalImageL());
+	
+	delete iNaviPaneHandler;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::ConstructL(void)
+    {
+    iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(iAppUi->StatusPane());
+    }
+
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::CStatusPaneHandler
+//
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler::CStatusPaneHandler(CAknAppUi* aAppUi) : iAppUi(aAppUi)
+	{
+	__ASSERT_ALWAYS(iAppUi, TUtil::Panic(KErrGeneral));
+
+	iOriginalTitleStored = EFalse;
+	iOriginalTitle = KNullDesC;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::GetTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+TBool CStatusPaneHandler::GetTitleL(CAknAppUi* aAppUi, TDes& aTitle)
+	{
+	aTitle = KNullDesC;
+
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if (statusPane && statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
+		{
+        CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
+            (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
+        if (titlePane->Text()) 
+			{
+		    TUtil::StrCopy(aTitle, *titlePane->Text());
+			return ETrue;
+    		}
+		}
+
+	return EFalse;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+TBool CStatusPaneHandler::SetTitleL(CAknAppUi* aAppUi, const TDesC& aTitle)
+	{
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if (statusPane && statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
+		{
+        CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
+            (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
+        if (titlePane->Text()) 
+			{
+	   		titlePane->SetTextL(aTitle);
+			return ETrue;
+			}
+		}
+	return EFalse;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetNaviPaneTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetNaviPaneTitleL(const TDesC& aTitle)
+	{
+	iNaviPaneHandler->SetNaviPaneTitleL(aTitle);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetNaviPaneTitle
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetNaviPaneTitle(const TDesC& aTitle)
+	{
+	TRAP_IGNORE(iNaviPaneHandler->SetNaviPaneTitleL(aTitle));
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetNaviPaneTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetNaviPaneTitleL(TInt aResource)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResource);
+    SetNaviPaneTitleL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::StoreNavipaneL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::StoreNavipaneL()
+	{
+	iNaviPaneHandler->StoreNavipaneL();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::StoreOriginalTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::StoreOriginalTitleL()
+	{
+	TBool ret = GetTitleL(iAppUi, iOriginalTitle);
+	
+	if (ret)
+		{
+		iOriginalTitleStored = ETrue;
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::RestoreOriginalTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::RestoreOriginalTitleL()
+	{
+	if (iOriginalTitleStored)
+		{
+		SetTitleL(iAppUi, iOriginalTitle);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetTitleL(const TDesC& aText)
+	{
+	if (iOriginalTitleStored)
+		{
+		SetTitleL(iAppUi, aText);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetTitleL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetTitleL(TInt aResourceId)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResourceId);
+	SetTitleL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetNewImageL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetNewImageL(const TDesC& aFilename,TInt aMainId,TInt aMaskId)
+	{
+	__ASSERT_DEBUG(!iOriginalImage, TUtil::Panic(KErrGeneral)); // can set image only once
+
+	CEikImage* image = new (ELeave) CEikImage;
+	CleanupStack::PushL(image);
+	
+	image->CreatePictureFromFileL(aFilename, aMainId, aMaskId);
+
+	iOriginalImage = SetImageL(iAppUi, image);
+
+	if (iOriginalImage)
+		{
+        CleanupStack::Pop(image); // ownership transferred to context pane
+		return;
+		}
+
+	CleanupStack::PopAndDestroy(image);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::RestoreOriginalImageL
+// 
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::RestoreOriginalImageL()
+	{
+	if (!iOriginalImage)
+		{
+		return; // image has not been replaced
+		}
+
+	CEikImage* image = NULL;
+	TRAPD(err, image = SetImageL(iAppUi, iOriginalImage));
+
+	if (err == KErrNone && image)
+		{
+		delete image; // delete our own image
+		}
+	else
+		{
+		delete iOriginalImage; // delete original image (could not restore it)
+		iOriginalImage = NULL;
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetImageL
+// 
+// ----------------------------------------------------------------------------
+//
+CEikImage* CStatusPaneHandler::SetImageL(CAknAppUi* aAppUi, CEikImage* aIcon)
+	{
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if (statusPane && statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidContext)).IsPresent())
+		{
+        CAknContextPane* contextPane = static_cast<CAknContextPane*>
+            (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext)));
+        if (contextPane) 
+			{
+	   		return contextPane->SwapPicture(aIcon);
+			}
+		}
+
+	return NULL;
+	}
+
+
+
+
+/*******************************************************************************
+ * class CAspSelectionItemList
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspSelectionItemList::Cleanup
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSelectionItemList::Cleanup(TAny* aObj)
+    {
+    CAspSelectionItemList* list = static_cast<CAspSelectionItemList*>(aObj);
+	list->ResetAndDestroy();
+	delete list;
+	list = NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSelectionItemList::CAspSelectionItemList
+//
+// -----------------------------------------------------------------------------
+//
+CAspSelectionItemList::CAspSelectionItemList(TInt aGranularity) 
+: CSelectionItemList(aGranularity)
+	{
+	}
+
+
+
+/*******************************************************************************
+ * class CAspListItemData
+ *******************************************************************************/
+
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::NewLC
+// 
+//------------------------------------------------------------------------------
+//
+CAspListItemData* CAspListItemData::NewLC()
+	{
+	CAspListItemData* self = new (ELeave) CAspListItemData;
+	CleanupStack::PushL( self);
+	self->ConstructL();
+	return self;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::ConstructL
+//
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::ConstructL()
+	{
+	Init();
+	
+    iHeader  = HBufC::NewL(0);
+	iDisplayValue = HBufC::NewL(0);
+	iValue = HBufC::NewL(0);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspListItemData::CAspListItemData
+// -----------------------------------------------------------------------------
+//
+CAspListItemData::CAspListItemData()
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+//
+//------------------------------------------------------------------------------
+//
+CAspListItemData::~CAspListItemData()
+	{
+	delete iHeader;
+	delete iDisplayValue;
+	delete iValue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::Header
+//
+//------------------------------------------------------------------------------
+//
+const TDesC& CAspListItemData::Header()
+	{
+	__ASSERT_ALWAYS(iHeader, TUtil::Panic(KErrGeneral));
+	
+	return *iHeader;
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetHeaderL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetHeaderL(const TDesC& aText)
+	{
+	delete iHeader;
+	iHeader = NULL;
+	iHeader = aText.AllocL();
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetHeaderL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetHeaderL(TInt aResourceId)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(aResourceId);
+    SetHeaderL(hBuf->Des());
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::Value
+// 
+//------------------------------------------------------------------------------
+//
+const TDesC& CAspListItemData::Value()
+	{
+	__ASSERT_ALWAYS(iValue, TUtil::Panic(KErrGeneral));
+	
+	return *iValue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetValue
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetValueL(const TDesC& aText)
+	{
+    delete iValue;
+    iValue = NULL;
+	iValue = aText.AllocL();
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetValueL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetValueL(TInt aNumber)
+	{
+	TBuf<KBufSize32> buf;
+	buf.Num(aNumber);
+	SetValueL(buf);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetDisplayValue
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetDisplayValueL(const TDesC& aText)
+	{
+	delete iDisplayValue;
+	iDisplayValue = NULL;
+	iDisplayValue = aText.AllocL();
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::SetDisplayValue
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::SetDisplayValueL(TInt aResource)
+	{
+	delete iDisplayValue;
+	iDisplayValue = NULL;
+	
+	iDisplayValue = StringLoader::LoadL(aResource);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::IsEmpty
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspListItemData::IsEmpty()
+	{
+	if (!iValue)
+		{
+		return ETrue;
+		}
+		
+	if (TUtil::IsEmpty(iValue->Des()))
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::ListItemTextL
+//
+// Constructs header and value suitable for listbox.
+// List item syntax:
+// "\t<header>\t\t<value>\t<mandatorychar>\t\t<readonlyicon>"
+//------------------------------------------------------------------------------
+//
+HBufC* CAspListItemData::ListItemTextL(TBool aConvert)
+	{
+	_LIT(KTab, "\t");
+	_LIT(KMandatoryChar, "*");
+	_LIT(KReadOnlyIconIndex, "0");
+	
+	HBufC* hBuf = HBufC::NewL(KBufSize255);
+	TPtr ptr = hBuf->Des();
+	
+	ptr.Append(KTab);
+	ptr.Append(iHeader->Des());
+	ptr.Append(KTab);
+	ptr.Append(KTab);
+	                                              //"PC Suite" string in Host address field and server id should be displayed as chinese
+	if (IsEmpty() || iItemType == ETypeSecret || (TDialogUtil::IsPCSuiteDesC(iValue->Des()) && (iItemId == EAspHostAddress || iItemId == EAspServerId)))
+		{
+		ptr.Append(iDisplayValue->Des());
+		}
+	else
+		{
+		ptr.Append(iValue->Des());
+		}
+
+	ptr.Append(KTab);
+	
+	if (iMandatory)
+		{
+		ptr.Append(KMandatoryChar);
+		}
+	
+	ptr.Append(KTab);
+	ptr.Append(KTab);
+	
+	if (iHidden == EVisibilityReadOnly)
+		{
+		ptr.Append(KReadOnlyIconIndex);
+		}
+
+	if (aConvert)
+		{
+		AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr);
+		}
+
+	return hBuf;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspListItemData::Init
+// 
+//------------------------------------------------------------------------------
+//
+void CAspListItemData::Init()
+	{
+	iNumberData = KErrNotFound;
+	iDate = 0;
+	iTime = 0;
+	
+	iItemType = KErrNotFound;
+	iHidden = EVisibilityNormal;
+	iMaxLength = KBufSize;
+	iResource = KErrNotFound;
+	iIndex = KErrNotFound;
+	iItemId = KErrNotFound;
+	
+	iMandatory = EFalse;
+	iLatinInput = EFalse;
+	
+	iMinValue = KErrNotFound;
+	iMaxValue = KErrNotFound;
+	
+	//iFilter = 0;
+	iSelectKeyPressed = EFalse;
+	
+	iValue = NULL;
+	iDisplayValue = NULL;
+	iHeader = NULL;
+    }
+
+
+		
+/*******************************************************************************
+ * class CAspRadioButtonSettingPageEditor
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspRadioButtonSettingPageEditor::CAspRadioButtonSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspRadioButtonSettingPageEditor::CAspRadioButtonSettingPageEditor(TInt aResourceID,
+                            TInt& aCurrentSelectionIndex,
+                            const MDesCArray* aItemArray
+                            )
+                            
+ : CAknRadioButtonSettingPage(aResourceID, aCurrentSelectionIndex, aItemArray)
+	{
+	}
+	
+	
+// ----------------------------------------------------------------------------
+// CAspRadioButtonSettingPageEditor::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspRadioButtonSettingPageEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+		    if(EKeyEnter == aKeyEvent.iCode)
+		    {
+		    	ProcessCommandL(EAknSoftkeyOk);
+		    	return EKeyWasConsumed;
+		    }
+		    return CAknRadioButtonSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspRadioButtonSettingPageEditor::~CAspRadioButtonSettingPageEditor()
+	{
+	}
+
+		
+/*******************************************************************************
+ * class CAspTextSettingPageEditor
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspTextSettingPageEditor::CAspTextSettingPageEditor
+// 
+//------------------------------------------------------------------------------
+//
+CAspTextSettingPageEditor::CAspTextSettingPageEditor(TInt aResourceID, 
+                                                     TDes& aText, 
+                                                     TInt aTextSettingPageFlags)                      
+ : CAknTextSettingPage(aResourceID, aText, aTextSettingPageFlags)
+	{
+	}
+	
+	
+// ----------------------------------------------------------------------------
+// CAspTextSettingPageEditor::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspTextSettingPageEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+		    if(EKeyEnter == aKeyEvent.iCode)
+		    {
+		    	ProcessCommandL(EAknSoftkeyOk);
+		    	return EKeyWasConsumed;
+		    }
+		    return CAknTextSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspTextSettingPageEditor::~CAspTextSettingPageEditor()
+	{
+	}
+
+		
+/*******************************************************************************
+ * class CAspAlphaPasswordSettingPageEditor
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPageEditor::CAspAlphaPasswordSettingPageEditor
+// 
+//------------------------------------------------------------------------------
+//
+CAspAlphaPasswordSettingPageEditor::CAspAlphaPasswordSettingPageEditor(TInt aResourceID, 
+                                                     TDes& aNewPassword, 
+                                                     const TDesC& aOldPassword)                      
+ : CAknAlphaPasswordSettingPage(aResourceID,aNewPassword,aOldPassword)
+	{
+	}
+	
+	
+// ----------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPageEditor::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspAlphaPasswordSettingPageEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+		    if(EKeyEnter == aKeyEvent.iCode)
+		    {
+		    	ProcessCommandL(EAknSoftkeyOk);
+		    	return EKeyWasConsumed;
+		    }
+		    return CAknAlphaPasswordSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspAlphaPasswordSettingPageEditor::~CAspAlphaPasswordSettingPageEditor()
+	{
+	}
+
+/*******************************************************************************
+ * class CAspIntegerSettingPageEditor
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspIntegerSettingPageEditor::CAspIntegerSettingPageEditor
+// 
+//------------------------------------------------------------------------------
+//
+CAspIntegerSettingPageEditor::CAspIntegerSettingPageEditor(TInt aResourceID, 
+												TInt& aValue, 
+												TInt aTextSettingPageFlags)
+ : CAknIntegerSettingPage(aResourceID,aValue,aTextSettingPageFlags)
+	{
+	}
+	
+	
+// ----------------------------------------------------------------------------
+// CAspIntegerSettingPageEditor::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspIntegerSettingPageEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+		    if(EKeyEnter == aKeyEvent.iCode)
+		    {
+		    	ProcessCommandL(EAknSoftkeyOk);
+		    	return EKeyWasConsumed;
+		    }
+		    return CAknIntegerSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspIntegerSettingPageEditor::~CAspIntegerSettingPageEditor()
+	{
+	}
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspFilter.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1322 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+// INCLUDES
+
+#include <SyncMLTransportProperties.h>
+
+
+#include "aspfilter.h"
+#include "aspprofile.h"
+#include "AspResHandler.h"
+#include "AspDialogUtil.h"
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+/*******************************************************************************
+ * class CAspFilterList
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAspFilterList* CAspFilterList::NewL(const TAspParam& aParam, RPointerArray<CSyncMLFilter>& aArray)
+    {
+    CAspFilterList* self = new(ELeave) CAspFilterList(aParam, aArray);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::~CAspFilterList
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilterList::~CAspFilterList()
+    {
+    iFilterList.ResetAndDestroy();
+    iFilterList.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterList::ConstructL()
+    {
+    InitFiltersL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::CAspFilterList
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilterList::CAspFilterList(const TAspParam& aParam, RPointerArray<CSyncMLFilter>& aArray)
+	{
+	iApplicationId = aParam.iApplicationId;
+	//iAspTask = aParam.iSyncTask;
+	iArray = aArray;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::InitFiltersL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterList::InitFiltersL()
+	{
+	//TSyncMLFilterChangeInfo changeInfo = ESyncMLDefault;
+	//RPointerArray<CSyncMLFilter>& arr = iAspTask->Task().SupportedServerFiltersL(changeInfo);
+	
+	TInt count = iArray.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CSyncMLFilter* filter = iArray[i];
+		CAspFilter* aspFilter = CAspFilter::NewLC(filter, i);
+		iFilterList.AppendL(aspFilter);
+		CleanupStack::Pop(aspFilter);
+		}
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspFilterList::Count
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterList::Count()
+	{
+	return iFilterList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::FiltersEnabled
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspFilterList::FiltersEnabled()
+	{
+    TInt count = iFilterList.Count();
+    
+    for (TInt i=0; i<count; i++)
+    	{
+    	CAspFilter* filter = iFilterList[i];
+    	if (filter->Enabled())
+    		{
+    		return ETrue;
+    		}
+    	}
+    	
+    return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::SetFiltersEnabledL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterList::SetFiltersEnabledL(TBool aEnable)
+	{
+    TInt count = iFilterList.Count();
+    
+    for (TInt i=0; i<count; i++)
+    	{
+    	CAspFilter* filter = iFilterList[i];
+    	filter->SetEnabledL(aEnable);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::SaveL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterList::SaveL()
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::Item
+// 
+// -----------------------------------------------------------------------------
+//
+CAspFilter* CAspFilterList::Item(TInt aIndex)
+	{
+	if (aIndex < 0 || aIndex >= iFilterList.Count())
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	return iFilterList[aIndex];
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspFilterList::ItemForIdL
+// 
+// -----------------------------------------------------------------------------
+//
+CAspFilter* CAspFilterList::ItemForId(TInt aId)
+	{
+    TInt count = iFilterList.Count();
+    
+    for (TInt i=0; i<count; i++)
+    	{
+    	CAspFilter* filter = iFilterList[i];
+    	if (filter->Id() == aId)
+    		{
+    		return filter;
+    		}
+    	}
+	
+	return NULL;
+	}
+
+
+
+
+
+/*******************************************************************************
+ * class CAspFilter
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilter* CAspFilter::NewLC(CSyncMLFilter* aSyncFilter, TInt aId)
+    {
+    CAspFilter* self = new(ELeave) CAspFilter(aSyncFilter, aId);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::~CAspFilter
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilter::~CAspFilter()
+    {
+    iFilterItemList.ResetAndDestroy();
+    iFilterItemList.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CAspFilter::ConstructL()
+    {
+    InitFilterItemsL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::CAspFilter
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilter::CAspFilter(CSyncMLFilter* aSyncFilter, TInt aId)
+	{
+	iId = KFilterBaseId + aId;
+	iSyncFilter = aSyncFilter;
+	
+    __ASSERT_ALWAYS(iSyncFilter, TUtil::Panic(KErrGeneral));		
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspFilter::SaveL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilter::SaveL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::InitFilterItemsL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilter::InitFilterItemsL()
+	{
+	RPointerArray<CSyncMLFilterProperty>& arr = iSyncFilter->FilterProperties();
+	
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CSyncMLFilterProperty* property = arr[i];
+		CAspFilterItem* item = CAspFilterItem::NewLC(property, i);
+		iFilterItemList.AppendL(item);
+		CleanupStack::Pop(item);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::DisplayName
+// 
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspFilter::DisplayName()
+	{
+	return iSyncFilter->DisplayName();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::GetDisplayValueL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilter::GetDisplayValueL(TDes& aText)
+	{
+	aText = KNullDesC;
+	
+	if (!Enabled())
+		{
+		CAspResHandler::ReadL(aText, R_ASP_NOT_DEFINED);
+		}
+	else if (iFilterItemList.Count() == 1)
+		{
+	    CAspFilterItem* item = iFilterItemList[0];
+	    item->GetDisplayValueL(aText);
+		}
+	else if (iFilterItemList.Count() > 1)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_MULTIPLE_SELECTION);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::Id
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilter::Id()
+	{
+	return iId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::ItemCount
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilter::ItemCount()
+	{
+	return iFilterItemList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::Item
+// 
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem* CAspFilter::Item(TInt aIndex)
+	{
+	if (aIndex < 0 || aIndex >= ItemCount())
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	return iFilterItemList[aIndex];
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::ItemForIdL
+// 
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem* CAspFilter::ItemForId(TInt aId)
+	{
+    TInt count = ItemCount();
+    
+    for (TInt i=0; i<count; i++)
+    	{
+    	CAspFilterItem* item = Item(i);
+    	if (item->Id() == aId)
+    		{
+    		return item;
+    		}
+    	}
+	
+	return NULL;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::Enabled
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspFilter::Enabled()
+	{
+	return iSyncFilter->Enabled();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilter::SetEnabledL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilter::SetEnabledL(TBool aEnable)
+	{
+	iSyncFilter->SetEnabledL(aEnable);
+	}
+
+
+
+	
+
+	
+	
+/*******************************************************************************
+ * class CAspFilterItem
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem* CAspFilterItem::NewLC(CSyncMLFilterProperty* aProperty, TInt aId)
+    {
+    CAspFilterItem* self = new(ELeave) CAspFilterItem(aProperty, aId);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem* CAspFilterItem::NewL(CSyncMLFilterProperty* aProperty, TInt aId)
+    {
+    CAspFilterItem* self = new(ELeave) CAspFilterItem(aProperty, aId);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::~CAspFilterItem
+//
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem::~CAspFilterItem()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::ConstructL()
+    {
+    InitListTypeL();
+    InitDataTypeL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::CAspFilterItem
+// -----------------------------------------------------------------------------
+//
+CAspFilterItem::CAspFilterItem(CSyncMLFilterProperty* aProperty, TInt aId)
+	{
+	iId = aId + KFilterItemBaseId;
+	iProperty = aProperty;
+	
+	__ASSERT_ALWAYS(iProperty, TUtil::Panic(KErrGeneral));
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::ListType
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::ListType()
+	{
+	return iListType;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::DataType
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::DataType()
+	{
+	return iDataType;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::InitListType
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::InitListTypeL()
+	{
+	TInt defaultValueCount = iProperty->DefaultValueCount();
+	TBool querySupported = iProperty->CanUseQueryValue();
+	TBool multiSelectionSupported = iProperty->SupportsMultipleSelection(); 
+
+    if (defaultValueCount == 0 && querySupported)
+    	{
+    	iListType = ETypeQuery;
+    	}
+    else if (defaultValueCount > 0 && !querySupported && !multiSelectionSupported)
+    	{
+    	iListType = ETypeSingleSelection;
+    	}
+    else if (defaultValueCount > 0 && querySupported && !multiSelectionSupported)
+    	{
+    	iListType = ETypeSingleSelectionUserDefined;
+    	}
+    else if (defaultValueCount > 0 && !querySupported && multiSelectionSupported)
+    	{
+    	iListType = ETypeMultipleSelection;
+    	}
+    else if (defaultValueCount > 0 && querySupported && multiSelectionSupported)
+    	{
+    	iListType = ETypeMultipleSelectionUserDefined;
+    	}
+    else
+    	{
+    	User::Leave(KErrNotSupported);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::InitDataType
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::InitDataTypeL()
+	{
+	if (!iProperty->CanUseQueryValue())
+		{
+		iDataType = CAspListItemData::ETypeList;
+		return;
+		}
+		
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+		
+    switch (type)
+    	{
+    	case ESyncMLDataTypeBool:
+    	    iDataType = CAspListItemData::ETypeBoolean;
+    	    break;
+    	case ESyncMLDataTypeNumber:
+    	    iDataType = CAspListItemData::ETypeNumber;
+    	    break;
+    	case ESyncMLDataTypeDate:
+    	    iDataType = CAspListItemData::ETypeDate;
+    	    break;
+    	case ESyncMLDataTypeTime:
+    	    iDataType = CAspListItemData::ETypeTime;
+    	    break;
+    	case ESyncMLDataTypeText8:
+    	    iDataType = CAspListItemData::ETypeText;
+    	    break;
+    	case ESyncMLDataTypeText16:
+    	    iDataType = CAspListItemData::ETypeText;
+    	    break;
+
+    	default:
+    	    User::Leave(KErrNotSupported);
+    	    break;
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::DisplayName
+// 
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspFilterItem::DisplayName()
+	{
+	return iProperty->DisplayName();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::DisplayValueL
+// 
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspFilterItem::DisplayValueL()
+	{
+	GetDisplayValueL(iDisplayValueBuf);
+	return iDisplayValueBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetDisplayValueL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetDisplayValueL(TDes& aText)
+	{
+	aText = KNullDesC;
+	
+	if (ListType() == ETypeQuery)
+		{
+		GetQueryValueTextL(aText);
+		}
+	else if (SelectionAndQueryCount() > 1)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_MULTIPLE_SELECTION);
+		}
+	else if (SelectionAndQueryCount() == 1)
+		{
+		if (QueryValueSelected())
+			{
+			GetQueryValueTextL(aText);
+			}
+		else
+			{
+			GetListValueTextL(aText);
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetQueryValueTextL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetQueryValueTextL(TDes& aText)
+	{
+	aText = KNullDesC;
+	
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+		
+	switch (type)
+		{
+		case ESyncMLDataTypeText16:
+	    	GetText(aText);
+		    break;
+
+		case ESyncMLDataTypeText8:
+		    GetText(aText);
+		    break;
+		    
+		case ESyncMLDataTypeNumber:
+		    aText.Num(iProperty->QueryValueIntL());
+    	    break;
+
+		case ESyncMLDataTypeBool:
+			{
+		    CDesCArray* stringData = CAspResHandler::ReadDesArrayStaticLC(R_ASP_FILTER_ITEM_YESNO);
+		    if (iProperty->QueryValueBoolL())
+		    	{
+		    	aText = (*stringData)[1];
+		    	}
+		    else
+		    	{
+		    	aText = (*stringData)[0];
+		    	}
+		    CleanupStack::PopAndDestroy(stringData);
+		    break;
+			}
+		
+		case ESyncMLDataTypeDate:
+		    TUtil::GetDateTextL(aText, iProperty->QueryValueDateL());
+		    break;
+		    
+		case ESyncMLDataTypeTime:
+		    TUtil::GetTimeTextL(aText, iProperty->QueryValueTimeL());
+		    break;
+
+		default:
+		    break;
+	
+		}
+		
+
+	if (TUtil::IsEmpty(aText))
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETTING_VALUE_NONE);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetQueryValueTextL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetQueryValueTextL(const TDesC& aText)
+	{
+	TInt num = 0;
+	
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+		
+	switch (type)
+		{
+		case ESyncMLDataTypeText16:
+	    	iProperty->SetQueryValueText16L(aText);
+		    break;
+
+		case ESyncMLDataTypeText8:
+		    TUtil::StrCopy(iBuf8, aText);
+	    	iProperty->SetQueryValueText8L(iBuf8);
+		    break;
+		    
+		case ESyncMLDataTypeNumber:
+    	    User::LeaveIfError(TUtil::StrToInt(aText, num));
+		    iProperty->SetQueryValueIntL(num);
+    	    break;
+
+		case ESyncMLDataTypeBool:
+		    User::LeaveIfError(TUtil::StrToInt(aText, num));
+		    if (num)
+		    	{
+		    	iProperty->SetQueryValueBoolL(ETrue);
+		    	}
+		    else
+		    	{
+		    	iProperty->SetQueryValueBoolL(EFalse);
+		    	}
+    	    break;
+
+		case ESyncMLDataTypeDate:
+    	    User::LeaveIfError(TUtil::StrToInt(aText, num));
+		    iProperty->SetQueryValueDateL(num);
+    	    break;
+
+		case ESyncMLDataTypeTime:
+    	    User::LeaveIfError(TUtil::StrToInt(aText, num));
+		    iProperty->SetQueryValueTimeL(num);
+    	    break;
+
+		default:
+		    break;
+	
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetListValueTextL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetListValueTextL(TDes& aText)
+	{
+	aText = KNullDesC;
+	TInt index = SelectionIndex();
+	if (index == KErrNotFound)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETTING_VALUE_NONE);
+		return; // list does not have one item selected
+		}
+		
+	GetListValueTextL(aText, index);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetListValueTextL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetListValueTextL(TDes& aText, TInt aIndex)
+	{
+	aText = KNullDesC;
+	
+	if (aIndex < 0 || aIndex >= iProperty->DefaultValueCount())
+		{
+		TUtil::Panic(KErrArgument);
+		}
+		
+	TSyncMLFilterPropertyDataType type = iProperty->DefaultValueDataType();
+		
+	switch (type)
+		{
+		case ESyncMLDataTypeText16:
+	    	TUtil::StrCopy(aText, iProperty->DefaultValueText16L(aIndex));
+		    break;
+
+		case ESyncMLDataTypeText8:
+	    	TUtil::StrCopy(aText, iProperty->DefaultValueText8L(aIndex));
+		    break;
+		    
+		case ESyncMLDataTypeNumber:
+		    aText.Num(iProperty->DefaultValueIntL(aIndex));
+    	    break;
+
+		case ESyncMLDataTypeBool:
+			{
+			CDesCArray* stringData = CAspResHandler::ReadDesArrayStaticLC(R_ASP_FILTER_ITEM_YESNO);
+		    if (iProperty->DefaultValueBoolL(aIndex))
+		    	{
+		    	aText = (*stringData)[1];
+		    	}
+		    else
+		    	{
+		    	aText = (*stringData)[0];
+		    	}
+		    CleanupStack::PopAndDestroy(stringData);
+		    break;
+			}
+		
+		case ESyncMLDataTypeDate:
+		    TUtil::GetDateTextL(aText, iProperty->DefaultValueDateL(aIndex));
+		    break;
+		    
+		case ESyncMLDataTypeTime:
+		    TUtil::GetTimeTextL(aText, iProperty->DefaultValueTimeL(aIndex));
+		    break;
+
+		default:
+		    break;
+	
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SelectionCount
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::SelectionCount()
+	{
+	TInt count = 0;
+	TInt defaultValueCount = iProperty->DefaultValueCount();
+	
+	for (TInt i=0; i<defaultValueCount; i++)
+		{
+		if (iProperty->IsDefaultValueSelected(i))
+			{
+			count++;
+			}
+		}
+
+   	return count;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SelectionAndQueryCount
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::SelectionAndQueryCount()
+	{
+	TInt count = SelectionCount();
+
+	if (QueryValueSelected())
+		{
+		count++;
+		}
+   		
+   	return count;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SelectionIndex
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::SelectionIndex()
+	{
+	if (SelectionCount() != 1)
+		{
+		return KErrNotFound;
+		}
+	if (QueryValueSelected())
+		{
+		return KErrNotFound;
+		}
+		
+	TInt count = iProperty->DefaultValueCount();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		if (iProperty->IsDefaultValueSelected(i))
+			{
+			return i;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::QueryValueSelected
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspFilterItem::QueryValueSelected()
+	{
+	if (iProperty->DefaultValueCount() > 0 && iProperty->CanUseQueryValue())
+		{
+    	if (iProperty->IsQueryValueSelected())
+			{
+			return ETrue;
+        	}
+		}
+	
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::Id
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::Id()
+	{
+	return iId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::IsMandatory
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspFilterItem::IsMandatory()
+	{
+	if (iListType == ETypeMultipleSelection || iListType == ETypeMultipleSelectionUserDefined)
+		{
+		if (!iProperty->SupportsEmptySelection())
+			{
+			return ETrue;
+			}
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::MaxLength
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::MaxLength()
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+    if (type != ESyncMLDataTypeText8 && type != ESyncMLDataTypeText16)
+    	{
+    	return 0;
+    	}
+    
+   return iProperty->MaxTextLength();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetSelectionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetSelectionL(CSelectionItemList* aList)
+	{
+	__ASSERT_ALWAYS(aList, TUtil::Panic(KErrGeneral));
+	
+	TBuf<KBufSize> buf;
+	
+	TInt count = iProperty->DefaultValueCount();
+	for (TInt i=0; i<count; i++)
+		{
+		TBool selected = iProperty->IsDefaultValueSelected(i);
+		GetListValueTextL(buf, i);
+     	
+		CSelectableItem* item = new (ELeave) CSelectableItem(buf, selected);
+   	    CleanupStack::PushL(item);
+	    item->ConstructL();
+	    aList->AppendL(item);
+	    CleanupStack::Pop(item);
+    	}
+    	
+    AddQueryValueL(aList);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetSelectionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetSelectionL(CSelectionItemList* aList)
+	{
+	TInt count = aList->Count();
+	TInt defaultValuecount = iProperty->DefaultValueCount();
+	
+	__ASSERT_ALWAYS(count >= defaultValuecount, TUtil::Panic(KErrGeneral));
+	
+	for (TInt i=0; i<defaultValuecount; i++)
+		{
+		TBool selected = (*aList)[i]->SelectionStatus();
+		if (selected)
+			{
+			iProperty->SelectDefaultValueL(i);
+			}
+		else
+			{
+			iProperty->UnselectDefaultValueL(i);
+			}
+     	}
+    	
+    UpdateQueryValueL(aList);
+    
+    CheckEmptySelectionL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::CheckEmptySelectionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::CheckEmptySelectionL()
+	{	
+	if (iListType != ETypeMultipleSelection && iListType != ETypeMultipleSelectionUserDefined)
+		{
+		return;
+		}
+	
+	if (SelectionAndQueryCount() == 0 && !iProperty->SupportsEmptySelection())
+		{
+		if (iProperty->DefaultValueCount() > 0)
+			{
+			iProperty->SelectDefaultValueL(0);
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::UpdateQueryValueL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::UpdateQueryValueL(CSelectionItemList* aList)
+	{	
+	if (iListType != ETypeSingleSelectionUserDefined && iListType != ETypeMultipleSelectionUserDefined)
+		{
+		return;
+		}
+	
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	if (type != ESyncMLDataTypeNumber && type != ESyncMLDataTypeText16 && type != ESyncMLDataTypeText8)
+		{
+		return; // "User defined" list only supports number and text
+		}
+	
+	
+	TInt count = aList->Count();
+	TInt defaultValueCount = iProperty->DefaultValueCount();
+	
+	__ASSERT_ALWAYS(count == defaultValueCount+1, TUtil::Panic(KErrGeneral));
+	
+		
+	CSelectableItem* item = (*aList)[count-1];
+	
+	SetQueryValueTextL(item->ItemText());
+		
+	if (!item->SelectionStatus())
+		{
+		iProperty->UnselectQueryValueL();
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::AddQueryValueL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::AddQueryValueL(CSelectionItemList* aList)
+	{	
+	if (iListType != ETypeSingleSelectionUserDefined && iListType != ETypeMultipleSelectionUserDefined)
+		{
+		return;
+		}
+		
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	if (type != ESyncMLDataTypeNumber && type != ESyncMLDataTypeText16 && type != ESyncMLDataTypeText8)
+		{
+		return; // "User defined" list only supports number and text
+		}
+
+
+	
+	TBuf<KBufSize> buf;
+	TBool selected = iProperty->IsQueryValueSelected();
+	GetQueryValueTextL(buf);
+
+	CSelectableItem* item = new (ELeave) CSelectableItem(buf, selected);
+   	CleanupStack::PushL(item);
+	item->ConstructL();
+	aList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetTextL(TDes& aText)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeText8 || type==ESyncMLDataTypeText16, TUtil::Panic(KErrGeneral));
+	
+	if (type == ESyncMLDataTypeText8)
+		{
+		TUtil::StrCopy(aText, iProperty->QueryValueText8L());
+		}
+	else
+		{
+	    TUtil::StrCopy(aText, iProperty->QueryValueText16L());
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::GetText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::GetText(TDes& aText)
+	{
+	TRAPD(err, GetTextL(aText));
+	
+	if (err != KErrNone)
+		{
+		aText = KNullDesC;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetTextL(const TDesC& aText)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeText8 || type==ESyncMLDataTypeText16, TUtil::Panic(KErrGeneral));
+	
+	if (type == ESyncMLDataTypeText8)
+		{
+	    TUtil::StrCopy(iBuf8, aText);
+    	iProperty->SetQueryValueText8L(iBuf8);
+		}
+	else
+		{
+		iProperty->SetQueryValueText16L(aText);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::BoolL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspFilterItem::BoolL()
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeBool, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->QueryValueBoolL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetBoolL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetBoolL(TBool aBool)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeBool, TUtil::Panic(KErrGeneral));
+	
+	iProperty->SetQueryValueBoolL(aBool);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::IntL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspFilterItem::IntL()
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeNumber, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->QueryValueIntL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetIntL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetIntL(TInt aInt)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeNumber, TUtil::Panic(KErrGeneral));
+	
+	iProperty->SetQueryValueIntL(aInt);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::DateL
+//
+// -----------------------------------------------------------------------------
+//
+TTime CAspFilterItem::DateL()
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeDate, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->QueryValueDateL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetDateL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetDateL(TTime aTime)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeDate, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->SetQueryValueDateL(aTime);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::TimeL
+//
+// -----------------------------------------------------------------------------
+//
+TTime CAspFilterItem::TimeL()
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeTime, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->QueryValueTimeL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterItem::SetTimeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterItem::SetTimeL(TTime aTime)
+	{
+	TSyncMLFilterPropertyDataType type = iProperty->QueryValueDataType();
+	
+	__ASSERT_DEBUG(type==ESyncMLDataTypeTime, TUtil::Panic(KErrGeneral));
+	
+	return iProperty->SetQueryValueTimeL(aTime);
+	}
+
+
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspFilterDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1643 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "AspFilterDialog.h"
+#include "AspFilter.h"
+#include "AspUtil.h"
+#include "AspDefines.h"
+#include "AspDialogUtil.h"
+#include "AspResHandler.h"
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+
+#include <AknRadioButtonSettingPage.h>  // CAknRadioButtonSettingPage
+#include <AknCheckBoxSettingPage.h>  // CAknRadioButtonSettingPage
+#include <AknTextSettingPage.h>         // for CAknIntegerSettingPage
+
+//#include "ds.hlp.hrh"  // help text ids
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+/*******************************************************************************
+ * class CAspMultiChoiceListSettingPage
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspFilterDialog::ShowDialogL(TAspParam& aParam)
+	{
+	CAspFilterDialog* dialog = CAspFilterDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_FILTER_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspFilterDialog* CAspFilterDialog::NewL(TAspParam& aParam)
+    {
+    CAspFilterDialog* self = new (ELeave) CAspFilterDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return( self );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::CAspFilterDialog
+//
+//------------------------------------------------------------------------------
+//
+CAspFilterDialog::CAspFilterDialog(TAspParam& aParam)
+	{
+	iApplicationId = aParam.iApplicationId;
+	iDialogParam = &aParam;
+	iFilter = aParam.iSyncFilter;
+	
+    __ASSERT_ALWAYS(iFilter, TUtil::Panic(KErrGeneral));	
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+//
+//------------------------------------------------------------------------------
+//
+CAspFilterDialog::~CAspFilterDialog()
+	{
+	if (iSettingList)
+		{
+		iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+		}
+
+	delete iStatusPaneHandler;
+	delete iResHandler;
+	
+	if (iAvkonAppUi)
+		{
+		iAvkonAppUi->RemoveFromStack(this);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspFilterDialog::ConstructL()
+    {
+	CAknDialog::ConstructL(R_ASP_FILTER_DIALOG_MENU);
+	
+	iResHandler = CAspResHandler::NewL();
+    iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(10);
+	
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+    } 
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::ActivateL (from CCoeControl)
+//
+// Called by system when dialog is activated
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//-----------------------------------------------------------------------------
+// CAspFilterDialog::HandleOKL
+//
+// Handle content parameter editing.
+//-----------------------------------------------------------------------------
+//
+void CAspFilterDialog::HandleOKL()
+	{
+	CAspListItemData* item = ItemForIndex(ListBox()->CurrentItemIndex());
+	item->iFilter = iFilter;
+
+	if (EditSettingItemL(*item))
+		{
+		SetVisibility();
+		UpdateListBoxL(ListBox(), iSettingList);
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::ProcessCommandL
+//
+// Handle menu commands.
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::ProcessCommandL( TInt aCommandId )
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAspMenuCmdHelp:
+			{
+            break;
+			}
+
+		case EAspMenuCmdChange:
+			{				
+			CAspListItemData* item = ItemForIndex(ListBox()->CurrentItemIndex());
+			item->iSelectKeyPressed = EFalse;
+			HandleOKL();
+
+			break;
+			}
+
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+
+		default:
+		    break;
+		}
+	
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+		// save silently and quit application (= return ETrue)
+		TRAP_IGNORE(SaveSettingsL());
+	
+		return ETrue;
+		}
+
+	if ( aButtonId == EAknSoftkeyBack )
+        {
+		TInt index = CheckMandatoryFieldsL();
+		if (index != KErrNotFound)
+			{
+			if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY))
+				{
+				ListBox()->SetCurrentItemIndexAndDraw(index);
+				return EFalse; // leave dialog open
+				}
+			}
+		
+		SaveSettingsL();
+		return ETrue;
+		}
+
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::OfferKeyEventL
+//
+// Handle key events.
+//------------------------------------------------------------------------------
+//
+TKeyResponse CAspFilterDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+			case EKeyOK: // OK button
+				{
+				CAspListItemData* item = ItemForIndex(ListBox()->CurrentItemIndex());
+			    item->iSelectKeyPressed = ETrue;
+
+				HandleOKL();
+				return EKeyWasConsumed;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::PreLayoutDynInitL
+//
+// Called by system before the dialog is shown.
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::PreLayoutDynInitL()
+	{
+	iListBox = (CAknSettingStyleListBox*)Control(EAspFilterDialog);
+	
+	ListBox()->SetListBoxObserver(this);
+	ListBox()->CreateScrollBarFrameL( ETrue );
+	ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); 
+	
+    CreateSettingsListL();
+    UpdateListBoxL(ListBox(), iSettingList);
+	
+	//Set title pane text
+	iStatusPaneHandler->SetTitleL(iFilter->DisplayName());
+	}
+
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::DynInitMenuPaneL( TInt aResourceID, CEikMenuPane* aMenuPane)
+	{
+    if (aResourceID != R_ASP_FILTER_DIALOG_MENU_PANE)
+		{
+		return;
+		}
+
+	if (ListBox()->Model()->NumberOfItems() == 0)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::HandleListBoxEventL
+//
+// Handle listbox events.
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if (aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked)
+		{
+		HandleOKL();
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspFilterDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspFilterDialog::UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList)
+	{
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt index=0; index<count; index++ )
+		{
+	   	TBool convert = ETrue;
+
+		CAspListItemData* item = (*aItemList)[index];
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	ListBox()->HandleItemAdditionL();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspFilterDialog::CreateSettingsListL
+// 
+// Function creates setting list array (iSettingList).
+// ----------------------------------------------------------------------------
+//
+void CAspFilterDialog::CreateSettingsListL()
+	{
+    TInt count = iFilter->ItemCount();	
+	for (TInt i=0; i<count; i++)
+		{
+		CAspFilterItem* item = iFilter->Item(i);
+		AddItemL(item);
+		}
+		
+	// write setting data into each CAspListItemData
+	count=iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		item->iFilter = iFilter;
+		
+		InitSettingItemL(item);
+		}
+
+	SetVisibility();  // find out what setting appear on UI
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspFilterDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspFilterDialog::AddItemL(CAspFilterItem* aFilterItem)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(aFilterItem->DisplayName());
+	item->iItemId =aFilterItem->Id();
+	item->iItemType = aFilterItem->DataType();
+	item->iMandatory = aFilterItem->IsMandatory();
+	
+	if (item->iMandatory)
+		{
+		item->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
+		}
+	else
+		{
+		item->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+		}
+		
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::InitSettingItemL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterDialog::InitSettingItemL(CAspListItemData* aItem)
+	{
+	__ASSERT_ALWAYS(aItem->iFilter, TUtil::Panic(KErrGeneral));
+	
+	CAspFilterItem* filterItem = aItem->iFilter->ItemForId(aItem->iItemId);
+	
+	if (filterItem->ListType() != CAspFilterItem::ETypeQuery)
+		{
+		aItem->SetValueL(filterItem->DisplayValueL());
+		return; // this filter item is list, not a single value
+		}
+	
+	
+	HBufC* hBuf = HBufC::NewLC(KBufSize255);
+	TPtr ptr = hBuf->Des();
+	
+    	
+	switch (aItem->iItemType)
+		{
+		case CAspListItemData::ETypeNumber:
+			{
+			aItem->SetValueL(filterItem->IntL());
+		    aItem->iNumberData = filterItem->IntL();
+            break;
+			}
+
+		case CAspListItemData::ETypeText:
+			{
+			filterItem->GetText(ptr);
+   			aItem->SetValueL(ptr);
+    		break;
+			}
+
+		case CAspListItemData::ETypeBoolean:
+			{
+			CDesCArray* stringData = CAspResHandler::ReadDesArrayStaticLC(R_ASP_FILTER_ITEM_YESNO);
+			
+			aItem->iNumberData = EAspSettingEnabled;      // 1;
+			if (!filterItem->BoolL())
+				{
+				aItem->iNumberData = EAspSettingDisabled; // 0;
+				}
+			
+         	aItem->SetValueL((*stringData)[aItem->iNumberData]);
+         	aItem->iResource = R_ASP_FILTER_ITEM_YESNO;
+         	
+         	CleanupStack::PopAndDestroy(stringData);
+			break;
+     		}
+
+		case CAspListItemData::ETypeTime:
+			{
+    		aItem->iTime = filterItem->TimeL();
+    		if (aItem->iTime > 0)
+    			{
+    			TUtil::GetTimeTextL(ptr, aItem->iTime);
+    		    aItem->SetValueL(ptr);
+    			}
+	
+			break;
+			}
+
+		case CAspListItemData::ETypeDate:
+			{
+    		aItem->iDate = filterItem->DateL();
+    		if (aItem->iDate > 0)
+    			{
+    			TUtil::GetDateTextL(ptr, aItem->iDate);
+    		    aItem->SetValueL(ptr);
+    			}
+	
+			break;
+			}
+
+        default:
+			TUtil::Panic(KErrArgument);
+			break;
+		
+		}
+		
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspFilterDialog::SetVisibility()
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::SaveSettingsL
+//
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::SaveSettingsL()
+	{
+    iFilter->SaveL();
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::CheckMandatoryFieldsL
+//
+// Check that mandatory fields are filled correctly.
+//------------------------------------------------------------------------------
+//
+TInt CAspFilterDialog::CheckMandatoryFieldsL()
+	{ 
+    TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		if (item->iMandatory && item->IsEmpty())
+			{
+			return item->iIndex;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditFilterL
+//
+// NOTE: Function is not used by CAspFilterDialog. It can be called from
+// other dialogs in case filter only contains one filter item.
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditFilterL(CAspListItemData& aItem)
+	{
+    __ASSERT_ALWAYS(aItem.iFilter, TUtil::Panic(KErrGeneral));
+	
+	if (aItem.iFilter->ItemCount() != 1)
+		{
+		return EFalse; // this functions edits filter with one filter item
+		}
+		
+	CAspFilterItem* filterItem = aItem.iFilter->Item(0);
+		
+	__ASSERT_ALWAYS(filterItem, TUtil::Panic(KErrGeneral));
+	
+	
+	CAspListItemData* item = CAspListItemData::NewLC();
+	
+	item->SetHeaderL(filterItem->DisplayName());
+	item->iItemId = filterItem->Id();
+	item->iItemType = filterItem->DataType();
+	item->iMandatory = filterItem->IsMandatory();
+	
+	item->iSelectKeyPressed = aItem.iSelectKeyPressed;
+	item->iFilter = aItem.iFilter;
+
+	if (item->iMandatory)
+		{
+		item->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
+		}
+	else
+		{
+		item->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+		}
+	
+	InitSettingItemL(item);
+	
+	TBool ret = EditSettingItemL(*item);
+	
+    CleanupStack::PopAndDestroy(item);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	__ASSERT_ALWAYS(aItem.iFilter, TUtil::Panic(KErrGeneral));
+	
+	TBool ret = EFalse;
+
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+    TInt type = filterItem->ListType();
+    
+	switch (type)
+		{
+		case CAspFilterItem::ETypeQuery:
+			ret = EditSettingItemQueryL(aItem);
+		    break;
+
+		case CAspFilterItem::ETypeSingleSelection:
+			ret = EditSingleChoiceListL(aItem);
+		    break;
+		
+		case CAspFilterItem::ETypeSingleSelectionUserDefined:
+			ret = EditSingleChoiceListL(aItem);
+		    break;
+
+		case CAspFilterItem::ETypeMultipleSelection:
+		    ret = EditMultiChoiceListL(aItem);
+		   	break;
+
+		case CAspFilterItem::ETypeMultipleSelectionUserDefined:
+		    ret = EditMultiChoiceListL(aItem);
+		   	break;
+
+		default:
+		    break;
+
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemQueryL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemQueryL(CAspListItemData& aItem)
+	{
+	TBool ret = EFalse;
+	
+	switch (aItem.iItemType)
+		{
+		case CAspListItemData::ETypeText:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeNumber:
+			ret = EditSettingItemNumberL(aItem);
+		    break;
+		
+		case CAspListItemData::ETypeBoolean:
+		    if (aItem.iSelectKeyPressed)
+		    	{
+		    	ret = EditSettingItemBooleanL(aItem);
+		    	}
+		    else
+		    	{
+		    	ret = EditSettingItemListL(aItem);
+		    	}
+		    break;
+
+		case CAspListItemData::ETypeTime:
+		    ret = EditSettingItemTimeL(aItem);
+		   	break;
+
+		case CAspListItemData::ETypeDate:
+		    ret = EditSettingItemDateL(aItem);
+		   	break;
+
+		default:
+		    break;
+
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSingleChoiceListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSingleChoiceListL(CAspListItemData& aItem)
+	{
+	CAspSelectionItemList*	list = new (ELeave) CAspSelectionItemList(1);
+	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
+
+	CAspFilterItem* filterItem = (aItem.iFilter)->ItemForId(aItem.iItemId);
+	TInt listType = filterItem->ListType();
+	TInt dataType = filterItem->DataType();
+	
+	TInt type = CAspChoiceList::ETypeNormal;
+	if (listType == CAspFilterItem::ETypeSingleSelectionUserDefined &&
+	    dataType == CAspListItemData::ETypeNumber)
+		{
+		type = CAspChoiceList::ETypeIntegerUserDefined;
+		}
+	
+	if (listType == CAspFilterItem::ETypeSingleSelectionUserDefined &&
+	    dataType == CAspListItemData::ETypeText)
+		{
+		type = CAspChoiceList::ETypeTextUserDefined;
+		}
+	
+	filterItem->GetSelectionL(list);
+	
+	CAspChoiceList* editor = CAspChoiceList::NewLC(filterItem->DisplayName(), list, type, filterItem->MaxLength());
+	
+	TBool ret = editor->ShowListL();
+	if (ret)
+		{
+		filterItem->SetSelectionL(list);
+		aItem.SetValueL(filterItem->DisplayValueL());
+		}
+		
+	
+	CleanupStack::PopAndDestroy(editor);
+	CleanupStack::PopAndDestroy(list);
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditMultiChoiceListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditMultiChoiceListL(CAspListItemData& aItem)
+	{
+	CAspSelectionItemList*	list = new (ELeave) CAspSelectionItemList(1);
+	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
+	
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+	TInt listType = filterItem->ListType();
+	TInt dataType = filterItem->DataType();
+	
+	TInt type = CAspChoiceList::ETypeNormal;
+	if (listType == CAspFilterItem::ETypeMultipleSelectionUserDefined &&
+	    dataType == CAspListItemData::ETypeNumber)
+		{
+		type = CAspChoiceList::ETypeIntegerUserDefined;
+		}
+	if (listType == CAspFilterItem::ETypeMultipleSelectionUserDefined &&
+	    dataType == CAspListItemData::ETypeText)
+		{
+		type = CAspChoiceList::ETypeTextUserDefined;
+		}
+	
+	filterItem->GetSelectionL(list);
+	
+	CAspMultiChoiceList* editor = CAspMultiChoiceList::NewLC(filterItem->DisplayName(), list, type, filterItem->MaxLength());
+	
+	TBool ret = editor->ShowListL();
+	if (ret)
+		{
+		filterItem->SetSelectionL(list);
+		aItem.SetValueL(filterItem->DisplayValueL());
+		}
+	
+	
+	CleanupStack::PopAndDestroy(editor);
+	CleanupStack::PopAndDestroy(list);
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemTextL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemTextL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+	
+	HBufC* hBuf = HBufC::NewLC(KBufSize255);
+	TPtr ptr = hBuf->Des();
+	
+	TUtil::StrCopy(ptr, aItem.Value());
+	
+	TBool ret = TDialogUtil::ShowTextEditorL(ptr, aItem.Header(), aItem.iMandatory, aItem.iLatinInput, filterItem->MaxLength());
+	if (ret)
+		{
+		aItem.SetValueL(ptr);
+		filterItem->SetTextL(ptr);
+		}
+		
+	CleanupStack::PopAndDestroy(hBuf);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemListL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+	
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* stringData = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	
+	TBool ret = TDialogUtil::ShowListEditorL(stringData, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = curSelection; 
+		aItem.SetValueL((*stringData)[curSelection]);
+		filterItem->SetIntL(aItem.iNumberData);
+		}
+
+	CleanupStack::PopAndDestroy(stringData);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemBooleanL
+//
+// Change Yes/No value straight if ok key is pressed
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemBooleanL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+		
+	CDesCArray* stringData = CAspResHandler::ReadDesArrayStaticLC(R_ASP_FILTER_ITEM_YESNO);
+	
+	if (aItem.iNumberData == EAspSettingDisabled)
+		{
+		aItem.iNumberData = EAspSettingEnabled;
+		}
+	else
+		{
+		aItem.iNumberData = EAspSettingDisabled;
+		}
+	
+	aItem.SetValueL( (*stringData)[aItem.iNumberData] );
+	filterItem->SetIntL(aItem.iNumberData);
+
+	CleanupStack::PopAndDestroy(stringData);
+	return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemNumberL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemNumberL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+		
+	TBool ret = TDialogUtil::ShowIntegerEditorL(aItem.iNumberData, aItem.Header(), aItem.iMinValue, aItem.iMaxValue);
+
+	if (ret)
+		{
+		aItem.SetValueL(aItem.iNumberData);
+		filterItem->SetIntL(aItem.iNumberData);
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemDateL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemDateL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+	
+	TBool ret = TDialogUtil::ShowDateEditorL(aItem.iDate, aItem.Header());
+
+	if (ret)
+		{
+		TBuf<KBufSize> buf;
+		TUtil::GetDateTextL(buf, aItem.iDate);
+	    aItem.SetValueL(buf);
+        filterItem->SetDateL(aItem.iDate);
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::EditSettingItemTimeL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspFilterDialog::EditSettingItemTimeL(CAspListItemData& aItem)
+	{
+	CAspFilterItem* filterItem = aItem.iFilter->ItemForId(aItem.iItemId);
+	
+	TBool ret = TDialogUtil::ShowTimeEditorL(aItem.iTime, aItem.Header());
+
+	if (ret)
+		{
+		TBuf<KBufSize> buf;
+		TUtil::GetTimeTextL(buf, aItem.iTime);
+	    aItem.SetValueL(buf);
+        filterItem->SetTimeL(aItem.iTime);
+		}
+
+	return ret;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspFilterDialog::ItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspFilterDialog::ItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspFilterDialog::Item
+// 
+// Find item with aItemId (TAspConnectionSettingItem).
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspFilterDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::ResHandler
+// 
+// -----------------------------------------------------------------------------
+//
+CAspResHandler* CAspFilterDialog::ResHandler()
+	{
+	__ASSERT_DEBUG(iResHandler, TUtil::Panic(KErrGeneral));
+
+	return iResHandler;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspFilterDialog::ListBox
+// 
+// -----------------------------------------------------------------------------
+//
+CAknSettingStyleListBox* CAspFilterDialog::ListBox()
+	{
+    __ASSERT_DEBUG(iListBox, TUtil::Panic(KErrGeneral));	
+	
+	return iListBox;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspFilterDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspFilterDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor=KUidSmlSyncApp;
+	//aContext.iContext=KDS_HLP_APPLICATION;
+	}
+
+
+
+
+
+
+/*******************************************************************************
+ * class CAspMultiChoiceListSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceListSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceListSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+		
+	if (iType == ETypeUserDefined && aCommandId == EAknSoftkeySelect)
+		{
+		CAknSetStyleListBox* listBox = ListBoxControl();
+		TInt bottomIndex = listBox->BottomItemIndex();
+		TInt currentIndex = listBox->CurrentItemIndex();
+		
+		TBool itemChecked = (*iSelectionList)[currentIndex]->SelectionStatus();
+		
+		if (bottomIndex == currentIndex && !itemChecked) //  "User defined" has focus and is checked
+			{
+			
+			if (!iObserver->HandleChoiceListEventL(0, 0))
+				{
+				return;  // leave editor open if user defined editor is canceled
+				}
+			}
+		}
+		
+	CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceListSettingPage::CAspMultiChoiceListSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspMultiChoiceListSettingPage::CAspMultiChoiceListSettingPage(TInt aResourceID, CSelectionItemList* aItemArray,
+                                                               MAspChoiceListObserver* aObserver, TInt aType)
+ : CAknCheckBoxSettingPage(aResourceID, aItemArray)
+	{
+	iObserver = aObserver;
+	iType = aType;
+	iSelectionList = aItemArray;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspMultiChoiceListSettingPage::~CAspMultiChoiceListSettingPage()
+	{
+	}
+
+
+
+
+/*******************************************************************************
+ * class CAspChoiceListSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceListSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceListSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+		
+	if (iType == ETypeUserDefined && aCommandId == EAknSoftkeySelect)
+		{
+		CAknSetStyleListBox* listBox = ListBoxControl();
+		TInt num1 = listBox->BottomItemIndex();
+		TInt num2 = listBox->CurrentItemIndex();
+		
+		if (num1 == num2)
+			{
+			if (!iObserver->HandleChoiceListEventL(0, 0))
+				{
+				return;  // leave editor open if user defined editor is canceled
+				}
+			}
+		}
+		
+	CAknRadioButtonSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceListSettingPage::CAspChoiceListSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspChoiceListSettingPage::CAspChoiceListSettingPage(TInt aResourceID, TInt& aCurrentSelectionIndex, 
+                                                     const MDesCArray* aItemArray,
+                                                     MAspChoiceListObserver* aObserver, TInt aType)
+ : CAknRadioButtonSettingPage(aResourceID, aCurrentSelectionIndex, aItemArray)
+	{
+	iObserver = aObserver;
+	iType = aType;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspChoiceListSettingPage::~CAspChoiceListSettingPage()
+	{
+	}
+
+
+
+
+	
+/*******************************************************************************
+ * class CAspChoiceList
+ *******************************************************************************/
+	
+	
+	
+// -----------------------------------------------------------------------------
+// CAspChoiceList::NewLC
+//
+// -----------------------------------------------------------------------------
+CAspChoiceList* CAspChoiceList::NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength)
+    {
+    CAspChoiceList* self = new (ELeave) CAspChoiceList(aTitle, aList, aType, aMaxLength);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    return(self);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::CAspChoiceList
+// 
+//------------------------------------------------------------------------------
+//
+CAspChoiceList::CAspChoiceList(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength)
+	{
+	__ASSERT_DEBUG(aList, TUtil::Panic(KErrGeneral));
+	
+	TUtil::StrCopy(iTitle, aTitle);
+	iSelectionList = aList;
+	iListType = aType;
+	iMaxTextLength = aMaxLength;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspChoiceList::~CAspChoiceList()
+	{
+	}
+
+	
+//------------------------------------------------------------------------------
+// CAspChoiceList::ConstructL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceList::ConstructL()
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::ShowListL
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspChoiceList::ShowListL()
+	{
+	TInt current = SelectedIndex(iSelectionList);
+	TInt listType = CAspChoiceListSettingPage::ETypeNormal;
+	if (iListType != CAspChoiceList::ETypeNormal)
+		{
+		listType = CAspChoiceListSettingPage::ETypeUserDefined;
+		AddUserDefinedL(); // replace last item text as "User defined"
+		}
+		
+	CDesCArray* arr = DesArrayLC(iSelectionList);
+
+	CAspChoiceListSettingPage* dlg = new (ELeave) CAspChoiceListSettingPage(
+	                                       R_ASP_SETTING_RADIO, current, arr, this, listType);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(iTitle); 
+	CleanupStack::Pop(dlg);
+
+	TBool ret = dlg->ExecuteLD();
+	
+	SetSelectedIndex(iSelectionList, current);
+	if (iListType != CAspChoiceList::ETypeNormal)
+		{
+		RemoveUserDefinedL(); // restore original last item text
+		}
+	
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::DesArrayLC
+// 
+//------------------------------------------------------------------------------
+//
+CDesCArray* CAspChoiceList::DesArrayLC(CSelectionItemList* aList)
+	{
+	CDesCArray* arr = new (ELeave) CDesCArrayFlat(5);
+	CleanupStack::PushL(arr);
+	
+	TInt count = aList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* item = (*aList)[i];
+		TBuf<128> buf(item->ItemText());
+		arr->AppendL(item->ItemText());
+		}
+		
+	return arr;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::SelectedIndex
+// 
+//------------------------------------------------------------------------------
+//
+TInt CAspChoiceList::SelectedIndex(CSelectionItemList* aList)
+	{
+    TInt count = aList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* item = (*aList)[count-1];
+		if (item->SelectionStatus())
+			{
+			return i;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::SetSelectedIndex
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceList::SetSelectedIndex(CSelectionItemList* aList, TInt aIndex)
+	{
+    TInt count = aList->Count();
+    
+    __ASSERT_DEBUG(aIndex<count, TUtil::Panic(KErrGeneral));
+    
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* item = (*aList)[i];
+		if (i == aIndex)
+			{
+			item->SetSelectionStatus(ETrue);
+			}
+		else
+			{
+			item->SetSelectionStatus(EFalse);
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::AddItemL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceList::AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable)
+	{
+	CSelectableItem* item = new (ELeave) CSelectableItem(aText, aEnable);
+   	CleanupStack::PushL(item);
+	item->ConstructL();
+	aList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+	
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::AddUserDefined
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceList::AddUserDefinedL()
+	{
+	TInt count = iSelectionList->Count();
+	CSelectableItem* item = (*iSelectionList)[count-1];
+	
+	TBool selected = item->SelectionStatus();
+	iUserDefinedText = item->ItemText();
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		User::LeaveIfError(TUtil::StrToInt(iUserDefinedText, iUserDefinedInt));
+		}
+
+	
+	delete item;
+	iSelectionList->Delete(count-1);
+	iSelectionList->Compress();
+
+	TBuf<KBufSize> buf;
+	CAspResHandler::ReadL(buf, R_ASP_LIST_USER_DEFINED);
+	
+	
+	AddItemL(iSelectionList, buf, selected);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::RemoveUserDefined
+// 
+//------------------------------------------------------------------------------
+//
+void CAspChoiceList::RemoveUserDefinedL()
+	{
+	TInt count = iSelectionList->Count();
+	CSelectableItem* item = (*iSelectionList)[count-1];
+    TBool selected = item->SelectionStatus();
+
+	delete item;
+	iSelectionList->Delete(count-1);
+	iSelectionList->Compress();
+
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		iUserDefinedText.Num(iUserDefinedInt);
+		}
+	AddItemL(iSelectionList, iUserDefinedText, selected);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::EditTextL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspChoiceList::EditTextL(TDes& aText, const TDesC& aTitle)
+	{
+	TBool mandatory = EFalse;
+	TBool latinInput = ETrue;
+	TInt maxLength = iMaxTextLength;
+	
+	return TDialogUtil::ShowTextEditorL(aText, aTitle, mandatory, latinInput, maxLength);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspChoiceList::HandleChoiceListEventL
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspChoiceList::HandleChoiceListEventL(TInt /*aEvent*/, TInt /*aListType*/)
+	{
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		return TDialogUtil::ShowIntegerEditorL(iUserDefinedInt, iTitle, KErrNotFound, KErrNotFound);
+		}
+	else if (iListType == CAspChoiceList::ETypeTextUserDefined)
+		{
+		return EditTextL(iUserDefinedText, iTitle);
+		}
+		
+	return EFalse;
+	}
+
+	
+	
+	
+/*******************************************************************************
+ * class CAspMultiChoiceList
+ *******************************************************************************/
+	
+	
+// -----------------------------------------------------------------------------
+// CAspMultiChoiceList::NewLC
+//
+// -----------------------------------------------------------------------------
+CAspMultiChoiceList* CAspMultiChoiceList::NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength)
+    {
+    CAspMultiChoiceList* self = new (ELeave) CAspMultiChoiceList(aTitle, aList, aType, aMaxLength);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    return(self);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::CAspMultiChoiceList
+// 
+//------------------------------------------------------------------------------
+//
+CAspMultiChoiceList::CAspMultiChoiceList(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength)
+	{
+	__ASSERT_DEBUG(aList, TUtil::Panic(KErrGeneral));
+	
+	TUtil::StrCopy(iTitle, aTitle);
+	iSelectionList = aList;
+	iListType = aType;
+	iMaxTextLength = aMaxLength;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspMultiChoiceList::~CAspMultiChoiceList()
+	{
+	}
+	
+	
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::ConstructL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::ConstructL()
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::ShowListL
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspMultiChoiceList::ShowListL()
+	{
+	TInt listType = CAspChoiceListSettingPage::ETypeNormal;
+	if (iListType != CAspChoiceList::ETypeNormal)
+		{
+		listType = CAspChoiceListSettingPage::ETypeUserDefined;
+		AddUserDefinedL(); // replace last item text as "User defined"
+		}
+	
+
+	CAspMultiChoiceListSettingPage* dlg = new (ELeave) CAspMultiChoiceListSettingPage(
+	                                       R_ASP_SETTING_RADIO, iSelectionList, this, listType);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(iTitle); 
+	CleanupStack::Pop(dlg);
+
+	TBool ret = dlg->ExecuteLD();
+	
+	if (iListType != CAspChoiceList::ETypeNormal)
+		{
+		RemoveUserDefinedL(); // set original last item text
+		}
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::AddItemL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable)
+	{
+	CSelectableItem* item = new (ELeave) CSelectableItem(aText, aEnable);
+   	CleanupStack::PushL(item);
+	item->ConstructL();
+	aList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::AddItemL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::AddItemL(TDes& aText, TBool aEnable)
+	{
+	AddItemL(iSelectionList, aText, aEnable);
+	}
+	
+	
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::AddItemL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::AddItemL(TInt aNumber, TBool aEnable)
+	{
+	TBuf<KBufSize> buf;
+	
+	buf.Num(aNumber);
+	AddItemL(iSelectionList, buf, aEnable);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::AddUserDefined
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::AddUserDefinedL()
+	{
+	TInt count = iSelectionList->Count();
+	CSelectableItem* item = (*iSelectionList)[count-1];
+	
+	TBool selected = item->SelectionStatus();
+	iUserDefinedText = item->ItemText();
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		User::LeaveIfError(TUtil::StrToInt(iUserDefinedText, iUserDefinedInt));
+		}
+
+	
+	delete item;
+	iSelectionList->Delete(count-1);
+	iSelectionList->Compress();
+
+	TBuf<KBufSize> buf;
+	CAspResHandler::ReadL(buf, R_ASP_LIST_USER_DEFINED);
+	
+	
+	AddItemL(iSelectionList, buf, selected);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::RemoveUserDefined
+// 
+//------------------------------------------------------------------------------
+//
+void CAspMultiChoiceList::RemoveUserDefinedL()
+	{
+	TInt count = iSelectionList->Count();
+	CSelectableItem* item = (*iSelectionList)[count-1];
+    TBool selected = item->SelectionStatus();
+
+	delete item;
+	iSelectionList->Delete(count-1);
+	iSelectionList->Compress();
+
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		iUserDefinedText.Num(iUserDefinedInt);
+		}
+	AddItemL(iSelectionList, iUserDefinedText, selected);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::EditTextL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspMultiChoiceList::EditTextL(TDes& aText, const TDesC& aTitle)
+	{
+	TBool mandatory = ETrue;
+	TBool latinInput = ETrue;
+	TInt maxLength = iMaxTextLength;
+	
+	return TDialogUtil::ShowTextEditorL(aText, aTitle, mandatory, latinInput, maxLength);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspMultiChoiceList::HandleChoiceListEventL
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspMultiChoiceList::HandleChoiceListEventL(TInt /*aEvent*/, TInt /*aListType*/)
+	{
+	if (iListType == CAspChoiceList::ETypeIntegerUserDefined)
+		{
+		return TDialogUtil::ShowIntegerEditorL(iUserDefinedInt, iTitle, KErrNotFound, KErrNotFound);
+		}
+	else if (iListType == CAspChoiceList::ETypeTextUserDefined)
+		{
+		return EditTextL(iUserDefinedText, iTitle);
+		}
+		
+	return EFalse;
+	}
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspLogDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,730 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspLogDialog.h"
+#include "AspDialogUtil.h"
+#include "AspUtil.h"
+#include "AspDebug.h"
+
+#include <SyncMLErr.h>  // sync error codes
+#include "AspSchedule.h"
+
+
+
+/*******************************************************************************
+ * class CAspLogDialog
+ *******************************************************************************/
+
+
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+void CAspLogDialog::ShowDialogL()
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(R_SML_LOG_SYNCLOG_TITLE);
+
+    TDialogUtil::ShowPopupDialog2L(hBuf->Des(), iList);
+    
+   	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspLogDialog* CAspLogDialog::NewL(const TAspParam& aParam)
+    {
+    CAspLogDialog* self = new (ELeave) CAspLogDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::CAspLogDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspLogDialog::CAspLogDialog(const TAspParam& aParam)
+	{
+    iProfileId = aParam.iProfileId;
+	iSyncSession = aParam.iSyncSession;
+
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrArgument));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspLogDialog::ConstructL()
+    {
+    iResHandler = CAspResHandler::NewL();
+    iList = new (ELeave) CDesCArrayFlat(1);
+   		
+    TAspParam param(KErrNotFound, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);   		
+	profile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+	
+    TAspParam param2(KErrNotFound, iSyncSession);
+	param2.iProfile = profile;
+	param2.iMode = CAspContentList::EInitAll;
+	CAspContentList* taskList = CAspContentList::NewLC(param2);
+	
+	CreateListL(iList, profile, taskList);
+	
+	CleanupStack::PopAndDestroy(taskList);
+	CleanupStack::PopAndDestroy(profile);
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspLogDialog::~CAspLogDialog()
+    {
+	delete iResHandler;
+    delete iList;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::CreateListL
+// 
+// Example log format:
+//
+// Profile: PC Suite
+// Server: PC Suite
+// Date: 13/10/2004
+// Time: 11:04
+// Status: Complete
+//
+// Phone:  
+//
+// Added Contacts:
+//  4
+// Added Notes:
+//  12
+// Deleted Calendar:
+//  2
+//
+// Server:
+//
+// Added contacts:
+//  12
+// 
+// -----------------------------------------------------------------------------
+void CAspLogDialog::CreateListL(CDesCArray* aList, CAspProfile* aProfile,
+                                CAspContentList* aTaskList)
+	{
+	_LIT(KTab, "\t");
+	
+	aList->Reset();
+	
+	const CSyncMLHistoryJob* historyJob = aProfile->LatestHistoryJob();
+   	if (!historyJob)
+   		{
+   		User::Leave(KErrNotFound);  // this profile has not been synced
+   		}
+
+		
+	TTime time = historyJob->TimeStamp();
+	
+	CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_PROFILE); //profile name heading
+	iBuf.Append(KTab);
+
+#ifdef RD_DSUI_TIMEDSYNC
+	 CAspSchedule* schedule = CAspSchedule::NewLC();
+	 TInt asProfileId = schedule->AutoSyncProfileId();
+	 if (asProfileId == aProfile->ProfileId())
+		{
+		TInt profileId = schedule->ProfileId();
+		TAspParam param(KErrNotFound, iSyncSession);
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		profile->OpenL(profileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+
+		profile->GetName(iBuf2);
+		CleanupStack::PopAndDestroy(profile);
+		}
+	 else
+		{
+		aProfile->GetName(iBuf2);
+		}
+	 CleanupStack::PopAndDestroy(schedule);
+#else	 
+	aProfile->GetName(iBuf2);
+#endif
+	iBuf.Append(iBuf2);
+	AddLineL(aList, iBuf);
+    
+	CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_REMOTE); //server name heading
+	iBuf.Append(KTab);
+
+	if(aProfile->IsPCSuiteProfile(aProfile))
+	{
+		aProfile->GetLocalisedPCSuite(iBuf2);
+	}
+	else
+	{
+		TInt num = 0;
+		aProfile->GetHostAddress(iBuf2, num);
+	}	
+	iBuf.Append(iBuf2);
+	AddLineL(aList, iBuf);
+		
+    CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_DATE); // sync date heading
+	iBuf.Append(KTab);
+	TUtil::GetDateTextL(iBuf2, time);
+	iBuf.Append(iBuf2);
+	AddLineL(aList, iBuf);
+
+	CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_TIME); // sync time heading
+	iBuf.Append(KTab);
+    TUtil::GetTimeTextL(iBuf2, time);
+	iBuf.Append(iBuf2);
+	AddLineL(aList, iBuf);	
+		
+
+	//
+	// check sync errors
+	//
+	CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_STATUS); // status heading
+	iBuf.Append(KTab);	
+		
+	TInt syncError = historyJob->ResultCode();
+	if (syncError != KErrNone && syncError != SyncMLError::KErrSlowSync)
+		{
+		if (syncError == KErrCancel)
+			{
+			CAspResHandler::ReadL(iBuf2, R_QTN_SML_LOG_CANCELLED);
+			}
+		else
+			{
+			CAspResHandler::ReadL(iBuf2, R_QTN_SML_LOG_ERR);
+			}
+		
+		iBuf.Append(iBuf2);
+		AddLineL(aList, iBuf);
+		
+		// Added for syncml engine error handling and displaying in view logs
+		if (syncError <= SyncMLError::KErrSyncEngineErrorBase)
+			{
+			TInt id = TAspSyncError::GetSmlErrorValue (syncError) ;
+			CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_ERROR); // sync error heading
+			iBuf.Append(KTab);
+			CAspResHandler::ReadL(iBuf2, id);
+			iBuf.Append(iBuf2);
+			AddLineL(aList, iBuf);
+			}
+		
+		return;
+		}
+	
+	if (HasTaskErrors(historyJob))
+		{
+		CAspResHandler::ReadL(iBuf2, R_QTN_SML_LOG_ERR);
+		iBuf.Append(iBuf2);
+    	AddLineL(aList, iBuf);
+		}
+    else
+    	{
+    	CAspResHandler::ReadL(iBuf2, R_QTN_SML_LOG_OK);
+	    iBuf.Append(iBuf2);
+    	AddLineL(aList, iBuf);
+    	}
+		
+	
+	if (PhoneModified(historyJob))
+		{
+		CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_PHONE);
+	    iBuf.Append(KTab);
+   	    AddLineL(aList, iBuf);
+
+        AddLogItemsL(aList, historyJob, aTaskList, ELogAddedPhone);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogUpdatedPhone);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogDeletedPhone);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogDiscardedPhone);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogMovedPhone);
+		}
+
+	
+	if (ServerModified(historyJob))
+		{
+		CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_SERVER);
+	    iBuf.Append(KTab);
+   	    AddLineL(aList, iBuf);
+
+        AddLogItemsL(aList, historyJob, aTaskList, ELogAddedServer);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogUpdatedServer);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogDeletedServer);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogDiscardedServer);
+        AddLogItemsL(aList, historyJob, aTaskList, ELogMovedServer);
+		}
+
+	if (HasTaskErrors(historyJob))
+		{
+		CAspResHandler::ReadL(iBuf, R_QTN_SML_LOG_ERROR);
+	    iBuf.Append(KTab);
+   	    AddLineL(aList, iBuf);
+
+        AddTaskErrorsL(aList, historyJob, aTaskList);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::AddLogItemsL
+// 
+// -----------------------------------------------------------------------------
+void CAspLogDialog::AddLogItemsL(CDesCArray* aList, const CSyncMLHistoryJob* aHistoryJob, 
+                                 CAspContentList* aTaskList, TInt aType)
+	{
+	_LIT(KFormat, "%S\t%d");
+	
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& taskInfo = aHistoryJob->TaskAt(i);
+        	
+        TInt index = aTaskList->FindProviderIndexForTask(taskInfo.iTaskId);
+        if (index == KErrNotFound)
+    	    {
+       	    continue; // profile no longer has this task
+    	    }
+       	TAspProviderItem& provider = aTaskList->ProviderItem(index);
+     
+     
+		TInt count = SyncedItemCount(taskInfo, aType);
+		if (count == 0)
+			{
+			continue;
+			}
+
+		HBufC* hBuf = LogItemTextLC(aType, provider.iDataProviderId, provider.iDisplayName);
+	    TPtr ptr = hBuf->Des();
+	    iBuf.Format(KFormat, &ptr, count);
+	    CleanupStack::PopAndDestroy(hBuf);
+	    
+       	AddLineL(aList, iBuf);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::AddTaskErrorsL
+// 
+// -----------------------------------------------------------------------------
+void CAspLogDialog::AddTaskErrorsL(CDesCArray* aList, 
+                                   const CSyncMLHistoryJob* aHistoryJob, 
+                                   CAspContentList* aTaskList)
+	{
+	_LIT(KTab, "\t");
+	
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& taskInfo = aHistoryJob->TaskAt(i);
+        	
+        TInt index = aTaskList->FindProviderIndexForTask(taskInfo.iTaskId);
+        if (index == KErrNotFound)
+    	    {
+       	    continue; // profile no longer has this task
+    	    }
+    
+    	TAspProviderItem& provider = aTaskList->ProviderItem(index);
+  	
+		if (taskInfo.iError != KErrNone && taskInfo.iError != SyncMLError::KErrSlowSync)
+		    {
+	    	iBuf = KNullDesC;
+	    	HBufC* hBuf = CAspResHandler::GetContentNameLC(provider.iDataProviderId,
+	    	                                               provider.iDisplayName);
+	        iBuf.Append(hBuf->Des());
+	        CleanupStack::PopAndDestroy(hBuf);
+
+		    CAspResHandler::ReadL(iBuf2, R_QTN_SML_LOG_ERR); // "Incomplete"
+		    iBuf.Append(KTab);
+     	    iBuf.Append(iBuf2);
+     	    
+#ifdef _DEBUG 
+       	    TBuf<64> buf;
+     	    buf.Format(_L(" (%d)"), taskInfo.iError);
+     	    iBuf.Append(buf);
+#endif
+     	    
+     	    AddLineL(aList, iBuf);
+    		}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::PhoneModified
+// 
+// -----------------------------------------------------------------------------
+TBool CAspLogDialog::PhoneModified(const CSyncMLHistoryJob* aHistoryJob)
+	{
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& task = aHistoryJob->TaskAt(i);
+	    
+	    TInt count = task.iServerItemsAdded + task.iServerItemsChanged +
+	                 task.iServerItemsDeleted + task.iServerItemsFailed +
+	                 task.iServerItemsMoved;
+        
+        if (count > 0)
+        	{
+        	return ETrue;
+        	}
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::ServerModified
+// 
+// -----------------------------------------------------------------------------
+TBool CAspLogDialog::ServerModified(const CSyncMLHistoryJob* aHistoryJob)
+	{
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& task = aHistoryJob->TaskAt(i);
+
+	    TInt count = task.iItemsAdded + task.iItemsChanged +
+	                 task.iItemsDeleted + task.iItemsFailed +
+	                 task.iItemsMoved;
+        
+        if (count > 0)
+        	{
+        	return ETrue;
+        	}
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::HasTaskErrors
+// 
+// -----------------------------------------------------------------------------
+TBool CAspLogDialog::HasTaskErrors(const CSyncMLHistoryJob* aHistoryJob)
+	{
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& taskInfo = aHistoryJob->TaskAt(i);
+        
+        if (taskInfo.iError != KErrNone && taskInfo.iError != SyncMLError::KErrSlowSync)
+        	{
+        	FLOG(_L("### CAspLogDialog::HasTaskErrors (%d) ###"), taskInfo.iError);
+        	return ETrue;
+        	}
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::AddLineL
+// 
+// -----------------------------------------------------------------------------
+void CAspLogDialog::AddLineL(CDesCArray* aList, TDes& aText)
+	{
+	AknTextUtils::DisplayTextLanguageSpecificNumberConversion(aText);
+	aList->AppendL(aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::SyncedItemCount
+// 
+// -----------------------------------------------------------------------------
+TInt CAspLogDialog::SyncedItemCount(const CSyncMLHistoryJob::TTaskInfo& aTaskInfo, TInt aType)
+	{
+	TInt count = 0;
+
+	switch (aType)
+		{
+		case ELogAddedPhone:
+			count = aTaskInfo.iServerItemsAdded;
+			break;
+		case ELogUpdatedPhone:
+			count = aTaskInfo.iServerItemsChanged;
+			break;
+		case ELogDeletedPhone:
+			count = aTaskInfo.iServerItemsDeleted;
+			break;
+		case ELogDiscardedPhone:
+			count = aTaskInfo.iServerItemsFailed;
+			break;
+		case ELogMovedPhone:
+			count = aTaskInfo.iServerItemsMoved;
+			break;
+
+		case ELogAddedServer:
+			count = aTaskInfo.iItemsAdded;
+			break;
+		case ELogUpdatedServer:
+			count = aTaskInfo.iItemsChanged;
+			break;
+		case ELogDeletedServer:
+			count = aTaskInfo.iItemsDeleted;
+			break;
+		case ELogDiscardedServer:
+			count = aTaskInfo.iItemsFailed;
+			break;
+		case ELogMovedServer:
+			count = aTaskInfo.iItemsMoved;
+			break;
+
+		default:
+			break;
+		}
+
+	return count;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspLogDialog::LogItemTextLC
+// 
+// -----------------------------------------------------------------------------
+HBufC* CAspLogDialog::LogItemTextLC(TInt aType, TInt aDataProviderId, const TDesC& aDisplayName)
+	{
+	TInt resourceId = KErrNotFound;
+	
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_CONTACTS;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_CONTACTS;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_CONTACTS;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_CONTACTS;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_CONTACTS;
+			}
+		}
+	else if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_CALENDAR;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_CALENDAR;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_CALENDAR;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_CALENDAR;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_CALENDAR;
+			}
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_EMAIL;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_EMAIL;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_EMAIL;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_EMAIL;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_EMAIL;
+			}
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_NOTES;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_NOTES;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_NOTES;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_NOTES;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_NOTES;
+			}
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_SMS;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_SMS;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_SMS;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_SMS;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_SMS;
+			}
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_MMS;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_MMS;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_MMS;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_MMS;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_MMS;
+			}
+		}
+
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_BKM;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_BKM;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_BKM;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_BKM;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_BKM;
+			}
+		}
+	
+	else  // unknown data provider
+		{
+		if (aType == ELogAddedPhone || aType == ELogAddedServer)
+			{
+			resourceId = R_QTN_SML_LOG_ADDED_CONTENT;
+			}
+		if (aType == ELogUpdatedPhone || aType == ELogUpdatedServer)
+			{
+			resourceId = R_QTN_SML_LOG_UPDATED_CONTENT;
+			}
+		if (aType == ELogDeletedPhone || aType == ELogDeletedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DELETED_CONTENT;
+			}
+		if (aType == ELogDiscardedPhone || aType == ELogDiscardedServer)
+			{
+			resourceId = R_QTN_SML_LOG_DISCARDED_CONTENT;
+			}
+		if (aType == ELogMovedPhone || aType == ELogMovedServer)
+			{
+			resourceId = R_QTN_SML_LOG_MOVED_CONTENT;
+			}
+
+        __ASSERT_DEBUG(resourceId != KErrNotFound, TUtil::Panic(KErrGeneral));
+        
+		return CAspResHandler::ReadLC(resourceId, aDisplayName);
+		}
+	
+	__ASSERT_DEBUG(resourceId != KErrNotFound, TUtil::Panic(KErrGeneral));
+	
+    return CAspResHandler::ReadLC(resourceId);
+	}
+
+
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspPreSyncPluginInterface.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This implementation enumerates and returns the plugin
+*
+*/
+
+
+// INCLUDE FILES
+#include "AspPreSyncPluginInterface.h"
+#include "CPreSyncPlugin.h"
+
+_LIT(kDefault,"DEFAULT");
+
+// ============================== MEMBER FUNCTIONS ============================
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::NewL
+// Two Phase Construction
+// ----------------------------------------------------------------------------
+CPreSyncPluginInterface* CPreSyncPluginInterface::NewL()
+{    
+    CPreSyncPluginInterface* self = CPreSyncPluginInterface::NewLC();
+    CleanupStack::Pop( self );
+      
+    return self;
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::NewLC
+// Two Phase Construction
+// ---------------------------------------------------------------------------- 
+CPreSyncPluginInterface* CPreSyncPluginInterface::NewLC()
+{   
+    CPreSyncPluginInterface* self = new( ELeave ) CPreSyncPluginInterface();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::CPreSyncPluginInterface
+// Constructor
+// ----------------------------------------------------------------------------    
+CPreSyncPluginInterface::CPreSyncPluginInterface()
+{
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::ConstructL
+// 2nd phase constructor
+// ---------------------------------------------------------------------------- 
+void CPreSyncPluginInterface::ConstructL()
+{
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::~CPreSyncPluginInterface
+// Constructor
+// ---------------------------------------------------------------------------- 
+CPreSyncPluginInterface::~CPreSyncPluginInterface( ) 
+{
+    UnloadPlugIns();    
+}
+        
+/**
+* Lists all implementations which satisfy this ecom interface
+*
+* @param aImplInfoArray On return, contains the list of available implementations
+* 
+*/   
+inline void CPreSyncPluginInterface::ListAllImplementationsL( RImplInfoPtrArray& aImplInfoArray )
+{
+    REComSession::ListImplementationsL( KPreSyncPluginInterfaceUid, aImplInfoArray );
+}
+        
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::InstantiateAllPlugInsL
+// Instantiates all plugins
+// ----------------------------------------------------------------------------     
+CPreSyncPlugin* CPreSyncPluginInterface::InstantiateRoamingPluginLC( TSmlProfileId aProfileId )
+{
+    RImplInfoPtrArray infoArray;
+    TBool bHandleSync = EFalse;
+    CPreSyncPlugin* syncPlugin = NULL;
+    CPreSyncPlugin* defaultSyncPlugin = NULL;
+
+    // Get list of all implementations
+    TRAPD(error, ListAllImplementationsL( infoArray ));
+    
+    if (error != KErrNone)
+        {
+        return NULL;
+        }
+    // Instantiate plugins for all impUIds by calling 
+    // InstantiatePlugInFromImpUidLC
+    for ( TInt i=0; i<infoArray.Count(); i++ )
+        {
+        // Get imp info
+        CImplementationInformation& info( *infoArray[i] );
+
+		TUid impUid ( info.ImplementationUid() );	        
+	    
+
+        if ( info.DisplayName().Compare(kDefault) == 0 )
+            {			
+	        //instantiate plugin for impUid
+	        defaultSyncPlugin = InstantiatePlugInFromImpUidLC( impUid );
+	        defaultSyncPlugin->SetProfile(aProfileId);
+            }
+		else
+		    {
+			syncPlugin = InstantiatePlugInFromImpUidLC( impUid );
+			syncPlugin->SetProfile(aProfileId);
+			if(syncPlugin->IsSupported())
+			    {
+				bHandleSync = ETrue;
+				break;
+			    }
+			else
+			    {
+			    CleanupStack::PopAndDestroy(syncPlugin);
+			    }
+		    }
+        }
+
+    infoArray.ResetAndDestroy();
+	if(bHandleSync)
+	{		
+		//delete defaultSyncPlugin;
+	    if(defaultSyncPlugin != NULL)
+	    {
+	    CleanupStack::PopAndDestroy(defaultSyncPlugin);
+	    }
+		return syncPlugin;
+	}
+	else
+	{
+		return defaultSyncPlugin;
+	}    
+ }
+
+// -----------------------------------------------------------------------------
+// CPreSyncPluginInterface::UnloadPlugIns
+// Unloads plugins
+// -----------------------------------------------------------------------------
+void CPreSyncPluginInterface::UnloadPlugIns()
+{    
+    REComSession::FinalClose();
+}
+
+// ----------------------------------------------------------------------------
+// CPreSyncPluginInterface::InstantiatePlugInFromImpUidLC
+// Instantiates plugin
+// ---------------------------------------------------------------------------- 
+CPreSyncPlugin* CPreSyncPluginInterface::InstantiatePlugInFromImpUidLC( const TUid& aImpUid )
+{    
+   // REComSession
+    CPreSyncPlugin *preSyncPlugin = CPreSyncPlugin::NewL(aImpUid);    
+    CleanupStack::PushL(preSyncPlugin);
+    return preSyncPlugin;
+}
+    
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfile.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,4048 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+// INCLUDES
+
+#include <SyncMLTransportProperties.h>
+#include <featmgr.h>   // FeatureManager
+
+#include "AspProfile.h"
+#include "AspResHandler.h"
+#include "AspDialogUtil.h"
+#include "AspDebug.h"
+#include "AspSchedule.h"
+#include <centralrepository.h> //CRepository
+
+
+
+/*******************************************************************************
+ * class TAspProviderItem
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// TAspProviderItem::CompareItems
+//
+// -----------------------------------------------------------------------------
+//
+TInt TAspProviderItem::CompareItems(const TAspProviderItem& aFirst, const TAspProviderItem& aSecond)
+	{
+	const TInt KNegative = -1;
+	const TInt KPositive = 1;
+	
+	TInt firstOrder = SortOrder(aFirst.iDataProviderId);
+	TInt secondOrder = SortOrder(aSecond.iDataProviderId);
+	
+	if (firstOrder > secondOrder)
+		{
+		return KNegative;
+		}
+	else if (secondOrder > firstOrder)
+		{
+		return KPositive;
+		}
+	else
+		{
+		return 0;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspProviderItem::CompareItems
+//
+// -----------------------------------------------------------------------------
+//
+TInt TAspProviderItem::SortOrder(TInt aDataProviderId)
+	{
+	TInt ret = EOrderOther;
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		ret = EOrderContact;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		ret = EOrderCalendar;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+		ret = EOrderNotes;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		ret = EOrderEmail;
+		}
+	return ret;
+	}
+	
+	
+
+/*******************************************************************************
+ * class CAspContentList
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspContentList* CAspContentList::NewLC(const TAspParam& aParam)
+    {
+   	FLOG( _L("CAspContentList::NewLC START") );
+   	
+    CAspContentList* self = new (ELeave) CAspContentList(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+    FLOG( _L("CAspContentList::NewLC END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspContentList* CAspContentList::NewL(const TAspParam& aParam)
+    {
+   	FLOG( _L("CAspContentList::NewL START") );
+   	
+    CAspContentList* self = new (ELeave) CAspContentList(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+    FLOG( _L("CAspContentList::NewL END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspContentList::~CAspContentList()
+    {
+	iProviderList.Close();
+	iTaskList.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ConstructL(void)
+    {
+	if (iListMode == EInitDataProviders)
+		{
+        InitDataProvidersL();
+		}
+	else if (iListMode == EInitTasks)
+		{
+		__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+		
+        InitAllTasksL();
+		}
+	else 
+		{
+		__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+		
+		InitDataProvidersL();
+		InitAllTasksL();
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CAspContentList
+//
+// -----------------------------------------------------------------------------
+//
+CAspContentList::CAspContentList(const TAspParam& aParam)
+	{
+	iSyncSession = aParam.iSyncSession;
+	iProfile = aParam.iProfile;
+	iListMode = aParam.iMode;
+	iApplicationId = aParam.iApplicationId;
+
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::SetProfile
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::SetProfile(CAspProfile* aProfile)
+	{
+	if (aProfile)
+		{
+
+	    __ASSERT_ALWAYS(iProfile == NULL, TUtil::Panic(KErrGeneral));
+
+		}
+
+	iProfile = aProfile;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::IsLocked
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspContentList::IsLocked()
+	{
+	if (iProfile)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ProviderCount
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::ProviderCount()
+	{
+	return iProviderList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ProviderItem
+// 
+// -----------------------------------------------------------------------------
+//
+TAspProviderItem& CAspContentList::ProviderItem(TInt aIndex)
+	{
+	if (aIndex < 0 || aIndex >= ProviderCount())
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	return iProviderList[aIndex];
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::FindProviderIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::FindProviderIndex(TInt aId)
+	{
+	TInt count = iProviderList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& item = iProviderList[i];
+		if (item.iDataProviderId == aId)
+			{
+			return i;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::FindProviderIndexForTask
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::FindProviderIndexForTask(TInt aId)
+	{
+	TInt index = FindTaskIndex(aId);
+	if (index == KErrNotFound)
+		{
+		return KErrNotFound;
+		}
+	
+	TAspTaskItem& item = TaskItem(index);
+	
+	return FindProviderIndex(item.iDataProviderId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::TaskCount
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::TaskCount()
+	{
+	return iTaskList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::TaskItem
+// 
+// -----------------------------------------------------------------------------
+//
+TAspTaskItem& CAspContentList::TaskItem(TInt aIndex)
+	{
+	if ((aIndex < 0) || (aIndex >= TaskCount()))
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	return iTaskList[aIndex];
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::FindTaskIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::FindTaskIndex(TInt aId)
+	{
+	TInt count = iTaskList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspTaskItem& task = iTaskList[i];
+		if (task.iTaskId == aId)
+			{
+			return i;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::FindTaskIndexForProvider
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::FindTaskIndexForProvider(TInt aId)
+	{
+	TInt count = iTaskList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspTaskItem& item = iTaskList[i];
+		if (item.iDataProviderId == aId)
+			{
+			return i;
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::FindTaskIdForProvider
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::FindTaskIdForProvider(TInt aId)
+	{
+	TInt index = FindTaskIndexForProvider(aId);
+	if (index == KErrNotFound)
+		{
+		return KErrNotFound;
+		}
+		
+	TAspTaskItem& item = iTaskList[index];
+	return item.iTaskId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::DoInitDataProvidersL
+// 
+// Initialize data provider list.
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::DoInitDataProvidersL()
+	{
+	FLOG( _L("CAspContentList::DoInitDataProvidersL START") );
+	
+	iProviderList.Reset();
+	
+	RArray<TSmlDataProviderId> arr;
+	
+	Session().ListDataProvidersL(arr);
+	CleanupClosePushL(arr);
+
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		RSyncMLDataProvider provider;
+		TInt id = arr[i];
+		
+		TRAPD(err, provider.OpenL(Session(), id));
+	
+		if (err == KErrNone)
+			{
+    		CleanupClosePushL(provider);
+
+	    	TAspProviderItem item;
+		    ReadDataProviderItemL(provider, item);
+            item.iIsIncludedInSync = EFalse;
+		    
+		    if (TUtil::IsEmpty(item.iDisplayName))
+		    	{
+		    	// providers must have display name
+		    	CleanupStack::PopAndDestroy(&provider);
+		    	FTRACE( RDebug::Print(_L("### provider has no display name (id=%x) ###"), item.iDataProviderId) );
+		    	continue;
+		    	}
+	
+		    User::LeaveIfError(iProviderList.Append(item));
+	        
+	        CleanupStack::PopAndDestroy(&provider);
+		    }
+		    
+		if (err != KErrNone)
+			{
+			FTRACE( RDebug::Print(_L("### RSyncMLDataProvider::Open failed (id=%x, err=%d) ###"), id, err) );
+			}
+		
+		}
+		
+	CleanupStack::PopAndDestroy(&arr);
+	
+	FLOG( _L("CAspContentList::DoInitDataProvidersL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::UpdateDataProviderL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::UpdateDataProviderL(TInt aDataProviderId)
+	{
+	TInt index = FindProviderIndex(aDataProviderId);
+	if (index == KErrNotFound)
+		{
+		return;  // unknown provider
+		}
+	TAspProviderItem& providerItem = ProviderItem(index);
+		
+	RArray<TSmlDataProviderId> arr;
+	Session().ListDataProvidersL(arr);
+	CleanupClosePushL(arr);
+
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		RSyncMLDataProvider provider;
+		TInt id = arr[i];
+		
+		TRAPD(err, provider.OpenL(Session(), id));
+	
+		if (err == KErrNone)
+			{
+    		CleanupClosePushL(provider);
+
+		    TInt id = provider.Identifier();
+		    if (id == aDataProviderId)
+		    	{
+       		    ReadDataProviderItemL(provider, providerItem);
+       		    CleanupStack::PopAndDestroy(&provider);
+       		    break;
+		    	}
+       
+	        CleanupStack::PopAndDestroy(&provider);
+		    }
+		}
+		
+	CleanupStack::PopAndDestroy(&arr);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ReadDataProviderItemL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ReadDataProviderItemL(RSyncMLDataProvider& aProvider, 
+                                            TAspProviderItem& aItem)
+	{
+    aItem.iTaskId=KErrNotFound;
+	aItem.iDataProviderId = aProvider.Identifier();
+		    
+    aItem.iSyncProtocol = ESmlVersion1_2;
+    //item.iSyncProtocol = provider.RequiredProtocolVersionL();
+		    
+		    
+    aItem.iAllowMultipleDataStores = aProvider.AllowsMultipleDataStores();
+    TUtil::StrCopy(aItem.iDisplayName, aProvider.DisplayName());
+	
+    TPtrC ptr = aProvider.DefaultDataStoreName();
+    if (TUtil::IsEmpty(ptr))
+    	{
+    	aItem.iHasDefaultDataStore = EFalse;
+    	aItem.iDefaultDataStore = KNullDesC;
+    	}
+    else
+    	{
+    	aItem.iHasDefaultDataStore = ETrue;
+    	TUtil::StrCopy(aItem.iDefaultDataStore, ptr);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::InitDataProvidersL
+// 
+// Initialize data provider list.
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::InitDataProvidersL()
+	{
+
+#ifdef _DEBUG
+   	TTime time_1 = TUtil::TimeBefore();
+#endif
+
+    DoInitDataProvidersL();
+    Sort();
+    
+#ifdef _DEBUG
+   	TUtil::TimeAfter(time_1, _L("CAspContentList::DoInitDataProvidersL took"));
+#endif
+
+
+#ifndef __SYNCML_DS_EMAIL   // KFeatureIdSyncMlDsEmail
+    RemoveDataProvider(KUidNSmlAdapterEMail.iUid);
+#endif
+
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspContentList::RemoveDataProvider
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::RemoveDataProvider(TInt aDataProviderId)
+	{
+    TInt index = FindProviderIndex(aDataProviderId);
+        
+    // remove data provider with id aDataProviderId
+    if (index != KErrNotFound)
+    	{
+    	iProviderList.Remove(index);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::InitAllTasksL
+//
+// Initialize task list.
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::InitAllTasksL()
+	{
+	FLOG( _L("CAspContentList::InitAllTasksL START") );
+	
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+	iTaskList.Reset();
+	
+	RArray<TSmlTaskId> arr;
+    
+	iProfile->Profile().ListTasksL(arr); // IPC call
+	CleanupClosePushL(arr);
+	
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspTaskItem item = ReadTaskItemL(iProfile->Profile(), arr[i]);
+		
+		item.iLastSync = iProfile->LastSync(item.iTaskId);
+		
+    	User::LeaveIfError(iTaskList.Append(item));
+		}
+		
+	
+    CleanupStack::PopAndDestroy(&arr);
+    
+    FLOG( _L("CAspContentList::InitAllTasksL END") );
+	}
+
+// -----------------------------------------------------------------------------
+// CAspContentList::UpdateLocalDatabaseL()
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::UpdateLocalDatabaseL()
+{
+	InitDataProvidersL();
+	InitAllTasksL();
+	RSyncMLDataProvider provider;
+	TRAPD(err, provider.OpenL(Session(), KUidNSmlAdapterEMail.iUid));
+	
+	if (err == KErrNone)
+		{
+    	CleanupClosePushL(provider);
+    	TAspProviderItem item;
+		ReadDataProviderItemL(provider, item);
+		}
+	TInt index = FindTaskIdForProvider( KUidNSmlAdapterEMail.iUid);
+	if (index != KErrNotFound)
+		{
+		TAspTaskItem emailItem = ReadTaskItemL(iProfile->Profile(), index);
+
+		CDesCArray* databaseList = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+		CleanupStack::PushL(databaseList);
+		GetLocalDatabaseList(KUidNSmlAdapterEMail.iUid, databaseList);
+	
+		TInt count = databaseList->Count();
+		TBool taskUpdated = EFalse;
+		for (TInt i = 0; i < count ;i++)
+			{
+			
+			if ((*databaseList)[i].Compare(emailItem.iClientDataSource) == 0)
+				{
+				taskUpdated = ETrue;
+				break;
+				}
+			}
+		if (!taskUpdated)
+			{
+			TBuf<KBufSize> aLocalDatabase;
+			TBuf<KBufSize> aRemoteDatabase;
+			TInt aSyncDirection;
+			TBool aTaskEnabled;
+			ReadTaskL(KUidNSmlAdapterEMail.iUid, aLocalDatabase, aRemoteDatabase,
+		    	               aTaskEnabled, aSyncDirection);
+			
+			if(count == 0) 
+			{
+				if(aLocalDatabase != KNullDesC)
+				{
+					aLocalDatabase = KNullDesC;
+					aTaskEnabled = EFalse;
+					
+					CreateTaskL(KUidNSmlAdapterEMail.iUid,aLocalDatabase , aRemoteDatabase,
+	                              aTaskEnabled, aSyncDirection);
+	                				
+				}
+			}
+			else
+			{
+				aLocalDatabase = provider.DefaultDataStoreName();
+				CreateTaskL(KUidNSmlAdapterEMail.iUid,aLocalDatabase , aRemoteDatabase,
+	                              aTaskEnabled, aSyncDirection);
+			
+			}
+			
+			
+
+			}
+		
+		
+		CleanupStack::PopAndDestroy(databaseList);
+		}
+
+	if (err == KErrNone)
+	{
+	CleanupStack::PopAndDestroy(&provider);
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CAspContentList::InitTaskL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::InitTaskL(TInt aTaskId)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+    TAspTaskItem task = ReadTaskItemL(iProfile->Profile(), aTaskId);
+    
+    // try to remove old task
+    TInt index = FindTaskIndex(aTaskId);
+    if (index != KErrNotFound)
+    	{
+    	iTaskList.Remove(index);
+    	}
+    
+    task.iLastSync = iProfile->LastSync(aTaskId);
+	
+	// add new task
+	User::LeaveIfError(iTaskList.Append(task));
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::RemoveTask
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::RemoveTask(TInt aDataProviderId)
+	{
+    TInt index = FindTaskIndexForProvider(aDataProviderId);
+        
+    // remove task that uses dataprovider aDataProviderId
+    if (index != KErrNotFound)
+    	{
+    	iTaskList.Remove(index);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::RemoveAllTasks
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::RemoveAllTasks()
+	{
+   	iTaskList.Reset();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ReadTaskItemL
+//
+// Reads one task from sync profile.
+// -----------------------------------------------------------------------------
+//
+TAspTaskItem CAspContentList::ReadTaskItemL(RSyncMLDataSyncProfile& aProfile, TInt aTaskId)
+	{
+	RSyncMLTask task;
+	TAspTaskItem item;
+
+#ifdef _DEBUG	
+	TTime _time = TUtil::TimeBefore();
+#endif
+	
+	TRAPD(err, task.OpenL(aProfile, aTaskId));  // IPC call
+	if (err != KErrNone)
+		{
+		FLOG( _L("### RSyncMLTask::OpenL failed (id=%d, err=%d) ###"), aTaskId, err );
+	    User::Leave(err);
+		}
+
+#ifdef _DEBUG		
+	TUtil::TimeAfter(_time, _L("*RSyncMLTask::Open took"));
+#endif	
+		
+   	item.iTaskId = aTaskId; 
+	TUtil::StrCopy(item.iDisplayName, task.DisplayName());
+	item.iSyncDirection = TAspTask::SyncDirection(task.DefaultSyncType());
+	
+	item.iDataProviderId = task.DataProvider();
+	item.iEnabled = task.Enabled();
+
+	item.iClientDataSource = task.ClientDataSource();
+    item.iLocalDatabaseDefined = EFalse;
+    item.iRemoteDatabaseDefined = EFalse;
+	if (!TUtil::IsEmpty(task.ClientDataSource()))
+		{
+		item.iLocalDatabaseDefined = ETrue;
+		}
+	if (!TUtil::IsEmpty(task.ServerDataSource()))
+		{
+		item.iRemoteDatabaseDefined = ETrue;
+		}
+	
+	task.Close();
+	
+	return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::Session
+// 
+// -----------------------------------------------------------------------------
+//
+RSyncMLSession& CAspContentList::Session()
+	{
+	__ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrGeneral));
+	
+	return *iSyncSession;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CheckMandatoryDataL
+//
+// Function checks that all tasks have mandatory data.
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::CheckMandatoryDataL(TInt& aContentCount)
+	{
+	aContentCount = 0;
+	TInt goodContentCount = 0;
+
+	TInt count = iTaskList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspTaskItem& task = iTaskList[i];
+
+		if (!task.iEnabled)
+			{
+			continue; // task not part of sync - no need to check mandatory fields
+			}
+			
+		if (iApplicationId != KErrNotFound && iApplicationId != EApplicationIdSync)
+			{
+			TInt appId = TUtil::AppIdFromProviderId(task.iDataProviderId);
+			if (appId != iApplicationId)
+				{
+				continue; // task not part of sync - no need to check mandatory fields
+				}
+			}
+			
+       	if (!task.iRemoteDatabaseDefined)
+			{
+			aContentCount = goodContentCount;
+		    return EMandatoryNoRemoteDatabase;
+			}
+
+		goodContentCount++;
+		}
+
+    aContentCount = goodContentCount;
+    
+    if (goodContentCount > 0)
+		{
+       	return EMandatoryOk;
+		}
+	else
+		{
+		return EMandatoryNoContent;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::IncludeTasks
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::IncludeTasks(const CArrayFix<TInt>* aIncludedProviderList)
+	{
+	// update iIsIncludedInSync for all provider items (used in IncludeTaskL)
+	SetIncludedProviders(aIncludedProviderList);
+	
+	TInt count = iProviderList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& item = iProviderList[i];
+		TRAPD(err, IncludeTaskL(item));
+		
+		if (err != KErrNone)
+			{
+			FLOG( _L("### CAspContentList::IncludeTaskL failed (id=%x, err=%d) ###"), item.iDataProviderId, err );
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::SetIncludedProviders
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::SetIncludedProviders(const CArrayFix<TInt>* aIncludedProviderList)
+	{
+	// exclude all providers
+	TInt providerCount = iProviderList.Count();
+	for (TInt i=0; i<providerCount; i++)
+		{
+        (iProviderList[i]).iIsIncludedInSync = EFalse;
+		}
+		
+	// include selected providers (aIncludedProviderList comes from ui)
+	TInt count = aIncludedProviderList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+        TInt index = (*aIncludedProviderList)[i];
+        
+        __ASSERT_ALWAYS(index>=0, TUtil::Panic(KErrGeneral));
+        __ASSERT_ALWAYS(index<providerCount, TUtil::Panic(KErrGeneral));
+        
+        (iProviderList[index]).iIsIncludedInSync = ETrue;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::GetIncludedProviders
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::GetIncludedProviders(CArrayFix<TInt>* aIncludedProviderList)
+	{
+
+	// get list indexes of data providers with enabled task
+	
+	TInt count = iProviderList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+        TAspProviderItem& item = iProviderList[i];
+        TInt index = FindTaskIndexForProvider(item.iDataProviderId);
+        if (index != KErrNotFound)
+        	{
+        	TAspTaskItem& item2 = iTaskList[index];
+        	if (item2.iEnabled)
+        		{
+        		TRAP_IGNORE(aIncludedProviderList->AppendL(i));
+        		}
+        	}
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::IncludeTaskL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::IncludeTaskL(TAspProviderItem& aDataProvider)
+	{
+	if (!aDataProvider.iIsIncludedInSync)
+		{
+		// exclude task (if exists) from sync
+		ModifyTaskIncludedL(aDataProvider, EFalse, KNullDesC);
+		return;
+		}
+	
+	TInt index = FindTaskIndexForProvider(aDataProvider.iDataProviderId);
+	if (index == KErrNotFound)
+		{
+		// task does not exist - create new
+	    TInt id = CreateTaskL(aDataProvider);
+	    InitTaskL(id);
+		}
+	else
+	 	{
+	 	// include in sync
+		ModifyTaskIncludedL(aDataProvider, ETrue, KNullDesC);
+	 	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ModifyTaskIncludedL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ModifyTaskIncludedL(TInt aDataProviderId, TBool aIsIncluded, const TDesC& aLocalDatabase)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+    TInt index = FindProviderIndex(aDataProviderId);
+	if (index != KErrNotFound)
+		{
+		TAspProviderItem& item = iProviderList[index];
+		if (!TUtil::IsEmpty(aLocalDatabase))
+		{
+			ModifyTaskIncludedL(item, aIsIncluded, aLocalDatabase);	
+		}
+		else
+		{
+			ModifyTaskIncludedL(item, aIsIncluded, KNullDesC);
+		}
+	}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ModifyTaskIncludedL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ModifyTaskIncludedL(TAspProviderItem& aProvider, TBool aIsIncluded, const TDesC& aLocalDatabase)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+	TInt index = FindTaskIndexForProvider(aProvider.iDataProviderId);
+	if (index == KErrNotFound)
+		{
+		if (!TUtil::IsEmpty(aLocalDatabase) && (aProvider.iDataProviderId == KUidNSmlAdapterEMail.iUid))
+		{
+			CreateTaskL(aProvider.iDataProviderId,aLocalDatabase,KNullDesC,ETrue,TAspTask::SyncDirection(SmlSyncDirection()));
+	 		iProfile->Profile().UpdateL();
+	 			 
+	    }
+		return; // no task for this provider
+		}
+		
+	TAspTaskItem& item = iTaskList[index];
+	if ((item.iEnabled == aIsIncluded) && (aProvider.iDataProviderId != KUidNSmlAdapterEMail.iUid))
+		{
+		return; // nothing to modify
+		}
+	
+	if(aProvider.iDataProviderId == KUidNSmlAdapterEMail.iUid)
+	{
+	RSyncMLTask task;
+	CleanupClosePushL(task);
+    
+	task.OpenL(iProfile->Profile(), item.iTaskId);
+	if (!TUtil::IsEmpty(aLocalDatabase))
+	{
+		CreateTaskL(aProvider.iDataProviderId,aLocalDatabase,task.ServerDataSource(),
+	 			 ETrue,TAspTask::SyncDirection(task.DefaultSyncType()));
+	
+	}
+
+	task.SetEnabledL(aIsIncluded);
+	// store task into database
+	task.UpdateL();
+	
+	iProfile->Profile().UpdateL();
+	
+	item.iEnabled = aIsIncluded;
+	CleanupStack::PopAndDestroy(&task);
+	}
+	else
+	{
+		RSyncMLTask task;
+		CleanupClosePushL(task);
+    
+	task.OpenL(iProfile->Profile(), item.iTaskId);
+	task.SetEnabledL(aIsIncluded);
+	
+	// store task into database
+	task.UpdateL();
+	iProfile->Profile().UpdateL();
+	
+	item.iEnabled = aIsIncluded;
+	
+	CleanupStack::PopAndDestroy(&task);
+	}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ModifyTaskDirectionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ModifyTaskDirectionL(TAspProviderItem& aProvider, TInt aSyncDirection)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+	TInt index = FindTaskIndexForProvider(aProvider.iDataProviderId);
+	if (index == KErrNotFound)
+		{
+		return; // no task for this provider
+		}
+		
+	TAspTaskItem& item = iTaskList[index];
+	if (item.iSyncDirection == aSyncDirection)
+		{
+		return; // nothing to modify
+		}
+	
+	RSyncMLTask task;
+	CleanupClosePushL(task);
+    
+	task.OpenL(iProfile->Profile(), item.iTaskId);
+	task.SetDefaultSyncTypeL(TAspTask::SmlSyncDirection(aSyncDirection));
+	
+	// store task into database
+	task.UpdateL();
+	iProfile->Profile().UpdateL();
+	
+	item.iSyncDirection = aSyncDirection;
+	
+	CleanupStack::PopAndDestroy(&task);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ModifyTaskDirectionsL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ModifyTaskDirectionsL(TInt aSyncDirection)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	
+	TInt count = iProviderList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+        TAspProviderItem& item = iProviderList[i];
+        ModifyTaskDirectionL(item, aSyncDirection);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CheckTaskDirectionsL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspContentList::CheckTaskDirectionsL()
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+
+    TInt previous = KErrNotFound;
+    
+	TInt count = iTaskList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+        TAspTaskItem& item = iTaskList[i];
+        if (item.iSyncDirection != previous && previous != KErrNotFound)
+        	{
+        	return EFalse;
+        	}
+        	
+        previous = item.iSyncDirection;
+		}
+		
+	return ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CreateTaskL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::CreateTaskL(TAspProviderItem& aDataProvider)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+		
+	if (!aDataProvider.iHasDefaultDataStore)
+		{
+		User::Leave(KErrNotFound);
+		}
+		
+	RSyncMLTask task;
+	CleanupClosePushL(task);
+	
+	task.CreateL(iProfile->Profile(), aDataProvider.iDataProviderId, 
+	              KNullDesC, aDataProvider.iDefaultDataStore);
+	
+	task.SetEnabledL(aDataProvider.iIsIncludedInSync);
+	task.SetDefaultSyncTypeL(SmlSyncDirection());
+	
+	// store task into database
+	task.UpdateL();
+	iProfile->Profile().UpdateL();
+	
+	TInt id = task.Identifier();
+	
+	CleanupStack::PopAndDestroy(&task);
+	
+	return id;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CreateTaskL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::CreateTaskL(TInt aDataProviderId,
+                                  const TDesC& aLocalDatabase,
+                                  const TDesC& aRemoteDatabase,
+                                  TBool aEnabled, TInt aSyncDirection)
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+		
+	TInt providerIndex = FindProviderIndex(aDataProviderId);
+	if (providerIndex == KErrNotFound)
+		{
+		return;
+		}
+	 
+	// remove existing task for aDataProviderId
+    TInt taskIndex = FindTaskIndexForProvider(aDataProviderId);
+    if (taskIndex != KErrNotFound)
+    	{
+    	TAspTaskItem& item = TaskItem(taskIndex);
+        iProfile->Profile().DeleteTaskL(item.iTaskId);
+        iProfile->Profile().UpdateL();
+        RemoveTask(aDataProviderId);  // remove deleted task from task list   	
+    	}
+    
+    TAspProviderItem& item = ProviderItem(providerIndex);
+    
+	RSyncMLTask task;
+	CleanupClosePushL(task);
+	
+	if (TUtil::IsEmpty(aLocalDatabase))
+		{
+		if(!ProviderItem(providerIndex).iHasDefaultDataStore)
+			{
+			// defult data store name was probably truncated
+			task.CreateL(iProfile->Profile(), aDataProviderId, 
+			             aRemoteDatabase, KNullDesC);
+			aEnabled = EFalse;
+			}
+		else
+			{
+			task.CreateL(iProfile->Profile(), aDataProviderId, 
+			             aRemoteDatabase, item.iDefaultDataStore);
+			}
+		}
+	else
+		{
+		task.CreateL(iProfile->Profile(), aDataProviderId, 
+		                                  aRemoteDatabase, aLocalDatabase);
+		}
+	
+	task.SetEnabledL(aEnabled);
+	task.SetDefaultSyncTypeL(TAspTask::SmlSyncDirection(aSyncDirection));
+	
+	// store task into database
+	task.UpdateL();
+	iProfile->Profile().UpdateL();
+	
+	CleanupStack::PopAndDestroy(&task);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::CreateTask
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::CreateTask(TInt aDataProviderId, 
+                                 const TDesC& aLocalDatabase,
+                                 const TDesC& aRemoteDatabase,
+                                 TBool aEnabled, TInt aSyncDirection)
+	{
+	FLOG( _L("CAspContentList::CreateTask START") );
+	
+	TRAPD(err, CreateTaskL(aDataProviderId, aLocalDatabase, aRemoteDatabase, aEnabled, aSyncDirection));
+	
+	if (err != KErrNone)
+		{
+		FLOG( _L("### CreateTask failed (id=%x err=%d) ###"), aDataProviderId, err );
+		}
+		
+	FLOG( _L("CAspContentList::CreateTask END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::ReadTaskL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::ReadTaskL(TInt aDataProviderId, TDes& aLocalDatabase,
+                                TDes& aRemoteDatabase, TBool& aEnable, TInt& aSyncDirection)
+
+	{
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+
+	aLocalDatabase = KNullDesC;
+	aRemoteDatabase = KNullDesC;
+	aSyncDirection = SyncDirection();
+	aEnable = EFalse;
+
+	TInt index = FindTaskIndexForProvider(aDataProviderId);
+	if (index == KErrNotFound)
+		{
+		return;
+		}
+	 
+    TAspTaskItem& item = TaskItem(index);
+    
+	RSyncMLTask task;
+	CleanupClosePushL(task);
+	
+	task.OpenL(iProfile->Profile(), item.iTaskId);
+	
+	aLocalDatabase = task.ClientDataSource();
+	aRemoteDatabase = task.ServerDataSource();
+	aEnable = task.Enabled();
+	aSyncDirection = TAspTask::SyncDirection(task.DefaultSyncType());
+		
+	CleanupStack::PopAndDestroy(&task);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::GetLocalDatabaseListL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::GetLocalDatabaseListL(TInt aDataProviderId, CDesCArray* aList)
+	{
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+	
+    RSyncMLDataProvider provider;	
+    CleanupClosePushL(provider);
+
+    provider.OpenL(*iSyncSession, aDataProviderId);
+    provider.GetDataStoreNamesL(*aList);
+    
+    CleanupStack::PopAndDestroy(&provider);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::GetLocalDatabaseList
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::GetLocalDatabaseList(TInt aDataProviderId, CDesCArray* aList)
+	{
+	TRAP_IGNORE(GetLocalDatabaseListL(aDataProviderId, aList));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::SmlSyncDirection
+//
+// -----------------------------------------------------------------------------
+//
+TSmlSyncType CAspContentList::SmlSyncDirection()
+	{
+	TInt syncDirection = SyncDirection();
+	return TAspTask::SmlSyncDirection(syncDirection);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::SyncDirection
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspContentList::SyncDirection()
+	{
+	if (iTaskList.Count() == 0)
+		{
+		return ESyncDirectionTwoWay; // default sync direction
+		}
+		
+	TAspTaskItem& item = iTaskList[0];
+	return item.iSyncDirection;  // all tasks have same sync direction
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::TaskEnabled
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspContentList::TaskEnabled(TInt aDataProviderId)
+	{
+	TBool ret = EFalse;
+	
+    TInt index = FindTaskIndexForProvider(aDataProviderId);
+    if (index != KErrNotFound)
+    	{
+    	TAspTaskItem& item = TaskItem(index);
+    	if (item.iEnabled)
+    		{
+    		ret = ETrue;
+    		}
+    	}
+    	
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::Sort
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::Sort()
+	{
+	iProviderList.Sort(TLinearOrder<TAspProviderItem>(TAspProviderItem::CompareItems));
+	}
+
+
+#ifdef _DEBUG
+
+// -----------------------------------------------------------------------------
+// CAspContentList::LogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::LogL(const TDesC& aText)
+	{
+	FLOG( _L("CAspContentList::LogL START") );
+
+	if (aText.Length() > 0)
+		{
+		FTRACE( RDebug::Print(_L("Profile = '%S'"), &aText) );
+		}
+		
+	LogTasksL();
+	LogDataProvidersL();
+	
+	FLOG( _L("CAspContentList::LogL END") );
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspContentList::LogTasksL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::LogTasksL()
+	{
+    FLOG( _L("---- sync tasks ----") );
+    
+	TInt count = iTaskList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspTaskItem& t = iTaskList[i];
+		TBuf<128> buf;
+		GetTaskLogText(buf, t);
+		FLOG(buf);
+		}
+		
+	FLOG( _L("---- sync tasks ----") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::GetTaskLogText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::GetTaskLogText(TDes& aText, TAspTaskItem& aTask)
+	{
+	TBuf<KBufSize64> buf;
+	GetDataProviderIdText(buf, aTask.iDataProviderId);
+	
+	aText.Format(_L("id=%d, remote_db=%d, local_db=%d, enabled=%d, providerId=%x, providername='%S'"),
+	             aTask.iTaskId, aTask.iRemoteDatabaseDefined, aTask.iLocalDatabaseDefined,
+	             aTask.iEnabled, aTask.iDataProviderId, &buf);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspContentList::LogDataProvidersL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::LogDataProvidersL()
+	{
+    FLOG( _L("---- data providers ----") );
+    
+	TInt count = iProviderList.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& item = iProviderList[i];
+		TBuf<32> buf;
+		GetDataProviderIdText(buf, item.iDataProviderId);
+		if (item.iHasDefaultDataStore)
+			{
+			FTRACE( RDebug::Print(_L("id=%S (%x), name='%S'"), &buf, item.iDataProviderId, &item.iDisplayName) );
+			}
+		else
+			{
+			FTRACE( RDebug::Print(_L("id=%S (%x), name='%S', ### no default data provider ###"), &buf, item.iDataProviderId, &item.iDisplayName) );
+			}
+		}
+		
+	FLOG( _L("---- data providers ----") );
+	}
+
+    
+// -----------------------------------------------------------------------------
+// CAspContentList::GetDataProviderIdText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspContentList::GetDataProviderIdText(TDes& aText, TInt aId)
+	{
+	aText = _L("unknown");
+	
+	if (aId == KUidNSmlAdapterContact.iUid)
+		{
+		aText = _L("KUidNSmlAdapterContact");
+		}
+	if (aId == KUidNSmlAdapterCalendar.iUid)
+		{
+		aText = _L("KUidNSmlAdapterCalendar");
+		}
+	if (aId == KUidNSmlAdapterEMail.iUid)
+		{
+		aText = _L("KUidNSmlAdapterEMail");
+		}
+	if (aId == KUidNSmlAdapterNote.iUid)
+		{
+		aText = _L("KUidNSmlAdapterNote");
+    	}
+	if (aId == KUidNSmlAdapterSms.iUid)
+		{
+		aText = _L("KUidNSmlAdapterSms");
+    	}
+	if (aId == KUidNSmlAdapterMMS.iUid)
+		{
+		aText = _L("KUidNSmlAdapterMMS");
+    	}
+	if (aId == KUidNSmlAdapterBookmarks.iUid)
+		{
+		aText = _L("KUidNSmlAdapterBookmarks");
+    	}
+	}
+	
+#endif
+
+
+
+/*******************************************************************************
+ * class TAspProfileItem
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// TAspProfileItem::Init
+//
+// -----------------------------------------------------------------------------
+//
+void TAspProfileItem::Init()
+	{
+	iProfileName = KNullDesC;
+	iProfileId = KErrNotFound;
+	iSynced = EFalse;
+	iLastSync = 0;
+	iBearer = KErrNotFound;
+	iActive = EFalse;
+	iDeleteAllowed = EFalse;
+	iApplicationId = KErrNotFound;
+	iMandatoryCheck = KErrNotFound;
+	iTaskCount = KErrNotFound;
+	iTaskId = KErrNotFound;
+	}
+
+
+
+
+// -----------------------------------------------------------------------------
+// TAspProfileItem::NameLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* TAspProfileItem::NameLC()
+	{
+	return iProfileName.AllocLC();
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspProfileItem::Name
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC& TAspProfileItem::Name()
+	{
+	return iProfileName;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspProfileItem::SetName
+//
+// -----------------------------------------------------------------------------
+//
+void TAspProfileItem::SetName(const TDesC& aName)
+	{
+	TUtil::StrCopy(iProfileName, aName);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspProfileItem::CompareItems
+//
+// -----------------------------------------------------------------------------
+//
+TInt TAspProfileItem::CompareItems(const TAspProfileItem& aFirst, const TAspProfileItem& aSecond)
+	{
+	return aFirst.iProfileName.CompareC(aSecond.iProfileName);
+	}
+
+
+
+
+
+
+/*******************************************************************************
+ * class CAspProfileList
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileList* CAspProfileList::NewLC(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfileList::NewLC START") );
+    
+    CAspProfileList* self = new (ELeave) CAspProfileList(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	
+	
+    FLOG( _L("CAspProfileList::NewLC END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileList* CAspProfileList::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfileList::NewL START") );
+    
+    CAspProfileList* self = new (ELeave) CAspProfileList(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProfileList::NewL END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileList::~CAspProfileList()
+    {
+	iList.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ConstructL(void)
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::CAspProfileList
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileList::CAspProfileList(const TAspParam& aParam)
+	{
+	__ASSERT_ALWAYS(aParam.iSyncSession, TUtil::Panic(KErrGeneral));
+
+	iSyncSession = aParam.iSyncSession;
+	iApplicationId = aParam.iApplicationId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::Count
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::Count()
+	{
+	return iList.Count();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::Count
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::Count(TInt aApplicationId)
+	{
+	TInt profileCount = 0;
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		if (item.iApplicationId == aApplicationId)
+			{
+			profileCount++;
+			}
+		}
+	
+	return profileCount;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::DeletableProfileCount
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::DeletableProfileCount()
+	{
+	TInt profileCount = 0;
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		if (item.iDeleteAllowed)
+			{
+			profileCount++;
+			}
+		}
+	
+	return profileCount;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::Item
+// 
+// -----------------------------------------------------------------------------
+//
+TAspProfileItem& CAspProfileList::Item(TInt aIndex)
+	{
+	if ((aIndex < 0) || (aIndex >= Count()))
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	return iList[aIndex];
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::FindProfileIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::FindProfileIndex(const TDesC& aProfileName)
+	{
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TPtrC ptr = Item(i).Name();
+		if (ptr.Compare(aProfileName) == 0)
+			{
+			return i;
+			}
+		}
+
+	return KErrNotFound;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::GetDefaultProfileIdL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::GetDefaultProfileIdL(TInt& aValue)
+	{
+	const TUid KRepositoryId = KCRUidDSDefaultProfileInternalKeys;
+	
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Get(KNsmlDsDefaultProfile, aValue);
+	User::LeaveIfError(err);
+	CleanupStack::PopAndDestroy(rep);    
+	}
+	
+// -----------------------------------------------------------------------------
+// CAspProfileList::FindLastSyncedProfileIndexL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::FindLastSyncedProfileIndexL()
+	{
+	TInt index = KErrNotFound;
+	TTime syncTime = 0;
+	
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		if (item.iLastSync > syncTime)
+			{
+			syncTime = item.iLastSync;
+			index = i;
+			}
+		}
+	
+	if (index == KErrNotFound && count > 0)
+		{
+		//Read the Default Profile Id from the Cenrep
+		TInt defaultprofileId;
+		GetDefaultProfileIdL(defaultprofileId);
+		for (TInt i=0; i<count; i++)
+			{
+			TAspProfileItem& item = iList[i];
+			if ( item.iProfileId == defaultprofileId )
+				{
+				index = i;
+				break;
+				}
+			}
+		
+		if(index == KErrNotFound)
+			{
+			TAspParam param(iApplicationId, iSyncSession);
+	    	    	
+			for( TInt i=0; i<count; i++)
+				{
+				CAspProfile* profile = CAspProfile::NewLC(param);
+				TAspProfileItem& item = iList[i];
+				profile->OpenL(item.iProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);	
+				if( CAspProfile::IsPCSuiteProfile(profile) )
+					{
+					index = i;
+					CleanupStack::PopAndDestroy(profile);
+					break;
+					}
+				else
+					{
+					CleanupStack::PopAndDestroy(profile);
+					}			
+				}
+			}
+		}
+	return index;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::FilteredList
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileList* CAspProfileList::FilteredListL(TAspFilterInfo& aFilterInfo)
+	{
+	TInt type = aFilterInfo.iFilterType;
+	
+	if (type != TAspFilterInfo::EIncludeDeletableProfile &&
+	    type != TAspFilterInfo::EIncludeRemoteProfile)
+		{
+		TUtil::Panic(KErrNotSupported);
+		}
+		
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspProfileList* profileList = CAspProfileList::NewLC(param);
+	
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		
+		if (type == TAspFilterInfo::EIncludeDeletableProfile)
+			{
+		    if (item.iDeleteAllowed)
+			    {
+			    profileList->AddL(item);
+			    }
+			}
+
+		if (type == TAspFilterInfo::EIncludeRemoteProfile)
+			{
+		    if (item.iBearer == EAspBearerInternet)
+			    {
+			    profileList->AddL(item);
+			    }
+			}
+    	}
+	
+		
+	CleanupStack::Pop(profileList);
+	return profileList;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::ReplaceProfileItemL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ReplaceProfileItemL(TAspProfileItem& aProfileItem)
+	{
+	// remove old profile with same id
+	Remove(aProfileItem.iProfileId);
+	
+	// add new profile 
+    User::LeaveIfError(iList.Append(aProfileItem));
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfileList::ReadProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ReadProfileL(TInt aProfileId)
+	{
+	FLOG( _L("CAspProfileList::ReadProfileL START") );
+	
+	TAspParam param(iApplicationId, iSyncSession);
+    CAspProfile* profile = CAspProfile::NewLC(param);
+	
+	profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+	
+	TAspProfileItem item;
+	item.Init();
+
+	if (iApplicationId != EApplicationIdSync)
+		{
+		TInt dataProviderId = TUtil::ProviderIdFromAppId(iApplicationId);
+		TInt taskId = TAspTask::FindTaskIdL(profile, dataProviderId, KNullDesC);
+		item.iTaskId = taskId; // needed for syncing only one content 
+		}
+	
+	ReadProfileItemL(profile, item);
+	
+	//item.iMandatoryCheck = CAspProfile::CheckMandatoryData(profile, item.iTaskCount);
+	
+	ReplaceProfileItemL(item);
+
+#ifdef _DEBUG
+    TAspParam param2(iApplicationId, iSyncSession);
+	param2.iProfile = profile;
+	param2.iMode = CAspContentList::EInitAll;
+	CAspContentList* contentList = CAspContentList::NewLC(param2);
+
+    contentList->LogL(item.iProfileName);
+    
+    CleanupStack::PopAndDestroy(contentList);
+#endif	
+	
+	CleanupStack::PopAndDestroy(profile);
+	
+	FLOG( _L("CAspProfileList::ReadProfileL END") );
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfileList::ReadAllProfilesL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ReadAllProfilesL(TInt aListMode)
+	{
+	FLOG( _L("CAspProfileList::ReadAllProfilesL START") );
+	
+#ifdef _DEBUG
+    	TTime time_1 = TUtil::TimeBefore();
+#endif
+	
+	iList.Reset();
+	
+	RArray<TSmlProfileId> arr;
+    Session().ListProfilesL(arr, ESmlDataSync);
+   	CleanupClosePushL(arr);
+
+	TInt count = arr.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspParam param(iApplicationId, iSyncSession);
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		TInt id = arr[i];
+		
+		if (aListMode == EBasePropertiesOnly)
+			{
+			profile->OpenL(id, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
+			}
+		else
+			{
+			profile->OpenL(id, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+			}
+			
+
+		TAspProfileItem item;
+		item.Init();
+		
+		if (iApplicationId != EApplicationIdSync)
+			{
+			TInt dataProviderId = TUtil::ProviderIdFromAppId(iApplicationId);
+			TInt taskId = TAspTask::FindTaskIdL(profile, dataProviderId, KNullDesC);
+			item.iTaskId = taskId; // needed for syncing only one content 
+			}
+		
+		if (aListMode == EBasePropertiesOnly)
+			{
+			profile->GetName(item.iProfileName);
+			if (TUtil::IsEmpty(item.iProfileName))
+				{
+				CAspResHandler::ReadL(item.iProfileName,R_ASP_UNNAMED_SET);
+				}
+			item.iApplicationId = profile->CreatorId();
+			item.iProfileId = profile->ProfileId();
+			}
+		else
+			{
+			ReadProfileItemL(profile, item);
+			}
+		
+		if (aListMode == EMandatoryCheck || aListMode == EMandatoryCheckEx)
+			{
+			item.iMandatoryCheck = CAspProfile::CheckMandatoryData(profile, item.iTaskCount);
+			}
+
+		if (aListMode == EMandatoryCheckEx && item.iMandatoryCheck != EMandatoryOk)
+			{
+			CleanupStack::PopAndDestroy(profile);
+			continue;  // ignore profile that misses some mandatory data
+			}
+		
+		if(IsAutoSyncProfile(profile))
+			{
+			CleanupStack::PopAndDestroy(profile);
+			continue;  // auto sync profile should be hidden
+			}
+		
+		User::LeaveIfError(iList.Append(item));
+		
+		CleanupStack::PopAndDestroy(profile);
+		}
+        
+    CleanupStack::PopAndDestroy(&arr);
+    
+#ifdef _DEBUG    
+    TUtil::TimeAfter(time_1, _L("ReadAllProfilesL took"));
+#endif
+    
+    FLOG( _L("CAspProfileList::ReadAllProfilesL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::ReadEMailProfilesL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ReadEMailProfilesL(const TDesC& aLocalDatabase, TInt /*aListMode*/)
+	{
+	FLOG( _L("CAspProfileList::ReadEMailProfilesL START") );
+	
+	iList.Reset();
+	
+	RArray<TSmlProfileId> arr;
+    Session().ListProfilesL(arr, ESmlDataSync);
+   	CleanupClosePushL(arr);
+
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspParam param(iApplicationId, iSyncSession);
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		
+		TInt id = arr[i];
+		profile->OpenL(id, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
+		
+		TAspProfileItem item;
+		item.Init();
+		
+		TInt taskId = TAspTask::FindTaskIdL(profile, KUidNSmlAdapterEMail.iUid, aLocalDatabase);
+		item.iTaskId = taskId; // needed for syncing only one content
+		
+		if( taskId != KErrNotFound )
+		{
+		profile->GetName(item.iProfileName);
+		item.iApplicationId = profile->CreatorId();
+		item.iProfileId = profile->ProfileId();
+		
+		if(IsAutoSyncProfile(profile))
+			{
+			CleanupStack::PopAndDestroy(profile);
+			continue;  // auto sync profile should be hidden
+			}
+		
+		User::LeaveIfError(iList.Append(item));
+		}
+		CleanupStack::PopAndDestroy(profile);
+		}
+        
+    CleanupStack::PopAndDestroy(&arr);
+    
+    FLOG( _L("CAspProfileList::ReadEMailProfilesL END") );
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::ReadProfileItemL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::ReadProfileItemL(CAspProfile* aProfile, TAspProfileItem& aItem)
+	{
+	aProfile->GetName(iBuf);
+	if (TUtil::IsEmpty(iBuf))
+		{
+		CAspResHandler::ReadL(iBuf, R_ASP_UNNAMED_SET);
+		}
+    aItem.SetName(iBuf);
+	
+	aProfile->GetServerId(iBuf);
+	TInt len = iBuf.Size();  // number of bytes
+	TUint16 checkSum = 0;
+	if (len > 0)
+		{
+		Mem::Crc(checkSum, iBuf.Ptr(), len);
+		}
+	aItem.iServerIdCheckSum = checkSum;
+
+	aItem.iProfileId = aProfile->ProfileId();
+	aItem.iSynced    = aProfile->IsSynced();
+	aItem.iLastSync  = aProfile->LastSync();
+	aItem.iBearer    = aProfile->BearerType();
+    
+    aItem.iActive = EFalse;
+    if (aProfile->SASyncState() != ESASyncStateDisable)
+    	{
+    	aItem.iActive = ETrue;
+    	}
+    	
+	aItem.iDeleteAllowed = aProfile->DeleteAllowed();
+	aItem.iMandatoryCheck = EMandatoryOk;
+	aItem.iApplicationId = aProfile->CreatorId();
+	
+	aItem.iTaskCount = 0;
+    }
+		
+	
+// -----------------------------------------------------------------------------
+// CAspProfileList::Sort
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::Sort()
+	{
+	iList.Sort(TLinearOrder<TAspProfileItem>(TAspProfileItem::CompareItems));
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::Remove
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::Remove(TInt aProfileId)
+	{
+	TInt count = iList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		if (item.iProfileId == aProfileId)
+			{
+			iList.Remove(i);
+			return;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::AddL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileList::AddL(TAspProfileItem& aProfileItem)
+	{
+	User::LeaveIfError(iList.Append(aProfileItem));
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::ListIndex
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileList::ListIndex(TInt aProfileId)
+	{
+	TInt count = iList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProfileItem& item = iList[i];
+		if (item.iProfileId == aProfileId)
+			{
+			return i;
+			}
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::Session
+// 
+// -----------------------------------------------------------------------------
+//
+RSyncMLSession& CAspProfileList::Session()
+	{
+	__ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrGeneral));
+	
+	return *iSyncSession;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileList::IsUniqueServerId
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfileList::IsUniqueServerId(const TDesC& aServerId, TInt aProfileId)
+	{
+	TInt serverIdLen = aServerId.Length();
+	if (serverIdLen == 0)
+		{
+		return ETrue;
+		}
+		
+	TBool serverIdFound = EFalse;
+	
+	TInt count = iList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+	   	TAspProfileItem& item = iList[i];
+		if (item.iProfileId == aProfileId)
+			{
+			continue;
+			}
+
+		TUint16 checkSum = 0;
+		TInt len = aServerId.Size(); // number of bytes
+	
+		Mem::Crc(checkSum, aServerId.Ptr(), len);
+		if (item.iServerIdCheckSum == checkSum)
+			{
+			serverIdFound = ETrue;
+			break;
+			}
+		}
+
+    if (serverIdFound)
+    	{
+    	return EFalse;
+    	}
+    	
+    return ETrue;
+	}
+
+
+TBool CAspProfileList::IsAutoSyncProfile(CAspProfile* aProfile)
+	{
+	TBuf<KBufSize> profileName;
+	aProfile->GetName(profileName);
+	if (profileName.Compare(KAutoSyncProfileName) == 0)
+		{
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+/******************************************************************************
+ * class CAspProfile
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfile* CAspProfile::NewLC(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfile::NewLC START") );
+    
+    CAspProfile* self = new (ELeave) CAspProfile(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	FLOG( _L("CAspProfile::NewLC END") );
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CAspProfile::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfile* CAspProfile::NewL (const TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfile::NewL START") );
+    
+    CAspProfile* self = new (ELeave) CAspProfile(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProfile::NewL END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfile::~CAspProfile()
+    {
+    if (iHistoryLogOpen)
+    	{
+    	iHistoryLog.Close();
+    	}
+
+    if (iConnectionOpen)
+    	{
+    	iConnection.Close();
+    	}
+    
+    iProfile.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::ConstructL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CAspProfile
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfile::CAspProfile(const TAspParam& aParam)
+	{
+	__ASSERT_ALWAYS(aParam.iSyncSession, TUtil::Panic(KErrGeneral));
+
+	iSyncSession = aParam.iSyncSession;
+	iApplicationId = aParam.iApplicationId;
+	
+	
+    iHistoryLogOpen = EFalse;
+    iConnectionOpen = EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::OpenL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::OpenL(TInt aProfileId, TInt aReadWrite, TInt aOpenMode)
+    {
+    FLOG( _L("CAspProfile::OpenL START") );
+    
+    if (aReadWrite == EOpenRead)
+    	{
+    	iProfile.OpenL(*iSyncSession, aProfileId, ESmlOpenRead);
+    	}
+    else
+    	{
+    	iProfile.OpenL(*iSyncSession, aProfileId, ESmlOpenReadWrite);
+    	}
+    
+    if (aOpenMode == EAllProperties)
+    	{
+    	OpenConnection();  // this updates iConnectionOpen
+    	OpenHistoryLog();  // this updates iHistoryLogOpen
+    	}
+    	
+    FLOG( _L("CAspProfile::OpenL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CreateL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::CreateL(TInt aOpenMode)
+    {
+    FLOG( _L("CAspProfile::CreateL START") );
+    
+   	iProfile.CreateL(*iSyncSession);
+   	iProfile.SetCreatorId(iApplicationId);  // creator application id
+   	iProfile.UpdateL();
+   	
+	// create connection for new profile (convergence)
+    //TInt transportId = DefaultTransportIdL();
+    //iConnection.CreateL(iProfile, transportId);
+    //iConnection.UpdateL();
+    //iConnection.Close();
+    //iProfile.UpdateL();	
+   	
+    if (aOpenMode == EAllProperties)
+    	{
+    	OpenConnection();  // this updates iConnectionOpen
+    	OpenHistoryLog();  // this updates iHistoryLogOpen
+    	}
+    	
+    FLOG( _L("CAspProfile::CreateL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::DefaultTransportIdL 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::DefaultTransportIdL()
+    {
+    TAspParam param(EApplicationIdSync, iSyncSession);
+    CAspBearerHandler* bearerHandler = CAspBearerHandler::NewL(param);
+    CleanupStack::PushL(bearerHandler);
+    
+    TInt id = bearerHandler->DefaultBearer(); 
+    
+    CleanupStack::PopAndDestroy(bearerHandler);
+    
+    if (id == KErrNotFound)
+    	{
+    	User::Leave(KErrNotFound);
+    	}
+    	
+    return CAspBearerHandler::SmlBearerId(id);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CreateCopyL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::CreateCopyL(TInt aProfileId)
+    {
+    FLOG( _L("CAspProfile::CreateCopyL START") );
+    
+    CreateL(EAllProperties);
+    
+    TAspParam param(iApplicationId, iSyncSession);
+    CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+    
+    CopyValuesL(profile);
+    
+    CleanupStack::PopAndDestroy(profile);
+    
+    FLOG( _L("CAspProfile::CreateCopyL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SaveL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SaveL()
+    {
+    //iProfile.UpdateL();  // convergence
+    
+    if (iConnectionOpen)
+    	{
+    	iConnection.UpdateL();
+    	}
+    	
+   	iProfile.UpdateL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::Save
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::Save()
+    {
+    TRAPD(err, SaveL());
+    
+    if (err != KErrNone)
+    	{
+    	FLOG( _L("###  CAspProfile::SaveL failed (%d) ###"), err );
+    	}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetName(TDes& aText)
+	{
+ 		if(!IsPCSuiteProfile(this))
+ 		{
+			TUtil::StrCopy(aText, iProfile.DisplayName());
+			return;
+ 		}
+ 		//For PC suite profile Localise as per specifications
+ 		GetLocalisedPCSuite(aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::NameL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspProfile::NameL()
+	{
+	return iProfile.DisplayName().AllocL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetNameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetNameL(const TDesC& aText)
+	{
+	iProfile.SetDisplayNameL(aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CreatorId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CreatorId()
+	{
+	return iProfile.CreatorId();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetCreatorId
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetCreatorId(TInt aCreatorId)
+	{
+	iProfile.SetCreatorId(aCreatorId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::ProfileId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::ProfileId()
+	{
+	return iProfile.Identifier();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::DeleteAllowed
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfile::DeleteAllowed()
+	{
+	return iProfile.DeleteAllowed();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::IsSynced
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfile::IsSynced()
+    {
+    if (!iHistoryLogOpen)
+    	{
+    	return EFalse;
+    	}
+    	
+    if (iHistoryLog.Count() == 0)
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::LastSync
+//
+// -----------------------------------------------------------------------------
+//
+TTime CAspProfile::LastSync()
+    {
+    if (!iHistoryLogOpen)
+    	{
+    	return 0;
+    	}
+
+    if (iHistoryLog.Count() == 0)
+        {
+        return 0;  // profile has not been synced
+        }
+        
+    const CSyncMLHistoryJob* job = LatestHistoryJob();
+    if (!job)
+    	{
+    	return 0;
+    	}
+    
+    return job->TimeStamp();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::LastSync
+//
+// -----------------------------------------------------------------------------
+//
+TTime CAspProfile::LastSync(TInt aTaskId)
+    {
+    if (!iHistoryLogOpen)
+    	{
+    	return 0;
+    	}
+
+    if (iHistoryLog.Count() == 0)
+        {
+        return 0;  // profile has not been synced
+        }
+        
+    const CSyncMLHistoryJob* job = LatestHistoryJob(aTaskId);
+    if (!job)
+    	{
+    	return 0;
+    	}
+    
+    return job->TimeStamp();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetServerId
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetServerId(TDes& aText)
+	{
+	TUtil::StrCopy(aText, iProfile.ServerId());  // convert TDes8 to TDes
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetGetServerIdL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetServerIdL(const TDesC& aText)
+	{
+	TUtil::StrCopy(iBuf8, aText);  // convert TDes to TDes8
+	iProfile.SetServerIdL(iBuf8);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::ProtocolVersion
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::ProtocolVersion()
+	{
+	TSmlProtocolVersion version = iProfile.ProtocolVersion();
+	if (version == ESmlVersion1_1_2)
+		{
+		return EAspProtocol_1_1;
+		}
+		
+	return EAspProtocol_1_2;
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SetProtocolVersionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetProtocolVersionL(TInt aProtocolVersion)
+	{
+	if (aProtocolVersion == EAspProtocol_1_1)
+		{
+		iProfile.SetProtocolVersionL(ESmlVersion1_1_2);
+		}
+	else
+		{
+		iProfile.SetProtocolVersionL(ESmlVersion1_2);
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::BearerType
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::BearerType()
+	{
+	if (!iConnectionOpen)
+		{
+	    return KErrNotFound;	
+		}
+
+	TInt id = iConnection.Identifier();
+   	return CAspBearerHandler::AspBearerId(id);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetBearerTypeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetBearerTypeL(TInt aId)
+	{
+	if (!iConnectionOpen)
+		{
+		return;
+		}
+	
+	TInt newBearer = CAspBearerHandler::SmlBearerId(aId);
+    
+    if (newBearer != KErrNotFound)
+    	{
+    	TInt currentBearer = iConnection.Identifier();
+    	if (currentBearer != newBearer)
+    		{
+    		iConnection.CreateL(Profile(), newBearer);
+    		}
+    	}
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetBearerTypeL (convergence)
+//
+// -----------------------------------------------------------------------------
+//
+/*
+void CAspProfile::SetBearerTypeL(TInt aId)
+	{
+	TInt newBearer = CAspBearerHandler::SmlBearerId(aId);
+	if (newBearer == KErrNotFound)
+		{
+		return;  // unknown bearer
+		}
+	
+   	TInt currentBearer = KErrNotFound;
+   	if (iConnectionOpen)
+   	    {
+   		currentBearer = iConnection.Identifier();
+   	    }
+   	if (currentBearer == newBearer)
+   		{
+   		return;	// bearer has not changed
+   		}
+
+	if (iConnectionOpen)
+	    {
+		iConnection.Close();
+		iConnectionOpen = EFalse;
+	    }
+
+	DeleteConnectionsL(0);
+    			
+	TRAPD(err, iConnection.CreateL(iProfile, newBearer));
+   	if (err == KErrNone)
+    	{
+    	iConnection.UpdateL();
+        iConnection.Close();
+        iProfile.UpdateL();
+        iConnection.OpenL(iProfile, newBearer);
+        iConnectionOpen = ETrue;    		    				    
+      	}
+    }
+*/
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::DeleteConnectionsL (convergence)
+//
+// -----------------------------------------------------------------------------
+//
+/*
+void CAspProfile::DeleteConnectionsL()
+    {
+   	RArray<TSmlConnectionId> arr;
+   	Profile().ListConnectionsL(arr);
+   	CleanupClosePushL(arr);
+   	
+   	TInt count = arr.Count();
+    	
+   	for (TInt i=0; i<count; i++)
+   	    {
+   	    TInt id = arr[i];
+   	    iProfile.DeleteConnectionL(id);
+   	    iProfile.UpdateL();
+   	    }
+   	    
+   	CleanupStack::PopAndDestroy(&arr);
+    }
+*/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::AccessPointL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::AccessPointL()
+	{
+	if (!iConnectionOpen)
+		{
+    	return KErrNotFound;
+		}
+	
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return KErrNotFound; // this setting is only for internet bearer
+		}
+		
+	TBuf8<KBufSize32> key;
+	TBuf<KBufSize32> value;
+	TInt num = KErrNotFound;
+
+	GetConnectionPropertyNameL(key, EPropertyIntenetAccessPoint);
+	TUtil::StrCopy(value, iConnection.GetPropertyL(key)); // convert TDes8 to TDes
+	if (TUtil::IsEmpty(value))
+		{
+		return KErrNotFound;
+		}
+		
+	User::LeaveIfError(TUtil::StrToInt(value, num));
+	return num;
+	}
+		
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SetAccessPointL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetAccessPointL(const TInt aId)
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+    	
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+
+	TBuf<KBufSize32> buf;
+	TBuf8<KBufSize32> key;
+	TBuf8<KBufSize32> value;
+	
+	buf.Num(aId);
+	TUtil::StrCopy(value, buf);  // convwert TDes to TDes8
+	
+	GetConnectionPropertyNameL(key, EPropertyIntenetAccessPoint);
+	iConnection.SetPropertyL(key, value);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetHostAddress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetHostAddress(TDes& aText, TInt& aPort)
+	{
+	aText = KNullDesC;
+	aPort = TURIParser::EDefaultHttpPort;
+	
+    if (!iConnectionOpen)	
+    	{
+      	return;
+    	}
+	
+	if (BearerType() != EAspBearerInternet)
+		{
+		TUtil::StrCopy(aText, iConnection.ServerURI()); // convert TDes8 to TDes
+		return;  // port number handling is for internet bearer only 
+		}
+
+	TUtil::StrCopy(iBuf, iConnection.ServerURI()); // convert TDes8 to TDes
+	
+	TURIParser parser(iBuf);
+	
+	parser.GetUriWithoutPort(aText);
+
+	aPort = parser.Port();
+	if (aPort == KErrNotFound)
+		{
+		aPort = parser.DefaultPort();
+		}
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SetHostAddressL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetHostAddressL(const TDesC& aText, const TInt aPort)
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+	
+	if (BearerType() != EAspBearerInternet)
+		{
+		TUtil::StrCopy(iBuf, aText); // port number handling is for inteernet bearer only 
+		}
+	else
+		{
+		TURIParser parser(aText); // add port number to internet host address
+	    parser.GetUriWithPort(iBuf, aPort);
+		}
+	
+	TUtil::StrCopy(iBuf8, iBuf);  // convert TDes to TDes8
+	iConnection.SetServerURIL(iBuf8);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetUserName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetUserName(TDes& aText)
+	{
+	TUtil::StrCopy(aText, iProfile.UserName());   // convert TDes8 to TDes
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SetUserNameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetUserNameL(const TDesC& aText)
+	{
+	TUtil::StrCopy(iBuf8, aText);  // conver TDes to TDes8
+	iProfile.SetUserNameL(iBuf8);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetPassword
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetPassword(TDes& aText)
+	{
+	TUtil::StrCopy(aText, iProfile.Password());   // convert TDes8 to TDes
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SetPasswordL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetPasswordL(const TDesC& aText)
+	{
+	TUtil::StrCopy(iBuf8, aText);    // conver TDes to TDes8
+	iProfile.SetPasswordL(iBuf8);
+	}
+
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::SASyncState
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::SASyncState()
+	{
+	TSmlServerAlertedAction state = iProfile.SanUserInteraction();
+
+	if (state == ESmlConfirmSync)
+		{
+		return ESASyncStateConfirm;
+		}
+	else if (state == ESmlDisableSync)
+		{
+		return ESASyncStateDisable;
+		}
+	else 
+		{
+		return ESASyncStateEnable;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetSASyncStateL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetSASyncStateL(TInt aState)
+    {
+	if (aState == ESASyncStateConfirm)
+		{
+		Profile().SetSanUserInteractionL(ESmlConfirmSync);
+		}
+	else if (aState == ESASyncStateDisable)
+		{
+		Profile().SetSanUserInteractionL(ESmlDisableSync);
+		}
+	else
+		{
+		Profile().SetSanUserInteractionL(ESmlEnableSync);
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetHttpUsedL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetHttpUsedL(TBool aEnable)
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+	
+	TBuf8<KBufSize32> key;
+	TBuf8<KBufSize32> value;
+	
+	if (aEnable)
+		{
+		value.Num(1); 
+		}
+	else
+		{
+		value.Num(0);
+		}
+		
+	GetConnectionPropertyNameL(key, EPropertyHttpUsed);
+	iConnection.SetPropertyL(key, value);
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// CAspProfile::HttpUsedL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfile::HttpUsedL()
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return EFalse;
+    	}
+	
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return EFalse; // this setting is only for internet bearer
+		}
+
+	TBuf8<KBufSize32> key; 
+	TBuf<KBufSize32> value;
+	TInt intValue;
+	
+	GetConnectionPropertyNameL(key, EPropertyHttpUsed);
+	TUtil::StrCopy(value, iConnection.GetPropertyL(key));  // convert TDes8 to TDes
+	
+    User::LeaveIfError(TUtil::StrToInt(value, intValue));
+	
+    if (intValue == 0)
+    	{
+    	return EFalse; 
+    	}
+    return ETrue;
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetHttpUsernameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetHttpUserNameL(TDes& aText)
+	{
+	aText = KNullDesC;
+	
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+	
+
+	TBuf8<KBufSize32> key; 
+	
+	GetConnectionPropertyNameL(key, EPropertyHttpUserName);
+	TUtil::StrCopy(aText, iConnection.GetPropertyL(key));  // convert TDes8 to TDes
+  	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetHttpUsernameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetHttpUserNameL(const TDesC& aText)
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+	
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+
+	TBuf8<KBufSize32> key;
+	
+	GetConnectionPropertyNameL(key, EPropertyHttpUserName);
+	TUtil::StrCopy(iBuf8, aText);  // convert TDes to TDes8
+	iConnection.SetPropertyL(key, iBuf8);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetHttpPasswordL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetHttpPasswordL(TDes& aText)
+	{
+   	aText = KNullDesC;
+   	
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+
+
+	TBuf8<KBufSize32> key; 
+	
+	GetConnectionPropertyNameL(key, EPropertyHttpPassword);
+	TUtil::StrCopy(aText, iConnection.GetPropertyL(key));  // convert TDes8 to TDes
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetHttpPasswordL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetHttpPasswordL(const TDesC& aText)
+	{
+    if (!iConnectionOpen)	
+    	{
+    	return;
+    	}
+	
+	if (iConnection.Identifier() != KUidNSmlMediumTypeInternet.iUid)
+		{
+		return; // this setting is only for internet bearer
+		}
+    		
+	TBuf8<KBufSize32> key;
+	
+	GetConnectionPropertyNameL(key, EPropertyHttpPassword);
+	TUtil::StrCopy(iBuf8, aText);  // convert TDes to TDes8
+	iConnection.SetPropertyL(key, iBuf8);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::Profile
+//
+// -----------------------------------------------------------------------------
+//
+RSyncMLDataSyncProfile& CAspProfile::Profile()
+    {
+    return iProfile;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::LatestHistoryJob
+//
+// -----------------------------------------------------------------------------
+//
+const CSyncMLHistoryJob* CAspProfile::LatestHistoryJob()
+    {
+    if (!iHistoryLogOpen)
+    	{
+    	return NULL;
+    	}
+
+    TInt count = iHistoryLog.Count();
+    if (count == 0)
+        {
+        return NULL;  // profile has no history job
+        }
+        
+    iHistoryLog.SortEntries(CSyncMLHistoryEntry::ESortByTime);    
+    
+    // try to find latest sync job (start from last array entry)
+    for (TInt i=count-1; i>=0; i--)
+    	{
+        const CSyncMLHistoryEntry& entry = iHistoryLog[i];
+        const CSyncMLHistoryJob* jobEntry = CSyncMLHistoryJob::DynamicCast(&entry);
+        if (jobEntry)
+        	{
+        	return jobEntry;
+        	}
+    	}
+
+    return NULL;  // profile has no history job
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::LatestHistoryJob
+//
+// -----------------------------------------------------------------------------
+//
+const CSyncMLHistoryJob* CAspProfile::LatestHistoryJob(TInt aTaskId)
+    {
+    if (!iHistoryLogOpen)
+    	{
+    	return NULL;
+    	}
+
+    TInt count = iHistoryLog.Count();
+    if (count == 0)
+        {
+        return NULL;  // profile has no history job
+        }
+        
+    iHistoryLog.SortEntries(CSyncMLHistoryEntry::ESortByTime);    
+    
+    // try to find latest sync job (start from last array entry)
+    for (TInt i=count-1; i>=0; i--)
+    	{
+        const CSyncMLHistoryEntry& entry = iHistoryLog[i];
+        const CSyncMLHistoryJob* jobEntry = CSyncMLHistoryJob::DynamicCast(&entry);
+        if (jobEntry)
+        	{
+        	if (TaskExist(jobEntry, aTaskId))
+        		{
+        		return jobEntry;
+        		}
+        	}
+    	}
+
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CAspProfile::DeleteHistory
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::DeleteHistory()
+	{
+	if (iHistoryLogOpen)
+    	{
+    	iHistoryLog.DeleteAllEntriesL();	
+    	}  
+    	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::TaskExist
+// 
+// -----------------------------------------------------------------------------
+TBool CAspProfile::TaskExist(const CSyncMLHistoryJob* aHistoryJob, TInt aTaskId)
+	{
+	TInt taskCount = aHistoryJob->TaskCount();
+	for (TInt i=0; i<taskCount; i++)
+		{
+		const CSyncMLHistoryJob::TTaskInfo& taskInfo = aHistoryJob->TaskAt(i);
+        
+        if (taskInfo.iTaskId == aTaskId)
+        	{
+        	return ETrue;
+        	}
+		}
+		
+	return EFalse;
+	}
+
+
+
+/* 
+// -----------------------------------------------------------------------------
+// CAspProfile::HistoryJobsLC (debugging code)
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspProfile::HistoryJobsLC()
+    {
+   	HBufC* hBuf = HBufC::NewLC(1024);
+	TPtr ptr = hBuf->Des();
+
+    if (!iHistoryLogOpen)
+    	{
+    	return hBuf;
+    	}
+
+    TInt count = iHistoryLog.Count();
+    if (count == 0)
+        {
+        return hBuf;  // profile has no history job
+        }
+        
+    // sort array
+    iHistoryLog.SortEntries(CSyncMLHistoryEntry::ESortByTime);    
+    
+    // try to find latest sync job (start from last array entry)
+    for (TInt i=count-1; i>=0; i--)
+    //for (TInt i=0; i<count; i++)
+    	{
+        const CSyncMLHistoryEntry& entry = iHistoryLog[i];
+        const CSyncMLHistoryJob* jobEntry = CSyncMLHistoryJob::DynamicCast(&entry);
+        if (jobEntry)
+        	{
+        	TTime t = jobEntry->TimeStamp();
+        	TBuf<128> buf;
+        	TUtil::GetDateTimeTextL(buf, t);
+        	ptr.Append(buf);
+        	ptr.Append(_L("\n"));
+        	}
+    	}
+
+    return hBuf;
+    }
+*/
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::OpenHistoryLog
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::OpenHistoryLog()
+    {
+    TInt id = ProfileId();
+   	TRAPD(err, iHistoryLog.OpenL(Session(), id));
+   	if (err == KErrNone)
+   		{
+   		iHistoryLogOpen = ETrue;
+    	}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::OpenConnection
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::OpenConnection()
+    {
+   	TInt err = KErrNone;
+   	RArray<TSmlTransportId> arr;
+   	
+    TRAP(err, Profile().ListConnectionsL(arr));
+    if (err != KErrNone)
+    	{
+    	return; 
+    	}
+    if (arr.Count() == 0)
+    	{
+     	arr.Close();  
+    	return; // no connection
+    	}
+        	
+    TInt transportId = arr[0];
+    arr.Close();
+    	
+    TRAP(err, iConnection.OpenL(iProfile, transportId));
+    if (err == KErrNone)
+    	{
+    	iConnectionOpen = ETrue;
+    	}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::Session
+// 
+// -----------------------------------------------------------------------------
+//
+RSyncMLSession& CAspProfile::Session()
+	{
+	__ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrGeneral));
+	
+	return *iSyncSession;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::ApplicationId
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::ApplicationId()
+	{
+	return iApplicationId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetConnectionPropertyNameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetConnectionPropertyNameL(TDes8& aText, TInt aPropertyPos)
+	{
+	//
+	// at the moment RSyncMLTransport is only needed for internet connection settings
+	//
+	RSyncMLTransport transport;
+	transport.OpenL(Session(), KUidNSmlMediumTypeInternet.iUid);  // no ICP call
+	CleanupClosePushL(transport);
+	
+	const CSyncMLTransportPropertiesArray&  arr = transport.Properties();
+	
+    __ASSERT_DEBUG(arr.Count()>aPropertyPos, TUtil::Panic(KErrGeneral));
+    	
+	const TSyncMLTransportPropertyInfo& info = arr.At(aPropertyPos);
+	aText = info.iName;
+	
+	CleanupStack::PopAndDestroy(&transport);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CopyValuesL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::CopyValuesL(CAspProfile* aSource)
+    {
+    TBuf<KBufSize255> buf;
+    TInt num = 0;
+    
+    num = aSource->ProtocolVersion();
+    SetProtocolVersionL(num);
+    if (num == EAspProtocol_1_2)
+    	{
+    	if (!IsPCSuiteProfile(aSource))
+    		{
+        	aSource->GetServerId(buf);
+        	SetServerIdL(buf);
+    		}
+    	}
+    	
+    num = aSource->BearerType();
+    SetBearerTypeL(num);
+    
+    num = aSource->AccessPointL();
+
+	//check if the access point is valid
+	TAspAccessPointItem item;
+	item.iUid = num;
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspAccessPointHandler* apHandler = CAspAccessPointHandler::NewL(param);
+	CleanupStack::PushL(apHandler);
+	TInt ret = apHandler->GetInternetApInfo(item);
+	if (ret == KErrNone)
+	    {
+	    SetAccessPointL(num);
+	    }
+	else
+	    {
+	    SetAccessPointL(CAspAccessPointHandler::KDefaultConnection);
+	    }    
+    CleanupStack::PopAndDestroy(apHandler);
+	
+    aSource->GetHostAddress(buf, num);
+    SetHostAddressL(buf, num);
+     
+    aSource->GetUserName(buf);
+    SetUserNameL(buf);
+     
+    aSource->GetPassword(buf);
+    SetPasswordL(buf);
+    
+    num = aSource->SASyncState();
+    SetSASyncStateL(num);
+    
+    if (aSource->BearerType() == EAspBearerInternet)
+    	{
+    	num = aSource->HttpUsedL();
+    	SetHttpUsedL(num);
+    	
+    	aSource->GetHttpUserNameL(buf);
+    	SetHttpUserNameL(buf);
+    	
+    	aSource->GetHttpPasswordL(buf);
+    	SetHttpPasswordL(buf);
+    	}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::SetDefaultValuesL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::SetDefaultValuesL(CAspProfile* aProfile)
+	{
+	aProfile->SetSASyncStateL(ESASyncStateConfirm);
+	aProfile->SetHttpUsedL(EFalse);
+	aProfile->SetAccessPointL(CAspAccessPointHandler::KDefaultConnection);
+	aProfile->SetProtocolVersionL(EAspProtocol_1_2);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetNewProfileNameL
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspProfile::GetNewProfileNameLC(CAspProfileList* aList, TInt aApplicationId)
+	{
+    HBufC* hBuf = NULL;
+    
+    for (TInt i=1; i<=KMaxProfileCount; i++)
+		{
+        hBuf = CAspResHandler::GetNewProfileNameLC(i, aApplicationId);
+		if (aList->FindProfileIndex(hBuf->Des()) == KErrNotFound)
+			{
+			break;
+     		}
+     	
+     	if (i == KMaxProfileCount)
+     		{
+     		break; // too many profiles - use existing name
+     		}
+     		
+     	CleanupStack::PopAndDestroy(hBuf);
+     	hBuf = NULL;
+		}
+		
+	if (!hBuf)
+		{
+		User::Leave(KErrNotFound);
+		}
+		
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CheckMandatoryDataL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CheckMandatoryData(CAspProfile* aProfile, TInt& aContentCount)
+	{
+	aContentCount = 0;
+	
+	TInt ret = CheckMandatoryConnData(aProfile);
+	if (ret != EMandatoryOk)
+		{
+		return ret;
+		}
+
+    ret = CheckMandatoryTaskData(aProfile, aContentCount);
+    
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CheckMandatoryConnData
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CheckMandatoryConnData(CAspProfile* aProfile)
+	{
+	const TInt KMaxHostAddressLength = KAspMaxURILength + 5;
+	
+	TBuf<KMaxHostAddressLength> buf;
+	TInt num;
+
+	aProfile->GetName(buf);
+	if (TUtil::IsEmpty(buf))
+		{
+		return EMandatoryNoProfileName;
+		}
+
+	aProfile->GetHostAddress(buf, num);
+	if (TUtil::IsEmpty(buf))
+		{
+		return EMandatoryNoHostAddress;
+		}
+
+    return EMandatoryOk;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CheckMandatoryTaskDataL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CheckMandatoryTaskDataL(CAspProfile* aProfile, TInt& aContentCount)
+	{
+    TAspParam param(aProfile->ApplicationId(), &(aProfile->Session()));
+	param.iProfile = aProfile;
+	param.iMode = CAspContentList::EInitTasks;
+	
+	CAspContentList* list = CAspContentList::NewLC(param);
+    
+    TInt ret = list->CheckMandatoryDataL(aContentCount);
+	CleanupStack::PopAndDestroy(list);
+	
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CheckMandatoryTaskData
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CheckMandatoryTaskData(CAspProfile* aProfile, TInt& aContentCount)
+	{
+	TInt ret = EMandatoryNoContent;
+	
+	TRAP_IGNORE(ret = CheckMandatoryTaskDataL(aProfile, aContentCount));
+	
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::OtherSyncRunning
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfile::OtherSyncRunning(RSyncMLSession* aSyncSession)
+	{
+	TInt currentJob = CurrentJob(aSyncSession);
+
+    if (currentJob != KErrNotFound)
+		{
+		return ETrue;
+		}
+	
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfile::CurrentJob
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfile::CurrentJob(RSyncMLSession* aSyncSession)
+	{
+	TInt currentJob = KErrNotFound;
+	TSmlUsageType usageType = ESmlDataSync;
+	TRAP_IGNORE(aSyncSession->CurrentJobL(currentJob, usageType));
+		
+	if (currentJob >= 0)
+		{
+		return currentJob;	
+		}
+	return KErrNotFound;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspProfile:::IsPCSuiteProfile
+// 
+//-----------------------------------------------------------------------------
+//
+TBool CAspProfile::IsPCSuiteProfile(CAspProfile* aProfile)
+	{
+	_LIT(KPCSuite, "pc suite");
+
+	if (aProfile->DeleteAllowed())
+		{
+		return EFalse; // this is not "PC Suite" profile 
+		}
+	
+	TInt num = KErrNotFound;
+	TBuf<KBufSize64> buf;
+	aProfile->GetHostAddress(buf, num);
+	buf.LowerCase();
+	
+	if (buf.Compare(KPCSuite) == 0)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfile::GetLocalisedPCSuite
+//
+// Returns "PC Suite" string localised to specific language
+// 
+// Current requirement is to localise to 2 languages TaiwanChinese and ELangHongKongChinese
+// For all the rest it will be mapped to "PC suite" only
+// -----------------------------------------------------------------------------
+//
+void CAspProfile::GetLocalisedPCSuite(TDes& aText)
+{
+ 		TLanguage language = User::Language();
+         
+ 		switch(language)
+ 		{
+ 			case ELangTaiwanChinese:
+            case ELangHongKongChinese:
+ 			case ELangEnglish_HongKong:
+ 			case ELangPrcChinese:
+ 			case ELangEnglish_Taiwan:
+			case ELangEnglish_Prc:
+ 			case ELangMalay_Apac:
+ 			case ELangIndon_Apac: 
+            {
+            	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_PC_SUITE_PROFILE);
+            	TUtil::StrCopy(aText,*hBuf);
+            	CleanupStack::PopAndDestroy(hBuf);
+            	return;
+            }
+            default:
+            {
+            	TUtil::StrCopy(aText, iProfile.DisplayName());
+            	return;
+            }
+ 		}
+}
+
+
+
+/*******************************************************************************
+ * class TAspTask
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// TAspTask::SmlSyncDirection
+//
+// -----------------------------------------------------------------------------
+//
+TSmlSyncType TAspTask::SmlSyncDirection(TInt aSyncDirection)
+	{
+	TSmlSyncType type = ESmlTwoWay;
+	
+	if (aSyncDirection == ESyncDirectionOneWayFromDevice)
+		{
+		type = ESmlOneWayFromClient;
+		}
+	if (aSyncDirection == ESyncDirectionOneWayIntoDevice)
+		{
+		type = ESmlOneWayFromServer;
+		}
+	if (aSyncDirection == ESyncDirectionRefreshFromServer)
+		{
+		type = ESmlRefreshFromServer;
+		}
+		
+	return type;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspTask::SmlSyncDirection
+//
+// -----------------------------------------------------------------------------
+//
+TInt TAspTask::SyncDirection(TSmlSyncType aSmlSyncDirection)
+    {
+	TInt type = ESyncDirectionTwoWay;
+	
+	if (aSmlSyncDirection == ESmlOneWayFromClient)
+		{
+		type = ESyncDirectionOneWayFromDevice;
+		}
+	if (aSmlSyncDirection == ESmlOneWayFromServer)
+		{
+		type = ESyncDirectionOneWayIntoDevice;
+		}
+	if (aSmlSyncDirection == ESmlRefreshFromServer)
+		{
+		type = ESyncDirectionRefreshFromServer;
+		}
+		
+
+	return type;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspTask::FindTaskIdL
+//
+// -----------------------------------------------------------------------------
+//
+
+TInt TAspTask::FindTaskIdL(CAspProfile* aProfile, TInt aDataProviderId, const TDesC& aLocalDatabase)
+	{
+	TInt ret = KErrNotFound;
+	
+	RArray<TSmlTaskId> arr;
+	aProfile->Profile().ListTasksL(arr); // IPC call
+	CleanupClosePushL(arr);
+	
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TInt taskId = arr[i];
+	    RSyncMLTask task;
+    	task.OpenL(aProfile->Profile(), taskId);  // IPC call
+		
+	    if (aDataProviderId != task.DataProvider())
+	    	{
+	    	task.Close();
+	    	continue; // wrong data provider
+	    	}
+    	if (!task.Enabled())
+    		{
+    		task.Close();
+    		continue; // task not in use
+    		}
+
+	    if (TUtil::IsEmpty(aLocalDatabase))
+	    	{
+	    	ret = taskId;  // parameter aLocalDatabase is empty - no db name check
+	    	}
+	    else
+	    	{
+	    	TPtrC ptr = task.ClientDataSource();
+	        if (ptr.Compare(aLocalDatabase) == 0)
+	    	    {
+	    	    ret = taskId;
+	    	    }
+	    	}
+	
+	    task.Close();
+		
+		if (ret != KErrNotFound)
+			{
+			break;
+			}
+		}
+		
+    CleanupStack::PopAndDestroy(&arr);		
+    
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspTask::CheckLocalDatabase
+// 
+// -----------------------------------------------------------------------------
+//
+TInt TAspTask::CheckLocalDatabase(CAspProfile* aProfile, TInt& aDataProviderId)
+	{
+	TBool ret = ETrue;
+	
+	TRAPD(err, ret = CheckLocalDatabaseL(aProfile, aDataProviderId));
+	if (err != KErrNone)
+		{
+		return ETrue; // check failed, ETrue means profile has local database
+		}
+		
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspTask::CheckLocalDatabaseL
+//
+// -----------------------------------------------------------------------------
+//
+
+TBool TAspTask::CheckLocalDatabaseL(CAspProfile* aProfile, TInt& aDataProviderId)
+	{
+	FLOG( _L("TAspTask::CheckLocalDatabaseL START") );
+	
+	TInt ret = ETrue;
+	aDataProviderId = KErrNotFound;
+	
+	RArray<TSmlTaskId> arr;
+	aProfile->Profile().ListTasksL(arr); // IPC call
+	CleanupClosePushL(arr);
+	
+	TInt count = arr.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		// open sync task
+		RSyncMLTask task;
+        TInt taskId = arr[i];
+    	TRAPD(err, task.OpenL(aProfile->Profile(), taskId));  // IPC call
+	    if (err != KErrNone)
+		    {
+		    FTRACE( RDebug::Print(_L("### RSyncMLTask::OpenL failed (id=%d, err=%d) ###"), taskId, err) );
+	        User::Leave(err);
+		    }
+		    
+		CleanupClosePushL(task);
+		    
+    	TInt dataProviderId = task.DataProvider();
+    	TBool enabled = task.Enabled();
+    	
+        if (dataProviderId != KUidNSmlAdapterEMail.iUid)
+        	{
+	    	CleanupStack::PopAndDestroy(&task);
+	    	continue;  // only email sync task is checked
+        	}
+
+	    if (!enabled)
+	    	{
+	    	CleanupStack::PopAndDestroy(&task);
+	    	continue;  // this task is not included in sync
+	    	}
+     	
+        
+        // open data provider
+       	RSyncMLDataProvider dataProvider;
+        TRAPD(err2, dataProvider.OpenL(aProfile->Session(), dataProviderId));
+   	    if (err2 != KErrNone)
+		    {
+		    FTRACE( RDebug::Print(_L("### RSyncMLDataProvider::OpenL failed (id=%xd, err=%d) ###"), dataProviderId, err2) );
+	        User::Leave(err);
+		    }
+		CleanupClosePushL(dataProvider);
+        
+        TPtrC localDatabase = task.ClientDataSource();
+        
+        if (TUtil::IsEmpty(localDatabase))
+        	{
+        	TPtrC defaultDatabase = dataProvider.DefaultDataStoreName();
+        	if (TUtil::IsEmpty(defaultDatabase))
+        		{
+        		aDataProviderId = dataProviderId;
+        		ret = EFalse;
+        		}
+        	}
+        else
+        	{
+        	CDesCArrayFlat* localDataStores= new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+        	CleanupStack::PushL(localDataStores);
+        	dataProvider.GetDataStoreNamesL(*localDataStores);
+        	TInt dataStorecount = localDataStores->Count();
+        	
+        	if (dataStorecount > 0)
+        		{
+	        	TInt found = localDataStores->Find(localDatabase, count);
+        	   	if (found != 0)  // 0 means database was found
+        		    {
+        		    aDataProviderId = dataProviderId;
+        		    ret = EFalse;
+        		    }
+        		}
+        	else
+        		{
+        		aDataProviderId = dataProviderId;
+        		ret = EFalse;
+        		}
+        		
+        	CleanupStack::PopAndDestroy(localDataStores);
+        	}
+	
+	    CleanupStack::PopAndDestroy(&dataProvider);
+	    CleanupStack::PopAndDestroy(&task);
+		
+		if (!ret)
+			{
+			break;
+			}
+		}
+		
+    CleanupStack::PopAndDestroy(&arr);
+    
+    FLOG( _L("TAspTask::CheckLocalDatabaseL END") );
+    return ret;
+	}
+
+
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfileDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2115 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspProfileDialog.h"
+#include "AspContentDialog.h"
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+#include <AknIconArray.h>   // for GulArray
+#include <aknpasswordsettingpage.h>     // CAknAlphaPasswordSettingPage
+#include <ConnectionUiUtilities.h>      // CConnectionUiUtilities
+#include <featmgr.h>   // FeatureManager
+#include <cmdefconnvalues.h>
+#include <cmmanager.h>
+
+#include "AspSchedule.h"
+
+const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspProfileDialog::ShowDialogL(const TAspParam& aParam)
+	{
+	CAspProfileDialog* dialog = CAspProfileDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_PROFILE_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspProfileDialog* CAspProfileDialog::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfileDialog::NewL START") );
+
+    CAspProfileDialog* self = new ( ELeave ) CAspProfileDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProfileDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::CAspProfileDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspProfileDialog::CAspProfileDialog(const TAspParam& aParam)
+	{
+    iSyncSession = aParam.iSyncSession;
+    iApplicationId = aParam.iApplicationId;
+    iProfile = aParam.iProfile;
+    iContentList = aParam.iContentList;
+    iProfileList = aParam.iProfileList;
+    iEditMode = aParam.iMode;
+    iMSKEmpty = EFalse;
+       
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iContentList, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::ConstructL()
+    {
+    FLOG( _L("CAspProfileDialog::ConstructL START") );
+	
+	// contruct menu for our dialog
+	CAknDialog::ConstructL(R_ASP_PROFILE_DIALOG_MENU);
+
+	iResHandler = CAspResHandler::NewL();
+
+	iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(1);
+
+    TAspParam param(KErrNotFound, iSyncSession);
+	iBearerHandler = CAspBearerHandler::NewL(param);
+	iApHandler = CAspAccessPointHandler::NewL(param);
+	
+	// get previous title so it can be restored
+	iSettingEnforcement = TUtil::SettingEnforcementState();
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	FLOG( _L("CAspProfileDialog::ConstructL END") );
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspProfileDialog::~CAspProfileDialog()
+    {
+    FLOG( _L("CAspProfileDialog::~CAspProfileDialog START") );
+
+	delete iResHandler;
+	
+	if (iSettingList)
+		{
+		iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+		}
+
+	delete iStatusPaneHandler;
+	delete iBearerHandler;
+	delete iApHandler;
+	
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	FLOG( _L("CAspProfileDialog::~CAspProfileDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::ActivateL
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspProfileDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	aContext.iContext = KDS_HLP_SETTINGS;    
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::HandleListBoxEventL
+// 
+// -----------------------------------------------------------------------------
+void CAspProfileDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                            TListBoxEvent aEventType)
+	{
+	if( AknLayoutUtils::PenEnabled() )  
+	  {
+	   switch ( aEventType )
+        {
+         case EEventItemDoubleClicked:
+              HandleOKL();
+              break;
+         case EEventEnterKeyPressed :
+         case EEventItemClicked :
+         case EEventItemDraggingActioned :
+         case EEventPenDownOnItem :
+        	  if(iEditMode != EDialogModeSettingEnforcement)
+				    {
+				    TRAPD(err ,CheckContentSettingL());//folder
+		         	User::LeaveIfError(err);
+				    }
+              break;
+         default:
+              break;
+        }
+		
+	  }
+    
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::PreLayoutDynInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAspProfileDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+    
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	
+	// create array of setting items (iSettingList)
+	CreateSettingsListL();
+
+	// add setting headers into listbox
+	UpdateListBoxL(iSettingListBox, iSettingList);
+	
+	if (iEditMode == EDialogModeEditMandatory)
+		{
+		TInt index = CheckMandatoryFields();
+		if (index != KErrNotFound)
+			{
+			ListBox()->SetCurrentItemIndexAndDraw(index);
+			}
+		}
+	
+	TInt curIndex = ListBox()->CurrentItemIndex();
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+    	
+   	//if((isPCSuite && curItem->iHidden == EVisibilityReadOnly)
+   	if(curItem->iHidden == EVisibilityReadOnly
+   		|| iEditMode == EDialogModeSettingEnforcement)
+   	{
+   	   	 SetEmptyMiddleSoftKeyLabelL();
+   	}
+   	
+#ifdef RD_DSUI_TIMEDSYNC 
+	iStatusPaneHandler->SetTitleL(R_ASP_TITLE_PROFILE_SETTINGS);
+#else
+    iProfile->GetName(iBuf);
+    iStatusPaneHandler->SetTitleL(iBuf);
+#endif
+	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::SetMiddleSoftKeyLabelL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::SetEmptyMiddleSoftKeyLabelL()
+    {
+    ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,EAknSoftkeyOpen );
+    HBufC* middleSKText = StringLoader::LoadLC( R_TEXT_SOFTKEY_EMPTY );
+
+    ButtonGroupContainer().AddCommandToStackL(
+        KMSKControlId,
+        EAknSoftkeyEmpty,
+        *middleSKText );
+    iMSKEmpty= ETrue;
+    CleanupStack::PopAndDestroy( middleSKText );
+    }
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::SetIconsL()
+    {
+    if (!iSettingListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	// Create the lock icon as the last icon in the table
+	CFbsBitmap* skinnedBitmap = NULL;
+    CFbsBitmap* skinnedMask = NULL;
+    
+	// Make the icon and put it in the array
+    CGulIcon* icon = CGulIcon::NewL();
+    CleanupStack::PushL(icon);
+    icon->SetBitmapsOwnedExternally(EFalse);
+		
+    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+    // Create color icon
+    AknsUtils::CreateColorIconL(skin,
+							    KAknsIIDQgnIndiSettProtectedAdd, 
+							    KAknsIIDQsnIconColors,
+							    EAknsCIQsnIconColorsCG13,
+							    skinnedBitmap, 
+							    skinnedMask,
+							    bitmapName,
+							    EMbmAspsyncutilQgn_indi_sett_protected_add, 
+							    EMbmAspsyncutilQgn_indi_sett_protected_add_mask,
+							    KRgbBlack
+							   );
+	
+    icon->SetMask(skinnedMask);     // ownership transferred
+    icon->SetBitmap(skinnedBitmap); // ownership transferred
+    
+	icons->AppendL( icon );  
+
+	CleanupStack::Pop(icon); // icon
+    // Create the lock icon for highlight
+    skinnedBitmap = NULL;
+    skinnedMask = NULL;
+    
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr =
+		iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspProfileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspProfileDialog::DynInitMenuPaneL(TInt /*aResourceID*/, CEikMenuPane* aMenuPane)
+	{
+   
+   	if (ListBox()->Model()->NumberOfItems() == 0) 
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		return;
+		}
+
+	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		}
+	
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
+		}
+	
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspProfileDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAknCmdHelp:
+			{
+			TUtil::LaunchHelpAppL(iEikonEnv);
+            break;
+			}
+
+		case EAspMenuCmdChange:
+		case EAspMenuCmdOpen:
+			{				
+    		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+
+			if (item->iItemType == CAspListItemData::ETypeListYesNo)
+				{
+				// open editor for Yes/No setting
+				if (EditSettingItemListL(*item))
+					{
+					SetVisibility();
+					UpdateListBoxL(ListBox(), iSettingList);
+					}
+				}				
+			else
+				{
+				HandleOKL();
+				}
+
+			break;
+			}
+		    
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:			
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+		// save silently and close dialog
+		
+		CheckSettingValues(aButtonId);
+
+		TRAP_IGNORE(SaveSettingsL());
+		return ETrue; // close dialog
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+        TBool ret = CheckSettingValues(aButtonId);
+        if (!ret)
+        	{
+        	return EFalse; // leave dialog open
+        	}
+        	
+		TRAP_IGNORE(SaveSettingsL());
+		return ETrue; // close dialog
+		}
+		
+	if (aButtonId == EAknSoftkeyOpen || aButtonId == EAknSoftkeyEmpty)  // MSK
+        {
+		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+		if (item->iHidden == EVisibilityReadOnly)
+			{
+    		if(iEditMode == EDialogModeSettingEnforcement)
+    		{
+    			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+    		}
+     		else
+     		{
+			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+     		}
+			return EFalse;
+			}
+
+        HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+		
+	if (aButtonId == EAknSoftkeyOptions)	
+		{
+		if (iCommandSetId == R_ASP_CBA_OPTIONS_BACK_OPEN)
+			{
+			UpdateMenuL(R_ASP_PROFILE_CONTEXT_MENU);
+			}	
+		else 
+			{
+			UpdateMenuL(R_ASP_PROFILE_DIALOG_MENU);	
+			}
+		return EFalse;
+		}
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::CheckSettingValuesL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::CheckSettingValuesL(TInt aButtonId)
+	{
+    if (iEditMode == EDialogModeReadOnly || 
+        iEditMode == EDialogModeSettingEnforcement)
+    	{
+    	return ETrue;
+    	}
+	
+	if (aButtonId == EEikBidCancel)
+		{
+		TInt index = CheckUniqueServerId();
+		if (index != KErrNotFound)
+			{
+			Item(EAspServerId)->SetValueL(iOldServerId);
+			}
+
+		return ETrue;
+		}
+
+	TInt mandatoryIndex = CheckMandatoryFields();
+	if (mandatoryIndex != KErrNotFound)
+		{
+		if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY))
+			{
+			ListBox()->SetCurrentItemIndexAndDraw(mandatoryIndex);
+			return EFalse; // leave dialog open
+			}
+				
+	    TInt serverIdIndex = CheckUniqueServerId();
+	    if (serverIdIndex != KErrNotFound)
+	    	{
+	    	Item(EAspServerId)->SetValueL(iOldServerId);
+	    	}
+		}
+	else
+		{
+		TInt serverIdIndex = CheckUniqueServerId();
+	    if (serverIdIndex != KErrNotFound)
+		    {
+		    if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_SERVER_ID_EXISTS))
+			    {
+			    ListBox()->SetCurrentItemIndexAndDraw(serverIdIndex);
+			    return EFalse; // leave dialog open
+			    }
+		    else
+			    {
+			    Item(EAspServerId)->SetValueL(iOldServerId);
+			    }
+		    }
+		}
+
+    return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::CheckSettingValues
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::CheckSettingValues(TInt aButtonId)
+	{
+	TBool ret = EFalse;
+	
+	TRAPD(err, ret = CheckSettingValuesL(aButtonId));
+	if (err != KErrNone)
+		{
+		return ETrue;
+		}
+
+	return ret;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspProfileDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEnter:
+				{
+					HandleOKL();
+					return EKeyWasConsumed;
+				}
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+			case EKeyUpArrow:
+			case EKeyDownArrow:
+			    {
+			    	if(iEditMode != EDialogModeSettingEnforcement)
+				    {
+				    TRAPD(err ,CheckContentSettingL(aKeyEvent));//folder
+		         	User::LeaveIfError(err);
+				    }
+			    break;
+			    }
+            default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+// ---------------------------------------------------------------------------------------------
+// CAspProfileDialog::CheckContentSetting
+// modifies MSK and menu item depending on the item in the list box when touch events are handled
+// ----------------------------------------------------------------------------------------------
+//
+
+void CAspProfileDialog::CheckContentSettingL()
+{
+	TInt curIndex = ListBox()->CurrentItemIndex();
+	TInt count = iSettingList->Count();
+	CAspListItemData* lastItem = (*iSettingList)[--count];
+	
+
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+	if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly))
+	{
+   		SetEmptyMiddleSoftKeyLabelL();
+   		return;
+	}
+	if(curItem->iItemId != EAspSyncContent)
+		{
+		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
+			{
+			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
+		
+			}
+		return;		
+		}
+	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
+
+}
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::CheckContentSetting
+// modifies MSK depending on the item
+// ----------------------------------------------------------------------------
+//
+
+void CAspProfileDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent)
+	{
+	
+	TInt curIndex = ListBox()->CurrentItemIndex();
+	TInt count = iSettingList->Count();
+	CAspListItemData* lastItem = (*iSettingList)[--count];
+	
+	switch (aKeyEvent.iCode)
+		{
+		case EKeyUpArrow:
+			{
+				if (curIndex)
+				{
+					curIndex--;
+				}
+				else
+				{
+				    curIndex = lastItem->iIndex;
+				}
+			break;
+			}
+		case EKeyDownArrow:
+			{
+				if (curIndex == lastItem->iIndex)
+				{
+				curIndex = 0;
+				}
+				else
+				{
+				curIndex++;
+				}
+			break;
+			}
+		}
+		
+	CAspListItemData* curItem = GetItemForIndex(curIndex);
+	if(curItem->iHidden == EVisibilityReadOnly)
+	{
+   		SetEmptyMiddleSoftKeyLabelL();
+   		return;
+	}
+	if(curItem->iItemId != EAspSyncContent)
+		{
+		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
+			{
+			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
+		
+			}
+		return;		
+		}
+	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
+
+	}
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::CheckMandatoryFields
+//
+// Check that all mandatory fields are filled.
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileDialog::CheckMandatoryFields()
+	{ 
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		
+		if (!CheckMandatoryContentFields(item))
+			{
+			return item->iIndex;
+			}
+			
+		if ( item->iMandatory && item->IsEmpty() && (item->iHidden == EVisibilityNormal) )
+			{
+			return item->iIndex;
+			}
+		}
+
+    return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::CheckUniqueServerId
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileDialog::CheckUniqueServerId()
+	{
+	TPtrC ptr = Item(EAspServerId)->Value();
+	
+	if (iOldServerId.Compare(ptr) == 0)
+		{
+		return KErrNotFound;  // server id has not changed
+		}
+	
+	if (!iProfileList)
+		{
+		return KErrNotFound;
+		}
+
+	TInt profileId = iProfile->ProfileId();
+
+	if (iProfileList->IsUniqueServerId(Item(EAspServerId)->Value(), profileId))
+		{
+		return KErrNotFound;
+		}
+		
+	return Item(EAspServerId)->iIndex;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::CheckMandatoryContentFields
+//
+// Check that all mandatory fields are filled.
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::CheckMandatoryContentFields(CAspListItemData* aListItem)
+	{
+	if (aListItem->iItemType != CAspListItemData::ETypeSyncContent)
+		{
+		return ETrue;
+		}
+		
+	TInt index = iContentList->FindTaskIndexForProvider(aListItem->iNumberData);
+	if (index == KErrNotFound)
+		{
+		return ETrue;
+		}
+		
+	TAspTaskItem& item = iContentList->TaskItem(index);
+	if (item.iEnabled && !item.iRemoteDatabaseDefined)
+		{
+		return EFalse;
+		}
+		
+    return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::HandleOKL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileDialog::HandleOKL()
+	{
+	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+			if(iEditMode == EDialogModeSettingEnforcement)
+      		{
+    			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+    		}
+     		else
+     		{
+			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+     		}
+		return;
+		}
+
+	if (EditSettingItemL(*item))
+		{
+		SetVisibility();
+		UpdateListBoxL(ListBox(), iSettingList);
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::CreateSettingsListL
+// 
+// Function creates setting list array (iSettingsList).
+// Note: enum TAspConnectionSettings must match with string array
+// (R_ASP_CONNECTION_DIALOG_SETTING_ITEMS).
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::CreateSettingsListL()
+	{
+	// read setting headers from resource
+	CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_CONNECTION_DIALOG_SETTING_ITEMS);
+	
+	// add one CAspListItemData for each setting
+	AddItemL(EAspProfileName, arr);
+	AddItemL(EAspProtocolVersion, arr);
+	AddItemL(EAspServerId, arr);
+
+	AddItemL(EAspConnType, arr);
+	AddItemL(EAspAccessPoint,R_ASP_NETWORK_DESTINATION);
+	AddItemL(EAspHostAddress, arr);
+	AddItemL(EAspPort, arr);
+	AddItemL(EAspUsername, arr);
+	AddItemL(EAspPassword, arr);
+	
+#ifdef __SYNCML_DS_ALERT
+	AddItemL(EAspServerAlert, arr);
+#endif
+
+	AddItemL(EAspHttpsUsername, arr);
+	AddItemL(EAspHttpsPassword, arr);
+	
+	AddItemL(EAspSyncDirection, arr);
+	
+#ifndef	RD_DSUI_TIMEDSYNC 
+	AddContentItemsL();
+#endif
+
+	// write setting data into each CAspListItemData
+	TInt count=iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		InitSettingItemL((*iSettingList)[i]);
+		}
+
+	SetVisibility();  // find out what setting appear on UI
+
+	CleanupStack::PopAndDestroy(arr);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::AddItemL(TInt aItemId, CDesCArray* aHeaders)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL((*aHeaders)[aItemId]);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::AddItemL(TInt aItemId, TInt aResourceId)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(aResourceId);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::AddContentItemsL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::AddContentItemsL()
+	{
+   	TInt count = iContentList->ProviderCount();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
+		TInt appId = TUtil::AppIdFromProviderId(providerItem.iDataProviderId);
+		if (iApplicationId != EApplicationIdSync && iApplicationId != appId)
+			{
+			continue;
+			}
+				
+		HBufC* firstLine = CAspResHandler::GetContentSettingLC(
+		                                   providerItem.iDataProviderId,
+		                                   providerItem.iDisplayName);
+		
+	    CAspListItemData* item = CAspListItemData::NewLC();
+    
+    	item->SetHeaderL(firstLine->Des());
+	    item->iItemId = EAspSyncContent;
+	    item->iItemType = CAspListItemData::ETypeSyncContent;
+	    item->iNumberData = providerItem.iDataProviderId;
+	    iSettingList->AppendL(item);
+	    CleanupStack::Pop(item);
+	    
+	    CleanupStack::PopAndDestroy(firstLine);
+    	}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::UpdateListBoxL(CEikTextListBox* aListBox,
+                                       CAspSettingList* aItemList)
+	{
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt i=0; i<count; i++ )
+		{	
+		CAspListItemData* item = (*aItemList)[i];
+		TInt id = item->iItemId;
+		
+		TBool convert = ETrue;
+	   TBool isPCSuite=CAspProfile::IsPCSuiteProfile(iProfile);
+       TBool readOnly = iProfile->DeleteAllowed();
+       if(isPCSuite && !readOnly||iSettingEnforcement)
+        {
+                if(id==EAspAccessPoint || id==EAspSyncDirection ||id==EAspConnType)
+        	       convert = EFalse;//no number conversion
+        }
+       if(!isPCSuite &&!readOnly)
+       {
+                if(id==EAspAccessPoint ||id==EAspConnType)
+        	       convert = EFalse;//no number conversion
+       }	
+		if (id == EAspServerId || id == EAspHostAddress ||
+	       id == EAspPort || id == EAspUsername || id == EAspHttpsUsername||iSettingEnforcement)
+			{
+			convert = EFalse; // no number conversion
+			}
+
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+			
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	ListBox()->HandleItemAdditionL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::SetVisibility()
+	{
+    TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+    
+    TBool readOnly = iProfile->DeleteAllowed();
+	
+	if (Item(EAspProtocolVersion)->iNumberData == EAspProtocol_1_1)
+		{
+		Item(EAspServerId)->iHidden = EVisibilityHidden;
+		}
+	else if (isPCSuite || !readOnly)
+		{
+		Item(EAspServerId)->iHidden = EVisibilityReadOnly;
+		}
+	else
+		{
+		Item(EAspServerId)->iHidden = EVisibilityNormal;
+		}
+	
+	
+	if (isPCSuite || !readOnly)
+		{
+		Item(EAspConnType)->iHidden = EVisibilityReadOnly;
+		}
+	else
+		{
+		Item(EAspConnType)->iHidden = EVisibilityNormal;
+		}
+
+	if (isPCSuite || !readOnly)
+		{
+		Item(EAspHostAddress)->iHidden = EVisibilityReadOnly;
+		}
+	else
+		{
+		Item(EAspHostAddress)->iHidden = EVisibilityNormal;
+		}
+		
+	if(isPCSuite)
+	{
+		Item(EAspSyncDirection)->iHidden = EVisibilityReadOnly;
+	}
+	else
+	{
+		Item(EAspSyncDirection)->iHidden = EVisibilityNormal;
+	}
+    
+		
+
+	if (iBearerHandler->SupportedBearerCount() == 1)
+		{
+		Item(EAspConnType)->iHidden = EVisibilityReadOnly;
+		}
+	
+    Item(EAspUsername)->iHidden = EVisibilityNormal;
+	Item(EAspPassword)->iHidden = EVisibilityNormal;
+
+	if (Item(EAspConnType)->iNumberData != EAspBearerInternet)
+		{
+		Item(EAspAccessPoint)->iHidden = EVisibilityHidden;
+		Item(EAspPort)->iHidden = EVisibilityHidden;
+		Item(EAspHttpsUsername)->iHidden = EVisibilityHidden;
+		Item(EAspHttpsPassword)->iHidden = EVisibilityHidden;
+    	}
+	else
+		{
+		Item(EAspAccessPoint)->iHidden = EVisibilityNormal;
+		Item(EAspPort)->iHidden = EVisibilityNormal;
+		Item(EAspHttpsUsername)->iHidden = EVisibilityNormal;
+		Item(EAspHttpsPassword)->iHidden = EVisibilityNormal;
+		}
+		
+#ifdef __SYNCML_DS_ALERT
+    Item(EAspServerAlert)->iHidden = EVisibilityNormal;
+#endif
+	
+    if (iEditMode == EDialogModeReadOnly || 
+        iEditMode == EDialogModeSettingEnforcement)
+    	{
+    	SetAllReadOnly();
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::SetAllReadOnly
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::SetAllReadOnly()
+	{
+	TInt count = iSettingList->Count();
+
+	for (TInt i=0; i<count; i++ )
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		if (item->iHidden != EVisibilityHidden)
+			{
+			item->iHidden = EVisibilityReadOnly;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::InitSettingItemL
+// 
+// Constructs CAspListItemData for one connection setting.
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::InitSettingItemL(CAspListItemData* aItem)
+	{
+	__ASSERT_ALWAYS(aItem, TUtil::Panic(KErrGeneral));	
+	
+	iBuf = KNullDesC;  // reset common buffer
+	
+	switch (aItem->iItemId)
+		{
+		case EAspProfileName:
+			{
+			iProfile->GetName(iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
+			
+			aItem->iMaxLength = KAspMaxProfileNameLength;
+			aItem->iLatinInput = EFalse;
+			aItem->iItemType = CAspListItemData::ETypeText;
+			aItem->iMandatory = ETrue;
+			break;
+			}
+
+		case EAspProtocolVersion:
+			{
+			CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_PROTOCOL_VERSION);
+    
+    		aItem->iNumberData = iProfile->ProtocolVersion();
+			aItem->SetValueL((*arr)[aItem->iNumberData]);
+				
+			aItem->iResource = R_ASP_PROTOCOL_VERSION;
+			aItem->iItemType = CAspListItemData::ETypeProtocolList;
+			
+			CleanupStack::PopAndDestroy(arr);
+			break;
+			}
+
+		case EAspServerId:
+			{
+			iProfile->GetServerId(iBuf);
+			aItem->SetValueL(iBuf);
+			if(TDialogUtil::IsPCSuiteDesC(iBuf))
+			{
+				aItem->SetDisplayValueL(R_ASP_PC_SUITE_PROFILE);	
+			}
+			else
+			{
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+			}
+
+			aItem->iMaxLength = KAspMaxServerIdLength;
+			aItem->iLatinInput = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeText;
+			
+			TUtil::StrCopy(iOldServerId, iBuf);
+			break;
+			}
+		
+		
+		case EAspConnType:
+			{
+			aItem->iNumberData = iProfile->BearerType();
+
+			if (!iBearerHandler->IsSupported(aItem->iNumberData))
+				{
+				aItem->iNumberData = iBearerHandler->DefaultBearer();
+				}
+
+ 			iBearerHandler->GetBearerName(iBuf, aItem->iNumberData);
+			aItem->SetValueL(iBuf);
+			aItem->iItemType = CAspListItemData::ETypeBearerList;
+
+			break;
+			}
+		
+		case EAspAccessPoint:
+			{
+			TAspAccessPointItem item;
+	        item.iUid = iProfile->AccessPointL();
+	        TInt ret = iApHandler->GetInternetApInfo(item);
+	        if (ret == KErrNone)
+	        	{
+	        	aItem->iNumberData = item.iUid;
+	        	aItem->SetValueL(item.iName);
+	        	aItem->iResource = R_ASP_NETWORK_CONNECTION;
+	        	}
+	        else
+	        	{
+	        	aItem->iNumberData = CAspAccessPointHandler::KDefaultConnection;	
+	        	aItem->SetDisplayValueL(R_ASP_DEFAULT_CONNECTION);
+	        	aItem->iResource = R_ASP_NETWORK_CONNECTION;
+	        	}
+	        aItem->iItemType = CAspListItemData::ETypeInternetAccessPoint;
+			break;
+			}
+		
+		case EAspHostAddress:
+			{
+			iProfile->GetHostAddress(iBuf, aItem->iNumberData);
+			aItem->SetValueL(iBuf);
+			if(TDialogUtil::IsPCSuiteDesC(iBuf))
+			{
+				aItem->SetDisplayValueL(R_ASP_PC_SUITE_PROFILE);	
+	 		}
+	        else
+	        {
+	        	aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
+	        }
+			
+			aItem->iMaxLength = KAspMaxURILength;
+			aItem->iLatinInput = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeHostAddress;
+			aItem->iMandatory = ETrue;
+			
+			break;
+			}
+		    
+		case EAspPort:
+			{
+			iProfile->GetHostAddress(iBuf, aItem->iNumberData);
+			if ( aItem->iNumberData > TURIParser::EMaxURIPortNumber || aItem->iNumberData < TURIParser::EMinURIPortNumber)
+  					 	aItem->iNumberData = TURIParser::EDefaultHttpPort;	
+			aItem->SetValueL(aItem->iNumberData);
+			
+			aItem->iMaxLength = KBufSize16;
+			aItem->iMaxValue = TURIParser::EMaxURIPortNumber;
+			aItem->iMinValue = TURIParser::EMinURIPortNumber;
+			aItem->iItemType = CAspListItemData::ETypeNumber;
+			aItem->iLatinInput = ETrue;
+			break;
+			}
+		    
+		case EAspUsername:
+			{
+			iProfile->GetUserName(iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+
+			aItem->iMaxLength = KAspMaxUsernameLength;
+			aItem->iLatinInput = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeText;
+			break;
+			}
+		    
+		case EAspPassword:
+			{
+			iProfile->GetPassword(iBuf);
+			aItem->SetValueL(iBuf);
+			TUtil::Fill(iBuf, KSecretEditorMask, KSecretEditorMaskLength);
+			aItem->SetDisplayValueL(iBuf);
+
+			aItem->iMaxLength = KAspMaxPasswordLength;
+			aItem->iItemType = CAspListItemData::ETypeSecret;
+			break;
+			}
+		
+		case EAspHttpsUsername:
+			{
+			iProfile->GetHttpUserNameL(iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+
+			aItem->iMaxLength = KAspMaxUsernameLength;
+			aItem->iLatinInput = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeText;
+			break;
+			}
+
+		case EAspHttpsPassword:
+			{
+			iProfile->GetHttpPasswordL(iBuf);
+			aItem->SetValueL(iBuf);
+			TUtil::Fill(iBuf, KSecretEditorMask, KSecretEditorMaskLength);
+			aItem->SetDisplayValueL(iBuf);
+
+			aItem->iMaxLength = KAspMaxPasswordLength;
+			aItem->iItemType = CAspListItemData::ETypeSecret;
+			break;
+			}
+		
+		case EAspServerAlert:
+			{
+			CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_SERVER_ALERT_TYPE);
+
+            aItem->iNumberData = iProfile->SASyncState();
+			aItem->iResource = R_ASP_SERVER_ALERT_TYPE;
+			aItem->SetValueL((*arr)[aItem->iNumberData]);
+			aItem->iItemType = CAspListItemData::ETypeList;
+			
+			CleanupStack::PopAndDestroy(arr);
+			break;
+			}
+			
+		case EAspSyncDirection:
+			{
+    		CDesCArray* arr;
+    		TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
+    		if(isPCSuite)
+			 {
+			 	
+			    arr = iResHandler->ReadDesArrayLC(R_ASP_SYNC_PCSUITE_TYPE);
+    			aItem->iResource = R_ASP_SYNC_PCSUITE_TYPE;
+    			   		
+			 }
+			 else
+			 {
+			 	arr = iResHandler->ReadDesArrayLC(R_ASP_SYNC_TYPE);
+    			aItem->iResource =R_ASP_SYNC_TYPE ;
+    			   		
+			 }
+    	
+    		aItem->iNumberData = iContentList->SyncDirection();
+			aItem->SetValueL((*arr)[aItem->iNumberData]);
+			aItem->iItemType = CAspListItemData::ETypeList;
+    		
+    		CleanupStack::PopAndDestroy(arr);
+			break;
+			}
+			
+        
+        case EAspSyncContent:
+        	{
+        	break;
+        	}
+        	
+        default:
+           	__ASSERT_DEBUG(EFalse, TUtil::Panic(KErrGeneral));
+			break;
+		
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileDialog::SaveSettingsL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileDialog::SaveSettingsL()
+	{
+    if (iEditMode == EDialogModeReadOnly || 
+        iEditMode == EDialogModeSettingEnforcement)
+    	{
+    	return;
+    	}
+
+   	iBuf = KNullDesC;  // reset common buffer
+   	
+	TInt count = iSettingList->Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		
+		switch (item->iItemId)
+			{
+			case EAspProfileName:
+			    iProfile->SetNameL(item->Value());
+			    break;
+
+			case EAspProtocolVersion:
+				iProfile->SetProtocolVersionL(item->iNumberData);
+			    break;
+
+			case EAspServerId:
+			    iProfile->SetServerIdL(item->Value());
+			    break;
+
+			case EAspConnType:
+				iProfile->SetBearerTypeL(item->iNumberData);
+			    break;
+
+			case EAspAccessPoint:
+				iProfile->SetAccessPointL(item->iNumberData);
+			    break;
+
+			case EAspHostAddress:
+				{
+				iBuf = item->Value();
+				TURIParser parser(iBuf);
+				TInt portNumber = parser.Port();
+	            if (!parser.IsValidPort(portNumber))
+		            {
+		            	if ( Item(EAspPort)->iNumberData > TURIParser::EMaxURIPortNumber || Item(EAspPort)->iNumberData < TURIParser::EMinURIPortNumber)
+  							    Item(EAspPort)->iNumberData = TURIParser::EDefaultHttpPort;	
+				 		portNumber = Item(EAspPort)->iNumberData;    	
+		            }
+
+				iProfile->SetHostAddressL(iBuf, portNumber);
+				break;
+				}
+
+			case EAspPort:
+				break;  // port is included in host address
+
+			case EAspUsername:
+				iProfile->SetUserNameL(item->Value());
+			    break;
+			
+			case EAspPassword:
+			    iProfile->SetPasswordL(item->Value());
+			    break;
+
+			case EAspServerAlert:
+				{
+				iProfile->SetSASyncStateL(item->iNumberData);
+			    break;
+				}
+
+			case EAspHttpsUsername:
+			    iProfile->SetHttpUserNameL(item->Value());
+			    break;
+
+			case EAspHttpsPassword:
+			    iProfile->SetHttpPasswordL(item->Value());
+			    break;
+			    
+			case EAspSyncDirection:
+				iContentList->ModifyTaskDirectionsL(item->iNumberData);
+				break;
+			    
+			}
+
+		}
+
+	iProfile->Save();
+	iContentList->UpdateLocalDatabaseL();
+#ifdef RD_DSUI_TIMEDSYNC
+	CheckAutoSyncSetttigsL();
+#endif
+	}
+	
+	
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	TInt ret = EFalse;
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (schedule->IsAutoSyncEnabled())
+		{
+		TInt profileId = schedule->ProfileId();
+		if (profileId == iProfile->ProfileId())
+			{
+			TDialogUtil::ShowInformationQueryL(R_ASP_NOTE_MODIFY_AUTO_SYNC_SETTINGS);
+			}
+		}
+    CleanupStack::PopAndDestroy(schedule);
+#endif
+
+	switch (aItem.iItemType)
+		{
+		case CAspListItemData::ETypeInternetAccessPoint:
+		    ret = EditSettingItemAccessPointL(aItem);
+		    break;
+			
+		case CAspListItemData::ETypeText:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeSecret:
+			ret = EditSettingItemSecretL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeNumber:
+			ret = EditSettingItemNumberL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeList:
+			ret = EditSettingItemListL(aItem);
+		    break;
+		
+		case CAspListItemData::ETypeBearerList:
+			ret = EditSettingItemBearerListL(aItem);
+		    break;
+		    
+		case CAspListItemData::ETypeProtocolList:
+			ret = EditSettingItemProtocolListL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeListYesNo:
+			ret = EditSettingItemYesNoL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeHostAddress:
+			ret = EditSettingItemHostAddressL(aItem);
+			break;
+
+		case CAspListItemData::ETypeSyncContent:
+			ret = EditSettingItemSyncContentL(aItem);
+			break;
+
+		default:
+		    break;
+		}
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemYesNoL
+//
+// Change Yes/No value without showing radio button editor.
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemYesNoL(CAspListItemData& aItem)
+	{
+	CDesCArray* arr = iResHandler->ReadDesArrayLC(aItem.iResource);
+	
+	if (aItem.iNumberData == EAspSettingDisabled)
+		{
+		aItem.iNumberData = EAspSettingEnabled;
+		}
+	else
+		{
+		aItem.iNumberData = EAspSettingDisabled;
+		}
+	
+	
+	// store localized setting text (Yes/No)
+	aItem.SetValueL( (*arr)[aItem.iNumberData] );
+
+	CleanupStack::PopAndDestroy(arr);
+	return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemNumberL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemNumberL(CAspListItemData& aItem)
+	{
+	TBool ret = TDialogUtil::ShowIntegerEditorL(aItem.iNumberData, aItem.Header(), 
+	                         aItem.iMinValue, aItem.iMaxValue, aItem.iLatinInput);
+
+	if (ret)
+		{
+		aItem.SetValueL(aItem.iNumberData);
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemSecretL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemSecretL(CAspListItemData& aItem)
+	{
+	TBuf<KBufSize64> newPassword;
+	newPassword = aItem.Value();
+	
+	
+	CAspAlphaPasswordSettingPageEditor* pwd = new (ELeave) CAspAlphaPasswordSettingPageEditor(
+		                                R_ASP_SETTING_PASSWORD, newPassword, aItem.Value());
+	
+	CleanupStack::PushL(pwd);
+	pwd->SetSettingTextL(aItem.Header()); 
+	pwd->ConstructL();
+	pwd->AlphaPasswordEditor()->SetMaxLength(aItem.iMaxLength);
+	//pwd->AlphaPasswordEditor()->RevealSecretText(ETrue);  // pasi
+	CleanupStack::Pop(pwd);
+
+	if (pwd->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
+		{
+		aItem.SetValueL(newPassword);
+		return ETrue;
+		}
+	
+	return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemTextL
+//
+// Edit text setting item.
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemTextL(CAspListItemData& aItem)
+	{
+	TUtil::StrCopy(iBuf, aItem.Value());
+	
+	TInt len = iBuf.Length();
+	if (len > aItem.iMaxLength)
+		{
+		iBuf.SetLength(aItem.iMaxLength);
+		}
+	
+    TBool ret = TDialogUtil::ShowTextEditorL(iBuf, aItem.Header(), 
+                             aItem.iMandatory, aItem.iLatinInput, aItem.iMaxLength);
+   	if (ret)
+		{
+		aItem.SetValueL(iBuf);
+		}
+		
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemHostAddressL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemHostAddressL(CAspListItemData& aItem)
+	{
+	_LIT(KHttpHeader, "http://");
+	
+	TBool httpHeaderUsed = EFalse;
+	TInt bearer = Item(EAspConnType)->iNumberData;
+	HBufC* hBuf = HBufC::NewLC(KBufSize255);
+	TPtr ptr = hBuf->Des();
+	TUtil::StrCopy(ptr, aItem.Value());
+	if (TUtil::IsEmpty(aItem.Value()) && bearer == EAspBearerInternet)
+		{
+		aItem.SetValueL(KHttpHeader);
+		httpHeaderUsed = ETrue;
+		}
+		
+	TBool ret = EFalse;
+	for(;;)
+	{
+	ret = EditSettingItemTextL(aItem);
+	
+	if (httpHeaderUsed && (aItem.Value().Compare(KHttpHeader) == 0))
+		{
+		aItem.SetValueL(KNullDesC);
+		}
+	
+	
+	if (ret)
+		{
+		if(bearer == EAspBearerInternet)
+		{
+			if (!TURIParser::IsValidUri(aItem.Value()))
+			{			
+			TDialogUtil::ShowInformationNoteL(R_ASP_LOG_ERR_URIINVALID);
+			}
+		else
+			{
+			TPtrC ptr = aItem.Value();
+			TURIParser parser(ptr);
+	        TInt portNumber = parser.Port();
+	        if (parser.IsValidPort(portNumber))
+		        {
+		        Item(EAspPort)->iNumberData = portNumber;
+		        Item(EAspPort)->SetValueL(portNumber);
+		        }
+		    break;    
+			}	
+		}
+		else if(bearer == EAspBearerBlueTooth)
+		{
+			if (!TURIParser::IsValidBluetoothHostAddress(aItem.Value()))
+		    {
+		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
+		   
+		    }
+		    else
+		    {
+		    	break;
+		    }
+			}
+		}
+	else if(!ret) 
+		{
+		aItem.SetValueL(ptr);
+		break;	
+		}
+	else
+		{
+		 break;	
+		}
+	}
+	CleanupStack::PopAndDestroy(); //hBuf
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemListL(CAspListItemData& aItem)
+	{
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = curSelection; 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemProtocolListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemProtocolListL(CAspListItemData& aItem)
+	{
+#ifdef __SYNCML_DS_EMAIL   // KFeatureIdSyncMlDsEmail
+	TInt oldSelection = aItem.iNumberData;
+#endif
+	
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* arr2 = iResHandler->ReadDesArrayLC(aItem.iResource);
+	CDesCArray* arr = TUtil::NumberConversionLC(arr2);
+	
+	
+	if (TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection))
+		{
+		aItem.iNumberData = curSelection; 
+		aItem.SetValueL((*arr)[curSelection]);
+		
+	    
+#ifdef __SYNCML_DS_EMAIL   // KFeatureIdSyncMlDsEmail
+
+	    TBool emailSync = EFalse;
+	    TInt id = iProfile->ApplicationId();
+	    if (id == EApplicationIdSync || id == EApplicationIdEmail)
+	    	{
+	    	emailSync = ETrue;
+	    	}
+		
+
+#ifdef RD_DSUI_TIMEDSYNC
+		if (curSelection == EAspProtocol_1_1 )
+				{
+				CAspSchedule* schedule = CAspSchedule::NewLC();
+				TInt profileId = schedule->ProfileId();
+				if (profileId == iProfile->ProfileId())
+					{
+					TInt selectedContentCnt = 0;
+					TInt selectedContentIndex = 0;
+					TInt emailIndex = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+					schedule->ContentSelectionInfo(selectedContentCnt, selectedContentIndex);
+					if (selectedContentCnt == 1 && selectedContentIndex == emailIndex)
+						{
+						schedule->SetProfileId(KErrNotFound);
+						schedule->SetContentEnabled(emailIndex, EFalse);
+						schedule->SetSyncPeakSchedule(CAspSchedule::EIntervalManual);
+						schedule->SetSyncOffPeakSchedule(CAspSchedule::EIntervalManual);
+						schedule->SetSyncFrequency(CAspSchedule::EIntervalManual);
+						schedule->UpdateSyncScheduleL();
+						schedule->SaveL();
+						}
+					}
+				CleanupStack::PopAndDestroy(schedule);
+				}
+#endif
+		
+#endif
+		
+		CleanupStack::PopAndDestroy(arr);
+		CleanupStack::PopAndDestroy(arr2);
+		return ETrue;
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	CleanupStack::PopAndDestroy(arr2);
+	return EFalse;
+	}
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemAccessPointL
+//
+//------------------------------------------------------------------------------
+//	
+TBool CAspProfileDialog::EditSettingItemAccessPointL(CAspListItemData& aItem)
+{
+
+	TBool ret;
+	TInt selection = 0;
+	TInt curSelection = aItem.iNumberData;
+	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
+	if(curSelection < 0)
+	{
+		curSelection = 0;
+	}
+	else
+	{
+		curSelection = 1;
+	}
+	ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	CleanupStack::PopAndDestroy(arr);
+	if(!ret)
+	{
+		return EFalse;
+	}
+	if (curSelection == 0 )
+		{
+		aItem.iNumberData = CAspAccessPointHandler::KDefaultConnection;
+		aItem.SetValueL(KNullDesC);
+		aItem.SetDisplayValueL(R_ASP_DEFAULT_CONNECTION);
+		selection = CAspAccessPointHandler::KDefaultConnection;
+		}	
+	if(selection == CAspAccessPointHandler::KDefaultConnection)
+	{
+	#ifdef RD_DSUI_TIMEDSYNC
+   	CAspSchedule* schedule = CAspSchedule::NewLC();
+	TInt profileId = schedule->ProfileId();
+	TInt enabled = schedule->IsAutoSyncEnabled();
+	CleanupStack::PopAndDestroy(schedule);
+	if(profileId == iProfile->ProfileId() && enabled)
+		{
+		TBool showQuery = ETrue;
+			RCmManager cmmgr;
+			cmmgr.OpenL();
+			TCmDefConnValue defConnValue;
+			cmmgr.ReadDefConnL(defConnValue);
+			cmmgr.Close();
+			if(defConnValue.iType == ECmDefConnDestination)
+			{
+				showQuery = EFalse;
+			}
+		if(showQuery)
+		{
+			HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_QUERY_IAP_NO_ASK_ALWAYS);
+    		if (!TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
+	 		{
+	  	  		CleanupStack::PopAndDestroy(hBuf);
+				return ETrue;// user selected "Always ask" option 
+    	}	
+			CleanupStack::PopAndDestroy(hBuf);
+		}
+		else
+		{
+			return ETrue;
+		}
+			
+		}
+		else
+		{
+			return ETrue;
+		}
+    	   	
+	#else
+		return ETrue;
+	#endif
+	}
+	TAspAccessPointItem item;
+	item.iUid2 = aItem.iNumberData;
+	
+	ret = iApHandler->ShowApSelectDialogL(item);
+	
+	if (ret == CAspAccessPointHandler::EAspDialogSelect)
+		{
+		aItem.iNumberData = item.iUid;
+		aItem.SetValueL(item.iName);
+		return ETrue;
+		}
+	else if (ret == CAspAccessPointHandler::EAspDialogExit)
+		{
+		ProcessCommandL(EAknCmdExit); // user has selected "Exit" from options menu
+		}
+	else
+		{
+		// user canceled ap selection
+		return EFalse;
+		}
+		
+	return EFalse;
+}
+
+//------------------------------------------------------------------------------
+// CAspProfileDialog::EditSettingItemBearerListL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileDialog::EditSettingItemBearerListL(CAspListItemData& aItem)
+	{
+	CDesCArray* arr = iBearerHandler->BuildBearerListLC();
+	if (arr->Count() == 0) 
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	TInt curSelection = iBearerHandler->ListIndexForBearer(aItem.iNumberData);
+	if (curSelection == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	if (TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection))
+		{
+		aItem.iNumberData = iBearerHandler->BearerForListIndex(curSelection);
+       	aItem.SetValueL((*arr)[curSelection]);
+		CleanupStack::PopAndDestroy(arr);
+		return ETrue;
+		}
+	
+	CleanupStack::PopAndDestroy(arr);
+	return EFalse;
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::EditSettingItemSyncContentL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileDialog::EditSettingItemSyncContentL(CAspListItemData& aItem)
+	{
+ 	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfile = iProfile;
+    param.iDataProviderId = aItem.iNumberData;
+    param.iSyncTaskId = KErrNotFound;
+    param.iContentList = iContentList;
+
+    CAspContentDialog::ShowDialogL(param);
+     
+    return ETrue;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspProfileDialog::GetItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspProfileDialog::GetItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspProfileDialog::Item
+// 
+// Find item with aItemId (TAspConnectionSettingItem).
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspProfileDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::ListBox
+// 
+// -----------------------------------------------------------------------------
+//
+CAknSettingStyleListBox* CAspProfileDialog::ListBox()
+	{
+	return iSettingListBox;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::UpdateCbaL(TInt aResourceId)
+	{
+	CEikButtonGroupContainer& cba = ButtonGroupContainer();
+	cba.SetCommandSetL(aResourceId);
+	iCommandSetId = aResourceId;
+	iMSKEmpty = EFalse;
+	cba.DrawDeferred();
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::UpdateMenuL
+// 
+// -----------------------------------------------------------------------------
+//
+
+void CAspProfileDialog::UpdateMenuL(TInt aResource)
+	{
+	CEikMenuBar* menuBar = iMenuBar; // from CAknDialog
+	menuBar->SetMenuTitleResourceId(aResource);
+
+	TRAPD(err, menuBar->TryDisplayMenuBarL());
+    		
+	User::LeaveIfError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfileDialog::CheckAutoSyncSetttigsL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileDialog::CheckAutoSyncSetttigsL()
+	{
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	TInt profileId = schedule->ProfileId();
+	if (profileId == iProfile->ProfileId())
+			{
+			if (iProfile->BearerType() != EAspBearerInternet)
+				{
+				schedule->SetProfileId(KErrNotFound);
+				schedule->SetSyncPeakSchedule(CAspSchedule::EIntervalManual);
+				schedule->SetSyncOffPeakSchedule(CAspSchedule::EIntervalManual);
+				schedule->SetSyncFrequency(CAspSchedule::EIntervalManual);
+				schedule->UpdateSyncScheduleL();
+				schedule->SaveL();
+				}
+			else
+				{
+				schedule->UpdateProfileSettingsL();
+				}
+			}
+	CleanupStack::PopAndDestroy(schedule);	
+	}
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfileSelectionDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,608 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspProfileSelectionDialog.h"
+#include "AspSchedule.h"
+#include "AspProfileWizard.h"
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <AspSyncUtil.mbg>  // for bitmap enumerations
+#include <Avkon.mbg>
+#include <akniconarray.h>   // for GulArray
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspProfileSelectionDialog::ShowDialogL(TAspParam& aParam)
+	{
+	CAspProfileSelectionDialog* dialog = CAspProfileSelectionDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_AUTO_SYNC_PROFILE_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspProfileSelectionDialog* CAspProfileSelectionDialog::NewL(TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfileSelectionDialog::NewL START") );
+
+    CAspProfileSelectionDialog* self = new (ELeave) CAspProfileSelectionDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProfileSelectionDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::CAspProfileSelectionDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspProfileSelectionDialog::CAspProfileSelectionDialog(TAspParam& aParam)
+	{
+    iSyncSession = aParam.iSyncSession;
+    iApplicationId = aParam.iApplicationId;
+    iProfileId = aParam.iProfileId;
+    iDialogParam = &aParam;
+           
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::ConstructL()
+    {
+    FLOG( _L("CAspProfileSelectionDialog::ConstructL START") );
+	
+	CAknDialog::ConstructL(R_ASP_AUTO_SYNC_PROFILE_DIALOG_MENU);
+
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspProfileList* list = CAspProfileList::NewLC(param);
+	list->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+		
+    TAspFilterInfo info;
+    info.iFilterType = TAspFilterInfo::EIncludeRemoteProfile;
+    iProfileList = list->FilteredListL(info);
+    iProfileList->Sort();
+    CleanupStack::PopAndDestroy(list);
+	
+    param.iMode = CAspContentList::EInitDataProviders;
+	iContentList = CAspContentList::NewL(param);
+
+
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	iCommandSetId = R_ASP_CBA_OPTIONS_SELECT_BACK;
+	
+	FLOG( _L("CAspProfileSelectionDialog::ConstructL END") );
+    }
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspProfileSelectionDialog::~CAspProfileSelectionDialog()
+    {
+    FLOG( _L("CAspProfileSelectionDialog::~CAspProfileSelectionDialog START") );
+
+    delete iProfileList;
+    delete iContentList;
+	delete iStatusPaneHandler;
+	
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	FLOG( _L("CAspProfileSelectionDialog::~CAspProfileSelectionDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileSelectionDialog::ActivateL
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	//aContext.iContext = KDS_HLP_SET_CONN_SETTINGS;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::HandleListBoxEventL
+// 
+// -----------------------------------------------------------------------------
+void CAspProfileSelectionDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                             TListBoxEvent /*aEventType*/)
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::PreLayoutDynInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::PreLayoutDynInitL()
+    {
+    iListBox = (CAknSingleGraphicStyleListBox*) (ControlOrNull(EAspAutoSyncProfileDialogList));
+    
+   	__ASSERT_ALWAYS(iListBox, TUtil::Panic(KErrGeneral));
+    
+	iListBox->SetListBoxObserver(this);
+	iListBox->CreateScrollBarFrameL(ETrue);
+	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	
+    
+    TInt index = iProfileList->ListIndex(iProfileId);
+    if (index == KErrNotFound)
+    	{
+    	// select first profile
+    	if (iProfileList->Count() > 0)
+    		{
+   	    	TAspProfileItem& item = iProfileList->Item(0);
+   	    	iProfileId = item.iProfileId;	
+    		}
+    	}
+
+    UpdateListBoxL();
+    
+
+	iStatusPaneHandler->SetTitleL(R_ASP_TITLE_AUTOMATIC_SYNC_PROFILE_SELECTION);
+	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::SetIconsL()
+    {
+    if (!iListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+		
+	
+	icons->AppendL(IconL(KAknsIIDQgnPropCheckboxOff, bitmapName,
+	                     EMbmAvkonQgn_prop_checkbox_off,
+	                     EMbmAvkonQgn_prop_checkbox_off_mask));
+
+	/*
+	icons->AppendL(IconL(KAknsIIDQgnIndiMarkedAdd, bitmapName, 
+	                     EMbmAvkonQgn_indi_marked_add,
+	                     EMbmAvkonQgn_indi_marked_add_mask));
+	*/
+
+	icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName, 
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->ColumnData()->IconArray();
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspProfileSelectionDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileSelectionDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane)
+	{
+    if (aResourceID != R_ASP_AUTO_SYNC_PROFILE_DIALOG_MENU_PANE)
+		{
+		return;
+		}
+		
+	TInt index = iListBox->CurrentItemIndex();
+	if (index != KErrNotFound)
+		{
+	    TAspProfileItem& item = iProfileList->Item(index);
+	
+	    if (iProfileId == item.iProfileId)
+		    {
+		    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSelect);
+		    }
+		}
+	else
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSelect);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdView);
+		}
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileSelectionDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAspMenuCmdHelp:
+			{
+            break;
+			}
+
+		case EAspMenuCmdSelect:
+			{
+			HandleOKL();
+			break;
+			}
+
+		case EAspMenuCmdView:
+			{
+			ShowContentListL();			
+			break;
+			}
+
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:			
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileSelectionDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileSelectionDialog::OkToExitL(TInt aButtonId)
+	{
+	(*iDialogParam).iReturnValue = EFalse;
+	(*iDialogParam).iProfileId = iProfileId;
+	
+	if (aButtonId == EEikBidCancel)
+		{
+		return ETrue;
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+       	(*iDialogParam).iReturnValue = ETrue;
+		return ETrue;
+		}
+
+	if (aButtonId == EAknSoftkeyOpen)  // MSK
+        {
+        HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspProfileSelectionDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,
+                                                      TEventCode aType)
+	{
+	
+	// catch listbox item "gain focus" here
+	if (aType == EEventKeyUp)
+		{
+		UpdateCbaL();
+		return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+		}
+		
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEnter:
+			case EKeyOK:
+				{
+     			HandleOKL();
+				return EKeyWasConsumed;
+				}
+
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+            default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileSelectionDialog::HandleOKL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::HandleOKL()
+	{
+	if (iCommandSetId == R_ASP_CBA_OPTIONS_VIEW_CONTENT_BACK)
+		{
+		ShowContentListL();
+		return;
+		}
+		
+	TInt index = iListBox->CurrentItemIndex();
+	if (index != KErrNotFound)
+		{
+	    TAspProfileItem& item = iProfileList->Item(index);
+	
+	    if (item.iProfileId != iProfileId)
+		    {
+		    iProfileId = item.iProfileId; // uselect
+		    UpdateListBoxL();
+		    }
+		}
+	
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::UpdateListBoxL()
+	{
+	_LIT(KFormat, "%d\t%S");
+		
+	CDesCArray* arr = (CDesCArray*) iListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = iProfileList->Count();
+	for (TInt i=0; i<count; i++ )
+		{
+		TAspProfileItem& item = iProfileList->Item(i);
+
+		TBuf<KBufSize> buf;
+		
+		if (item.iProfileId == iProfileId)
+			{
+			buf.Format(KFormat, 1, &item.iProfileName);
+			}
+		else
+			{
+			buf.Format(KFormat, 0, &item.iProfileName);
+			}
+
+		arr->AppendL(buf);
+		}
+
+	iListBox->HandleItemAdditionL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::UpdateCbaL()
+    {
+   	TInt index = iListBox->CurrentItemIndex();
+   	if (index == KErrNotFound)
+   		{
+   		return;	
+   		}
+   		
+	TAspProfileItem& item = iProfileList->Item(index);
+	CEikButtonGroupContainer& cba = ButtonGroupContainer();
+	
+	if (item.iProfileId == iProfileId)
+		{
+		if (iCommandSetId != R_ASP_CBA_OPTIONS_VIEW_CONTENT_BACK)
+			{
+	        cba.SetCommandSetL(R_ASP_CBA_OPTIONS_VIEW_CONTENT_BACK);
+	        cba.DrawDeferred();
+	        iCommandSetId = R_ASP_CBA_OPTIONS_VIEW_CONTENT_BACK;
+			}
+		}
+    else 
+    	{
+    	if (iCommandSetId != R_ASP_CBA_OPTIONS_SELECT_BACK)
+    		{
+    	    cba.SetCommandSetL(R_ASP_CBA_OPTIONS_SELECT_BACK);
+    	    cba.DrawDeferred();
+    	    iCommandSetId = R_ASP_CBA_OPTIONS_SELECT_BACK;		
+    		}
+    	}
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileSelectionDialog::ShowContentListL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileSelectionDialog::ShowContentListL()
+	{
+	TInt index = iListBox->CurrentItemIndex();
+	if (index == KErrNotFound)
+		{
+		return;	
+		}
+		
+	TAspProfileItem& item = iProfileList->Item(index);
+	
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    
+   	profile->OpenL(item.iProfileId, CAspProfile::EOpenRead,
+                                          CAspProfileList::EBasePropertiesOnly);
+    iContentList->SetProfile(profile);
+    TRAPD(err, iContentList->InitAllTasksL());
+    iContentList->SetProfile(NULL);
+    User::LeaveIfError(err);
+    CleanupStack::PopAndDestroy(profile);
+                                          
+
+	CDesCArray* arr = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	CleanupStack::PushL(arr);
+	
+    TInt count = iContentList->ProviderCount();
+    for (TInt i=0; i<count; i++)
+    	{
+    	TAspProviderItem& item = iContentList->ProviderItem(i);
+    	
+    	TInt index = iContentList->FindTaskIndexForProvider(item.iDataProviderId);
+    	if (index != KErrNotFound)
+    		{
+    		HBufC* hBuf = CAspResHandler::GetContentNameLC(item.iDataProviderId,
+		                                               item.iDisplayName);
+		    arr->AppendL(hBuf->Des());
+		    CleanupStack::PopAndDestroy(hBuf);
+    		}
+    	}
+
+	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_TITLE_AUTOMATIC_SYNC_CONTENT_LIST);
+	
+	TDialogUtil::ShowPopupDialogL(hBuf->Des(), arr);
+	
+	CleanupStack::PopAndDestroy(hBuf);
+	CleanupStack::PopAndDestroy(arr);
+	}
+	
+	
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfileWizard.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1310 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspProfileWizard.h"
+#include "AspUtil.h"
+#include "AspDebug.h"
+#include "AspSyncUtil.rh"
+
+
+#include <textresolver.h>
+#include <applayout.cdl.h>      // Multiline_Message_writing_texts_Line_3
+#include <aknlayoutscalable_apps.cdl.h>
+
+				 
+
+
+
+/*******************************************************************************
+ * class CAspWizardItem
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAspWizardItem* CAspWizardItem::NewL()
+    {
+    CAspWizardItem* self = new (ELeave) CAspWizardItem();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspWizardItem::~CAspWizardItem()
+    {
+    if (iValue)
+		{
+		delete iValue;
+		iValue = NULL ;
+		}
+    delete iContentName;
+    delete iHeader;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::CAspWizardItem
+//
+// -----------------------------------------------------------------------------
+//
+CAspWizardItem::CAspWizardItem()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::ConstructL()
+    {
+	InitL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::SetValueL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::SetValueL(const TDesC& aText)
+	{
+	if (iValue)
+		{
+		delete iValue;
+		iValue = NULL;
+		}
+	iValue = aText.AllocL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::Value
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspWizardItem::Value()
+	{
+	__ASSERT_ALWAYS(iValue, TUtil::Panic(KErrGeneral));
+		
+	return *iValue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::SetContentNameL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::SetContentNameL(const TDesC& aText)
+	{
+	delete iContentName;
+	iContentName = NULL;
+	iContentName = aText.AllocL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::ContentName
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspWizardItem::ContentName()
+	{
+	__ASSERT_ALWAYS(iContentName, TUtil::Panic(KErrGeneral));
+		
+	return *iContentName;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::SetHeaderL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::SetHeaderL(const TDesC& aText)
+	{
+	delete iHeader;
+	iHeader = NULL;
+	iHeader = aText.AllocL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::SetHeaderL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::SetHeaderL(TInt aResourceId)
+	{
+	delete iHeader;
+	iHeader = NULL;
+	iHeader = CAspResHandler::ReadL(aResourceId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::Header
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspWizardItem::Header()
+	{
+	__ASSERT_ALWAYS(iHeader, TUtil::Panic(KErrGeneral));
+		
+	return *iHeader;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspWizardItem::InitL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspWizardItem::InitL()
+	{
+	iSettingType = KErrNotFound;
+	iSettingId = KErrNotFound;
+	iResourceId = KErrNotFound;
+	iPopupNoteResourceId = KErrNotFound;
+	iErrorNoteResourceId = KErrNotFound;
+	iEnabled = ETrue;
+	iMaxLength = 0;
+	iMandatory = ETrue;
+	iLatinInput = ETrue;  // accept only western chars
+	iNumber = 0;
+	SetValueL(KNullDesC);
+	SetContentNameL(KNullDesC);
+	SetHeaderL(KNullDesC);
+    }
+
+
+	
+	
+
+/*******************************************************************************
+ * class CAspProfileWizard
+ *******************************************************************************/
+
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::NewL
+//
+// -----------------------------------------------------------------------------
+CAspProfileWizard* CAspProfileWizard::NewL(TAspParam& aParam)
+    {
+    CAspProfileWizard* self = new (ELeave) CAspProfileWizard(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::CAspProfileWizard
+// 
+// -----------------------------------------------------------------------------
+//
+CAspProfileWizard::CAspProfileWizard(TAspParam& aParam)
+	{
+	iApplicationId = aParam.iApplicationId;
+	iSyncSession = aParam.iSyncSession;
+	
+	iDialogParam = &aParam;
+	iProfileId = KErrNotFound;
+	iCurrentItemIndex = 0;
+
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrArgument));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizard::ConstructL()
+    {
+    TAspParam param(iApplicationId, iSyncSession);
+	param.iMode = CAspContentList::EInitDataProviders;
+	iContentList = CAspContentList::NewL(param);
+
+   	// get email syncml mailboxes
+   	iLocalDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	iContentList->GetLocalDatabaseList(KUidNSmlAdapterEMail.iUid, iLocalDataStores);
+
+    CreateSettingListL();
+
+    SetContentEnabled(iApplicationId);
+
+   	if (iLocalDataStores->Count() == 0)
+   		{
+   		SetContentEnabled(KUidNSmlAdapterEMail.iUid, EFalse);
+   		}
+   	TBool emailEnabled = ContentEnabled(KUidNSmlAdapterEMail.iUid);
+	SetContentLocalDatabaseEnabled(KUidNSmlAdapterEMail.iUid, emailEnabled);
+	
+	if (iApplicationId == EApplicationIdEmail)
+		{
+		SetEnabled(CAspWizardItem::ETypeProtocolVersion, EFalse);
+		}
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspProfileWizard::~CAspProfileWizard()
+    {
+    delete iLocalDataStores;
+    
+    iSettingList.ResetAndDestroy();
+    iSettingList.Close();
+    
+    delete iContentList;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::CreateSettingListL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizard::CreateSettingListL()
+    {
+    TInt localDbCount = iLocalDataStores->Count();
+    
+	CAspWizardItem* item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeStart;
+	item->iResourceId = R_ASP_SET_WIZARD_START;
+	item->SetHeaderL(item->iResourceId);
+	item->iEnabled = ETrue; // start must always be enabled
+	iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeProfileName;
+	item->iResourceId = R_ASP_SET_DESTINATION_NAME;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_PROFILE_NAME;
+	item->iErrorNoteResourceId = R_ASP_NOTE_PROFILE_NAME_MISSING;
+	item->SetHeaderL(item->iResourceId);
+	item->iMaxLength = KAspMaxProfileNameLength;
+	item->iLatinInput = EFalse; // accept also non-western chars
+	iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeProtocolVersion;
+	item->iResourceId = R_ASP_SET_PROTOCOL_VERSION;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_PROTOCOL_VERSION;
+	item->SetHeaderL(item->iResourceId);
+	iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeContentSelection;
+	item->iResourceId = R_ASP_SET_CONTENT_SELECTION;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_CONTENT_SELECTION;
+	item->SetHeaderL(item->iResourceId);
+    iSettingList.Append(item);
+
+    TInt count = iContentList->ProviderCount();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& p = iContentList->ProviderItem(i);
+	
+	    //if (p.iDataProviderId == KUidNSmlAdapterEMail.iUid && localDbCount == 0)
+	    //	{
+	    //	continue; // leave email out - no email SyncML mailboxes found
+	    //	}
+	    
+	    item = CAspWizardItem::NewL();
+	    item->iSettingType = CAspWizardItem::ETypeSyncContent;
+	    item->iSettingId = p.iDataProviderId;
+	    item->iResourceId = 
+	          CAspResHandler::RemoteDatabaseHeaderId(p.iDataProviderId);
+	    item->iPopupNoteResourceId = 
+	          ContentPopupNoteResourceId(p.iDataProviderId);
+	    
+	    if (p.iDataProviderId == KUidNSmlAdapterContact.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_CONTACTS_DB_MISSING;
+            }
+        else if (p.iDataProviderId == KUidNSmlAdapterCalendar.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_CALENDAR_DB_MISSING;
+            }
+        else if (p.iDataProviderId == KUidNSmlAdapterSms.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_SMS_DATABASE_MISSING;
+            }
+        else if (p.iDataProviderId == KUidNSmlAdapterMMS.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_MMS_DATABASE_MISSING;
+            }
+        else if (p.iDataProviderId == KUidNSmlAdapterNote.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_NOTES_DB_MISSING;
+            }
+        else if (p.iDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_BKM_DATABASE_MISSING;
+            }
+        else
+            {
+            item->iErrorNoteResourceId = R_ASP_NOTE_REMOTE_DATABASE_MISSING;
+            }
+	    item->SetHeaderL(item->iResourceId);
+	    item->iMaxLength = KAspMaxRemoteNameLength;
+	    
+	    HBufC* hBuf = CAspResHandler::GetContentNameLC(p.iDataProviderId, p.iDisplayName);
+	    item->SetContentNameL(hBuf->Des());
+        CleanupStack::PopAndDestroy(hBuf);
+	    
+        iSettingList.Append(item);
+        
+        if (p.iDataProviderId == KUidNSmlAdapterEMail.iUid && localDbCount > 1)
+        	{
+	        item = CAspWizardItem::NewL();
+	        item->iSettingType = CAspWizardItem::ETypeSyncContentLocalDatabase;
+	        item->iSettingId = p.iDataProviderId;
+	        item->iResourceId = R_ASP_LOCAL_DATABASE_EML;
+	        item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_EMAIL_LOCAL_DB;
+	        item->SetHeaderL(item->iResourceId);
+    
+            iSettingList.Append(item);
+        	}
+		}
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeBearerType;
+	item->iResourceId = R_ASP_SET_BEARER_TYPE;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_CONNECTION_TYPE;
+	item->SetHeaderL(item->iResourceId);
+    iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeHostAddress;
+	item->iResourceId = R_ASP_SET_HOST_ADDRESS;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_HOST_ADDRESS;
+	item->iErrorNoteResourceId = R_ASP_NOTE_HOST_ADDRESS_MISSING;
+	item->SetHeaderL(item->iResourceId);
+	item->iMaxLength = KAspMaxURILength;
+    iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeServerId;
+	item->iResourceId = R_ASP_SET_SERVER_ID;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_SERVER_ID;
+	item->iErrorNoteResourceId = KErrNotFound;
+	item->SetHeaderL(item->iResourceId);
+	item->iMaxLength = KAspMaxServerIdLength;
+    iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeUserName;
+	item->iResourceId = R_ASP_SET_USERNAME;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_USERNAME;
+	item->iErrorNoteResourceId = R_ASP_NOTE_USERNAME_MISSING;
+	item->SetHeaderL(item->iResourceId);
+	item->iMaxLength = KAspMaxUsernameLength;
+    iSettingList.Append(item);
+
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypePassword;
+	item->iResourceId = R_ASP_SET_PASSWORD;
+	item->iPopupNoteResourceId = R_ASP_WIZARD_POPUP_PASSWORD;
+	item->iErrorNoteResourceId = R_ASP_NOTE_PASSWORD_MISSING;
+	item->SetHeaderL(item->iResourceId);
+	item->iMaxLength = KAspMaxPasswordLength;
+    iSettingList.Append(item);
+    
+	item = CAspWizardItem::NewL();
+	item->iSettingType = CAspWizardItem::ETypeEnd;
+	item->iResourceId = R_ASP_SET_WIZARD_END;
+	item->SetHeaderL(item->iResourceId);
+	item->iEnabled = ETrue; // end must always be enabled
+	iSettingList.Append(item);
+    } 
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::ContentPopupNoteResourceId
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::ContentPopupNoteResourceId(TInt aDataProviderId)
+	{
+	TInt ret = R_ASP_WIZARD_POPUP_REMOTE_DB;
+	
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		ret = R_ASP_WIZARD_POPUP_CONTACTS_DB;
+		}
+	if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		ret = R_ASP_WIZARD_POPUP_CALENDAR_DB;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		ret = R_ASP_WIZARD_POPUP_EMAIL_DB;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+    	ret = R_ASP_WIZARD_POPUP_NOTES_DB;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+    	ret = R_ASP_WIZARD_POPUP_SMS_DB;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+    	ret = R_ASP_WIZARD_POPUP_MMS_DB;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+    	ret = R_ASP_WIZARD_POPUP_BKM_DB;
+		}
+    
+
+    return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetContentSelectionL
+// 
+// Construct CSelectionItemList from setting list.
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetContentSelectionL(CSelectionItemList* aList)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+	        TBuf<KBufSize> buf(item->ContentName());
+	        CSelectableItem* selectableItem = new (ELeave) CSelectableItem(
+	                                          buf, item->iEnabled);
+   	        CleanupStack::PushL(selectableItem);
+	        selectableItem->ConstructL();
+	        aList->AppendL(selectableItem);
+	        CleanupStack::Pop(selectableItem);
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentSelectionL
+// 
+// Update setting list from CSelectionItemList.
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentSelectionL(CSelectionItemList* aList)
+	{
+	TInt count = aList->Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* selectableItem = (*aList)[i];
+		TBool selected = selectableItem->SelectionStatus();
+		SetContentEnabled(selectableItem->ItemText(), selected);
+		}
+		
+	TBool emailEnabled = ContentEnabled(KUidNSmlAdapterEMail.iUid);
+	SetContentLocalDatabaseEnabled(KUidNSmlAdapterEMail.iUid, emailEnabled);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentEnabled(const TDesC& aText, TBool aEnabled)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+	        TPtrC ptr = item->ContentName();
+	        if (ptr.Compare(aText) == 0)
+	        	{
+	        	item->iEnabled = aEnabled;
+	        	break;
+	        	}
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::ContentId
+// 
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::ContentId(const TDesC& aText)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+	        TPtrC ptr = item->ContentName();
+	        if (ptr.Compare(aText) == 0)
+	        	{
+	        	return item->iSettingId;
+	        	}
+			}
+		}
+		
+	return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentEnabled(TInt aApplicationId)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType != CAspWizardItem::ETypeSyncContent)
+			{
+			continue;
+			}
+		
+		if (aApplicationId == EApplicationIdSync)
+			{
+			item->iEnabled = ETrue; // sync app enables all contents
+			}
+		else
+			{
+			TInt appId = TUtil::AppIdFromProviderId(item->iSettingId);
+		    if (appId == aApplicationId)
+			    {
+			    item->iEnabled = ETrue;
+			    }
+		    else
+			    {
+			    item->iEnabled = EFalse;
+			    }
+			}
+		}
+		
+	if (aApplicationId != EApplicationIdSync)
+		{
+		// only sync app shows content selection page
+		SetEnabled(CAspWizardItem::ETypeContentSelection, EFalse);
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentLocalDatabaseEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentLocalDatabaseEnabled(TInt aDataproviderId, TBool aEnabled)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContentLocalDatabase)
+			{
+			if (item->iSettingId == aDataproviderId)
+			    {
+			    item->iEnabled = aEnabled;
+			    }
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentEnabled(TInt aDataproviderId, TBool aEnabled)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iSettingId == aDataproviderId)
+			    {
+			    item->iEnabled = aEnabled;
+			    }
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::ContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileWizard::ContentEnabled(TInt aDataproviderId)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iSettingId == aDataproviderId)
+			    {
+			    return item->iEnabled;
+			    }
+			}
+		}
+		
+	return EFalse;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetContentEnabled(RArray<TInt>& aDataProviderArray)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			item->iEnabled = EFalse;
+			if (aDataProviderArray.Find(item->iSettingId) != KErrNotFound)
+				{
+				item->iEnabled = ETrue;
+				}
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetContentEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetContentEnabled(RArray<TInt>& aDataProviderArray)
+	{
+	aDataProviderArray.Reset();
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iEnabled)
+				{
+				aDataProviderArray.Append(item->iSettingId);
+				}
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetContentName
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetContentName(TDes& aText)
+	{
+	aText = KNullDesC;
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iEnabled)
+				{
+				aText = item->ContentName();
+				}
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetEnabled
+// 
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetEnabled(TInt aSettingType, TBool aEnabled)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType)
+			{
+        	item->iEnabled = aEnabled;
+        	break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::DeleteProfile
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::DeleteProfile()
+	{
+	FLOG( _L("CAspProfileWizard::DeleteProfile START") );
+	
+	if (iProfileId != KErrNotFound)
+		{
+		TRAPD(err, iSyncSession->DeleteProfileL(iProfileId));
+		iProfileId = KErrNotFound;
+		
+		if (err != KErrNone)
+			{
+			FLOG( _L("### RSyncMLSession::DeleteProfileL failed (%d) ###"), err );
+			}
+		}
+		
+	FLOG( _L("CAspProfileWizard::DeleteProfile END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::CreateProfileL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::CreateProfileL()
+	{
+	FLOG( _L("CAspProfileWizard::CreateProfileL START") );
+	
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	
+	iProfileId = KErrNotFound;
+	profile->CreateL(CAspProfile::EAllProperties);
+	iProfileId = profile->ProfileId();
+	
+	CAspProfile::SetDefaultValuesL(profile);
+	
+	GetStringValue(iBuf, CAspWizardItem::ETypeProfileName);
+	profile->SetNameL(iBuf);
+    
+	TInt protocol = NumberValue(CAspWizardItem::ETypeProtocolVersion);
+	profile->SetProtocolVersionL(protocol);
+
+	TInt bearerType = NumberValue(CAspWizardItem::ETypeBearerType);
+	profile->SetBearerTypeL(bearerType);
+	
+	GetStringValue(iBuf, CAspWizardItem::ETypeHostAddress);
+	TURIParser parser(iBuf);
+	TInt portNumber = parser.Port();
+	if (!parser.IsValidPort(portNumber))
+		{
+		portNumber = parser.DefaultPort();
+		}
+    profile->SetHostAddressL(iBuf, portNumber);
+    
+    GetStringValue(iBuf, CAspWizardItem::ETypeServerId);
+    profile->SetServerIdL(iBuf);
+	
+	GetStringValue(iBuf, CAspWizardItem::ETypeUserName);
+	profile->SetUserNameL(iBuf);
+	
+	GetStringValue(iBuf, CAspWizardItem::ETypePassword);
+	profile->SetPasswordL(iBuf);
+	
+	profile->SaveL();
+	iContentList->SetProfile(profile);
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iEnabled)
+				{
+				TBuf<KBufSize> localDb;
+				GetStringValue(iBuf, CAspWizardItem::ETypeSyncContent,
+				               item->iSettingId);
+				
+				GetStringValue(localDb, CAspWizardItem::ETypeSyncContentLocalDatabase,
+				               item->iSettingId);
+				               
+				iContentList->CreateTask(item->iSettingId,
+				              localDb, iBuf, ETrue, ESyncDirectionTwoWay);
+				}
+			}
+		}
+	
+	iContentList->SetProfile(NULL);
+	CleanupStack::PopAndDestroy(profile);
+	
+	FLOG( _L("CAspProfileWizard::CreateProfileL END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetStringValueL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetStringValueL(const TDesC& aValue,
+                                        TInt aSettingType, TInt aSettingId)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType && item->iSettingId == aSettingId)
+			{
+			item->SetValueL(aValue);
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetStringValueL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetStringValueL(const TDesC& aValue, TInt aSettingType)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType)
+			{
+			item->SetValueL(aValue);
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetStringValue
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetStringValue(TDes& aValue, TInt aSettingType)
+	{
+	aValue = KNullDesC;
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType)
+			{
+			TUtil::StrCopy(aValue, item->Value());
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetStringValue
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetStringValue(TDes& aValue, TInt aSettingType, TInt aSettingId)
+	{
+	aValue = KNullDesC;
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType && item->iSettingId == aSettingId)
+			{
+			TUtil::StrCopy(aValue, item->Value());
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::GetNumberValue
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::GetNumberValue(TInt& aValue, TInt aSettingType)
+	{
+	aValue = KErrNotFound;
+	
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType)
+			{
+			aValue = item->iNumber;
+			break;
+			}
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::NumberValue
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::NumberValue(TInt aSettingType)
+	{
+	TInt num = KErrNotFound;
+	GetNumberValue(num, aSettingType);
+	return num;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::SetNumberValue
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::SetNumberValue(TInt& aValue, TInt aSettingType)
+	{
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == aSettingType)
+			{
+			item->iNumber = aValue;
+			break;
+			}
+		}
+	}
+	
+	
+//------------------------------------------------------------------------------
+// CAspProfileWizard::NumOfEnabledContentItems
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::NumOfEnabledContentItems()
+	{
+	TInt total = 0;
+
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			if (item->iEnabled)
+				{
+				total++;
+				}
+			}
+		}
+		
+	return total;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::NumOfContentItems
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::NumOfContentItems()
+	{
+	TInt total = 0;
+
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iSettingType == CAspWizardItem::ETypeSyncContent)
+			{
+			total++;
+			}
+		}
+		
+	return total;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::NumOfEnabledItems
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::NumOfEnabledItems()
+	{
+	TInt total = 0;
+
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		if (item->iEnabled)
+			{
+			total++;
+			}
+		}
+		
+	return total;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::NumOfCurrentItem
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::NumOfCurrentItem(CAspWizardItem* aItem)
+	{
+	// find position of aItem in the list of all enabled items
+	TInt current = 0;
+
+	TInt count = iSettingList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspWizardItem* item = iSettingList[i];
+		
+		if (!item->iEnabled)
+			{
+			continue;
+			}
+		
+		current++;
+				
+		if (item->iSettingType == aItem->iSettingType)
+			{
+			if (item->iSettingType != CAspWizardItem::ETypeSyncContent)
+				{
+				break;
+				}
+				
+		    if (item->iSettingId == aItem->iSettingId)
+		    	{
+		    	break;
+		    	}
+			}
+		}
+		
+	return current;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::CurrentItem
+//
+//------------------------------------------------------------------------------
+//
+CAspWizardItem* CAspProfileWizard::CurrentItem()
+	{
+	TInt count = iSettingList.Count();
+	
+	__ASSERT_ALWAYS(iCurrentItemIndex >= 0, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iCurrentItemIndex < count, TUtil::Panic(KErrGeneral));
+	
+	return iSettingList[iCurrentItemIndex];
+	}
+	
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::CurrentItemType
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::CurrentItemType()
+	{
+	CAspWizardItem* item = CurrentItem();
+	
+	return  item->iSettingType;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::CreatedProfileId
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::CreatedProfileId()
+	{
+	return iProfileId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::MoveToNext
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::MoveToNext()
+	{
+	iCurrentItemIndex = IncreaseCurrentIndex(iCurrentItemIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::MoveToPrevious
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::MoveToPrevious()
+	{
+	iCurrentItemIndex = DecreaseCurrentIndex(iCurrentItemIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizard::MoveToStart
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizard::MoveToStart()
+	{
+	iCurrentItemIndex = 0;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::IncreaseCurrentIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::IncreaseCurrentIndex(const TInt aIndex)
+	{
+	TInt maxIndex = iSettingList.Count() - 1;
+	TInt index = aIndex;
+	
+	for (;;)
+		{
+		__ASSERT_DEBUG(index < maxIndex, TUtil::Panic(KErrGeneral));
+
+		if (!(index < maxIndex))
+			{
+			return maxIndex;
+			}
+				
+		index++;
+				
+	    CAspWizardItem* item = iSettingList[index];
+	    if (item->iEnabled)
+	    	{
+	    	break;
+	    	}
+		}
+		
+	return index;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::DecreaseCurrentIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileWizard::DecreaseCurrentIndex(const TInt aIndex)
+	{
+	TInt index = aIndex;
+	
+	for (;;)
+		{
+		__ASSERT_DEBUG(index > 0, TUtil::Panic(KErrGeneral));
+		
+		if (!(index > 0))
+			{
+			return 0;
+			}
+			
+		index--;
+		
+	    CAspWizardItem* item = iSettingList[index];
+	    if (item->iEnabled)
+	    	{
+	    	break;
+	    	}
+		}
+		
+	return index;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizard::LocalDatabaseList
+//
+// -----------------------------------------------------------------------------
+//
+CDesCArray* CAspProfileWizard::LocalDatabaseList(const TInt aDataproviderId)
+	{
+	__ASSERT_DEBUG(aDataproviderId == KUidNSmlAdapterEMail.iUid, 
+	               TUtil::Panic(KErrGeneral));
+	
+	return iLocalDataStores;
+	}
+	
+
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfileWizardDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1811 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+#include <txtfrmat.h>
+#include <txtfmlyr.h>
+#include <gdi.h>
+// BackGround Context
+#include <AknsBasicBackgroundControlContext.h>
+
+#include "AspProfileWizardDialog.h"
+#include "AspUtil.h"
+#include "AspDialogUtil.h"
+#include "AspDebug.h"
+#include "AspSyncUtil.rh"
+
+#include <textresolver.h>
+#include <eikrted.h>  // CEikRichTextEditor
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+/*******************************************************************************
+ * class CAspTextSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspTextSettingPage::CAspTextSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspTextSettingPage::CAspTextSettingPage(TInt aResourceID, TDes& aText,
+                     TInt aTextSettingPageFlags, TAspSettingPageParam& aParam)
+ : CAknTextSettingPage(aResourceID, aText, aTextSettingPageFlags), iParam(aParam)
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspTextSettingPage::~CAspTextSettingPage()
+	{
+	delete iIndicatorHandler;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspTextSettingPage::OKToExitL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspTextSettingPage::OkToExitL(TInt aButtonId)
+	{
+	 // command id set in ProcessCommandL
+	if (iParam.iCommandId == EAknSoftkeyOk || iParam.iCommandId == EEikBidSelect)
+		{
+		if (iParam.iObserver)
+			{
+			CEikEdwin* edwin = TextControl();
+			HBufC* hBuf = NULL;
+			TInt len = edwin->TextLength();
+			if (len == 0)
+				{
+				hBuf = HBufC::NewL(0);
+				}
+			else
+				{
+				hBuf = edwin->GetTextInHBufL();
+				}
+				
+			TBool ret = iParam.iObserver->CheckValidity(hBuf->Des(),
+			                                            iParam.iSettingType);
+			
+			delete hBuf;
+			return ret;
+			}
+		}
+
+	return  CAknTextSettingPage::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspTextSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspTextSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+    iParam.iCommandId = aCommandId; // return command id to caller
+    
+    CAknTextSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CIMSSettingsWizardEditTextPage::PostDisplayCheckL
+//
+// ----------------------------------------------------------------------------
+//
+TBool CAspTextSettingPage::PostDisplayCheckL()
+    {
+    // Set the text to navipane
+    UpdateNaviPaneL();
+
+    return ETrue;
+    }
+    
+// ----------------------------------------------------------------------------
+// CIMSSettingsWizardEditTextPage::UpdateIndicatorL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspTextSettingPage::UpdateNaviPaneL()
+    {
+    if (!iIndicatorHandler)
+    	{
+    	iIndicatorHandler = new (ELeave) CAspIndicatorHandler(
+    	                                 iAvkonEnv->EditingStateIndicator());
+    	}
+    	
+    iIndicatorHandler->SetIndicatorStateL(
+              EAknNaviPaneEditorIndicatorMessageLength, iParam.iPageText);
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CAspTextSettingPage::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspTextSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+    if(EKeyEnter == aKeyEvent.iCode)
+    {
+    	ProcessCommandL(EAknSoftkeyOk);
+    	return EKeyWasConsumed;
+    }
+    if (aType == EEventKeyDown && iParam.iObserver)
+        {
+       	iParam.iObserver->HandleEditorEvent(
+       	                  MAspEditorPageObserver::EKeyEvent, 0);
+        }
+        
+    return CAknTextSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+
+
+/*******************************************************************************
+ * class CAspRadioButtonSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspRadioButtonSettingPage::CAspRadioButtonSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspRadioButtonSettingPage::CAspRadioButtonSettingPage(TInt aResourceID,
+                            TInt& aCurrentSelectionIndex,
+                            const MDesCArray* aItemArray,
+                            TAspSettingPageParam& aParam)
+                            
+ : CAknRadioButtonSettingPage(aResourceID, aCurrentSelectionIndex, aItemArray),
+   iParam(aParam)
+	{
+	iItemArray = aItemArray;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspRadioButtonSettingPage::~CAspRadioButtonSettingPage()
+	{
+	delete iNaviPaneHandler;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspRadioButtonSettingPage::ProcessCommandL
+//------------------------------------------------------------------------------
+//
+void CAspRadioButtonSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+    if (aCommandId == EAknSoftkeyOk || aCommandId == EEikBidSelect)
+    	{
+    	TInt index = ListBoxControl()->CurrentItemIndex();
+    	TBuf<KBufSize> buf;
+    	buf.Num(index);
+    	TBool ret = iParam.iObserver->CheckValidity(buf, iParam.iSettingType);
+    	}
+    
+    iParam.iCommandId = aCommandId; // return command id to caller
+    
+    CAknRadioButtonSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspRadioButtonSettingPage::PostDisplayCheckL
+// ----------------------------------------------------------------------------
+//
+TBool CAspRadioButtonSettingPage::PostDisplayCheckL()
+    {
+    UpdateNaviPaneL();
+
+    return ETrue;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspRadioButtonSettingPage::UpdateNaviPaneL
+// ----------------------------------------------------------------------------
+//
+void CAspRadioButtonSettingPage::UpdateNaviPaneL()
+    {
+    if (!iNaviPaneHandler)
+    	{
+    	iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
+    	                       iEikonEnv->AppUiFactory()->StatusPane());
+    	}
+    	
+    iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
+    }
+
+//----------------------------------------------------------------------------
+//CAspRadioButtonSettingPage::HandleListBoxEventL
+//----------------------------------------------------------------------------
+//
+
+
+void CAspRadioButtonSettingPage::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+{
+	if( AknLayoutUtils::PenEnabled() )
+	{
+	  	switch(aEventType)
+		{  
+			case EEventItemClicked:
+       			 this->ProcessCommandL(EAknSoftkeySelect);	
+        		 break;
+		  	default:
+				break;
+    		
+		}	
+	}
+}
+
+// ----------------------------------------------------------------------------
+// CAspRadioButtonSettingPage::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspRadioButtonSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+        if(EKeyEnter == aKeyEvent.iCode)
+    {
+    	ProcessCommandL(EAknSoftkeyOk);
+    	return EKeyWasConsumed;
+    }
+    if (aType == EEventKeyDown && iParam.iObserver)
+        {
+       	iParam.iObserver->HandleEditorEvent(
+                              MAspEditorPageObserver::EKeyEvent, 0);    
+        }
+        
+    return CAknRadioButtonSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+
+
+/*******************************************************************************
+ * class CAspAlphaPasswordSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPage::CAspAlphaPasswordSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspAlphaPasswordSettingPage::CAspAlphaPasswordSettingPage(TInt aResourceID,
+                              TDes& aNewPassword, const TDesC& aOldPassword,
+                              TAspSettingPageParam& aParam)
+                              
+ : CAknAlphaPasswordSettingPage(aResourceID, aNewPassword, aOldPassword),
+   iParam(aParam)
+	{
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspAlphaPasswordSettingPage::~CAspAlphaPasswordSettingPage()
+	{
+	delete iIndicatorHandler;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspAlphaPasswordSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+    iParam.iCommandId = aCommandId; // return command id to caller
+    
+    CAknAlphaPasswordSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPage::PostDisplayCheckL
+
+// ----------------------------------------------------------------------------
+//
+TBool CAspAlphaPasswordSettingPage::PostDisplayCheckL()
+    {
+    UpdateNaviPaneL();
+
+    return ETrue;
+    }
+
+// ----------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPage::UpdateNaviPaneL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspAlphaPasswordSettingPage::UpdateNaviPaneL()
+    {
+    if (!iIndicatorHandler)
+    	{
+    	iIndicatorHandler = new (ELeave) CAspIndicatorHandler(
+    	                                 iAvkonEnv->EditingStateIndicator());
+    	}
+    	
+    iIndicatorHandler->SetIndicatorStateL(
+              EAknNaviPaneEditorIndicatorMessageLength, iParam.iPageText);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspAlphaPasswordSettingPage::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspAlphaPasswordSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+    if (aType == EEventKeyDown && iParam.iObserver)
+        {
+       	iParam.iObserver->HandleEditorEvent(
+                                MAspEditorPageObserver::EKeyEvent, 0);    
+        }
+        
+    return CAknAlphaPasswordSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+
+/*******************************************************************************
+ * class CAspCheckBoxSettingPage
+ *******************************************************************************/
+
+
+//------------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::CAspCheckBoxSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAspCheckBoxSettingPage::CAspCheckBoxSettingPage(TInt aResourceID,
+                   CSelectionItemList* aItemArray, TAspSettingPageParam& aParam)
+                   
+ : CAknCheckBoxSettingPage(aResourceID, aItemArray), iParam(aParam)
+	{
+    iSelectionItemList = aItemArray;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAspCheckBoxSettingPage::~CAspCheckBoxSettingPage()
+	{
+	delete iNaviPaneHandler;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspCheckBoxSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+    if (aCommandId == EAknSoftkeyMark)
+    	{
+        CAknSetStyleListBox* listbox = ListBoxControl();
+        TInt index = listbox->CurrentItemIndex();
+       	CSelectableItem* selectableItem = (*iSelectionItemList)[index];
+       	TBuf<KBufSize> buf;
+       	buf = selectableItem->ItemText();
+       	
+       	TBool ret = iParam.iObserver->CheckValidity(buf, iParam.iSettingType);
+			
+       	if (ret)
+       	
+       		{
+            CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
+            return;
+       		}
+       	else
+       		{
+       		return;	
+       		}
+    	}
+    
+    	
+    iParam.iCommandId = aCommandId; // return command id to caller
+
+    CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::PostDisplayCheckL
+//
+// ----------------------------------------------------------------------------
+//
+TBool CAspCheckBoxSettingPage::PostDisplayCheckL()
+    {
+    UpdateNaviPaneL();
+    
+    iSelectionCount = ListBoxControl()->SelectionIndexes()->Count();
+
+    return ETrue;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::UpdateNaviPaneL
+// ----------------------------------------------------------------------------
+//
+void CAspCheckBoxSettingPage::UpdateNaviPaneL()
+    {
+    if (!iNaviPaneHandler)
+    	{
+    	iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
+    	                       iEikonEnv->AppUiFactory()->StatusPane());
+    	}
+    	
+    iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
+    }
+
+// ----------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::OfferKeyEventL
+//
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspCheckBoxSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+    if(EKeyEnter == aKeyEvent.iCode)
+    {
+    	ProcessCommandL(EAknSoftkeyMark);
+    	return EKeyWasConsumed;
+    }
+   
+    if (aType == EEventKeyDown && iParam.iObserver)
+        {
+       	iParam.iObserver->HandleEditorEvent(
+                              MAspEditorPageObserver::EKeyEvent, 0);    
+        }
+
+    if (aType == EEventKeyUp && iParam.iObserver)
+        {
+	    TInt count = ListBoxControl()->SelectionIndexes()->Count();
+       	if (count != iSelectionCount)
+       		{
+       		iParam.iObserver->GetNavipaneText(iParam.iPageText, count);
+       	    UpdateNaviPaneL();
+       	    iSelectionCount = count;
+       		}
+        }
+        
+    return CAknCheckBoxSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+// ----------------------------------------------------------------------------
+// CAspCheckBoxSettingPage::HandleListBoxEventL
+//
+// ----------------------------------------------------------------------------
+//
+
+				 
+void CAspCheckBoxSettingPage::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+{
+	TInt index;
+	CSelectableItem* selectableItem;
+	if( AknLayoutUtils::PenEnabled() )  
+	{
+	  	switch(aEventType)
+	
+		{   
+			case EEventItemClicked:
+       		 	 index=aListBox->CurrentItemIndex();
+       		 	 selectableItem = (*iSelectionItemList)[index];
+       		 	 if(selectableItem->SelectionStatus())
+       		 	 {
+       		   		this->ProcessCommandL(EAknSoftkeyUnmark);	
+       		 	 }
+       		     else
+       		     {
+       			    this->ProcessCommandL(EAknSoftkeyMark);
+       		     }
+		        break;
+	 	default:
+			    break;
+		}	
+	}
+
+}
+
+/*******************************************************************************
+ * class CAspProfileWizardDialog
+ *******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfileWizardDialog::ShowDialogL(TAspParam& aParam)
+	{
+    CAspProfileWizardDialog* dialog = CAspProfileWizardDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_PROFILE_WIZARD_DIALOG);
+
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileWizardDialog* CAspProfileWizardDialog::NewL(TAspParam& aParam)
+    {
+    FLOG( _L("CAspProfileWizardDialog::NewL START") );
+
+    CAspProfileWizardDialog* self = new (ELeave) CAspProfileWizardDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProfileWizardDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::CAspProfileWizardDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspProfileWizardDialog::CAspProfileWizardDialog(TAspParam& aParam) 
+    {
+    iSyncSession = aParam.iSyncSession;
+	iApplicationId = aParam.iApplicationId;
+	iDialogParam = &aParam;
+	
+	iBgContext = NULL;
+	iMoveBack = EFalse ;
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::ConstructL()
+    {
+    FLOG( _L("CAspProfileWizardDialog::ConstructL START") );
+
+    if (iApplicationId == KErrNotFound)
+    	{
+    	User::Leave(KErrNotFound); // unknown caller app
+    	}
+	
+    TAspParam param2(KErrNotFound, iSyncSession);
+	iBearerHandler = CAspBearerHandler::NewL(param2);
+
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	CAspResHandler::ReadL(iNaviPaneTextFormat, R_ASP_WIZARD_PAGE_COUNTER);
+	
+	iActiveCaller = CAspActiveCaller::NewL(this);
+
+	TAspParam param(iApplicationId, iSyncSession);
+	iWizard = CAspProfileWizard::NewL(param);
+	SetDefaultValuesL();
+	
+	param.iApplicationId = EApplicationIdSync;
+	iProfileList = CAspProfileList::NewL	(param);
+	iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+	
+	iPopupNote = CAknInfoPopupNoteController::NewL();
+	
+    if (iApplicationId == EApplicationIdEmail)
+    	{
+   	    CDesCArray* arr = iWizard->LocalDatabaseList(KUidNSmlAdapterEMail.iUid);
+	    if (!arr)
+		    {
+		    TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+		    User::Leave(KErrNotFound); // no syncml mailbox
+		    }
+		
+	    if (arr->Count() == 0) 
+		    {
+		    TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+		    User::Leave(KErrNotFound); // no syncml mailbox
+		    }
+    	}
+
+	FLOG( _L("CAspProfileWizardDialog::ConstructL END") );
+    } 
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspProfileWizardDialog::~CAspProfileWizardDialog()
+    {
+    FLOG( _L("CAspProfileWizardDialog::~CAspProfileWizardDialog START") );
+
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	delete iWizard;
+	if(iTextEditorText)
+		{
+		delete iTextEditorText;
+		}
+    delete iBearerHandler;
+	delete iStatusPaneHandler;
+	delete iActiveCaller;
+	delete iProfileList;
+	
+	if (iPopupNote)
+		{
+    	iPopupNote->HideInfoPopupNote();
+	    delete iPopupNote;
+		}
+	
+	if (iBgContext)
+		{
+		delete iBgContext ;
+		iBgContext = NULL ;
+		}
+
+	
+	FLOG( _L("CAspProfileWizardDialog::~CAspProfileWizardDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::ActivateL (from CCoeControl)
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::ActivateL()
+	{
+    FLOG( _L("CAspProfileWizardDialog::ActivateL START") );
+    
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+	
+    FLOG( _L("CAspProfileWizardDialog::ActivateL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::OKToExitL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspProfileWizardDialog::OkToExitL(TInt aButtonId)
+	{
+    FLOG( _L("CAspProfileWizardDialog::OkToExitL START") );
+	
+	iDialogParam->iReturnValue = KErrNotFound;
+	iDialogParam->iProfileId = KErrNotFound;
+
+	if (aButtonId == EEikBidOk)
+		{
+		if (iWizard->CurrentItemType() == CAspWizardItem::ETypeStart)
+			{
+			if (iTextEditorText)
+   				{
+   			 	delete iTextEditorText;
+				iTextEditorText = NULL;
+				}
+    		TRect mainPane;
+			AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, mainPane );
+   	 		iTextEditor->SetRect(mainPane);
+    		iTextEditor->SetTextL(iTextEditorText);
+    		UpdateCbaL(R_ASP_CBA_NEXT_BACK_NEXT);
+		
+			iWizard->MoveToNext();
+			
+			// start wizard when this completes (in HandleActiveCallL)
+			iActiveCaller->Request();
+			 
+			FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
+			return EFalse;
+			}
+		else if (iWizard->CurrentItemType() == CAspWizardItem::ETypeEnd)
+			{
+			iDialogParam->iReturnValue = KErrNone;
+			iDialogParam->iProfileId = iWizard->CreatedProfileId();
+	        
+	        FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
+			return ETrue;
+			}
+		//Case of quick succession clicks on touch screen profile creation wizard
+		else
+			{
+			   return EFalse;	
+			}
+		}
+	//Case of quick succession backs on touch screen profile creation wizard
+	else if(aButtonId == EAknSoftkeyDone)
+	{
+		return EFalse;
+	}
+		
+		
+	
+	FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::ProcessCommandL
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::ProcessCommandL(TInt /*aCommandId*/)
+	{
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileWizardDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspProfileWizardDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEnter:
+			{
+			     TryExitL(EEikBidOk);
+			     return EKeyWasConsumed;
+			}
+			case EKeyOK:
+				{
+				break;
+				}
+
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+            default:
+				{
+				//return iTextEditor->OfferKeyEventL(aKeyEvent, aType);
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::PreLayoutDynInitL
+//
+// Called by framework before dialog is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::PreLayoutDynInitL()
+    {
+    FLOG( _L("CAspProfileWizardDialog::PreLayoutDynInitL START") );
+   
+    iTextEditor = (CEikRichTextEditor*) ControlOrNull (EAspProfileWizardDialogList);
+    
+    User::LeaveIfNull(iTextEditor);
+   
+    SetTextEditorTextL(R_ASP_SET_WIZARD_START);
+    
+	TRect mainPane;
+    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);        
+    iTextEditor->SetRect(mainPane);
+	
+	SetBackgroundContextL ();
+	
+    iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+    iStatusPaneHandler->SetTitleL(R_ASP_SETTING_DIALOG_TITLE);
+    
+    FLOG( _L("CAspProfileWizardDialog::PreLayoutDynInitL END") );
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProfileWizardDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iTextEditor->SetSize(mainPaneRect.Size());
+        SetBackgroundContextL();
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+	if (aType == KAknsMessageSkinChange)
+		{
+		// When skin changes, we need to update text color
+		TRAP_IGNORE(UpdateTextColorL());
+		}
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::HandleActiveCallL (from MAspActiveCallerObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::HandleActiveCallL(TInt /*aCallId*/)
+	{
+    FLOG( _L("CAspProfileWizardDialog::HandleActiveCallL START") );
+	
+	TInt err = RunWizard();
+	
+	if (err != KErrNone)
+		{
+		iWizard->DeleteProfile();
+		
+		ShowErrorNoteL(err);
+
+        TryExitL(EEikBidCancel); // close profile wizard dialog
+		}
+
+    FLOG( _L("CAspProfileWizardDialog::HandleActiveCallL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::RunWizard
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::RunWizard()
+	{
+    FLOG( _L("CAspProfileWizardDialog::RunWizard START") );
+    
+    TRAPD(err, RunWizardL());
+	
+	HidePopupNote();
+	
+	if (err != KErrNone)
+		{
+		iWizard->MoveToStart();
+		FLOG( _L("### RunWizardL failed (%d) ###"), err );
+		}
+		
+    FLOG( _L("CAspProfileWizardDialog::RunWizard END") );
+	return err;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::RunWizardL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::RunWizardL()
+	{
+	for (;;)
+		{
+		CAspWizardItem* item = iWizard->CurrentItem();
+	
+	    if (item->iSettingType == CAspWizardItem::ETypeEnd)
+		    {
+		    iMoveBack = ETrue ;
+		    iWizard->CreateProfileL();
+		    
+		    if (iApplicationId == EApplicationIdSync)
+		    	{
+		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END);
+		        UpdateCbaL(R_ASP_CBA_ACTIVATE_LATER_ACTIVATE);
+		    	}
+		    else if (iApplicationId == EApplicationIdEmail)
+		    	{
+		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END_EMAIL);
+		    	UpdateCbaL(R_AVKON_SOFTKEYS_OK_EMPTY);
+		    	}
+		    else
+		    	{
+		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END_APP);
+		    	UpdateCbaL(R_AVKON_SOFTKEYS_OK_EMPTY);
+		    	}
+
+		    TBuf<KBufSize> buf;
+		    GetNaviPaneText(buf, item);
+		    iStatusPaneHandler->SetNaviPaneTitleL(buf);
+		    
+		    return; // return to wizard dialog view
+		    }
+		
+	    if (item->iSettingType == CAspWizardItem::ETypeStart)
+		    {
+		    iMoveBack = ETrue ;
+		    SetTextEditorTextL(R_ASP_SET_WIZARD_START);
+		    UpdateCbaL(R_ASP_CBA_START_CANCEL_START);
+		    return; // return to wizard dialog view
+		    }
+
+	    TInt ret = EditSettingItemL(item); // show setting editor
+	
+	    if (ret == EAknSoftkeyOk || ret == EEikBidSelect)
+		    {
+		    iMoveBack = EFalse ;
+		    iWizard->MoveToNext();
+        	}
+	    else if (ret == EAknSoftkeyDone)
+		    {
+		    iMoveBack = ETrue ;
+		    iWizard->MoveToPrevious();
+			}
+	    else
+	        {
+	        iMoveBack = EFalse ;
+	        iWizard->MoveToStart();
+		    return; // probably system cancel - wizard must close
+		    }
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemL(CAspWizardItem* aItem)
+	{
+	TInt ret = EAknSoftkeyOk;
+	
+	ShowPopupNoteL(aItem->iPopupNoteResourceId, KMsToWaitBeforePopup);
+	
+	switch (aItem->iSettingType)
+		{
+		case CAspWizardItem::ETypeStart:
+		    break;
+			
+		case CAspWizardItem::ETypeProfileName:
+			ret = EditSettingItemProfileNameL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeProtocolVersion:
+			ret = EditSettingItemProtocolVersionL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeHostAddress:
+			ret = EditSettingItemHostAddressL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeServerId:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeBearerType:
+			ret = EditSettingItemBearerTypeL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeUserName:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+		
+		case CAspWizardItem::ETypePassword:
+			ret = EditSettingItemSecretL(aItem);
+		    break;
+		    
+		case CAspWizardItem::ETypeContentSelection:
+			ret = EditSettingItemContentSelectionL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeSyncContent:
+	    	ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeSyncContentLocalDatabase:
+	    	ret = EditSettingItemLocalDatabaseL(aItem);
+		    break;
+
+		case CAspWizardItem::ETypeEnd:
+			break;
+
+		default:
+		    break;
+		}
+
+	HidePopupNote();
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemTextL
+//
+// Edit text setting item.
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemTextL(CAspWizardItem* aItem)
+	{
+	TUtil::StrCopy(iBuf, aItem->Value());
+	
+	TInt flags(CAknTextSettingPage::EZeroLengthAllowed);
+
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+    
+	CAspTextSettingPage* dlg = new (ELeave) CAspTextSettingPage(
+	                     R_ASP_SETTING_TEXT_NEXT_BACK, iBuf, flags, param);
+	CleanupStack::PushL(dlg);
+
+	dlg->SetSettingTextL(aItem->Header()); 
+	dlg->ConstructL();
+	dlg->TextControl()->SetTextLimit(aItem->iMaxLength);
+
+	if (aItem->iLatinInput)
+		{		
+		dlg->TextControl()->SetAvkonWrap(ETrue);
+		dlg->TextControl()->SetAknEditorCase(EAknEditorLowerCase);
+		dlg->TextControl()->SetAknEditorFlags(EAknEditorFlagNoT9 |
+		                                EAknEditorFlagLatinInputModesOnly);
+		}
+	
+	CleanupStack::Pop(dlg);
+
+    //
+	// CAknTextSettingPage::ExecuteLD returns boolean. 
+	// See CAknSettingPage::ProcessCommandL what softkey values map to
+	// ETrue and EFalse.
+	// Profile wizard editors return EAknSoftkeyDone for "Back" and 
+	// EAknSoftkeyOk for "Next". Editors need "positive" ids for saving
+	// setting values.
+	//
+	TInt ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+   
+
+    aItem->SetValueL(iBuf);
+    
+    return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemProtocolVersionL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileWizardDialog::EditSettingItemProtocolVersionL(CAspWizardItem* aItem)
+	{
+	TInt curSelection = aItem->iNumber;
+	CDesCArray* arr2 = CAspResHandler::ReadDesArrayStaticLC(R_ASP_PROTOCOL_VERSION);
+	CDesCArray* arr = TUtil::NumberConversionLC(arr2);
+	
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+	
+	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
+	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
+	                                  curSelection, arr, param);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(aItem->Header()); 
+	CleanupStack::Pop(dlg);
+
+	dlg->ExecuteLD();
+	
+	aItem->iNumber = curSelection;
+   	aItem->SetValueL((*arr)[curSelection]);
+   	
+   	if (curSelection == EAspProtocol_1_1)
+   		{
+   		iWizard->SetContentEnabled(KUidNSmlAdapterEMail.iUid, EFalse);
+        iWizard->SetEnabled(CAspWizardItem::ETypeServerId, EFalse);
+   		}
+   	else
+   		{
+   		iWizard->SetEnabled(CAspWizardItem::ETypeServerId, ETrue);
+   		}
+
+	CleanupStack::PopAndDestroy(arr);
+	CleanupStack::PopAndDestroy(arr2);
+   	return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemBearerTypeL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemBearerTypeL(CAspWizardItem* aItem)
+	{
+	CDesCArray* arr = iBearerHandler->BuildBearerListLC();
+	if (arr->Count() == 0) 
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	TInt curSelection = iBearerHandler->ListIndexForBearer(aItem->iNumber);
+	if (curSelection == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);
+		}
+
+
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+	
+	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
+	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
+	                                  curSelection, arr, param);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(aItem->Header()); 
+	CleanupStack::Pop(dlg);
+
+	dlg->ExecuteLD();
+		
+	aItem->iNumber = iBearerHandler->BearerForListIndex(curSelection);
+   	aItem->SetValueL((*arr)[curSelection]);
+	
+	CleanupStack::PopAndDestroy(arr);
+		
+   	return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemLocalDatabaseL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemLocalDatabaseL(CAspWizardItem* aItem)
+	{
+	CDesCArray* arr = iWizard->LocalDatabaseList(aItem->iSettingId);
+	if (!arr)
+		{
+		User::Leave(KErrNotFound);
+		}
+		
+	if (arr->Count() == 0) 
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	TInt curSelection = aItem->iNumber;
+	if (curSelection < 0)
+		{
+		curSelection = 0;
+		}
+
+
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+	
+	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
+	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
+	                                  curSelection, arr, param);
+	CleanupStack::PushL(dlg);
+	dlg->SetSettingTextL(aItem->Header()); 
+	CleanupStack::Pop(dlg);
+
+	dlg->ExecuteLD();
+		
+	aItem->iNumber = curSelection;
+   	aItem->SetValueL((*arr)[curSelection]);
+	
+   	return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemSecretL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemSecretL(CAspWizardItem* aItem)
+	{
+	TBuf<KBufSize64> newPassword;
+	TUtil::StrCopy(newPassword, aItem->Value());
+	
+	
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+
+	CAspAlphaPasswordSettingPage* pwd = new (ELeave) CAspAlphaPasswordSettingPage(
+		     R_ASP_SETTING_PASSWORD_NEXT_BACK, newPassword, aItem->Value(), param);
+
+	CleanupStack::PushL(pwd);
+	pwd->SetSettingTextL(aItem->Header()); 
+	pwd->ConstructL();
+	pwd->AlphaPasswordEditor()->SetMaxLength(aItem->iMaxLength);
+	//pwd->AlphaPasswordEditor()->RevealSecretText(ETrue);
+	CleanupStack::Pop(pwd);
+
+	TInt ret = pwd->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+		
+	aItem->SetValueL(newPassword);
+   	
+   	return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemProfileNameL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemProfileNameL(CAspWizardItem* aItem)
+	{
+	TInt commandId = EditSettingItemTextL(aItem);
+      	
+    return commandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemHostAddressL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemHostAddressL(CAspWizardItem* aItem)
+	{
+	_LIT(KIPAddressRegX,"http://*");
+	TInt bearer = iWizard->NumberValue(CAspWizardItem::ETypeBearerType);
+	TPtrC ptr = aItem->Value();
+	TPtrC httpHeader(KIPAddressRegX); 
+	
+	if (bearer == EAspBearerInternet)
+		{
+		   //If existing ptr is NOT an IP address
+		   if(ptr.MatchC(httpHeader) == KErrNotFound)
+		   {
+				aItem->SetValueL(KHttpHeader);   	
+		   }
+		}
+	else
+		{
+		    //If existing ptr is IP address
+		    if(ptr.MatchC(httpHeader) != KErrNotFound)
+		    {
+		    	aItem->SetValueL(KNullDesC); 		
+		    }
+		}
+	
+	TInt commandId;
+	while (ETrue)
+		{
+		commandId = EditSettingItemTextL(aItem);
+		if (commandId == EAknSoftkeyOk && bearer == EAspBearerInternet)
+			{
+			if (!TURIParser::IsValidUri(aItem->Value()))
+				{			
+				TDialogUtil::ShowInformationNoteL(R_ASP_LOG_ERR_URIINVALID);
+				}
+			else
+				{
+				break;	
+				}
+			}
+		else
+			{
+			break;	
+			}
+		}
+    return commandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::EditSettingItemContentSelectionL
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspProfileWizardDialog::EditSettingItemContentSelectionL(CAspWizardItem* aItem)
+	{
+	CAspSelectionItemList* list = new (ELeave) CAspSelectionItemList(1);
+	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
+	
+	iWizard->GetContentSelectionL(list);
+	
+    TAspSettingPageParam param;
+    param.iCommandId = EAknSoftkeyOk;
+    GetNaviPaneText(param.iPageText, aItem);
+    param.iObserver = this;
+    param.iSettingType = aItem->iSettingType;
+
+	CAspCheckBoxSettingPage* dlg = new (ELeave) CAspCheckBoxSettingPage(
+	                                   R_ASP_SETTING_CHECK_NEXT_BACK, list, param);
+	
+   	CleanupStack::PushL(dlg);
+    dlg->SetSettingTextL(aItem->Header());
+	CleanupStack::Pop(dlg);
+
+    TBool ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+    
+    iWizard->SetContentSelectionL(list);
+    
+	CleanupStack::PopAndDestroy(list);
+
+   	return param.iCommandId;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::CheckValidity (from MAspEditorPageObserver)
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileWizardDialog::CheckValidity(const TDesC& aText, TInt aSettingType)
+	{
+	TInt ret = ETrue;
+	
+	TRAPD(err, ret = CheckValidityL(aText, aSettingType));
+	
+	if (err != KErrNone)
+		{
+		return ETrue;
+		}
+	
+	return ret;
+	}
+	
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::CheckValidityL (from MAspEditorPageObserver)
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspProfileWizardDialog::CheckValidityL(const TDesC& aText, TInt aSettingType)
+	{
+	if (aSettingType == CAspWizardItem::ETypeProfileName)
+		{
+	    if (TUtil::IsEmpty(aText))
+		    {
+		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_PROFILE_NAME_MISSING);
+		    return EFalse;
+		    }
+		}
+		
+	if (aSettingType == CAspWizardItem::ETypeSyncContent)
+		{
+	    if (TUtil::IsEmpty(aText))
+		    {
+		    CAspWizardItem* item = iWizard->CurrentItem();
+		    if (item->iErrorNoteResourceId == R_ASP_NOTE_CONTACTS_DB_MISSING)
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_CONTACTS_DB_MISSING);
+		    	return EFalse;
+		    	}
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_CALENDAR_DB_MISSING)
+		    	{	
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_CALENDAR_DB_MISSING);
+		    	return EFalse;
+		    	}
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_NOTES_DB_MISSING)
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_NOTES_DB_MISSING);
+		    	return EFalse;
+		    	}
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_EMAIL_DB_MISSING)
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_EMAIL_DB_MISSING);
+		    	return EFalse;
+		    	} 
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_MMS_DATABASE_MISSING)
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_MMS_DATABASE_MISSING);
+		    	return EFalse;
+		    	} 
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_SMS_DATABASE_MISSING)
+		        {
+		        TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_SMS_DATABASE_MISSING);
+		        return EFalse;
+		        } 
+		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_BKM_DATABASE_MISSING)
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_BKM_DATABASE_MISSING);
+		    	return EFalse;
+		    	} 
+		    else
+		    	{
+		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_REMOTE_DATABASE_MISSING);
+		    	return EFalse;
+    	    	}
+    	        	    
+    	    }
+		}
+
+	if (aSettingType == CAspWizardItem::ETypeHostAddress)
+		{
+	    if (TUtil::IsEmpty(aText))
+		    {
+		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_HOST_ADDRESS_MISSING);
+		    return EFalse;
+		    }
+		TInt bearer = iWizard->NumberValue(CAspWizardItem::ETypeBearerType);
+		if	(bearer == EAspBearerInternet)		    
+			{
+				if (!TURIParser::IsValidUri(aText))
+			    {
+			    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
+			    return EFalse;
+			    }
+			}
+			else if (bearer == EAspBearerBlueTooth)
+			{
+				if (!TURIParser::IsValidBluetoothHostAddress(aText))
+			    {
+			    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
+			    return EFalse;
+			    }
+			}
+		}
+    
+	if (aSettingType == CAspWizardItem::ETypeServerId)
+		{
+	    if (!iProfileList->IsUniqueServerId(aText, KErrNotFound))
+		    {
+		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_SERVER_ID);
+		    return EFalse;
+		    }
+		}
+
+	if (aSettingType == CAspWizardItem::ETypeContentSelection)
+		{
+		TInt adapterId = iWizard->ContentId(aText);
+		if (adapterId == KUidNSmlAdapterEMail.iUid)
+			{
+		    TInt protocol = iWizard->NumberValue(CAspWizardItem::ETypeProtocolVersion);
+		   	
+		   	
+		   	CDesCArray* arr = iWizard->LocalDatabaseList(KUidNSmlAdapterEMail.iUid);
+	        if (!arr)
+		        {
+		        TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+		        return EFalse;  // no syncml mailbox
+		        }
+		
+	        if (arr->Count() == 0) 
+		        {
+		        TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+		        return EFalse;   // no syncml mailbox
+		        }
+			}
+		}
+
+	
+
+	return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::GetNavipaneText (from MAspEditorPageObserver)
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::GetNavipaneText(TDes& aText, TInt aContentCount)
+	{
+    CAspWizardItem* item = iWizard->CurrentItem();
+    
+    TInt total = iWizard->NumOfEnabledItems();
+    total--; // start page not included in page count
+    
+    TInt current = iWizard->NumOfCurrentItem(item);
+    current--; // start page not included in page count
+    
+    TInt enabledContentCount = iWizard->NumOfEnabledContentItems();
+    
+    total = total - enabledContentCount;
+    total = total + aContentCount;
+
+    GetNaviPaneText(aText, current, total);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspProfileWizardDialog::HandleEditorEvent (from MAspEditorPageObserver)
+//
+//------------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::HandleEditorEvent(TInt aEvent, TInt /*aValue*/)
+	{
+	if (aEvent == MAspEditorPageObserver::EKeyEvent)
+		{
+		HidePopupNote();
+		TRAP_IGNORE( ShowPopupNoteL(KErrNotFound, KMsToWaitBeforeRePopup) );
+		}
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::SetDefaultValuesL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::SetDefaultValuesL()
+	{
+	// use existing profile list for name creation
+	if (iDialogParam->iProfileList)
+		{
+	    HBufC* hBuf = CAspProfile::GetNewProfileNameLC(
+	                  iDialogParam->iProfileList, iApplicationId);
+	    iWizard->SetStringValueL(hBuf->Des(), CAspWizardItem::ETypeProfileName);  
+	    CleanupStack::PopAndDestroy(hBuf);
+		}
+	else
+		{
+		// create profile list for name creation
+	    TAspParam param(EApplicationIdSync, iSyncSession);
+        CAspProfileList* list =  CAspProfileList::NewLC(param);
+	    list->ReadAllProfilesL(CAspProfileList::EBasePropertiesOnly);
+	
+	    HBufC* hBuf = CAspProfile::GetNewProfileNameLC(list, iApplicationId);
+	    iWizard->SetStringValueL(hBuf->Des(), CAspWizardItem::ETypeProfileName);
+	    CleanupStack::PopAndDestroy(hBuf);
+	
+	    CleanupStack::PopAndDestroy(list);
+		}
+		
+	if (iBearerHandler)
+		{
+		TInt bearerType = iBearerHandler->DefaultBearer();
+		iWizard->SetNumberValue(bearerType, CAspWizardItem::ETypeBearerType);
+		}
+		
+	TInt num = EAspProtocol_1_2;
+	iWizard->SetNumberValue(num, CAspWizardItem::ETypeProtocolVersion);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::GetNaviPaneText
+//
+// Function constructs navi pane text. Text format is:
+// "Page %0N/%1N"  (eg "Page 5/6")
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::GetNaviPaneText(TDes& aText, TInt aCurrent, TInt aFinal)
+	{
+    TBuf <KBufSize> buf;
+    
+    // replace  %0N with aCurrent
+    StringLoader::Format(buf, iNaviPaneTextFormat, 0, aCurrent);
+    
+    // replace %1N with aFinal
+    StringLoader::Format(aText, buf, 1, aFinal);
+    
+    AknTextUtils::DisplayTextLanguageSpecificNumberConversion(aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::GetNaviPaneText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::GetNaviPaneText(TDes& aText, CAspWizardItem* aItem)
+	{
+    TInt total = iWizard->NumOfEnabledItems();
+    total--; // start page not included in page count
+    
+    TInt current = iWizard->NumOfCurrentItem(aItem);
+    current--; // start page not included in page count
+
+    GetNaviPaneText(aText, current, total);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::UpdateCbaL(TInt aResourceId)
+    {
+    CEikButtonGroupContainer& cba = ButtonGroupContainer();
+    cba.SetCommandSetL(aResourceId);
+    cba.DrawDeferred();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::SetTextEditorTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::SetTextEditorTextL(TInt aResource)
+	{
+	if(iTextEditorText)
+		{
+		delete iTextEditorText;
+		iTextEditorText = NULL;		
+		}
+	if (iMoveBack)
+		{
+		TRect mainPane;
+    	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);        
+    	iTextEditor->SetRect(mainPane);
+		}
+	iTextEditorText = CAspResHandler::ReadL(aResource);
+	UpdateTextColorL() ;
+	iTextEditor->SetTextL(iTextEditorText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::ShowPopupNote
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::ShowPopupNoteL(TInt aResource, TInt aDelay) 
+    {
+    if (aResource != KErrNotFound)
+    	{
+    	HBufC* hBuf = CAspResHandler::ReadLC(aResource);    
+        iPopupNote->SetTextL(hBuf->Des());
+        CleanupStack::PopAndDestroy(hBuf);
+    	}
+    	
+    iPopupNote->SetTimePopupInView(KMsTimePopupInView);    
+    iPopupNote->SetTimeDelayBeforeShow(aDelay);
+    iPopupNote->ShowInfoPopupNote();    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::HidePopupNote
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::HidePopupNote() 
+    {
+    iPopupNote->HideInfoPopupNote();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::ShowErrorNoteL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::ShowErrorNoteL(TInt aError)
+	{
+	if (aError == KErrNoMemory || aError == KErrDiskFull)
+		{
+		CTextResolver* tr = CTextResolver::NewLC();
+		iBuf = tr->ResolveErrorString(aError, CTextResolver::ECtxNoCtxNoSeparator);
+     	CleanupStack::PopAndDestroy(tr);
+		}
+	else
+		{
+		CAspResHandler::ReadL(iBuf, R_ASP_LOG_ERR_PROFILE_WIZARD);
+		}
+		
+    TDialogUtil::ShowErrorNoteL(iBuf);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::SetBackgroundContextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::SetBackgroundContextL( )
+{
+	TRect mainPane( 0,0,0,0 );
+		
+	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, mainPane );
+	
+	if (iBgContext)
+		{
+		delete iBgContext ;
+		iBgContext = NULL ;
+		}
+	
+	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
+                        KAknsIIDQsnBgAreaMain, mainPane, EFalse );
+		
+	iTextEditor->SetSkinBackgroundControlContextL( iBgContext );                            
+}
+
+
+// -----------------------------------------------------------------------------
+// CAspProfileWizardDialog::UpdateTextColorL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProfileWizardDialog::UpdateTextColorL() 
+	{
+	TRgb textColor( KRgbBlack );
+	AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
+	                           textColor,
+	                           KAknsIIDQsnTextColors,
+	                           EAknsCIQsnTextColorsCG6 );
+
+
+	const CFont* sysfont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont); 
+	TFontSpec sysfontspec = sysfont->FontSpecInTwips();
+
+	TCharFormat charFormat;
+	TCharFormatMask charFormatMask;
+	charFormat.iFontSpec = sysfontspec;
+
+	charFormat.iFontPresentation.iTextColor = textColor; 
+	charFormatMask.SetAll();
+	charFormatMask.SetAttrib( EAttFontHeight );
+	charFormatMask.SetAttrib( EAttColor );
+	CCharFormatLayer* formatLayer = CCharFormatLayer::NewL(charFormat, charFormatMask);
+	iTextEditor->SetCharFormatLayer(formatLayer);
+	}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspProgressDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,531 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+#include "AspProgressDialog.h"
+#include "AspSyncUtil.rh"
+#include "AspUtil.h"
+#include "AspDebug.h"
+#include "AspDefines.h"
+#include "AspResHandler.h"
+#include "AspDialogUtil.h"
+
+
+#include <eikprogi.h>
+#include <notecontrol.h>
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+/*******************************************************************************
+ * class CAspProgressDialog
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::CAspProgressDialog
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog::CAspProgressDialog(MAspProgressDialogObserver* aObserver) : iObserver(aObserver)
+    {
+    FLOG( _L("CAspProgressDialog: CAspProgressDialog") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog* CAspProgressDialog::NewL(MAspProgressDialogObserver* aObserver)
+    {
+    FLOG( _L("CAspProgressDialog::NewL START") );
+
+    CAspProgressDialog* self = new (ELeave) CAspProgressDialog(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspProgressDialog::NewL END") );
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::ConstructL()
+    {
+    FLOG( _L("CAspProgressDialog::ConstructL START") );
+
+	iLastText = KNullDesC;
+	iAnimation = EFalse;
+	iResHandler = CAspResHandler::NewL();
+	iProgressDialogRunning = EFalse;
+    
+	FLOG( _L("CAspProgressDialog::ConstructL END") );
+    } 
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog::~CAspProgressDialog()
+    {
+    FLOG( _L("CAspProgressDialog::~CAspProgressDialog START") );
+
+	delete iResHandler;
+    delete iProgressDialog;
+
+	FLOG( _L("CAspProgressDialog::~CAspProgressDialog END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::LaunchProgressDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::LaunchProgressDialogL(const TDesC& aLabel, TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId)
+	{
+    FLOG( _L("CAspProgressDialog::LaunchProgressDialogL START") );
+
+	iProgressDialog = new(ELeave) CAspProgressDialog2(reinterpret_cast<CEikDialog**>(&iProgressDialog), iApplicationId);
+    
+	iProgressDialog->PrepareLC(R_ASP_PROGRESS_NOTE);
+    iProgressDialog->SetTextL(aLabel);
+	
+	CEikImage* image = TDialogUtil::CreateImageLC(aId, aFileName, aFileBitmapId, aFileMaskId);
+    iProgressDialog->SetImageL(image);
+	CleanupStack::Pop(image);
+
+    // get reference to progress info bar
+    iProgressInfo = iProgressDialog->GetProgressInfoL();
+    iProgressDialog->SetCallback(this);
+    
+    iProgressDialog->RunLD();
+    iProgressDialogRunning = ETrue;
+
+	FLOG( _L("CAspProgressDialog::LaunchProgressDialogL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::CancelProgressDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::CancelProgressDialogL()
+    {
+    FLOG( _L("CAspProgressDialog::CancelProgressDialogL START") );
+
+	if (!iProgressDialogRunning)
+		{
+		return; // dialog is already closed
+		}
+		
+	if(iProgressDialog)
+        {        
+        iProgressDialog->ProcessFinishedL();
+        iProgressDialogRunning = EFalse;
+        }    
+
+	FLOG( _L("CAspProgressDialog::CancelProgressDialogL END") );
+    }
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::ProgressDialog
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog2* CAspProgressDialog::ProgressDialog()
+	{
+	return iProgressDialog;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::UpdateTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::UpdateTextL(const TDesC& aText)
+    {
+    FLOG( _L("CAspProgressDialog::UpdateTextL START") );
+
+	__ASSERT_DEBUG(iProgressDialog, TUtil::Panic(KErrGeneral));
+
+	if (iLastText.Compare(aText) == 0)
+		{
+		return;  // text has not changed
+		}
+    
+    iProgressDialog->SetTextL(aText);
+	TUtil::StrCopy(iLastText, aText);
+	
+	FLOG( _L("aText is '%S'"), &aText );
+
+	FLOG( _L("CAspProgressDialog::UpdateTextL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::SetProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::SetProgress(TInt aValue)
+    {
+    FLOG( _L("CAspProgressDialog::SetProgress START") );
+    
+	__ASSERT_DEBUG(iProgressDialog  && iProgressInfo, TUtil::Panic(KErrGeneral));
+
+	CEikProgressInfo::SInfo info = iProgressInfo->Info();
+
+	TInt val = aValue;
+	if (val > info.iFinalValue)
+		{
+		val = info.iFinalValue;
+		}
+	
+	iProgressInfo->SetAndDraw(val);
+	
+	FLOG( _L("aValue is %d"), aValue );
+    
+	FLOG( _L("CAspProgressDialog::SetProgress END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::SetFinalProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::SetFinalProgress(TInt aFinalValue)
+	{
+    FLOG( _L("CAspProgressDialog::SetFinalProgress START") );
+    
+    __ASSERT_DEBUG(iProgressInfo, TUtil::Panic(KErrGeneral));
+
+    if (aFinalValue < 0)
+    	{
+    	iProgressInfo->SetFinalValue(0);
+    	}
+    else
+    	{
+    	iProgressInfo->SetFinalValue(aFinalValue);
+    	}
+    	
+	iProgressInfo->SetAndDraw(0);
+
+	FLOG( _L("aFinalValue is %d"), aFinalValue );
+	
+	FLOG( _L("CAspProgressDialog::SetFinalProgress END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::NoteControl
+//
+// -----------------------------------------------------------------------------
+//
+CAknNoteControl* CAspProgressDialog::NoteControl()
+	{
+    CAknNoteControl* note = STATIC_CAST(CAknNoteControl*, iProgressDialog->ControlOrNull(EAspSyncProgressNote));
+
+	__ASSERT_DEBUG(note, TUtil::Panic(KErrGeneral));
+
+	return note;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::CancelAnimation
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::CancelAnimation()
+	{
+	FLOG( _L("CAspProgressDialog::CancelAnimation START") );
+	
+	NoteControl()->CancelAnimation();
+	iAnimation = EFalse;
+
+	FLOG( _L("CAspProgressDialog::CancelAnimation END") );
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspProgressDialog::StartAnimationL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspProgressDialog::StartAnimationL()
+	{
+	FLOG( _L("CAspProgressDialog::StartAnimationL START") );
+	
+	if (!iAnimation)
+		{
+		NoteControl()->StartAnimationL();
+		iAnimation = ETrue;
+		
+		FLOG( _L("animation started") );
+		}
+		
+    FLOG( _L("CAspProgressDialog::StartAnimationL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::DialogDismissedL (From MProgressDialogCallback)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::DialogDismissedL(TInt aButtonId)
+    {
+    FLOG( _L("CAspProgressDialog::DialogDismissedL START" ) );
+  
+    if (!iObserver)
+		{
+		FLOG( _L("### no observer ###") );
+		FLOG( _L("CAspProgressDialog::DialogDismissedL END") );
+		return; // no observer
+		}
+	
+	// end key handling
+	if (aButtonId == EKeyPhoneEnd)
+	    {
+        TRAP_IGNORE(iObserver->HandleDialogEventL(EKeyPhoneEnd));
+        }
+
+	// this dialog only sends one cancel event - other events are ignored 
+	if (aButtonId == EEikBidCancel)
+		{
+        TRAP_IGNORE(iObserver->HandleDialogEventL(EEikBidCancel));
+        }
+
+    FLOG( _L("CAspProgressDialog::DialogDismissedL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog::HideButtonL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspProgressDialog::HideButtonL()
+    {
+    const TInt KLastButtonIndex = 2;
+    
+   	CEikButtonGroupContainer& container = iProgressDialog->ButtonGroupContainer();
+	
+	container.RemoveCommandFromStack(KLastButtonIndex, EAknSoftkeyCancel);
+	container.AddCommandToStackL(KLastButtonIndex, EAknSoftkeyEmpty, KNullDesC);
+	container.DrawDeferred();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspProgressDialog::SetApplicationId
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspProgressDialog::SetApplicationId(TInt aApplicationId)
+	{
+	iApplicationId = aApplicationId;
+	}
+
+
+
+
+
+/*******************************************************************************
+ * class CAspProgressDialog2
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog2::CAspProgressDialog2
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog2::CAspProgressDialog2(CEikDialog** aSelfPtr, TInt aApplicationId)
+ : CAknProgressDialog(aSelfPtr)
+	{
+	FLOG( _L("CAspProgressDialog2::CAspProgressDialog2 START") );
+	
+    iCloseEventReceived = EFalse;
+    iCancelEventReceived = EFalse;
+    iClosed = EFalse;
+    iCanceled = EFalse;
+	iApplicationId = aApplicationId;
+	
+	if (iApplicationId != EApplicationIdSync)
+		{
+		// to make sure that wserv does not change our priority even we lose foreground.
+	    // this is needed for receiving event EKeyPhoneEnd without delay.
+	    
+	    RWsSession& wsSession = iEikonEnv->WsSession();
+	    wsSession.ComputeMode(RWsSession::EPriorityControlDisabled);
+	    
+	    FLOG( _L("RWsSession::ComputeMode(RWsSession::EPriorityControlDisabled)") );
+	    
+		}
+		
+	FLOG( _L("CAspProgressDialog2::CAspProgressDialog2 END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog2::~CAspProgressDialog2()
+    {
+    FLOG( _L("CAspProgressDialog2::~CAspProgressDialog2 START") );
+
+	if (iApplicationId != EApplicationIdSync)
+		{
+		RWsSession& wsSession = iEikonEnv->WsSession();
+	    wsSession.ComputeMode(RWsSession::EPriorityControlComputeOff);
+	    
+	    FLOG( _L("RWsSession::ComputeMode(RWsSession::EPriorityControlComputeOff)") );
+		}
+
+    if (iAvkonAppUi)
+        {
+        iAvkonAppUi->RemoveFromStack(this);
+        }
+
+	FLOG( _L("CAspProgressDialog2::~CAspProgressDialog2 END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspProgressDialog2::OkToExitL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspProgressDialog2::OkToExitL(TInt aButtonId)
+    {
+    FLOG( _L("CAspProgressDialog2::OkToExitL START") );
+    
+    // close key handling
+    if (iCloseEventReceived && !iClosed)
+        {
+   	    if (iCallback)
+   	    	{
+   	    	TRAP_IGNORE(iCallback->DialogDismissedL(EKeyPhoneEnd));
+   	    	
+   	    	FLOG( _L("CAspProgressDialog2::OkToExitL: close handling done") );
+  	    	}
+   		    
+        if (iAvkonAppUi)
+            {
+            // prevent further close events
+            iAvkonAppUi->RemoveFromStack(this);
+            }
+            
+        FLOG( _L("CAspProgressDialog2::OkToExitL END") );
+
+        iClosed = ETrue;
+        return ETrue;
+        }
+
+    // cancel key handling
+    if (aButtonId == EEikBidCancel && iCancelEventReceived && !iCanceled && !iClosed)
+        {
+        if (iCallback)
+        	{
+        	TRAP_IGNORE(iCallback->DialogDismissedL(EEikBidCancel));
+        	
+        	FLOG( _L("CAspProgressDialog2::OkToExitL: cancel key handling done") );
+        	}
+        
+		FLOG( _L("CAspProgressDialog2::OkToExitL END") );
+		
+		iCanceled = ETrue;
+		return EFalse; // leave dialog open - let observer close it
+		}
+
+
+    FLOG( _L("CAspProgressDialog2::OkToExitL END") );
+    
+    return CAknProgressDialog::OkToExitL(aButtonId);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspProgressDialog2::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspProgressDialog2::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	FLOG( _L("CAspProgressDialog2::OfferKeyEventL START") );
+	
+	if (aKeyEvent.iScanCode == EStdKeyDevice1)
+		{
+		iCancelEventReceived = ETrue;
+		FLOG( _L("CAspProgressDialog2::OfferKeyEventL: EStdKeyDevice1 received") );
+     	}
+		
+
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+
+            case EKeyEscape:  // iCode 27 (0x1b)
+            	{
+            	iCloseEventReceived = ETrue;
+            	FLOG( _L("CAspProgressDialog2::OfferKeyEventL: EKeyEscape received") );
+            	break;
+            	}
+            	
+            case EKeyPhoneEnd:
+             	{
+             	iCloseEventReceived = ETrue;
+                FLOG( _L("CAspProgressDialog2::OfferKeyEventL: EKeyPhoneEnd received") );
+                break;
+               	}
+
+            default:
+                FLOG( _L("event key code is %d"),  aKeyEvent.iCode);        
+			    break;
+			}
+		}
+
+
+    FLOG( _L("CAspProgressDialog2::OfferKeyEventL END") );
+    
+	return CAknProgressDialog::OfferKeyEventL(aKeyEvent, aType);
+	}
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspResHandler.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,618 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+// INCLUDES
+#include "AspResHandler.h"
+#include "AspUtil.h"
+#include "AspState.h"
+
+#include <akntabgrp.h>      // for AknTextUtils
+#include <StringLoader.h>
+#include <data_caging_path_literals.hrh>  // for resource and bitmap directories
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspResHandler* CAspResHandler::NewL()
+    {
+    CAspResHandler* self = new (ELeave) CAspResHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspResHandler::~CAspResHandler()
+    {
+	if (iResId)
+		{
+        iEikEnv->DeleteResourceFile(iResId);
+		}
+
+	delete iProgressTextFormat;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspResHandler::ConstructL(void)
+    {
+	iEikEnv = CEikonEnv::Static();
+	
+	// add resource file
+	TFileName buf;
+	GetResFileName(buf);
+	iResId = TUtil::AddResFileL(buf);
+
+	iProgressTextFormatId = KErrNotFound;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::CAspResHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspResHandler::CAspResHandler()
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspResHandler::ReadL(TDes& aText, TInt aResourceId)
+	{
+	StringLoader::Load(aText, aResourceId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspResHandler::ReadL(TDes& aText, TInt aResourceId, const TDesC& aSubString)
+	{
+    HBufC* hBuf = StringLoader::LoadLC(aResourceId, aSubString);
+    TUtil::StrCopy(aText, *hBuf);
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadLC(TInt aResourceId)
+	{
+    return StringLoader::LoadLC(aResourceId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadL(TInt aResourceId)
+	{
+    return StringLoader::LoadL(aResourceId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadDesArrayLC
+//
+// -----------------------------------------------------------------------------
+//
+CDesCArrayFlat* CAspResHandler::ReadDesArrayLC(TInt aResourceId)
+	{
+	CDesCArrayFlat* arr = iEikEnv->ReadDesCArrayResourceL(aResourceId);
+	CleanupStack::PushL(arr);
+    return arr;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadDesArrayL
+//
+// -----------------------------------------------------------------------------
+//
+CDesCArrayFlat* CAspResHandler::ReadDesArrayL(TInt aResourceId)
+	{
+	CDesCArrayFlat* arr = iEikEnv->ReadDesCArrayResourceL(aResourceId);
+    return arr;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadDesArrayStaticLC
+//
+// -----------------------------------------------------------------------------
+//
+CDesCArrayFlat* CAspResHandler::ReadDesArrayStaticLC(TInt aResourceId)
+	{
+	CDesCArrayFlat* arr = CEikonEnv::Static()->ReadDesCArrayResourceL(aResourceId);
+	CleanupStack::PushL(arr);
+    return arr;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadLC(TInt aResourceId, const TDesC& aSubString)
+	{
+	HBufC* hBuf = StringLoader::LoadL(aResourceId, aSubString);
+	CleanupStack::PushL(hBuf);
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadLC(TInt aResourceId, TInt aNumber)
+	{
+	HBufC* hBuf = StringLoader::LoadL(aResourceId, aNumber);
+	CleanupStack::PushL(hBuf);
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetResFileName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspResHandler::GetResFileName(TDes& aText)
+	{
+	TParse parse;
+	parse.Set(KResFileName, &KDC_RESOURCE_FILES_DIR, NULL);
+	TUtil::StrCopy(aText, parse.FullName());
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetBitmapFileName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspResHandler::GetBitmapFileName(TDes& aText)
+	{
+	TParse parse;
+	parse.Set(KBitmapFileName, &KDC_APP_BITMAP_DIR, NULL);
+	TUtil::StrCopy(aText, parse.FullName());
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProgressTextL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProgressTextLC(const TDesC& aContent, TInt aPhase)
+	{
+	HBufC* hBuf = NULL;
+	
+	if (aPhase == CAspState::EPhaseSending)
+		{
+	    hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_SENDING, aContent);
+		}
+	else if (aPhase == CAspState::EPhaseReceiving)
+		{
+		hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_RECEIVING, aContent);
+		}
+    else
+    	{
+    	hBuf = HBufC::NewLC(0);  // empty string
+    	}
+	
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProgressTextL
+//
+// Function constructs progress dialog text that is shown with progress bar.
+// Text format is one of the following:
+// "Sending %U"
+// "Receiving %U"
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProgressTextLC(TInt aResourceId, const TDesC& aContent)
+	{
+    
+    if (aResourceId != iProgressTextFormatId)
+    	{
+    	delete iProgressTextFormat;
+    	iProgressTextFormat = NULL;
+    	iProgressTextFormat = StringLoader::LoadL(aResourceId, iEikEnv);
+    	iProgressTextFormatId = aResourceId;
+    	}
+    	
+    TInt len = iProgressTextFormat->Length() + aContent.Length();
+    
+    HBufC* hBuf = HBufC::NewLC(len);
+    TPtr ptr = hBuf->Des();
+
+    
+    // replace  %0U with content name (eg "Contacts")
+    StringLoader::Format(ptr, iProgressTextFormat->Des(), 0, aContent);
+    
+    //HBufC* hBuf = StringLoader::LoadLC(aResourceId, aContent);
+   
+    return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProfileInfoTextLC
+//
+// Text format: 
+// "Profile: %0U, connection: %1U"
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProfileInfoTextLC(const TDesC& aProfile, const TDesC& aBearer)
+	{
+    HBufC* hBuf   = HBufC::NewLC(KBufSize255);
+    HBufC* temp   = HBufC::NewLC(KBufSize255);
+    HBufC* format = ReadLC(R_ASP_POPUP_PROFILE_INFO);
+    	
+    TPtr ptr = hBuf->Des();
+    TPtr tempPtr = temp->Des();
+    
+    // replace  %0U with profile name
+    StringLoader::Format(tempPtr, format->Des(), 0, aProfile);
+    
+    // replace %1U with bearer name
+    StringLoader::Format(ptr, tempPtr, 1, aBearer);
+    
+    AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr);
+    
+    
+    CleanupStack::PopAndDestroy(format);
+    CleanupStack::PopAndDestroy(temp);
+    
+    return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProfileInfoTextLC
+//
+// Text format: 
+// "Profile: %0U, connection: %1U. Next sync in %0N hours %1N minutes"
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProfileInfoTextLC(const TDesC& aProfile, const TDesC& aBearer,
+		                                    TInt aHours, TInt aMinutes)
+	{
+    HBufC* hBuf   = HBufC::NewLC(KBufSize255);
+    HBufC* temp   = HBufC::NewLC(KBufSize255);
+    HBufC* format = ReadLC(R_ASP_POPUP_AUTO_SYNC_PROFILE);
+    	
+    TPtr ptr = hBuf->Des();
+    TPtr tempPtr = temp->Des();
+    
+    // replace  %0U with profile name
+    StringLoader::Format(tempPtr, format->Des(), 0, aProfile);
+    
+    // replace %1U with bearer name
+    StringLoader::Format(ptr, tempPtr, 1, aBearer);
+    
+    // replace %0N with hours
+    StringLoader::Format(tempPtr, ptr, 0, aHours);
+
+    // replace %1N with minutes
+    StringLoader::Format(ptr, tempPtr, 1, aMinutes);
+
+    AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr);
+    
+    
+    CleanupStack::PopAndDestroy(format);
+    CleanupStack::PopAndDestroy(temp);
+    
+    return hBuf;
+	}
+		                                    		
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadAutoSyncInfoTextLC
+//
+// Text format: 
+// "Next sync: %0U, profile: %1U"
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadAutoSyncInfoTextLC(const TDesC& aProfile, TTime aTime)
+	{
+    HBufC* hBuf   = HBufC::NewLC(KBufSize255);
+    HBufC* temp   = HBufC::NewLC(KBufSize255);
+    HBufC* format = ReadLC(R_ASP_MAIN_NOTE_AUTO_ON);
+    	
+    TPtr ptr = hBuf->Des();
+    TPtr tempPtr = temp->Des();
+
+	TTime currentTime;
+	currentTime.HomeTime();
+	TDateTime today = currentTime.DateTime();
+	TDateTime syncDay = aTime.DateTime();
+
+	TBuf<64> aTimeString;
+	if(today.Day() == syncDay.Day() && today.Month() == syncDay.Month())
+		{
+		//show next sync time
+		TBuf<KBufSize> timeFormat;
+		CAspResHandler::ReadL(timeFormat, R_QTN_TIME_USUAL_WITH_ZERO);
+		aTime.FormatL(aTimeString, timeFormat);
+
+		}
+	else 
+		{
+		//show sync day
+		TBuf<KBufSize> dateFormat;
+		CAspResHandler::ReadL(dateFormat, R_QTN_DATE_USUAL_WITH_ZERO);
+		aTime.FormatL(aTimeString, dateFormat);
+
+		}
+	
+	
+    // replace  %0U with Next Sync
+    StringLoader::Format(tempPtr, format->Des(), 0, aTimeString);
+        
+    // replace %1U with profile name
+    StringLoader::Format(ptr, tempPtr, 1, aProfile);
+    
+    AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr);
+    
+    
+    CleanupStack::PopAndDestroy(format);
+    CleanupStack::PopAndDestroy(temp);
+    
+    return hBuf;
+	}
+		                
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetNewProfileNameLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::GetNewProfileNameLC(TInt aIndex, TInt aApplicationId)
+	{
+	HBufC* hBuf = NULL;
+	
+	switch (aApplicationId)
+		{
+		case EApplicationIdContact:
+			hBuf =  StringLoader::LoadLC(R_ASP_PROFILENAME_PHONEBOOK, aIndex);
+			break;
+		case EApplicationIdCalendar:
+			hBuf =  StringLoader::LoadLC(R_ASP_PROFILENAME_CALENDAR, aIndex);
+			break;
+		case EApplicationIdEmail:
+			hBuf =  StringLoader::LoadLC(R_ASP_PROFILENAME_EMAIL, aIndex);
+			break;
+		case EApplicationIdNote:
+			hBuf =  StringLoader::LoadLC(R_ASP_PROFILENAME_NOTE, aIndex);
+			break;
+		default:
+			hBuf =  StringLoader::LoadLC(R_QTN_APPS_NEWPROFILE, aIndex);
+			break;
+		}
+		
+	return hBuf;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetContentNameLC
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::GetContentNameLC(TInt aDataProviderId, const TDesC& aDefaultText)
+	{
+    if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_PHONEBOOK);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_CALENDAR);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_EMAIL);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_NOTE);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_SMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_MMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_NAME_BKM);
+		}
+	else
+		{
+		return aDefaultText.AllocLC();
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetContentTitleLC
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::GetContentTitleLC(TInt aDataProviderId, const TDesC& aDefaultText)
+	{
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_PHONEBOOK);
+		}
+	if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_CALENDAR);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_EMAIL);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_NOTE);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_SMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_MMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_TITLE_BKM);
+		}
+	else
+		{
+		return aDefaultText.AllocLC();
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetContentSettingLC
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::GetContentSettingLC(TInt aDataProviderId, const TDesC& aDefaultText)
+	{
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_PHONEBOOK);
+		}
+	if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_CALENDAR);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_EMAIL);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_NOTES);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_SMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_MMS);
+		}
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+    	return CAspResHandler::ReadLC(R_ASP_CONTENT_SETTING_BKM);
+		}
+	else
+		{
+		return aDefaultText.AllocLC();
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspResHandler::RemoteDatabaseHeaderId
+//
+//------------------------------------------------------------------------------
+//
+TInt CAspResHandler::RemoteDatabaseHeaderId(TInt aDataProviderId)
+	{
+	TInt ret = R_ASP_REMOTE_DATABASE;
+	
+	if (aDataProviderId == KUidNSmlAdapterContact.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_CNT;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterCalendar.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_AGN;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterEMail.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_EML;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterNote.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_NPD;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterSms.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_SMS;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterMMS.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_MMS;
+		}
+	else if (aDataProviderId == KUidNSmlAdapterBookmarks.iUid)
+		{
+		ret = R_ASP_REMOTE_DATABASE_BKM;
+		}
+		
+	return ret;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSchedule.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2481 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+
+#include "AspSchedule.h"
+#include "AspUtil.h"
+#include "AspDialogUtil.h"
+#include "AspDebug.h"
+#include "AspProfile.h"
+#include "AspLogDialog.h"
+#include "AspAutoSyncHandler.h"
+
+#include "schinfo.h" // TScheduleEntryInfo2
+#include <s32mem.h>  // RDesWriteStream
+#include <s32file.h> // RFileReadStream
+#include <bautils.h> // BaflUtils
+#include <centralrepository.h>  // CRepository
+#include <rconnmon.h>
+#include <SyncMLClientDS.h>
+
+
+
+/*******************************************************************************
+ * class CAspSchedule
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSchedule* CAspSchedule::NewL()
+    {
+    CAspSchedule* self = new (ELeave) CAspSchedule();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return(self);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspSchedule* CAspSchedule::NewLC()
+    {
+    CAspSchedule* self = new (ELeave) CAspSchedule();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    return(self);
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CAspSchedule
+// 
+// -----------------------------------------------------------------------------
+//
+CAspSchedule::CAspSchedule()
+	{
+	iSettingChanged = EFalse;
+	iSyncSessionOpen = EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ConstructL()
+    {
+    InternalizeL();
+	
+	if(iAutoSyncProfileId == KErrNotFound)
+		{
+		CreateAutoSyncProfileL();
+		}
+	
+		
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspSchedule::~CAspSchedule()
+    {
+    iList.Close();
+	CloseSyncSession();
+    }
+
+
+// ----------------------------------------------------------------------------
+// InitializeL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::InitializeL()
+    {
+    
+    FLOG( _L("CAspSchedule::InitializeL START") );
+    iError          = KErrNone;
+    iProfileId      = KErrNotFound;
+    iRoamingAllowed = EFalse;
+	iDailySyncEnabled = EFalse;
+	iPeakSyncEnabled = EFalse;
+	iOffPeakSyncEnabled = EFalse;
+	
+
+	iContentFlags = 0xFF;
+	iSyncFrequency          = EIntervalManual;
+	iSyncPeakSchedule       = EIntervalManual;
+    iSyncOffPeakSchedule    = EIntervalManual;
+
+    iPeakScheduleHandle = KErrNotFound;
+	iOffPeakScheduleHandle = KErrNotFound;
+
+	iStartPeakTimeHr		 = KStartPeakHour;
+	iStartPeakTimeMin		 = KStartPeakMin;
+	iEndPeakTimeHr         = KEndPeakHour;
+	iEndPeakTimeMin         = KEndPeakMin;
+
+	iAutoSyncProfileId = KErrNotFound;
+	iAutoSyncScheduleTimeHr = KDefaultStartHour;
+	iAutoSyncScheduleTimeMin = 0;
+
+	SetWeekdayEnabled(EMonday,    ETrue);
+   	SetWeekdayEnabled(ETuesday,   ETrue);
+   	SetWeekdayEnabled(EWednesday, ETrue);
+   	SetWeekdayEnabled(EThursday,  ETrue);
+   	SetWeekdayEnabled(EFriday,    ETrue);
+   	SetWeekdayEnabled(ESaturday,  EFalse);
+   	SetWeekdayEnabled(ESunday,    EFalse);
+
+	InitializeContentsL();
+	FLOG( _L("CAspSchedule::InitializeL END") );
+
+    }
+
+// ----------------------------------------------------------------------------
+// InitializeContentsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::InitializeContentsL()
+	{
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	param.iMode = CAspContentList::EInitDataProviders;
+	CAspContentList* asContentList = CAspContentList::NewLC(param);		
+	
+	TInt providerCount = asContentList->ProviderCount();
+	
+	for (TInt index = 0; index < providerCount; index++)
+		{
+		TAspProviderItem& provider = asContentList->ProviderItem(index);
+			
+		if (provider.iDataProviderId == KUidNSmlAdapterEMail.iUid)
+			{
+			if (MailboxExistL())
+				{
+				SetContentEnabled(index, ETrue);
+				}
+			else
+				{
+				SetContentEnabled(index, EFalse);
+				}
+			}
+		else
+			{
+			SetContentEnabled(index, ETrue);
+			}
+		
+		}
+	CleanupStack::PopAndDestroy(asContentList);
+
+
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::DoInternalizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::DoInternalizeL()
+	{
+	const TInt KMaxLength = 1024;
+	
+    HBufC8*  hBuf = HBufC8::NewLC(KMaxLength);
+    TPtr8 ptr = hBuf->Des();
+    
+    ReadRepositoryL(ERepositoryKeyBin, ptr);
+    
+    RDesReadStream stream(ptr);
+    stream.PushL();
+    
+    InternalizeL(stream);
+    
+    stream.Pop();
+    stream.Close();
+    
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::InternalizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::InternalizeL()
+	{
+	FLOG( _L("CAspSchedule::InternalizeL START") );
+	TRAPD(err, DoInternalizeL());
+	
+	if (err == KErrNoMemory || err == KErrLocked || err == KErrAlreadyExists)
+		{
+		FLOG( _L("CAspSchedule::InternalizeL Error 1:  %d"),err );
+		User::Leave(err);
+		}
+		
+	else if (err != KErrNone)
+		{
+		FLOG( _L("CAspSchedule::InternalizeL Error 2:  %d"),err );
+		ResetRepositoryL();  // settings corrupted
+	    InitializeL();
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::InternalizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::InternalizeL(RReadStream& aStream)
+	{
+	const TInt KAutoSyncSettingCount = 20;
+	
+    iList.Reset();
+    
+    // total setting count
+	TInt32 count = 0;
+	
+	TRAPD(err, count = aStream.ReadInt32L());
+	
+	if (err != KErrNone && err != KErrEof)
+		{
+		User::Leave(err);
+		}
+	
+	if (count != KAutoSyncSettingCount)
+		{
+		InitializeL(); // settings not found - use defaults
+		SaveL();
+		return;
+		}
+    
+    
+    iError                 = aStream.ReadInt32L();
+    iProfileId             = aStream.ReadInt32L();
+    iWeekdayFlags          = aStream.ReadInt32L();
+    TInt roamingAllowed    = aStream.ReadInt32L();
+
+
+	
+	iPeakScheduleHandle = aStream.ReadInt32L();
+	iOffPeakScheduleHandle = aStream.ReadInt32L();
+	iContentFlags           = aStream.ReadInt32L();
+	iSyncPeakSchedule       = aStream.ReadInt32L();
+    iSyncOffPeakSchedule    = aStream.ReadInt32L();
+	iStartPeakTimeHr		= aStream.ReadInt32L();
+	iStartPeakTimeMin		= aStream.ReadInt32L();
+	iEndPeakTimeHr          = aStream.ReadInt32L();
+	iEndPeakTimeMin         = aStream.ReadInt32L();
+	iSyncFrequency          = aStream.ReadInt32L();
+	iDailySyncEnabled 			= aStream.ReadInt32L();
+	iPeakSyncEnabled        = aStream.ReadInt32L();
+	iOffPeakSyncEnabled		= aStream.ReadInt32L();
+
+	iAutoSyncProfileId		= aStream.ReadInt32L();
+	
+	iAutoSyncScheduleTimeHr = aStream.ReadInt32L();
+	iAutoSyncScheduleTimeMin = aStream.ReadInt32L();
+	
+#ifdef _DEBUG
+    LogSettings();
+#endif
+
+    iRoamingAllowed = EFalse;
+    if (roamingAllowed)
+    	{
+    	iRoamingAllowed = ETrue;
+    	}
+
+	CheckEmailSelectionL();
+    }   
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CheckEmailSelectionL()
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::CheckEmailSelectionL()
+	{
+	TRAPD(err, OpenSyncSessionL());
+	if (err != KErrNone)
+		{
+		
+		/*OpenSynSessionL() may leave when system time is changed so that peak and off-peak syncs are
+		scheduled simulataneously.In that case also next sync time has to be updated. So a leave here should be
+		trapped and return to the time update function.	
+		*/
+		
+		FLOG( _L("Session cannot be opened now : return") );
+		return;
+		}
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	param.iMode = CAspContentList::EInitDataProviders;
+	CAspContentList* asContentList = CAspContentList::NewLC(param);		
+	
+	TInt providerCount = asContentList->ProviderCount();
+
+	TInt emailIndex = asContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+					
+	if (!MailboxExistL())
+		{
+		SetContentEnabled(emailIndex, EFalse);
+		}
+	else if (!IsAutoSyncEnabled())
+		{
+		SetContentEnabled(emailIndex, ETrue);
+		}
+
+	if (iProfileId != KErrNotFound
+		 					&& !ProtocolL())
+		{
+		SetContentEnabled(emailIndex, EFalse);
+		}
+	
+	CleanupStack::PopAndDestroy(asContentList);
+
+	}
+	
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ExternalizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ExternalizeL()
+	{
+	const TInt KMaxLength = 1024;
+	
+    HBufC8*  hBuf = HBufC8::NewLC(KMaxLength);
+    TPtr8 ptr = hBuf->Des();
+    RDesWriteStream stream(ptr);
+    stream.PushL();
+    
+    ExternalizeL(stream);
+    
+    stream.CommitL();
+    stream.Pop();
+    stream.Close();
+    
+    TRAPD (err,WriteRepositoryL(ERepositoryKeyBin, ptr));
+	User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ExternalizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ExternalizeL(RWriteStream& aStream)
+	{
+	const TInt KAutoSyncSettingCount = 20;
+	
+        
+    TInt roamingAllowed = 0;
+    if (iRoamingAllowed)
+    	{
+    	roamingAllowed = 1;
+    	}
+    
+   
+    aStream.WriteInt32L(KAutoSyncSettingCount);
+	aStream.WriteInt32L(iError);
+    aStream.WriteInt32L(iProfileId);
+    aStream.WriteInt32L(iWeekdayFlags);
+    aStream.WriteInt32L(roamingAllowed);
+
+	aStream.WriteInt32L(iPeakScheduleHandle);
+	aStream.WriteInt32L(iOffPeakScheduleHandle);
+    aStream.WriteInt32L(iContentFlags);
+	aStream.WriteInt32L(iSyncPeakSchedule);
+	aStream.WriteInt32L(iSyncOffPeakSchedule);
+	aStream.WriteInt32L(iStartPeakTimeHr);
+	aStream.WriteInt32L(iStartPeakTimeMin);
+	aStream.WriteInt32L(iEndPeakTimeHr);
+   	aStream.WriteInt32L(iEndPeakTimeMin);
+	aStream.WriteInt32L(iSyncFrequency);
+	aStream.WriteInt32L(iDailySyncEnabled);
+	aStream.WriteInt32L(iPeakSyncEnabled);
+	aStream.WriteInt32L(iOffPeakSyncEnabled);
+	aStream.WriteInt32L(iAutoSyncProfileId);
+
+    aStream.WriteInt32L(iAutoSyncScheduleTimeHr);
+	aStream.WriteInt32L(iAutoSyncScheduleTimeMin);
+
+#ifdef _DEBUG
+	LogSettings();
+#endif
+
+	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::WriteRepositoryL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::WriteRepositoryL(TInt aKey, const TDesC8& aValue)
+	{
+	const TUid KRepositoryId = KCRUidNSmlDSApp; // 0x101F9A1D
+
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Set(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ReadRepositoryL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ReadRepositoryL(TInt aKey, TDes8& aValue)
+	{
+	const TUid KRepositoryId = KCRUidNSmlDSApp;
+
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Get(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ResetRepositoryL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ResetRepositoryL()
+	{
+	const TUid KRepositoryId = KCRUidNSmlDSApp;
+
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Reset();
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SaveL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SaveL()
+	{
+	ExternalizeL();
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::PeakScheduleHandle
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::PeakScheduleHandle()
+	{
+	return iPeakScheduleHandle;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetPeakScheduleHandle
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetPeakScheduleHandle(TInt aScheduleHandle)
+	{
+	iPeakScheduleHandle = aScheduleHandle;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetPeakScheduleHandle
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::OffPeakScheduleHandle()
+	{
+	return iOffPeakScheduleHandle;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetPeakScheduleHandle
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetOffPeakScheduleHandle(TInt aScheduleHandle)
+	{
+	iOffPeakScheduleHandle = aScheduleHandle;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ProfileId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::ProfileId()
+	{
+	return iProfileId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetProfileId
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetProfileId(TInt aProfileId)
+	{
+	iProfileId = aProfileId;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::DailySyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::DailySyncEnabled()
+	{
+	return iDailySyncEnabled;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetDailySyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetDailySyncEnabled(TBool aSyncEnabled)
+	{
+	iDailySyncEnabled = aSyncEnabled;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::PeakSyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::PeakSyncEnabled()
+	{
+	return iPeakSyncEnabled;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetPeakSyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetPeakSyncEnabled(TBool aSyncEnabled)
+	{
+	iPeakSyncEnabled = aSyncEnabled;
+	}
+// -----------------------------------------------------------------------------
+// CAspSchedule::OffPeakSyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+
+TBool CAspSchedule::OffPeakSyncEnabled()
+	{
+	return iOffPeakSyncEnabled;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetOffPeakSyncEnabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetOffPeakSyncEnabled(TBool aSyncEnabled)
+	{
+	iOffPeakSyncEnabled = aSyncEnabled;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::WeekdayEnabled
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::WeekdayEnabled(TInt aWeekday)
+	{
+	TInt dayFlag = WeekdayFlag(aWeekday);
+	
+	TFlag flag(iWeekdayFlags);
+	
+	return flag.IsOn(dayFlag);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetWeekdayEnabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetWeekdayEnabled(TInt aWeekday, TInt aEnabled)
+	{
+	TInt dayFlag = WeekdayFlag(aWeekday);
+	
+	TFlag flag(iWeekdayFlags);
+	
+	if (aEnabled)
+		{
+		flag.SetOn(dayFlag);
+		}
+	else
+		{
+		flag.SetOff(dayFlag);
+		}
+	iSettingChanged = ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::WeekdayFlag
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::WeekdayFlag(TInt aWeekday)
+	{
+	TInt ret = EFlagMonday;
+	
+	switch (aWeekday)
+		{
+		case EMonday:
+		    ret = EFlagMonday;
+		    break;
+		case ETuesday:
+		    ret = EFlagTuesday;
+		    break;
+		case EWednesday:
+		    ret = EFlagWednesday;
+		    break;
+		case EThursday:
+		    ret = EFlagThursday;
+		    break;
+		case EFriday:
+		    ret = EFlagFriday;
+		    break;
+		case ESaturday:
+		    ret = EFlagSaturday;
+		    break;
+		case ESunday:
+		    ret = EFlagSunday;
+		    break;
+		default:
+		    TUtil::Panic(KErrArgument);
+		    break;
+		}
+		
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SelectedDayInfo
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SelectedDayInfo(TInt& aDayCount, TInt& aWeekday)
+	{
+	aDayCount = 0;
+
+	for (TInt i=EMonday; i<=ESunday; i++)
+		{
+		if (WeekdayEnabled(i))
+			{
+			aDayCount++;
+			aWeekday = i;
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetContentEnabled
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetContentEnabled(TInt aContent, TInt aEnabled)
+	{
+	TInt contentFlag = 1 << aContent;
+	TFlag flag(iContentFlags);
+	if (aEnabled)
+		{
+		flag.SetOn(contentFlag);
+		}
+	else
+		{
+		flag.SetOff(contentFlag);
+		}
+	iSettingChanged = ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ContentEnabled
+// 
+// -----------------------------------------------------------------------------
+//
+
+TBool CAspSchedule::ContentEnabled(TInt aContent)
+	{
+	TInt contentFlag = 1 << aContent;
+	TFlag flag(iContentFlags);
+	return flag.IsOn(contentFlag);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ContentSelectionInfo
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::ContentSelectionInfo(TInt& aContentCnt, TInt& aContent)
+	{
+	aContentCnt = 0;
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	param.iMode = CAspContentList::EInitDataProviders;
+	CAspContentList* asContentList = CAspContentList::NewLC(param);		
+	
+	//contents are saved in the sorted order of data providers
+	TInt providerCount = asContentList->ProviderCount();
+	for (TInt i= 0; i < providerCount; i++)
+		{
+		if (ContentEnabled(i))
+			{
+			aContentCnt++;
+			aContent = i;
+			}
+		}
+	CleanupStack::PopAndDestroy(asContentList);
+	
+	}	
+	
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::StartPeakTime
+//
+// -----------------------------------------------------------------------------
+//
+
+TTime CAspSchedule::StartPeakTime()
+	{
+	TDateTime time(0, EJanuary, 0, iStartPeakTimeHr, iStartPeakTimeMin, 0, 0);
+	TTime startTime(time);
+	return startTime;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetStartPeakTime
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetStartPeakTime(TTime aStartTime)
+	{
+	TDateTime startTime  = aStartTime.DateTime();
+	if (iStartPeakTimeHr != startTime.Hour() || iStartPeakTimeMin != startTime.Minute())
+		{
+		iStartPeakTimeHr = startTime.Hour();
+		iStartPeakTimeMin = startTime.Minute();
+		iSettingChanged = ETrue;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::EndPeakTime
+//
+// -----------------------------------------------------------------------------
+//
+
+
+TTime CAspSchedule::EndPeakTime()
+	{
+	TDateTime time(0, EJanuary, 0, iEndPeakTimeHr, iEndPeakTimeMin, 0, 0);
+	TTime endTime(time);
+	return endTime;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetEndPeakTime
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetEndPeakTime(TTime aEndTime)
+	{
+	TDateTime endTime  = aEndTime.DateTime();
+	
+	if (iEndPeakTimeHr != endTime.Hour() || iEndPeakTimeMin != endTime.Minute())
+		{
+		iEndPeakTimeHr = endTime.Hour();
+		iEndPeakTimeMin = endTime.Minute();
+		iSettingChanged = ETrue;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SyncFrequency
+//
+// -----------------------------------------------------------------------------
+//
+
+TInt CAspSchedule::SyncFrequency()
+	{
+	return iSyncFrequency;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetSyncFrequency
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetSyncFrequency(TInt aSchedule)
+	{
+	if (aSchedule != iSyncFrequency)
+		{
+		iSyncFrequency = aSchedule;
+		iSettingChanged = ETrue;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SyncPeakSchedule
+//
+// -----------------------------------------------------------------------------
+//
+
+TInt CAspSchedule::SyncPeakSchedule()
+	{
+	return iSyncPeakSchedule;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetSyncPeakSchedule
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetSyncPeakSchedule(TInt aSchedule)
+	{
+	if (aSchedule != iSyncPeakSchedule)
+		{
+		iSyncPeakSchedule = aSchedule;
+		iSettingChanged = ETrue;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SyncOffPeakSchedule
+//
+// -----------------------------------------------------------------------------
+//
+
+TInt CAspSchedule::SyncOffPeakSchedule()
+	{
+	return iSyncOffPeakSchedule;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetSyncOffPeakSchedule
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetSyncOffPeakSchedule(TInt aSchedule)
+	{
+	if (aSchedule != iSyncOffPeakSchedule)
+		{
+		iSyncOffPeakSchedule = aSchedule;
+		iSettingChanged = ETrue;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::AutoSyncScheduleTime
+//
+// -----------------------------------------------------------------------------
+//
+
+TTime CAspSchedule::AutoSyncScheduleTime()
+	{
+	TDateTime time(0, EJanuary, 0, iAutoSyncScheduleTimeHr, iAutoSyncScheduleTimeMin, 0, 0);
+	TTime scheduleTime(time);
+	return scheduleTime;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetAutoSyncScheduleTime
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetAutoSyncScheduleTime(TTime aSchedule)
+	{
+	TDateTime schedule  = aSchedule.DateTime();
+	
+	//To do- check value
+	if (iAutoSyncScheduleTimeHr != schedule.Hour() || iAutoSyncScheduleTimeMin != schedule.Minute())
+		{
+		iAutoSyncScheduleTimeHr = schedule.Hour();
+		iAutoSyncScheduleTimeMin = schedule.Minute();
+		iSettingChanged = ETrue;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::RoamingAllowed
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::RoamingAllowed()
+	{
+	return iRoamingAllowed;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetRoamingAllowed
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetRoamingAllowed(TBool aRoamingAllowed)
+	{
+	iRoamingAllowed = aRoamingAllowed;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::Error
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::Error()
+	{
+	return iError;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetError
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::SetError(TInt aError)
+	{
+	iError = aError;
+	}
+
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::UniversalStartTime
+//
+// ----------------------------------------------------------------------------
+//
+TTime CAspSchedule::UniversalStartTime(TInt& aStartHour)
+	{
+	// add two hours to current universal time and 
+	// set minutes to 0 (eg. 13:45 -> 15:00)
+    TTime time;
+    time.UniversalTime();
+ 
+    TTimeIntervalHours twoHours(2);
+    time += twoHours;
+	
+    TDateTime dateTime = time.DateTime();
+    dateTime.SetMinute(0);
+   	dateTime.SetSecond(0);
+	dateTime.SetMicroSecond(0);
+
+	aStartHour = dateTime.Hour();  // return start hour to caller
+	
+    TTime time2(dateTime);
+    return time2;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::LocalStartTime
+//
+// ----------------------------------------------------------------------------
+//
+TTime CAspSchedule::LocalStartTime(TInt aStartHour)
+	{
+	TTime time;
+	time.HomeTime();
+	
+	TDateTime dateTime = time.DateTime();
+	dateTime.SetMinute(0);
+	dateTime.SetSecond(0);
+	dateTime.SetMicroSecond(0);
+	dateTime.SetHour(aStartHour);
+	
+	TTime time2(dateTime); 
+	TTime now;
+	now.HomeTime();
+	if (now > time2)
+		{
+	    TTimeIntervalDays oneDay(1);
+	    time2 += oneDay;
+		}
+		
+	return time2;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::IsDaySelected
+//
+// ----------------------------------------------------------------------------
+//
+TBool CAspSchedule::IsDaySelected(TTime aTime)
+	{
+	TDay day = aTime.DayNoInWeek();
+	TBool ret = WeekdayEnabled(day);
+
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateSyncScheduleL
+// Called when any auto sync setting is changed
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::UpdateSyncScheduleL()
+	{
+	FLOG( _L("CAspSchedule::UpdateSyncScheduleL START") );
+	
+	CAspSyncSchedule* schedule = CAspSyncSchedule::NewLC();
+	
+	TInt profileId      = ProfileId();
+	TBool contentStatus = IsContentSelected();
+		    
+   	if (profileId == KErrNotFound || !contentStatus)
+		{
+		SetDailySyncEnabled(EFalse);
+		SetPeakSyncEnabled(EFalse);
+		SetOffPeakSyncEnabled(EFalse);
+		schedule->DeleteScheduleL(this);
+		CleanupStack::PopAndDestroy(schedule);
+		return;
+		}
+
+   	if (!IsAutoSyncEnabled())
+   		{
+		//Manual Sync selected ---->Delete schedule, if exists
+	 	 schedule->DeleteScheduleL(this);
+    	}
+   	else
+   		{
+   		if (iDailySyncEnabled)
+   			{
+			//Daily sync enabled ,use peak scheduling with intervals more than a day
+	  	 	schedule->DeleteScheduleL(this);
+			SetDailySyncEnabled(ETrue);
+			schedule->CreatePeakScheduleL(this);
+			}
+  		else
+   			{
+   		 	if (iPeakSyncEnabled != 0 && iOffPeakSyncEnabled ==0)
+  				{
+  				//Only peak sync enabled
+	  	 		schedule->DeleteScheduleL(this);
+				SetPeakSyncEnabled(ETrue);
+				schedule->CreatePeakScheduleL(this);
+				}
+   			else if (iPeakSyncEnabled == 0 && iOffPeakSyncEnabled !=0)
+  				{			
+  				//Only peak sync enabled
+	  			schedule->DeleteScheduleL(this);
+				SetOffPeakSyncEnabled(ETrue);
+				schedule->CreateOffPeakScheduleL(this);
+				}
+   			else if (iPeakSyncEnabled && iOffPeakSyncEnabled)
+    			{
+      			schedule->DeleteScheduleL(this);
+				SetPeakSyncEnabled(ETrue);
+				SetOffPeakSyncEnabled(ETrue);
+				schedule->CreatePeakScheduleL(this);
+      			schedule->CreateOffPeakScheduleL(this);
+				}   
+   			}
+   		}
+
+  	
+    	CleanupStack::PopAndDestroy(schedule);
+    
+#ifdef _DEBUG
+    
+    CAspSyncSchedule* s = CAspSyncSchedule::NewLC();
+    FLOG( _L("") );
+    LogScheduleL();
+    FLOG( _L("") );
+    s->LogSchedule(this);
+    FLOG( _L("") );
+    CleanupStack::PopAndDestroy(s);
+    
+#endif  //    _DEBUG 
+    
+    FLOG( _L("CAspSchedule::UpdateSyncScheduleL END") );
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateSyncSchedule
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::UpdateSyncSchedule()
+	{
+	TRAPD(err, UpdateSyncScheduleL());
+	
+	if (err != KErrNone)
+		{
+		FLOG( _L("### CAspSchedule::UpdateSyncScheduleL failed (err=%d) ###"), err );
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::GetStartTimeL
+// -Get next auto sync start time ,peak/off-peak whichever is earlier and enabled
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::GetStartTimeL(TTime& aTime, TBool aHomeTime)
+	{
+
+	CAspSyncSchedule* s = CAspSyncSchedule::NewLC();
+
+	if (iDailySyncEnabled)
+		{
+		s->GetPeakStartTimeL(this, aTime, aHomeTime);
+		}
+	else if (iPeakSyncEnabled != 0 && iOffPeakSyncEnabled ==0)
+		{
+		s->GetPeakStartTimeL(this, aTime, aHomeTime);
+		}
+	else if (iPeakSyncEnabled == 0 && iOffPeakSyncEnabled !=0)
+		{
+		s->GetOffPeakStartTimeL(this, aTime, aHomeTime);
+		}
+	else //peak & off-peak schedules enabled
+		{
+		TTime peakStart;
+		TTime offPeakStart;
+		
+		s->GetPeakStartTimeL(this, peakStart, aHomeTime);
+		s->GetOffPeakStartTimeL(this, offPeakStart, aHomeTime);
+
+		if (peakStart < offPeakStart)
+			{
+			aTime = peakStart;
+			}
+		else
+			{
+			aTime = offPeakStart;
+			}
+		}
+    CleanupStack::PopAndDestroy(s);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CanSynchronizeL
+// Check primary auto sync settings
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::CanSynchronizeL()
+	{
+	if (iProfileId == KErrNotFound && iAutoSyncProfileId == KErrNotFound)
+		{
+        FLOG( _L("CAspSchedule::CanSynchronizeL Failed :CP1") );
+		return EFalse;
+		}
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+
+	TRAPD (err, profile->OpenL(iProfileId, CAspProfile::EOpenRead, 
+	                           CAspProfile::EBaseProperties));
+	if (err == KErrNotFound)
+		{
+		SetProfileId(KErrNotFound);
+		if (iAutoSyncProfileId != KErrNotFound)
+			{
+			TRAPD (err1, profile->OpenL(iAutoSyncProfileId, CAspProfile::EOpenRead, 
+	                           CAspProfile::EBaseProperties));
+			if (err1 == KErrNotFound)
+				{
+				SetAutoSyncProfileId(KErrNotFound);
+				}
+			}		
+		UpdateSyncSchedule();
+		SaveL();
+		CleanupStack::PopAndDestroy(profile);
+		FLOG( _L("CAspSchedule::CanSynchronizeL Failed :CP2") );
+		return EFalse;
+		}
+	CleanupStack::PopAndDestroy(profile);
+
+	if (!IsContentSelected())
+		{
+		UpdateSyncSchedule();
+		SaveL();
+		FLOG( _L("CAspSchedule::CanSynchronizeL Failed :CP3") );
+		return EFalse;
+		}
+	
+	if (!IsAutoSyncEnabled())
+		{
+        FLOG( _L("CAspSchedule::CanSynchronizeL Failed :CP4") );
+		return EFalse;
+		}
+	
+	return ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::IsValidPeakScheduleL
+// Check if current time is peak
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::IsValidPeakScheduleL()
+	{
+	//convert all time values to same day and comapre
+	const TInt KPositive = 1;
+	const TInt KZero = 0;
+	const TInt KNegative = -1;
+
+	TTime startPeak = StartPeakTime();
+	TTime endPeak   = EndPeakTime();
+	
+	TInt retVal = 0;
+	TTime now;
+	now.HomeTime();
+	
+	if (!WeekdayEnabled(now.DayNoInWeek()))
+		{
+		retVal = KPositive; 
+		return retVal;
+		}
+
+	TDateTime timenow = now.DateTime();
+	TDateTime date = startPeak.DateTime();
+	TInt nowHr  = timenow.Hour();
+	TInt nowMin = timenow.Minute();
+	TInt day    = date.Day();
+
+    TDateTime time(0, EJanuary, day, nowHr, nowMin, 0, 0);
+	TTime curTime(time);
+	
+	if ( curTime >= startPeak && curTime < endPeak)
+		{
+		retVal =  KZero; //In peak period
+		}
+	else if (curTime < startPeak)
+		{
+		retVal = KPositive;
+		}
+	else if (curTime > endPeak)
+		{
+		retVal = KNegative;
+		}
+    
+    return retVal;
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::IsValidOffPeakScheduleL
+// Check if the current time off-peak
+// -----------------------------------------------------------------------------
+//
+
+TInt CAspSchedule::IsValidOffPeakScheduleL()
+	{
+	//convert all time values to same day and comapre
+	const TInt KPositive = 1;
+	const TInt KZero = 0;
+		
+	TTime startOffPeak = EndPeakTime()+ (TTimeIntervalMinutes)1;
+	TTime endOffPeak   = StartPeakTime() + (TTimeIntervalDays)1 -(TTimeIntervalMinutes)1 ;
+	TInt retVal = 0;
+	TTime now;
+	now.HomeTime();
+
+	if (!WeekdayEnabled(now.DayNoInWeek()))
+		{
+		retVal = KZero; 
+		return retVal;
+		}
+
+	TDateTime timenow = now.DateTime();
+	TDateTime date = startOffPeak.DateTime();
+	TInt nowHr  = timenow.Hour();
+	TInt nowMin = timenow.Minute();
+	TInt day    = date.Day();
+
+    TDateTime time(0, EJanuary, day, nowHr, nowMin, 0, 0);
+	TTime curTime(time);
+	
+	if (curTime < StartPeakTime() || (curTime >= startOffPeak && curTime < endOffPeak ))
+		{
+		retVal = KZero; 
+		}
+	else if (curTime < startOffPeak)
+		{
+		retVal = KPositive;		
+		}
+	
+	return retVal;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::IsValidNextPeakScheduleL
+// -Add sync interval to current time and checks if the next schedule will be in peak period.
+// -otherwise sync can be postponed until next peak start
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::IsValidNextPeakScheduleL()
+	{
+	//convert all time vakues to same day and compare
+	TTime startPeak = StartPeakTime();
+	TTime endPeak   = EndPeakTime();
+	
+	TTime now;
+	now.HomeTime();
+
+	CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+	TInt interval = SyncPeakSchedule();
+    TIntervalType intervalType = syncSchedule->IntervalType(interval);
+  	
+	TInt intervalVal = syncSchedule->Interval(interval);
+
+	if (interval == EInterval15Mins
+				|| interval == EInterval30Mins)
+		{
+		now = now + (TTimeIntervalMinutes)intervalVal;
+		}
+	else if (intervalType == EHourly)
+		{
+		now = now + (TTimeIntervalHours)intervalVal;
+		}
+		
+	CleanupStack::PopAndDestroy(syncSchedule);	
+	if (!WeekdayEnabled(now.DayNoInWeek()))
+		{
+		return EFalse;
+		}
+	TDateTime timenow = now.DateTime();
+	TDateTime date = startPeak.DateTime();
+	TInt nowHr  = timenow.Hour();
+	TInt nowMin = timenow.Minute();
+	TInt day    = date.Day();
+
+    TDateTime time(0, EJanuary, day, nowHr, nowMin, 0, 0);
+	TTime nextPeakSync(time);
+	
+	if ( nextPeakSync >= startPeak && nextPeakSync < endPeak)
+		{
+		return ETrue; //In peak period
+		}
+
+	return EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::IsValidNextOffPeakScheduleL
+// -Add sync interval to current time and checks if the next schedule will be in off-peak period.
+// -otherwise sync can be postponed until next off-peak start
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::IsValidNextOffPeakScheduleL()
+	{
+
+    TTime startOffPeak = EndPeakTime()+ (TTimeIntervalMinutes)1;
+	TTime endOffPeak   = StartPeakTime() + (TTimeIntervalDays)1 -(TTimeIntervalMinutes)1 ;
+	
+	TTime now;
+	now.HomeTime();
+
+	CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+	TInt interval = SyncOffPeakSchedule();
+    TIntervalType intervalType = syncSchedule->IntervalType(interval);
+  	
+	TInt intervalVal = syncSchedule->Interval(interval);
+
+	if (interval == EInterval15Mins
+				|| interval == EInterval30Mins)
+		{
+		now = now + (TTimeIntervalMinutes)intervalVal;
+		}
+	else if (intervalType == EHourly)
+		{
+		now = now + (TTimeIntervalHours)intervalVal;
+		}
+		
+	CleanupStack::PopAndDestroy(syncSchedule);
+
+	if (!WeekdayEnabled(now.DayNoInWeek()))
+		{
+		return ETrue;
+		}
+	
+	TDateTime timenow = now.DateTime();
+	TDateTime date = startOffPeak.DateTime();
+	TInt nowHr  = timenow.Hour();
+	TInt nowMin = timenow.Minute();
+	TInt day    = date.Day();
+
+    TDateTime time(0, EJanuary, day, nowHr, nowMin, 0, 0);
+	TTime nextOffPeakSync(time);
+
+	if (nextOffPeakSync < StartPeakTime() || (nextOffPeakSync >= startOffPeak && nextOffPeakSync < endOffPeak ))
+		{
+		return ETrue; //in off-peak period
+		}
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CreateAutoSyncProfileL
+// -Creates a hidden profile that is used for auto sync.
+// -It is created when auto sync is used for first time
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::CreateAutoSyncProfileL()
+	{
+	if (iAutoSyncProfileId != KErrNotFound)
+		{
+		return;			
+		}
+	OpenSyncSessionL();
+
+	TBuf<KBufSize> aBufName(KAutoSyncProfileName);
+	
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+
+	profile->CreateL(CAspProfile::EAllProperties);
+	CAspProfile::SetDefaultValuesL(profile);
+	profile->SetNameL(aBufName);
+	profile->SetSASyncStateL(ESmlDisableSync);
+	profile->SaveL();
+	
+	iAutoSyncProfileId = profile->ProfileId();
+	SaveL();
+	
+	CleanupStack::PopAndDestroy(profile);
+	
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::AutoSyncProfileId
+// -----------------------------------------------------------------------------
+//
+
+TInt CAspSchedule::AutoSyncProfileId()
+	{
+	return iAutoSyncProfileId;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::SetAutoSyncProfileId
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::SetAutoSyncProfileId(TInt aProfileId)
+	{
+	iAutoSyncProfileId = aProfileId;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CopyAutoSyncContentsL
+// -Copy contents selected in Automatic sync settings view to the profiles content list
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::CopyAutoSyncContentsL()
+	{
+	FLOG( _L("CAspSchedule::CopyAutoSyncContentsL START") );
+	if (iAutoSyncProfileId == KErrNotFound)
+		{
+		return;
+		}
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	
+	param.iMode = CAspContentList::EInitDataProviders;
+	CAspContentList* asContentList = CAspContentList::NewLC(param);		
+	
+	CAspProfile* profile = CAspProfile::NewLC(param);
+
+	TRAPD (err, profile->OpenL(iAutoSyncProfileId, CAspProfile::EOpenReadWrite, 
+	                           CAspProfile::EAllProperties));
+	User::LeaveIfError(err);
+
+	asContentList->SetProfile(profile);
+	asContentList->InitAllTasksL();
+		
+	TBool aEnabled;
+	
+	TInt providerCount = asContentList->ProviderCount();
+		
+	for (TInt i= 0; i < providerCount; i++)
+		{
+		if(ContentEnabled(i))
+			{
+			aEnabled = ETrue;
+			}
+		else
+			{
+			aEnabled = EFalse;
+			}
+		TAspProviderItem& provider = asContentList->ProviderItem(i);	
+		if (provider.iDataProviderId != KErrNotFound)
+			{
+			asContentList->ModifyTaskIncludedL(provider.iDataProviderId, aEnabled, KNullDesC);
+			}
+		}
+	CleanupStack::PopAndDestroy(profile);
+	CleanupStack::PopAndDestroy(asContentList);
+	FLOG( _L("CAspSchedule::CopyAutoSyncContentsL END") );
+     
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateProfileSettingsL
+// -Copy latest settings from profile selected for sync to auto sync profile.
+// -Called before every scheduled sync to get updated settings
+// -Also called when any settings changed
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::UpdateProfileSettingsL()
+	{
+	FLOG( _L("CAspSchedule::UpdateProfileSettingsL START") );
+	if (iProfileId == KErrNotFound || iAutoSyncProfileId == KErrNotFound)
+		{
+		return;
+		}
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+
+	param.iMode = CAspContentList::EInitDataProviders;
+			
+	CAspContentList* asContentList = CAspContentList::NewL(param);
+	CleanupStack::PushL(asContentList);
+	CAspContentList* contentList = CAspContentList::NewL(param);
+	CleanupStack::PushL(contentList);
+	
+    CAspProfile* selectedProfile = CAspProfile::NewLC(param);
+    selectedProfile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+
+	CAspProfile* autosyncProfile = CAspProfile::NewLC(param);
+	autosyncProfile->OpenL(iAutoSyncProfileId, CAspProfile::EOpenReadWrite, CAspProfile::EAllProperties);
+
+	autosyncProfile->CopyValuesL(selectedProfile);
+	autosyncProfile->SetSASyncStateL(ESmlDisableSync);
+	autosyncProfile->SaveL();
+
+    //Copy database names.
+    contentList->SetProfile(selectedProfile);
+	contentList->InitAllTasksL();
+	
+	TBuf<KBufSize> aLocalDatabase;
+	TBuf<KBufSize> aRemoteDatabase;
+	TInt aSyncDirection;
+	TBool aTaskEnabled;
+	
+	asContentList->SetProfile(autosyncProfile);
+	asContentList->InitAllTasksL();
+	
+	TInt providerCount = asContentList->ProviderCount();
+	
+ 	for (TInt i= 0; i < providerCount; i++)
+		{
+		TAspProviderItem& provider = asContentList->ProviderItem(i);
+			
+		contentList->ReadTaskL(provider.iDataProviderId, aLocalDatabase, aRemoteDatabase,
+		                    aTaskEnabled, aSyncDirection);
+		
+		
+		if(ContentEnabled(i))
+			{
+			aTaskEnabled = ETrue;
+			}
+		else
+			{
+			aTaskEnabled = EFalse;
+			}
+
+		if (provider.iDataProviderId == KUidNSmlAdapterEMail.iUid)
+			{
+			if (!MailboxExistL())
+				{
+				continue;
+				}
+			RSyncMLDataProvider provider;
+			TInt err;
+			TRAP(err, provider.OpenL(iSyncSession, KUidNSmlAdapterEMail.iUid));
+			aLocalDatabase = provider.DefaultDataStoreName();
+			}
+		
+		if (aTaskEnabled)
+			{		
+			TBuf<KBufSize> asLocaldb;
+			TBuf<KBufSize> asRemotedb;
+			TBool asTask;
+			TInt asDirection;
+		
+			asContentList->ReadTaskL(provider.iDataProviderId,asLocaldb,asRemotedb,
+													asTask,asDirection);
+													
+		    if (asLocaldb != aLocalDatabase || asRemotedb != aRemoteDatabase ||
+		    					asTask != aTaskEnabled || asDirection != aSyncDirection )
+		    	{
+		    	TRAPD(err,	asContentList->CreateTaskL(provider.iDataProviderId, aLocalDatabase, aRemoteDatabase,
+	                              aTaskEnabled, aSyncDirection));
+		    	User::LeaveIfError(err);
+		    	}
+			}
+	
+		}
+	CleanupStack::PopAndDestroy(autosyncProfile);
+	CleanupStack::PopAndDestroy(selectedProfile);
+	
+	CleanupStack::PopAndDestroy(contentList);
+	CleanupStack::PopAndDestroy(asContentList);
+	FLOG( _L("CAspSchedule::UpdateProfileSettingsL END") );
+	
+   }
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdatePeakSchedule
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::UpdatePeakScheduleL()
+	{
+	//Today's peak time ended ,postpone the peak scheduling until tomorrow peak start time
+	CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+    TIntervalType intervalType = syncSchedule->IntervalType(SyncPeakSchedule());
+    if(intervalType == EDaily )
+    	{
+		CleanupStack::PopAndDestroy(syncSchedule);
+		return;
+		}
+	syncSchedule->UpdatePeakScheduleL(this);
+	CleanupStack::PopAndDestroy(syncSchedule);		
+
+    }
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateOffPeakSchedule
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::UpdateOffPeakScheduleL()
+	{
+	//postpone the off-peak scheduling until tomorrow off-peak start time
+	CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+    TIntervalType intervalType = syncSchedule->IntervalType(SyncOffPeakSchedule());
+    if (intervalType == EDaily )
+    	{
+		CleanupStack::PopAndDestroy(syncSchedule);
+		return;
+		}
+	syncSchedule->UpdateOffPeakScheduleL(this);
+	CleanupStack::PopAndDestroy(syncSchedule);		
+
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::EnableSchedule
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::EnableScheduleL()
+	{
+	if ( iPeakScheduleHandle == KErrNotFound && iOffPeakScheduleHandle == KErrNotFound)
+		{
+		return;
+		}
+	CAspSyncSchedule* syncSchedule = CAspSyncSchedule::NewLC();
+	syncSchedule->EnableSchedule(this);
+	CleanupStack::PopAndDestroy(syncSchedule);		
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateOffPeakSchedule
+// -----------------------------------------------------------------------------
+//
+TIntervalType CAspSchedule::IntervalType(TInt aInterval)
+	{
+	if (aInterval == EInterval24hours
+			  || aInterval == EInterval2days
+			  || aInterval == EInterval4days
+			  || aInterval == EInterval7days
+			  || aInterval == EInterval14days
+			  || aInterval == EInterval30days)
+		{
+		return EDaily;
+		}
+		
+	return EHourly;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::MailboxExistL()
+// Return ETrue if any mail box exists, EFlase otherwise
+// ----------------------------------------------------------------------------
+//
+TBool CAspSchedule::MailboxExistL()
+	{
+	OpenSyncSessionL();
+	TBool mailboxExist = EFalse;
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	param.iMode = CAspContentList::EInitDataProviders;
+	CAspContentList* contentList = CAspContentList::NewL(param);
+	CleanupStack::PushL(contentList);
+	// get email syncml mailboxes
+   	CDesCArray* localDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	CleanupStack::PushL(localDataStores);
+	contentList->GetLocalDatabaseList(KUidNSmlAdapterEMail.iUid, localDataStores);
+
+    if (localDataStores->Count() > 0)
+   		{
+   		mailboxExist = ETrue;
+   		}
+
+	CleanupStack::PopAndDestroy(localDataStores);
+	CleanupStack::PopAndDestroy(contentList);
+
+	return mailboxExist;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::ProtocolL()
+// Return server protocol version 
+// ----------------------------------------------------------------------------
+//
+TInt CAspSchedule::ProtocolL()
+	{
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	profile->OpenL(iProfileId, CAspProfile::EOpenRead,
+                                         CAspProfile::EBaseProperties);
+	TInt protocol = profile->ProtocolVersion();
+	CleanupStack::PopAndDestroy(profile);
+	return protocol;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::IsAutoSyncEnabled()
+// Return ETrue if autosync enable ,EFalse otherwise 
+// ----------------------------------------------------------------------------
+//
+TBool CAspSchedule::IsAutoSyncEnabled()
+	{
+	if (iDailySyncEnabled || iPeakSyncEnabled || iOffPeakSyncEnabled)
+		{
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::OpenSyncSessionL
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::OpenSyncSessionL()
+	{
+	if (!iSyncSessionOpen)
+		{
+        TRAPD(err, iSyncSession.OpenL());
+        
+        if (err != KErrNone)
+        	{
+        	FLOG( _L("### CAspSchedule: RSyncMLSession::OpenL failed (%d) ###"), err );
+        	User::Leave(err);
+        	}
+
+		iSyncSessionOpen = ETrue;
+		}
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CloseSyncSession
+// -----------------------------------------------------------------------------
+//
+
+void CAspSchedule::CloseSyncSession()
+	{
+	if (iSyncSessionOpen)
+		{
+		iSyncSession.Close();
+		iSyncSessionOpen = EFalse;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::CheckMandatoryData
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspSchedule::CheckMandatoryDataL(TInt& count,TInt& firstItem)
+	{
+	FLOG( _L("CAspSchedule::CheckMandatoryDataL START") );
+	OpenSyncSessionL();
+    TAspParam param(EApplicationIdSync, &iSyncSession);
+
+    CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+    
+	param.iProfile = profile;
+	param.iMode = CAspContentList::EInitAll;
+	CAspContentList* list = CAspContentList::NewLC(param);
+
+   	TInt index = 0;
+	count = 0;
+	firstItem = 0;
+	
+	TInt providerCount = list->ProviderCount();
+	
+	for (TInt i= 0; i < providerCount; i++)
+		{
+		if (ContentEnabled(i))
+			{
+			FLOG( _L("Content Id : %d"),i );
+			TAspProviderItem& provider = list->ProviderItem(i);	
+			index = list->FindTaskIndexForProvider(provider.iDataProviderId);
+			if (index == KErrNotFound )
+				{
+				FLOG( _L("Index not found , Id : %d"),i );
+				count++;
+				if(count == 1)
+					{
+					firstItem = i;
+					}
+				continue;
+				}
+			TAspTaskItem& task = list->TaskItem(index);
+			if (provider.iDataProviderId == KUidNSmlAdapterEMail.iUid)
+				{
+				if(!task.iRemoteDatabaseDefined || !task.iLocalDatabaseDefined)
+					{
+					count++;
+					if(count == 1)
+						{
+						firstItem = i;
+						}
+					}
+				}
+			else
+				{
+				if (!task.iRemoteDatabaseDefined)
+					{
+					count++;
+					if(count == 1)
+						{
+						firstItem = i;
+						}
+					}
+				}
+			}
+			}
+		
+	CleanupStack::PopAndDestroy(list);
+	CleanupStack::PopAndDestroy(profile);
+	
+	if (count)
+		{
+		return EFalse;
+		}
+
+	FLOG( _L("CAspSchedule::CheckMandatoryDataL END") );
+	return ETrue;
+
+   }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::ShowAutoSyncLogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::ShowAutoSyncLogL()
+	{
+	FLOG( _L("CAspSchedule::ShowAutoSyncLogL START") );
+	OpenSyncSessionL();
+    TAspParam param(EApplicationIdSync, &iSyncSession);
+	param.iProfileId = iProfileId;
+
+	CAspProfile* asProfile = CAspProfile::NewLC(param);
+	asProfile->OpenL(iAutoSyncProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+	
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	profile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+
+	if (asProfile->LastSync() > profile->LastSync())
+		{
+		param.iProfileId = iAutoSyncProfileId;
+		}
+	CleanupStack::PopAndDestroy(profile);
+	CleanupStack::PopAndDestroy(asProfile);
+	
+    CAspLogDialog* dialog = CAspLogDialog::NewL(param);
+    CleanupStack::PushL(dialog);
+        
+    dialog->ShowDialogL();
+        
+    CleanupStack::PopAndDestroy(dialog);
+	FLOG( _L("CAspSchedule::ShowAutoSyncLogL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::UpdateServerIdL
+// Do server id modifications so that SAN selectes correct profile instead of hidden
+// auto sync profile.
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::UpdateServerIdL()
+	{
+	FLOG( _L("CAspSchedule::ClearAutoSyncProfileServerL START") );
+	OpenSyncSessionL();
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+		
+	CAspProfile* asprofile = CAspProfile::NewLC(param);
+	TRAPD (err, asprofile->OpenL(iAutoSyncProfileId, CAspProfile::EOpenReadWrite, 
+	                           CAspProfile::EAllProperties));
+	User::LeaveIfError(err);
+
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	TRAPD (err1, profile->OpenL(iProfileId, CAspProfile::EOpenReadWrite, 
+	                           CAspProfile::EAllProperties));
+	User::LeaveIfError(err1);
+
+	asprofile->GetServerId(iBuf);
+	profile->SetServerIdL(iBuf);
+	asprofile->SetServerIdL(KNullDesC);
+	profile->SaveL();
+	asprofile->SaveL();
+	
+	CleanupStack::PopAndDestroy(profile);
+	CleanupStack::PopAndDestroy(asprofile);
+	FLOG( _L("CAspSchedule::ClearAutoSyncProfileServerL END") );
+	}
+// -----------------------------------------------------------------------------
+// CAspSchedule::IsContentSelected
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSchedule::IsContentSelected()
+	{
+	TInt selectedContentCnt = 0;
+	TInt selectedContentIndex = 0;
+	
+	ContentSelectionInfo(selectedContentCnt, selectedContentIndex);
+	if (selectedContentCnt)
+		{
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+
+#ifdef _DEBUG
+
+void CAspSchedule::LogSettings()
+	{
+	FLOG( _L("iProfileId   %d"),iProfileId);
+	FLOG( _L("iPeakScheduleHandle   %d"),iPeakScheduleHandle);
+	FLOG( _L("iOffPeakScheduleHandle   %d"),iOffPeakScheduleHandle);
+   	FLOG( _L("iStartPeakTimeHr   %d"),iStartPeakTimeHr);
+	FLOG( _L("iStartPeakTimeMin   %d"),iStartPeakTimeMin);
+	FLOG( _L("iEndPeakTimeHr   %d"),iEndPeakTimeHr);
+	FLOG( _L("iEndPeakTimeMin   %d"),iEndPeakTimeMin);
+	FLOG( _L("iSyncPeakSchedule   %d"),iSyncPeakSchedule);
+	FLOG( _L("iSyncOffPeakSchedule   %d"),iSyncOffPeakSchedule);
+	FLOG( _L("iDailySyncEnabled   %d"),iDailySyncEnabled);
+	FLOG( _L("iPeakSyncEnabled   %d"),iPeakSyncEnabled);
+	FLOG( _L("iOffPeakSyncEnabled   %d"),iOffPeakSyncEnabled);
+    FLOG( _L("iAutoSyncProfileId   %d"),iAutoSyncProfileId);
+    FLOG( _L("iAutoSyncScheduleTimeHr   %d"),iAutoSyncScheduleTimeHr);
+    FLOG( _L("iAutoSyncScheduleTimeMin   %d"),iAutoSyncScheduleTimeMin);
+	
+	
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::LogScheduleL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::LogScheduleL()
+	{
+	TBuf<128> buf; TBuf<128> buf2;
+	
+	FLOG( _L("---- automatic sync settings ----") );
+	
+	TTime time;
+	time.HomeTime();
+    TUtil::GetDateTimeTextL(buf, time);
+    buf2.Format(_L("current time: %S"), &buf);
+    FLOG(buf2);
+    
+    if (PeakSyncEnabled())
+    	{
+    	buf = _L("Peak sync enabled");
+    	}
+   
+    FLOG(buf);
+
+	if (OffPeakSyncEnabled())
+    	{
+    	buf = _L("Off-Peak sync enabled");
+    	}
+    FLOG(buf);
+	 
+    TInt id = ProfileId();
+    FLOG(_L("profile id: %d"), id);
+    
+    LogSyncInterval();
+    LogSyncDays();
+
+#if 0   
+    if (RoamingAllowed())
+    	{
+    	buf = _L("roaming allowed: yes");
+    	}
+    else
+    	{
+    	buf = _L("roaming allowed: no");
+       	}
+    FLOG(buf);
+#endif
+    FLOG( _L("---- automatic sync settings ----") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::LogSyncDays
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::LogSyncDays()
+	{
+	TBuf<128> buf; TBuf<128> buf2;
+	
+	buf = KNullDesC;
+	
+	if (WeekdayEnabled(EMonday))
+    	{
+    	buf.Append(_L("monday "));
+    	}
+	if (WeekdayEnabled(ETuesday))
+    	{
+    	buf.Append(_L("tuesday "));
+    	}
+	if (WeekdayEnabled(EWednesday))
+    	{
+    	buf.Append(_L("wednesday "));
+    	}
+	if (WeekdayEnabled(EThursday))
+    	{
+    	buf.Append(_L("thursday "));
+    	}
+	if (WeekdayEnabled(EFriday))
+    	{
+    	buf.Append(_L("friday "));
+    	}
+	if (WeekdayEnabled(ESaturday))
+    	{
+    	buf.Append(_L("saturday "));
+    	}
+	if (WeekdayEnabled(ESunday))
+    	{
+    	buf.Append(_L("sunday "));
+    	}
+	if (buf.Length() == 0)
+    	{
+    	buf.Append(_L("none"));
+    	}
+
+    buf2.Format(_L("sync days: %S"), &buf);
+    FLOG(buf2);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::LogSyncInterval
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::LogSyncInterval()
+	{
+	TBuf<128> buf; TBuf<128> buf2;
+	
+	switch (iSyncPeakSchedule)
+		{
+		case CAspSchedule::EIntervalManual:
+		    buf = _L("Manual");
+		    break;
+		case CAspSchedule::EInterval15Mins:
+		    buf = _L("15 minutes");
+		    break;
+		case CAspSchedule::EInterval30Mins:
+		    buf = _L("30 minutes");
+		    break;
+		case CAspSchedule::EInterval1hour:
+		    buf = _L("1 hour");
+		    break;
+		case CAspSchedule::EInterval2hours:
+		    buf = _L("2 hours");
+		    break;
+		case CAspSchedule::EInterval4hours:
+		    buf = _L("4 hours");
+		    break;
+		case CAspSchedule::EInterval8hours:
+		    buf = _L("8 hours");
+		    break;
+		case CAspSchedule::EInterval12hours:
+		    buf = _L("12 hours");
+		    break;
+		case CAspSchedule::EInterval24hours:
+		    buf = _L("24 hours");
+		    break;
+		case CAspSchedule::EInterval2days:
+		    buf = _L("2 days");
+		    break;
+		case CAspSchedule::EInterval4days:
+		    buf = _L("4 days");
+		    break;
+		case CAspSchedule::EInterval7days:
+		    buf = _L("7 days");
+		    break;
+		case CAspSchedule::EInterval14days:
+		    buf = _L("14 days");
+		    break;
+		case CAspSchedule::EInterval30days:
+		    buf = _L("30 days");
+		    break;
+		default:
+		    buf = _L("unknown sync interval");
+		    break;
+		}
+		
+    buf2.Format(_L("sync interval: %S"), &buf);
+    FLOG(buf2);
+    }
+
+#endif  // _DEBUG
+
+
+#ifdef _DEBUG
+
+
+// ----------------------------------------------------------------------------
+// CAspSchedule::PrintTimeL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::PrintTimeL(TTime aTime)
+	{
+	TBuf<128> buf;
+	TUtil::GetDateTimeTextL(buf, aTime);
+	TDialogUtil::ShowInformationQueryL(buf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::TestL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::TestL()
+	{
+	TRAPD(err, DoTestL());
+	
+	if (err != KErrNone)
+		{
+	    TBuf<KBufSize> buf;
+        buf.Format(_L("TestL failed (%d)"), err);
+        TDialogUtil::ShowErrorNoteL(buf);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSchedule::DoTestL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSchedule::DoTestL()
+	{
+	const TInt KTestCount = 500;
+	
+    TInt err = KErrNone;
+    
+    ResetRepositoryL();
+    
+    CAspSchedule* s = NULL;
+    TInt count = 0;
+    for (; count<KTestCount; count++)
+    	{
+        TRAP(err, InternalizeL());
+        if (err != KErrNone)
+        	{
+        	User::Leave(err);
+        	}
+        
+        if (s)
+        	{
+      		CompareValues(s);
+        	CleanupStack::PopAndDestroy(s);
+        	s = NULL;
+        	}
+
+        TRAP(err, UpdateValuesL(count));
+        if (err != KErrNone)
+        	{
+        	User::Leave(err);
+        	}
+        
+        s = CreateCopyLC();
+        	
+        TRAP(err, ExternalizeL());
+        if (err != KErrNone)
+        	{
+        	User::Leave(err);
+        	}
+     	}
+    	
+    if (s)
+    	{
+    	CleanupStack::PopAndDestroy(s);
+    	}
+    	
+    TBuf<KBufSize> buf;
+    buf.Format(_L("centrep test ok (%d)"), count);
+    TDialogUtil::ShowErrorNoteL(buf);
+    
+    	
+	return;
+	}
+
+
+// ----------------------------------------------------------------------------
+// UpdateValuesL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::UpdateValuesL(TInt aCount)
+    {
+    TInt num = 100 * aCount;
+    TBool isEven = aCount % 2;
+    
+    iPeakScheduleHandle = num+1;
+	iOffPeakScheduleHandle = num +1;
+  
+    iError          = num+3;
+    
+    iPeakSyncEnabled = isEven;
+	iOffPeakSyncEnabled = isEven;
+    iProfileId = num+4;
+    
+    iRoamingAllowed = isEven;
+    
+	if (isEven)
+    	{
+    	SetWeekdayEnabled(EMonday, ETrue);
+    	SetWeekdayEnabled(ETuesday, ETrue);
+    	SetWeekdayEnabled(EWednesday, ETrue);
+    	SetWeekdayEnabled(EThursday, ETrue);
+    	SetWeekdayEnabled(EFriday, ETrue);
+    	SetWeekdayEnabled(ESaturday, EFalse);
+    	SetWeekdayEnabled(ESunday, EFalse);
+    	}
+    else
+    	{
+    	SetWeekdayEnabled(EMonday, EFalse);
+    	SetWeekdayEnabled(ETuesday, EFalse);
+    	SetWeekdayEnabled(EWednesday, EFalse);
+    	SetWeekdayEnabled(EThursday, EFalse);
+    	SetWeekdayEnabled(EFriday, EFalse);
+    	SetWeekdayEnabled(ESaturday, ETrue);
+    	SetWeekdayEnabled(ESunday, ETrue);
+    	}
+    }
+
+
+// ----------------------------------------------------------------------------
+// CreateCopyLC
+//
+// ----------------------------------------------------------------------------
+//
+CAspSchedule* CAspSchedule::CreateCopyLC()
+    {
+    CAspSchedule* s = CAspSchedule::NewL();
+    CleanupStack::PushL(s);
+    
+    s->iPeakScheduleHandle = iPeakScheduleHandle;
+	s->iOffPeakScheduleHandle = iOffPeakScheduleHandle;
+    s->iError = iError;
+    s->SetProfileId(ProfileId());
+    s->SetPeakSyncEnabled(PeakSyncEnabled());
+    s->SetRoamingAllowed(RoamingAllowed());
+    
+    
+    TBool enabled = EFalse;
+    if (WeekdayEnabled(EMonday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(EMonday, enabled);    	
+    	
+    enabled = EFalse;
+    if (WeekdayEnabled(ETuesday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(ETuesday, enabled);    	
+    
+    enabled = EFalse;
+    if (WeekdayEnabled(EWednesday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(EWednesday, enabled);    	
+    
+    enabled = EFalse;
+    if (WeekdayEnabled(EThursday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(EThursday, enabled);    	
+    
+    enabled = EFalse;
+    if (WeekdayEnabled(EFriday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(EFriday, enabled);
+    
+    enabled = EFalse;
+    if (WeekdayEnabled(ESaturday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(ESaturday, enabled);    	
+    
+    enabled = EFalse;
+    if (WeekdayEnabled(ESunday))
+    	{
+        enabled = ETrue;    	
+    	}
+    s->SetWeekdayEnabled(ESunday, enabled);
+    
+    return s;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CompareValues
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::CompareValues(CAspSchedule* aSchedule)
+    {
+    CAspSchedule* s = aSchedule;
+    
+    AssertEqual(s->PeakScheduleHandle(), PeakScheduleHandle());
+    AssertEqual(s->OffPeakScheduleHandle(), OffPeakScheduleHandle());
+    AssertEqual(s->Error(), Error());
+    AssertEqual(s->ProfileId(), ProfileId());
+
+	AssertEqual(s->PeakSyncEnabled(), PeakSyncEnabled());
+	AssertEqual(s->OffPeakSyncEnabled(), OffPeakSyncEnabled());
+   
+    AssertEqual(s->RoamingAllowed(), RoamingAllowed());
+    
+    AssertEqual(s->iWeekdayFlags, iWeekdayFlags);    
+  
+    AssertEqual(s->WeekdayEnabled(EMonday), WeekdayEnabled(EMonday));
+    AssertEqual(s->WeekdayEnabled(ETuesday), WeekdayEnabled(ETuesday));
+    AssertEqual(s->WeekdayEnabled(EWednesday), WeekdayEnabled(EWednesday));
+    AssertEqual(s->WeekdayEnabled(EThursday), WeekdayEnabled(EThursday));
+    AssertEqual(s->WeekdayEnabled(EFriday), WeekdayEnabled(EFriday));
+    AssertEqual(s->WeekdayEnabled(ESaturday), WeekdayEnabled(ESaturday));
+    AssertEqual(s->WeekdayEnabled(ESunday), WeekdayEnabled(ESunday));
+    }
+
+
+// ----------------------------------------------------------------------------
+// AssertEqual
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSchedule::AssertEqual(TInt aValue1, TInt aValue2)
+    {
+    __ASSERT_DEBUG(aValue1 == aValue2, TUtil::Panic(KErrArgument));
+    }
+
+#endif  // _DEBUG
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspScheduleDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2807 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspScheduleDialog.h"
+#include "AspProfileSelectionDialog.h"
+#include "AspSchedule.h"
+#include "AspProfileWizard.h"
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+#include <AknIconArray.h>   // for GulArray
+#include <featmgr.h>   // FeatureManager
+
+#include "AspProfile.h"
+#include "AspContentDialog.h"
+#include "AspSettingViewDialog.h"
+#include <ConnectionUiUtilities.h>    
+#include <cmdefconnvalues.h>
+#include <cmmanager.h>
+const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// AspScheduleDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspScheduleDialog::ShowDialogL(const TAspParam& aParam)
+	{
+	CAspScheduleDialog* dialog = CAspScheduleDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_AUTO_SYNC_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspScheduleDialog* CAspScheduleDialog::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspScheduleDialog::NewL START") );
+
+    CAspScheduleDialog* self = new (ELeave) CAspScheduleDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspScheduleDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::CAspScheduleDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspScheduleDialog::CAspScheduleDialog(const TAspParam& aParam)
+	{
+    iSyncSession = aParam.iSyncSession;
+    iApplicationId = aParam.iApplicationId;
+    iProfileList = aParam.iProfileList;
+    iEditMode = aParam.iMode;
+	iProfile = aParam.iProfile;
+	iContentList = aParam.iContentList;
+	iSchedule = aParam.iSchedule;
+
+	iDoCleanUp = EFalse;
+	           
+	__ASSERT_ALWAYS(iProfileList, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::ConstructL()
+    {
+    FLOG( _L("CAspScheduleDialog::ConstructL START") );
+	
+	CAknDialog::ConstructL(R_ASP_AUTO_SYNC_DIALOG_MENU);
+
+	iResHandler = CAspResHandler::NewL();
+
+	iSettingEnforcement = TUtil::SettingEnforcementState();
+	
+	iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(KDefaultArraySize);
+
+	if (!iSchedule)
+		{
+		iDoCleanUp = ETrue;
+		iSchedule = CAspSchedule::NewL();
+		}
+    
+    iWeekdayList = iResHandler->ReadDesArrayL(R_ASP_AUTO_SYNC_DAYS_LIST);
+    iContentsList = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+    iSettingChanged = EFalse;
+
+	
+	FLOG( _L("CAspScheduleDialog::ConstructL END") );
+    }
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspScheduleDialog::~CAspScheduleDialog()
+    {
+    FLOG( _L("CAspScheduleDialog::~CAspScheduleDialog START") );
+
+	delete iResHandler;
+	
+	if (iSettingList)
+		{
+		iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+		}
+	if (iDoCleanUp)
+		{
+		delete iSchedule;
+		}
+    delete iWeekdayList;
+    delete iContentsList;
+	delete iStatusPaneHandler;
+
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	FLOG( _L("CAspScheduleDialog::~CAspScheduleDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::ActivateL
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	aContext.iContext = KDS_HLP_SETTINGS;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::HandleListBoxEventL
+// 
+// -----------------------------------------------------------------------------
+
+void CAspScheduleDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                            TListBoxEvent aEventType)
+	{
+	if( AknLayoutUtils::PenEnabled() )  
+	  {
+	   switch ( aEventType )
+        {
+         case EEventItemDoubleClicked:
+              HandleOKL();
+              break;
+         case EEventEnterKeyPressed :
+         case EEventItemClicked :
+         case EEventItemDraggingActioned :
+         case EEventPenDownOnItem :
+              break;
+         default:
+              break;
+        }
+		
+	  }
+    
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::PreLayoutDynInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAspAutoSyncDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+    
+	if(iSettingEnforcement)
+	{
+	ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,EAknSoftkeyOpen );	
+	HBufC* middleSKText = StringLoader::LoadLC( R_TEXT_SOFTKEY_EMPTY );
+
+    ButtonGroupContainer().AddCommandToStackL(
+        KMSKControlId,
+        EAknSoftkeyEmpty,
+        *middleSKText );
+    CleanupStack::PopAndDestroy( middleSKText );
+	}
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	
+	// create array of setting items (iSettingList)
+	CreateSettingsListL();
+
+	// add setting headers into listbox
+	UpdateListBoxL(iSettingListBox, iSettingList);
+	
+	if (iEditMode == EDialogModeEditMandatory)
+		{
+		TInt index = CheckMandatoryFields();
+		if (index != KErrNotFound)
+			{
+			iSettingListBox->SetCurrentItemIndexAndDraw(index);
+			}
+		}
+	
+
+	iStatusPaneHandler->SetTitleL(R_ASP_TITLE_AUTOMATIC_SYNC_SETTINGS);
+	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetIconsL()
+    {
+    if (!iSettingListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName, 
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr = iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspScheduleDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::DynInitMenuPaneL
+//
+// Called by system before menu is shown.
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane)
+	{
+    if (aResourceID != R_ASP_AUTO_SYNC_DIALOG_MENU_PANE)
+		{
+		return;
+		}
+
+	if (iSettingListBox->Model()->NumberOfItems() == 0) 
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		return;
+		}
+
+	CAspListItemData* item = GetItemForIndex(iSettingListBox->CurrentItemIndex());
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
+		}
+	
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
+		}
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAknCmdHelp:
+			{
+			
+			TUtil::LaunchHelpAppL(iEikonEnv);
+            break;
+
+			}
+
+		case EAspMenuCmdChange:
+			{				
+    		CAspListItemData* item = GetItemForIndex(iSettingListBox->CurrentItemIndex());
+
+			if (item->iItemType == CAspListItemData::ETypeListYesNo)
+				{
+				// open editor for Yes/No setting
+			/*	if (EditSettingItemListL(*item))
+					{
+					SetVisibility();
+					UpdateListBoxL(iSettingListBox, iSettingList);
+					
+					iSettingChanged = ETrue;
+					}*/
+				}				
+			else
+				{
+				HandleOKL();
+				}
+
+			break;
+			}
+		    
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:			
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel)
+		{
+    //	TRAP_IGNORE(SaveSettingsL());
+		return ETrue;
+		}
+
+	if (aButtonId == EAknSoftkeyBack)
+        {
+   #if 0
+		TInt mandatoryIndex = CheckMandatoryFields();
+		if (mandatoryIndex != KErrNotFound)
+			{
+			if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY))
+				{
+				iSettingListBox->SetCurrentItemIndexAndDraw(mandatoryIndex);
+				return EFalse; // leave dialog open
+				}
+			}
+   #endif
+		if (iSettingChanged)
+			{
+			if(!CheckPeakTime())
+				{
+				HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_INCORRECT_PEAK_TIME);
+				TDialogUtil::ShowInformationNoteL(hBuf->Des());
+				CleanupStack::PopAndDestroy(hBuf);
+				return EFalse;
+				}
+		    TRAPD(err, SaveSettingsL());
+		    if (err == KErrNone)
+			    {
+			    CheckMandatoryDataL();
+		        iSchedule->CopyAutoSyncContentsL();
+				iSchedule->UpdateProfileSettingsL();
+				iSchedule->UpdateSyncSchedule();
+			    iSchedule->SaveL(); // for saving sync schedule id
+			    iSchedule->EnableScheduleL(); 
+			    }
+			}
+		ShowAutoSyncInfoL();
+		return ETrue;
+		}
+		
+	if (aButtonId == EAknSoftkeyOpen || aButtonId == EAknSoftkeyEmpty)  // MSK
+        {
+        HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+	
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspScheduleDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,
+                                                      TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEnter:
+			case EKeyOK:
+				{
+				CAspListItemData* item = 
+				GetItemForIndex(iSettingListBox->CurrentItemIndex());
+     			if (item->iHidden == EVisibilityReadOnly)
+     				{
+     				TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+  					return EKeyWasConsumed;
+     				}
+		
+				
+				HandleOKL();
+				return EKeyWasConsumed;
+				}
+
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+            default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::CheckMandatoryFields
+//
+// Check that all mandatory fields are filled.
+//------------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::CheckMandatoryFields()
+	{ 
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+			
+		if ( item->iMandatory && item->IsEmpty() && (item->iHidden == EVisibilityNormal) )
+			{
+			return item->iIndex;
+			}
+		}
+
+    return KErrNotFound;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::HandleOKL
+//
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::HandleOKL()
+	{
+	CAspListItemData* item = GetItemForIndex(iSettingListBox->CurrentItemIndex());
+
+	if (item->iHidden == EVisibilityReadOnly)
+		{
+		if(!iSettingEnforcement)
+    	{
+     	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
+    	}
+     	else
+     	{
+     		TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);	
+     	}
+		return;
+		}
+
+	if (EditSettingItemL(*item))
+		{
+		SetVisibility();
+		UpdateListBoxL(iSettingListBox, iSettingList);
+		
+		iSettingChanged = ETrue;
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::CreateSettingsListL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::CreateSettingsListL()
+	{
+
+    AddItemL(EAspAutoSyncProfile,R_ASP_SETT_AUTO_SYNC_PROFILE);
+    AddItemL(EAspAutoSyncContents, R_ASP_SETT_AUTO_SYNC_CONTENTS);
+	AddItemL(EAspAutoSyncFrequency, R_ASP_SETT_AUTO_SYNC_FREQ);	
+    AddItemL(EAspAutoSyncPeakSchedule, R_ASP_SETT_AUTO_PEAK_SCHEDULE);
+    AddItemL(EAspAutoSyncOffPeakSchedule, R_ASP_SETT_AUTO_OFF_PEAK_SCHEDULE);
+    AddItemL(EAspAutoSyncScheduleTime, R_ASP_SETT_AUTO_SYNC_TIME);
+	AddItemL(EAspAutoSyncPeakStartTime, R_ASP_SETT_AUTO_PEAK_START);
+    AddItemL(EAspAutoSyncPeakEndTime, R_ASP_SETT_AUTO_PEAK_END);
+	AddItemL(EAspAutoSyncPeakDays, R_ASP_SETT_AUTO_SYNC_DAYS);
+
+//roaming to be implemented later
+#if 0 
+	AddItemL(EAspAutoSyncRoamingStatus, R_ASP_SETTING_AUTO_SYNC_ROAMING_STATUS);
+#endif
+
+	// write setting data into each CAspListItemData
+	TInt count=iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		InitSettingItemL((*iSettingList)[i]);
+		}
+
+	SetVisibility();  // find out what setting appear on UI
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::AddItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::AddItemL(TInt aItemId, TInt aResourceId)
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(aResourceId);
+	item->iItemId = aItemId;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::UpdateListBoxL(CEikTextListBox* aListBox,
+                                        CAspSettingList* aItemList)
+	{
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt i=0; i<count; i++ )
+		{	
+		CAspListItemData* item = (*aItemList)[i];
+		
+		TBool convert = ETrue;
+
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+			
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	iSettingListBox->HandleItemAdditionL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetVisibility()
+	{
+
+	Item(EAspAutoSyncScheduleTime)->iHidden = EVisibilityHidden;
+	Item(EAspAutoSyncPeakStartTime)->iHidden = EVisibilityHidden;
+	Item(EAspAutoSyncPeakEndTime)->iHidden = EVisibilityHidden;
+	Item(EAspAutoSyncPeakSchedule)->iHidden = EVisibilityHidden;
+	Item(EAspAutoSyncOffPeakSchedule)->iHidden = EVisibilityHidden;
+	Item(EAspAutoSyncPeakDays)->iHidden = EVisibilityHidden;
+
+	if (Item(EAspAutoSyncFrequency)->iNumberData == CAspSchedule::EManyTimesPerDay)
+		{
+		Item(EAspAutoSyncScheduleTime)->iHidden = EVisibilityHidden;
+		Item(EAspAutoSyncPeakSchedule)->iHidden = EVisibilityNormal;
+		Item(EAspAutoSyncOffPeakSchedule)->iHidden = EVisibilityNormal;
+		if (Item(EAspAutoSyncPeakSchedule)->iNumberData || 
+								Item(EAspAutoSyncOffPeakSchedule)->iNumberData)
+			{
+			Item(EAspAutoSyncPeakStartTime)->iHidden = EVisibilityNormal;
+     		Item(EAspAutoSyncPeakEndTime)->iHidden = EVisibilityNormal;
+			Item(EAspAutoSyncPeakDays)->iHidden = EVisibilityNormal;
+			}
+		}
+	if (iSchedule->IntervalType(Item(EAspAutoSyncFrequency)->iNumberData) == EDaily  )
+		{
+		Item(EAspAutoSyncScheduleTime)->iHidden = EVisibilityNormal;
+		}
+	
+	if (iEditMode == EDialogModeReadOnly || iSettingEnforcement)
+    	{
+    	SetAllReadOnly();
+    	}
+ 
+  	}
+
+
+// -----------------------------------------------------------------------------
+// CAspContentDialog::SetAllReadOnly
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetAllReadOnly()
+	{
+	TInt count = iSettingList->Count();
+
+	for (TInt i=0; i<count; i++ )
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		if (item->iHidden != EVisibilityHidden)
+			{
+			item->iHidden = EVisibilityReadOnly;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::InitSettingItemL
+// 
+// Constructs CAspListItemData for one connection setting.
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::InitSettingItemL(CAspListItemData* aItem)
+	{
+	__ASSERT_ALWAYS(aItem, TUtil::Panic(KErrGeneral));	
+	
+	iBuf = KNullDesC;  // reset common buffer
+	
+	switch (aItem->iItemId)
+		{
+
+		case EAspAutoSyncProfile:
+			{
+			if (!iSchedule->IsAutoSyncEnabled())
+				{
+				aItem->iNumberData = KErrNotFound;
+				}
+			else
+				{
+				aItem->iNumberData = iSchedule->ProfileId();
+				}
+			
+			GetProfileName(aItem->iNumberData, iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETT_VALUE_NOT_DEFINED);
+			aItem->iMandatory = ETrue;
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncProfile;
+			break;
+			}
+		case EAspAutoSyncContents:
+		    {
+			if (!iSchedule->IsAutoSyncEnabled())
+				{
+				SetDefaultContentL();
+				}
+			GetContentsNameL(iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncContent;
+			break;	
+		    }
+		case EAspAutoSyncFrequency:
+			{
+			CDesCArray* arr = GetSyncFrequencyListLC();
+			aItem->iNumberData = iSchedule->SyncFrequency();
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+															|| !iSchedule->IsAutoSyncEnabled())
+				{
+				aItem->iNumberData = CAspSchedule::EIntervalManual;
+				}
+			TInt currentSelection = GetSyncFrequencyPositionL(arr, aItem->iNumberData); 
+			aItem->SetValueL((*arr)[currentSelection]);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncFrequency;
+			CleanupStack::PopAndDestroy(arr);
+			break;
+
+			}
+		case EAspAutoSyncPeakSchedule:
+			{
+			CDesCArray* arr = GetPeakScheduleListLC();
+			aItem->iNumberData = iSchedule->SyncPeakSchedule();
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+														|| !iSchedule->IsAutoSyncEnabled())
+				{
+				aItem->iNumberData = CAspSchedule::EIntervalManual;
+				}
+			TInt currentSelection = GetPeakPositionL(arr, aItem->iNumberData); 
+			aItem->SetValueL((*arr)[currentSelection]);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncPeakSchedule;
+			CleanupStack::PopAndDestroy(arr);
+			break;
+			}
+		
+		case EAspAutoSyncOffPeakSchedule:
+			{
+			CDesCArray* arr = GetOffPeakScheduleListLC();
+			aItem->iNumberData = iSchedule->SyncOffPeakSchedule();
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+															|| !iSchedule->IsAutoSyncEnabled())
+				{
+				aItem->iNumberData = CAspSchedule::EIntervalManual;
+				}
+			TInt currentSelection = GetOffPeakPositionL(arr, aItem->iNumberData); 
+			aItem->SetValueL((*arr)[currentSelection]);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncOffPeakSchedule;
+			CleanupStack::PopAndDestroy(arr);
+			break;
+			}
+		case EAspAutoSyncScheduleTime:
+			{
+			if (iSchedule->DailySyncEnabled())
+				{
+				aItem->iTime = iSchedule->AutoSyncScheduleTime();
+				}
+			else
+				{
+				TTime currentTime;
+				currentTime.HomeTime();
+				aItem->iTime = currentTime;
+				}
+			
+			GetTimeTextL(iBuf, aItem->iTime);  
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncTime;
+			Item(EAspAutoSyncScheduleTime)->iHidden = EVisibilityHidden;
+			break;
+			}
+		case EAspAutoSyncPeakStartTime:
+			{
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+													    || !iSchedule->IsAutoSyncEnabled())
+				{
+				TDateTime time(0, EJanuary, 0, KStartPeakHour, KStartPeakMin, 0, 0);
+				TTime startTime(time);
+				aItem->iTime = time;
+				}
+			else
+				{
+				aItem->iTime = iSchedule->StartPeakTime();	
+				}
+
+			GetTimeTextL(iBuf, aItem->iTime);  
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncTime;
+			break;
+			}
+		case EAspAutoSyncPeakEndTime:
+			{
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+													    || !iSchedule->IsAutoSyncEnabled())
+				{
+				TDateTime time(0, EJanuary, 0, KEndPeakHour, KEndPeakMin, 0, 0);
+				TTime startTime(time);
+				aItem->iTime = time;
+				}
+			else
+				{
+				aItem->iTime = iSchedule->EndPeakTime();	
+				}
+			GetTimeTextL(iBuf, aItem->iTime);			
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncTime;
+			break;
+			}
+		case EAspAutoSyncPeakDays:
+			{
+			if (iSchedule->ProfileId() == KErrNotFound || !iSchedule->IsContentSelected()
+													    || !iSchedule->IsAutoSyncEnabled())
+				{
+				SetDefaultdaySelectionL();
+				}
+			GetWeekdayNameL(iBuf);
+			aItem->SetValueL(iBuf);
+			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);				
+			aItem->iResource = R_ASP_AUTO_SYNC_DAYS_LIST;
+			aItem->iItemType = CAspListItemData::ETypeAutoSyncDays;
+	   		break;
+			}		 
+		case EAspAutoSyncRoamingStatus:
+			{
+			CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_AUTO_SYNC_ROAMING_YESNO);
+    		
+    		if (iSchedule->RoamingAllowed())
+				{
+				aItem->iNumberData = EAspSettingEnabled;  // 1
+				}
+			else
+				{
+				aItem->iNumberData = EAspSettingDisabled; // 0
+				}
+
+			aItem->iResource = R_ASP_AUTO_SYNC_ROAMING_YESNO;
+			aItem->SetValueL((*arr)[aItem->iNumberData]);
+			aItem->iItemType = CAspListItemData::ETypeListYesNo;
+			
+			CleanupStack::PopAndDestroy(arr);
+            break;
+			}
+        	
+        default:
+           	TUtil::Panic(KErrGeneral);
+			break;
+	
+	  	
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::SaveSettingsL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SaveSettingsL()
+	{
+   	iBuf = KNullDesC;  // reset common buffer
+   	
+	TInt count = iSettingList->Count();
+
+	if (iSettingEnforcement)
+		{
+		return;
+		}
+	
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* item = (*iSettingList)[i];
+		
+		switch (item->iItemId)
+			{
+			case EAspAutoSyncProfile:
+				{
+				TInt oldProfile = iSchedule->ProfileId();
+				iSchedule->SetProfileId(item->iNumberData);
+				if(oldProfile != iSchedule->ProfileId())
+					{
+					iSchedule->UpdateProfileSettingsL();
+					}
+				break;
+				}
+				
+			case EAspAutoSyncContents:
+			    break;//handled in EditSettingItemContentL  
+			case EAspAutoSyncFrequency:
+				{
+				iSchedule->SetSyncFrequency(item->iNumberData);
+				if (iSchedule->IntervalType(item->iNumberData) == EDaily)
+					{
+					iSchedule->SetDailySyncEnabled(ETrue);
+					}
+				else
+					{
+					iSchedule->SetDailySyncEnabled(EFalse);	
+					}
+
+				}
+			case EAspAutoSyncPeakSchedule:
+				{
+				iSchedule->SetSyncPeakSchedule(item->iNumberData);
+				if(item->iNumberData)
+					{
+					iSchedule->SetPeakSyncEnabled(ETrue);
+					}
+				else
+					{
+					iSchedule->SetPeakSyncEnabled(EFalse);	
+					}
+				break;
+				}
+			case EAspAutoSyncOffPeakSchedule:
+				{
+				iSchedule->SetSyncOffPeakSchedule(item->iNumberData);
+			    if(item->iNumberData)
+					{
+					iSchedule->SetOffPeakSyncEnabled(ETrue);
+					}
+				else
+					{
+					iSchedule->SetOffPeakSyncEnabled(EFalse);	
+					}
+				break;
+				}
+			case EAspAutoSyncScheduleTime:
+			    iSchedule->SetAutoSyncScheduleTime(item->iTime);
+			case EAspAutoSyncPeakStartTime:
+				iSchedule->SetStartPeakTime(item->iTime);
+				break;
+			case EAspAutoSyncPeakEndTime:
+				iSchedule->SetEndPeakTime(item->iTime);
+				break;
+			case EAspAutoSyncPeakDays:
+				 break;//handled in EditSettingItemWeekdaysL
+            case EAspAutoSyncRoamingStatus:
+			    iSchedule->SetRoamingAllowed(item->iNumberData);
+			    break;
+			    
+            default:
+                break;
+			}
+		}
+
+	iSchedule->SaveL();
+	}
+	
+	
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	TInt ret = EFalse;
+	
+	switch (aItem.iItemType)
+		{
+		case CAspListItemData::ETypeText:
+			ret = EditSettingItemTextL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeAutoSyncTime:
+			ret = EditSettingItemTimeL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeAutoSyncFrequency:
+			ret = EditSettingItemSyncFrequencyL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeAutoSyncPeakSchedule:
+			ret = EditSettingItemPeakScheduleL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeAutoSyncOffPeakSchedule:
+			ret = EditSettingItemOffPeakScheduleL(aItem);
+		    break;
+		
+		case CAspListItemData::ETypeAutoSyncProfile:
+			ret = EditSettingItemProfileL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeAutoSyncContent:
+		    ret = EditSettingItemContentL(aItem);
+			break;
+		    
+		case CAspListItemData::ETypeAutoSyncDays:
+			ret = EditSettingItemWeekdaysL(aItem);
+		    break;
+
+		case CAspListItemData::ETypeListYesNo:
+			ret = EditSettingItemYesNoL(aItem);
+		    break;
+
+		default:
+		    break;
+		}
+	
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemYesNoL
+//
+// Change Yes/No value without showing radio button editor.
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemYesNoL(CAspListItemData& aItem)
+	{
+	CDesCArray* arr = iResHandler->ReadDesArrayLC(aItem.iResource);
+	
+	if (aItem.iNumberData == EAspSettingDisabled)
+		{
+		aItem.iNumberData = EAspSettingEnabled;
+		}
+	else
+		{
+		aItem.iNumberData = EAspSettingDisabled;
+		}
+	
+	
+	// store localized setting text (Yes/No)
+	aItem.SetValueL( (*arr)[aItem.iNumberData] );
+
+	CleanupStack::PopAndDestroy(arr);
+	return ETrue;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemNumberL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemNumberL(CAspListItemData& aItem)
+	{
+	TBool ret = TDialogUtil::ShowIntegerEditorL(aItem.iNumberData, aItem.Header(),
+	                         aItem.iMinValue, aItem.iMaxValue, aItem.iLatinInput);
+
+	if (ret)
+		{
+		aItem.SetValueL(aItem.iNumberData);
+		}
+
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemTextL
+//
+// Edit text setting item.
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemTextL(CAspListItemData& aItem)
+	{
+	TUtil::StrCopy(iBuf, aItem.Value());
+	
+    TBool ret = TDialogUtil::ShowTextEditorL(iBuf, aItem.Header(),
+                             aItem.iMandatory, aItem.iLatinInput, aItem.iMaxLength);
+   	if (ret)
+		{
+		aItem.SetValueL(iBuf);
+		}
+		
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemSyncFrequencyL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemSyncFrequencyL(CAspListItemData& aItem)
+	{
+	CDesCArray* arr = GetSyncFrequencyListLC();
+	TInt curSelection = GetSyncFrequencyPositionL(arr, aItem.iNumberData); 
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = SyncFrequencyL((*arr)[curSelection]); 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+
+	if (iSchedule->IntervalType(aItem.iNumberData) == EDaily
+					|| aItem.iNumberData == CAspSchedule::EIntervalManual)
+		{
+		Item(EAspAutoSyncPeakSchedule)->iNumberData = CAspSchedule::EIntervalManual;
+		GetPeakScheduleValueL(CAspSchedule::EIntervalManual, iBuf);
+		Item(EAspAutoSyncPeakSchedule)->SetValueL(iBuf);
+		Item(EAspAutoSyncOffPeakSchedule)->iNumberData = CAspSchedule::EIntervalManual;
+		GetPeakScheduleValueL(CAspSchedule::EIntervalManual, iBuf);
+		Item(EAspAutoSyncOffPeakSchedule)->SetValueL(iBuf);
+		}
+		
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemPeakScheduleL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemPeakScheduleL(CAspListItemData& aItem)
+	{
+
+	CDesCArray* arr = GetPeakScheduleListLC();
+
+	TInt curSelection = GetPeakPositionL(arr, aItem.iNumberData); 
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = PeakScheduleL((*arr)[curSelection]); 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemOffPeakScheduleL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemOffPeakScheduleL(CAspListItemData& aItem)
+	{
+	
+	CDesCArray* arr = GetOffPeakScheduleListLC();
+
+	TInt curSelection = GetOffPeakPositionL(arr, aItem.iNumberData); 
+	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
+	if (ret)
+		{
+		aItem.iNumberData = OffPeakScheduleL((*arr)[curSelection]); ; 
+		aItem.SetValueL((*arr)[curSelection]);
+		}
+	
+	CleanupStack::PopAndDestroy(arr);
+	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemProfileL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemProfileL(CAspListItemData& aItem)
+	{
+
+	TAspFilterInfo info;
+    info.iFilterType = TAspFilterInfo::EIncludeRemoteProfile;
+    CAspProfileList* remoteProfList = iProfileList->FilteredListL(info);
+    CleanupStack::PushL(remoteProfList);
+	
+	TInt asProfileId = iSchedule->AutoSyncProfileId();
+	if(asProfileId != KErrNotFound)
+		{
+		remoteProfList->Remove(asProfileId);
+		}
+    TInt curSelection = remoteProfList->ListIndex(aItem.iNumberData);
+    TInt count = remoteProfList->Count();
+   
+    CDesCArray* profileNames = new (ELeave) CDesCArrayFlat(KMaxProfileCount);
+	CleanupStack::PushL(profileNames);
+    for(TInt index = 0; index < count; ++index)
+		{
+		TAspProfileItem& item = remoteProfList->Item(index);
+		GetProfileName(item.iProfileId ,iBuf);
+		profileNames->AppendL(iBuf);
+		}
+	
+	TBool ret = TDialogUtil::ShowListEditorL(profileNames, aItem.Header(), curSelection);
+
+	if (ret)
+		{
+		TAspProfileItem& item = remoteProfList->Item(curSelection);
+		aItem.iNumberData = item.iProfileId;
+		GetProfileName(item.iProfileId, iBuf);
+		aItem.SetValueL(iBuf);
+
+		if (aItem.iNumberData != KErrNotFound)
+		{
+	    CheckAccessPointSelectionL(aItem.iNumberData);
+		}
+		}
+	CleanupStack::PopAndDestroy(profileNames);
+	CleanupStack::PopAndDestroy(remoteProfList);
+	return ret;  // ETrue or EFalse
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemWeekdaysL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::EditSettingItemWeekdaysL(CAspListItemData& aItem)
+	{
+	CAspSelectionItemList* list = new (ELeave) CAspSelectionItemList(1);
+	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
+	
+	GetWeekdaySelectionL(list);
+
+	CAknCheckBoxSettingPage* dlg = new (ELeave) CAknCheckBoxSettingPage(
+	                                   R_ASP_MULTI_SELECTION_LIST, list);
+	
+   	CleanupStack::PushL(dlg);
+    dlg->SetSettingTextL(aItem.Header());
+	CleanupStack::Pop(dlg);
+
+    TBool ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+    
+    if (ret)
+    	{
+        SetWeekdaySelectionL(list);
+        GetWeekdayNameL(iBuf);
+        aItem.SetValueL(iBuf);
+    	}
+    
+	CleanupStack::PopAndDestroy(list);
+
+   	return ret;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemTimeL
+//
+//------------------------------------------------------------------------------
+//
+//
+TBool CAspScheduleDialog::EditSettingItemTimeL(CAspListItemData& aItem)
+	{
+
+	TBool ret = TDialogUtil::ShowTimeEditorL(aItem.iTime, aItem.Header());
+	
+	if (ret)
+		{
+ 		GetTimeTextL(iBuf, aItem.iTime);
+		aItem.SetValueL(iBuf);
+		}
+
+   	return ret;
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::EditSettingItemContentL
+//
+//------------------------------------------------------------------------------
+//
+//
+TBool CAspScheduleDialog::EditSettingItemContentL(CAspListItemData& aItem)
+	{
+	
+	CAspSelectionItemList* list = new (ELeave) CAspSelectionItemList(1);
+	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
+
+	TInt emailIndex = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+	if (!iSchedule->MailboxExistL())
+		{
+		iSchedule->SetContentEnabled(emailIndex, EFalse);
+		}
+	
+	TInt profileId = Item(EAspAutoSyncProfile)->iNumberData;
+	if (profileId != KErrNotFound)
+		{
+		TAspParam param(iApplicationId, iSyncSession);
+
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		profile->OpenL(profileId, CAspProfile::EOpenRead,
+                                         CAspProfile::EBaseProperties);
+		TInt protocol = profile->ProtocolVersion();
+		CleanupStack::PopAndDestroy(profile);
+		if (protocol == EAspProtocol_1_1)
+			{
+	  		iSchedule->SetContentEnabled(emailIndex, EFalse);
+			}
+		}
+	GetContentSelectionL(list);
+	
+	//CAknCheckBoxSettingPage* dlg = new (ELeave) CAknCheckBoxSettingPage(
+	//                                   R_ASP_MULTI_SELECTION_LIST, list);
+
+	TAutoSyncSettingPageParam param;
+    param.iCommandId = EAknSoftkeyUnmark;
+   
+    param.iObserver = this;
+    
+
+	CAutoSyncCheckBoxSettingPage* dlg = new (ELeave) CAutoSyncCheckBoxSettingPage(
+	                                   R_ASP_MULTI_SELECTION_LIST, list, param);
+
+	
+   	CleanupStack::PushL(dlg);
+    dlg->SetSettingTextL(aItem.Header());
+
+	CleanupStack::Pop(dlg);
+
+    TBool ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+	
+	if (ret)
+    	{
+        SetContentSelectionL(list);
+        GetContentsNameL(iBuf);
+        aItem.SetValueL(iBuf);
+    	}
+
+	CleanupStack::PopAndDestroy(list);
+
+   	return ret;
+	
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::CheckAccessPointSelection
+// Check if the selected profile has valid access point
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::CheckAccessPointSelectionL(TInt aProfileId)
+	{
+	
+	CAspProfile* profile = NULL;
+	TAspParam param(iApplicationId, iSyncSession);
+	TBool doCleanUp = EFalse;
+
+	if (iProfile && aProfileId == iProfile->ProfileId())//setting view opened & selected same profile
+		{
+		profile = iProfile;
+		}
+	else
+		{
+		profile = CAspProfile::NewLC(param);//Automatic sync menu opened
+		TRAPD(err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite,
+                                         CAspProfile::EAllProperties));
+    	if (err == KErrLocked)
+    		{
+    		CleanupStack::PopAndDestroy(profile);
+    		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+			return;
+			}
+		doCleanUp = ETrue;
+		}
+
+	TInt accessPoint = profile->AccessPointL();
+	TAspAccessPointItem item;
+    item.iUid = accessPoint;
+	CAspAccessPointHandler* apHandler = CAspAccessPointHandler::NewL(param);
+	CleanupStack::PushL(apHandler);
+
+	TInt ret = apHandler->GetInternetApInfo(item);
+	if (ret == KErrNone)
+	   	{
+			CleanupStack::PopAndDestroy(apHandler);
+			if (doCleanUp)
+				{
+		 		CleanupStack::PopAndDestroy(profile);
+		 		}
+		return;
+	   		}
+		RCmManager cmmgr;
+		cmmgr.OpenL();
+		TCmDefConnValue defConnValue;
+		cmmgr.ReadDefConnL(defConnValue);
+		cmmgr.Close();
+		if(defConnValue.iType == ECmDefConnDestination)
+		{
+			CleanupStack::PopAndDestroy(apHandler);
+			if (doCleanUp)
+		     {
+	 		 CleanupStack::PopAndDestroy(profile);
+	 		 }
+		return;
+		}
+		
+	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_QUERY_IAP_NO_ASK_ALWAYS);
+	if (!TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
+	    {
+	  	 CleanupStack::PopAndDestroy(hBuf);
+		 CleanupStack::PopAndDestroy(apHandler);
+	  	 if (doCleanUp)
+		     {
+	 		 CleanupStack::PopAndDestroy(profile);
+	 		 }
+		 return ;// user selected "Always ask" option 
+		}
+	else
+		{
+		item.iUid2 = accessPoint;
+		TInt ret = apHandler->ShowApSelectDialogL(item);
+	
+		if (ret == CAspAccessPointHandler::EAspDialogSelect)
+			{
+			profile->SetAccessPointL(item.iUid);
+			profile->Save();
+			}
+		}	
+		
+	CleanupStack::PopAndDestroy(hBuf);
+	CleanupStack::PopAndDestroy(apHandler);
+		
+	if (doCleanUp)
+	     {
+	 	 CleanupStack::PopAndDestroy(profile);
+		 }
+	return;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetProfileName
+//
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetProfileName(TInt& aProfileId, TDes& aText)
+	{
+	aText = KNullDesC;
+	
+	TInt index = iProfileList->ListIndex(aProfileId);
+    
+    if (index == KErrNotFound)
+    	{
+    	aProfileId = KErrNotFound;
+        return; // profile does not exist	
+    	}
+    	
+    TAspProfileItem& item = iProfileList->Item(index);
+    aText = item.iProfileName;
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetWeekdayNameL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetWeekdayNameL(TDes& aText)
+	{
+	const TInt KWeekdayCount = ESunday + 1;
+	
+	aText = KNullDesC;
+	
+	TInt selectedDayCount = 0;
+	TInt selectedDayIndex = 0;
+	
+	iSchedule->SelectedDayInfo(selectedDayCount, selectedDayIndex);
+		
+	if (selectedDayCount == 1)
+		{
+		aText = (*iWeekdayList)[selectedDayIndex];
+		}
+	else if (selectedDayCount == KWeekdayCount)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETT_AUTO_SYNC_ALL_DAYS);
+		}
+	else if (selectedDayCount > 1)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETT_AUTO_SYNC_SEL_DAYS);
+		}
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetWeekdaySelectionL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetWeekdaySelectionL(CSelectionItemList* aList)
+	{
+	for (TInt i=EMonday; i<=ESunday; i++)
+		{
+		TBuf<KBufSize> buf((*iWeekdayList)[i]);
+		TBool enabled = iSchedule->WeekdayEnabled(i);
+
+        CSelectableItem* selectableItem =
+                         new (ELeave) CSelectableItem(buf, enabled);
+                         
+        CleanupStack::PushL(selectableItem);
+        selectableItem->ConstructL();
+        aList->AppendL(selectableItem);
+        CleanupStack::Pop(selectableItem);
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::SetWeekdaySelectionL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetWeekdaySelectionL(CSelectionItemList* aList)
+	{
+	TInt count = aList->Count();
+	
+	__ASSERT_DEBUG(count == ESunday + 1, TUtil::Panic(KErrGeneral));
+	
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* selectableItem = (*aList)[i];
+		TBool selected = selectableItem->SelectionStatus();
+		iSchedule->SetWeekdayEnabled(i, selected);
+		}
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::SetDefaultdaySelectionL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetDefaultdaySelectionL()
+	{
+	iSchedule->SetWeekdayEnabled(EMonday,    ETrue);
+   	iSchedule->SetWeekdayEnabled(ETuesday,   ETrue);
+   	iSchedule->SetWeekdayEnabled(EWednesday, ETrue);
+   	iSchedule->SetWeekdayEnabled(EThursday,  ETrue);
+   	iSchedule->SetWeekdayEnabled(EFriday,    ETrue);
+   	iSchedule->SetWeekdayEnabled(ESaturday,  EFalse);
+   	iSchedule->SetWeekdayEnabled(ESunday,    EFalse);
+	}
+
+//-----------------------------------------------------------------------------
+// CAspScheduleDialog::GetItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspScheduleDialog::GetItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+//-----------------------------------------------------------------------------
+// CAspScheduleDialog::Item
+// 
+// Find item with aItemId (TAspConnectionSettingItem).
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspScheduleDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::GetTimeTextL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetTimeTextL(TDes& aText, TTime aTime)
+	{
+	HBufC* hBuf = CAspResHandler::ReadLC(R_QTN_TIME_USUAL_WITH_ZERO);
+    aTime.FormatL(aText, *hBuf);
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetContentsNameL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetContentsNameL(TDes& aText)
+	{
+	
+	TInt contentCount = iContentList->ProviderCount();
+	
+	aText = KNullDesC;
+	
+	TInt selectedContentCnt = 0;
+	TInt selectedContentIndex = 0;
+	
+	iSchedule->ContentSelectionInfo(selectedContentCnt, selectedContentIndex);
+		
+	if (selectedContentCnt == contentCount)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETT_VALUE_ALL_CONTENTS);
+		}
+	else if (selectedContentCnt > 0)
+		{
+		CAspResHandler::ReadL(aText, R_ASP_SETT_VALUE_SELECTED_CONTENTS);
+		}
+    }
+
+
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetContentSelectionL
+// Get selected contents 
+//------------------------------------------------------------------------------
+//
+
+void CAspScheduleDialog::GetContentSelectionL(CSelectionItemList* aList)
+	{
+	
+	TInt providerCount = iContentList->ProviderCount();
+	
+	CreateContentListL();
+	for (TInt index = 0; index < providerCount; index++)
+		{
+		TBuf<KBufSize> buf((*iContentsList)[index]);
+		TBool enabled = iSchedule->ContentEnabled(index);
+
+        CSelectableItem* selectableItem =
+                         new (ELeave) CSelectableItem(buf, enabled);
+                         
+        CleanupStack::PushL(selectableItem);
+        selectableItem->ConstructL();
+        aList->AppendL(selectableItem);
+        CleanupStack::Pop(selectableItem);
+		}
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::CreateContentList
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::CreateContentListL()
+	{
+
+	TInt providerCount = iContentList->ProviderCount();
+
+	for (TInt index = 0; index < providerCount; index++)
+		{
+		HBufC* name = NULL;
+		TAspProviderItem& provider = iContentList->ProviderItem(index);
+		name = CAspResHandler::GetContentNameLC(
+		            provider.iDataProviderId, provider.iDisplayName);	
+		//iContentsList->AppendL(provider.iDisplayName);
+		iContentsList->AppendL(*name);
+		CleanupStack::PopAndDestroy();//name
+		}
+	}
+	
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::SetDefaultContentL
+// Set default content selection
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::SetDefaultContentL()
+	{
+	
+	TInt providerCount = iContentList->ProviderCount();
+	
+	for (TInt index = 0; index < providerCount; index++)
+		{
+		TAspProviderItem& provider = iContentList->ProviderItem(index);
+			
+		if (provider.iDataProviderId == KUidNSmlAdapterEMail.iUid)
+			{
+			if (iSchedule->MailboxExistL())
+				{
+				iSchedule->SetContentEnabled(index, ETrue);
+				}
+			else
+				{
+				iSchedule->SetContentEnabled(index, EFalse);
+				}
+
+			if (iSchedule->ProfileId() != KErrNotFound
+		 					&& !iSchedule->ProtocolL())
+				{
+				iSchedule->SetContentEnabled(index, EFalse);
+				}
+			}
+		else
+			{
+			iSchedule->SetContentEnabled(index, ETrue);
+			}
+		}
+	
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::SetContentSelectionL
+// Set selected contents 
+//------------------------------------------------------------------------------
+//
+	
+void CAspScheduleDialog::SetContentSelectionL(CSelectionItemList* aList)
+	{
+    
+    TInt count = aList->Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* selectableItem = (*aList)[i];
+		TBool selected = selectableItem->SelectionStatus();
+		iSchedule->SetContentEnabled(i, selected);
+		}
+    
+    }
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetSyncFrequencyListLC
+// 
+//------------------------------------------------------------------------------
+//
+
+CDesCArray* CAspScheduleDialog::GetSyncFrequencyListLC()
+	{
+	const TInt KScheduleCount = 5;
+	CDesCArray* scheduleList = new (ELeave) CDesCArrayFlat(KScheduleCount);
+	CleanupStack::PushL(scheduleList);
+
+	GetSyncFrequencyValueL(CAspSchedule::EIntervalManual, iBuf);
+	scheduleList->AppendL(iBuf);
+	
+	GetSyncFrequencyValueL(CAspSchedule::EManyTimesPerDay, iBuf);
+	scheduleList->AppendL(iBuf);
+
+	GetSyncFrequencyValueL(CAspSchedule::EInterval24hours, iBuf);
+	scheduleList->AppendL(iBuf);
+	
+	TInt keyVal;
+	TRAPD (err ,ReadRepositoryL(EKeySyncFrequency, keyVal));
+	if (err == KErrNone)
+		{
+		TUint mask = 1;
+		for(TInt schedule = 0; schedule < KScheduleCount; ++schedule)
+			{
+			TInt offsetSyncFreq = 10;
+			if (mask & keyVal)
+				{
+				offsetSyncFreq +=schedule;
+				GetSyncFrequencyValueL(offsetSyncFreq ,iBuf);
+				scheduleList->AppendL(iBuf);		
+				}
+			mask = mask << 1;
+			}
+		}
+	else
+		{
+		//defualt items in the list
+		
+		GetSyncFrequencyValueL(CAspSchedule::EInterval2days, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetSyncFrequencyValueL(CAspSchedule::EInterval7days, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetSyncFrequencyValueL(CAspSchedule::EInterval30days, iBuf);
+		scheduleList->AppendL(iBuf);
+		
+		}
+	return scheduleList;
+
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetSyncFrequencyValueL
+// 
+//------------------------------------------------------------------------------
+//
+
+void CAspScheduleDialog::GetSyncFrequencyValueL(TInt schedule, TDes& aBuf)
+	{
+	aBuf = KNullDesC;
+	
+	switch(schedule)
+		{
+		case CAspSchedule::EIntervalManual:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_SYNC_FREQ_VALUE_MANUAL);
+			break;
+		case CAspSchedule::EInterval24hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_24_HOURS);
+			break;
+		case CAspSchedule::EInterval2days:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_2_DAYS);
+			break;
+		case CAspSchedule::EInterval4days:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_4_DAYS);
+			break;
+		case CAspSchedule::EInterval7days:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_7_DAYS);
+			break;
+		case CAspSchedule::EInterval14days:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_14_DAYS);
+			break;
+		case CAspSchedule::EInterval30days:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_30_DAYS);
+			break;
+		case CAspSchedule::EManyTimesPerDay:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_SYNC_FREQ_MANY_A_DAY);
+			break;
+			
+		default:
+			break;
+		}
+		
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::PeakSchedule
+// Get sync frequency number from string
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::SyncFrequencyL(const TDesC& aBuf)
+	{
+	       		
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_SYNC_FREQ_VALUE_MANUAL);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EIntervalManual;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_SYNC_FREQ_MANY_A_DAY);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EManyTimesPerDay;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_24_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval24hours;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_2_DAYS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval2days;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_4_DAYS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval4days;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_7_DAYS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval7days;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_14_DAYS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval14days;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_30_DAYS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval30days;
+			}
+		
+	   	
+    	return KErrNotFound;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::GetSyncFrequencyPositionL
+// Get position of selected interval from the interval list
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::GetSyncFrequencyPositionL(CDesCArray* arr, TInt aInterval)
+	{
+	const TInt KScheduleCount = 8;
+	for (TInt i=0; i < KScheduleCount; i++)
+		{
+		if(aInterval == SyncFrequencyL((*arr)[i]))
+		return i;
+		}
+	return KErrNotFound;
+
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetPeakScheduleListLC
+// 
+//------------------------------------------------------------------------------
+//
+
+CDesCArray* CAspScheduleDialog::GetPeakScheduleListLC()
+	{
+	const TInt KScheduleCount = 7;
+	CDesCArray* scheduleList = new (ELeave) CDesCArrayFlat(KScheduleCount);
+	CleanupStack::PushL(scheduleList);
+
+	GetPeakScheduleValueL(CAspSchedule::EIntervalManual, iBuf);
+	scheduleList->AppendL(iBuf);
+
+	TInt keyVal;
+	TRAPD (err,	ReadRepositoryL(EKeyPeakSyncInterval, keyVal));
+	if (err == KErrNone)
+		{
+		TUint mask = 1;
+		for(TInt schedule = 1; schedule <= KScheduleCount; ++schedule)
+			{
+			if (mask & keyVal)
+				{
+				GetPeakScheduleValueL(schedule ,iBuf);
+				scheduleList->AppendL(iBuf);		
+				}
+			mask = mask << 1;
+			}
+		}
+	else
+		{
+		GetPeakScheduleValueL(CAspSchedule::EInterval15Mins, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetPeakScheduleValueL(CAspSchedule::EInterval1hour, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetPeakScheduleValueL(CAspSchedule::EInterval2hours, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetPeakScheduleValueL(CAspSchedule::EInterval4hours, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetPeakScheduleValueL(CAspSchedule::EInterval12hours, iBuf);
+		scheduleList->AppendL(iBuf);
+		}
+	return scheduleList;
+
+	}
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetPeakScheduleValueL
+// 
+//------------------------------------------------------------------------------
+//
+
+void CAspScheduleDialog::GetPeakScheduleValueL(TInt schedule, TDes& aBuf)
+	{
+	aBuf = KNullDesC;
+	
+	switch(schedule)
+		{
+		case CAspSchedule::EIntervalManual:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_MANUAL);
+			break;
+		case CAspSchedule::EInterval15Mins:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_15_MINS);
+			break;
+		case CAspSchedule::EInterval30Mins:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_30_MINS);
+			break;
+		case CAspSchedule::EInterval1hour:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_1_HOUR);
+			break;
+		case CAspSchedule::EInterval2hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_2_HOURS);
+			break;
+		case CAspSchedule::EInterval4hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_4_HOURS);
+			break;
+		case CAspSchedule::EInterval8hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_8_HOURS);
+			break;
+		case CAspSchedule::EInterval12hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_12_HOURS);
+			break;
+				
+		default:
+			break;
+		}
+		
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetOffPeakScheduleListLC
+// 
+//------------------------------------------------------------------------------
+//
+
+CDesCArray* CAspScheduleDialog::GetOffPeakScheduleListLC()
+	{
+	const TInt KScheduleCount = 7;
+	CDesCArray* scheduleList = new (ELeave) CDesCArrayFlat(KScheduleCount);
+	CleanupStack::PushL(scheduleList);
+
+	GetOffPeakScheduleValueL(CAspSchedule::EIntervalManual, iBuf);
+	scheduleList->AppendL(iBuf);
+
+	TInt keyVal;
+	TRAPD (err,	ReadRepositoryL(EKeyOffPeakSyncInterval, keyVal));
+	if (err == KErrNone)
+		{
+		TUint mask = 1;
+		for(TInt schedule = 1; schedule <= KScheduleCount; ++schedule)
+			{
+			if (mask & keyVal)
+				{
+				GetOffPeakScheduleValueL(schedule ,iBuf);
+				scheduleList->AppendL(iBuf);		
+				}
+			mask = mask << 1;
+			}
+		}
+	else
+		{
+		GetOffPeakScheduleValueL(CAspSchedule::EInterval15Mins, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetOffPeakScheduleValueL(CAspSchedule::EInterval1hour, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetOffPeakScheduleValueL(CAspSchedule::EInterval2hours, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetOffPeakScheduleValueL(CAspSchedule::EInterval4hours, iBuf);
+		scheduleList->AppendL(iBuf);
+
+		GetOffPeakScheduleValueL(CAspSchedule::EInterval12hours, iBuf);
+		scheduleList->AppendL(iBuf);
+		}
+	
+	return scheduleList;
+	}
+
+//------------------------------------------------------------------------------
+// CAspScheduleDialog::GetOffPeakScheduleValueL
+// 
+//------------------------------------------------------------------------------
+//
+void CAspScheduleDialog::GetOffPeakScheduleValueL(TInt schedule, TDes& aBuf)
+	{
+	aBuf = KNullDesC;
+	
+	switch(schedule)
+		{
+		case CAspSchedule::EIntervalManual:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_MANUAL);
+			break;
+		case CAspSchedule::EInterval15Mins:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_15_MINS);
+			break;
+		case CAspSchedule::EInterval30Mins:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_30_MINS);
+			break;
+		case CAspSchedule::EInterval1hour:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_1_HOUR);
+			break;
+		case CAspSchedule::EInterval2hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_2_HOURS);
+			break;
+		case CAspSchedule::EInterval4hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_4_HOURS);
+			break;
+		case CAspSchedule::EInterval8hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_8_HOURS);
+			break;
+		case CAspSchedule::EInterval12hours:
+			iResHandler->ReadL(aBuf, R_ASP_SETT_AUTO_VALUE_OFF_12_HOURS);
+			break;
+		
+		default:
+			break;
+		}
+	
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::PeakScheduleL
+// Get peak schedule number from string
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::PeakScheduleL(const TDesC& aBuf)
+	{
+	       		
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_MANUAL);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EIntervalManual;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_15_MINS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval15Mins;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_30_MINS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval30Mins;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_1_HOUR);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval1hour;
+			}
+        iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_2_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval2hours;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_4_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval4hours;
+			}
+	    iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_8_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval8hours;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_12_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval12hours;
+			}
+		
+	   	
+    	return KErrNotFound;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::OffPeakScheduleL
+// Get off-peak schedule number from string
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::OffPeakScheduleL(const TDesC& aBuf)
+	{
+	       		
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_MANUAL);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EIntervalManual;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_15_MINS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval15Mins;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_30_MINS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval30Mins;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_1_HOUR);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval1hour;
+			}
+        iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_2_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval2hours;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_4_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval4hours;
+			}
+	    iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_8_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval8hours;
+			}
+		iResHandler->ReadL(iBuf, R_ASP_SETT_AUTO_VALUE_OFF_12_HOURS);
+		if(iBuf.Compare(aBuf) == 0)
+			{
+			return CAspSchedule::EInterval12hours;
+			}
+		
+		
+    	return KErrNotFound;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::GetPeakPositionL
+// Get position of selected interval from the interval list
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::GetPeakPositionL(CDesCArray* arr, TInt aInterval)
+	{
+	const TInt KScheduleCount = 6;
+	for (TInt i=0; i < KScheduleCount; i++)
+		{
+		if(aInterval == PeakScheduleL((*arr)[i]))
+		return i;
+		}
+	return KErrNotFound;
+
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::GetOffPeakPositionL
+// Get position of selected interval from the interval list
+// ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::GetOffPeakPositionL(CDesCArray* arr, TInt aInterval)
+	{
+	const TInt KScheduleCount = 6;
+	for (TInt i=0; i < KScheduleCount; i++)
+		{
+		if(aInterval == OffPeakScheduleL((*arr)[i]))
+		return i;
+		}
+	return KErrNotFound;
+
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::CheckMandatoryDataL
+// 
+// ----------------------------------------------------------------------------
+//
+
+void CAspScheduleDialog::CheckMandatoryDataL()
+	{
+	FLOG( _L("CAspScheduleDialog::CheckMandatoryDataL START") );
+	
+	if (iSchedule->ProfileId() == KErrNotFound)
+		{
+		return;
+		}
+	if (!iSchedule->IsAutoSyncEnabled())
+		{
+		return;
+		}
+	
+	TInt incompleteCount;
+	TInt firstItem;
+
+	TBool ret = iSchedule->CheckMandatoryDataL(incompleteCount, firstItem);
+	if (!ret)
+		{
+		if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_NOTE_AUTO_CONTENTS_MISSING_SETTINGS))
+			{
+			return ; 
+			}
+
+		TAspParam param(iApplicationId, iSyncSession);
+			
+		TBool doCleanUp = EFalse;
+
+		CAspProfile* profile = NULL;
+		TInt aProfileId = iSchedule->ProfileId();
+
+		if (iProfile && (aProfileId == iProfile->ProfileId()))//setting view opened & selected same profile
+			{
+			profile = iProfile;
+			}
+		else
+			{
+			profile = CAspProfile::NewLC(param);//Automatic sync menu opened
+			TRAPD(err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite,
+                                         CAspProfile::EAllProperties));
+		 
+    		if (err == KErrLocked)
+    			{
+    			CleanupStack::PopAndDestroy(profile);
+    			TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+				return ;
+				}
+			doCleanUp = ETrue;
+			iContentList->SetProfile(profile);
+			}
+
+		TAspProviderItem& provider = iContentList->ProviderItem(firstItem);	
+		param.iProfile = profile;
+		param.iContentList = iContentList;
+		param.iDataProviderId = provider.iDataProviderId;
+		param.iProfileList = iProfileList;
+		param.iMode = iEditMode;
+		param.iSchedule = iSchedule;
+		if (incompleteCount == 1)
+			{
+			CAspContentDialog::ShowDialogL(param);
+			}
+		else if (incompleteCount >1)
+			{
+			CAspSettingViewDialog::ShowDialogL(param);
+			}
+			
+		if (doCleanUp)
+			{
+			iContentList->SetProfile(NULL);
+			CleanupStack::PopAndDestroy(profile);
+			}
+
+		}
+
+	if (!CheckBearerType())
+			{
+			iSchedule->SetProfileId(KErrNotFound);
+			return;
+			}
+	if (!iSchedule->MailboxExistL() || !iSchedule->ProtocolL())
+			{
+			TInt emailIndex = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+			iSchedule->SetContentEnabled(emailIndex, EFalse);
+			}
+		
+	FLOG( _L("CAspScheduleDialog::CheckMandatoryDataL END") );
+	
+	}
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::ShowAutoSyncInfoL
+// Show next auto sync time 
+// ----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::ShowAutoSyncInfoL()
+	{
+	FLOG( _L("CAspScheduleDialog::ShowAutoSyncInfoL START") );
+	if (iSchedule->ProfileId() == KErrNotFound)
+		{
+		iSchedule->SetDailySyncEnabled(EFalse);
+		iSchedule->SetPeakSyncEnabled(EFalse);
+		iSchedule->SetOffPeakSyncEnabled(EFalse);
+        FLOG( _L("Profile Not Found") );
+		return ;
+		}
+		
+	if (!iSchedule->IsAutoSyncEnabled())
+		{
+		return;
+		}
+
+	if (iSchedule->PeakSyncEnabled() && !iSchedule->OffPeakSyncEnabled())
+		{
+		TInt dayCount = 0;
+	    TInt dayIndex = 0;
+        iSchedule->SelectedDayInfo(dayCount, dayIndex); 
+		if (dayCount == 0)
+			{
+			return;
+			}
+		}
+	if (iSchedule->PeakSyncEnabled() && (iSchedule->IsValidPeakScheduleL() == 0)
+						|| iSchedule->OffPeakSyncEnabled() && (iSchedule->IsValidOffPeakScheduleL() == 0 ))
+		{
+		return;
+		}
+	
+	TTime currentTime;
+	currentTime.HomeTime();
+	TDateTime today = currentTime.DateTime();
+	
+	TDateTime startDay = iSchedule->AutoSyncScheduleTime().DateTime();
+	
+	if (iSchedule->SyncFrequency() >= CAspSchedule::EInterval24hours)
+		{
+		if (startDay.Hour() == today.Hour() && startDay.Minute() <= today.Minute())
+			{
+			return;
+			}
+		else if (startDay.Hour() < today.Hour())
+			{
+			return;
+			}
+		}
+
+	TTime nextSync;
+    iSchedule->GetStartTimeL(nextSync ,ETrue);
+   	 
+	TDateTime syncDay = nextSync.DateTime();
+
+	TBuf<KBufSize> aTimeString;
+	if(today.Day() == syncDay.Day() && today.Month() == syncDay.Month())
+		{
+		//show next sync time
+		TBuf<KBufSize> timeFormat;
+		CAspResHandler::ReadL(timeFormat, R_QTN_TIME_USUAL_WITH_ZERO);
+		nextSync.FormatL(aTimeString, timeFormat);
+		}
+	else 
+		{
+		//show sync day
+		TBuf<KBufSize> dateFormat;
+		CAspResHandler::ReadL(dateFormat, R_QTN_DATE_USUAL_WITH_ZERO);
+		nextSync.FormatL(aTimeString, dateFormat);
+		}
+	
+	HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_SETT_AUTO_SYNC_DONE, aTimeString);
+	TDialogUtil::ShowInformationNoteL(hBuf->Des());
+
+	CleanupStack::PopAndDestroy(hBuf);
+
+	FLOG( _L("CAspScheduleDialog::ShowAutoSyncInfoL END") );
+
+   	
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::CheckBearerType
+// Return ETrue if bearer type of the selected profile is internet & EFalse otherwise
+// ----------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::CheckBearerType()
+	{
+	TAspParam param(iApplicationId, iSyncSession);
+	
+	CAspProfile* profile = CAspProfile::NewLC(param);
+
+	TInt aProfileId = iSchedule->ProfileId();
+	TRAPD(err, profile->OpenL(aProfileId, CAspProfile::EOpenRead,
+                                         CAspProfile::EAllProperties));
+	User::LeaveIfError(err);
+	if (profile->BearerType() != EAspBearerInternet)
+		{
+		CleanupStack::PopAndDestroy(profile);
+		return EFalse;
+		}
+	CleanupStack::PopAndDestroy(profile);
+	return ETrue;
+	}
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::CheckPeakTime
+// Check peak time definition
+// ----------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::CheckPeakTime()
+	{
+	if (Item(EAspAutoSyncPeakSchedule)->iNumberData == CAspSchedule::EIntervalManual
+				&& Item(EAspAutoSyncOffPeakSchedule)->iNumberData == CAspSchedule::EIntervalManual)
+		{
+		return ETrue;
+		}
+	if (Item(EAspAutoSyncPeakStartTime)->iTime >= Item(EAspAutoSyncPeakEndTime)->iTime)
+		{
+		return EFalse;
+		}
+	return ETrue;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::CheckValidityL
+// Check validity of content selected
+// ----------------------------------------------------------------------------
+//
+TBool CAspScheduleDialog::CheckValidityL()
+	{
+	TBool ret = ETrue;
+	TRAPD(err, ret = iSchedule->MailboxExistL())
+	User::LeaveIfError(err);
+	if (!ret)
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+		TInt emailIndex = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+		iSchedule->SetContentEnabled(emailIndex, EFalse);
+		return EFalse;  // no syncml mailbox
+		}
+	TInt profileId = Item(EAspAutoSyncProfile)->iNumberData;
+	if (profileId != KErrNotFound)
+		{
+		TAspParam param(iApplicationId, iSyncSession);
+
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		profile->OpenL(profileId, CAspProfile::EOpenRead,
+                                         CAspProfile::EBaseProperties);
+		TInt protocol = profile->ProtocolVersion();
+		CleanupStack::PopAndDestroy(profile);
+
+		}
+	return ETrue;
+	}
+// ----------------------------------------------------------------------------
+// CAspScheduleDialog::EmailIndex
+//  ----------------------------------------------------------------------------
+//
+TInt CAspScheduleDialog::EmailIndex()
+	{
+	TInt index = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
+	return index;
+
+	}
+	
+// -----------------------------------------------------------------------------
+// CAspScheduleDialog::ReadRepositoryL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspScheduleDialog::ReadRepositoryL(TInt aKey, TInt& aValue)
+	{
+	const TUid KRepositoryId = KCRUidNSmlDSApp;
+	const TInt KSyncFrequencyCount = 3;
+	const TInt KSyncIntervalCount = 5;
+
+    CRepository* rep = CRepository::NewLC(KRepositoryId);
+    TInt err = rep->Get(aKey, aValue);
+	User::LeaveIfError(err);
+	CleanupStack::PopAndDestroy(rep);
+    
+
+	TInt keyVal = aValue;
+	if (aKey == EKeySyncFrequency)
+		{
+		TInt intervalCount = 0;
+		TUint mask = 1;
+		TInt maxSchedules = 5;
+		for (TInt i = 0 ;i < maxSchedules ;i++)
+			{
+			if (mask & keyVal)
+				{
+				intervalCount++;
+				}
+			mask = mask << 1;
+			}
+		if (keyVal >= 0x32 || intervalCount != KSyncFrequencyCount)
+			{
+			User::Leave(KErrGeneral);
+			}
+		}
+	else if (aKey == EKeyPeakSyncInterval ||
+									aKey == EKeyOffPeakSyncInterval)
+		{
+		TInt intervalCount = 0;
+		TUint mask = 1;
+		TInt maxSchedules = 7;
+		for (TInt i = 0 ;i < maxSchedules ;i++)
+			{
+			if (mask & keyVal)
+				{
+				intervalCount++;
+				}
+			mask = mask << 1;
+			}
+		if (keyVal >= 0x128 || intervalCount != KSyncIntervalCount)
+			{
+			User::Leave(KErrGeneral);
+			}
+		}
+	}
+
+//------------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::CAspCheckBoxSettingPage
+// 
+//------------------------------------------------------------------------------
+//
+CAutoSyncCheckBoxSettingPage::CAutoSyncCheckBoxSettingPage(TInt aResourceID,
+                   CSelectionItemList* aItemArray, TAutoSyncSettingPageParam& aParam)
+                   
+ : CAknCheckBoxSettingPage(aResourceID, aItemArray), iParam(aParam)
+	{
+    iSelectionItemList = aItemArray;
+	}
+
+
+//------------------------------------------------------------------------------
+// Destructor
+// 
+//------------------------------------------------------------------------------
+//
+CAutoSyncCheckBoxSettingPage::~CAutoSyncCheckBoxSettingPage()
+	{
+	
+	}
+
+
+//------------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::ProcessCommandL
+// 
+//------------------------------------------------------------------------------
+//
+void CAutoSyncCheckBoxSettingPage::ProcessCommandL(TInt aCommandId)
+	{
+    if (aCommandId == EAknSoftkeyUnmark || aCommandId == EAknSoftkeyMark)
+    	{
+        
+        CAknSetStyleListBox* listbox = ListBoxControl();
+    	TInt index = listbox->CurrentItemIndex();
+       	CSelectableItem* selectableItem = (*iSelectionItemList)[index];
+       	TBool ret = ETrue;
+
+		UpdateCbaL(R_ASP_CBA_OK_CANCEL_MARK);
+		TInt emailIndex = iParam.iObserver->EmailIndex();
+		if (index == emailIndex)
+			{
+       		ret = iParam.iObserver->CheckValidityL();
+			}       	
+		
+		TInt count = ListBoxControl()->SelectionIndexes()->Count();
+		TInt selected = count - 1;
+		if (selectableItem->SelectionStatus())
+			{
+        	if (!selected)//all unselected
+				{
+				UpdateCbaL(R_ASP_CBA_EMPTY_CANCEL_MARK);
+				}
+			}
+		else
+			{
+			if (index == emailIndex && !ret && !count)
+				{
+				UpdateCbaL(R_ASP_CBA_EMPTY_CANCEL_MARK);
+				}
+			}
+			
+       	if (ret)
+       		{
+            CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
+            return;
+       		}
+       	else
+       		{
+       		return;	
+       		}
+    	}
+    
+        	
+    iParam.iCommandId = aCommandId; // return command id to caller
+
+    CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
+	}
+	
+
+//------------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::OfferKeyEventL
+// 
+//------------------------------------------------------------------------------
+//
+TKeyResponse CAutoSyncCheckBoxSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
+                                                 TEventCode aType)
+    {
+		    if(EKeyEnter == aKeyEvent.iCode)
+		    {
+		    	ProcessCommandL(EAknSoftkeyMark);
+		    	return EKeyWasConsumed;
+		    }
+		    return CAknCheckBoxSettingPage::OfferKeyEventL(aKeyEvent, aType);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAutoSyncCheckBoxSettingPage::UpdateCbaL(TInt aResourceId)
+    {
+    CEikButtonGroupContainer* cba = Cba();
+    cba->SetCommandSetL(aResourceId);
+    cba->DrawDeferred();
+    }
+// -----------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::DynamicInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAutoSyncCheckBoxSettingPage::DynamicInitL()
+	{
+	TInt count = iSelectionItemList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CSelectableItem* selectableItem = (*iSelectionItemList)[i];
+		TBool selected = selectableItem->SelectionStatus();
+		if (selected)
+			{
+			return;
+			}
+		}
+	UpdateCbaL(R_ASP_CBA_EMPTY_CANCEL_MARK);
+	}
+	
+// ----------------------------------------------------------------------------
+// CAutoSyncCheckBoxSettingPage::HandleListBoxEventL
+//
+// ----------------------------------------------------------------------------
+//
+
+				 
+void CAutoSyncCheckBoxSettingPage::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+{
+	TInt index = 0;
+	CSelectableItem* selectableItem;
+	if( AknLayoutUtils::PenEnabled() )  
+	{
+	  	switch(aEventType)
+	
+		{   
+			case EEventItemClicked:
+       		 	 index=aListBox->CurrentItemIndex();
+       		 	 selectableItem = (*iSelectionItemList)[index];
+       		 	 if(selectableItem->SelectionStatus())
+       		 	 {
+       		   		this->ProcessCommandL(EAknSoftkeyUnmark);	
+       		 	 }
+       		     else
+       		     {
+       			    this->ProcessCommandL(EAknSoftkeyMark);
+       		     }
+		        break;
+	 	default:
+			    break;
+		}	
+	}
+
+}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSettingDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2930 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+#include <AknIconArray.h>   // for GulArray
+#include <aknconsts.h>      // for KAvkonBitmapFile
+
+#include "AspSettingDialog.h"
+#include "AspProfileDialog.h"
+#include "AspScheduleDialog.h"
+#include "AspSchedule.h"
+#include "AspDialogUtil.h"
+#include "AspLogDialog.h"
+#include "AspUtil.h"
+#include "AspProfileWizardDialog.h"
+#include "AspDebug.h"
+#include "AspSyncUtil.rh"
+#include "AspAdvanceSettingsDialog.h"
+
+#include <aknsettingitemlist.h>
+
+#include <csxhelp/ds.hlp.hrh>  // for help text ids
+
+#ifndef RD_DSUI_TIMEDSYNC 
+#include <avkon.mbg>
+#else
+#include "AspSettingViewDialog.h"
+#endif
+#include <DataSyncInternalPSKeys.h>
+#include "AspAutoSyncHandler.h"
+#include <featmgr.h>   // FeatureManager
+
+const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+
+/******************************************************************************
+ * class CAspSettingDialog
+ ******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::ShowDialogL(TAspParam& aParam)
+	{
+    CAspSettingDialog* dialog = CAspSettingDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_SETTING_DIALOG);
+
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSettingDialog* CAspSettingDialog::NewL(TAspParam& aParam)
+    {
+    FLOG( _L("CAspSettingDialog::NewL START") );
+
+    CAspSettingDialog* self = new (ELeave) CAspSettingDialog(aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspSettingDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CAspSettingDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspSettingDialog::CAspSettingDialog(TAspParam& aParam) 
+    {
+	iApplicationId = aParam.iApplicationId;
+	iSyncSession = aParam.iSyncSession;
+	iDialogMode = aParam.iMode;
+	
+	iCurrentProfileId = KErrNotFound;
+	iCurrentProfileName = KNullDesC;
+	
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ConstructL()
+    {
+    FLOG( _L("CAspSettingDialog::ConstructL START") );
+
+    CAknDialog::ConstructL(R_ASP_SETTING_DIALOG_MENU);
+    
+    iSettingEnforcement = TUtil::SettingEnforcementState();
+
+	TAspParam param(iApplicationId, iSyncSession);
+	iProfileList = CAspProfileList::NewL(param);
+	iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+	iProfileList->Sort();
+	
+    param.iMode = CAspContentList::EInitDataProviders;
+	iContentList = CAspContentList::NewL(param);
+	
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+#ifdef RD_DSUI_TIMEDSYNC 
+
+    iTabHandler = new (ELeave) CAspTabbedNaviPaneHandler(iAvkonAppUi->StatusPane() ,this);
+	iUpdateTabGroup = ETrue;
+
+#else
+	// store current navi pane
+	iStatusPaneHandler->StoreNavipaneL();
+	
+#endif
+	
+	
+
+	iResHandler = CAspResHandler::NewL();
+
+	// start listening sync database events
+	iDbNotifier = CAspDbNotifier::NewL(param, this);
+	iDbNotifier->RequestL();
+	
+	iPopupNote = CAknInfoPopupNoteController::NewL();
+    iBearerHandler = CAspBearerHandler::NewL(param);
+
+	SetCurrentProfileL();
+	
+	FLOG( _L("CAspSettingDialog::ConstructL END") );
+    } 
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspSettingDialog::~CAspSettingDialog()
+    {
+    FLOG( _L("CAspSettingDialog::~CAspSettingDialog START") );
+
+	delete iProfileList;
+	delete iContentList;
+	
+	delete iStatusPaneHandler;
+	delete iResHandler;
+	
+	delete iDbNotifier;
+	iDbNotifier = NULL;
+	
+	delete iSyncHandler;   // created when sync is started
+	
+	if (iAvkonAppUi)
+		{
+		iAvkonAppUi->RemoveFromStack(this);
+		}
+
+	if (iPopupNote)
+		{
+    	iPopupNote->HideInfoPopupNote();
+	    delete iPopupNote;
+		}
+
+	delete iBearerHandler;
+
+#ifdef RD_DSUI_TIMEDSYNC
+
+	delete iTabHandler;
+#endif
+
+	FLOG( _L("CAspSettingDialog::~CAspSettingDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspSettingDialog::ActivateL (from CCoeControl)
+//
+// Called by system when dialog is activated
+//------------------------------------------------------------------------------
+//
+void CAspSettingDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspSettingDialog::GetHelpContext
+//
+//
+//------------------------------------------------------------------------------
+//
+void CAspSettingDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	aContext.iContext = KDS_HLP_MAIN_VIEW;    
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspSettingDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspSettingDialog::ProcessCommandL(TInt aCommandId)
+	{
+	TInt err = KErrNone;
+
+    // prevent db notifications while processing menu command
+	//Notifier()->SetDisabled(ETrue);
+	TRAP(err, DoProcessCommandL(aCommandId));
+	//Notifier()->SetDisabled(EFalse);
+	
+	if (err != KErrNone)
+		{
+		iDbNotifier->CheckUpdateEventL();
+		FLOG( _L("### CAspSettingDialog::ProcessCommandL failed (%d) ###"), err );
+		User::Leave(err);
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspSettingDialog::DoProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspSettingDialog::DoProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+        case EAspMenuCmdSync:
+			{
+			SyncProfileL();
+			break;
+			}
+		case EAspMenuCmdCopyFromServer:
+			{
+			CopyFromServerL();
+			break;
+			}
+        case EAspMenuCmdChangeProfile:
+			{
+			ChangeProfileL();
+			break;
+			}
+        case EAspMenuCmdEdit:
+			{
+			EditProfileL(EDialogModeEdit ,KErrNotFound);
+			break;
+			}
+        case EAspMenuCmdNewSet:
+			{
+			CreateProfileL();
+			break;
+			}
+		case EAspMenuCmdDelete:
+			{
+			DeleteProfileL();
+	   		break;
+			}
+		case EAspMenuCmdViewLog:
+			{
+			ShowLogDialogL();
+			break;
+			}
+		case EAspMenuCmdAutoSync:
+			{
+			ShowAutoSyncDialogL();
+			break;
+			}
+		case EAspMenuCmdAdvanceSettings:
+		    {
+		    //CAspAdvanceSettingsDialog* dialog = CAspAdvanceSettingsDialog::NewL();
+		    //CleanupStack::PushL(dialog);
+		        
+		    CAspAdvanceSettingsDialog::ShowDialogL();
+		        
+		    //CleanupStack::PopAndDestroy(dialog);
+
+		    //ShowContextMenuL(R_ASP_ROAMING_SETTINGS_CONTEXT_MENU);
+		    break;
+		    }
+        case EAspMenuCmdRoamingSettings:
+            {
+            ShowContextMenuL(R_ASP_ROAMING_SETTINGS_CONTEXT_MENU);
+            break;
+            }		
+
+		case EAspMenuCmdMark:
+		case EAspMenuCmdUnmark:
+			{
+			SaveSelectionL();
+			break;	
+			}
+    case EAknCmdHelp:
+			{
+            TUtil::LaunchHelpAppL(iEikonEnv);
+			break;
+		  }
+
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+   		
+            //
+			// Exit dialog
+			//
+			// CEikAppUi::ProcessCommandL starts CAknAppShutter that 
+			// closes all dialogs and finally calling application. Before 
+			// dialog is closed (deleted) it's OkToExitL(EEikBidCancel)
+			// is called. EEikBidCancel means OkToExitL must silently
+			// save and return ETrue.
+			//
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+
+			break;
+			}
+
+		default:
+			{
+			break;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::OkToExitL
+//
+// Called by framework before dialog is closed.
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::OkToExitL(TInt aButtonId)
+    {
+    
+	// Options/Exit, End key, Close key ('c')
+	if (aButtonId == EEikBidCancel)
+		{
+		// framework calls this when dialog must shut down
+    	return ETrue;
+		}
+
+	// Back key (cba)
+	if (aButtonId == EAknSoftkeyBack)
+        {
+		return ETrue;
+		}
+
+    // Exit key (cba)
+	if (aButtonId == EAknSoftkeyExit)
+        {
+        if (iDialogMode == EModeDialogNoWait && iApplicationId == EApplicationIdSync)
+        	{
+            //  close sync app
+        	iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+        	}
+
+        return ETrue;
+		}
+		
+	if (aButtonId == EAknSoftkeyMark || aButtonId == EAknSoftkeyUnmark 
+		|| aButtonId == EAknSoftkeyOpen)  // MSK
+        {
+
+		if (iProfileList->Count() == 0)
+			{
+			return EFalse;
+			}
+        
+        if (IsProfileLockedL(iCurrentProfileId))
+        	{
+        	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+			CancelCheckboxEvent();
+			return EFalse;
+			}
+        
+        if (iSettingEnforcement)
+			{
+			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+			return EFalse;  // leave dialog open;
+			}
+        
+        if (!CheckEmailSelection())
+        	{
+        	return EFalse;  // leave dialog open;
+        	}
+				
+		TInt ret =  SaveCurrentProfile();
+		if (ret != KErrNone)
+			{
+			CancelCheckboxEvent();
+			}
+			
+		return EFalse;  // leave dialog open
+		}
+		
+
+	return CAknDialog::OkToExitL(aButtonId);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::CancelMailBoxForEnterL
+// 
+// ----------------------------------------------------------------------------
+//
+
+void CAspSettingDialog::CancelMailBoxForEnterL()
+{
+	CListBoxView* view = iSettingListBox->View();
+	
+    TInt index = view->CurrentItemIndex();
+    TAspProviderItem& item = iContentList->ProviderItem(index);
+    TBool selected = view->ItemIsSelected(index);
+    
+    if(selected)
+    {
+        view->DeselectItem(index);
+    }
+    else
+    {
+    	view->SelectItemL(index);
+    }   
+    
+}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspSettingDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			//case EKeyOK:
+			//	{
+			//	ShowContextMenuL(R_ASP_SETTING_DIALOG_CONTEXT_MENU);
+			//	return EKeyWasConsumed;
+			//	}
+			case EKeyEnter:
+			{
+                   CancelMailBoxForEnterL();
+                   OkToExitL(EAknSoftkeyOpen);
+                   return EKeyWasConsumed;
+			}
+
+			case EKeyEscape:  // framework calls this when dialog must shut
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+        		
+			//case EStdKeyHome:
+			//	{
+			//	DeleteSelectedProfileL();
+			//	return EKeyWasConsumed;
+			//	}
+
+#ifdef RD_DSUI_TIMEDSYNC 
+
+			case EKeyLeftArrow:
+				{
+				SetPreviousProfileL();
+				return EKeyWasConsumed;
+				}
+
+			case EKeyRightArrow:
+				{
+				SetNextProfileL();
+				return EKeyWasConsumed;
+				}
+
+#endif
+            default:
+			    break;
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+
+void CAspSettingDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+        
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+/*
+void CAspSettingDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+  
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        TBuf<299> buf;
+        buf.Format(_L("(%d,%d) (%d,%d)"), mainPaneRect.iTl.iX, mainPaneRect.iTl.iY, mainPaneRect.iBr.iX, mainPaneRect.iBr.iY);
+
+        SetRect(mainPaneRect);
+        iSettingListBox->HandleResourceChange(aType);
+		DrawNow();
+  
+        
+        CAknDialog::HandleResourceChange(aType);
+        
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        //iSettingListBox->HandleResourceChange(aType);
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+		
+		
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+        
+    CCoeControl::HandleResourceChange(aType);
+    }
+*/
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetIconsL()
+    {
+    if (!iSettingListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	// NOTE: icons must be appended in correct order (TAspSettingDialogIconIndex)
+	icons->AppendL(IconL(KAknsIIDQgnPropCheckboxOn, KAvkonBitmapFile, 
+	                     EMbmAvkonQgn_prop_checkbox_on,
+	                     EMbmAvkonQgn_prop_checkbox_on_mask));
+	                     
+	icons->AppendL(IconL(KAknsIIDQgnPropCheckboxOff, KAvkonBitmapFile,
+	                     EMbmAvkonQgn_prop_checkbox_off,
+	                     EMbmAvkonQgn_prop_checkbox_off_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr = iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::ShowContextMenuL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowContextMenuL(TInt aResource)
+	{
+	if (SyncRunning())
+		{
+		return;
+		}
+	
+	//
+	// Switch to Context specific options menu,
+	// Show it and switch back to main options menu.
+	// 
+	CEikMenuBar* menuBar = iMenuBar; // from CAknDialog
+	menuBar->SetMenuTitleResourceId(aResource);
+
+
+	// TRAP displaying of menu bar.
+	// If it fails, the correct resource is set back before leave.
+	TRAPD(err, menuBar->TryDisplayMenuBarL());
+	
+	menuBar->SetMenuTitleResourceId(R_ASP_SETTING_DIALOG_MENU);
+		
+	User::LeaveIfError(err);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::PostLayoutDynInitL
+//
+// Called by framework after dialog is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::PostLayoutDynInitL()
+	{
+	#ifdef RD_DSUI_TIMEDSYNC
+	ShowAutoSyncProfileInfo();
+	#else
+  ShowCurrentProfileInfo();
+  #endif
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::PreLayoutDynInitL
+//
+// Called by framework before dialog is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknDoubleLargeStyleListBox*) ControlOrNull (EAspSettingDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+	
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	UpdateListBoxL();
+
+#ifdef RD_DSUI_TIMEDSYNC 
+
+	UpdateTabsL();
+#else
+
+	UpdateNavipaneL(iCurrentProfileName);
+#endif
+
+	
+	iSettingListBox->UpdateScrollBarsL();
+	iSettingListBox->ScrollBarFrame()->MoveVertThumbTo(0);
+
+	iStatusPaneHandler->SetTitleL(R_ASP_SETTING_DIALOG_TITLE);
+
+	SetCurrentIndex();
+//#ifdef RD_DSUI_CP_INTEGRATION
+	TBool flag = CEikonEnv::Static()->StartedAsServerApp() ;
+	if (flag || iApplicationId != EApplicationIdSync)
+/*#else
+	if (iApplicationId != EApplicationIdSync)
+#endif */
+		{
+		UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_MARK);
+		}
+		
+	if(iSettingEnforcement)
+	{
+		UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY);	
+   	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DynInitMenuPaneL
+//
+// Called by framework before menu is shown.
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DynInitMenuPaneL(TInt aResourceID, 	CEikMenuPane* aMenuPane)
+	{
+	TInt menu1 = R_ASP_SETTING_DIALOG_MENU_PANE;
+	TInt menu2 = R_ASP_SETTING_DIALOG_CONTEXT_MENU_PANE;
+	
+    if (aResourceID != menu1 && aResourceID != menu2)
+		{
+		return; // not one of our menus
+		}
+
+	if (aResourceID == R_ASP_SETTING_DIALOG_CONTEXT_MENU_PANE)
+		{
+		InitContextMenuL(aMenuPane); // separate handling for context menu
+		}
+	else
+		{
+		InitOptionsMenuL(aMenuPane);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::InitContextMenuL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::InitContextMenuL(CEikMenuPane* /*aMenuPane*/)
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::InitOptionsMenuL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::InitOptionsMenuL(CEikMenuPane* aMenuPane)
+	{
+	TInt profileCount = iProfileList->Count();
+	TInt providerCount = iContentList->ProviderCount();
+	TInt deletableProfileCount = iProfileList->DeletableProfileCount();
+	
+	if (providerCount == 0)  // no data providers
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdNewSet);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdEdit);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
+		return;
+    	}
+	
+	
+	// Options/Sync
+	// Options/Copy all from server
+	if (iCurrentProfileId == KErrNotFound && profileCount > 0)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
+		}
+	if (iSettingEnforcement && profileCount == 0)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
+		}
+
+	if (iCurrentProfileId == KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
+		}
+
+	// Options/Change
+	if (profileCount == 0)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdMark);
+	    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdUnmark);	 
+		}
+	if (profileCount == 1 && iCurrentProfileId != KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
+		}
+	
+	// Options/Edit
+	if (iCurrentProfileId == KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdEdit);
+		}
+	
+	// Options/Auto sync
+	if (iCurrentProfileId == KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
+		}
+
+	// Options/New
+	if (iSettingEnforcement)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdNewSet);
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdMark);
+	    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdUnmark);	 
+		}
+
+	// Options/Delete   
+   if (IsSyncOnGoingL(iCurrentProfileId) || iSettingEnforcement 
+   										|| deletableProfileCount == 0)
+    	{
+    	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
+     	}
+	
+	// Options/View log
+	if (iCurrentProfileId == KErrNotFound)
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
+		}
+	
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
+		}
+		
+#ifdef RD_DSUI_TIMEDSYNC 
+	if(profileCount)
+		{
+	 	//Delete active profile
+	 	TAspParam param(iApplicationId, iSyncSession);
+	 	TAspProfileItem& currentProfile = CurrentProfileL();
+	 	if(!currentProfile.iDeleteAllowed)
+	 		{
+	    	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
+			}
+	 	//Change profile option is removed
+	 	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
+	 	
+
+	 	CAspSchedule* schedule = CAspSchedule::NewLC();
+	 	TInt asProfileId = schedule->AutoSyncProfileId();
+	 	if (iCurrentProfileId == schedule->ProfileId()
+	 							&& asProfileId != KErrNotFound)
+			{
+			CAspProfile* asProfile = CAspProfile::NewLC(param);
+			asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+			if (!asProfile->IsSynced() && !currentProfile.iSynced)
+				{
+				TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
+				}
+			CleanupStack::PopAndDestroy(asProfile);
+			}
+	 	else
+			{
+			if (!currentProfile.iSynced)
+		    	{
+	        	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
+		    	}
+
+			}
+		 CleanupStack::PopAndDestroy(schedule);
+		}
+#else
+	 
+	 
+	 TAspProfileItem& profile = CurrentProfileL();
+     if (!profile.iSynced)
+		 {
+	         iProfileList->ReadProfileL(iCurrentProfileId);
+	       }
+	  
+	   if (!profile.iSynced)
+	           {
+	     TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
+		 }
+#endif
+if(!iSettingEnforcement)
+{
+	UpdateMarkMenuItem(aMenuPane);
+}
+#ifndef RD_DSUI_TIMEDSYNC
+     TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
+#endif
+
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::IsSyncOnGoing
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::IsSyncOnGoingL(TInt aProfileId)
+	{
+	TInt currentJobId = CAspProfile::CurrentJob(iSyncSession);
+	if (currentJobId != KErrNotFound)
+			{
+			RSyncMLDataSyncJob syncJob;
+			syncJob.OpenL(*iSyncSession, currentJobId);
+			if (syncJob.Profile() == aProfileId)
+				{
+				syncJob.Close();
+				return ETrue;
+				}
+			syncJob.Close();
+			}
+	return EFalse;
+	}
+
+	
+#ifdef RD_DSUI_TIMEDSYNC 
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SetNextProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetNextProfileL()
+	{
+    FLOG( _L("CAspSettingDialog::SetNextProfileL START") );
+
+	if (iProfileList->Count() == 0)
+		{
+		return;
+		}
+    
+    TInt currentIndex = iProfileList->ListIndex(iCurrentProfileId);
+    if (currentIndex == KErrNotFound)
+    	{
+    	FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
+    	
+    	User::Leave(KErrNotFound);
+    	}
+    
+    TInt newIndex = 0;
+    TInt count = iProfileList->Count();
+    if (currentIndex >= count-1)
+        {
+        newIndex = 0;
+        }
+    else
+        {
+        newIndex = currentIndex + 1;
+        }
+    TAspProfileItem& olditem = iProfileList->Item(currentIndex);        
+    TAspProfileItem& item = iProfileList->Item(newIndex);
+
+	if (item.iProfileName.Compare(KAutoSyncProfileName) == 0)
+			{
+			if(newIndex >= count-1)
+				{
+				newIndex = 0;
+				}
+			else
+				{
+				newIndex++;
+				}
+			TAspProfileItem& newItem = iProfileList->Item(newIndex);
+			SetCurrentProfile(newItem.iProfileId);
+			}
+	else 
+		{
+		SetCurrentProfile(item.iProfileId);
+		}
+	
+	//ShowCurrentProfileInfo();
+    UpdateListBoxL();
+	//UpdateNavipaneL(iCurrentProfileName);
+    UpdateTabsL();
+        
+    FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SetPreviousProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetPreviousProfileL()
+	{
+    FLOG( _L("CAspSettingDialog::SetPreviousProfileL START") );
+
+	if (iProfileList->Count() == 0)
+		{
+		return;
+		}
+    
+    TInt currentIndex = iProfileList->ListIndex(iCurrentProfileId);
+    if (currentIndex == KErrNotFound)
+    	{
+    	FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
+    	
+    	User::Leave(KErrNotFound);
+    	}
+    
+    TInt newIndex = 0;
+    TInt count = iProfileList->Count();
+    if (currentIndex == 0)
+        {
+        newIndex = count - 1;
+        }
+    else
+        {
+        newIndex = currentIndex - 1;
+        }
+   
+    TAspProfileItem& item = iProfileList->Item(newIndex);
+
+	if (item.iProfileName.Compare(KAutoSyncProfileName) == 0)
+		{
+		if(newIndex == 0)
+			{
+				newIndex = count - 1;
+			}
+		else
+			{
+				newIndex--;
+			}
+			TAspProfileItem& newItem = iProfileList->Item(newIndex);
+			SetCurrentProfile(newItem.iProfileId);
+		}
+	else
+		{
+		 SetCurrentProfile(item.iProfileId);	
+		}
+
+   
+	//ShowCurrentProfileInfo();
+    UpdateListBoxL();
+	//UpdateNavipaneL(iCurrentProfileName);
+	UpdateTabsL();
+
+    FLOG( _L("CAspSettingDialog::SetPreviousProfileL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateTabsL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateTabsL()
+	{
+    FLOG( _L("CAspSettingDialog::UpdateTabsL START") );
+
+	TInt count = iProfileList->Count();
+	if (count == 0)
+		{
+		//handle no profile condition
+		iTabHandler->DeleteTabsL();
+		_LIT(KEmpty, " ");
+		TBuf<64> tabText(KEmpty);
+		TInt profileId = KMaxProfileCount;
+		iTabHandler->AddTabL(tabText, profileId);
+		iTabHandler->SetActiveTabL(profileId);
+		return;
+		}
+
+	if (iTabHandler->TabIndex(iCurrentProfileId) == KErrNotFound)
+		{
+		iUpdateTabGroup = ETrue;
+		}
+	if (iUpdateTabGroup)
+		{
+		//update changed settings
+	    iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+		iProfileList->Sort();
+    	SetCurrentProfile(iCurrentProfileId);
+		count = iProfileList->Count();
+		iTabHandler->DeleteTabsL();
+        for (TInt i=0; i<count; i++)
+        	{
+        	TAspProfileItem& item = iProfileList->Item(i);
+			iTabHandler->AddTabL(item.iProfileName, item.iProfileId);
+    		}
+    	iTabHandler->SetTabWidthL();
+		iUpdateTabGroup = EFalse;		
+		}
+	if (iCurrentProfileId != KErrNotFound)
+		{
+		iTabHandler->SetTabTextL(iCurrentProfileName, iCurrentProfileId);	
+		}
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (iCurrentProfileId == schedule->ProfileId()
+							 && schedule->IsAutoSyncEnabled())
+		{
+		//show indicator icon for profile that has auto sync ON.
+		_LIT(KSpace,"  ");
+		TBuf<64> tabText;
+		tabText.Append(KClockCharacter);//Unicode character U+F815 (clock)
+		tabText.Append(KSpace);
+		tabText.Append(iCurrentProfileName);
+		iTabHandler->SetTabTextL(tabText, iCurrentProfileId);
+		}
+		
+	if (iCurrentProfileId != KErrNotFound)
+        {
+        iTabHandler->SetActiveTabL(iCurrentProfileId);    
+        }
+
+	CleanupStack::PopAndDestroy(schedule);
+	
+	
+    FLOG( _L("CAspSettingDialog::UpdateTabsL END") );
+	}
+
+#endif
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateMarkMenuItem
+//
+// -----------------------------------------------------------------------------
+//
+
+void CAspSettingDialog::UpdateMarkMenuItem(CEikMenuPane* aMenuPane)
+	{
+	
+	CListBoxView* view = iSettingListBox->View();
+    
+    TInt index = view->CurrentItemIndex();
+    TBool mark = view->ItemIsSelected(index);
+	
+	aMenuPane->SetItemDimmed(EAspMenuCmdMark,mark);
+	aMenuPane->SetItemDimmed(EAspMenuCmdUnmark,!mark);
+		
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SaveSelection
+// Update Mark/Unmark selected from menu 
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SaveSelectionL()
+{
+    if (IsProfileLockedL(iCurrentProfileId))
+       	{
+       	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		return;
+		}
+       
+       if (iSettingEnforcement)
+		{
+		TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
+		return; 
+		}
+		
+	//update check box & profile
+    CListBoxView* view = iSettingListBox->View();
+    
+    TInt index = view->CurrentItemIndex();
+    TBool selected = view->ItemIsSelected(index);
+    if (selected)
+    	{
+        view->DeselectItem(index);
+       	}
+    else
+    	{
+    	view->SelectItemL(index);
+    	}
+    iSettingListBox->SetCurrentItemIndex(index);
+    if (!CheckEmailSelection())
+       	{
+       	return; 
+       	}
+	TInt ret =  SaveCurrentProfile();
+	if (ret != KErrNone)
+		{
+		CancelCheckboxEvent();
+		}
+	
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DoSetCurrentProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DoSetCurrentProfileL(TInt aProfileId)
+	{
+    FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL START") );
+    
+    iCurrentProfileId = KErrNotFound;
+    iCurrentProfileName = KNullDesC;
+    iContentList->RemoveAllTasks();
+    iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+	iProfileList->Sort();
+	
+	if (iProfileList->Count() == 0)
+		{
+		return;
+		}
+        
+    if (aProfileId == KErrNotFound)
+    	{
+    	FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
+    	User::Leave(KErrNotFound);
+    	}
+    	
+    TInt index = iProfileList->ListIndex(aProfileId);
+    if (index == KErrNotFound)
+    	{
+    	FLOG( _L("### unknown profile (id=%d) ###"), aProfileId );
+    	FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
+    	
+    	User::Leave(KErrNotFound);
+    	}
+    
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	
+	//if profile already locked ,open as read only
+	if (IsProfileLockedL(aProfileId))
+	{
+	   profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+    
+	}
+	else
+	{
+	   profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite, CAspProfile::EAllProperties);
+	}
+	
+    iContentList->SetProfile(profile);
+    
+    // read sync tasks from database into content list
+    iContentList->InitAllTasksL();
+    if (IsProfileLockedL(aProfileId))
+    {
+    	iContentList->UpdateLocalDatabaseL();
+    }
+    
+    if (!iContentList->CheckTaskDirectionsL())
+       	{
+        if (!iSettingEnforcement)
+           	{
+           	iContentList->ModifyTaskDirectionsL(ESyncDirectionTwoWay);
+    	   	}
+    	   	
+    	FLOG( _L("### sync direction conflict ###") );
+    	}
+    
+    //check if mailbox exists
+    CDesCArray* localDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+	CleanupStack::PushL(localDataStores);
+	iContentList->GetLocalDatabaseList(KUidNSmlAdapterEMail.iUid, localDataStores);
+
+    TInt num = profile->ProtocolVersion();
+    if (num == EAspProtocol_1_1 || localDataStores->Count() == 0)
+    	{
+    	TInt index = iContentList->FindTaskIdForProvider( KUidNSmlAdapterEMail.iUid);
+		if (index != KErrNotFound)
+			{
+			TAspTaskItem emailItem = iContentList->ReadTaskItemL(profile->Profile(), index);
+			if (emailItem.iEnabled)
+				{
+		    	iContentList->ModifyTaskIncludedL(KUidNSmlAdapterEMail.iUid, EFalse, KNullDesC);
+				}
+			}
+    	}
+	CleanupStack::PopAndDestroy(localDataStores);
+	
+    iContentList->SetProfile(NULL);
+    
+    iCurrentProfileId = aProfileId;
+    
+    profile->GetName(iCurrentProfileName);
+  	if (TUtil::IsEmpty(iCurrentProfileName))
+		{
+		CAspResHandler::ReadL(iCurrentProfileName, R_ASP_UNNAMED_SET);
+		}
+
+  
+    CleanupStack::PopAndDestroy(profile);
+    
+    FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SetCurrentProfile
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetCurrentProfile(TInt aProfileId)
+	{
+	if (iContentList->IsLocked())
+		{
+		return; // iContentList used by CAspProfileDialog
+		}
+		
+	TInt err = KErrNone;
+	TInt oldCurrentProfileId = iCurrentProfileId;
+	
+	TRAP(err, DoSetCurrentProfileL(aProfileId));
+	
+	iContentList->SetProfile(NULL);
+	
+    if (err != KErrNone)
+    	{
+        iCurrentProfileId = KErrNotFound;
+        iCurrentProfileName = KNullDesC;
+        iContentList->RemoveAllTasks();
+       	}
+       	
+    if (err != KErrNone && oldCurrentProfileId != KErrNotFound)
+    	{
+   		// some error - try restoring old current profile
+   		TRAP(err, DoSetCurrentProfileL(oldCurrentProfileId));
+   		
+   		iContentList->SetProfile(NULL);
+	
+	    if (err != KErrNone)
+    	    {
+            iCurrentProfileId = KErrNotFound;
+    	    iCurrentProfileName = KNullDesC;
+            iContentList->RemoveAllTasks();
+    	    }
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SetCurrentProfile
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetCurrentProfileL()
+	{
+
+#ifdef RD_DSUI_TIMEDSYNC //display profiles in alphabetic order.
+	TInt index = 0;
+	if (!iProfileList->Count())
+		{
+		index = KErrNotFound;
+		}
+
+#else
+	TInt index = iProfileList->FindLastSyncedProfileIndexL();
+
+#endif
+	if (index != KErrNotFound)
+		{
+		TAspProfileItem& item = iProfileList->Item(index);
+		SetCurrentProfile(item.iProfileId);
+		}
+	else
+		{
+		SetCurrentProfile(KErrNotFound);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CurrentProfileL
+//
+// -----------------------------------------------------------------------------
+//
+TAspProfileItem& CAspSettingDialog::CurrentProfileL()
+	{
+	TInt index = iProfileList->ListIndex(iCurrentProfileId);
+	if (index == KErrNotFound)
+		{
+		User::Leave(KErrNotFound);
+		}
+		
+	return iProfileList->Item(index);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HasCurrentProfile
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::HasCurrentProfile()
+	{
+	TInt ret = ETrue;
+	
+	if (iCurrentProfileId == KErrNotFound)
+		{
+		ret = EFalse;
+		}
+		
+	if (iProfileList->Count() == 0)
+		{
+		ret = EFalse;
+		}
+		
+	if (ret)
+		{
+	    TInt index = iProfileList->ListIndex(iCurrentProfileId);	
+	    
+	    __ASSERT_DEBUG(index != KErrNotFound, TUtil::Panic(KErrGeneral));
+		}
+	
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::IsCurrentProfile
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::IsCurrentProfile(TInt aProfileId)
+	{
+	if (aProfileId != KErrNotFound && aProfileId == iCurrentProfileId)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DoSaveCurrentProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DoSaveCurrentProfileL()
+	{
+	if (iSettingEnforcement)
+		{
+		return;  // read-only profile
+		}
+
+	if (!HasCurrentProfile())
+		{
+		User::Leave(KErrNotFound);
+		}
+
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite, 
+                                      CAspProfile::EAllProperties);
+
+	iContentList->SetProfile(profile);
+	// store selected sync tasks into database
+	iContentList->IncludeTasks(iSettingListBox->SelectionIndexes());
+	iContentList->SetProfile(NULL);
+	
+	CleanupStack::PopAndDestroy(profile);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SaveCurrentProfile
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingDialog::SaveCurrentProfile()
+	{
+	TRAPD(err, DoSaveCurrentProfileL());
+	
+	iContentList->SetProfile(NULL);
+	
+    if (err == KErrLocked)
+   		{
+        TRAP_IGNORE( TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE) );
+        }
+
+	if (err != KErrNone)
+		{
+		FLOG( _L("### CAspSettingDialog::SaveCurrentProfile: err=%d ###"), err );
+    	}
+    	
+    return err;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::EditProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::EditProfileL(TInt aEditMode ,TInt aFocus)
+	{
+	if (iSettingEnforcement)
+		{
+		aEditMode = EDialogModeSettingEnforcement;
+		}
+    
+    if (IsProfileLockedL(iCurrentProfileId))
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		return;
+		}
+	TRAPD(err, DoEditProfileL(aEditMode ,aFocus));
+    iContentList->SetProfile(NULL);
+	User::LeaveIfError(err);
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	iUpdateTabGroup = ETrue;
+	UpdateTabsL();
+#endif
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DoEditProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DoEditProfileL(TInt aEditMode, TInt aFocus)
+	{
+	if (!HasCurrentProfile())
+		{
+		return;
+		}
+		
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    
+    iContentList->SetProfile(profile);
+    
+    if (aEditMode == EDialogModeEdit || aEditMode == EDialogModeEditMandatory)
+    	{
+    	profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite,
+                                          CAspProfile::EAllProperties);
+                                          
+    	}
+    else
+    	{
+    	profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead,
+                                          CAspProfile::EAllProperties);
+    	}
+
+		
+	TAspParam param2(iApplicationId, iSyncSession);
+	param2.iProfile = profile;
+	param2.iMode = aEditMode;
+    param2.iContentList = iContentList;
+    param2.iProfileList = iProfileList;  // needed for unique server id check
+    param2.iDataProviderId = aFocus;
+ 
+#ifdef RD_DSUI_TIMEDSYNC 
+	CAspSettingViewDialog::ShowDialogL(param2);
+#else
+	CAspProfileDialog::ShowDialogL(param2);
+#endif
+
+	iContentList->SetProfile(NULL);
+	CleanupStack::PopAndDestroy(profile);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CheckMandatoryDataL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingDialog::CheckMandatoryDataL()
+	{
+	TInt ret = EMandatoryOk;
+	
+	TRAPD(err, ret = DoCheckMandatoryDataL());
+	
+	User::LeaveIfError(err);
+		
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DoCheckMandatoryDataL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingDialog::DoCheckMandatoryDataL()
+	{
+	if (!HasCurrentProfile())
+		{
+		User::Leave(KErrNotFound);
+		}
+		
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead,
+                                      CAspProfile::EAllProperties);
+    
+    
+    TInt mandatoryConnectionData = CAspProfile::CheckMandatoryConnData(profile);
+    CleanupStack::PopAndDestroy(profile);
+	
+	TInt contentCount = 0;
+	TInt mandatoryContentData = iContentList->CheckMandatoryDataL(contentCount);
+	
+	if (mandatoryConnectionData != EMandatoryOk)
+		{
+		return mandatoryConnectionData;
+		}
+		
+	return mandatoryContentData;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DeleteProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DeleteProfileL()
+    {
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	 TAspParam param(iApplicationId, iSyncSession);
+	 CAspProfile* profile = CAspProfile::NewLC(param);
+     TRAPD(err,profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite,
+                                      CAspProfile::EAllProperties));
+
+	 if (err == KErrLocked)
+   		{
+        TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		CleanupStack::PopAndDestroy(profile);
+		return;
+	 	}
+	 CAspSchedule* schedule = CAspSchedule::NewLC();
+	
+	 TInt profileId = schedule->ProfileId();
+	 if (profileId == iCurrentProfileId && schedule->IsAutoSyncEnabled())
+	 	{
+		HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_DS_CONF_QUERY_DELETE_AUTO_SYNC_PROFILE);
+		if (!TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
+			{
+			CleanupStack::PopAndDestroy(hBuf);
+			CleanupStack::PopAndDestroy(schedule);
+	        CleanupStack::PopAndDestroy(profile);
+			return;
+			}
+		CleanupStack::PopAndDestroy(hBuf);
+		schedule->SetProfileId(KErrNotFound);
+		schedule->UpdateSyncScheduleL();
+		schedule->SaveL();
+		}
+	 else
+	 	{
+		TBuf<KBufSize> profileName;
+	 	profile->GetName(profileName);
+	 	HBufC* hBuf1 = CAspResHandler::ReadLC(R_ASP_QUERY_COMMON_CONF_DELETE, profileName);
+
+	 	if (!TDialogUtil::ShowConfirmationQueryL(hBuf1->Des()))
+		    {
+			CleanupStack::PopAndDestroy(hBuf1);
+			CleanupStack::PopAndDestroy(schedule);
+			CleanupStack::PopAndDestroy(profile);
+			return;
+	 		}
+		CleanupStack::PopAndDestroy(hBuf1);
+	 	}
+	CleanupStack::PopAndDestroy(schedule);
+	CleanupStack::PopAndDestroy(profile);
+	if (!IsSyncOnGoingL(iCurrentProfileId))
+		{
+		TRAPD (err1,iSyncSession->DeleteProfileL(iCurrentProfileId));
+		
+		if (err1 == KErrLocked)
+   			{
+       		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+       		}
+    	User::LeaveIfError(err);
+		}
+	iUpdateTabGroup = ETrue;	
+	SetPreviousProfileL();
+	
+	
+#else
+
+    TAspFilterInfo info;
+    info.iFilterType = TAspFilterInfo::EIncludeDeletableProfile;
+    CAspProfileList* filteredList = iProfileList->FilteredListL(info);
+    CleanupStack::PushL(filteredList);
+    
+	TInt count = filteredList->Count();
+	TInt err = KErrNone;
+
+	if (count == 1)
+		{
+		TAspProfileItem& profile = filteredList->Item(0);
+
+		HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_CONFIRM_DELETE, profile.iProfileName);
+	    if (TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
+		    {
+		    if (!IsSyncOnGoingL(profile.iProfileId))
+		    	{
+		    	TRAP(err, iSyncSession->DeleteProfileL(profile.iProfileId));
+		    	}
+		    }
+   		
+   		CleanupStack::PopAndDestroy(hBuf);
+    	}
+	
+	else if (count > 0)
+		{
+		TInt profileId = KErrNotFound;
+	    if (TDialogUtil::ShowProfileQueryL(filteredList, profileId,
+	                                       R_ASP_QUERY_TITLE_DELETE_PROFILE))
+		    {
+		    if (!IsSyncOnGoingL(profileId))
+		    	{
+		    	TRAP(err, iSyncSession->DeleteProfileL(profileId));
+		    	}
+		    }
+		}
+
+	if (err == KErrLocked)
+   		{
+        TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+        }
+    User::LeaveIfError(err);
+    
+	CleanupStack::PopAndDestroy(filteredList);
+
+#endif
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowLogDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowLogDialogL()
+    {
+    
+	TAspParam param(iApplicationId, iSyncSession);
+	TAspProfileItem& profile = CurrentProfileL();
+	param.iProfileId = profile.iProfileId;
+
+#ifdef RD_DSUI_TIMEDSYNC 
+   	
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (iCurrentProfileId == schedule->ProfileId())
+		{
+		TInt asProfileId = schedule->AutoSyncProfileId();
+		CAspProfile* asProfile = CAspProfile::NewLC(param);
+		asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+
+		/*if (asProfile->LastSync() > profile.iLastSync)
+			{
+			param.iProfileId = asProfileId;
+			}*/	
+		TTime now;
+		now.HomeTime();
+		if (profile.iLastSync == 0)
+			{
+			param.iProfileId = asProfileId;
+			}
+		else if ((asProfile->LastSync()< now && profile.iLastSync < now)
+								|| (asProfile->LastSync() > now && profile.iLastSync > now))
+			{
+			if (asProfile->LastSync() > profile.iLastSync)
+				{
+				param.iProfileId = asProfileId;
+				}
+			}
+		else if	((asProfile->LastSync()< now && profile.iLastSync > now))
+			{
+			param.iProfileId = asProfileId;
+			}
+		CleanupStack::PopAndDestroy(asProfile);
+		}
+	
+	CleanupStack::PopAndDestroy(schedule);
+		
+#endif   
+	
+
+    CAspLogDialog* dialog = CAspLogDialog::NewL(param);
+    CleanupStack::PushL(dialog);
+        
+    dialog->ShowDialogL();
+        
+    CleanupStack::PopAndDestroy(dialog);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowAutoSyncDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowAutoSyncDialogL()
+    {
+    
+    CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (schedule->IsAutoSyncEnabled())
+		{
+		TInt profileId = schedule->ProfileId();
+		if(profileId != iCurrentProfileId && profileId != KErrNotFound)
+			{
+			if(!TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_AUTO_SYNC_ON))
+				{
+				CleanupStack::PopAndDestroy(schedule);
+				return ;
+				}
+			}
+		}
+    CleanupStack::PopAndDestroy(schedule);
+	
+	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfileList = iProfileList;
+	param.iProfile = NULL;
+	param.iContentList = iContentList;
+ 	CAspScheduleDialog::ShowDialogL(param);
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	UpdateTabsL();
+#endif
+	
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ChangeProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ChangeProfileL()
+    {
+    if (iProfileList->Count() == 0)
+    	{
+    	return;
+    	}
+    	
+	TInt profileId = KErrNotFound;
+	if (TDialogUtil::ShowProfileQueryL(iProfileList, profileId, 
+	                                   R_ASP_QUERY_TITLE_CHANGE_PROFILE))
+		{
+		if (profileId == iCurrentProfileId)
+			{
+			return;
+			}
+			
+		SetCurrentProfile(profileId);
+		//ShowCurrentProfileInfo();
+		UpdateListBoxL();
+		
+#ifdef RD_DSUI_TIMEDSYNC //RD_DSUI_NO_TIMEDSYNC
+
+		UpdateTabsL();
+#else
+		UpdateNavipaneL(iCurrentProfileName);
+#endif
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CopyFromServerL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::CopyFromServerL()
+	{
+	if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_COPY_FROM_SERVER))
+		{
+		return;
+		}
+
+	TRAPD(err, DoSyncProfileL(ESyncDirectionRefreshFromServer));
+	
+	if (err == KErrLocked)
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		}
+	User::LeaveIfError(err);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SyncProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SyncProfileL()
+	{
+		
+	if (IsProfileLockedL(iCurrentProfileId))
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		return;
+		}
+	
+	TRAPD(err, DoSyncProfileL(KErrNotFound));
+	User::LeaveIfError(err);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DoSyncProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DoSyncProfileL(TInt aSyncType)
+	{
+    __ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    	
+	if (iProfileList->Count() == 0)
+		{
+	    if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_NO_PROFILES))
+		    {
+		    CreateProfileL();
+		    }
+		    
+		return;
+    	}
+    
+    //check PS key
+    TInt keyVal = 0;//EDataSyncNotRunning
+    TInt err = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                 KDataSyncStatus,
+                                 keyVal );
+    if(err == KErrNone && keyVal)
+    	{
+    	TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
+		return;
+    	}
+    
+	
+	if (CAspProfile::OtherSyncRunning(iSyncSession))
+		{
+		TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
+		return;
+		}
+
+     // check that valid current profile exists
+    TInt mandatoryCheck = CheckMandatoryDataL();
+    
+ 	if (mandatoryCheck == EMandatoryNoContent)
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_ERR_NOCONTENT);
+		return;
+        }
+	else if (mandatoryCheck != EMandatoryOk)
+		{
+        if (iSettingEnforcement)
+    	    {
+    	    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_TARM_MANDATORY_MISSING);
+    	    }    	
+		else if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_MANDATORY_MISSING))
+			{
+			TInt contentCount = 0;
+			TInt incompleteContent = KErrNotFound;
+			TInt taskIndex = KErrNotFound;
+			if (iContentList->CheckMandatoryDataL(contentCount))
+				{
+				TInt count = iContentList->ProviderCount();
+				for (TInt i=0; i<count; i++)
+					{
+					//data provider ids are sorted before task list creation ,so provider id has to be used
+					//to get the correct position of item
+					TAspProviderItem& providerItem = iContentList->ProviderItem(i);
+					taskIndex = iContentList->FindTaskIndexForProvider(providerItem.iDataProviderId);
+					if (taskIndex == KErrNotFound)
+						{
+						//task is not created
+						continue;	
+						}
+					TAspTaskItem& task = iContentList->TaskItem(taskIndex);
+					if (!task.iEnabled)
+						{
+						continue; // task not part of sync - no need to check remote data base
+						}
+					if (!task.iRemoteDatabaseDefined)
+						{
+						incompleteContent = task.iDataProviderId;
+						break;
+						}
+					}
+				}
+			EditProfileL(EDialogModeEditMandatory ,incompleteContent);
+			}
+			
+		return;
+        }
+
+
+	if (!iSyncHandler)
+		{
+    	TAspParam param(iApplicationId, NULL);
+		iSyncHandler = CAspSyncHandler::NewL(param);
+		}
+	else
+		{
+		if (SyncRunning())
+			{
+			TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
+    		return;
+			}
+		}
+    	
+    iSyncHandler->SetObserver(this);
+
+   	TAspSyncParam param(iApplicationId);
+	param.iProfileId = iCurrentProfileId;
+	if (aSyncType == ESyncDirectionRefreshFromServer)
+		{
+		param.iSyncDirection = aSyncType;
+		}
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	DeleteAutoSyncHistory();
+#endif
+
+	iSyncHandler->SynchronizeL(param);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::DeleteAutoSyncHistory
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::DeleteAutoSyncHistory()
+	{
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (schedule->IsAutoSyncEnabled() && iCurrentProfileId == schedule->ProfileId())
+		{
+		TInt asProfileId = schedule->AutoSyncProfileId();
+		CAspProfile* asProfile = CAspProfile::NewLC(param);
+		asProfile->OpenL(asProfileId, CAspProfile::EOpenReadWrite, CAspProfile::EAllProperties);
+		asProfile->DeleteHistory();
+		CleanupStack::PopAndDestroy(asProfile);
+		}
+	CleanupStack::PopAndDestroy(schedule);
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CreateProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::CreateProfileL()
+	{
+	TAspParam param(iApplicationId, iSyncSession);
+	param.iProfileList = iProfileList;
+	
+	CAspProfileWizardDialog::ShowDialogL(param);
+
+#ifdef RD_DSUI_TIMEDSYNC 
+	iUpdateTabGroup = ETrue;
+#endif
+
+	if (param.iReturnValue == KErrNone && param.iProfileId != KErrNotFound)
+		{
+		SetCurrentProfile(param.iProfileId);
+		UpdateListBoxL();
+#ifdef RD_DSUI_TIMEDSYNC 
+	
+		UpdateTabsL();
+#else
+		UpdateNavipaneL(iCurrentProfileName);
+#endif
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspSettingDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+	
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateListBoxL
+//	
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateListBoxL()
+	{
+	SetCurrentIndex();
+	
+	CAknDoubleLargeStyleListBox* listBox = ListBox();
+	CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray();
+	items->Reset();
+    listBox->ItemDrawer()->ClearAllPropertiesL();
+   
+	TInt count = iContentList->ProviderCount();
+
+	for (TInt i=0; i<count; i++)
+		{
+		HBufC* firstLine = NULL;
+		HBufC* secondLine = NULL;
+				
+		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
+		
+		firstLine = CAspResHandler::GetContentNameLC(
+		            providerItem.iDataProviderId, providerItem.iDisplayName);
+		
+		TInt index = iContentList->FindTaskIndexForProvider(providerItem.iDataProviderId);
+		if (providerItem.iDataProviderId == KUidNSmlAdapterEMail.iUid )
+		{
+		
+			if(!providerItem.iHasDefaultDataStore)
+			{
+			TInt providerListIndex = iContentList->FindProviderIndex(providerItem.iDataProviderId);
+			
+			CListBoxView* view = iSettingListBox->View();
+
+			view->DeselectItem(providerListIndex);
+			}
+		}
+		if (index != KErrNotFound)
+			{
+			TAspTaskItem& task = iContentList->TaskItem(index);
+	
+		    if (task.iLastSync != 0) // task has been synchronised
+			    {
+			    secondLine = TUtil::SyncTimeLC(task.iLastSync);
+			    }
+		    else
+			    {
+			    secondLine = CAspResHandler::ReadLC(R_ASP_NOT_SYNCED);
+			    }
+			}
+		else
+			{
+			secondLine = CAspResHandler::ReadLC(R_ASP_NOT_SYNCED);
+			}
+		
+		
+		TPtr ptr1 = firstLine->Des();
+		AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr1);
+		TPtr ptr2 = secondLine->Des();
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr2);
+
+		HBufC* hBuf = NULL;
+		hBuf = TDialogUtil::ConstructListBoxItemLC(firstLine->Des(), secondLine->Des(), 0);
+
+		items->AppendL(hBuf->Des());
+		
+		CleanupStack::PopAndDestroy(hBuf);
+		CleanupStack::PopAndDestroy(secondLine);
+		CleanupStack::PopAndDestroy(firstLine);
+		}
+
+	listBox->HandleItemAdditionL();
+	
+	if (listBox->Model()->NumberOfItems() == 0)
+		{
+	    iStatusPaneHandler->SetNaviPaneTitle(KNullDesC);
+		}
+	else
+		{
+		UpdateContentSelectionL();
+		
+		TInt current = CurrentIndex();
+		if (current != KErrNotFound)
+			{
+			ListBox()->SetCurrentItemIndexAndDraw(current);
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateContentSelectionL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateContentSelectionL()
+    {
+    // update selected task check boxes from current profile content list
+    CListBoxView::CSelectionIndexArray* arrayOfSelectionIndexes = NULL;
+    arrayOfSelectionIndexes = new (ELeave) CArrayFixFlat<TInt>(KDefaultArraySize);
+    CleanupStack::PushL(arrayOfSelectionIndexes);
+
+	if (HasCurrentProfile())
+		{
+		iContentList->GetIncludedProviders(arrayOfSelectionIndexes);
+		}
+        
+    iSettingListBox->SetSelectionIndexesL(arrayOfSelectionIndexes);
+
+    CleanupStack::PopAndDestroy(arrayOfSelectionIndexes);
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateNavipaneL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateNavipaneL(const TDesC& aText)
+	{
+	if (iCurrentProfileName.Compare(aText) != 0)
+		{
+		TUtil::StrCopy(iCurrentProfileName, aText);
+		}
+		
+	iStatusPaneHandler->SetNaviPaneTitleL(iCurrentProfileName);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HandleSyncEventL (from MAspSyncObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::HandleSyncEventL(TInt /*aError*/, TInt aInfo1)
+	{
+    iDbNotifier->CreateUpdateEventL(aInfo1, KErrNone);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HandleDbEventL (from MAspDbEventHandler)
+//
+// This function updates UI when it receives sync profile database
+// events (see AspDbNotifier).
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::HandleDbEventL(TAspDbEvent aEvent)
+	{
+	FLOG( _L("CAspSettingDialog::HandleDbEventL START") );
+
+    switch (aEvent.iType)
+		{
+		case CAspDbNotifier::EClose:
+			{
+			
+#ifdef _DEBUG			
+			LogDatabaseEvent(aEvent);
+#endif		
+	
+			TDialogUtil::ShowErrorNoteL(R_ASP_LOG_ERR_SERVERERROR);
+            iAvkonAppUi->ProcessCommandL(EAknCmdExit); //  close sync app
+			break;
+			}
+		
+		case CAspDbNotifier::EUpdate:
+			{
+			iProfileList->ReadProfileL(aEvent.iProfileId);
+			iProfileList->Sort();
+      	    if (IsCurrentProfile(aEvent.iProfileId))
+            	{
+            	if (!iContentList->IsLocked())
+            		{
+            		SetCurrentProfile(aEvent.iProfileId);
+                    UpdateListBoxL();
+#ifdef RD_DSUI_TIMEDSYNC 
+					UpdateTabsL();
+#else
+                    UpdateNavipaneL(iCurrentProfileName);
+#endif               
+            		}
+            	}
+			
+#ifdef _DEBUG
+            LogDatabaseEvent(aEvent);
+#endif
+			
+			break;
+			}
+
+		case CAspDbNotifier::EDelete:
+			{
+
+#ifdef _DEBUG
+            LogDatabaseEvent(aEvent);
+#endif
+
+            TInt index = iProfileList->ListIndex(aEvent.iProfileId);
+            if (index != KErrNotFound)
+            	{
+            	iProfileList->Remove(aEvent.iProfileId);
+            	if (IsCurrentProfile(aEvent.iProfileId))
+            		{
+            		if (!iContentList->IsLocked())
+            		    {
+            		    SetCurrentProfileL(); // set new current profile
+                        UpdateListBoxL();
+#ifdef RD_DSUI_TIMEDSYNC 
+					UpdateTabsL();
+#else
+                    UpdateNavipaneL(iCurrentProfileName);
+#endif            		 
+						}
+            		}
+            	}
+			break;
+			}
+
+		case CAspDbNotifier::EUpdateAll:
+			{
+
+#ifdef _DEBUG			
+			LogDatabaseEvent(aEvent);
+#endif
+
+			iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+			iProfileList->Sort();
+           	if (!iContentList->IsLocked())
+            	{
+            	SetCurrentProfile(iCurrentProfileId); // set new current profile
+                UpdateListBoxL();
+#ifdef RD_DSUI_TIMEDSYNC 
+					UpdateTabsL();
+#else
+                    UpdateNavipaneL(iCurrentProfileName);
+#endif         	
+				}
+
+			break;
+			}
+
+		default:
+			break;
+		}
+		
+	FLOG( _L("CAspSettingDialog::HandleDbEventL END") );
+	}
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HandleOKL()
+// 
+// -----------------------------------------------------------------------------
+//
+
+void CAspSettingDialog::HandleOKL()
+{
+	
+	if (iProfileList->Count() == 0)
+			{
+			return;
+			}
+        
+        if (IsProfileLockedL(iCurrentProfileId))
+        	{
+        	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+			CancelCheckboxEvent();
+			return;
+			}
+        
+        if (iSettingEnforcement)
+			{
+			CancelCheckboxEvent();
+			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_MAIN_LOCKED);
+			return ;  // leave dialog open;
+			}
+        
+        if (!CheckEmailSelection())
+        	{
+        	return ;  // leave dialog open;
+        	}
+				
+		TInt ret =  SaveCurrentProfile();
+		if (ret != KErrNone)
+			{
+			CancelCheckboxEvent();
+			}
+			
+		return ;
+}
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HandleListBoxEventL (from MEikListBoxObserver)
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	   if( AknLayoutUtils::PenEnabled() )  
+	   {
+	   	 switch(aEventType)
+		{
+			case EEventItemClicked :
+			     HandleOKL();
+			     break;
+			default:
+			     break;
+		}
+	   }
+	  
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::HandleActiveCallL (from MAspActiveCallerObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::HandleActiveCallL(TInt /*aCallId*/)
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SetCurrentIndex
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::SetCurrentIndex()
+	{
+	TInt count = ListBox()->Model()->NumberOfItems();
+
+	if (count == 0)
+		{
+		iCurrentListBoxIndex = KErrNotFound;  // empty list
+		}
+	else
+		{
+		iCurrentListBoxIndex = ListBox()->CurrentItemIndex();
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::CurrentIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingDialog::CurrentIndex()
+	{
+	TInt count = ListBox()->Model()->NumberOfItems();
+	
+	if (count == 0)
+		{
+		iCurrentListBoxIndex = KErrNotFound;
+		}
+	else if (iCurrentListBoxIndex >= count)
+		{
+		iCurrentListBoxIndex = count-1; // last listbox item
+		}
+	else if (iCurrentListBoxIndex < 0)
+		{
+		iCurrentListBoxIndex = 0; // first listbox item
+		}
+		
+	return iCurrentListBoxIndex;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowCurrentProfileInfoL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowCurrentProfileInfoL()
+	{
+	TAspProfileItem& item = CurrentProfileL();
+	TBuf<KBufSize> buf;
+    iBearerHandler->GetBearerName(buf, item.iBearer);
+    HBufC* hBuf = CAspResHandler::ReadProfileInfoTextLC(item.iProfileName, buf);
+    ShowPopupNoteL(hBuf->Des());
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowCurrentProfileInfo
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowCurrentProfileInfo()
+	{
+	TRAP_IGNORE(ShowCurrentProfileInfoL());
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowAutoSyncProfileInfoL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::ShowAutoSyncProfileInfo()
+	{
+	TBool ret = EFalse;
+	
+	TRAPD(err, ret = ShowAutoSyncProfileInfoL());
+
+#ifdef RD_DSUI_TIMEDSYNC
+	UpdateTabsL();	
+#endif
+	
+	if (err != KErrNone)
+		{
+		return EFalse;
+		}
+	return ret;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowAutoSyncProfileInfoL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::ShowAutoSyncProfileInfoL()
+	{
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	
+	if (!schedule->CanSynchronizeL())
+    	{
+   	    CleanupStack::PopAndDestroy(schedule);
+	    return EFalse;
+    	}
+	
+	TInt autoSyncError = schedule->Error();
+	if (autoSyncError != KErrNone)
+		{
+
+		TInt profileId = schedule->ProfileId();
+		TInt asProfileId = schedule->AutoSyncProfileId();
+		TAspParam param(iApplicationId, iSyncSession);
+		CAspProfile* asProfile = CAspProfile::NewLC(param);
+		asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+		CAspProfile* profile = CAspProfile::NewLC(param);
+		profile->OpenL(profileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+
+		//display auto sync error query only if profile hasn't been manually synced after last auto sync
+		if (asProfile->LastSync() >= profile->LastSync())
+			{
+			if (autoSyncError == CAspAutoSyncHandler::EOtherSyncRunning)
+				{
+				HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_MANUAL_SYNC_OVERRIDE);
+				_LIT(KEmpty, " ");
+				TDialogUtil::ShowMessageQueryL(KEmpty, hBuf->Des());
+   	   			CleanupStack::PopAndDestroy(hBuf);
+				}
+			else
+				{
+				HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_POPUP_AUTO_SYNC_ERROR);
+				_LIT(KNewLine ,"\n");
+				TBuf<KBufSize> buf(hBuf->Des());
+				buf.Append(KNewLine);
+				CAspResHandler::ReadL(iBuf, R_ASP_MAIN_AUTO_ERROR_LOG_LINK);
+				buf.Append(iBuf);
+				CleanupStack::PopAndDestroy(hBuf);
+				hBuf = HBufC::NewLC(buf.Size());
+				TPtr ptr(hBuf->Des());
+				ptr = buf;
+
+			   	TDialogUtil::ShowAutoSyncMessageQueryL(hBuf->Des());
+	   	   		CleanupStack::PopAndDestroy(hBuf);
+				}
+	  	    
+   	    	schedule->SetError(KErrNone);
+   	    	schedule->SaveL();
+
+			CleanupStack::PopAndDestroy(profile);
+			CleanupStack::PopAndDestroy(asProfile);
+			CleanupStack::PopAndDestroy(schedule);
+   	    	return ETrue;
+			}
+		
+		CleanupStack::PopAndDestroy(profile);
+		CleanupStack::PopAndDestroy(asProfile);
+		
+		schedule->SetError(KErrNone);
+   	    schedule->SaveL();
+		}
+
+    
+    TTime nextSync;
+    schedule->GetStartTimeL(nextSync ,ETrue);
+
+    TInt profileIndex = iProfileList->ListIndex(schedule->ProfileId());
+    TAspProfileItem& item = iProfileList->Item(profileIndex); 
+    
+	HBufC* hBuf1 = CAspResHandler::ReadAutoSyncInfoTextLC( item.iProfileName, nextSync);
+	
+	TDialogUtil::ShowInformationNoteL(hBuf1->Des());
+   	CleanupStack::PopAndDestroy(hBuf1);
+    CleanupStack::PopAndDestroy(schedule);
+	return ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::ShowPopupNote
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::ShowPopupNoteL(const TDesC& aText) 
+    {
+    iPopupNote->SetTextL(aText);
+    iPopupNote->SetTimePopupInView(KSettingDialogPopupDisplayTime);    
+    iPopupNote->ShowInfoPopupNote();    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::Listbox
+//
+// -----------------------------------------------------------------------------
+//
+CAknDoubleLargeStyleListBox* CAspSettingDialog::ListBox()
+	{
+	__ASSERT_DEBUG(iSettingListBox, TUtil::Panic(KErrGeneral));
+
+	return iSettingListBox;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::SyncRunning
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::SyncRunning()
+	{
+    if (!iSyncHandler)
+		{
+		return EFalse;
+		}
+
+	if (iSyncHandler->SyncRunning())
+		{
+		return ETrue;
+		}
+
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateCbaL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateCbaL(TInt aResourceId)
+    {
+    CEikButtonGroupContainer& cba = ButtonGroupContainer();
+    cba.SetCommandSetL(aResourceId);
+    cba.DrawDeferred();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::CancelCheckboxEvent
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingDialog::CancelCheckboxEventL()
+	{
+	CListBoxView* view = iSettingListBox->View();
+    
+    TInt index = view->CurrentItemIndex();
+    TBool selected = view->ItemIsSelected(index);
+    if (selected)
+       	{
+        view->DeselectItem(index);
+       	}
+    else
+    	{
+    	view->SelectItemL(index);
+    	}
+    	
+    iSettingListBox->SetCurrentItemIndex(index);
+    //view->SetCurrentItemIndex(index);
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::CancelCheckboxEvent
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingDialog::CancelCheckboxEvent()
+	{
+	TRAP_IGNORE(CancelCheckboxEventL());
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::CheckEmailSelection
+// 
+// ----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::CheckEmailSelection()
+	{
+	TBool ret = ETrue;
+	
+	TRAPD(err, ret = CheckEmailSelectionL());
+	
+	if (err != KErrNone)
+		{
+		return ETrue;
+		}
+	
+	return ret;
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::CheckEmailSelectionL
+// 
+// ----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::CheckEmailSelectionL()
+	{
+	CListBoxView* view = iSettingListBox->View();
+	
+    TInt index = view->CurrentItemIndex();
+    TAspProviderItem& item = iContentList->ProviderItem(index);
+    TBool selected = view->ItemIsSelected(index);
+    
+    if (item.iDataProviderId != KUidNSmlAdapterEMail.iUid)
+    	{
+    	return ETrue;
+    	}
+        
+    if (!selected)
+    	{
+    	return ETrue;
+    	}
+    
+    iContentList->UpdateDataProviderL(item.iDataProviderId);
+    if (!item.iHasDefaultDataStore)
+    	{
+    	CancelCheckboxEvent();
+    	TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
+    	return EFalse;
+    	}
+    	
+    if (HasCurrentProfile())
+    	{
+    	TAspParam param(iApplicationId, iSyncSession);
+	    CAspProfile* profile = CAspProfile::NewLC(param);
+        profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+      
+	    TInt num = profile->ProtocolVersion();
+	    CleanupStack::PopAndDestroy(profile);
+
+    	}
+    
+    	
+    
+    return ETrue;
+	}
+
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::IsProfileLockedL
+// Checks if a particular profile is already opened
+// ----------------------------------------------------------------------------
+//
+TBool CAspSettingDialog::IsProfileLockedL(TInt aProfileId)
+{
+	
+	TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	
+	
+	TRAPD(err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite,
+                                         CAspProfile::EAllProperties));
+                                         
+    
+	if (err == KErrLocked)
+		{
+		CleanupStack::PopAndDestroy(profile);
+		return ETrue;
+		}
+	else
+		{
+		CleanupStack::PopAndDestroy(profile);
+		return EFalse;
+		}
+	
+}
+// ----------------------------------------------------------------------------
+// CAspSettingDialog::UpdateMiddleSoftKeyLabelL
+// Update the MSK Label
+// ----------------------------------------------------------------------------
+//
+void CAspSettingDialog::UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId)
+{
+	ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,aCommandId );
+	HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
+
+	ButtonGroupContainer().AddCommandToStackL(
+	KMSKControlId,
+	aCommandId,
+	*middleSKText );
+	CleanupStack::PopAndDestroy( middleSKText );
+}
+
+#ifdef _DEBUG
+
+
+// -----------------------------------------------------------------------------
+// LogDatabaseEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::LogDatabaseEvent(TAspDbEvent aEvent)
+	{
+	TBuf<KBufSize> buf;
+	
+    if (aEvent.iType == CAspDbNotifier::EClose)
+    	{
+    	FLOG( _L("### EClose: close setting dialog ###") );
+    	}
+    else if (aEvent.iType == CAspDbNotifier::EUpdate)
+    	{
+        TInt index = iProfileList->ListIndex(aEvent.iProfileId);
+        if (index != KErrNotFound)
+           	{
+           	TAspProfileItem& item = iProfileList->Item(index);
+            FTRACE( RDebug::Print(_L("EUpdate: %S (%d)"), &item.iProfileName, aEvent.iProfileId) );
+               
+            buf.Format(_L("EUpdate: %S"), &item.iProfileName);
+		    TUtil::Print(buf);
+           	}
+        else
+          	{
+           	FTRACE( RDebug::Print(_L("### EUpdate: profile not found (%d) ###"), aEvent.iProfileId) );
+           	TUtil::Print(_L("EUpdate: profile not found"));
+           	}
+    	}
+    else if (aEvent.iType == CAspDbNotifier::EDelete)
+    	{
+        TInt index = iProfileList->ListIndex(aEvent.iProfileId);
+        if (index != KErrNotFound)
+           	{
+           	TAspProfileItem& item = iProfileList->Item(index);
+		    FTRACE( RDebug::Print(_L("EDelete: %S (%d)"), &item.iProfileName, aEvent.iProfileId) );
+
+            buf.Format(_L("EDelete: %S"), &item.iProfileName);
+		    TUtil::Print(buf);
+           	}
+        else
+           	{
+           	FTRACE( RDebug::Print(_L("EDelete: profile not found (%d)"), aEvent.iProfileId) );
+           	TUtil::Print(_L("EDelete: profile not found"));
+           	}
+    	
+    	}
+    else if (aEvent.iType == CAspDbNotifier::EUpdateAll)
+    	{
+     	FLOG( _L("EUpdateAll: read all profiles") );
+     	TUtil::Print(_L("EUpdateAll: read all profiles"));
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// TestL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingDialog::TestL()
+    {
+    TAspParam param(iApplicationId, iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
+      
+	TBuf<128> buf; TBuf<128> buf2;
+	profile->GetPassword(buf);
+	TInt len = buf.Length();
+	buf2.Format(_L("len = %d  text = %S"), len, &buf);
+	TDialogUtil::ShowMessageQueryL(_L("huu"), buf2);
+    CleanupStack::PopAndDestroy(profile);
+    
+    /*
+    CListBoxView* view = iSettingListBox->View();
+    const CListBoxView::CSelectionIndexArray* arr = view->SelectionIndexes();
+    TBuf<128> buf; TBuf<128> buf2;
+    TInt count = arr->Count();
+    for (TInt i=0; i<count; i++)
+     	{
+       	buf2.Format(_L("%d "), (*arr)[i]);
+       	buf.Append(buf2);
+       	}
+    TDialogUtil::ShowMessageQueryL(_L("huu"), buf);
+    */
+    
+    /*
+    HBufC* hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), CAspState::EPhaseSending);
+    TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
+    CleanupStack::PopAndDestroy(hBuf);
+    
+    hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), CAspState::EPhaseReceiving);
+    TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
+    CleanupStack::PopAndDestroy(hBuf);
+
+    hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), 34);
+    TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
+    CleanupStack::PopAndDestroy(hBuf);
+    */
+    }
+
+
+#endif
+
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSettingViewDialog.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,756 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 FILES
+
+#include "AspSettingViewDialog.h"
+#include "AspProfileDialog.h"
+#include "AspContentDialog.h"
+#include "AspScheduleDialog.h"
+
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+#include <csxhelp/ds.hlp.hrh>
+
+#include <aspsyncutil.mbg>  // for bitmap enumerations
+#include <AknIconArray.h>   // for GulArray
+
+#include "AspSchedule.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::ShowDialogL
+// 
+// -----------------------------------------------------------------------------
+TBool CAspSettingViewDialog::ShowDialogL(const TAspParam& aParam)
+	{
+    CAspSettingViewDialog* dialog = CAspSettingViewDialog::NewL(aParam);
+
+	TBool ret = dialog->ExecuteLD(R_ASP_SETTING_VIEW_DIALOG);
+
+    return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::NewL
+//
+// -----------------------------------------------------------------------------
+CAspSettingViewDialog* CAspSettingViewDialog::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspSettingViewDialog::NewL START") );
+
+    CAspSettingViewDialog* self = new ( ELeave )CAspSettingViewDialog (aParam);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CAspSettingViewDialog::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::CAspSettingViewDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CAspSettingViewDialog::CAspSettingViewDialog(const TAspParam& aParam)
+	{
+    iSyncSession = aParam.iSyncSession;
+    iApplicationId = aParam.iApplicationId;
+    iProfile = aParam.iProfile;
+    iContentList = aParam.iContentList;
+    iProfileList = aParam.iProfileList;
+    iEditMode = aParam.iMode;
+	iDataProviderId =aParam.iDataProviderId;
+	iSchedule = aParam.iSchedule;
+    
+       
+	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iContentList, TUtil::Panic(KErrGeneral));
+	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::ConstructL()
+    {
+    FLOG( _L("CAspSettingViewDialog::ConstructL START") );
+	
+	// contruct menu for our dialog
+	CAknDialog::ConstructL(R_ASP_SETTING_VIEW_DIALOG_MENU);
+
+	iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(1);
+
+	TAspParam param(KErrNotFound, iSyncSession);
+		
+	// get previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	FLOG( _L("CAspSettingViewDialog::ConstructL END") );
+    } 
+
+
+// ----------------------------------------------------------------------------
+// Destructor
+//
+// ----------------------------------------------------------------------------
+//
+CAspSettingViewDialog::~CAspSettingViewDialog()
+    {
+    FLOG( _L("CAspSettingViewDialog::~CAspSettingViewDialog START") );
+
+	if (iSettingList)
+		{
+		iSettingList->ResetAndDestroy();
+	    delete iSettingList;
+		}
+
+	delete iStatusPaneHandler;
+	
+	
+    if (iAvkonAppUi)
+    	{
+    	iAvkonAppUi->RemoveFromStack(this);
+    	}
+
+	FLOG( _L("~CAspSettingViewDialog::~~CAspSettingViewDialog END") );
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspSettingViewDialog::ActivateL
+//
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+	// this cannot be in ConstructL which is executed before dialog is launched
+	iAvkonAppUi->AddToStackL(this);
+    }
+
+
+//------------------------------------------------------------------------------
+// CAspContentListDialog::GetHelpContext
+//
+//------------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::GetHelpContext(TCoeHelpContext& aContext) const
+	{
+	aContext.iMajor = KUidSmlSyncApp;
+	aContext.iContext = KDS_HLP_SETTINGS;    
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::HandleListBoxEventL
+// 
+// -----------------------------------------------------------------------------
+void CAspSettingViewDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
+                                            TListBoxEvent aEventType)
+	{
+    switch ( aEventType )
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            HandleOKL();
+            break;
+        default:
+           break;
+        }
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::PreLayoutDynInitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::PreLayoutDynInitL()
+    {
+    iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAspSettingViewDialogList);
+    
+   	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
+    
+	iSettingListBox->SetListBoxObserver(this);
+	iSettingListBox->CreateScrollBarFrameL(ETrue);
+	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
+	
+	SetIconsL();
+	
+	// create array of setting items (iSettingList)
+	CreateSettingsListL();
+
+	// add setting headers into listbox
+	UpdateListBoxL(iSettingListBox, iSettingList);
+
+	if (iDataProviderId)
+		{
+		iSettingListBox->SetCurrentItemIndex(GetIndexFromProvider(iDataProviderId));
+		}
+    iProfile->GetName(iBuf);
+	iStatusPaneHandler->SetTitleL(iBuf);
+	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::SetIconsL
+//
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::SetIconsL()
+    {
+    if (!iSettingListBox)
+    	{
+    	return;
+    	}
+ 
+ 	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
+	CleanupStack::PushL(icons);
+	
+	icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add,
+	                     EMbmAspsyncutilQgn_indi_sett_protected_add_mask));
+	
+    // delete old icons
+    CArrayPtr<CGulIcon>* arr =
+    iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
+    
+    if (arr)
+    	{
+    	arr->ResetAndDestroy();
+	    delete arr;
+	    arr = NULL;
+    	}
+
+	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
+	CleanupStack::Pop(icons);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::IconL
+// 
+// -----------------------------------------------------------------------------
+//
+CGulIcon* CAspSettingViewDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
+	{
+    return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspSettingViewDialog::ProcessCommandL
+//
+// Handle commands from menu.
+//------------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::ProcessCommandL(TInt aCommandId)
+	{
+	HideMenu();
+
+	switch (aCommandId)
+		{
+		case EAknCmdHelp:
+			{
+			TUtil::LaunchHelpAppL(iEikonEnv);
+            break;
+			}
+
+		case EAspMenuCmdChange:
+		case EAspMenuCmdOpen:
+			{				
+			HandleOKL();
+			break;
+			}
+		    
+        case EAspMenuCmdExit:
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+			// close dialog and exit calling application
+			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
+			break;
+			}
+
+		default:			
+		    break;
+		}
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspSettingViewDialog::OkToExitL
+//
+//------------------------------------------------------------------------------
+//
+TBool CAspSettingViewDialog::OkToExitL(TInt aButtonId)
+	{
+	if (aButtonId == EEikBidCancel || aButtonId == EAknSoftkeyBack)
+		{
+		return ETrue; // close dialog
+		}
+
+	if (aButtonId == EAknSoftkeyOpen)  // MSK
+        {
+	    HandleOKL();
+		return EFalse;  // leave dialog open
+		}
+
+	return CAknDialog::OkToExitL(aButtonId);
+	}
+
+
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::OfferKeyEventL
+// 
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CAspSettingViewDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (aKeyEvent.iCode)
+			{
+			case EKeyEscape:  // framework calls this when dialog must shut down
+				{
+				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+        		}
+
+			default:
+				{
+			    break;
+				}
+			}
+		}
+
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
+	}
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::HandleResourceChange
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::HandleResourceChange(TInt aType)
+    {   
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        iSettingListBox->SetSize(mainPaneRect.Size());
+        CCoeControl::HandleResourceChange(aType);
+		DrawDeferred();
+	    return;
+		}
+		
+    if (aType == KAknsMessageSkinChange)
+        {
+        TRAP_IGNORE(SetIconsL());
+        }
+		
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+//------------------------------------------------------------------------------
+// CAspSettingViewDialog::HandleOKL
+//
+//------------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::HandleOKL()
+	{
+	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
+
+	EditSettingItemL(*item);
+	SetVisibility();
+	UpdateListBoxL(iSettingListBox, iSettingList);
+	
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::CreateSettingsListL
+// 
+// Function creates setting list array (iSettingsList).
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::CreateSettingsListL()
+	{
+	
+	AddProfileSettingItemL();
+#ifdef RD_DSUI_TIMEDSYNC
+
+	AddSchedulingSettingItemL();
+	
+#endif
+	AddContentItemsL();
+	SetVisibility();
+	UpdateListBoxL(iSettingListBox, iSettingList);
+	
+	}
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::AddProfileSettingItemL
+// 
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::AddProfileSettingItemL()
+	{
+	
+	CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(R_ASP_SETTING_FOLDER_PROFILE);
+	item->iItemId = EAspProfileSetting;
+	item->iItemType = CAspListItemData::ETypeProfileSetting;
+	item->iNumberData = KErrNotFound;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+		
+	}
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::AddSchedulingSettingItemL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::AddSchedulingSettingItemL()
+	{
+    CAspListItemData* item = CAspListItemData::NewLC();
+	item->SetHeaderL(R_ASP_SETTING_FOLDER_SCHEDULE);
+	item->iItemId = EAspSchedulingSetting;
+	item->iItemType = CAspListItemData::ETypeSchedulingSetting;
+	item->iNumberData = KErrNotFound;
+	iSettingList->AppendL(item);
+	CleanupStack::Pop(item);
+	}
+
+	
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::AddContentItemsL
+// 
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::AddContentItemsL()
+	{
+   	TInt count = iContentList->ProviderCount();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
+		TInt appId = TUtil::AppIdFromProviderId(providerItem.iDataProviderId);
+		if (iApplicationId != EApplicationIdSync && iApplicationId != appId)
+			{
+			continue;
+			}
+				
+		HBufC* firstLine = CAspResHandler::GetContentSettingLC(
+		                                   providerItem.iDataProviderId,
+		                                   providerItem.iDisplayName);
+		
+	    CAspListItemData* item = CAspListItemData::NewLC();
+    
+    	item->SetHeaderL(firstLine->Des());
+	    item->iItemId = EAspSyncContent;
+	    item->iItemType = CAspListItemData::ETypeSyncContent;
+	    item->iNumberData = providerItem.iDataProviderId;
+	    iSettingList->AppendL(item);
+	    CleanupStack::Pop(item);
+	    
+	    CleanupStack::PopAndDestroy(firstLine);
+    	}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CAspSettingViewDialog::UpdateListBoxL
+// 
+// Add settings headers into listbox.
+// ----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::UpdateListBoxL(CEikTextListBox* aListBox,
+                                       CAspSettingList* aItemList)
+	{
+		
+	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
+	arr->Reset();
+
+	TInt count = aItemList->Count();
+	for (TInt i=0; i<count; i++ )
+		{	
+		CAspListItemData* item = (*aItemList)[i];
+			
+		TBool convert = ETrue;
+		if (item->iHidden != EVisibilityHidden)
+			{
+			HBufC* hBuf = item->ListItemTextL(convert);
+			CleanupStack::PushL(hBuf);
+			
+			arr->AppendL(hBuf->Des());
+			
+			// store listbox index (from zero up) into setting item 
+			item->iIndex = arr->Count() - 1;
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+		else
+			{
+			item->iIndex = KErrNotFound;
+			}
+		}
+
+	ListBox()->HandleItemAdditionL();
+	}
+
+
+//------------------------------------------------------------------------------
+// CAspSettingViewDialog::EditSettingItemL
+//
+// Calls setting editing functions. 
+//------------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::EditSettingItemL(CAspListItemData& aItem)
+	{
+	TBool ret = KErrNone;
+	switch (aItem.iItemType)
+		{
+    	case CAspListItemData::ETypeProfileSetting:
+    	ret = EditSettingItemProfileSettingL();
+			break;
+
+		case CAspListItemData::ETypeSchedulingSetting:
+    	ret = EditSettingItemSchedulingSettingL();
+			break;
+
+		case CAspListItemData::ETypeSyncContent:
+			ret = EditSettingItemSyncContentL(aItem);
+			break;
+
+		default:
+		    break;
+		}
+	
+		User::LeaveIfError(ret);
+	
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::EditSettingItemProfileSettingL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingViewDialog::EditSettingItemProfileSettingL()
+	{
+ 	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfile = iProfile;
+    param.iProfileList = iProfileList;
+    param.iMode = iEditMode;
+    param.iContentList = iContentList;
+    
+    CAspProfileDialog::ShowDialogL(param);
+    
+    //Update profile name in navi pane ,to reflect any name change during profile editing
+    iProfile->GetName(iBuf);
+	iStatusPaneHandler->SetTitleL(iBuf);
+	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
+     
+    return KErrNone;
+	}
+	
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::EditSettingItemSchedulingSettingL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingViewDialog::EditSettingItemSchedulingSettingL()
+	{
+ 	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfileList = iProfileList;
+    param.iProfile = iProfile;
+	param.iContentList = iContentList;
+	param.iSchedule = iSchedule;
+
+	TBool settingEnforcement = TUtil::SettingEnforcementState();
+	
+	CAspSchedule* schedule = CAspSchedule::NewLC();
+	if (schedule->IsAutoSyncEnabled() && !settingEnforcement)
+		{
+		TInt profileId = schedule->ProfileId();
+		if(profileId != iProfile->ProfileId() && profileId != KErrNotFound)
+			{
+			if(!TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_AUTO_SYNC_ON))
+				{
+				CleanupStack::PopAndDestroy(schedule);
+				return KErrNone;
+				}
+			}
+		}
+    CleanupStack::PopAndDestroy(schedule);
+
+    CAspScheduleDialog::ShowDialogL(param);
+
+    return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CAspContentListDialog::EditSettingItemSyncContentL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspSettingViewDialog::EditSettingItemSyncContentL(CAspListItemData& aItem)
+	{
+
+	TAspParam param(iApplicationId, iSyncSession);
+    param.iProfile = iProfile;
+    param.iDataProviderId = aItem.iNumberData;
+    param.iSyncTaskId = KErrNotFound;
+    param.iContentList = iContentList;
+
+    CAspContentDialog::ShowDialogL(param);
+
+	    
+    return KErrNone;
+	}
+
+   
+//-----------------------------------------------------------------------------
+// CAspSettingViewDialog::GetItemForIndex
+// 
+// Find item in list position aIndex.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspSettingViewDialog::GetItemForIndex(TInt aIndex)
+	{
+	CAspListItemData* item = NULL;
+	
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iIndex == aIndex)
+			{
+			item = temp;
+			break;
+			}
+		}
+
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+//-----------------------------------------------------------------------------
+// CAspSettingViewDialog::SetVisibility
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSettingViewDialog::SetVisibility()
+	{
+	
+	if (iProfile->BearerType() == EAspBearerInternet)
+		{
+		Item(EAspSchedulingSetting)->iHidden = EVisibilityNormal;
+		}
+	else
+		{
+		Item(EAspSchedulingSetting)->iHidden = EVisibilityHidden;
+		}
+	}
+//-----------------------------------------------------------------------------
+// CAspSettingViewDialog::GetIndexFromProvider
+// 
+// Find index for a provider
+//-----------------------------------------------------------------------------
+//
+TInt CAspSettingViewDialog::GetIndexFromProvider(TInt aDataProvider)
+	{
+	
+	TInt count = iSettingList->Count();
+	TInt index;
+	for (index=0; index<count; index++)
+		{
+		CAspListItemData* temp = (*iSettingList)[index];
+		if (temp->iNumberData == aDataProvider)
+			{
+			break;
+			}
+		}
+	return index;
+	}
+	
+
+//-----------------------------------------------------------------------------
+// CAspSettingViewDialog::Item
+// 
+// Find item with aItemId.
+//-----------------------------------------------------------------------------
+//
+CAspListItemData* CAspSettingViewDialog::Item(TInt aItemId)
+	{
+	CAspListItemData* item = NULL;
+
+	TInt count = iSettingList->Count();
+	for (TInt i=0; i<count; i++)
+		{
+		CAspListItemData* temp = (*iSettingList)[i];
+		if (temp->iItemId == aItemId)
+			{
+			item = temp;
+			break;
+			}
+		}
+	
+	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
+
+    return item;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSettingViewDialog::ListBox
+// 
+// -----------------------------------------------------------------------------
+//
+CAknSettingStyleListBox* CAspSettingViewDialog::ListBox()
+	{
+	return iSettingListBox;
+	}
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspState.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+
+#include "AspState.h"
+#include "AspUtil.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CAspState::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAspState* CAspState::NewL()
+    {
+    CAspState* self = new (ELeave) CAspState();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspState::~CAspState()
+    {
+    delete iSyncContent;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspState::CAspState
+//
+// -----------------------------------------------------------------------------
+//
+CAspState::CAspState()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspState::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::ConstructL()
+    {
+	Reset();
+	
+	iSyncContent = HBufC::NewL(0);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspState::Reset
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::Reset()
+    {
+	iSyncPhase = EPhaseNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspState::SetSyncPhase
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::SetSyncPhase(TInt aPhase)
+	{
+	if (aPhase != iSyncPhase)
+		{
+		iSyncPhase = aPhase;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::SyncPhase
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspState::SyncPhase()
+	{
+	return iSyncPhase;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::IncreaseProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::IncreaseProgress()
+	{
+	iProgressCount++;
+	iProgressCount2++;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::IncreaseProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::IncreaseProgress(TInt aCount)
+	{
+	if (aCount > 0)
+		{
+		iProgressCount = iProgressCount + aCount;
+		iProgressCount2++;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::Progress
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspState::Progress()
+	{
+	return iProgressCount;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::SetProgress
+//
+// -----------------------------------------------------------------------------
+//
+/*
+void CAspState::SetProgress(TInt aCount)
+	{
+	if (aCount >= 0 && aCount <= KTotalProgress)
+		{
+		iProgressCount = aCount;
+		iProgressCount2++;
+		}
+	}
+*/
+
+// -----------------------------------------------------------------------------
+// CAspState::SetTotalProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::SetTotalProgress(TInt aCount)
+	{
+	if (aCount < 0)
+		{
+		iTotalProgressCount = KTotalProgressUnknown;
+		return;
+		}
+		
+	iTotalProgressCount = aCount;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::TotalProgress
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspState::TotalProgress()
+	{
+	return iTotalProgressCount;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::FirstProgress
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspState::FirstProgress()
+	{
+	if (iProgressCount2 == 1)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::SetContentL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::SetContentL(const TDesC& aText)
+	{
+	delete iSyncContent;
+	iSyncContent = NULL;
+	iSyncContent = aText.AllocL();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::Content
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC& CAspState::Content()
+	{
+	__ASSERT_ALWAYS(iSyncContent, TUtil::Panic(KErrGeneral));
+		
+	return *iSyncContent;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::ResetProgress
+//
+// -----------------------------------------------------------------------------
+//
+void CAspState::ResetProgress()
+	{
+	iProgressCount = 0;
+	iProgressCount2 = 0;
+	iTotalProgressCount = 0;
+	
+	TRAP_IGNORE(SetContentL(KNullDesC));
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspState::ProgressKnown
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspState::ProgressKnown()
+	{
+	if (iTotalProgressCount == KTotalProgressUnknown)
+		{
+		return EFalse;
+		}
+
+	return ETrue;
+	}
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1432 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+// INCLUDES
+#include "AspSyncHandler.h"
+#include "AspDebug.h"
+#include "AspSettingDialog.h"
+
+#include <aspsyncutil.mbg>  // for progress dialog bitmap enumerations
+
+#include <SyncMLErr.h>  // sync error codes
+
+#include <ecom/ecom.h>
+#include <ecom/implementationinformation.h>
+#include <rconnmon.h>
+#include <e32std.h> //For TRequestStatus
+#include "CPreSyncPlugin.h"
+#include "AspPreSyncPluginInterface.h"
+
+
+
+/******************************************************************************
+ * class TAspSyncParam
+ ******************************************************************************/
+
+
+// -------------------------------------------------------------------------------
+// TAspSyncParam::TAspSyncParam
+//
+// -------------------------------------------------------------------------------
+//
+TAspSyncParam::TAspSyncParam(TInt aApplicationId)
+ : iApplicationId(aApplicationId), iProfileId(KErrNotFound), iJobId(KErrNotFound),
+   iTaskId(KErrNotFound), iSyncDirection(KErrNotFound), iDialogMode(EModeDialogNoWait)
+	 {
+	 }
+
+
+
+/******************************************************************************
+ * class CAspSyncHandler
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncHandler* CAspSyncHandler::NewL(const TAspParam& aParam)
+    {
+    FLOG( _L("CAspSyncHandler::NewL START") );
+
+    CAspSyncHandler* self = new (ELeave) CAspSyncHandler(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+    FLOG( _L("CAspSyncHandler::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncHandler::~CAspSyncHandler()
+    {
+    FLOG( _L("CAspSyncHandler::~CAspSyncHandler START") );
+    
+    delete iProgressDialog;
+	delete iState;
+	delete iResHandler;
+	delete iActiveCaller;
+	delete iTextResolver;
+	
+	delete iContentList;
+	
+    if (iWait && iWait->IsStarted())
+        {
+        iWait->AsyncStop();
+        }
+	delete iWait;
+	
+	
+	CloseSyncSession();
+	
+	FLOG( _L("CAspSyncHandler::~CAspSyncHandler END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::ConstructL()
+    {
+	FLOG( _L("CAspSyncHandler::ConstructL START") );
+	
+	iState = CAspState::NewL();
+
+	iActiveCaller = CAspActiveCaller::NewL(this);
+	iTextResolver = CTextResolver::NewL();
+	
+	iServerAlertSync = EFalse;
+	iSyncRunning = EFalse;
+	iSyncError = KErrNone;
+	iCurrentSyncJobId = KErrNotFound;
+	iSyncSessionOpen = EFalse;
+	
+	iWait = new (ELeave) CActiveSchedulerWait();
+	
+	FLOG( _L("CAspSyncHandler::ConstructL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::CAspSyncHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncHandler::CAspSyncHandler(const TAspParam& /*aParam*/)
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::SetObserver
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::SetObserver(MAspSyncObserver* aObserver)
+	{
+	iSyncObserver = aObserver;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::HandleDialogEventL (from MAspProgressDialogObserver)
+//
+// 
+// Canceling sequence after user presses "Cancel":
+//
+// 1. framework calls CAspProgressDialog2::OkToExitL
+// 2. OkToExitL calls CAspProgressDialog::DialogDismissedL
+// 3. DialogDismissedL calls CAspSyncHandler::HandleDialogEventL
+// 4. HandleDialogEventL cancels sync (RSyncMLDataSyncJob::StopL)
+//    and updates progress dialog text ("Cancelling")
+// 5. MSyncMLEventObserver::EJobStop arrives (asynchronously)
+//    and CAspProgressDialog is closed
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::HandleDialogEventL(TInt aButtonId)
+    {
+    FLOG( _L("CAspSyncHandler::HandleDialogEventL START") );
+    
+    TBool syncRunning = SyncRunning();
+    
+	//  close handling (eg. end key)
+	if (aButtonId == EKeyPhoneEnd && syncRunning)
+		{
+		TRAPD(err, iSyncJob.StopL());
+
+		if (err != KErrNone)
+			{
+			FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err );
+			}
+
+	    iSyncJob.Close(); // this can be done when job has not been opened
+
+	    CloseSyncSession();
+
+		iSyncRunning = EFalse;
+		
+	 	if (iIsSynchronousOperation && iWait->IsStarted())
+		    {
+	        iWait->AsyncStop();
+		    }
+
+		
+		FLOG( _L("CAspSyncHandler::HandleDialogEventL: end key handling done") );
+		FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
+		return;
+		}
+		
+	// cancel key handling
+	if (aButtonId == EEikBidCancel && syncRunning)
+		{
+		if (iStopEventReceived)
+			{
+			CompleteWithDelay(KErrNone);
+        	FLOG( _L("### EJobStop already received ###") );
+        	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
+	        return;
+			}
+			
+		TInt jobId = CAspProfile::CurrentJob(&iSyncSession);
+       	if (jobId != iCurrentSyncJobId)
+	        {
+	        CompleteWithDelay(KErrNotFound);
+
+	        FLOG( _L("### job conflict (%d/%d) ###"), iCurrentSyncJobId, jobId );
+        	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
+	        return;
+	        }
+
+		TRAPD(err, iSyncJob.StopL());
+       	if (err != KErrNone)
+	        {
+	        CompleteWithDelay(err);
+
+	        FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err );
+        	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
+	        return;
+	        }
+		    
+	    State()->SetSyncPhase(CAspState::EPhaseCanceling);
+        UpdateDialog();
+        
+        FLOG( _L("CAspSyncHandler::HandleDialogEventL: cancel key handling done") );
+		}
+		
+	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
+    }
+
+
+TBool CAspSyncHandler::IsRoamingL()
+    {
+    RConnectionMonitor conMon;
+    
+    conMon.ConnectL();
+
+    TRequestStatus status;
+    TInt registrationStatus(0);
+
+    //check network status
+    conMon.GetIntAttribute(EBearerIdGSM, 0, KNetworkRegistration, 
+                            registrationStatus, status);
+
+    User::WaitForRequest(status);
+    conMon.Close();
+    
+    if (registrationStatus == ENetworkRegistrationRoaming)
+        {
+        return ETrue;   
+        }
+        
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::ReadRepositoryL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::ReadRepositoryL(TInt aKey, TInt& aValue)
+    {
+    CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp);
+    TInt err = rep->Get(aKey, aValue);
+    User::LeaveIfError(err);
+    
+    CleanupStack::PopAndDestroy(rep);
+    }
+
+TInt CAspSyncHandler::BearerTypeL(TInt aProfileId)
+    {    
+    TInt BearerType = KErrNotFound;
+    
+    // sync session
+    RSyncMLSession syncSession;
+    syncSession.OpenL();
+    CleanupClosePushL( syncSession );
+
+    RSyncMLDataSyncProfile syncProfile;
+    syncProfile.OpenL( syncSession, aProfileId, ESmlOpenRead );
+    CleanupClosePushL( syncProfile );
+    
+    // Check if always ask is selected as accesspoint
+    RSyncMLConnection connection;
+
+    TInt err = KErrNone;
+    RArray<TSmlTransportId> arr;
+    
+    TRAP(err, syncProfile.ListConnectionsL(arr));
+    if (err != KErrNone)
+        {
+        syncProfile.Close();
+        CleanupStack::Pop( &syncProfile );
+        return KErrNotFound; 
+        }
+    if (arr.Count() == 0)
+        {
+        syncProfile.Close();
+        CleanupStack::Pop( &syncProfile );
+        arr.Close();  
+        return KErrNotFound; // no connection
+        }
+            
+    TInt transportId = arr[0];
+    arr.Close();
+        
+    TRAP(err, connection.OpenL( syncProfile, transportId ) );
+    CleanupClosePushL( connection );
+
+    if ( err == KErrNone )
+        {
+        TInt id = connection.Identifier();
+        if (id == KUidNSmlMediumTypeInternet.iUid)
+            {
+            BearerType = EAspBearerInternet;
+            }
+        else if (id == KUidNSmlMediumTypeBluetooth.iUid)
+            {
+            BearerType = EAspBearerBlueTooth;
+            }
+        else if (id == KUidNSmlMediumTypeUSB.iUid)
+            {
+            BearerType = EAspBearerUsb;
+            }
+        else if (id == KUidNSmlMediumTypeIrDA.iUid)
+            {
+            BearerType = EAspBearerIrda;
+            }
+        }
+
+    connection.Close();
+    CleanupStack::Pop( &connection );
+    
+    syncProfile.Close();
+    CleanupStack::Pop( &syncProfile );
+            
+    syncSession.Close();
+    CleanupStack::Pop( &syncSession );
+    return BearerType;
+    }
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::SynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::SynchronizeL(TAspSyncParam& aSyncParam)
+	{
+	iServerAlertSync = EFalse;
+	iSyncRunning = EFalse;
+	iCurrentSyncJobId = KErrNotFound;
+	iSyncError = KErrNone;
+	iCompleteEventReceived = EFalse;
+	iStopEventReceived = EFalse;
+	iIsSynchronousOperation = EFalse;
+	TBool bCanSync = ETrue;
+	
+    TInt aValue = 0;
+    ReadRepositoryL(KNSmlDSRoamingFeature, aValue);
+    if(( IsRoamingL() ) && (aValue == EAspRoamingSettingFeatureEnabled))
+        {
+           TInt bearerType = BearerTypeL(aSyncParam.iProfileId);
+           if (bearerType == EAspBearerInternet)           
+            {
+            CPreSyncPluginInterface* syncPluginInterface = CPreSyncPluginInterface::NewL();
+            CPreSyncPlugin* syncPlugin = 
+                syncPluginInterface->InstantiateRoamingPluginLC(aSyncParam.iProfileId);
+
+            if(syncPlugin->IsSupported())
+                {
+                bCanSync = syncPlugin->CanSyncL();
+                }
+
+            CleanupStack::PopAndDestroy(syncPlugin);
+            //syncPluginInterface->UnloadPlugIns();
+            delete  syncPluginInterface;   
+
+            if(!bCanSync)
+                {
+                return;
+                }
+            }        
+        }	
+	
+	State()->SetSyncPhase(CAspState::EPhaseConnecting);
+	State()->ResetProgress();
+	//State()->SetTotalProgress(KTotalProgress);
+	
+	TRAPD(err, DoSynchronizeL(aSyncParam));
+	
+	if (err != KErrNone)
+		{
+		SynchronizeCompleted(err);
+     	return;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::DoSynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::DoSynchronizeL(TAspSyncParam& aSyncParam)
+	{
+	FLOG( _L("CAspSyncHandler::DoSynchronizeL START") );
+    
+	iApplicationId = aSyncParam.iApplicationId;
+	iProfileId = aSyncParam.iProfileId;
+	if (aSyncParam.iDialogMode == EModeDialogWait)
+		{
+		iIsSynchronousOperation = ETrue; // email 3.2 needs synchronous syncing
+		}
+
+	
+	ShowProgressDialogL();
+    OpenSyncSessionL();
+    CreateContentListL();
+    
+    iSyncSession.RequestEventL(*this);     // for MSyncMLEventObserver events
+    iSyncSession.RequestProgressL(*this);  // for MSyncMLProgressObserver events
+    
+ 	if (aSyncParam.iTaskId != KErrNotFound && iProfileId != KErrNotFound)
+		{
+		RArray<TSmlTaskId> arr(1);
+		CleanupClosePushL(arr);
+		User::LeaveIfError(arr.Append(aSyncParam.iTaskId));
+		if (aSyncParam.iSyncDirection != KErrNotFound)
+			{
+			TSmlSyncType syncDirection = TAspTask::SmlSyncDirection(aSyncParam.iSyncDirection);
+			iSyncJob.CreateL(iSyncSession, iProfileId, syncDirection, arr);
+			}
+		else
+			{
+			iSyncJob.CreateL(iSyncSession, iProfileId, arr);
+			}
+			
+		CleanupStack::PopAndDestroy(&arr);
+		}
+	else if (iProfileId != KErrNotFound)
+		{
+		if (aSyncParam.iSyncDirection != KErrNotFound)
+			{
+		    TSmlSyncType syncDirection = TAspTask::SmlSyncDirection(aSyncParam.iSyncDirection);
+			iSyncJob.CreateL(iSyncSession, iProfileId, syncDirection);
+			}
+		else
+			{
+		    iSyncJob.CreateL(iSyncSession, iProfileId);
+			}
+		}
+	else
+		{
+		User::Leave(KErrArgument);
+		}
+		
+	iCurrentSyncJobId = iSyncJob.Identifier();
+	iSyncRunning = ETrue;
+	
+	if (iIsSynchronousOperation)
+		{
+		iWait->Start();  // stop here until sync has completed
+		}
+   
+    FLOG( _L("sync job created: app=%d, profile=%d, job=%d, task=%d"), iApplicationId, iProfileId, aSyncParam.iJobId, aSyncParam.iTaskId );
+    FLOG( _L("CAspSyncHandler::DoSynchronizeL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::SynchronizeCompleted
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::SynchronizeCompleted(TInt aError)
+	{
+	FLOG( _L("CAspSyncHandler::SynchronizeCompleted START") );
+	
+	iSyncRunning = EFalse;
+	
+	if (aError != KErrNone)
+		{
+		iSyncError = aError;
+		}
+   	
+   	iSyncJob.Close(); // this can be done when job has not been opened
+   	
+    TRAP_IGNORE(Dialog()->CancelProgressDialogL());
+	
+	if (iSyncError != KErrNone)
+		{
+	   	CloseSyncSession();
+   		ShowErrorNote();
+      	
+      	FLOG( _L("### sync failed (%d) ###"), iSyncError );
+		}
+	else
+	    {
+      	CloseSyncSession();
+      	TRAP_IGNORE(TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_COMPLETED));
+	    }
+	    
+    if (iSyncObserver)
+    	{
+        TRAP_IGNORE(iSyncObserver->HandleSyncEventL(iSyncError, iProfileId));
+    	}
+    	
+ 	if (iIsSynchronousOperation && iWait->IsStarted())
+		{
+	    iWait->AsyncStop();
+		}
+	    	
+	FLOG( _L("CAspSyncHandler::SynchronizeCompleted END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::OnSyncMLSessionEvent (from MSyncMLEventObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt /*aAdditionalData*/)
+	{
+	FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent START") );
+
+#ifdef _DEBUG
+    LogSessionEvent(aEvent, aIdentifier, aError);
+#endif
+
+    if (iCurrentSyncJobId != aIdentifier)
+    	{
+    	FLOG( _L("### job conflict (%d/%d) ###"), iCurrentSyncJobId, aIdentifier );
+    	FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") );
+    	return; // not our sync job
+    	}
+	
+	if (aEvent == EJobStop)
+		{
+		iStopEventReceived = ETrue;
+		if (aError != KErrNone)
+			{
+			iSyncError = aError;
+			}
+	
+	    if (State()->SyncPhase() == CAspState::EPhaseCanceling)
+		    {
+		    CompleteWithDelay(aError);
+		    }
+        else if (iCompleteEventReceived || iSyncError != KErrNone)
+		    {
+		    CompleteWithDelay(aError);
+		    }
+		}
+    	
+	if (aEvent == EJobStartFailed || aEvent == EJobRejected)
+		{
+		CompleteWithDelay(aError);
+		}
+		
+	FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::CompleteWithDelay
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::CompleteWithDelay(TInt aError)
+	{
+	iActiveCaller->Start(aError, 0); // call SynchronizeCompleted with delay
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::OnSyncMLSyncError (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError, TInt /*aTaskId*/, TInt /*aInfo1*/, TInt /*aInfo2*/)
+	{
+	FLOG( _L("CAspSyncHandler::OnSyncMLSyncError START") );
+	
+	// just store error code - sync is terminated only in function OnSyncMLSessionEvent
+	if (aErrorLevel == ESmlFatalError)
+		{
+		iSyncError = aError;
+		}
+		
+#ifdef _DEBUG
+    LogErrorEvent(aErrorLevel, aError);
+#endif
+
+	FLOG( _L("CAspSyncHandler::OnSyncMLSyncError END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::OnSyncMLSyncProgress (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt /*aInfo2*/)
+	{
+	FLOG( _L("CAspSyncHandler::OnSyncMLSyncProgress START") );
+	
+	if (State()->SyncPhase() == CAspState::EPhaseCanceling)
+		{
+		return; // no progress dialog updating while canceling
+		}
+
+#ifdef _DEBUG
+    LogProgressEvent(aStatus, aInfo1);
+#endif
+	
+	switch (aStatus)
+		{
+		case ESmlConnecting:
+		    State()->SetSyncPhase(CAspState::EPhaseConnecting);
+	        UpdateDialog();
+		    break;
+		case ESmlConnected:
+		    break;
+		case ESmlLoggingOn:
+		    break;
+		case ESmlLoggedOn:
+		    State()->SetSyncPhase(CAspState::EPhaseSynchronizing);
+		    UpdateDialog();
+		    break;
+		case ESmlDisconnected:
+		    State()->SetSyncPhase(CAspState::EPhaseDisconnecting);
+		    UpdateDialog();
+		    break;
+		case ESmlCompleted:
+		    iCompleteEventReceived = ETrue;
+		    
+			if (iStopEventReceived)
+			    {
+			    FLOG( _L("### EJobStop already received ###") );
+			    CompleteWithDelay(iSyncError);
+			    }
+            else
+            	{
+            	State()->SetSyncPhase(CAspState::EPhaseDisconnecting);
+		        UpdateDialog();
+            	}
+		    break;
+
+		case ESmlSendingModificationsToServer:
+		    State()->SetSyncPhase(CAspState::EPhaseSending);
+   		    State()->ResetProgress();
+		    State()->SetTotalProgress(aInfo1); // set total sync event count
+
+     	    UpdateDialog();
+		    break;
+		case ESmlReceivingModificationsFromServer:
+		    State()->SetSyncPhase(CAspState::EPhaseReceiving);
+   		    State()->ResetProgress();
+		    State()->SetTotalProgress(aInfo1); // set total sync event count
+
+	        UpdateDialog();
+		    break;
+		    
+		case ESmlSendingMappingsToServer:
+		    State()->SetSyncPhase(CAspState::EPhaseSynchronizing);
+		    UpdateDialog();
+		    break;
+		
+		default:
+		    break;
+		}
+		
+	FLOG( _L("CAspSyncHandler::OnSyncMLSyncProgress END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::OnSyncMLDataSyncModifications (from MSyncMLProgressObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OnSyncMLDataSyncModifications(TInt aTaskId, 
+                      const TSyncMLDataSyncModifications& aClientModifications,
+                      const TSyncMLDataSyncModifications& aServerModifications)
+	{
+	
+    if (!Dialog()->ProgressDialog())
+    	{
+    	//it is observed that some times this call back comes 
+    	//just after deleting progress dialog.
+    	return;
+    	}
+	
+	TRAPD(err, OnSyncMLDataSyncModificationsL(aTaskId, aClientModifications, aServerModifications));
+	if (err != KErrNone)
+		{
+		FLOG( _L("### CAspSyncHandler::OnSyncMLDataSyncModificationsL failed (%d) ###"), err );
+		FLOG( _L("### CAspSyncHandler::OnSyncMLDataSyncModificationsL failed (%d) ###"), err );
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::OnSyncMLDataSyncModificationsL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OnSyncMLDataSyncModificationsL(TInt aTaskId,
+                      const TSyncMLDataSyncModifications& aClientModifications,
+                      const TSyncMLDataSyncModifications& aServerModifications)
+	{
+	FLOG( _L("CAspSyncHandler::OnSyncMLDataSyncModificationsL START") );
+	
+
+	if (State()->Progress() == 0)
+		{
+	    TInt index = iContentList->FindProviderIndexForTask(aTaskId);
+	
+	    if (index != KErrNotFound)
+		    {
+		    TAspProviderItem& item = iContentList->ProviderItem(index);
+		    HBufC* hBuf = CAspResHandler::GetContentNameLC(item.iDataProviderId,
+		                                                   item.iDisplayName);
+	        State()->SetContentL(hBuf->Des());
+
+#ifdef _DEBUG
+            LogModificationEvent(aTaskId, hBuf->Des());
+#endif
+
+	        CleanupStack::PopAndDestroy(hBuf);
+		    }
+	    else
+		    {
+		    State()->SetContentL(KNullDesC);
+		    FLOG( _L("### task not found (%d) ###"), aTaskId );
+		    }
+		}
+	
+	// Set sync event count. On last OnSyncMLDataSyncModifications call it 
+	// must match total sync event count (set in OnSyncMLSyncProgress). 
+	TInt count = ProgressCount(aClientModifications, aServerModifications);
+	State()->IncreaseProgress(count);
+	
+	UpdateDialog();
+
+	
+#ifdef _DEBUG
+    LogModificationEvent(aTaskId, aClientModifications, aServerModifications);
+#endif
+
+
+	FLOG( _L("CAspSyncHandler::OnSyncMLDataSyncModificationsL END") );
+	FLOG( _L(" ") );
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::UpdateDialog
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::UpdateDialog()
+	{
+	TRAPD(err, UpdateDialogL());
+	
+	if (err != KErrNone)
+		{
+		FLOG( _L("### CAspSyncHandler::UpdateDialogL failed (%d) ###"), err );
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::UpdateDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::UpdateDialogL()
+	{
+	if (!SyncRunning())
+		{
+		FLOG( _L("### CAspSyncHandler::UpdateDialogL: Sync not running ###") );
+		return;
+		}
+
+	TInt phase = State()->SyncPhase();
+	
+	if (phase == CAspState::EPhaseConnecting)
+		{
+		Dialog()->StartAnimationL();
+		HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_CONN);  // "Connecting"
+		Dialog()->UpdateTextL(hBuf->Des());
+		CleanupStack::PopAndDestroy(hBuf);
+		}
+
+	if (phase == CAspState::EPhaseSynchronizing)
+		{
+		Dialog()->StartAnimationL();
+		HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_SYNC); // "Synchronizing"
+		Dialog()->UpdateTextL(hBuf->Des());
+		CleanupStack::PopAndDestroy(hBuf);
+		}
+
+	if (phase == CAspState::EPhaseDisconnecting)
+		{
+		Dialog()->StartAnimationL();
+		HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_SYNC_DISC);  // "Disconnecting"
+		Dialog()->UpdateTextL(hBuf->Des());
+		CleanupStack::PopAndDestroy(hBuf);
+		}
+
+	if (phase == CAspState::EPhaseCanceling)
+		{
+		Dialog()->StartAnimationL();
+		HBufC* hBuf = ResHandlerL()->ReadLC(R_SYNCSTATUS_CANC);  // "Canceling"
+		Dialog()->UpdateTextL(hBuf->Des());
+		CleanupStack::PopAndDestroy(hBuf);
+		Dialog()->HideButtonL();
+		}
+
+//The number of Emails-Synced NOT printed if Sync is started from Sync E-mail Application
+	if (iApplicationId == EApplicationIdEmail)
+	     return;
+	
+	if (phase == CAspState::EPhaseSending || phase == CAspState::EPhaseReceiving)
+		{
+		if (State()->Progress() == 0 || State()->TotalProgress() == 0)
+			{
+			return; 
+			}
+			
+		if (State()->FirstProgress())
+			{
+			if (State()->ProgressKnown())
+				{
+    			Dialog()->CancelAnimation();
+	    		Dialog()->SetFinalProgress(State()->TotalProgress());
+     	    	Dialog()->SetProgress(State()->Progress());
+				}
+			else
+				{
+    			Dialog()->SetFinalProgress(0);
+	    	    Dialog()->StartAnimationL();
+				}
+			}
+		else if (State()->ProgressKnown())
+			{
+			Dialog()->SetProgress(State()->Progress());
+			}
+			
+		HBufC* hBuf = ResHandlerL()->ReadProgressTextLC(State()->Content(), phase);
+		
+
+#ifdef _DEBUG
+		TBuf<KBufSize> buf1; TBuf<KBufSize> buf2;
+		buf1 = hBuf->Des();
+		buf2.Format(_L("%S\n (%d/%d)"), &buf1, State()->Progress(), State()->TotalProgress());
+		CleanupStack::PopAndDestroy(hBuf);
+		hBuf = NULL;
+		hBuf = buf2.AllocLC();
+#endif
+		
+   	
+    	Dialog()->UpdateTextL(hBuf->Des());
+		CleanupStack::PopAndDestroy(hBuf);
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::UpdateRequired
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncHandler::UpdateRequired()
+	{
+    const TInt KProgressLevel_1 = 10;
+    const TInt KProgressLevel_2 = 20;
+    const TInt KProgressLevel_3 = 50;
+    
+    const TInt KProgressStep_1 = 5;
+    const TInt KProgressStep_2 = 10;
+    const TInt KProgressStep_3 = 20;
+    
+    TInt total = State()->TotalProgress();
+    TInt current = State()->Progress();
+    TBool firstProgress = State()->FirstProgress();
+    TBool progressKnown = State()->ProgressKnown();
+    
+    // always show first progress
+    if (firstProgress)
+    	{
+    	return ETrue;
+    	}
+    
+    // handle case where total progress count is not known
+    if (!progressKnown)
+    	{
+    	if (current <= KProgressStep_2)
+    		{
+    		return ETrue;
+    		}
+    	else if (current % KProgressStep_1 == 0)
+    		{
+    		return ETrue;
+    		}
+    		
+    	return EFalse;
+    	}
+    
+    // handle case where total progress count is known
+    if (current == total)
+    	{
+    	return ETrue; // always show last progress
+    	}
+    else if (total <= KProgressLevel_1)
+    	{
+    	return ETrue;
+    	}
+    else if (total > KProgressLevel_1 && total <= KProgressLevel_2)
+		{
+    	if (current % KProgressStep_1 == 0)
+			{
+			return ETrue;
+			}
+		}
+    else if (total > KProgressLevel_2 && total <= KProgressLevel_3)
+		{
+    	if (current % KProgressStep_2 == 0)
+			{
+			return ETrue;
+			}
+		}
+    else if (total > KProgressLevel_3)
+		{
+    	if (current % KProgressStep_3 == 0)
+			{
+			return ETrue;
+			}
+		}
+
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::HandleActiveCallL (from MAspActiveCallerObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::HandleActiveCallL(TInt aCallId)
+	{
+    SynchronizeCompleted(aCallId);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::ShowErrorNote
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::ShowErrorNote()
+	{
+	if (iSyncError == KErrNone || iSyncError == KErrCancel)
+		{
+		return; // nothing to show
+		}
+
+	// show sync engine error
+	if (iSyncError <= SyncMLError::KErrSyncEngineErrorBase)
+		{
+		HBufC* hBuf = NULL;
+		hBuf = TAspSyncError::GetSmlErrorText(iSyncError, 0);
+		if (hBuf)  // hBuf can be NULL
+ 			{
+     	   	TRAP_IGNORE(TDialogUtil::ShowErrorQueryL(hBuf->Des()));
+	     	delete hBuf;
+			}
+			
+		return;
+		}
+
+    // show system error
+    TPtrC errorMsg;
+    
+    errorMsg.Set(iTextResolver->ResolveErrorString(iSyncError, CTextResolver::ECtxNoCtxNoSeparator));
+	
+	TRAP_IGNORE(TDialogUtil::ShowErrorQueryL(errorMsg));
+    }
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::ShowProgressDialogL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::ShowProgressDialogL()
+	{
+	delete iProgressDialog;
+	iProgressDialog = NULL;
+	iProgressDialog = CAspProgressDialog::NewL(this);
+	
+	TInt resId = R_SYNCSTATUS_SYNC_CONN;
+	if (iApplicationId == EApplicationIdEmail)
+		{
+		resId = R_SYNCSTATUS_SYNC_SYNC;
+		}
+	
+	HBufC* hBuf = CAspResHandler::ReadLC(resId);
+	
+	iProgressDialog->SetApplicationId(iApplicationId);
+	
+   	TFileName bitmapName;
+	CAspResHandler::GetBitmapFileName(bitmapName);
+	
+	iProgressDialog->LaunchProgressDialogL(hBuf->Des(),
+	                                       KAknsIIDQgnNoteSml, 
+	                                       bitmapName,
+	                                       EMbmAspsyncutilQgn_note_sml,
+	                                       EMbmAspsyncutilQgn_note_sml_mask);
+	CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::CreateContentListL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::CreateContentListL()
+    {
+    TAspParam param(iApplicationId, &iSyncSession);
+
+    CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(iProfileId, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
+    
+	param.iProfile = profile;
+	param.iMode = CAspContentList::EInitAll;
+	
+	delete iContentList;
+	iContentList = NULL;
+	iContentList = CAspContentList::NewL(param);
+	
+    CleanupStack::PopAndDestroy(profile);	
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::CheckLocalDatabaseL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::CheckLocalDatabaseL(TInt aProfileId)
+    {
+    TAspParam param(iApplicationId, &iSyncSession);
+
+    CAspProfile* profile = CAspProfile::NewLC(param);
+    profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
+    
+	TInt dataProviderId = KErrNotFound;
+	TBool databaseFound = TAspTask::CheckLocalDatabase(profile, dataProviderId);
+	CleanupStack::PopAndDestroy(profile);
+	
+	if (!databaseFound)
+		{
+		User::Leave(SyncMLError::KErrClientDatabaseNotFound);
+		}
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::Dialog
+//
+// -----------------------------------------------------------------------------
+//
+CAspProgressDialog* CAspSyncHandler::Dialog()
+	{
+	__ASSERT_DEBUG(iProgressDialog, TUtil::Panic(KErrGeneral));
+
+	return iProgressDialog;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::State
+//
+// -----------------------------------------------------------------------------
+//
+CAspState* CAspSyncHandler::State()
+	{
+	__ASSERT_DEBUG(iState, TUtil::Panic(KErrGeneral));
+
+	return iState;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncHandler::ResHandlerL
+//
+// -----------------------------------------------------------------------------
+//
+CAspResHandler* CAspSyncHandler::ResHandlerL()
+	{
+	if (!iResHandler)
+		{
+		iResHandler = CAspResHandler::NewL();
+		}
+
+	return iResHandler;
+	}
+
+
+// -----------------------------------------------------------------------------
+// SyncRunning
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncHandler::SyncRunning()
+	{
+	return iSyncRunning;
+	}
+
+// -----------------------------------------------------------------------------
+// IsServerAlertSync
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncHandler::IsServerAlertSync()
+	{
+	return iServerAlertSync;
+	}
+
+
+// -----------------------------------------------------------------------------
+// OpenSyncSessionL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::OpenSyncSessionL()
+	{
+	if (!iSyncSessionOpen)
+		{
+        TRAPD(err, iSyncSession.OpenL());
+        
+        if (err != KErrNone)
+        	{
+        	FLOG( _L("### CAspSyncHandler: RSyncMLSession::OpenL failed (%d) ###"), err );
+        	User::Leave(err);
+        	}
+
+		iSyncSessionOpen = ETrue;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CloseSyncSession
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::CloseSyncSession()
+	{
+	if (iSyncSessionOpen)
+		{
+		iSyncSession.Close();
+		iSyncSessionOpen = EFalse;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// ProgressCount
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspSyncHandler::ProgressCount(const TSyncMLDataSyncModifications& aC, 
+                                    const TSyncMLDataSyncModifications& aS)
+	{
+	TInt num1 = aC.iNumAdded + aC.iNumReplaced + aC.iNumMoved + aC.iNumDeleted + aC.iNumFailed;
+	TInt num2 = aS.iNumAdded + aS.iNumReplaced + aS.iNumMoved + aS.iNumDeleted + aS.iNumFailed;
+	
+	return num1 + num2;
+	}
+	
+	
+
+#ifdef _DEBUG
+
+
+// -----------------------------------------------------------------------------
+// LogModificationEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::LogModificationEvent(TInt aTaskId, const TSyncMLDataSyncModifications& aC, const TSyncMLDataSyncModifications& aS)
+	{
+	TInt num1 = State()->Progress();
+	TInt num2 = State()->TotalProgress();
+	
+	if (num1 > num2 && num2 != -1)
+		{
+		FTRACE( RDebug::Print(_L("### syncui: task=%d, progress=%d, totalprogress=%d ###"), aTaskId, num1, num2) );
+		FLOG(_L("### syncui: task=%d, progress=%d, totalprogress=%d ###"), aTaskId, num1, num2);
+		}
+	else
+		{
+		FTRACE( RDebug::Print(_L("syncui: task=%d, progress=%d, totalprogress=%d"), aTaskId, num1, num2) );
+		FLOG(_L("syncui: task=%d, progress=%d, totalprogress=%d"), aTaskId, num1, num2);
+		}
+		
+	num1 = aC.iNumAdded + aC.iNumReplaced + aC.iNumMoved + aC.iNumDeleted + aC.iNumFailed;
+	num2 = aS.iNumAdded + aS.iNumReplaced + aS.iNumMoved + aS.iNumDeleted + aS.iNumFailed;
+	
+	if ( (num1>0 && num2>0) || (num1<0 || num2<0) || (num1==0 && num2==0) )
+		{
+		FLOG( _L("### parameter error ###") );
+		}
+		
+    FTRACE( RDebug::Print(_L("client: add=%d, rep=%d, mov=%d del=%d fai=%d"), aC.iNumAdded, aC.iNumReplaced, aC.iNumMoved, aC.iNumDeleted, aC.iNumFailed) );
+    FTRACE( RDebug::Print(_L("server: add=%d, rep=%d, mov=%d del=%d fai=%d"), aS.iNumAdded, aS.iNumReplaced, aS.iNumMoved, aS.iNumDeleted, aS.iNumFailed) );
+    
+    FLOG(_L("client: add=%d, rep=%d, mov=%d del=%d fai=%d"), aC.iNumAdded, aC.iNumReplaced, aC.iNumMoved, aC.iNumDeleted, aC.iNumFailed);
+    FLOG(_L("server: add=%d, rep=%d, mov=%d del=%d fai=%d"), aS.iNumAdded, aS.iNumReplaced, aS.iNumMoved, aS.iNumDeleted, aS.iNumFailed);
+	}
+
+
+// -----------------------------------------------------------------------------
+// LogModificationEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::LogModificationEvent(TInt aTaskId, const TDesC& aText)
+	{
+	FTRACE( RDebug::Print(_L("progress = 0, task id = %d, task name ='%S'"), aTaskId, &aText) );
+	FLOG(_L("progress = 0, task id = %d, task name ='%S'"), aTaskId, &aText);
+	}
+
+
+// -----------------------------------------------------------------------------
+// LogSessionEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::LogSessionEvent(TEvent& aEvent, TInt aIdentifier, TInt aError)
+	{
+    TBuf<KBufSize> eventStr;
+    GetSyncEventText(eventStr, aEvent);
+
+    TBuf<KBufSize> errStr;
+    TAspSyncError::GetSyncMLErrorText(errStr, aError);
+
+	if (aError == KErrNone)
+		{
+		FTRACE( RDebug::Print(_L("event='%S' err='%S' job= %d curjob= %d"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId) );
+		FLOG(_L("event='%S' err='%S' job= %d curjob= %d"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId);
+		}
+	else
+		{
+		FTRACE( RDebug::Print(_L("### event='%S' err='%S' job= %d curjob= %d ###"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId) );
+		FLOG(_L("### event='%S' err='%S' job= %d curjob= %d ###"), &eventStr, &errStr, aIdentifier, iCurrentSyncJobId);
+		}
+	}
+	
+
+// -----------------------------------------------------------------------------
+// LogProgressEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::LogProgressEvent(TStatus& aStatus, TInt aInfo1)
+	{
+    TBuf<KBufSize> statusStr;
+    GetSyncStatusText(statusStr, aStatus);
+    FTRACE( RDebug::Print(_L("OnSyncMLSyncProgress: status = '%S' info1 = %d"), &statusStr, aInfo1) );
+    FLOG(_L("OnSyncMLSyncProgress: status = '%S' info1 = %d"), &statusStr, aInfo1);
+    
+   	TInt num1 = State()->Progress();
+   	TInt num2 = State()->TotalProgress();
+   	if (num1 != num2 && num2 != -1)
+   		{
+   		FTRACE( RDebug::Print(_L("### progress count error (%d/%d) ###"), num1, num2) );
+   		FLOG(_L("### progress count error (%d/%d) ###"), num1, num2);
+   		}
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// LogErrorEvent
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::LogErrorEvent(TErrorLevel aErrorLevel, TInt aError)
+	{
+    TBuf<KBufSize> errStr;
+    TAspSyncError::GetSyncMLErrorText(errStr, aError);
+    
+    if (aErrorLevel == ESmlFatalError)
+    	{
+    	FTRACE( RDebug::Print(_L("### OnSyncMLSyncError: fatalerror = %S ###"), &errStr) );
+    	FLOG(_L("### OnSyncMLSyncError: fatalerror = %S ###"), &errStr);
+    	}
+    else
+    	{
+    	FTRACE( RDebug::Print(_L("### OnSyncMLSyncError: error = %S ###"), &errStr) );
+    	FLOG(_L("### OnSyncMLSyncError: error = %S ###"), &errStr);
+    	}
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// GetSyncStatusText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::GetSyncStatusText(TDes& aText, MSyncMLProgressObserver::TStatus aStatus)
+	{
+    aText = _L("Unknown");
+    		
+	if (aStatus == MSyncMLProgressObserver::ESmlConnecting)
+		{
+		aText = _L("ESmlConnecting");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlConnected)
+		{
+		aText = _L("ESmlConnected");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlLoggingOn)
+		{
+		aText = _L("ESmlLoggingOn");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlLoggedOn)
+		{
+		aText = _L("ESmlLoggedOn");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlDisconnected)
+		{
+		aText = _L("ESmlDisconnected");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlCompleted)
+		{
+		aText = _L("ESmlCompleted");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlSendingModificationsToServer)
+		{
+		aText = _L("ESmlSendingModificationsToServer");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlReceivingModificationsFromServer)
+		{
+		aText = _L("ESmlReceivingModificationsFromServer");
+		}
+	if (aStatus == MSyncMLProgressObserver::ESmlSendingMappingsToServer)
+		{
+		aText = _L("ESmlSendingMappingsToServer");
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// GetSyncEventText
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncHandler::GetSyncEventText(TDes& aText, MSyncMLEventObserver::TEvent aEvent)
+	{
+    aText = _L("Unknown");
+    		
+	if (aEvent == MSyncMLEventObserver::EJobStart)
+		{
+		aText = _L("EJobStart");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobStartFailed)
+		{
+		aText = _L("EJobStartFailed");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobStop)
+		{
+		aText = _L("EJobStop");
+		}
+	if (aEvent == MSyncMLEventObserver::EJobRejected)
+		{
+		aText = _L("EJobRejected");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileCreated)
+		{
+		aText = _L("EProfileCreated");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileChanged)
+		{
+		aText = _L("EProfileChanged");
+		}
+	if (aEvent == MSyncMLEventObserver::EProfileDeleted)
+		{
+		aText = _L("EProfileDeleted");
+		}
+	if (aEvent == MSyncMLEventObserver::ETransportTimeout)
+		{
+		aText = _L("ETransportTimeout");
+		}
+	if (aEvent == MSyncMLEventObserver::EServerSuspended)
+		{
+		aText = _L("EServerSuspended");
+		}
+	if (aEvent == MSyncMLEventObserver::EServerTerminated)
+		{
+		aText = _L("EServerTerminated");
+		}
+	}
+
+#endif
+
+
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncUtil.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,818 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+// INCLUDES
+#include "AspSyncUtil.h"
+#include "AspDialogUtil.h"
+#include "AspProfileDialog.h"
+#include "AspProfileWizardDialog.h"
+#include "AspAutoSyncHandler.h"
+
+#include "AspSyncUtil.rh"
+#include "AspDebug.h"
+
+#include <AiwCommon.hrh> // for application ids 
+#include <DataSyncInternalPSKeys.h>
+
+#ifdef RD_DSUI_TIMEDSYNC 
+#include "AspSettingViewDialog.h"
+#endif
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncUtil* CAspSyncUtil::NewL()
+    {
+	FLOG( _L("CAspSyncUtil::NewL START") );
+
+    CAspSyncUtil* self = new (ELeave) CAspSyncUtil();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+	FLOG( _L("CAspSyncUtil::NewL END") );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncUtil::~CAspSyncUtil()
+    {
+   	FLOG( _L("CAspSyncUtil::~CAspSyncUtil START") );
+   	
+	delete iResHandler;
+	delete iSyncHandler;
+ 	delete iContentList;
+	
+	CloseSyncSession();
+	
+	FLOG( _L("CAspSyncUtil::~CAspSyncUtil END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::ConstructL(void)
+    {
+   	FLOG( _L("CAspSyncUtil::ConstructL START") );
+ 	
+    iSettingEnforcement = TUtil::SettingEnforcementState();
+   	    
+   	TAspParam param(iApplicationId, NULL);  // param not used in CAspSyncHandler
+	iSyncHandler = CAspSyncHandler::NewL(param);
+
+	iSyncSessionOpen = EFalse;
+	
+   	FLOG( _L("CAspSyncUtil::ConstructL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::CAspSyncUtil
+//
+// -----------------------------------------------------------------------------
+//
+CAspSyncUtil::CAspSyncUtil()
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::SynchronizeL
+//
+// Called by CSyncUtilApi::SynchronizeL.
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::SynchronizeL(RFile& aTaskFile)
+	{
+	CAspAutoSyncHandler* autoSyncHandler = CAspAutoSyncHandler::NewL();
+	CleanupStack::PushL(autoSyncHandler);
+	
+	autoSyncHandler->SynchronizeL(aTaskFile);
+	
+	CleanupStack::PopAndDestroy(autoSyncHandler);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::SynchronizeL
+//
+// Called by CSyncUtilApi::SynchronizeL. 
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::SynchronizeL(TInt aApplicationId, TInt aJobId, TInt aInfo1, TDes& aInfo2)
+	{
+	FLOG( _L("CAspSyncUtil::SynchronizeL START") );
+	
+	if (!iResHandler)
+		{
+		iResHandler = CAspResHandler::NewL();
+		}
+		
+	iApplicationId = aApplicationId;
+	
+	OpenSyncSessionL();
+	
+	TRAPD(err, DoSynchronizeL(aApplicationId, aJobId, aInfo1, aInfo2));
+	
+	CloseSyncSession();
+	
+	User::LeaveIfError(err);
+		
+	FLOG( _L("CAspSyncUtil::SynchronizeL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::ShowSettingsL
+//
+// Called by CSyncUtilApi::ShowSettingsL.
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::ShowSettingsL(TInt aApplicationId, TInt aInfo1, TDes& /*aInfo2*/)
+	{
+    FLOG( _L("CAspSyncUtil::ShowSettingsL START") );
+
+	if (!iResHandler)
+		{
+		iResHandler = CAspResHandler::NewL();
+		}
+
+    iApplicationId = aApplicationId;
+    
+    if (aApplicationId != EApplicationIdSync)
+    	{
+    	// other apps only show profile dialog
+    	ShowProfileDialogL(aApplicationId);
+    	return;
+    	}
+    	
+    
+    TInt dialogMode = EModeDialogWait;
+    if (aInfo1 == EModeDialogNoWait)
+    	{
+    	dialogMode = EModeDialogNoWait;
+    	}
+    
+    OpenSyncSessionL();
+        
+    TRAPD(err, ShowSettingsDialogL(aApplicationId, KErrNotFound, dialogMode));
+            
+    if (dialogMode == EModeDialogWait)
+    	{
+    	iSettingDialog = NULL;
+    	CloseSyncSession();
+    	}
+    
+    User::LeaveIfError(err);
+    
+    FLOG( _L("CAspSyncUtil::ShowSettingsL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::ShowSettingsDialog
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::ShowSettingsDialogL(TInt aApplicationId, 
+                                       TInt aProfileId, TInt aDialogMode)
+	{
+	if (aApplicationId != EApplicationIdSync)
+		{
+		CreateContentListL();
+	    CheckAppAndProviderL(aApplicationId);
+		}
+	
+	TAspParam param(aApplicationId, &iSyncSession);
+	param.iMode = aDialogMode;
+	param.iProfileId = aProfileId;
+
+    iSettingDialog = CAspSettingDialog::NewL(param);
+ 
+    if (aDialogMode == EModeDialogWait)
+    	{
+    	iSettingDialog->ExecuteLD(R_ASP_SETTING_DIALOG);
+    	}
+    else
+    	{
+    	iSettingDialog->ExecuteLD(R_ASP_SETTING_DIALOG_2);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::ShowProfileDialog
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::ShowProfileDialogL(TInt aApplicationId)
+	{
+    FLOG( _L("CAspSyncUtil::ShowProfileDialogL START") );
+    
+	OpenSyncSessionL();
+	
+	TRAPD(err, EditProfileL(aApplicationId));
+	
+	CloseSyncSession();
+		
+    User::LeaveIfError(err);
+		
+	FLOG( _L("CAspSyncUtil::ShowProfileDialogL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::EditProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::EditProfileL(TInt aAplicationId)
+	{
+	CreateContentListL();
+    CheckAppAndProviderL(aAplicationId);
+	
+	TInt profileId = KErrNotFound;
+	TInt taskId = KErrNotFound;
+	TInt resourceId = R_ASP_PROFILE_QUERY_TITLE;
+	
+	TBool ret = SelectProfileL(profileId, taskId, resourceId, KNullDesC,ETrue);
+	if (!ret || profileId == KErrNotFound)
+		{
+		return;  // no sync profile
+		}
+
+    if (iSettingEnforcement)
+    	{
+    	DoEditReadOnlyProfileL(aAplicationId, profileId, 
+    	                       EDialogModeSettingEnforcement);
+    	}
+    else
+    	{
+    	DoEditProfileL(aAplicationId, profileId, EDialogModeEdit);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::DoEditProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::DoEditProfileL(TInt aApplicationId, TInt aProfileId,
+                                                      TInt aDialogMode)
+	{
+	TAspParam param(EApplicationIdSync, &iSyncSession);
+	CAspProfileList* profileList = CAspProfileList::NewLC(param);
+	profileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
+	
+	
+    param.iApplicationId = aApplicationId;
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    
+    TInt err = KErrNone;
+    TRAP(err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite,
+                                         CAspProfile::EAllProperties));
+
+	if (err == KErrLocked)
+		{
+		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+		}
+	User::LeaveIfError(err);
+
+	iContentList->SetProfile(profile);
+	TRAP(err, iContentList->InitAllTasksL());
+	
+	if (err != KErrNone)
+		{
+		iContentList->SetProfile(NULL);
+		}
+	User::LeaveIfError(err);
+		
+	TAspParam param2(aApplicationId, &iSyncSession);
+	param2.iProfile = profile;
+	param2.iMode = aDialogMode;
+    param2.iContentList = iContentList;
+    param2.iProfileList = profileList;  // needed for unique server id check
+ 
+#ifdef RD_DSUI_TIMEDSYNC 
+	CAspSettingViewDialog::ShowDialogL(param2);
+#else
+	TRAP(err, CAspProfileDialog::ShowDialogL(param2));
+#endif
+	
+	iContentList->SetProfile(NULL);
+	User::LeaveIfError(err);
+
+	CleanupStack::PopAndDestroy(profile);
+	CleanupStack::PopAndDestroy(profileList);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::DoEditReadOnlyProfileL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::DoEditReadOnlyProfileL(TInt aApplicationId, TInt aProfileId,
+                                                      TInt aDialogMode)
+	{
+	TAspParam param(aApplicationId, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+    
+    profile->OpenL(aProfileId, CAspProfile::EOpenRead,
+                                         CAspProfile::EAllProperties);
+
+	iContentList->SetProfile(profile);
+	TInt err = KErrNone;
+	TRAP(err, iContentList->InitAllTasksL());
+	
+	if (err != KErrNone)
+		{
+		iContentList->SetProfile(NULL);
+		}
+	User::LeaveIfError(err);
+		
+	TAspParam param2(aApplicationId, &iSyncSession);
+	param2.iProfile = profile;
+	param2.iMode = aDialogMode;
+    param2.iContentList = iContentList;
+ 
+	TRAP(err, CAspProfileDialog::ShowDialogL(param2));
+	
+	iContentList->SetProfile(NULL);
+	User::LeaveIfError(err);
+
+	CleanupStack::PopAndDestroy(profile);
+	}
+
+
+// -----------------------------------------------------------------------------------------------------
+// CAspSyncUtil::SelectProfileL
+// aCheckId currently will be always set to ETrue
+// this Check can be used in future to differentiate if its called from DoSynchronizeL() or EditProfileL()
+// ------------------------------------------------------------------------------------------------------
+//
+TBool CAspSyncUtil::SelectProfileL(TInt& aProfileId, TInt& aTaskId, 
+                                   TInt aResourceId, const TDesC& aLocalDatabase,TBool aCheckId)
+	{
+	aProfileId = KErrNotFound;
+	aTaskId = KErrNotFound;
+	TBool ret = EFalse;
+	TInt index=KErrNotFound;
+	
+	TAspParam param(iApplicationId, &iSyncSession);
+	CAspProfileList* profileList = CAspProfileList::NewLC(param);
+	
+	if (aLocalDatabase.Length() > 0)
+		{
+		profileList->ReadEMailProfilesL(aLocalDatabase, KErrNotFound);
+		if(profileList->Count() == 0)
+		{
+		 profileList->ReadAllProfilesL(CAspProfileList::EBasePropertiesOnly);
+		}
+		}
+	else
+		{
+		profileList->ReadAllProfilesL(CAspProfileList::EBasePropertiesOnly);
+		}
+	
+	profileList->Sort();
+   	
+	if (profileList->Count() == 0)
+		{
+	    if (!iSettingEnforcement)
+	    	{
+	    	if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_NO_PROFILES))
+		        {
+	    	    TAspParam param(iApplicationId, &iSyncSession);
+         	    CAspProfileWizardDialog::ShowDialogL(param);
+    	        }
+	    	}
+
+    	ret = EFalse;
+		}
+		
+	else if (profileList->Count() == 1)
+		{
+		TAspProfileItem& item = profileList->Item(0);
+		aProfileId = item.iProfileId;
+		aTaskId = item.iTaskId;
+       	ret = ETrue;
+		}
+		
+	else
+		{
+		if(aCheckId)
+		{
+			
+	
+			if (iSettingEnforcement)
+				{
+					ret = TDialogUtil::ShowProfileQueryL(profileList, aProfileId, aResourceId);
+						
+				}
+			else
+				{
+		  			ret = TDialogUtil::ShowProfileQueryAppL(profileList, aProfileId, aResourceId,index);	
+				}
+		
+		
+			if (ret)
+				{
+		   			 index = profileList->ListIndex(aProfileId);
+	    	
+	        		__ASSERT_DEBUG(index != KErrNotFound, TUtil::Panic(KErrGeneral));
+	              
+	         		TAspProfileItem& item = profileList->Item(index);
+	         		
+		   			aTaskId = item.iTaskId;
+	       
+				}
+			
+		 	else
+	 			 {
+	 		    		if(index==1)
+			     		CAspProfileWizardDialog::ShowDialogL(param);
+	        	 		//ret=EFalse;
+		 	
+		 		 }	
+		}
+		
+		else
+		{
+		
+		   
+			ret = TDialogUtil::ShowProfileQueryL(profileList, aProfileId, aResourceId);	
+		  	
+	 		if (ret)
+				{
+					TInt index = profileList->ListIndex(aProfileId);
+	    	
+	        		__ASSERT_DEBUG(index != KErrNotFound, TUtil::Panic(KErrGeneral));
+	                
+	          		TAspProfileItem& item = profileList->Item(index);
+		      		aTaskId = item.iTaskId;
+	        
+			
+		 
+		 		}
+				
+		
+	   		}
+		}
+		
+	CleanupStack::PopAndDestroy(profileList);
+
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::DoSynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::DoSynchronizeL(TInt aApplicationId, TInt /*aJobId*/, 
+                                  TInt aInfo1, TDes& aInfo2)
+	{
+	FLOG( _L("CAspSyncUtil::DoSynchronizeL START") );
+	
+	CreateContentListL();
+	CheckAppAndProviderL(aApplicationId);
+
+	//check PS key
+    TInt keyVal = 0;//EDataSyncNotRunning
+    TInt err = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                 KDataSyncStatus,
+                                 keyVal );
+    if(err == KErrNone && keyVal)
+    	{
+    	TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
+		return;
+    	}
+	
+	if (CAspProfile::OtherSyncRunning(&iSyncSession))
+		{
+		TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
+		FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+   		return;
+		}
+		
+	if (iApplicationId == EApplicationIdEmail && TUtil::IsEmpty(aInfo2))
+		{
+		FLOG( _L("### mailbox name not defined ###") );
+		FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+		User::Leave(KErrNotFound);
+		}
+	
+
+	TInt profileId = KErrNotFound;
+	TInt taskId = KErrNotFound;
+	TBool ret = EFalse;
+	TInt resourceId = R_ASP_PROFILE_QUERY_TITLE;
+
+	if (aApplicationId == EApplicationIdEmail)
+		{
+		ret = SelectProfileL(profileId, taskId, resourceId, aInfo2,ETrue);
+		}
+	else
+		{
+		ret = SelectProfileL(profileId, taskId, resourceId, KNullDesC,ETrue);
+		}
+		
+	if (!ret || profileId == KErrNotFound)
+		{
+		FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+		return; // no sync profile
+		}
+	
+	TAspParam aspParam(iApplicationId, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(aspParam);
+	TRAPD (err1, profile->OpenL(profileId, CAspProfile::EOpenRead, 
+	                           CAspProfile::EAllProperties));
+	User::LeaveIfError(err1);
+	if (aApplicationId != EApplicationIdEmail)
+		{
+		aInfo2 = KNullDesC;
+		}
+	//create task for content type ,if it is not created yet
+	ret = CheckTaskAndProtocolL(profileId, aInfo2);
+	
+	TInt dataProviderId = TUtil::ProviderIdFromAppId(aApplicationId);
+	taskId = TAspTask::FindTaskIdL(profile, dataProviderId, aInfo2);
+	
+	CleanupStack::PopAndDestroy(profile);
+	    		
+	if (!ret)
+		{
+		    FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+			return; // some mandatory data missing
+		}
+	
+	if (!CheckMandatoryL(profileId))
+		{
+	    FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+		return; // some mandatory data missing
+		}
+
+#ifdef _DEBUG
+        TBuf<KBufSize> buf;
+        TUtil::GetApplicationName(buf, aApplicationId);
+        FTRACE(RDebug::Print(_L("statrting sync (%S)"), &buf));
+#endif
+
+	TAspSyncParam param(aApplicationId);
+	param.iProfileId = profileId;
+	param.iTaskId = taskId;
+
+    if (aInfo1 == EApplicationIdEmail)
+    	{
+    	// email sync 3.2 needs synchronous syncing
+    	param.iDialogMode = EModeDialogWait;
+    	}
+
+	iSyncHandler->SynchronizeL(param);
+
+	FLOG( _L("CAspSyncUtil::DoSynchronizeL END") );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::CheckMandatoryL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncUtil::CheckMandatoryL(TInt aProfileId)
+	{
+	TAspParam param(iApplicationId, &iSyncSession);
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	profile->OpenL(aProfileId, CAspProfile::EOpenRead, 
+	                           CAspProfile::EAllProperties);
+	
+	TInt contentCount = 0;
+	TInt ret = CAspProfile::CheckMandatoryData(profile, contentCount);
+	CleanupStack::PopAndDestroy(profile);
+	
+	if (ret != EMandatoryOk)
+		{
+        if (iSettingEnforcement)
+    	    {
+    	    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_TARM_MANDATORY_MISSING);
+    	    }    	
+    	else if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_MANDATORY_MISSING))
+			{
+   	        DoEditProfileL(iApplicationId, aProfileId, EDialogModeEditMandatory);
+ 			}
+		
+		return EFalse;
+    	}
+	
+	return ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::DataProviderExist
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncUtil::DataProviderExist(TInt aApplicationId)
+	{
+	if (iContentList == NULL)
+		{
+		return ETrue;
+		}
+	
+	TInt providerId = TUtil::ProviderIdFromAppId(aApplicationId);
+	TInt index = iContentList->FindProviderIndex(providerId);
+	
+	if (index == KErrNotFound)
+		{
+		return EFalse;
+		}
+	return ETrue;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::CreateContentListL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::CreateContentListL()
+	{
+	if (iContentList)
+		{
+		return;
+		}
+
+	TAspParam param(KErrNotFound, &iSyncSession);
+    param.iMode = CAspContentList::EInitDataProviders;
+    iContentList = CAspContentList::NewL(param);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::CheckAppAndProvider
+//
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::CheckAppAndProviderL(TInt aApplicationId)
+	{
+	TInt sid = RProcess().SecureId().iId;
+	
+	if (!TUtil::IsValidSID(sid))
+		{
+		FLOG( _L("### CAspSyncUtil::CheckAppAndProviderL: wrong SID (%xd) ###"), sid);
+		User::Leave(KErrNotSupported);  // unknown caller app
+		}
+
+	if (!TUtil::IsValidAppId(aApplicationId))
+		{
+		FLOG( _L("### CAspSyncUtil::CheckAppAndProviderL: wrong app id (%d) ###"), aApplicationId);
+		User::Leave(KErrNotSupported);  // unknown caller app
+		}
+		
+	if (aApplicationId != EApplicationIdSync && !DataProviderExist(aApplicationId))
+		{
+		FLOG( _L("### CAspSyncUtil::CheckAppAndProviderL: no data provider (%d) ###"), aApplicationId);
+		User::Leave(KErrNotFound);  // sync data provider not found
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::CheckTaskAndProtocolL
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspSyncUtil::CheckTaskAndProtocolL(TInt aProfileId ,const TDesC& aLocalDatabase)
+	{
+	
+	TAspParam param(iApplicationId, &iSyncSession);
+	
+	CAspProfile* profile = CAspProfile::NewLC(param);
+	TRAPD (err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite, 
+	                           CAspProfile::EAllProperties));
+	if (err == KErrLocked)
+		{
+			TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
+			CleanupStack::PopAndDestroy(profile);                           
+			return EFalse;
+		}
+	
+	TInt dataProviderId = TUtil::ProviderIdFromAppId(iApplicationId);
+	iContentList->RemoveAllTasks();
+	iContentList->SetProfile(profile);
+	iContentList->InitAllTasksL();
+	
+	if (iApplicationId == EApplicationIdEmail)
+		{
+			    
+	    TInt protocol = profile->ProtocolVersion();
+		if (protocol == EAspProtocol_1_1)
+			{
+
+      		CleanupStack::PopAndDestroy(profile);
+      		iContentList->SetProfile(NULL);
+      		return EFalse;	 
+			}
+        
+        TInt taskId = TAspTask::FindTaskIdL(profile, dataProviderId, aLocalDatabase);
+        if (taskId == KErrNotFound)
+			{
+	  		
+      	  iContentList->ModifyTaskIncludedL(dataProviderId, ETrue, aLocalDatabase);
+      		
+      		}
+	
+		}
+    else
+		{
+		TInt taskId = TAspTask::FindTaskIdL(profile, dataProviderId, KNullDesC);
+        if (taskId == KErrNotFound)
+			{
+	  		    		
+      		iContentList->ModifyTaskIncludedL(dataProviderId, ETrue, KNullDesC);
+      		
+			}
+		}
+	
+	iContentList->SetProfile(NULL);
+	CleanupStack::PopAndDestroy(profile);
+	return ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// OpenSyncSessionL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::OpenSyncSessionL()
+	{
+	if (!iSyncSessionOpen)
+		{
+        TRAPD(err, iSyncSession.OpenL());
+        
+        if (err != KErrNone)
+        	{
+        	FLOG( _L("### CAspSyncUtil::OpenSyncSessionL: RSyncMLSession::OpenL failed (%d) ###"), err);
+        	
+            iSyncSession.Close();  // can be done always
+        	User::Leave(err);
+        	}
+        else
+        	{
+        	FLOG( _L("CAspSyncUtil::OpenSyncSessionL: RSyncMLSession::OpenL ok") );
+        	}
+        
+		iSyncSessionOpen = ETrue;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CloseSyncSession
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspSyncUtil::CloseSyncSession()
+	{
+	if (iSyncSessionOpen)
+		{
+		iSyncSession.Close();
+		iSyncSessionOpen = EFalse;
+		}
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncUtil.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2017 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+//  INCLUDES
+
+
+#include <eikon.rh>
+#include "registryinfov2.rh" 
+#include "AspSyncUtil.rh"
+
+// aspsyncutil uses sync app .loc file
+#include<NSmlDSSync.loc>
+
+// For profiles sync application brings
+#include<NSmlSyncProfiles.loc>
+
+// common avkon strings
+#include<avkon.loc>
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <AvkonIcons.hrh>
+
+
+
+//  RESOURCE IDENTIFIER
+NAME ASPU
+
+
+RESOURCE RSS_SIGNATURE { }
+
+
+//
+// STRINGS
+//
+
+STRUCT STRING
+	{
+	LTEXT text;
+	}
+
+// info note for sync protocol change
+RESOURCE TBUF r_asp_protocol_change { buf = qtn_sml_info_proc_change; }
+
+// shown when syncing and mandatory setting is missing and profile cannot be edited
+RESOURCE TBUF r_asp_note_tarm_mandatory_missing { buf=qtn_sml_note_tarm_mandatory_missing; }
+
+// shown when syncing and no profles exist
+RESOURCE TBUF r_asp_note_main_locked { buf=qtn_sml_note_main_locked; }
+
+// shown when settings enforcement is done
+RESOURCE TBUF r_asp_protected_setting { buf=qtn_selec_protected_setting; }
+
+// shown when syncing and no profles exist
+RESOURCE TBUF r_asp_query_no_profiles { buf=qtn_sml_query_no_profiles; }
+
+// shown when syncing and no profles exist
+RESOURCE TBUF r_asp_query_mandatory_missing { buf=qtn_sml_query_mandatory_missing; }
+
+// shown when syncing and no profles exist
+RESOURCE TBUF r_asp_query_title_delete_profile { buf=qtn_sml_query_title_delete_profile; }
+
+// shown when syncing and no profles exist
+RESOURCE TBUF r_asp_query_title_change_profile { buf=qtn_sml_query_title_change_profile; }
+
+// synced profile has no content
+RESOURCE TBUF r_asp_err_nocontent         	{ buf = qtn_sml_err_nocontent; }
+
+// profile wizard navipane text
+RESOURCE TBUF r_asp_wizard_page_counter    	{ buf = qtn_sml_wizard_page_counter; }
+
+// confirms copy all from server command
+RESOURCE TBUF r_asp_copy_from_server { buf = qtn_sml_query_slow_sync_conf; }
+
+// shown when user has given profile server id that already exists
+RESOURCE TBUF r_asp_server_id_exists { buf = qtn_sml_query_serverid_exists; }
+
+// informs user that sync cannot be synced because sync is already running
+RESOURCE TBUF r_asp_sync_already_running { buf = qtn_ds_note_hidden_ongoing; }
+
+// setting dialog (main dialog) title
+RESOURCE TBUF r_asp_setting_dialog_title { buf=qtn_apps_syncml_title; }
+
+// profile query dialog title
+RESOURCE TBUF r_asp_profile_query_title { buf=qtn_sml_apps_select_set; }
+
+// text shown in setting dialog when set has no name (not used)
+RESOURCE TBUF r_asp_unnamed_set { buf = qtn_apps_emptyprofile; }
+
+// confirms profile deletion
+RESOURCE TBUF r_asp_confirm_delete { buf = qtn_query_common_conf_delete; }
+
+// confirms closing dialog when some mandatory data is missing
+RESOURCE TBUF r_asp_exit_anyway { buf = qtn_ds_conf_mandatory_missing; }
+
+// confirms closing dialog when some mandatory data is missing (not used)
+//RESOURCE TBUF r_asp_exit_anyway_apps { buf = qtn_ds_conf_mandatory_missing_apps; }
+
+// compulsory setting item text setting value is not defined
+RESOURCE TBUF r_asp_must_be_defined { buf = qtn_selec_setting_compulsory; }
+
+// normal (not compulsory) setting item text setting value is not defined
+RESOURCE TBUF r_asp_setting_value_none{ buf = qtn_selec_sett_val_field_none; }
+
+// shown under profile name - indicates that profile has not been synced
+RESOURCE TBUF r_asp_not_synced { buf = qtn_sml_main_sync_no_last; }
+
+// default profile name when new profile is created
+RESOURCE TBUF r_asp_profilename_phonebook { buf = qtn_sml_apps_content_pb; }
+
+// default profile name when new profile is created
+RESOURCE TBUF r_asp_profilename_calendar { buf = qtn_sml_apps_content_cal; }
+
+// default profile name when new profile is created
+RESOURCE TBUF r_asp_profilename_email { buf = qtn_sml_apps_content_syncml; }
+
+// default profile name when new profile is created
+RESOURCE TBUF r_asp_profilename_note { buf = qtn_sml_apps_content_notes; }
+
+// content name
+RESOURCE TBUF r_asp_content_name_phonebook { buf = qtn_nsml_cnt_display_name; }
+
+// content name
+RESOURCE TBUF r_asp_content_name_calendar { buf = qtn_nsml_agn_display_name; }
+
+// content name
+RESOURCE TBUF r_asp_content_name_note { buf = qtn_nsml_npd_display_name; }
+
+// content name 
+RESOURCE TBUF r_asp_content_name_mms { buf = qtn_nsml_mms_display_name; }
+
+// content name 
+RESOURCE TBUF r_asp_content_name_bkm { buf = qtn_nsml_bkm_display_name; }
+
+
+// content name
+RESOURCE TBUF r_asp_content_name_email { buf = qtn_nsml_eml_display_name; }
+
+// content name
+RESOURCE TBUF r_asp_content_name_sms { buf = qtn_nsml_sms_display_name; }
+
+// content name
+RESOURCE TBUF r_asp_content_title_phonebook { buf = qtn_sml_title_contacts; }
+
+// content name
+RESOURCE TBUF r_asp_content_title_calendar { buf = qtn_sml_title_calendar; }
+
+// content name
+RESOURCE TBUF r_asp_content_title_note { buf = qtn_sml_title_notes; }
+
+// content name
+RESOURCE TBUF r_asp_content_title_email { buf = qtn_sml_title_email; }
+
+// content name
+RESOURCE TBUF r_asp_content_title_sms { buf = qtn_sml_title_sms; }
+
+// content name 
+RESOURCE TBUF r_asp_content_title_mms { buf = qtn_sml_title_mms; }
+
+// content name 
+RESOURCE TBUF r_asp_content_title_bkm { buf = qtn_sml_title_bookmarks; }
+
+// info note for missing mailboxes
+RESOURCE TBUF r_asp_no_mailboxes { buf = qtn_sml_info_no_mailboxes; }
+
+// used in connection dialog as setting value
+RESOURCE TBUF r_asp_always_ask { buf = qtn_ds_sett_always_ask; }
+RESOURCE TBUF r_asp_default_connection { buf = qtn_netw_conset_sett_default_connection; }
+RESOURCE TBUF r_asp_network_destination { buf = qtn_netw_conset_sett_destination; }
+
+// shown when user tries to edit read-only setting
+RESOURCE TBUF r_asp_note_read_only { buf = qtn_ds_note_read_only; }
+
+// shown when user tries to simultaneously edit one sync set
+RESOURCE TBUF r_asp_locked_profile { buf = qtn_nsml_locked_profile; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_phonebook { buf = qtn_sml_content_settings_pb; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_calendar { buf = qtn_sml_content_settings_cal; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_notes { buf = qtn_sml_content_settings_notes; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_email { buf = qtn_sml_content_settings_email; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_sms { buf = qtn_sml_content_settings_sms; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_mms { buf = qtn_sml_content_settings_mms; }
+
+// shown in profile dialog setting list
+RESOURCE TBUF r_asp_content_setting_bkm { buf = qtn_sml_content_settings_bkm; }
+
+
+RESOURCE TBUF r_qtn_apps_newprofile  	    	{ buf = qtn_apps_newprofile; }
+RESOURCE TBUF r_qtn_sml_settingrowitem_mand     { buf = "\t%0U\t\t%1U\t*"; }
+RESOURCE TBUF r_qtn_sml_settingrowitem          { buf = "\t%0U\t\t%1U\t"; }
+RESOURCE TBUF r_asp_sync_completed              { buf = qtn_sml_sync_end_done; }
+RESOURCE TBUF r_asp_popup_profile_info          { buf = qtn_sml_main_info; }
+
+
+// sync progress dialog strings
+RESOURCE TBUF r_syncstatus_sync_conn		    { buf = qtn_sml_sync_conn; }
+RESOURCE TBUF r_syncstatus_sync_disc		    { buf = qtn_sml_sync_disconn; }
+RESOURCE TBUF r_syncstatus_sync_sync		    { buf = qtn_sml_sync_sync; }
+RESOURCE TBUF r_syncstatus_canc		    	    { buf = qtn_sml_sync_cancel; }
+//RESOURCE TBUF r_qtn_nsml_sync_send_unknown      { buf = qtn_nsml_sync_send_unknown; }
+//RESOURCE TBUF r_qtn_nsml_updating  			    { buf = qtn_sml_sync_send; }
+//RESOURCE TBUF r_qtn_nsml_sync_recv_unknown      { buf = qtn_nsml_sync_recv_unknown; }
+//RESOURCE TBUF r_qtn_nsml_receving			    { buf = qtn_sml_sync_recv; }
+RESOURCE TBUF r_qtn_sml_sync_receiving		    { buf = qtn_sml_sync_receiving; }
+RESOURCE TBUF r_qtn_sml_sync_sending		    { buf = qtn_sml_sync_sending; }
+
+
+// log dialog strings
+RESOURCE TBUF r_sml_log_synclog_title  		{ buf = qtn_sml_log_synclog_title; }
+RESOURCE TBUF r_qtn_sml_log_ok			    { buf = qtn_sml_log_ok; }
+RESOURCE TBUF r_qtn_sml_log_cancelled	   	{ buf = qtn_sml_log_cancelled; }
+RESOURCE TBUF r_qtn_sml_log_err				{ buf = qtn_sml_log_err; }
+
+RESOURCE TBUF r_qtn_sml_log_server	    	{ buf = qtn_sml_log_server; }
+RESOURCE TBUF r_qtn_sml_log_remote      	{ buf = qtn_sml_log_remote; }
+RESOURCE TBUF r_qtn_sml_log_phone		    { buf = qtn_sml_log_phone; }
+RESOURCE TBUF r_qtn_sml_log_error		    { buf = qtn_sml_log_error; }
+
+
+RESOURCE TBUF r_qtn_sml_log_profile		    { buf=qtn_sml_log_profile; }
+RESOURCE TBUF r_qtn_sml_log_date		    { buf=qtn_sml_log_date; }
+RESOURCE TBUF r_qtn_sml_log_time		    { buf=qtn_sml_log_time; }
+RESOURCE TBUF r_qtn_sml_log_status		    { buf=qtn_sml_log_status; }
+
+RESOURCE TBUF r_qtn_sml_log_added_content      { buf=qtn_sml_log_added_content; }
+RESOURCE TBUF r_qtn_sml_log_updated_content	   { buf=qtn_sml_log_updated_content; }
+RESOURCE TBUF r_qtn_sml_log_deleted_content	   { buf=qtn_sml_log_deleted_content; }
+RESOURCE TBUF r_qtn_sml_log_discarded_content  { buf=qtn_sml_log_discarded_content; }
+RESOURCE TBUF r_qtn_sml_log_moved_content	   { buf=qtn_sml_log_moved_content; }
+
+RESOURCE TBUF r_qtn_sml_log_added_contacts     { buf=qtn_sml_log_added_contacts; }
+RESOURCE TBUF r_qtn_sml_log_updated_contacts   { buf=qtn_sml_log_updated_contacts; }
+RESOURCE TBUF r_qtn_sml_log_deleted_contacts   { buf=qtn_sml_log_deleted_contacts; }
+RESOURCE TBUF r_qtn_sml_log_discarded_contacts { buf=qtn_sml_log_discarded_contacts; }
+RESOURCE TBUF r_qtn_sml_log_moved_contacts	   { buf=qtn_sml_log_moved_contacts; }
+
+RESOURCE TBUF r_qtn_sml_log_added_calendar     { buf=qtn_sml_log_added_calendar; }
+RESOURCE TBUF r_qtn_sml_log_updated_calendar   { buf=qtn_sml_log_updated_calendar; }
+RESOURCE TBUF r_qtn_sml_log_deleted_calendar   { buf=qtn_sml_log_deleted_calendar; }
+RESOURCE TBUF r_qtn_sml_log_discarded_calendar { buf=qtn_sml_log_discarded_calendar; }
+RESOURCE TBUF r_qtn_sml_log_moved_calendar	   { buf=qtn_sml_log_moved_calendar; }
+
+RESOURCE TBUF r_qtn_sml_log_added_notes        { buf=qtn_sml_log_added_notes; }
+RESOURCE TBUF r_qtn_sml_log_updated_notes	   { buf=qtn_sml_log_updated_notes; }
+RESOURCE TBUF r_qtn_sml_log_deleted_notes	   { buf=qtn_sml_log_deleted_notes; }
+RESOURCE TBUF r_qtn_sml_log_discarded_notes    { buf=qtn_sml_log_discarded_notes; }
+RESOURCE TBUF r_qtn_sml_log_moved_notes  	   { buf=qtn_sml_log_moved_notes; }
+
+RESOURCE TBUF r_qtn_sml_log_added_email        { buf=qtn_sml_log_added_email; }
+RESOURCE TBUF r_qtn_sml_log_updated_email	   { buf=qtn_sml_log_updated_email; }
+RESOURCE TBUF r_qtn_sml_log_deleted_email	   { buf=qtn_sml_log_deleted_email; }
+RESOURCE TBUF r_qtn_sml_log_discarded_email    { buf=qtn_sml_log_discarded_email; }
+RESOURCE TBUF r_qtn_sml_log_moved_email  	   { buf=qtn_sml_log_moved_email; }
+
+RESOURCE TBUF r_qtn_sml_log_added_sms          { buf=qtn_sml_log_added_sms; }
+RESOURCE TBUF r_qtn_sml_log_updated_sms	       { buf=qtn_sml_log_updated_sms; }
+RESOURCE TBUF r_qtn_sml_log_deleted_sms	       { buf=qtn_sml_log_deleted_sms; }
+RESOURCE TBUF r_qtn_sml_log_discarded_sms      { buf=qtn_sml_log_discarded_sms; }
+RESOURCE TBUF r_qtn_sml_log_moved_sms  	       { buf=qtn_sml_log_moved_sms; }
+
+RESOURCE TBUF r_qtn_sml_log_added_mms         { buf=qtn_sml_log_added_mms; }
+RESOURCE TBUF r_qtn_sml_log_updated_mms	       { buf=qtn_sml_log_updated_mms; }
+RESOURCE TBUF r_qtn_sml_log_deleted_mms	       { buf=qtn_sml_log_deleted_mms; }
+RESOURCE TBUF r_qtn_sml_log_discarded_mms      { buf=qtn_sml_log_discarded_mms; }
+RESOURCE TBUF r_qtn_sml_log_moved_mms  	       { buf=qtn_sml_log_moved_mms; }
+
+RESOURCE TBUF r_qtn_sml_log_added_bkm          { buf=qtn_sml_log_added_bkm; }
+RESOURCE TBUF r_qtn_sml_log_updated_bkm	       { buf=qtn_sml_log_updated_bkm; }
+RESOURCE TBUF r_qtn_sml_log_deleted_bkm	       { buf=qtn_sml_log_deleted_bkm; }
+RESOURCE TBUF r_qtn_sml_log_discarded_bkm      { buf=qtn_sml_log_discarded_bkm; }
+RESOURCE TBUF r_qtn_sml_log_moved_bkm  	       { buf=qtn_sml_log_moved_bkm; }
+
+//
+// profile wizard strings
+//
+RESOURCE TBUF r_asp_set_wizard_start            { buf = qtn_ds_conf_profile_wizard_start; }
+RESOURCE TBUF r_asp_set_protocol_version        { buf = qtn_sml_set_list_protocol_version; }
+RESOURCE TBUF r_asp_set_destination_name        { buf = qtn_sml_set_list_destination_name; }
+RESOURCE TBUF r_asp_set_host_address    	    { buf = qtn_sml_set_list_host; }
+RESOURCE TBUF r_asp_set_server_id        	    { buf = qtn_sml_set_list_server_id; }
+RESOURCE TBUF r_asp_set_bearer_type             { buf = qtn_sml_set_bearertype; }
+RESOURCE TBUF r_asp_set_username        	    { buf = qtn_sml_set_list_username; }
+RESOURCE TBUF r_asp_set_password    	        { buf = qtn_sml_set_list_password; }
+RESOURCE TBUF r_asp_set_content_selection       { buf = qtn_sml_set_list_content_selection; }
+RESOURCE TBUF r_asp_set_wizard_end              { buf = qtn_ds_conf_profile_wizard_end; }
+RESOURCE TBUF r_asp_set_wizard_end_app          { buf = qtn_ds_conf_profile_wizard_end_app; }
+RESOURCE TBUF r_asp_set_wizard_end_email        { buf = qtn_ds_conf_profile_wizard_end_email; }
+
+RESOURCE TBUF r_asp_remote_database             { buf = qtn_sml_remote_database; }
+RESOURCE TBUF r_asp_remote_database_cnt         { buf = qtn_sml_remote_database_cnt; }
+RESOURCE TBUF r_asp_remote_database_agn         { buf = qtn_sml_remote_database_agn; }
+RESOURCE TBUF r_asp_remote_database_npd         { buf = qtn_sml_remote_database_npd; }
+RESOURCE TBUF r_asp_remote_database_eml         { buf = qtn_sml_remote_database_eml; }
+RESOURCE TBUF r_asp_remote_database_sms         { buf = qtn_sml_remote_database_sms; }
+RESOURCE TBUF r_asp_local_database_eml          { buf = qtn_sml_local_database_eml; }
+RESOURCE TBUF r_asp_remote_database_mms          { buf = qtn_sml_remote_database_mms; }
+RESOURCE TBUF r_asp_remote_database_bkm          { buf = qtn_sml_remote_database_bkm; }
+
+//Advance Setting String
+RESOURCE TBUF r_asp_wizard_popup_roaming_setting       { buf = qtn_ds_set_roaming; }
+// r_asp_remote_database_mms not used
+//RESOURCE TBUF r_asp_remote_database_mms         { buf = qtn_sml_remote_database_mms; }
+
+
+
+RESOURCE TBUF r_asp_wizard_popup_profile_name        { buf = qtn_ds_wizard_popup_profile_name; }
+RESOURCE TBUF r_asp_wizard_popup_protocol_version    { buf = qtn_ds_wizard_popup_protocol_version; }
+RESOURCE TBUF r_asp_wizard_popup_content_selection   { buf = qtn_ds_wizard_popup_content_selection; }
+RESOURCE TBUF r_asp_wizard_popup_contacts_db         { buf = qtn_ds_wizard_popup_contacts_db; }
+RESOURCE TBUF r_asp_wizard_popup_calendar_db         { buf = qtn_ds_wizard_popup_calendar_db; }
+RESOURCE TBUF r_asp_wizard_popup_notes_db            { buf = qtn_ds_wizard_popup_notes_db; }
+RESOURCE TBUF r_asp_wizard_popup_email_db            { buf = qtn_ds_wizard_popup_email_db; }
+RESOURCE TBUF r_asp_wizard_popup_email_local_db      { buf = qtn_ds_wizard_popup_mailbox; }
+RESOURCE TBUF r_asp_wizard_popup_sms_db              { buf = qtn_ds_wizard_popup_sms_db; }
+RESOURCE TBUF r_asp_wizard_popup_mms_db              { buf = qtn_ds_wizard_popup_mms_db; }
+RESOURCE TBUF r_asp_wizard_popup_bkm_db              { buf = qtn_ds_wizard_popup_bkm_db; }
+RESOURCE TBUF r_asp_wizard_popup_remote_db           { buf = qtn_ds_wizard_popup_remote_db; }
+RESOURCE TBUF r_asp_wizard_popup_connection_type     { buf = qtn_ds_wizard_popup_connection_type; }
+RESOURCE TBUF r_asp_wizard_popup_host_address        { buf = qtn_ds_wizard_popup_host_address; }
+RESOURCE TBUF r_asp_wizard_popup_server_id           { buf = qtn_ds_wizard_popup_server_id; }
+RESOURCE TBUF r_asp_wizard_popup_username            { buf = qtn_ds_wizard_popup_username; }
+RESOURCE TBUF r_asp_wizard_popup_password            { buf = qtn_ds_wizard_popup_password; }
+
+RESOURCE TBUF r_asp_note_profile_name_missing  	     { buf = qtn_sml_note_profile_name_missing; }
+RESOURCE TBUF r_asp_note_host_address_missing  	     { buf = qtn_sml_note_host_address_missing; }
+RESOURCE TBUF r_asp_note_incorrect_host_address	     { buf = qtn_sml_note_incorrect_host_address; }
+RESOURCE TBUF r_asp_note_remote_database_missing     { buf = qtn_sml_note_remote_database_missing; }
+RESOURCE TBUF r_asp_note_mms_database_missing     { buf = qtn_sml_note_mms_db_missing; }
+RESOURCE TBUF r_asp_note_sms_database_missing     { buf = qtn_sml_note_sms_db_missing; }
+RESOURCE TBUF r_asp_note_bkm_database_missing     { buf = qtn_sml_note_bkm_db_missing; }
+RESOURCE TBUF r_asp_note_contacts_db_missing     { buf = qtn_sml_note_contacts_db_missing; }
+RESOURCE TBUF r_asp_note_calendar_db_missing     { buf = qtn_sml_note_calendar_db_missing; }
+RESOURCE TBUF r_asp_note_notes_db_missing     { buf = qtn_sml_note_notes_db_missing; }
+RESOURCE TBUF r_asp_note_email_db_missing     { buf = qtn_sml_note_email_db_missing; }
+RESOURCE TBUF r_asp_note_username_missing            { buf = qtn_sml_note_username_missing; }
+RESOURCE TBUF r_asp_note_password_missing            { buf = qtn_sml_note_password_missing; }
+RESOURCE TBUF r_asp_note_incorrect_server_id         { buf = qtn_sml_note_incorrect_server_id; }
+
+RESOURCE TBUF r_asp_log_err_profile_wizard           { buf = qtn_sml_log_err_profile_wizard; }
+
+
+// automatic sync strings
+
+//RESOURCE TBUF r_asp_sett_auto_sync_status    	  { buf = qtn_sml_sett_auto_sync_status; }
+RESOURCE TBUF r_asp_sett_auto_sync_all_days       { buf = qtn_sml_sett_auto_sync_all_days; }
+RESOURCE TBUF r_asp_sett_auto_sync_sel_days       { buf = qtn_sml_sett_auto_sync_sel_days; }
+RESOURCE TBUF r_asp_sett_auto_sync_roaming    	  { buf = qtn_sml_sett_auto_sync_roaming; }
+//RESOURCE TBUF r_asp_title_automatic_sync_profile_selection 	  { buf = qtn_sml_title_profile_selection; }
+RESOURCE TBUF r_asp_title_automatic_sync_content_list   	  { buf = qtn_sml_auto_sync_view_contents_head; }
+RESOURCE TBUF r_asp_popup_auto_sync_profile   	  { buf = qtn_sml_main_info_auto_on; }
+RESOURCE TBUF r_asp_popup_auto_sync_error   	  { buf = qtn_sml_main_info_error; }
+RESOURCE TBUF r_asp_popup_auto_sync_done     	  { buf = qtn_sml_sett_auto_sync_done; }
+RESOURCE TBUF r_asp_note_peak_interval_days  	  { buf = qtn_sml_note_peak_interval_days; }
+RESOURCE TBUF r_asp_note_offpeak_interval_days  	  { buf = qtn_sml_note_offpeak_interval_days; }
+
+//auto sync setting
+RESOURCE TBUF r_asp_sett_auto_sync_profile   	  { buf = qtn_sml_sett_auto_sync_profile; }
+RESOURCE TBUF r_asp_sett_value_not_defined   	  { buf = qtn_sml_sett_value_not_defined; }
+RESOURCE TBUF r_asp_sett_auto_sync_contents   	  { buf = qtn_sml_sett_auto_sync_contents; }
+RESOURCE TBUF r_asp_sett_auto_peak_schedule   	  { buf = qtn_sml_sett_auto_peak_schedule; }
+RESOURCE TBUF r_asp_sett_auto_off_peak_schedule   	  { buf = qtn_sml_sett_auto_offpeak_schedule; }
+RESOURCE TBUF r_asp_sett_auto_sync_time   	  { buf = qtn_sml_sett_auto_sync_time; }
+RESOURCE TBUF r_asp_sett_auto_peak_start   	  { buf = qtn_sml_sett_auto_peak_start; }
+RESOURCE TBUF r_asp_sett_auto_peak_end   	  { buf = qtn_sml_sett_auto_peak_end; }
+RESOURCE TBUF r_asp_sett_auto_sync_days   	  { buf = qtn_sml_sett_auto_sync_days; }
+//RESOURCE TBUF r_asp_setting_auto_sync_roaming_status   	  { buf = qtn_sml_auto_sync_roaming_status; }
+RESOURCE TBUF r_asp_note_auto_contents_missing_settings   	  { buf = qtn_sml_note_auto_contents_missing_settings; }
+
+RESOURCE TBUF r_asp_sett_value_all_contents       { buf = qtn_sml_sett_value_all_contents; }
+RESOURCE TBUF r_asp_sett_value_selected_contents       { buf = qtn_sml_sett_value_selected_contents; }
+RESOURCE TBUF r_asp_main_auto_error_log_link       { buf = qtn_sml_main_auto_error_log_link; }
+
+RESOURCE TBUF r_asp_incorrect_peak_time       { buf = qtn_sml_incorrect_peak_time; }
+RESOURCE TBUF r_asp_manual_sync_override       { buf = qtn_sml_manual_sync_override; }
+
+//sync frequency
+RESOURCE TBUF r_asp_sett_auto_sync_freq      { buf = qtn_sml_sett_auto_sync_freq; }
+RESOURCE TBUF r_asp_sett_auto_sync_freq_value_manual      { buf = qtn_sml_sett_auto_sync_freq_value_manual; }
+RESOURCE TBUF r_asp_sett_auto_sync_freq_many_a_day      { buf = qtn_sml_sett_auto_sync_freq_many_a_day; }
+RESOURCE TBUF r_asp_sett_auto_value_24_hours      { buf = qtn_sml_sett_auto_value_24_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_2_days      { buf = qtn_sml_sett_auto_value_2_days; }
+RESOURCE TBUF r_asp_sett_auto_value_4_days      { buf = qtn_sml_sett_auto_value_4_days; }
+RESOURCE TBUF r_asp_sett_auto_value_7_days      { buf = qtn_sml_sett_auto_value_7_days; }
+RESOURCE TBUF r_asp_sett_auto_value_14_days      { buf = qtn_sml_sett_auto_value_14_days; }
+RESOURCE TBUF r_asp_sett_auto_value_30_days      { buf = qtn_sml_sett_auto_value_30_days; }
+
+
+//peak intervals
+RESOURCE TBUF r_asp_sett_auto_value_manual      { buf = qtn_sml_sett_auto_value_manual; }
+RESOURCE TBUF r_asp_sett_auto_value_15_mins      { buf = qtn_sml_sett_auto_value_15_mins; }
+RESOURCE TBUF r_asp_sett_auto_value_30_mins      { buf = qtn_sml_sett_auto_value_30_mins; }
+RESOURCE TBUF r_asp_sett_auto_value_1_hour      { buf = qtn_sml_sett_auto_value_1_hour; }
+RESOURCE TBUF r_asp_sett_auto_value_2_hours      { buf = qtn_sml_sett_auto_value_2_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_4_hours      { buf = qtn_sml_sett_auto_value_4_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_8_hours      { buf = qtn_sml_sett_auto_value_8_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_12_hours      { buf = qtn_sml_sett_auto_value_12_hours; }
+
+//off-peak intervals
+RESOURCE TBUF r_asp_sett_auto_value_off_manual      { buf = qtn_sml_sett_auto_value_off_manual; }
+RESOURCE TBUF r_asp_sett_auto_value_off_15_mins      { buf = qtn_sml_sett_auto_value_off_15_mins; }
+RESOURCE TBUF r_asp_sett_auto_value_off_30_mins      { buf = qtn_sml_sett_auto_value_off_30_mins; }
+RESOURCE TBUF r_asp_sett_auto_value_off_1_hour      { buf = qtn_sml_sett_auto_value_off_1_hour; }
+RESOURCE TBUF r_asp_sett_auto_value_off_2_hours      { buf = qtn_sml_sett_auto_value_off_2_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_off_4_hours      { buf = qtn_sml_sett_auto_value_off_4_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_off_8_hours      { buf = qtn_sml_sett_auto_value_off_8_hours; }
+RESOURCE TBUF r_asp_sett_auto_value_off_12_hours      { buf = qtn_sml_sett_auto_value_off_12_hours; }
+
+
+RESOURCE TBUF r_asp_main_note_auto_on      { buf = qtn_sml_main_note_auto_on; }
+RESOURCE TBUF r_asp_sett_auto_sync_done      { buf = qtn_sml_sett_auto_sync_done; }
+
+
+RESOURCE TBUF r_asp_title_profile_settings      { buf = qtn_sml_title_profile_settings; }
+RESOURCE TBUF r_asp_title_automatic_sync_settings { buf = qtn_sml_title_automatic_sync_settings; }
+
+RESOURCE TBUF r_asp_setting_folder_profile     { buf = qtn_sml_setting_folder_profile; }
+RESOURCE TBUF r_asp_setting_folder_schedule      { buf = qtn_sml_setting_folder_schedule; }
+RESOURCE TBUF r_asp_query_common_conf_delete      { buf = qtn_query_common_conf_delete; }
+RESOURCE TBUF r_asp_ds_conf_query_delete_auto_sync_profile      { buf = qtn_ds_conf_query_delete_auto_sync_profile; }
+RESOURCE TBUF r_asp_note_modify_auto_sync_settings      { buf = qtn_sml_note_modify_auto_sync_settings; }
+RESOURCE TBUF r_asp_query_iap_no_ask_always      { buf = qtn_sml_query_iap_no_ask_always; }
+
+
+
+RESOURCE TBUF r_asp_query_auto_sync_on      { buf = qtn_sml_query_auto_sync_on; }
+
+
+RESOURCE ARRAY r_asp_auto_sync_roaming_yesno
+	{
+	items=
+		{
+		STRING { text = qtn_sml_sett_auto_sync_roaming_off ; },
+		STRING { text = qtn_sml_sett_auto_sync_roaming_on ; }
+		};
+	}
+
+
+RESOURCE ARRAY r_asp_auto_sync_days_list
+	{
+	items=
+		{
+		STRING { text = qtn_sml_sett_auto_sync_mon ; },
+		STRING { text = qtn_sml_sett_auto_sync_tue ; },
+		STRING { text = qtn_sml_sett_auto_sync_wed ; },
+		STRING { text = qtn_sml_sett_auto_sync_thu ; },
+		STRING { text = qtn_sml_sett_auto_sync_fri ; },
+		STRING { text = qtn_sml_sett_auto_sync_sat ; },
+		STRING { text = qtn_sml_sett_auto_sync_sun ; }
+		};
+	}
+
+// error strings
+RESOURCE TBUF r_asp_log_err_systemerror    		   { buf = qtn_nsml_log_err_systemerror; }
+RESOURCE TBUF r_asp_log_err_servererror    		   { buf = qtn_nsml_log_err_servererror; }
+RESOURCE TBUF r_asp_log_err_protocol    	       { buf = qtn_nsml_log_err_protocol; }
+RESOURCE TBUF r_asp_log_err_cmdnotsupported    	   { buf = qtn_nsml_log_err_cmdnotsupported; }
+RESOURCE TBUF r_asp_log_err_versionnotsupported    { buf = qtn_nsml_log_err_versionnotsupported; }
+RESOURCE TBUF r_asp_log_err_contentnotsupported    { buf = qtn_nsml_log_err_contentnotsupported; }
+RESOURCE TBUF r_asp_log_err_clientauth    		   { buf = qtn_nsml_log_err_clientauth; }
+RESOURCE TBUF r_asp_log_err_serverbusy    		   { buf = qtn_nsml_log_err_serverbusy; }
+RESOURCE TBUF r_asp_log_err_servernotresponding    { buf = qtn_nsml_log_err_servernotresponding; }
+RESOURCE TBUF r_asp_log_err_uriinvalid    		   { buf = qtn_nsml_log_err_uriinvalid; }
+RESOURCE TBUF r_asp_log_err_comm    		       { buf = qtn_nsml_log_err_comm; }
+RESOURCE TBUF r_asp_log_err_invalidsynctype    	   { buf = qtn_nsml_log_err_invalidsynctype; }
+RESOURCE TBUF r_asp_log_err_localdatabase    	   { buf = qtn_nsml_log_err_localdatabase; }
+RESOURCE TBUF r_asp_log_err_remotedatabase    	   { buf = qtn_nsml_log_err_remotedatabase; }
+RESOURCE TBUF r_asp_log_err_invaliddatabase    	   { buf = qtn_nsml_log_err_invaliddatabase; }
+RESOURCE TBUF r_asp_log_err_httpauth    	       { buf = qtn_nsml_log_err_httpauth; }
+RESOURCE TBUF r_asp_log_err_localdbchanged    	   { buf = qtn_nsml_log_err_localdbchanged; }
+RESOURCE TBUF r_asp_log_err_offline         	   { buf = qtn_offline_not_possible; }
+RESOURCE TBUF r_asp_log_err_untrusted_certificate  { buf = qtn_sml_log_err_untrusted_certificate; }
+
+// Roaming settings resources
+RESOURCE TBUF r_asp_note_network_confirmation      { buf = qtn_sml_note_network_confirmation; }
+RESOURCE TBUF r_asp_note_network_not_allowed       { buf = qtn_sml_note_network_not_allowed; }
+RESOURCE TBUF r_asp_note_not_home_network          { buf = qtn_sml_note_not_home_network; }
+
+RESOURCE TBUF r_asp_title_advanced_settings        { buf = qtn_sml_title_adv_settings; }
+//------------------------------------------------------------------------------
+// connection dialog setting list item name resource
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_connection_dialog_setting_items
+	{
+	items=
+		{
+		STRING		{ text = qtn_sml_set_list_profile; },
+		STRING		{ text = qtn_sml_set_list_server_id; },
+		STRING 		{ text = qtn_sml_set_bearertype; },
+		STRING 		{ text = qtn_netw_conset_sett_destination; },
+		STRING		{ text = qtn_sml_set_list_host; },
+		STRING 		{ text = qtn_sml_set_list_port; },
+		STRING 		{ text = qtn_sml_set_list_username; },
+		STRING 		{ text = qtn_sml_set_list_password; },
+		STRING 		{ text = qtn_ds_set_lbl_active; },
+		STRING		{ text = qtn_sml_set_list_https_username; },
+		STRING		{ text = qtn_sml_set_list_https_password; },
+		STRING 		{ text = qtn_sml_sync_type; },
+		STRING		{ text = qtn_sml_set_list_protocol_version; }		
+		};
+	}
+
+RESOURCE ARRAY r_advance_settings_dialog_items
+    {
+    items=
+        {
+        STRING      { text = qtn_ds_set_roaming; }       
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// content dialog setting items
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_asp_sett_local_database  { buf = qtn_sml_local_database; }
+RESOURCE TBUF r_asp_sett_remote_database { buf = qtn_sml_remote_database; }
+RESOURCE TBUF r_asp_sett_use_filters     { buf = qtn_nsml_eml_use_filters; }
+
+
+
+
+//------------------------------------------------------------------------------
+// Editor for secret setting page
+//------------------------------------------------------------------------------
+//
+RESOURCE SECRETED r_setting_pwd_editor
+	{
+ 	num_letters=EAspMaxPasswordLength;
+	}
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_activate_later_activate
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_activate;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyCancel;
+            txt = qtn_sml_cba_later;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_activate;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_start_cancel_start
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_start;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyCancel;
+            txt = qtn_sml_cba_cancel;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_start;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_next_back_next
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_next;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyDone;
+            txt = qtn_sml_cba_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_next;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_next_back_mark
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_next;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyDone;
+            txt = qtn_sml_cba_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_next_back_select
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = qtn_sml_cba_next;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyDone;
+            txt = qtn_sml_cba_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeySelect;
+            txt = qtn_msk_select;
+            }
+        };
+    }
+
+
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_ok_cancel_mark
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOk;
+            txt = text_softkey_ok;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyCancel;
+            txt = text_softkey_cancel;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_options_back_change
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOpen;
+            txt = qtn_msk_change;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_options_select_back
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOpen;
+            txt = qtn_msk_select;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_options_view_content_back
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOpen;
+            txt = qtn_msk_view_contents;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_options_exit_mark
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyExit;
+            txt = text_softkey_exit;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_options_back_mark
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            }
+        };
+    }
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+
+RESOURCE CBA r_asp_cba_options_back_open
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyOpen;
+            txt = qtn_msk_open;
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_mark_cancel
+    {
+    buttons =
+        {
+         CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            },       
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyCancel;
+            txt = text_softkey_cancel;
+            }       
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Softkey resource
+//------------------------------------------------------------------------------
+//
+RESOURCE CBA r_asp_cba_empty_cancel_mark
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyEmpty;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyCancel;
+            txt = text_softkey_cancel;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyMark;
+            txt = qtn_msk_mark;
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Setting page for check box settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_check_next_back
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	softkey_resource = r_asp_cba_next_back_mark;
+	type =  EAknSetListBox;
+	editor_resource_id= r_setting_app_listbox;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for radio button settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_radio_next_back
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	softkey_resource = r_asp_cba_next_back_select;
+	type =  EAknSetListBox;
+	editor_resource_id= r_setting_app_listbox;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for text settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_text_next_back
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	type=EEikCtEdwin;
+	softkey_resource = r_asp_cba_next_back_next;
+	editor_resource_id = r_nsml_settings_text_editor;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for secret text editor
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_password_next_back
+	{	
+	number = EAknSettingPageNoOrdinalDisplayed;
+	type = EEikCtSecretEd;
+	softkey_resource = r_asp_cba_next_back_next;
+	editor_resource_id = r_setting_pwd_editor;
+	}
+
+
+
+
+//------------------------------------------------------------------------------
+// Listbox resourcee
+//------------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_setting_app_listbox 
+	{
+	flags = 0x0001;
+	}
+
+
+//------------------------------------------------------------------------------
+// Date editor
+//------------------------------------------------------------------------------
+//
+RESOURCE DATE_EDITOR r_asp_date_time_date_editor
+    {
+    minDate = DATE {day = 0; month = 0; year = 1980;};
+    maxDate = DATE {day = 30; month = 11; year = 2060;};
+    }
+
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_date
+    {
+    type = EEikCtDateEditor;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    menubar = R_AVKON_MENUPANE_EMPTY;
+    editor_resource_id = r_asp_date_time_date_editor;
+    }
+
+
+//------------------------------------------------------------------------------
+// Time editor
+//------------------------------------------------------------------------------
+//
+RESOURCE TIME_EDITOR r_asp_date_time_time_editor
+    {
+    minTime = TIME {second = 0; minute = 0; hour = 0;};
+    maxTime = TIME {second = 59; minute = 59; hour = 23;};
+    flags = EEikTimeWithoutSecondsField;
+    }
+
+
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_time
+    {
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    menubar = R_AVKON_MENUPANE_EMPTY;
+    type = EEikCtTimeEditor;
+    editor_resource_id = r_asp_date_time_time_editor;
+    }
+
+
+//------------------------------------------------------------------------------
+// Setting page for radio button settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_radio
+	{ 
+	number = EAknSettingPageNoOrdinalDisplayed;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+	type =  EAknSetListBox;
+	editor_resource_id= r_setting_app_listbox;
+	}
+
+//------------------------------------------------------------------------------
+// Setting page for multi selection list
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_multi_selection_list
+	{ 
+	number = EAknSettingPageNoOrdinalDisplayed;
+	softkey_resource = r_asp_cba_ok_cancel_mark;
+	type =  EAknSetListBox;
+	editor_resource_id= r_setting_app_listbox;
+	}
+
+//------------------------------------------------------------------------------
+// Editor for number setting page
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_INTEGER_EDWIN r_asp_setting_integer
+	{
+	maxlength = 5;
+	min =	1;
+	max =	65535;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for number settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_number
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	type=EAknCtIntegerEdwin;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+	editor_resource_id = r_asp_setting_integer;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for secret text editor
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_password
+	{	
+	number = EAknSettingPageNoOrdinalDisplayed;
+	type = EEikCtSecretEd;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+	editor_resource_id = r_setting_pwd_editor;
+	}
+
+
+//------------------------------------------------------------------------------
+// Editor for text setting page
+//------------------------------------------------------------------------------
+//
+RESOURCE EDWIN r_nsml_settings_text_editor
+	{
+	flags=0;
+	width=9;
+	lines=5;
+	maxlength=EAspMaxProfileNameLength;
+	default_input_mode=EAknEditorAlphaInputMode;
+	flags = EEikEdwinNoLineOrParaBreaks;
+	avkon_flags=0;
+	}
+
+
+//------------------------------------------------------------------------------
+// Setting page for text settings
+//------------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_asp_setting_text
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	type=EEikCtEdwin;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+	editor_resource_id = r_nsml_settings_text_editor;
+	}
+
+
+//------------------------------------------------------------------------------
+// yes/no selection resource
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_filters_used_yesno
+	{
+	items=
+		{
+		STRING { text = qtn_nsml_eml_use_filters_no ; },
+		STRING { text = qtn_nsml_eml_use_filters_yes ; }
+		};
+	}
+
+
+//------------------------------------------------------------------------------
+// content dialog sync type resource.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_sync_type
+	{
+	items =
+		{
+		STRING { text = qtn_sml_sync_type_normal; },
+		STRING { text = qtn_sml_sync_type_one_way_dev_to_srv; },
+		STRING { text = qtn_sml_sync_type_one_way_srv_to_dev; }
+		};
+	}
+
+
+//------------------------------------------------------------------------------
+// content dialog sync type resource.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_server_alert_type
+	{
+	items =
+		{
+		STRING { text = qtn_sml_set_sync_req_auto; },
+		STRING { text = qtn_sml_set_sync_req_ask_always; },
+		STRING { text = qtn_sml_set_sync_req_never; }
+		};
+	}
+
+
+//------------------------------------------------------------------------------
+// connection dialog proticol version resource.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_protocol_version
+	{
+	items =
+		{
+		STRING { text = qtn_sml_syncml_1_1 ; },
+		STRING { text = qtn_sml_syncml_1_2 ; }
+		};
+	}
+
+//------------------------------------------------------------------------------
+// Roaming Settings resource.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_roaming_settings
+    {
+    items =
+        {
+        STRING { text = qtn_sml_always_ask ; },
+        STRING { text = qtn_sml_always_allow ; },
+        STRING { text = qtn_sml_never_allow ; }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// connection dialog network connection resource.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_asp_network_connection
+	{
+	items =
+		{
+		STRING { text = qtn_netw_conset_sett_default_connection ; },
+		STRING { text = qtn_netw_conset_sett_user_defined ; }
+		};
+	}
+
+//------------------------------------------------------------------------------
+// text query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_text_query
+	{ 
+	flags=EGeneralQueryFlags;
+	buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+	items=
+		{
+		DLG_LINE
+			{
+			type=EAknCtQuery;
+			id=EGeneralQuery;
+			control=AVKON_DATA_QUERY
+				{
+				layout=EDataLayout;
+				control = EDWIN;
+				};
+			}
+		};
+	} 
+
+
+//------------------------------------------------------------------------------
+// confirmation query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_confirmation_query
+	{ 
+	flags=EGeneralQueryFlags;
+	buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+	items=
+		{
+		DLG_LINE
+			{
+			type=EAknCtQuery;
+			id=EGeneralQuery;
+			control=AVKON_CONFIRMATION_QUERY
+				{
+				layout=EConfirmationLayout;
+				};
+			}
+		};
+	} 
+
+//------------------------------------------------------------------------------
+// Roaming confirmation query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_roaming_confirmation_query
+    { 
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control=AVKON_CONFIRMATION_QUERY
+                {
+                layout=EConfirmationLayout;
+                };
+            }
+        };
+    } 
+
+
+//------------------------------------------------------------------------------
+// information query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_information_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_INFO_ANIM;
+                };
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// information query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_error_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_ERROR_ANIM;
+                };
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// message query resource
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_message_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE 
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                };
+            }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// progress dialog resource (shows sync progress)
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_progress_note
+	{ 
+	flags=EAknProgressNoteFlags | EEikDialogFlagNotifyEsc;
+	buttons=R_AVKON_SOFTKEYS_CANCEL;
+	items= 
+		{
+		DLG_LINE
+			{
+			type=EAknCtNote;
+			id=EAspSyncProgressNote;
+			control=AVKON_NOTE 
+				{
+                animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+				layout=EProgressLayout;
+				singular_label= "\n \n \n";
+				};
+			}
+		};
+	} 
+
+
+// -----------------------------------------------------------------------------
+// general list query resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_list_query
+    {
+    flags=EEikDialogFlagWait | EGeneralQueryFlags;
+
+    buttons=R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+	items=
+        {
+		AVKON_LIST_QUERY_DLG_LINE
+            {
+            control = AVKON_LIST_QUERY_CONTROL
+    	        {
+			    listtype = EAknCtSinglePopupMenuListBox;
+				heading = qtn_profile_dialog_title;
+			    
+			    listbox = AVKON_LIST_QUERY_LIST
+			        {
+				    // items added dynamically
+				    };
+			    };
+		    }
+		};
+    }
+
+
+// -----------------------------------------------------------------------------
+// filter dialog resource (shows sync connection settings).
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_filter_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspFilterDialog;
+			control=LISTBOX
+				{
+				flags=0;
+				height=11;
+				width=80;
+				};            
+            }
+		};
+    }
+
+
+RESOURCE MENU_BAR r_asp_filter_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_filter_dialog_menu_pane;
+			}
+		};
+	}
+
+
+RESOURCE MENU_PANE r_asp_filter_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdChange; txt=qtn_options_change; },
+		
+#ifdef __SERIES60_HELP				
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+
+// -----------------------------------------------------------------------------
+// profile dialog resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_profile_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    
+    buttons = r_asp_cba_options_back_change;
+    
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspProfileDialogList;
+			control=LISTBOX
+				{
+				flags=0;
+				height=11;
+				width=80;
+				};            
+            }
+		};
+    }
+
+
+
+
+RESOURCE MENU_BAR r_asp_profile_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_profile_dialog_menu_pane;
+			}
+		};
+	}
+
+RESOURCE MENU_BAR r_advance_settings_dialog_menu
+    {
+    titles= 
+        { 
+        MENU_TITLE 
+            { 
+            menu_pane=r_advance_settings_dialog_menu_pane;
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_asp_profile_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdChange; txt=qtn_options_change; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+RESOURCE MENU_PANE r_advance_settings_dialog_menu_pane
+    {
+    items=
+        {
+        MENU_ITEM { command=EAspMenuCmdChange; txt=qtn_options_change; },
+        
+#ifdef __SERIES60_HELP      
+        MENU_ITEM { command=EAspMenuCmdHelp; txt=qtn_options_help; },
+#endif
+        
+        MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+RESOURCE MENU_BAR r_asp_roaming_settings_context_menu
+    {
+    titles= 
+        { 
+        MENU_TITLE 
+            { 
+            menu_pane=r_advance_settings_dialog_menu_pane;
+            }
+        };
+    } 
+
+RESOURCE MENU_BAR r_asp_profile_context_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_profile_context_menu_pane;
+			}
+		};
+	} 
+    
+RESOURCE MENU_PANE r_asp_profile_context_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdOpen; txt=qtn_options_open; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// auto sync dialog resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_auto_sync_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    buttons = r_asp_cba_options_back_change;
+
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspAutoSyncDialogList;
+			control=LISTBOX
+				{
+				flags=0;
+				height=11;
+				width=80;
+				};   
+            }
+		};
+    }
+
+
+RESOURCE MENU_BAR r_asp_auto_sync_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_auto_sync_dialog_menu_pane;
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_asp_auto_sync_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdChange; txt=qtn_options_change; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// auto sync profile dialog resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_auto_sync_profile_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    buttons = r_asp_cba_options_select_back;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSingleGraphicListBox;
+            itemflags=EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+			id=EAspAutoSyncProfileDialogList;
+			control=LISTBOX
+				{
+				flags = EAknListBoxSelectionList;
+				};   
+            }
+		};
+    }
+
+
+
+RESOURCE MENU_BAR r_asp_auto_sync_profile_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_auto_sync_profile_dialog_menu_pane;
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_asp_auto_sync_profile_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdSelect; txt=qtn_sml_cmd_select; },
+		MENU_ITEM { command=EAspMenuCmdView; txt=qtn_sml_cmd_view_contents; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// content dialog resource (shows sync content settings).
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_content_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagNoDrag | EEikDialogFlagNoTitleBar |EEikDialogFlagFillAppClientRect | 
+          EEikDialogFlagCbaButtons | EEikDialogFlagNotifyEsc;
+
+	buttons=r_asp_cba_options_back_change;
+	
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspContentDialog;
+			control=LISTBOX
+				{
+				flags=0;
+				height=11;
+				width=80;
+				};            
+            }
+		};
+    }
+
+
+RESOURCE MENU_BAR r_asp_content_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_content_dialog_menu_pane;
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_asp_content_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdChange; txt=qtn_options_change; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif    	
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+
+// -----------------------------------------------------------------------------
+// Settings view dialog resource.
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE DIALOG r_asp_setting_view_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    
+    buttons = r_asp_cba_options_back_open;
+    
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspSettingViewDialogList;
+			control=LISTBOX
+				{
+				flags=0;
+				height=11;
+				width=80;
+				};            
+            }
+		};
+    }
+
+RESOURCE MENU_BAR r_asp_setting_view_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_setting_view_dialog_menu_pane;
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_asp_setting_view_dialog_menu_pane
+    {
+    items=
+        {
+		MENU_ITEM { command=EAspMenuCmdOpen; txt=qtn_options_open; },
+		
+#ifdef __SERIES60_HELP		
+    	MENU_ITEM { command=EAknCmdHelp; txt=qtn_options_help; },
+#endif
+    	
+		MENU_ITEM { command=EAspMenuCmdExit; txt=qtn_options_exit; }        
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// profile wizard dialog resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_profile_wizard_dialog
+    {
+    flags =
+        EEikDialogFlagWait | EEikDialogFlagNotifyEsc |
+        EEikDialogFlagCbaButtons | EEikDialogFlagNoDrag |
+        EEikDialogFlagNoTitleBar | EEikDialogFlagNoShadow |
+        EEikDialogFlagNoBorder | EEikDialogFlagFillAppClientRect;
+        
+    buttons = r_asp_cba_start_cancel_start;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EEikCtRichTextEditor;
+            id = EAspProfileWizardDialogList;
+            control = RTXTED
+                {
+                numlines = 10;
+                avkon_flags = EAknEditorFlagEnableScrollBars;
+                flags = EEikEdwinReadOnly |
+                        EEikEdwinNoAutoSelection |
+                        EEikEdwinAvkonDisableCursor;
+                };
+            }
+        };
+    }
+
+
+// -----------------------------------------------------------------------------
+// setting dialog resource (main dialog).
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_setting_dialog
+    {
+	flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+
+    //buttons=R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    buttons=r_asp_cba_options_back_mark;
+    items=
+        {
+        DLG_LINE
+            {
+            //type=EAknCtDoubleLargeListBox;
+            //type=EAknCtDoubleListBox;
+            type=EAknCtDoubleGraphicListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspSettingDialogList;
+			control=LISTBOX
+				{
+				//flags = EAknListBoxPointerMultiselectionList | EAknListBoxLoopScrolling;
+				//flags = EAknListBoxMultiselectionList | EAknListBoxLoopScrolling;
+				flags = EAknListBoxMultiselectionList | EAknListBoxPointerMultiselectionList | EAknListBoxLoopScrolling;
+				};            
+            }
+		};
+    }
+
+
+// -----------------------------------------------------------------------------
+// setting dialog resource (main dialog).
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_asp_setting_dialog_2
+    {
+	flags= EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+
+    //buttons=R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    buttons=r_asp_cba_options_exit_mark;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtDoubleGraphicListBox;
+			itemflags=EEikDlgItemTakesEnterKey;
+			id=EAspSettingDialogList;
+			control=LISTBOX
+				{
+				//flags = EAknListBoxPointerMultiselectionList | EAknListBoxLoopScrolling;
+				//flags = EAknListBoxMultiselectionList | EAknListBoxLoopScrolling;
+				flags = EAknListBoxMultiselectionList | EAknListBoxPointerMultiselectionList | EAknListBoxLoopScrolling;
+				height=2;
+				width=80;
+				};            
+            }
+		};
+    }
+
+
+
+RESOURCE MENU_BAR r_asp_setting_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_setting_dialog_menu_pane;
+			}
+		};
+	}
+
+
+RESOURCE MENU_BAR r_asp_setting_dialog_context_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_asp_setting_dialog_context_menu_pane;
+			}
+		};
+	}
+
+
+RESOURCE MENU_PANE r_asp_setting_dialog_menu_pane
+	{
+	items =
+		{
+		MENU_ITEM { command=EAspMenuCmdMark; 			txt=qtn_sml_cmd_mark; },
+		MENU_ITEM { command=EAspMenuCmdUnmark; 			txt=qtn_sml_cmd_unmark; },
+		MENU_ITEM { command=EAspMenuCmdSync;           txt=qtn_sml_cmd_sync; },
+		MENU_ITEM { command=EAspMenuCmdNewSet;         txt=qtn_sml_cmd_create_new; },
+		MENU_ITEM { command=EAspMenuCmdEdit;           txt=qtn_sml_cmd_edit; },
+		MENU_ITEM { command=EAspMenuCmdAdvanceSettings; txt=qtn_sml_cmd_advanced_settings; },
+		MENU_ITEM { command=EAspMenuCmdChangeProfile;  txt=qtn_sml_cmd_change_profile; },
+    	MENU_ITEM { command=EAspMenuCmdDelete;         txt=qtn_sml_cmd_delete; },
+    	MENU_ITEM { command=EAspMenuCmdAutoSync;       txt=qtn_sml_cmd_automatic_sync; },
+		MENU_ITEM { command=EAspMenuCmdViewLog;        txt=qtn_sml_cmd_view_log; },
+		MENU_ITEM { command=EAspMenuCmdCopyFromServer; txt=qtn_sml_cmd_slow_sync; },
+		
+#ifdef __SERIES60_HELP		
+		MENU_ITEM { command=EAknCmdHelp;	     txt=qtn_options_help; },
+#endif		
+    	
+    	MENU_ITEM { command=EAspMenuCmdExit;	     txt=qtn_options_exit; }
+		};
+	}
+
+RESOURCE DIALOG r_asp_advance_settings_dialog
+    {
+    flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+    
+    buttons = r_asp_cba_options_back_change;
+    
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtSettingListBox;
+            itemflags=EEikDlgItemTakesEnterKey;
+            id=EAdvanceSettingsDialogList;
+            control=LISTBOX
+                {
+                flags=0;
+                height=11;
+                width=80;
+                };            
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_asp_setting_dialog_context_menu_pane
+	{
+	items =
+		{
+		MENU_ITEM { command=EAspMenuCmdSync;         txt=qtn_sml_cmd_sync; },
+		MENU_ITEM { command=EAspMenuCmdEdit;         txt=qtn_sml_cmd_edit; },
+		MENU_ITEM { command=EAspMenuCmdDelete;       txt=qtn_sml_cmd_delete; },
+		MENU_ITEM { command=EAspMenuCmdViewLog;      txt=qtn_sml_cmd_view_log; },
+		MENU_ITEM { command=EAspMenuCmdNewSet;       txt=qtn_sml_cmd_create_new; }
+		};
+	}
+
+RESOURCE TBUF r_asp_select_profile_create_new { buf = qtn_sml_apps_select_profile_create_new; }
+
+RESOURCE DIALOG r_asp_list_app_query
+    {
+    flags=EEikDialogFlagWait | EGeneralQueryFlags;
+
+    buttons=R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+	items=
+        {
+		AVKON_LIST_QUERY_DLG_LINE
+            {
+            control = AVKON_LIST_QUERY_CONTROL
+    	        {
+			    listtype = EAknCtSingleGraphicPopupMenuListBox;
+				heading = qtn_profile_dialog_title;
+			    
+			    listbox = AVKON_LIST_QUERY_LIST
+			        {
+				    // items added dynamically
+				    };
+			    };
+		    }
+		};
+    }
+
+RESOURCE ARRAY r_asp_sync_pcsuite_type
+	{
+	items =
+		{
+		STRING { text = qtn_sml_sync_type_normal; }		
+		};
+	}
+
+// Display name for PC Suite profile
+RESOURCE TBUF r_asp_pc_suite_profile { buf = qtn_sml_pc_suite_profile; }
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncUtilApi.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 functions that are exported from AspSyncUtil for
+*                performing data synchronization.
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "AspSyncUtilApi.h"
+#include "AspSyncUtil.h"
+#include "AspDebug.h"
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CSyncUtilApi::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSyncUtilApi* CSyncUtilApi::NewL()
+    {
+    FLOG( _L("CSyncUtilApi::NewL START") );
+    
+    CSyncUtilApi* self = new (ELeave) CSyncUtilApi();
+    CleanupStack::PushL(self);
+	self->ConstructL();
+    CleanupStack::Pop(self);
+
+	FLOG( _L("CSyncUtilApi::NewL END") );
+	
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CSyncUtilApi::~CSyncUtilApi()
+    {
+    FLOG( _L("CSyncUtilApi::~CSyncUtilApi START") );
+    
+	delete iSyncUtil;
+	
+	FLOG( _L("CSyncUtilApi::~CSyncUtilApi END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSyncUtilApi::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSyncUtilApi::ConstructL()
+    {
+	iSyncUtil = CAspSyncUtil::NewL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSyncUtilApi::CSyncUtilApi
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSyncUtilApi::CSyncUtilApi()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSyncUtilApi::SynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSyncUtilApi::SynchronizeL(TInt aApplicationId, TInt aJobId, TInt aInfo1, TDes& aInfo2)
+    {
+	iSyncUtil->SynchronizeL(aApplicationId, aJobId, aInfo1, aInfo2); 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSyncUtilApi::ShowSettingsL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSyncUtilApi::ShowSettingsL(TInt aApplicationId, TInt aInfo1, TDes& aInfo2)
+    {
+    iSyncUtil->ShowSettingsL(aApplicationId, aInfo1, aInfo2);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspSyncUtil::SynchronizeL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSyncUtilApi::SynchronizeL(RFile& aScheduleTaskFile)
+	{
+	iSyncUtil->SynchronizeL(aScheduleTaskFile);
+	}
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/AspSyncUtil/src/AspUtil.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2749 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+
+// INCLUDES
+
+#include <SyncMLTransportProperties.h>
+#include <flogger.h>
+#include <eikenv.h>
+#include <bautils.h>  // BaflUtils
+#include <AiwGenericParam.hrh>  // for application ids
+#include <collate.h>   // for TCollationMethod
+
+#include <featmgr.h>   // FeatureManager
+#include <ApUtils.h>   // CApUtils
+#include <avkon.rsg>
+#include <hlplch.h>    // HlpLauncher
+
+#include <MuiuMsvUiServiceUtilities.h> // for MsvUiServiceUtilities
+
+
+#include "AspUtil.h"
+#include "AspDialogUtil.h"
+#include "AspResHandler.h"
+#include "AspDebug.h"
+#include <AspSyncUtil.rsg>
+
+#include <SyncMLErr.h>  // sync error codes
+
+//#ifdef __SAP_POLICY_MANAGEMENT
+#include <SettingEnforcementInfo.h> // VSettingEnforcementInfo
+//#endif
+
+
+
+
+
+/******************************************************************************
+ * class TAspParam
+ ******************************************************************************/
+
+
+// -------------------------------------------------------------------------------
+// TAspParam::TAspParam
+//
+// -------------------------------------------------------------------------------
+//
+TAspParam::TAspParam(TInt aApplicationId)
+ : iApplicationId(aApplicationId), iProfileId(KErrNotFound), iMode(KErrNotFound),
+   iId(KErrNotFound), iReturnValue(KErrNotFound), iDataProviderId(KErrNotFound),
+   iSyncTaskId(KErrNotFound), iProfile(NULL), 
+   iSyncTask(NULL), iSyncFilter(NULL), iSyncSession(NULL),
+   iProfileList(NULL), iContentList(NULL), iSchedule(NULL)
+	 {
+	 }
+
+
+// -------------------------------------------------------------------------------
+// TAspParam::TAspParam
+//
+// -------------------------------------------------------------------------------
+//
+TAspParam::TAspParam(TInt aApplicationId, RSyncMLSession* aSyncSession)
+ : iApplicationId(aApplicationId), iProfileId(KErrNotFound), iMode(KErrNotFound),
+   iId(KErrNotFound), iReturnValue(KErrNotFound), iDataProviderId(KErrNotFound),
+   iSyncTaskId(KErrNotFound), iProfile(NULL),
+   iSyncTask(NULL), iSyncFilter(NULL), iSyncSession(aSyncSession),
+   iProfileList(NULL), iContentList(NULL), iSchedule(NULL)
+  	 {
+	 }
+
+
+
+/******************************************************************************
+ * class TAspUtil
+ ******************************************************************************/
+
+
+// -------------------------------------------------------------------------------
+// TUtil::Panic
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::Panic(TInt aReason)
+    {
+	_LIT(KPanicCategory,"AspSyncUtil");
+
+	User::Panic(KPanicCategory, aReason); 
+    }
+
+
+// -------------------------------------------------------------------------------
+// TUtil::StrCopy
+//
+// String copy with lenght check.
+// -------------------------------------------------------------------------------
+//
+void TUtil::StrCopy(TDes8& aTarget, const TDesC& aSource)
+    {
+	TInt len = aTarget.MaxLength();
+    if(len < aSource.Length()) 
+	    {
+		aTarget.Copy(aSource.Left(len));
+		return;
+	    }
+	aTarget.Copy(aSource);
+    }
+
+// -------------------------------------------------------------------------------
+// TUtil::StrCopy
+//
+// String copy with lenght check.
+// -------------------------------------------------------------------------------
+//
+void TUtil::StrCopy(TDes& aTarget, const TDesC8& aSource)
+    {
+	TInt len = aTarget.MaxLength();
+    if(len < aSource.Length()) 
+	    {
+		aTarget.Copy(aSource.Left(len));
+		return;
+	    }
+	aTarget.Copy(aSource);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TUtil::StrCopy
+//
+// String copy with lenght check.
+// -------------------------------------------------------------------------------
+//
+void TUtil::StrCopy(TDes& aTarget, const TDesC& aSource)
+    {
+	TInt len = aTarget.MaxLength();
+    if(len < aSource.Length()) 
+	    {
+		aTarget.Copy(aSource.Left(len));
+		return;
+	    }
+	aTarget.Copy(aSource);
+    }
+
+//--------------------------------------------------------------------------------
+//TUtil::StrConversion
+//
+//Convert TBuf to HBuf
+//--------------------------------------------------------------------------------
+//
+HBufC* TUtil::StrConversion(const TDesC& aDefaultText)
+{
+	return aDefaultText.AllocLC();
+    }
+
+
+// -------------------------------------------------------------------------------
+// TUtil::StrAppend
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::StrAppend(TDes& aTarget, const TDesC& aSource)
+{
+    if (aSource.Length() == 0)
+    	{
+    	return;
+    	}
+    	
+	TInt free = aTarget.MaxLength() - aTarget.Length();
+	if (aSource.Length() < free)
+		{
+		aTarget.Append(aSource);
+		}
+}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::StrInsert
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::StrInsert(TDes& aTarget, const TDesC& aSource)
+{
+	TInt free = aTarget.MaxLength() - aTarget.Length();
+	if (aSource.Length() < free)
+		{
+		aTarget.Insert(0, aSource);
+		}
+}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::StrToInt
+//
+// -------------------------------------------------------------------------------
+//
+TInt TUtil::StrToInt(const TDesC& aText, TInt& aNum)
+	{
+    TLex lex(aText);
+
+    TInt err=lex.Val(aNum); 
+	return err;
+	}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::IsEmpty
+//
+// Function returns ETrue if string only contains white space or has no characters.
+// -------------------------------------------------------------------------------
+//
+TBool TUtil::IsEmpty(const TDesC& aText)
+	{
+	TInt len=aText.Length();
+	for (TInt i=0; i<len; i++)
+		{
+		TChar c=aText[i];
+		if (!c.IsSpace())
+			{
+			return EFalse;
+			}
+		}
+	return ETrue;
+	}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::Fill
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::Fill(TDes& aTarget, const TDesC& aOneCharStr, TInt aLength)
+	{
+	TInt len = aTarget.MaxLength();
+    if(len > aLength)
+    	{
+    	TBuf<KBufSize16> buf(aOneCharStr);
+	    aTarget.Fill(buf[0], aLength);
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::AddResFileL
+//
+// -----------------------------------------------------------------------------
+//
+TInt TUtil::AddResFileL(const TDesC& aFile)
+	{
+	CEikonEnv* env = CEikonEnv::Static();
+
+	TFileName fileName(aFile);
+
+	BaflUtils::NearestLanguageFile(env->FsSession(), fileName);
+
+    return env->AddResourceFileL(fileName);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::IsValidAppId
+//
+// -----------------------------------------------------------------------------
+//
+TBool TUtil::IsValidAppId(TInt aApplicationId)
+	{
+	TInt id = aApplicationId;
+	
+	if (id == EApplicationIdSync || id == EApplicationIdContact || 
+	    id == EApplicationIdCalendar || id == EApplicationIdEmail ||
+	    id == EApplicationIdNote || id == EApplicationIdMms)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::IsValidSID
+//
+// -----------------------------------------------------------------------------
+//
+TBool TUtil::IsValidSID(TInt aSid)
+	{
+	TInt id = aSid;
+	
+	if (id == KUidAppSync.iUid || id == KUidAppPhonebook.iUid || 
+	    id == KUidAppCalendar.iUid || id == KUidAppMessages.iUid ||
+	    id == KUidAppNotepad.iUid || id == KUidAppTest.iUid || 
+	    id == KUidAppMailEditor.iUid)
+		{
+		return ETrue;
+		}
+		
+	return EFalse;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::ProviderIdFromAppId
+//
+// -----------------------------------------------------------------------------
+//
+TInt TUtil::ProviderIdFromAppId(TInt aApplicationId)
+	{
+	TInt id=KErrNotFound;
+
+	switch (aApplicationId)
+		{
+		case EApplicationIdContact:
+			id = KUidNSmlAdapterContact.iUid;
+			break;
+		case EApplicationIdCalendar:
+			id = KUidNSmlAdapterCalendar.iUid;
+			break;
+		case EApplicationIdEmail:
+     		id = KUidNSmlAdapterEMail.iUid;
+			break;
+		case EApplicationIdNote:
+			id = KUidNSmlAdapterNote.iUid;
+			break;
+		default:
+            id = KErrNotFound;
+			break;
+		}
+
+	return id;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::AppIdFromProviderId
+//
+// -----------------------------------------------------------------------------
+//
+TInt TUtil::AppIdFromProviderId(TInt aAdapterId)
+	{
+	TInt id=KErrNotFound;
+
+	if (aAdapterId == KUidNSmlAdapterContact.iUid)
+		{
+		id = EApplicationIdContact;
+		}
+	if (aAdapterId == KUidNSmlAdapterCalendar.iUid)
+		{
+		id = EApplicationIdCalendar;
+		}
+	if (aAdapterId == KUidNSmlAdapterEMail.iUid)
+		{
+		id = EApplicationIdEmail;
+		}
+	if (aAdapterId == KUidNSmlAdapterNote.iUid)
+		{
+		id = EApplicationIdNote;
+		}
+
+	return id;
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::IsToDay
+//
+// -----------------------------------------------------------------------------
+//
+TBool TUtil::IsToday(TTime aTime)
+	{
+	TTime now;
+	now.HomeTime();
+	
+	TInt day1 = now.DayNoInYear();
+	TInt day2 = aTime.DayNoInYear();
+	
+	TDateTime date1 = now.DateTime();
+	TDateTime date2 = aTime.DateTime();
+	
+	
+	TTimeIntervalDays daysBetween = now.DaysFrom(aTime);
+	
+	if (day1 != day2 || date1.Year() != date2.Year())
+		{
+		return EFalse;
+		}
+		
+	if (daysBetween.Int() > 0)
+		{
+		return EFalse;
+		}
+		
+	return ETrue; 
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::SyncTimeLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* TUtil::SyncTimeLC(TTime aLastSync)
+	{
+	TTime homeTime = ConvertUniversalToHomeTime(aLastSync);
+	
+	HBufC* hBuf = HBufC::NewLC(KBufSize255);
+	TPtr ptr = hBuf->Des();
+
+	if (IsToday(homeTime))
+		{
+		TBuf<KBufSize> timeFormat;
+		CAspResHandler::ReadL(timeFormat, R_QTN_TIME_USUAL_WITH_ZERO);
+		homeTime.FormatL(ptr, timeFormat);
+		}
+	else
+		{
+		TBuf<KBufSize> dateFormat;
+		CAspResHandler::ReadL(dateFormat, R_QTN_DATE_USUAL_WITH_ZERO);
+		homeTime.FormatL(ptr, dateFormat);
+		}
+   
+	return hBuf;
+	}
+	
+	
+// -----------------------------------------------------------------------------
+// TUtil::ConvertUniversalToHomeTime
+//
+// -----------------------------------------------------------------------------
+//
+TTime TUtil::ConvertUniversalToHomeTime(const TTime& aUniversalTime)
+    {
+    TTime time(aUniversalTime);   // time stores UTC time.
+
+    TLocale locale;
+    TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
+    
+    // Add locale's universal time offset to universal time.
+    time += universalTimeOffset;    // time stores Local Time.
+
+    // If home daylight saving in effect, add one hour offset.
+    if (locale.QueryHomeHasDaylightSavingOn())
+        {
+        TTimeIntervalHours daylightSaving(1);
+        time += daylightSaving;
+        }
+
+    return time;
+    }
+	
+
+// -----------------------------------------------------------------------------
+// TUtil::GetDateTextL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::GetDateTextL(TDes& aText, TTime aDateTime)
+	{
+	TTime homeTime = ConvertUniversalToHomeTime(aDateTime);
+	
+	HBufC* hBuf = CAspResHandler::ReadLC(R_QTN_DATE_USUAL_WITH_ZERO);
+    homeTime.FormatL(aText, *hBuf);
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::GetTimeTextL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::GetTimeTextL(TDes& aText, TTime aDateTime)
+	{
+	TTime homeTime = ConvertUniversalToHomeTime(aDateTime);
+	
+	HBufC* hBuf = CAspResHandler::ReadLC(R_QTN_TIME_USUAL_WITH_ZERO);
+    homeTime.FormatL(aText, *hBuf);
+    CleanupStack::PopAndDestroy(hBuf);
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::GetDateTimeTextL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::GetDateTimeTextL(TDes& aText, TTime aDateTime)
+	{
+	TDateTime dt = aDateTime.DateTime();
+	aText.Format(_L("%02d.%02d.%04d %02d:%02d:%02d"), dt.Day()+1, dt.Month()+1, dt.Year(),  dt.Hour(), dt.Minute(), dt.Second());
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::LaunchHelpAppL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::LaunchHelpAppL()
+	{
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		return;
+		}
+		
+	CEikonEnv* eikEnv = CEikonEnv::Static();
+	HlpLauncher::LaunchHelpApplicationL(eikEnv->WsSession(), eikEnv->EikAppUi()->AppHelpContextL());
+	}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::LaunchHelpAppL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::LaunchHelpAppL(CEikonEnv* aEikonkEnv)
+	{
+	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+		{
+		return;
+		}
+		
+	CEikonEnv* eikEnv = CEikonEnv::Static();
+	HlpLauncher::LaunchHelpApplicationL(aEikonkEnv->WsSession(), 
+	                                    aEikonkEnv->EikAppUi()->AppHelpContextL());
+	}
+
+
+// ---------------------------------------------------------
+// TUtil::SettingEnforcementStateL
+// 
+// Checks if setting enforcement is activated.
+// ---------------------------------------------------------
+TBool TUtil::SettingEnforcementStateL()
+    {
+    
+ FeatureManager::InitializeLibL();
+ if(!FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+ {
+		//#ifndef __SAP_POLICY_MANAGEMENT
+		FeatureManager::UnInitializeLib();
+		    return EFalse;
+		//#else
+}
+else
+{
+	FeatureManager::UnInitializeLib();
+	CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+	CleanupStack::PushL(info);
+
+	TBool active = EFalse;
+	User::LeaveIfError(info->EnforcementActive(EDataSyncEnforcement, active));
+	CleanupStack::PopAndDestroy(info);
+
+	return active;
+ //#endif
+}
+
+
+    }
+
+
+// ---------------------------------------------------------
+// TUtil::SettingEnforcementState
+// 
+// Checks if setting enforcement is activated.
+// ---------------------------------------------------------
+TBool TUtil::SettingEnforcementState()
+    {
+    TBool ret = EFalse;
+    
+    TRAP_IGNORE(ret = SettingEnforcementStateL());
+    
+    return ret;
+    }
+
+
+// ---------------------------------------------------------
+// TUtil::NumberConversionLC
+// 
+// ---------------------------------------------------------
+CDesCArray* TUtil::NumberConversionLC(CDesCArray* aList)
+    {
+    CDesCArrayFlat* arr = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
+    CleanupStack::PushL(arr);
+    
+    TInt count = aList->Count();
+    
+    for (TInt i=0; i<count; i++)
+    	{
+    	TBuf<KBufSize> buf((*aList)[i]);
+     	AknTextUtils::DisplayTextLanguageSpecificNumberConversion(buf);
+     	arr->AppendL(buf);
+    	}
+    	
+    return arr;
+    }
+
+
+
+#ifdef _DEBUG
+
+// -------------------------------------------------------------------------------
+// TUtil::Print
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::Print(const TDesC& aText)
+    {
+	CEikonEnv::Static()->InfoMsg(aText);
+	}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::Print
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::Print(const TDesC& aText, TInt aNum)
+    {
+	_LIT(KFormat, "%S (%d)");
+
+	TBuf<KBufSize> buf;
+	buf.Format(KFormat, &aText, aNum);
+	CEikonEnv::Static()->InfoMsg(buf);
+	}
+
+
+// -------------------------------------------------------------------------------
+// TUtil::GetMandatoryFieldText
+//
+// -------------------------------------------------------------------------------
+//
+void TUtil::GetMandatoryFieldText(TDes& aText, TInt aStatus)
+    {
+	switch (aStatus)
+		{
+		case EMandatoryNoProfileName:
+            aText = _L("no profile name");
+			break;
+		case EMandatoryNoHostAddress:
+			aText = _L("no host address");
+			break;
+		case EMandatoryNoContent:
+			aText = _L("no content");
+			break;
+		case EMandatoryNoLocalDatabase:
+			aText = _L("no local database");
+			break;
+		case EMandatoryNoRemoteDatabase:
+			aText = _L("no remote database");
+			break;
+		default:
+			aText = _L("profile ok");
+			break;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// TUtil::TimeBefore
+//
+// Function returns TTime of the current time (needed with function TimeAfter).
+// -----------------------------------------------------------------------------
+//
+TTime TUtil::TimeBefore()
+{
+    TTime now;
+	now.UniversalTime();
+	return now;
+}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::TimeAfter
+//
+// Function returns milliseconds passed since aBefore.
+// -----------------------------------------------------------------------------
+//
+TInt TUtil::TimeAfter(TTime aBefore)
+{
+	TTime after;
+	after.UniversalTime();
+	TTimeIntervalMicroSeconds microSeconds = after.MicroSecondsFrom(aBefore); 
+	TInt seconds = microSeconds.Int64()/1000;
+	return seconds;
+}
+
+
+// -----------------------------------------------------------------------------
+// TUtil::TimeAfter
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::TimeAfter(TTime aBefore, const TDesC& aText)
+    {
+	TTime after;
+	after.UniversalTime();
+	TTimeIntervalMicroSeconds microSeconds = after.MicroSecondsFrom(aBefore); 
+	
+	FTRACE( RDebug::Print(_L("%S %d ms"), &aText, microSeconds.Int64()/1000) );
+    }
+
+
+// -----------------------------------------------------------------------------
+// TUtil::GetApplicationNameL
+//
+// -----------------------------------------------------------------------------
+//
+void TUtil::GetApplicationName(TDes& aText, TInt aApplicationId)
+    {
+	switch (aApplicationId)
+		{
+		case EApplicationIdSync:
+			aText = _L("EApplicationIdSync");
+			break;
+		case EApplicationIdContact:
+			aText = _L("EApplicationIdContact");
+			break;
+		case EApplicationIdCalendar:
+			aText = _L("EApplicationIdCalendar");
+			break;
+		case EApplicationIdEmail:
+			aText = _L("EApplicationIdEmail");
+			break;
+		case EApplicationIdMms:
+			aText = _L("EApplicationIdMms");
+			break;
+		case EApplicationIdNote:
+			aText = _L("EApplicationIdNote");
+			break;
+		default:
+			aText = _L("unknown app");
+			break;
+		}
+    }
+
+#endif
+
+
+
+/******************************************************************************
+ * class TURIParser
+ ******************************************************************************/
+
+
+// ---------------------------------------------------------
+// TURIParser::TURIParser
+// 
+// ---------------------------------------------------------
+TURIParser::TURIParser(const TDesC& aStr) : iOriginalStr(aStr)
+    {
+    SkipHttp();
+    }
+
+
+// ---------------------------------------------------------
+// TURIParser::GetUriWithoutPort
+// 
+// URI format: "http://serveraddress/documentname/"
+// ---------------------------------------------------------
+void TURIParser::GetUriWithoutPort(TDes& aText)
+	{
+	_LIT(KSlash, "/");
+	
+	aText = KNullDesC;
+	
+	TPtrC http = ParseHttp();
+	TPtrC address = ParseAddress();
+	TPtrC document = ParseDocument();
+	
+	TUtil::StrAppend(aText, http);
+	TUtil::StrAppend(aText, address);
+	
+	if (document.Length() > 0)
+		{
+		TUtil::StrAppend(aText, KSlash);
+		TUtil::StrAppend(aText, document);
+		}
+	//else if (aText.Length() > 0)
+	//	{
+	//	TUtil::StrAppend(aText, KSlash);
+	//	}
+	}
+	
+
+// ---------------------------------------------------------
+// TURIParser::GetUriWithPort
+// 
+// URI format: "http://serveraddress:port/documentname/"
+// ---------------------------------------------------------
+void TURIParser::GetUriWithPort(TDes& aText, const TInt aPort)
+	{
+	_LIT(KColon, ":");
+	_LIT(KSlash, "/");
+	
+	aText = KNullDesC;
+	
+	TPtrC http = ParseHttp();
+	
+	TPtrC address = ParseAddress();
+	
+	TPtrC document = ParseDocument();
+	
+	TUtil::StrAppend(aText, http);
+	TUtil::StrAppend(aText, address);
+	
+	TBuf<KBufSize32> buf;
+	buf.Num(aPort);
+	TUtil::StrAppend(aText, KColon);
+	TUtil::StrAppend(aText, buf);
+	
+	if (document.Length() > 0)
+		{
+		TUtil::StrAppend(aText, KSlash);
+		TUtil::StrAppend(aText, document);
+		}
+	//else if (aText.Length() > 0)
+	//	{
+	//	TUtil::StrAppend(aText, KSlash);
+	//	}
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::Port
+// 
+// ---------------------------------------------------------
+TInt TURIParser::Port()
+	{
+	TInt port = KErrNotFound;
+	
+	TInt err = ParsePort(port);
+	if (err != KErrNone)
+		{
+		return KErrNotFound;
+		}
+		
+	return port;
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::DefaultPort
+// 
+// ---------------------------------------------------------
+TInt TURIParser::DefaultPort()
+	{
+	_LIT(KHttpsHeader, "https://");
+	
+	TInt pos = iOriginalStr.FindF(KHttpsHeader);
+	if (pos != KErrNotFound)
+		{
+		return EDefaultHttpsPort;
+		}
+
+	return EDefaultHttpPort;
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::IsValidUri
+// 
+// ---------------------------------------------------------
+TBool TURIParser::IsValidUri(const TDesC& aText)
+	{
+	_LIT(KHttpHeader, "http://");
+	_LIT(KHttpsHeader, "https://");
+
+	const TInt KHttpLength = 7;
+	const TInt KHttpsLength = 8;
+	
+	// IsValidDomainL this does not accept comma ("http://" fails)
+	//return MsvUiServiceUtilities::IsValidDomainL(aText);
+	
+	if (TUtil::IsEmpty(aText))
+		{
+		return EFalse;
+		}
+		
+    if (aText.Compare(KHttpHeader) == 0)
+    	{
+    	return EFalse;
+    	}
+	
+    if (aText.Compare(KHttpsHeader) == 0)
+    	{
+    	return EFalse;
+    	}
+    
+    if (aText.Left(KHttpLength).Compare(KHttpHeader) != 0
+    				&& aText.Left(KHttpsLength).Compare(KHttpsHeader) != 0)
+    	{
+    	return EFalse;
+    	}
+	
+	return ETrue;
+	}
+
+// ---------------------------------------------------------
+// TURIParser::IsValidBluetoothHostAddress
+// 
+// ---------------------------------------------------------
+TBool TURIParser::IsValidBluetoothHostAddress(const TDesC& aText)
+	{
+	_LIT(KHttpHeader, "http://");
+	_LIT(KHttpsHeader, "https://");
+
+	const TInt KHttpLength = 7;
+	const TInt KHttpsLength = 8;
+	
+	// IsValidDomainL this does not accept comma ("http://" fails)
+	//return MsvUiServiceUtilities::IsValidDomainL(aText);
+	
+	if (TUtil::IsEmpty(aText))
+		{
+		return EFalse;
+		}
+		
+    if (aText.Compare(KHttpHeader) == 0)
+    	{
+    	return EFalse;
+    	}
+	
+    if (aText.Compare(KHttpsHeader) == 0)
+    	{
+    	return EFalse;
+    	}
+    
+    if (aText.Left(KHttpLength).Compare(KHttpHeader) == 0
+    				|| aText.Left(KHttpsLength).Compare(KHttpsHeader) == 0)
+    	{
+    	return EFalse;
+    	}
+	
+	return ETrue;
+	}
+// ---------------------------------------------------------
+// TURIParser::IsValidPort
+// 
+// ---------------------------------------------------------
+TBool TURIParser::IsValidPort(const TInt aPort)
+	{
+	if (aPort < TURIParser::EMinURIPortNumber || 
+	    aPort > TURIParser::EMaxURIPortNumber)
+		{
+		return EFalse;
+		}
+		
+	return ETrue;
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::SkipHttp
+// 
+// Set pointer to the end of "http://".
+// ---------------------------------------------------------
+void TURIParser::SkipHttp()
+	{
+    TInt start = KErrNotFound;
+    TInt end   = KErrNotFound;
+    TStr str(iOriginalStr);
+    
+    GetHttpPos(start, end);
+    
+    if (start != KErrNotFound)
+    	{
+    	iPtr.Set(str.Right(end+1));
+    	}
+    else
+    	{
+    	iPtr.Set(str.Right(0));
+    	}
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::ParseHttp
+// 
+// ---------------------------------------------------------
+TPtrC TURIParser::ParseHttp()
+	{
+    TInt start = KErrNotFound;
+    TInt end   = KErrNotFound;
+    
+    GetHttpPos(start, end);
+    
+    if (start == KErrNotFound)
+    	{
+    	return TPtrC();
+    	}
+    
+   	TStr str(iOriginalStr);
+    return str.SubStr(start, end);
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::GetHttpPos
+// 
+// ---------------------------------------------------------
+void TURIParser::GetHttpPos(TInt& aStartPos, TInt& aEndPos)
+	{
+	_LIT(KHttpHeader, "http://");
+    _LIT(KHttpsHeader, "https://");
+
+	aEndPos = KErrNotFound;
+	
+	aStartPos = iOriginalStr.FindF(KHttpHeader);
+	if (aStartPos != KErrNotFound)
+		{
+		aEndPos = aStartPos + KHttpHeader().Length() - 1;
+		return;
+		}
+	
+	aStartPos = iOriginalStr.FindF(KHttpsHeader);
+	if (aStartPos != KErrNotFound)
+		{
+		aEndPos = aStartPos + KHttpsHeader().Length() - 1;
+		return;
+		}
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::ParseAddress
+// 
+// ---------------------------------------------------------
+TPtrC TURIParser::ParseAddress()
+	{
+	const TChar KSlash('/');
+	const TChar KColon(':');
+	
+	TStr str(iPtr);
+	
+    TInt firstSlash = str.Find(0, KSlash);
+	TInt firstcolon = str.Find(0, KColon);
+	
+	TBool portFound = EFalse;
+	if (firstcolon != KErrNotFound)
+		{
+		if (firstSlash == KErrNotFound)
+			{
+			portFound = ETrue;
+			}
+		else if (firstcolon < firstSlash)
+			{
+			portFound = ETrue;
+			}
+		}
+    
+	if (portFound)
+		{
+		// address is text before first colon
+		return str.Left(firstcolon-1);
+		}
+	else if (firstSlash != KErrNotFound)
+		{
+		// address is text before first slash
+		return str.Left(firstSlash-1);
+		}
+	else
+		{
+		// address is all text
+		return str.Right(0);
+		}
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::ParseDocument
+// 
+// ---------------------------------------------------------
+TPtrC TURIParser::ParseDocument()
+	{
+	const TChar KSlash('/');
+	
+	TStr str(iPtr);
+    TInt firstSlash = str.Find(0, KSlash);
+    
+	if (firstSlash != KErrNotFound)
+		{
+		// document is all text after first slash
+		return str.Right(firstSlash+1);
+		}
+		
+	return TPtrC();
+	
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::ParsePort
+// 
+// ---------------------------------------------------------
+TInt TURIParser::ParsePort(TInt& aNumber)
+	{
+	TPtrC port = ParsePort();
+	if (port.Length() == 0)
+		{
+		return KErrNotFound;
+		}
+		
+	return TUtil::StrToInt(port, aNumber);
+	}
+
+
+// ---------------------------------------------------------
+// TURIParser::ParsePort
+// 
+// ---------------------------------------------------------
+TPtrC TURIParser::ParsePort()
+	{
+	const TChar KSlash('/');
+	const TChar KColon(':');
+	
+	TStr str(iPtr);
+    TInt firstSlash = str.Find(0, KSlash);
+	TInt firstColon = str.Find(0, KColon);
+    
+	if (firstSlash != KErrNotFound)
+		{
+		if (firstColon != KErrNotFound && firstColon < firstSlash)
+			{
+		    // port number is text between colon and slash 
+		    return str.SubStrEx(firstColon, firstSlash);
+			}
+		}
+	else 
+		{
+		if (firstColon != KErrNotFound)
+			{
+		    // port number is all text after colon 
+		    return str.Right(firstColon+1);
+			}
+		}
+		
+	return TPtrC();
+	}
+
+
+
+
+/******************************************************************************
+ * class TStr
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// TStr::TStr
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TStr::TStr(const TDesC& aStr) : iStr(aStr)
+    {
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Mid
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::Mid(TInt aPos)
+    {
+	TInt len = iStr.Length();
+	if ( (aPos < 0) || (aPos >= len) )
+	    {
+		return TPtrC();  // return empty descriptor
+	    }
+
+	return iStr.Mid(aPos);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Mid
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::Mid(TInt aPos, TInt aLen)
+    {
+	TInt len = iStr.Length();
+	if ( (aPos < 0) || (aPos >= len) )
+	    {
+		return TPtrC();
+	    }
+	if ( (aLen <= 0) || (aPos + aLen > len) )
+	    {
+		return TPtrC();
+	    }
+
+	return iStr.Mid(aPos, aLen);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Right
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::Right(TInt aPos)
+    {
+	return Mid(aPos);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Left
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::Left(TInt aPos)
+    {
+	TInt len = iStr.Length();
+
+	if ( (aPos < 0) || (len == 0) )
+	    {
+		return TPtrC();
+	    }
+
+	TInt pos = len;
+	if ( (aPos + 1) < len )
+	    {
+		pos = aPos + 1;
+	    }
+
+	return iStr.Left(pos);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::SubStr
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::SubStr(TInt aStartPos, TInt aEndPos)
+    {
+	return Mid(aStartPos, aEndPos - aStartPos + 1);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::SubStrEx
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::SubStrEx(TInt aStartPos, TInt aEndPos)
+    {
+	return Mid(aStartPos + 1, aEndPos - aStartPos - 1);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::LastPos
+//
+// -------------------------------------------------------------------------------
+//
+TInt TStr::LastPos()
+    {
+	return iStr.Length() - 1;
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Len
+//
+// -------------------------------------------------------------------------------
+//
+TInt TStr::Len()
+    {
+    return iStr.Length();
+    }
+
+// -------------------------------------------------------------------------------
+// TStr::Compare
+//
+// -------------------------------------------------------------------------------
+//
+TBool TStr::Compare(TInt aPos, TChar aChar)
+    {
+	TInt len = iStr.Length();
+	if ( (aPos < 0) || (aPos >= len) )
+	    {
+		return EFalse;
+	    }
+	TChar ch = iStr[aPos];
+	if (ch == aChar)
+	    {
+		return ETrue;
+	    }
+	return EFalse;
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Find
+//
+// -------------------------------------------------------------------------------
+//
+TInt TStr::Find(TInt aPos, TChar aChar)
+    {
+	TInt len = iStr.Length();
+	if ( (aPos < 0) || (aPos >= len) )
+	    {
+		return KErrNotFound;
+	    }
+	    
+	TPtrC ptr(iStr.Mid(aPos)); // move to possition aPos
+	return ptr.Locate(aChar);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::Trim
+//
+// -------------------------------------------------------------------------------
+//
+TPtrC TStr::Trim()
+    {
+	TInt first = FirstNonSpace();
+	TInt last = LastNonSpace();
+
+	return Mid(first, last - first + 1);
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::FirstNonSpace
+//
+// -------------------------------------------------------------------------------
+//
+TInt TStr::FirstNonSpace()
+    {
+	TInt len = Len();
+	for (TInt i = 0; i < len; i++)
+	    {
+		TChar c = iStr[i];
+        if (!c.IsSpace())
+		    {
+		    return i;
+		    }
+	    }
+	return KErrNotFound;
+    }
+
+
+// -------------------------------------------------------------------------------
+// TStr::LastNonSpace
+//
+// -------------------------------------------------------------------------------
+//
+TInt TStr::LastNonSpace()
+    {
+	TInt last = LastPos();
+	for (TInt i = last; i >= 0; i--)
+	    {
+		TChar c = iStr[i];
+        if (!c.IsSpace())
+		    {
+		    return i;
+		    }
+	    }
+	return KErrNotFound;
+    }
+
+
+
+/******************************************************************************
+ * class TFlag
+ ******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// TFlag::TFlag
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TFlag::TFlag(TUint32& aFlag) : iFlag(aFlag)
+    {
+    }
+
+// -------------------------------------------------------------------------------
+// TFlag::SetOn
+//
+// -------------------------------------------------------------------------------
+//
+void TFlag::SetOn(const TUint32 aValue)
+    {
+    iFlag |= aValue;
+    }
+
+// -------------------------------------------------------------------------------
+// TFlag::SetOff
+//
+// -------------------------------------------------------------------------------
+//
+void TFlag::SetOff(const TUint32 aValue)
+    {
+    iFlag &= ~aValue;
+    }
+
+// -------------------------------------------------------------------------------
+// TFlag::IsOn
+//
+// -------------------------------------------------------------------------------
+//
+TBool TFlag::IsOn(const TUint32 aValue) const
+    {
+    return iFlag & aValue;
+    }
+
+
+
+/*******************************************************************************
+ * class CAspIdleWait
+ *******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspIdleWait::WaitL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspIdleWait::WaitL()
+	{
+    CAspIdleWait* waiter = CAspIdleWait::NewL();
+    CleanupStack::PushL(waiter);
+    
+    CIdle* idle = CIdle::NewL(CActive::EPriorityIdle);
+	CleanupStack::PushL(idle);
+	
+	idle->Start(TCallBack(IdleCallback, waiter));
+	if (!waiter->iWait.IsStarted())
+		{
+		waiter->iWait.Start();
+		}
+
+    CleanupStack::PopAndDestroy(idle);
+    CleanupStack::PopAndDestroy(waiter);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspIdleWait::NewLC
+//
+// -----------------------------------------------------------------------------
+//
+CAspIdleWait* CAspIdleWait::NewL()
+    {
+    CAspIdleWait* self = new (ELeave) CAspIdleWait();
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspIdleWait::CAspIdleWait
+// 
+// -----------------------------------------------------------------------------
+//
+CAspIdleWait::CAspIdleWait() 
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspIdleWait::~CAspIdleWait()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspIdleWait::IdleCallback
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAspIdleWait::IdleCallback(TAny* aThisPtr)
+    {
+    static_cast<CAspIdleWait*>(aThisPtr)->iWait.AsyncStop();
+    return KErrNone;
+    }
+
+
+
+/******************************************************************************
+ * class CAspActiveCaller
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+CAspActiveCaller* CAspActiveCaller::NewL(MAspActiveCallerObserver* aObserver)
+    {
+    FLOG( _L("CAspActiveCaller::NewL START") );
+    
+    CAspActiveCaller* self = new (ELeave) CAspActiveCaller(aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+    FLOG( _L("CAspActiveCaller::NewL END") );
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+// 
+// -----------------------------------------------------------------------------
+//
+CAspActiveCaller::~CAspActiveCaller()
+    {
+    FLOG( _L("CAspActiveCaller::~CAspActiveCaller START") );
+    
+	Cancel();
+	iTimer.Close();
+	
+    FLOG( _L("CAspActiveCaller::~CAspActiveCaller END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::CAspActiveCaller
+// 
+// -----------------------------------------------------------------------------
+//
+CAspActiveCaller::CAspActiveCaller(MAspActiveCallerObserver* aObserver) : CActive(CActive::EPriorityStandard)
+    {
+	iObserver = aObserver;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::ConstructL
+// 
+// -----------------------------------------------------------------------------
+//
+void CAspActiveCaller::ConstructL()
+    {
+	User::LeaveIfError(iTimer.CreateLocal());
+	CActiveScheduler::Add(this);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::DoCancel
+//
+// -----------------------------------------------------------------------------
+//
+void CAspActiveCaller::DoCancel()
+    {
+    FLOG( _L("CAspActiveCaller::DoCancel START") );
+    
+	iTimer.Cancel();
+	
+    FLOG( _L( "CAspActiveCaller::DoCancel END" ) );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::RunL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspActiveCaller::RunL()
+    {
+    FLOG( _L("CAspActiveCaller::RunL START") );
+
+	TRAP_IGNORE(iObserver->HandleActiveCallL(iCallId));
+
+    FLOG( _L("CAspActiveCaller::RunL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::Request
+//
+// This function calls this class RunL.
+// -----------------------------------------------------------------------------
+//
+void CAspActiveCaller::Request()
+    {
+    FLOG( _L("CAspActiveCaller::Request START") );
+    
+	Cancel();
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, KErrNone);
+    
+    FLOG( _L("CAspActiveCaller::Request END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspActiveCaller::Start
+//
+// -----------------------------------------------------------------------------
+//
+void CAspActiveCaller::Start(TInt aCallId, TInt aMilliseconds)
+    {
+    FLOG( _L("CAspActiveCaller::Start START") );
+    
+	if (IsActive())
+		{
+		return;
+		}
+	
+	iCallId = aCallId;
+
+	if (aMilliseconds <= 0)
+		{
+		Request();  // no delay - complete right away
+		}
+	else
+		{
+	    iTimer.After(iStatus, aMilliseconds*1000);
+	    SetActive();
+		}
+    
+    FLOG( _L("CAspActiveCaller::Start END") );
+    }
+
+
+
+
+/******************************************************************************
+ * class CAspBearerHandler
+ ******************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::NewLC
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAspBearerHandler* CAspBearerHandler::NewL(const TAspParam& aParam)
+    {
+    CAspBearerHandler* self = new (ELeave) CAspBearerHandler(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspBearerHandler::~CAspBearerHandler()
+	{
+	iList.Close();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::CAspBearerHandler
+// -----------------------------------------------------------------------------
+//
+CAspBearerHandler::CAspBearerHandler(const TAspParam& aParam)
+	{
+	__ASSERT_ALWAYS(aParam.iSyncSession, TUtil::Panic(KErrGeneral));
+
+	iSyncSession = aParam.iSyncSession;	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CAspBearerHandler::ConstructL(void)
+    {
+	CreateSupportedBearerListL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::IsSupported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CAspBearerHandler::IsSupported(TInt aBearer)
+	{
+	TInt count = iList.Count();
+
+    for (TInt i=0; i<count; i++)
+		{
+		TAspBearerItem& item = iList[i];
+		if (item.iBearerType == aBearer)
+			{
+			return ETrue;
+			}
+		}
+	
+	return EFalse; // unknown bearer
+}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::BearerForListIndex
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::BearerForListIndex(TInt aIndex)
+	{
+	TInt count = iList.Count();
+	if (aIndex < 0 || aIndex >= count)
+	    {
+		TUtil::Panic(KErrArgument);
+	    }
+
+	TAspBearerItem& item = iList[aIndex];
+	return item.iBearerType;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::ListIndexForBearer
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::ListIndexForBearer(TInt aBearer)
+	{
+	TInt count = iList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspBearerItem& item = iList[i];
+		if (item.iBearerType == aBearer)
+			{
+			return i;
+			}
+		}
+
+	return KErrNotFound;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::CreateSupportedBearerListL
+//
+// -----------------------------------------------------------------------------
+//
+void CAspBearerHandler::CreateSupportedBearerListL()
+	{
+	RSyncMLTransport transport;
+	
+	RArray<TSmlTransportId> arr(8);
+	CleanupClosePushL(arr);
+	
+	//
+	// ListTransportsL returns transports that can be used in current phone.
+	// RSyncMLSession uses FeatureManager to construct this list.
+	//
+	iSyncSession->ListTransportsL(arr);
+	TInt count = arr.Count();
+	
+	for (TInt i=0; i<count; i++)
+		{
+		TInt id = arr[i];
+		transport.OpenL(*iSyncSession, id);
+		CleanupClosePushL(transport);
+		
+		TAspBearerItem item;
+		TInt smlBearerId = transport.Identifier();
+		item.iBearerType = AspBearerId(smlBearerId);  // convert bearer type
+		TUtil::StrCopy(item.iBearerName, transport.DisplayName());
+		
+
+#ifndef __SYNCML_DS_OVER_HTTP   // KFeatureIdDsOverHttp
+        
+   		if (item.iBearerType == EAspBearerInternet)
+			{
+			CleanupStack::PopAndDestroy(&transport);
+			continue;
+			}
+#endif
+
+   		if (item.iBearerType != EAspBearerInternet && 
+   		    item.iBearerType != EAspBearerBlueTooth)
+			{
+			CleanupStack::PopAndDestroy(&transport);
+			continue; // only internet and bluetooth are supported
+			}
+
+		if (item.iBearerType != KErrNotFound)
+			{
+			User::LeaveIfError(iList.Append(item));
+			}
+		
+		CleanupStack::PopAndDestroy(&transport);
+		}
+		
+	CleanupStack::PopAndDestroy(&arr);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::AspBearerId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::AspBearerId(const TInt aId)
+	{
+	if (aId == KUidNSmlMediumTypeInternet.iUid)
+		{
+		return EAspBearerInternet;
+		}
+	else if (aId == KUidNSmlMediumTypeBluetooth.iUid)
+		{
+		return EAspBearerBlueTooth;
+		}
+	else if (aId == KUidNSmlMediumTypeUSB.iUid)
+		{
+		return EAspBearerUsb;
+		}
+	else if (aId == KUidNSmlMediumTypeIrDA.iUid)
+		{
+		return EAspBearerIrda;
+		}
+	//else if (aId == KUidNSmlMediumTypeWSP.iUid)
+	//	{
+	//	return EAspBearerWsp;
+	//	}
+	//else if (aId == KUidNSmlMediumTypeNSmlUSB.iUid)
+	//	{
+	//	return EAspBearerSmlUsb;
+	//	}
+
+	else
+		{
+		return KErrNotFound;
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::SmlBearerId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::SmlBearerId(const TInt aId)
+	{
+	if (aId == EAspBearerInternet)
+		{
+		return KUidNSmlMediumTypeInternet.iUid;
+		}
+	else if (aId == EAspBearerBlueTooth)
+		{
+		return KUidNSmlMediumTypeBluetooth.iUid;
+    	}
+	else if (aId == EAspBearerUsb)
+		{
+		return KUidNSmlMediumTypeUSB.iUid;		
+		}
+	else if (aId == EAspBearerIrda)
+		{
+		return KUidNSmlMediumTypeIrDA.iUid;		
+		}
+	//else if (aId == EAspBearerWsp)
+	//	{
+	//	return KUidNSmlMediumTypeWSP.iUid;		
+	//	}
+	//else if (aId == EAspBearerSmlUsb)
+	//	{
+	//	return KUidNSmlMediumTypeNSmlUSB.iUid;		
+	//	}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::DefaultBearer
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::DefaultBearer()
+	{
+	if (IsSupported(EAspBearerInternet))
+		{
+		return EAspBearerInternet;
+		}
+	if (IsSupported(EAspBearerBlueTooth))
+		{
+		return EAspBearerBlueTooth;
+		}
+    if (IsSupported(EAspBearerUsb))
+		{
+		return EAspBearerUsb;
+		}
+	if (IsSupported(EAspBearerIrda))
+		{
+		return EAspBearerIrda;
+		}
+
+	return KErrNotFound; // something is wrong
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::GetBearerName
+//
+// -----------------------------------------------------------------------------
+//
+void CAspBearerHandler::GetBearerName(TDes& aText, TInt aBearerType)
+	{
+    aText = KNullDesC;
+	TInt count = iList.Count();
+
+	for (TInt i=0; i<count; i++)
+		{
+		TAspBearerItem& item = iList[i];
+		if (item.iBearerType == aBearerType)
+			{
+			TUtil::StrCopy(aText, item.iBearerName);
+			break;
+			}
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::BuildBearerListLC
+//
+// -----------------------------------------------------------------------------
+//
+CDesCArray* CAspBearerHandler::BuildBearerListLC()
+	{	
+	CDesCArray* arr = new (ELeave) CDesCArrayFlat(1);
+	CleanupStack::PushL(arr);
+
+	TInt count = iList.Count();
+	for (TInt i=0; i<count; i++)
+		{
+		TAspBearerItem& item = iList[i];
+		arr->AppendL(item.iBearerName);
+		}
+
+	return arr;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspBearerHandler::SupportedBearerCount
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspBearerHandler::SupportedBearerCount()
+	{
+	return iList.Count();
+	}
+
+
+
+
+
+/******************************************************************************
+ * class CAspAccessPointHandler
+ ******************************************************************************/
+
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::NewLC
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAspAccessPointHandler* CAspAccessPointHandler::NewL(const TAspParam& aParam)
+    {
+    CAspAccessPointHandler* self = new(ELeave) CAspAccessPointHandler(aParam);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAspAccessPointHandler::~CAspAccessPointHandler()
+	{
+	delete iCommDb;
+	delete iApUtil;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::CAspAccessPointHandler
+//
+// -----------------------------------------------------------------------------
+//
+CAspAccessPointHandler::CAspAccessPointHandler(const TAspParam& /*aParam*/)
+	{
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CAspAccessPointHandler::ConstructL(void)
+    {
+	iCommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
+	
+	iApUtil = CApUtils::NewLC(*iCommDb);
+	CleanupStack::Pop(iApUtil);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::ShowApSelectDialogL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspAccessPointHandler::ShowApSelectDialogL(TAspAccessPointItem& aItem)
+	{
+	aItem.iUid = KErrNotFound;
+	aItem.iName = KNullDesC;
+
+	TUint32 selectedAp = 0;
+	TUint32 currentAp = 0;
+	if (aItem.iUid2 != KAskAlways && aItem.iUid2 != KDefaultConnection)
+		{
+		//currentAp = aItem.iUid2;
+		
+		// convert internet ap to Wap ap (CApSettingsHandler requires this)
+    	TRAP_IGNORE(currentAp = iApUtil->WapIdFromIapIdL(aItem.iUid2));
+		}
+	
+	
+	CApSettingsHandler* handler = NULL;
+	handler = CApSettingsHandler::NewLC( ETrue,
+	                                     EApSettingsSelListIsPopUp,
+	                                     EApSettingsSelMenuSelectNormal,
+	                                     KEApIspTypeAll,
+	                                     BearerFlags(),
+	    	                             KEApSortNameAscending);
+
+	TInt ret = handler->RunSettingsL(currentAp, selectedAp);
+	CleanupStack::PopAndDestroy(handler);
+	
+	if (ret & KApUiEventSelected)
+		{
+		TAspAccessPointItem item;
+		item.iUid = selectedAp;
+
+	    GetApInfo(item);
+	    
+	    // convert Wap ap to internet ap
+	    aItem.iUid = iApUtil->IapIdFromWapIdL(selectedAp);
+	    
+	    //aItem.iUid = selectedAp;
+	    
+	    aItem.iName = item.iName;
+	    
+		return EAspDialogSelect;
+		}
+    else if (ret & KApUiEventExitRequested)
+    	{
+    	return EAspDialogExit;
+    	}
+    else
+    	{
+    	return EAspDialogCancel;
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::GetApInfoL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspAccessPointHandler::GetApInfoL(TAspAccessPointItem& aItem)
+	{
+	if (aItem.iUid == KAskAlways || aItem.iUid == KErrNotFound || aItem.iUid == KDefaultConnection)
+		{
+		return KErrNotFound;
+		}
+
+	CApSelect* selector = CApSelect::NewLC(*iCommDb,
+	                             KEApIspTypeAll,
+		                         BearerFlags(),
+		                         KEApSortUidAscending);
+	
+	TInt ret = KErrNone;
+	TBool found = EFalse;
+	
+	// find access point with id aId
+	if (selector->MoveToFirst())
+		{
+		if (aItem.iUid == (TInt)selector->Uid())
+			{
+			found = ETrue;		
+			}
+		while (!found && selector->MoveNext())
+			{
+			if (aItem.iUid == (TInt)selector->Uid())
+				{
+				found = ETrue;
+				}
+			}
+		}
+
+	if (found) 
+		{
+		TUtil::StrCopy(aItem.iName, selector->Name());
+		}
+	else
+		{
+		aItem.iName = KNullDesC;
+		ret = KErrNotFound;
+		}
+		
+    CleanupStack::PopAndDestroy(selector);
+	return ret;
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::GetApInfo
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspAccessPointHandler::GetApInfo(TAspAccessPointItem& aItem)
+	{
+	aItem.iName = KNullDesC;
+	
+	TInt ret = KErrNone;
+	TRAPD(err, ret = GetApInfoL(aItem));
+	
+	if (err != KErrNone)
+		{
+		return KErrNotFound;
+		}
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::GetInternetApInfo
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspAccessPointHandler::GetInternetApInfo(TAspAccessPointItem& aItem)
+	{
+	if (aItem.iUid == KAskAlways || aItem.iUid == KErrNotFound || aItem.iUid == KDefaultConnection)
+		{
+		return KErrNotFound;
+		}
+
+	TAspAccessPointItem item;
+	
+	// convert internet ap to Wap ap
+	TRAPD(err, item.iUid = iApUtil->WapIdFromIapIdL(aItem.iUid));
+	if (err != KErrNone)
+		{
+		return KErrNotFound;
+		}
+	
+	TInt ret = GetApInfo(item);
+	
+	TUtil::StrCopy(aItem.iName, item.iName);
+	return ret;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CAspAccessPointHandler::BearerFlags
+//
+// -----------------------------------------------------------------------------
+//
+TInt CAspAccessPointHandler::BearerFlags()
+	{
+	TInt flags;
+	if (FeatureManager::FeatureSupported(KFeatureIdAppCsdSupport))
+		{
+		//flags = EApBearerTypeGPRS | EApBearerTypeCDMA | EApBearerTypeWLAN | EApBearerTypeHSCSD | EApBearerTypeCSD;
+		flags = EApBearerTypeAllBearers;
+		}
+	else
+		{
+		flags = EApBearerTypeGPRS | EApBearerTypeCDMA | EApBearerTypeWLAN;
+		}
+		
+	return flags;
+	}
+
+
+
+
+/******************************************************************************
+ * class TAspSyncError
+ ******************************************************************************/
+
+
+
+
+// -----------------------------------------------------------------------------
+// TAspSyncError::GetSmlErrorText
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* TAspSyncError::GetSmlErrorText(TInt aErrorCode, TInt aTransport)
+	{
+	HBufC* hBuf = NULL;
+	
+	TRAPD(err, hBuf = GetSmlErrorTextL(aErrorCode, aTransport));
+	
+	if (err == KErrNone)
+		{
+		return hBuf;
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+
+// -----------------------------------------------------------------------------
+// TAspSyncError::GetSmlErrorTextL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* TAspSyncError::GetSmlErrorTextL(TInt aErrorCode, TInt /*aTransport*/)
+	{
+    TInt id = R_ASP_LOG_ERR_SYSTEMERROR;  // "System Error"
+   
+	switch (aErrorCode)
+		{
+		case SyncMLError::KErrTransportAuthenticationFailure:
+			{
+			id = R_ASP_LOG_ERR_HTTPAUTH;  // "Http authentication failed"
+		    break;
+			}
+	
+		case SyncMLError::KErrAuthenticationFailure:
+			{
+			id = R_ASP_LOG_ERR_CLIENTAUTH;  // "Invalid user name or password"
+		    break;
+			}
+
+		case KErrServerBusy:
+		    id = R_ASP_LOG_ERR_SERVERBUSY;  // "Synchronisation server was busy"
+		    break;
+		    
+		case SyncMLError::KErrServerDatabaseNotFound:
+		    id = R_ASP_LOG_ERR_REMOTEDATABASE;  // "Invalid remote database"
+		    break;
+
+		case SyncMLError::KErrClientDatabaseNotFound:
+		    id = R_ASP_LOG_ERR_LOCALDATABASE;  // "Unable to open database"
+		    break;
+
+		case SyncMLError::KErrConnectionError:
+		    id = R_ASP_LOG_ERR_SERVERNOTRESPONDING; // "Server is not responding"
+		    break;
+		    
+		case SyncMLError::KErrTransportSvrNoUri:
+		    id = R_ASP_LOG_ERR_URIINVALID; // "Invalid host address"
+		    break;
+		
+		case SyncMLError::KErrPhoneOnOfflineMode:
+		    id = R_ASP_LOG_ERR_OFFLINE; // "Operation not possible in Off-line mode"
+		    break;
+		    
+		case SyncMLError::KErrTransportRequest:
+		case SyncMLError::KErrTransportHeader:
+		case SyncMLError::KErrTransportSvrError:
+		case SyncMLError::KErrTransportDisconnected:
+		case SyncMLError::KErrCannotCommunicateWithServer:
+		    id = R_ASP_LOG_ERR_COMM;  // "Error in communication"
+		    break;
+		    
+		case SyncMLError::KErrVerDTDMissing:
+		case SyncMLError::KErrProtoMissing:
+		case SyncMLError::KErrVersionDTDNotSupported:
+		case SyncMLError::KErrProtoNotSupported:
+		    id = R_ASP_LOG_ERR_VERSIONNOTSUPPORTED;  // "Unsupported SyncML software version in server"
+		    break;
+       
+		case SyncMLError::KErrSessionIdNotValid:
+		case SyncMLError::KErrMappingInfoMissing:
+		case SyncMLError::KErrMappingInfoNotAcked:
+		case SyncMLError::KErrStatusCommandForCommandNotSent:
+		case SyncMLError::KErrStatusCommandNotTheSame:
+		case SyncMLError::KErrMissingStatusCommands:
+		case SyncMLError::KErrFailedToAddRecord:
+		case SyncMLError::KErrFailedToReplaceRecord:
+		case SyncMLError::KErrFailedToDeleteRecord:
+		case SyncMLError::KErrXmlParsingError:
+		case SyncMLError::KErrReferenceToolkitError:
+		case SyncMLError::KErrObjectTooLargeToSendToServer:
+		case SyncMLError::KErrFailedToGetRecord:
+		case SyncMLError::KErrUserInteractionFailed:
+		case SyncMLError::KErrStatusSizeMismatch:
+		case SyncMLError::KErrFailedToCloseDatabase:
+		case SyncMLError::KErrDatabaseAdapterIndexError:
+	   	    id = R_ASP_LOG_ERR_SERVERERROR;  // "Error in sync server"
+		    break;
+	        
+        default:
+            id = R_ASP_LOG_ERR_SYSTEMERROR;  // "System Error"
+		    break;
+		}
+		
+	HBufC* hBuf = CAspResHandler::ReadLC(id);
+	
+#ifdef _DEBUG
+	TBuf<KBufSize> buf2(hBuf->Des());
+	TBuf<KBufSize> buf1;
+	CleanupStack::PopAndDestroy(hBuf);
+		
+	hBuf = HBufC::NewLC(256);
+	TPtr ptr = hBuf->Des();
+		
+	GetSyncMLErrorText(buf1, aErrorCode);
+	ptr.Format(_L("%S (%S)"), &buf2, &buf1);
+#endif		
+		
+	CleanupStack::Pop(hBuf);
+	return hBuf;
+	}
+	
+
+// -----------------------------------------------------------------------------
+// TAspSyncError::GetSmlErrorValue
+// 
+// -----------------------------------------------------------------------------
+TInt TAspSyncError::GetSmlErrorValue(TInt aErrorCode)
+	{
+    TInt id = R_ASP_LOG_ERR_SYSTEMERROR;  // "System Error"
+   
+	switch (aErrorCode)
+		{
+		case SyncMLError::KErrTransportAuthenticationFailure:
+			{
+			id = R_ASP_LOG_ERR_HTTPAUTH;  // "Http authentication failed"
+		    break;
+			}
+	
+		case SyncMLError::KErrAuthenticationFailure:
+			{
+			id = R_ASP_LOG_ERR_CLIENTAUTH;  // "Invalid user name or password"
+		    break;
+			}
+
+		case KErrServerBusy:
+		    id = R_ASP_LOG_ERR_SERVERBUSY;  // "Synchronisation server was busy"
+		    break;
+		    
+		case SyncMLError::KErrServerDatabaseNotFound:
+		    id = R_ASP_LOG_ERR_REMOTEDATABASE;  // "Invalid remote database"
+		    break;
+
+		case SyncMLError::KErrClientDatabaseNotFound:
+		    id = R_ASP_LOG_ERR_LOCALDATABASE;  // "Unable to open database"
+		    break;
+
+		case SyncMLError::KErrConnectionError:
+		    id = R_ASP_LOG_ERR_SERVERNOTRESPONDING; // "Server is not responding"
+		    break;
+		    
+		case SyncMLError::KErrTransportSvrNoUri:
+		    id = R_ASP_LOG_ERR_URIINVALID; // "Invalid host address"
+		    break;
+		
+		case SyncMLError::KErrPhoneOnOfflineMode:
+		    id = R_ASP_LOG_ERR_OFFLINE; // "Operation not possible in Off-line mode"
+		    break;
+		    
+		case SyncMLError::KErrTransportRequest:
+		case SyncMLError::KErrTransportHeader:
+		case SyncMLError::KErrTransportSvrError:
+		case SyncMLError::KErrTransportDisconnected:
+		case SyncMLError::KErrCannotCommunicateWithServer:
+		    id = R_ASP_LOG_ERR_COMM;  // "Error in communication"
+		    break;
+		    
+		case SyncMLError::KErrVerDTDMissing:
+		case SyncMLError::KErrProtoMissing:
+		case SyncMLError::KErrVersionDTDNotSupported:
+		case SyncMLError::KErrProtoNotSupported:
+		    id = R_ASP_LOG_ERR_VERSIONNOTSUPPORTED;  // "Unsupported SyncML software version in server"
+		    break;
+       
+		case SyncMLError::KErrSessionIdNotValid:
+		case SyncMLError::KErrMappingInfoMissing:
+		case SyncMLError::KErrMappingInfoNotAcked:
+		case SyncMLError::KErrStatusCommandForCommandNotSent:
+		case SyncMLError::KErrStatusCommandNotTheSame:
+		case SyncMLError::KErrMissingStatusCommands:
+		case SyncMLError::KErrFailedToAddRecord:
+		case SyncMLError::KErrFailedToReplaceRecord:
+		case SyncMLError::KErrFailedToDeleteRecord:
+		case SyncMLError::KErrXmlParsingError:
+		case SyncMLError::KErrReferenceToolkitError:
+		case SyncMLError::KErrObjectTooLargeToSendToServer:
+		case SyncMLError::KErrFailedToGetRecord:
+		case SyncMLError::KErrUserInteractionFailed:
+		case SyncMLError::KErrStatusSizeMismatch:
+		case SyncMLError::KErrFailedToCloseDatabase:
+		case SyncMLError::KErrDatabaseAdapterIndexError:
+	   	    id = R_ASP_LOG_ERR_SERVERERROR;  // "Error in sync server"
+		    break;
+	        
+        default:
+            id = R_ASP_LOG_ERR_SYSTEMERROR;  // "System Error"
+		    break;
+		}
+		
+		return id ;
+	}
+	
+
+#ifdef _DEBUG
+
+// -----------------------------------------------------------------------------
+// TAspSyncError::GetSyncMLErrorText
+//
+// -----------------------------------------------------------------------------
+//
+void TAspSyncError::GetSyncMLErrorText(TDes& aText, TInt aError)
+	{
+    aText = KNullDesC();
+  
+   
+	switch (aError)
+		{
+		case SyncMLError::KErrTransportRequest:
+		    aText = _L("KErrTransportRequest");
+		    break;
+		case SyncMLError::KErrTransportHeader:
+		    aText = _L("KErrTransportHeader");
+		    break;
+		case SyncMLError::KErrTransportSvrNoUri:
+		    aText = _L("KErrTransportSvrNoUri");
+		    break;
+		case SyncMLError::KErrTransportSvrError:
+		    aText = _L("KErrTransportSvrError");
+		    break;
+		case SyncMLError::KErrTransportAuthenticationFailure:
+		    aText = _L("KErrTransportAuthenticationFailure");
+		    break;
+		case SyncMLError::KErrTransportDisconnected:
+		    aText = _L("KErrTransportDisconnected");
+		    break;
+		case SyncMLError::KErrConnectionError:
+		    aText = _L("KErrConnectionError");
+		    break;
+		case SyncMLError::KErrCannotCommunicateWithServer:
+		    aText = _L("KErrCannotCommunicateWithServer");
+		    break;
+		case SyncMLError::KErrDatabaseAdapterIndexError:
+		    aText = _L("KErrDatabaseAdapterIndexError");
+		    break;
+		case SyncMLError::KErrParseCallbackError:
+		    aText = _L("KErrParseCallbackError");
+		    break;
+		case SyncMLError::KErrCommandInvalid:
+		    aText = _L("KErrCommandInvalid");
+		    break;
+		case SyncMLError::KErrSessionIdNotValid:
+		    aText = _L("KErrSessionIdNotValid");
+		    break;
+		case SyncMLError::KErrVerDTDMissing:
+		    aText = _L("KErrVerDTDMissing");
+		    break;
+		case SyncMLError::KErrProtoMissing:
+		    aText = _L("KErrProtoMissing");
+		    break;
+		case SyncMLError::KErrSyncHdrMissing:
+		    aText = _L("KErrSyncHdrMissing");
+		    break;
+		case SyncMLError::KErrTargetLocMissing:
+		    aText = _L("KErrTargetLocMissing");
+		    break;
+		case SyncMLError::KErrSourceLocMissing:
+		    aText = _L("KErrSourceLocMissing");
+		    break;
+		case SyncMLError::KErrTargetLocNameMissing:
+		    aText = _L("KErrTargetLocNameMissing");
+		    break;
+		case SyncMLError::KErrSourceLocNameMissing:
+		    aText = _L("KErrSourceLocNameMissing");
+		    break;
+		case SyncMLError::KErrMappingInfoMissing:
+		    aText = _L("KErrMappingInfoMissing");
+		    break;
+		case SyncMLError::KErrMappingInfoNotAcked:
+		    aText = _L("KErrMappingInfoNotAcked");
+		    break;
+		case SyncMLError::KErrVersionDTDNotSupported:
+		    aText = _L("KErrVersionDTDNotSupported");
+		    break;
+		case SyncMLError::KErrProtoNotSupported:
+		    aText = _L("KErrProtoNotSupported");
+		    break;
+		case SyncMLError::KErrStatusCommandForCommandNotSent:
+		    aText = _L("KErrStatusCommandForCommandNotSent");
+		    break;
+		case SyncMLError::KErrStatusCommandNotTheSame:
+		    aText = _L("KErrStatusCommandNotTheSame");
+		    break;
+		case SyncMLError::KErrMissingStatusCommands:
+		    aText = _L("KErrMissingStatusCommands");
+		    break;
+		case SyncMLError::KErrFailedToAddRecord:
+		    aText = _L("KErrFailedToAddRecord");
+		    break;
+		case SyncMLError::KErrFailedToReplaceRecord:
+		    aText = _L("KErrFailedToReplaceRecord");
+		    break;
+		case SyncMLError::KErrFailedToDeleteRecord:
+		    aText = _L("KErrFailedToDeleteRecord");
+		    break;
+		case SyncMLError::KErrXmlParsingError:
+		    aText = _L("KErrXmlParsingError");
+		    break;
+		case SyncMLError::KErrReferenceToolkitError:
+		    aText = _L("KErrReferenceToolkitError");
+		    break;
+		case SyncMLError::KErrClientDatabaseNotFound:
+		    aText = _L("KErrClientDatabaseNotFound");
+		    break;
+		case SyncMLError::KErrServerDatabaseNotFound:
+		    aText = _L("KErrServerDatabaseNotFound");
+		    break;
+		case SyncMLError::KErrDevInfFileNotFound:
+		    aText = _L("KErrDevInfFileNotFound");
+		    break;
+		case SyncMLError::KErrObjectTooLargeToSendToServer:
+		    aText = _L("KErrObjectTooLargeToSendToServer");
+		    break;
+		case SyncMLError::KErrSlowSync:
+		    aText = _L("KErrSlowSync");
+		    break;
+		case SyncMLError::KErrFailedToGetRecord:
+		    aText = _L("KErrFailedToGetRecord");
+		    break;
+		case SyncMLError::KErrUserInteractionFailed:
+		    aText = _L("KErrUserInteractionFailed");
+		    break;
+		case SyncMLError::KErrStatusSizeMismatch:
+		    aText = _L("KErrStatusSizeMismatch");
+		    break;
+		case SyncMLError::KErrFailedToCloseDatabase:
+		    aText = _L("KErrFailedToCloseDatabase");
+		    break;
+	
+    	case SyncMLError::KErrPhoneOnOfflineMode:
+		    aText = _L("KErrPhoneOnOfflineMode");
+		    break;
+		
+	    case SyncMLError::KErrAuthenticationFailure:
+		    aText = _L("KErrAuthenticationFailure");
+		    break;
+		
+		case SyncMLError::KErrGeneral:
+		    aText = _L("KErrGeneral");
+		    break;
+		
+		case SyncMLError::KErrMessageTooShort:
+		    aText = _L("KErrMessageTooShort");
+		    break;
+		case SyncMLError::KErrMessageIsCorrupt:
+		    aText = _L("KErrMessageIsCorrupt");
+		    break;
+		case SyncMLError::KErrBadTransportId:
+		    aText = _L("KErrBadTransportId");
+		    break;
+		case SyncMLError::KErrNoNotificationBody:
+		    aText = _L("KErrNoNotificationBody");
+		    break;
+		case SyncMLError::KErrWrongVersion:
+		    aText = _L("KErrWrongVersion");
+		    break;
+		case SyncMLError::KErrUnsupportedMimeType:
+		    aText = _L("KErrUnsupportedMimeType");
+		    break;
+		case SyncMLError::KErrNoSuchTask:
+		    aText = _L("KErrNoSuchTask");
+		    break;
+		case SyncMLError::KErrUnknownSyncType:
+		    aText = _L("KErrUnknownSyncType");
+		    break;
+		case SyncMLError::KErrUnknownProfile:
+		    aText = _L("KErrUnknownProfile");
+		    break;
+		case SyncMLError::KErrInvalidProfile:
+		    aText = _L("KErrInvalidProfile");
+		    break;
+		case SyncMLError::KErrInvalidCredentials:
+		    aText = _L("KErrInvalidCredentials");
+		    break;
+		case SyncMLError::KErrNoCredentials:
+		    aText = _L("KErrNoCredentials");
+		    break;
+		case SyncMLError::KErrIntegrityFailureHMAC:
+		    aText = _L("KErrIntegrityFailureHMAC");
+		    break;
+		case SyncMLError::KErrMustUsageUriNotComplete:
+		    aText = _L("KErrMustUsageUriNotComplete");
+		    break;
+		case SyncMLError::KErrDMAccUriIsCorrupt:
+		    aText = _L("KErrDMAccUriIsCorrupt");
+		    break;
+		case SyncMLError::KErrDMConUriIsCorrupt:
+		    aText = _L("KErrDMConUriIsCorrupt");
+		    break;
+		case SyncMLError::KErrParmNameNotInProvDoc:
+		    aText = _L("KErrParmNameNotInProvDoc");
+		    break;
+		case SyncMLError::KErrInvalidAppIdValue:
+		    aText = _L("KErrInvalidAppIdValue");
+		    break;
+		case SyncMLError::KErrInvalidToNapIdValue:
+		    aText = _L("KErrInvalidToNapIdValue");
+		    break;
+		case SyncMLError::KErrInvalidProviderIdValue:
+		    aText = _L("KErrInvalidProviderIdValue");
+		    break;
+		case SyncMLError::KErrEmptyAauthLevelValue:
+		    aText = _L("KErrEmptyAauthLevelValue");
+		    break;
+		case SyncMLError::KErrAppSrvAAuthLevelNotFound:
+		    aText = _L("KErrAppSrvAAuthLevelNotFound");
+		    break;
+		case SyncMLError::KErrClientAAuthLevelNotFound:
+		    aText = _L("KErrClientAAuthLevelNotFound");
+		    break;
+		case SyncMLError::KErrInvalidAppAuth:
+		    aText = _L("KErrInvalidAppAuth");
+		    break;
+		case SyncMLError::KErrNoApplicationCharac:
+		    aText = _L("KErrNoApplicationCharac");
+		    break;
+		case SyncMLError::KErrNoAppAuthCharac:
+		    aText = _L("KErrNoAppAuthCharac");
+		    break;
+		case SyncMLError::KErrMissingRequiredParmInSvr:
+		    aText = _L("KErrMissingRequiredParmInSvr");
+		    break;
+		case SyncMLError::KErrMissingRequiredParmInClient:
+		    aText = _L("KErrMissingRequiredParmInClient");
+		    break;
+		case SyncMLError::KErrAppAddrCharacNotFound:
+		    aText = _L("KErrAppAddrCharacNotFound");
+		    break;
+		case SyncMLError::KErrUnsupportedVersion:
+		    aText = _L("KErrUnsupportedVersion");
+		    break;
+		case SyncMLError::KErrWrongProvPublicDocId:
+		    aText = _L("KErrWrongProvPublicDocId");
+		    break;
+		case SyncMLError::KErrProfileNotFound:
+		    aText = _L("KErrProfileNotFound");
+		    break;
+		case SyncMLError::KErrConnectionNotFound:
+		    aText = _L("KErrConnectionNotFound");
+		    break;
+		case SyncMLError::KErrTaskNotFound:
+		    aText = _L("KErrTaskNotFound");
+		    break;
+		case SyncMLError::KErrTransportNotFound:
+		    aText = _L("KErrTransportNotFound");
+		    break;
+		case SyncMLError::KErrDataProviderNotFound:
+		    aText = _L("KErrDataProviderNotFound");
+		    break;
+		case SyncMLError::KErrJobNotFound:
+		    aText = _L("KErrJobNotFound");
+		    break;
+		case SyncMLError::KErrObjectPendingDelete:
+		    aText = _L("KErrObjectPendingDelete");
+		    break;
+		case SyncMLError::KErrObjectInUse:
+		    aText = _L("KErrObjectInUse");
+		    break;
+		case SyncMLError::KErrProfileAccessDenied:
+		    aText = _L("KErrProfileAccessDenied");
+		    break;
+		case SyncMLError::KErrSuspended:
+		    aText = _L("KErrSuspended");
+		    break;
+		case SyncMLError::KErrDataDepotStreamNotFound:
+		    aText = _L("KErrDataDepotStreamNotFound");
+		    break;
+		
+		case SyncMLError::KErrServerIdNotMatching:
+		    aText = _L("KErrServerIdNotMatching");
+		    break;
+	        
+        default:
+            aText.Format(_L("%d"), aError);
+		    break;
+		}
+	}
+
+#endif
+
+
+
+
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/BWinscw/OmaDsAppUiPluginu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/data/102833A1.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 1028 Nokia Corporation and/or 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:  This rss file which contains the 
+				 interface implementation information.
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+{
+dll_uid = 0x102833A1;   //DSGS Plugin dll UID3 (security UID)  
+interfaces = 
+    {
+    INTERFACE_INFO
+        {
+        interface_uid               = 0x10207236;  // CGSPluginInterface UID   
+        implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid  = 0x102833A2; // DSGS Plugin implementation UID for CGSPluginInterface
+                version_no          = 1;
+                display_name        = "Data syncronization plugin";
+                default_data        = "0x10283319"; // Parent UID (DSGS is under "Connection UI")
+                opaque_data         = "10";         // Order number 
+                }
+            };
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/data/NsmlDSGSPluginResource.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS General Settings resource file
+*
+*/
+
+
+NAME DSGS
+
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <data_caging_paths_strings.hrh>
+
+#include<NSmlDSSync.loc>
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf=qtn_cp_folder_data_sync; }
+
+RESOURCE TBUF r_ds_gs_title  { buf=qtn_cp_folder_data_sync; }
+
+// END FILE dsapp.rss
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/eabi/OmaDsAppUiPluginu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI26COmaDsAppUiPluginInterface @ 2 NONAME ; #<TI>#
+	_ZTV26COmaDsAppUiPluginInterface @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/group/OmaDsAppUiPlugin.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Project specification file.
+*
+*/
+
+
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+#include <platform_paths.hrh>
+CAPABILITY 	CAP_ECOM_PLUGIN
+
+TARGET          OmaDsAppUiPlugin.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x102833A1
+VENDORID	    VID_DEFAULT
+
+#if defined(ARMCC)
+DEFFILE		../eabi/OmaDsAppUiPlugin.def
+#elif defined(WINSCW)
+DEFFILE		../BWinscw/OmaDsAppUiPlugin.def
+#endif
+
+SOURCEPATH      ../src
+// SOURCE tags needs to be here.
+SOURCE OmaDsAppUiPluginInterface.cpp
+SOURCE OmaDsAppUiPluginProxy.cpp
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 		/epoc32/include/ecom
+
+USERINCLUDE     ../inc 
+
+// for AspSyncUtilApi.h
+USERINCLUDE     ../../AspSyncUtil/inc
+
+// for nsmldssync.loc
+USERINCLUDE     ../../AspSyncUtil/src
+
+
+SOURCEPATH      ../data
+START RESOURCE  102833A1.rss					//Plugin registration data
+TARGET          OmaDsAppUiPlugin.rsc			
+END
+
+SOURCEPATH      ../data
+START RESOURCE  NsmlDSGSPluginResource.rss       
+TARGET          NsmlDSGSPluginResource.rsc
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+HEADER
+END
+
+
+LIBRARY    GSEcomPlugin.lib
+LIBRARY    GSFramework.lib 
+LIBRARY    aknskins.lib
+LIBRARY    aknicon.lib
+LIBRARY    Egul.lib
+LIBRARY    euser.lib
+LIBRARY    cone.lib
+LIBRARY    eikcore.lib
+LIBRARY    eikcoctl.lib
+LIBRARY	   avkon.lib
+LIBRARY    aspsyncutil.lib
+LIBRARY    CommonEngine.lib
+LIBRARY    bafl.lib
+
+// Required only for embedded app
+LIBRARY    apgrfx.lib
+LIBRARY    ws32.lib
+LIBRARY    apparc.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/group/OmaDsAppUiPlugin_icons_dc.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,71 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\OmaDsAppUiPlugin.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\OmaDsAppUiPlugin.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	/c8,8 qgn_prop_cp_conn_datasync.bmp \
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+//
+// Platforms
+//
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+//#ifdef RD_DSUI_CP_INTEGRATION
+
+//gnumakefile OmaDsAppUiPlugin_icons_dc.mk
+
+OmaDsAppUiPlugin.mmp
+//#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/inc/OmaDsAppUiPluginInterface.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  This class implements ECom interface for COmaDsAppUiPlugin.dll
+*
+*/
+
+
+#ifndef _NSML_DS_GS_PLUGIN_H_
+#define _NSML_DS_GS_PLUGIN_H_
+
+// System includes
+#include <gsplugininterface.h>
+#include "AspSyncUtilApi.h"
+
+#include <AknServerApp.h> 
+
+#define KUidNsmlDSGSPluginDll   0x102833A1
+#define KUidNsmlDSGSPluginImpl  0x102833A2
+
+// Use this UID in registry file as well.
+// UID belongs omadsapp.exe
+#define KDsAppUid 0x101F6DE4
+    
+class CAknNullService;
+
+/**
+* DsGS ECom Plugin
+*/
+class COmaDsAppUiPluginInterface : public CGSPluginInterface, 
+								   public MAknServerAppExitObserver
+    {    
+	public: // Constructors & destructors
+
+	    /**
+	    * Two-Phased constructor
+	    * Creates new DsUi plugin.
+	    * Uses Leave code KErrNotFound if implementation is not found.
+	    */                                                 
+	    static CGSPluginInterface* NewL();
+	    
+	    /**
+	    * From CAknView Returns this view Id.
+	    */
+		TUid Id() const;
+	    
+	    /**
+	    * returns the caption to be displayed in GS view
+	    *
+	    * @param aCaption - The caption to be displayed is to be copied here.
+	    */
+	    void GetCaptionL( TDes& aCaption ) const;
+		
+		/**
+		* returns the icon to be displayed in GS view
+		* 
+		* @param aIconType - type of icon to be displayed
+		*/
+	    CGulIcon* CreateIconL( const TUid aIconType );
+	    
+	    /**
+	    * Destructor
+	    */
+	    ~COmaDsAppUiPluginInterface();   
+
+    	/**
+        * From CGSPluginInterface.
+        * @return this plugin's provider category.
+        */
+        TInt PluginProviderCategory() const;
+
+        /**
+        * From CGSPluginInterface.
+        * @return this plugin's item type.
+        */
+        TGSListboxItemTypes ItemType();
+         
+	    /**
+        * From CGSPluginInterface.
+        * @param aSelectionType selection type.
+        */
+        void HandleSelection( const TGSSelectionTypes aSelectionType );
+	
+	protected:        
+	    
+	    /**
+	    * From CAknView Activates this view.
+	    */
+		void DoActivateL(const TVwsViewId& aPrevViewId,
+		    			 TUid aCustomMessageId, 
+		    			 const TDesC8& aCustomMessage);		
+		/**
+	    * From CAknView Deactivates this view.
+	    */
+		void DoDeactivate();		
+
+	private:
+	  	void ConstructL();
+		
+		/**
+		* Constructor
+		*/
+	    COmaDsAppUiPluginInterface();
+	
+        void LaunchDsAppL() ;
+
+	private:
+			
+		CEikonEnv* env;
+		TInt       iResId;
+		/**
+        * AVKON NULL Service.
+        * Own.
+        */
+        CAknNullService* iNullService;
+};
+
+#endif //_NSML_DS_GS_PLUGIN_H_
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/src/OmaDsAppUiPluginInterface.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Nsml DS settings Ecom plugin Impln.
+*
+*/
+
+
+//System Includes
+#include <e32std.h>
+#include <implementationproxy.h>
+#include <StringLoader.h>
+#include <bautils.h>
+#include <AknsUtils.h>
+#include <gulicon.h>
+#include <akntitle.h>
+
+// Required only for embedded app
+#include <AknNullService.h>
+#include <apgtask.h>
+
+// User includes
+#include "OmaDsAppUiPluginInterface.h"
+#include "gsprivatepluginproviderids.h"
+#include <nsmldssync.mbg>
+#include "NsmlDSGSPluginResource.rsg"
+
+
+_LIT(KNsmlDsIconFileName, "Z:\\resource\\apps\\nsmldssync.mif");
+_LIT(KNsmlDsResFileName,  "Z:\\resource\\NsmlDSGSPluginResource.rsc" );
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::NewLC
+// returns an object of COmaDsAppUiPluginInterface
+// ---------------------------------------------------------------------------------------------
+//
+CGSPluginInterface* COmaDsAppUiPluginInterface::NewL()
+    {
+	COmaDsAppUiPluginInterface* self = new(ELeave) COmaDsAppUiPluginInterface();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+	CleanupStack::Pop(self);
+	return (CGSPluginInterface*) self;
+	}
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::Id()
+// returns the view id
+// ---------------------------------------------------------------------------------------------
+//
+TUid COmaDsAppUiPluginInterface::Id() const
+	{
+	return TUid::Uid( KUidNsmlDSGSPluginDll );	
+	}
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::ConstructL
+// ---------------------------------------------------------------------------------------------
+//	
+void COmaDsAppUiPluginInterface::ConstructL()
+	{
+	BaseConstructL(); 
+	
+    env = CEikonEnv::Static();
+
+	TFileName fileName(KNsmlDsResFileName);
+	
+	BaflUtils::NearestLanguageFile(env->FsSession(), fileName);
+
+	iResId = env->AddResourceFileL(fileName);
+	}
+
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::COmaDsAppUiPluginInterface
+// ---------------------------------------------------------------------------------------------
+//    
+COmaDsAppUiPluginInterface::COmaDsAppUiPluginInterface() : iNullService( NULL )
+	{
+	// Nothing
+	}
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::~COmaDsAppUiPluginInterface
+// ---------------------------------------------------------------------------------------------
+//
+COmaDsAppUiPluginInterface::~COmaDsAppUiPluginInterface()
+	{
+	if (iResId)
+		{
+    	env->DeleteResourceFile(iResId);
+		}	
+	if ( iNullService )
+        {
+            delete iNullService;
+            iNullService = NULL;
+        }
+	}
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::GetCaptionL
+// returns the caption to be shown in GS view
+// ---------------------------------------------------------------------------------------------
+//
+void COmaDsAppUiPluginInterface::GetCaptionL( TDes& aCaption ) const
+    {
+    StringLoader::Load( aCaption, R_DS_GS_TITLE);
+    }
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::CreateIconL
+// returns the icon to be shown in GS view
+// ---------------------------------------------------------------------------------------------
+//
+CGulIcon* COmaDsAppUiPluginInterface::CreateIconL( const TUid /*aIconType*/ )
+	{
+	CFbsBitmap* bitmap = NULL;
+    CFbsBitmap* mask = NULL;                                               
+ 
+    MAknsSkinInstance* instance = AknsUtils::SkinInstance();    
+    AknsUtils::CreateIconL(instance, KAknsIIDQgnPropCpConnDatasync, bitmap, mask,
+    					KNsmlDsIconFileName,
+    					EMbmNsmldssyncQgn_prop_cp_conn_datasync,
+    					EMbmNsmldssyncQgn_prop_cp_conn_datasync_mask);
+
+    CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
+    icon->SetBitmapsOwnedExternally( EFalse );
+    bitmap = NULL;
+    mask = NULL;      
+    return icon;    
+	}
+	
+// -----------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::HandleSelection()
+// -----------------------------------------------------------------------------
+//
+void COmaDsAppUiPluginInterface::HandleSelection(
+    	const TGSSelectionTypes /*aSelectionType*/ )
+	{
+		TRAP_IGNORE(LaunchDsAppL());
+	}
+    
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::LaunchDsAppL
+// ---------------------------------------------------------------------------------------------
+//
+void COmaDsAppUiPluginInterface::LaunchDsAppL()
+	{
+	TUid KAppUid( TUid::Uid( KDsAppUid ) );
+
+	RWsSession ws;
+    User::LeaveIfError( ws.Connect() );
+    CleanupClosePushL( ws );
+    
+	TApaTaskList taskList( ws );
+    TApaTask task = taskList.FindApp( KAppUid );
+
+    if ( task.Exists() )
+   		{
+    	task.BringToForeground();
+    	}
+    else
+    	{
+        // Launch application as embedded.
+        if ( iNullService )
+        	{
+            delete iNullService;
+            iNullService = NULL;
+        	}
+        iNullService = CAknNullService::NewL( KAppUid, this );
+    	}
+    
+	CleanupStack::PopAndDestroy();
+  	}
+	
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::DoActivateL
+// ---------------------------------------------------------------------------------------------
+//
+void COmaDsAppUiPluginInterface::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
+											 TUid /*aCustomMessageId*/,
+											 const TDesC8& /*aCustomMessage*/)
+	{
+	// Nothing
+	}
+
+
+// -----------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::PluginProviderCategory
+// -----------------------------------------------------------------------------
+//
+TInt COmaDsAppUiPluginInterface::PluginProviderCategory() const
+	{
+    return KGSPluginProviderInternal;
+	}
+
+// -----------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::ItemType()
+// -----------------------------------------------------------------------------
+//
+TGSListboxItemTypes COmaDsAppUiPluginInterface::ItemType()
+	{
+    return EGSItemTypeSettingDialog;
+	}
+
+// ---------------------------------------------------------------------------------------------
+// COmaDsAppUiPluginInterface::DoDeactivate
+// ---------------------------------------------------------------------------------------------
+//	
+void COmaDsAppUiPluginInterface::DoDeactivate()
+	{
+	// Nothing
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/OmaDsAppUiPlugin/src/OmaDsAppUiPluginProxy.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Nsml DS settings Ecom plugin Impln.
+*
+*/
+
+
+#include <e32std.h>
+#include <implementationproxy.h>
+#include "OmaDsAppUiPluginInterface.h"
+
+
+
+// Constants
+const TImplementationProxy KOmaDsViewImplementationTable[] = 
+	{
+    IMPLEMENTATION_PROXY_ENTRY( KUidNsmlDSGSPluginImpl,	COmaDsAppUiPluginInterface::NewL ) // used by GS plugin
+	};
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Gate/factory function
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(  TInt& aTableCount )
+	{
+	aTableCount = sizeof( KOmaDsViewImplementationTable ) 
+                / sizeof( TImplementationProxy );
+	return KOmaDsViewImplementationTable;
+	}
+// End of File
Binary file omads/omadsappui/cenrep/keys_omadsui.xls has changed
Binary file omads/omadsappui/conf/omadsui.confml has changed
Binary file omads/omadsappui/conf/omadsui_101F9A1D.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/group/ABLD.BAT	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+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 the License "Symbian Foundation License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\s60\app\contentcontrol\omads\OmaDsAppUi\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Provides information for building omadsappui.
+*
+*/
+
+
+#include <platform_paths.hrh>
+//
+// Platforms
+//
+PRJ_PLATFORMS
+DEFAULT
+
+
+//
+// OmaDSAppUi exports
+//
+PRJ_EXPORTS
+
+../conf/omadsui.confml				APP_LAYER_CONFML(omadsui.confml)
+../conf/omadsui_101F9A1D.crml		APP_LAYER_CRML(omadsui_101F9A1D.crml)
+
+
+../rom/AspSyncProvider.iby	CORE_APP_LAYER_IBY_EXPORT_PATH(AspSyncProvider.iby)
+../rom/AspSyncUtil.iby		CORE_APP_LAYER_IBY_EXPORT_PATH(AspSyncUtil.iby)
+../rom/OmaDsAppUi.iby		CORE_APP_LAYER_IBY_EXPORT_PATH(OmaDsAppUi.iby)
+
+../rom/AspSyncProvider_Resources.iby	LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(AspSyncProvider_Resources.iby)
+../rom/AspSyncUtil_Resources.iby		LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(AspSyncUtil_Resources.iby)
+../rom/OmaDsAppUiResources.iby			LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(OmaDsAppUiResources.iby)
+
+//
+// OmaDSAppUi components
+//
+PRJ_MMPFILES
+
+#include "../AspSyncUtil/group/bld.inf"
+#include "../ui/group/bld.inf"
+#include "../AspPreSyncPlugin/group/bld.inf"
+
+#ifdef __SYNCML_DS_AIW_PROVIDER
+#include  "../AiwSyncProvider/group/bld.inf"
+#endif // __SYNCML_DS_AIW_PROVIDER
+
+#include  "../AspScheduleHandler/group/bld.inf"
+
+//  Help exports
+#include "../help/group/bld.inf"
+
+//#ifdef RD_DSUI_CP_INTEGRATION
+#include  "../OmaDsAppUiPlugin/group/bld.inf"
+//#endif // RD_DSUI_CP_INTEGRATION
Binary file omads/omadsappui/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/help/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - Initial contribution
+* 
+* Contributors:
+* 
+* 
+* Description:
+* Export help related files.
+*
+*/
+
+#include <platform_paths.hrh>				
+PRJ_EXPORTS
+:zip ../data/xhtml.zip   /epoc32/data/z/resource/ overwrite
+:zip ../data/xhtml.zip   /epoc32/winscw/c/resource/ overwrite
+
+../inc/ds.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/ds.hlp.hrh)
+../rom/omadsappuihelps_variant.iby		CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(omadsappuihelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/help/inc/ds.hlp.hrh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,23 @@
+//
+// ds.hlp.hrh
+// 
+
+//
+// File generated by CSXHelp Utilities on 2009-05-26
+// 
+
+#ifndef __DS_HLP_HRH__
+#define __DS_HLP_HRH__
+
+_LIT(KDS_HLP_MAIN_VIEW, "DS_HLP_MAIN_VIEW"); // 
+_LIT(KDS_HLP_SETTINGS, "DS_HLP_SETTINGS"); // 
+_LIT(KDS_HLP_SETTINGS_CAL, "DS_HLP_SETTINGS_CAL"); // 
+_LIT(KDS_HLP_SETTINGS_CNT, "DS_HLP_SETTINGS_CNT"); // 
+_LIT(KDS_HLP_SETTINGS_NOTES, "DS_HLP_SETTINGS_NOTES"); // 
+_LIT(KDS_HLP_SETTINGS_SMS, "DS_HLP_SETTINGS_SMS"); // 
+_LIT(KDS_HLP_SETTINGS_BOOKMARKS, "DS_HLP_SETTINGS_BOOKMARKS"); // 
+_LIT(KDS_HLP_AUTO_SYNC_SETTINGS, "DS_HLP_AUTO_SYNC_SETTINGS"); // 
+_LIT(KDS_HLP_SETTINGS_MMS, "DS_HLP_SETTINGS_MMS"); // 
+_LIT(KDS_HLP_PROFILE_SETTINGS, "DS_HLP_PROFILE_SETTINGS"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/help/rom/omadsappuihelps_variant.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -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: This iby file is to include all the components
+* 						needed for help text to be displayed.
+*
+*/
+
+#ifndef __SYNCML_DSHELPS_VARIANT_IBY__
+#define __SYNCML_DSHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE) && defined(__SYNCML_DS)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F6DE4\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x101F6DE4\contents.zip)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F6DE4\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F6DE4\index.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F6DE4\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F6DE4\keywords.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F6DE4\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F6DE4\meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/AspSyncProvider.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __ASPSYNCPROVIDER_IBY__
+#define __ASPSYNCPROVIDER_IBY__
+
+#ifdef __SYNCML_DS // nothing should be installed from this .iby file if __SYNCML_DS feature is not selected
+
+#ifdef __SYNCML_DS_AIW_PROVIDER
+
+//Resource file(s) for AspSyncProvider
+//data=DATAZ_\RESOURCE_FILES_DIR\AiwSyncProvider.RSC          RESOURCE_FILES_DIR\AiwSyncProvider.rsc
+
+
+ECOM_PLUGIN(AiwSyncProvider.dll,101F871F.RSC)
+
+
+#endif // __SYNCML_DS_AIW_PROVIDER
+
+#endif // __SYNCML_DS
+
+
+#endif //__ASPSYNCPROVIDER_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/AspSyncProvider_Resources.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __ASPSYNCPROVIDER_RESOURCES_IBY__
+#define __ASPSYNCPROVIDER_RESOURCES_IBY__
+
+#ifdef __SYNCML_DS // nothing should be installed from this .iby file if __SYNCML_DS feature is not selected
+
+#ifdef __SYNCML_DS_AIW_PROVIDER
+
+//Resource file(s) for AspSyncProvider
+data=DATAZ_\RESOURCE_FILES_DIR\AiwSyncProvider.RSC          RESOURCE_FILES_DIR\AiwSyncProvider.rsc
+
+#endif // __SYNCML_DS_AIW_PROVIDER
+
+#endif // __SYNCML_DS
+
+
+#endif //__ASPSYNCPROVIDER_RESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/AspSyncUtil.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __ASPSYNCUTIL_IBY__
+#define __ASPSYNCUTIL_IBY__
+
+#ifdef __SYNCML_DS // nothing should be installed from this .iby file if __SYNCML_DS feature is not selected
+
+
+file=ABI_DIR\BUILD_DIR\AspSyncUtil.dll   		SHARED_LIB_DIR\AspSyncutil.dll
+//file=ABI_DIR\UDEB\AspSyncUtil.dll        		SHARED_LIB_DIR\AspSyncutil.dll
+//file=ABI_DIR\DEBUG_DIR\AspSyncUtil.dll   		SHARED_LIB_DIR\AspSyncutil.dll
+
+file=ABI_DIR\BUILD_DIR\aspschedulehandler.exe    PROGRAMS_DIR\aspschedulehandler.exe
+
+ECOM_PLUGIN(AspPreSyncDefault.dll,AspPreSyncDefault.rsc)
+
+//
+// Normal icons
+//
+data=DATAZ_\BITMAP_DIR\AspSyncUtil.MIF               BITMAP_DIR\AspSyncUtil.mif
+AUTO-BITMAP=DATAZ_\BITMAP_DIR\AspSyncUtil.mbm               BITMAP_DIR\AspSyncUtil.mbm
+
+//Resource file(s) for AspSyncUtil
+//data=DATAZ_\RESOURCE_FILES_DIR\AspSyncUtil.RSC          RESOURCE_FILES_DIR\AspSyncUtil.rsc
+
+
+#endif // __SYNCML_DS
+
+#endif //__ASPSYNCUTIL_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/AspSyncUtil_Resources.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __ASPSYNCUTIL_RESOURCES_IBY__
+#define __ASPSYNCUTIL_RESOURCES_IBY__
+
+#ifdef __SYNCML_DS // nothing should be installed from this .iby file if __SYNCML_DS feature is not selected
+
+//Resource file(s) for AspSyncUtil
+data=DATAZ_\RESOURCE_FILES_DIR\AspSyncUtil.RSC          RESOURCE_FILES_DIR\AspSyncUtil.rsc
+
+#endif // __SYNCML_DS
+
+#endif //__ASPSYNCUTIL_RESOURCES_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/OmaDsAppUi.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+REM OMA Data Synchronisation Application UI
+
+#include <bldvariant.hrh>
+
+#ifndef __OMADSAPPUI_IBY__
+#define __OMADSAPPUI_IBY__
+
+#ifdef __SYNCML_DS // nothing should be installed from this .iby file if __SYNCML_DS feature is not selected
+
+REM S60_APP_EXE_UDEB(NSmlDSSync)
+REM file=ABI_DIR\UDEB\NSmlDSSync.exe                   PROGRAMS_DIR\NSmlDSSync.exe
+S60_APP_EXE(NSmlDSSync)
+
+REM S60_APP_BITMAP(NSmlDSSync)
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,NSmlDSSync)
+S60_APP_AIF_ICONS(NSmlDSSync)
+S60_APP_AIF_RSC(NSmlDSSync)
+
+
+//#ifdef RD_DSUI_CP_INTEGRATION
+ECOM_PLUGIN(OmaDsAppUiPlugin.dll, OmaDsAppUiPlugin.rsc)
+//#endif
+
+#endif // __SYNCML_DS
+
+#endif //__OMADSAPPUI_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/rom/OmaDsAppUiResources.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+REM OMA Data Synchronization Application UI IBY-file for localizable elements
+
+#ifndef __OMADSAPPUIRESOURCES_IBY__
+#define __OMADSAPPUIRESOURCES_IBY__
+
+#ifdef __SYNCML_DS
+
+S60_APP_RESOURCE(NSmlDSSync)
+S60_APP_CAPTION(NSmlDSSync)
+
+//#ifdef RD_DSUI_CP_INTEGRATION
+data=DATAZ_\RESOURCE_FILES_DIR\NsmlDSGSPluginResource.RSC            RESOURCE_FILES_DIR\NsmlDSGSPluginResource.RSC
+//#endif
+
+#endif
+
+#endif //__OMADSAPPUIRESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/aif/NSmlDSSyncaif.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <aiftool.rh>
+
+RESOURCE AIF_DATA
+    {
+    app_uid=0x0995CDE9;
+    num_icons=2;
+    embeddability=KAppNotEmbeddable;
+    newfile=KAppDoesNotSupportNewFile;
+    }
+
+// End of File
Binary file omads/omadsappui/ui/aif/context_pane_icon.bmp has changed
Binary file omads/omadsappui/ui/aif/context_pane_icon_mask.bmp has changed
Binary file omads/omadsappui/ui/aif/list_icon.bmp has changed
Binary file omads/omadsappui/ui/aif/list_icon_mask.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/ABLD.BAT	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+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 the License "Symbian Foundation License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\s60\app\contentcontrol\omads\OmaDsAppUi\ui\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/NSmlDSSync.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET      NSmlDSSync.exe
+TARGETTYPE  exe
+UID  0x100039CE 0x101F6DE4 
+
+EPOCSTACKSIZE 	0x5000
+
+VENDORID VID_DEFAULT
+
+CAPABILITY  CAP_APPLICATION
+
+SOURCEPATH ../src
+
+START RESOURCE ../src/NSmlDSSync.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+LANGUAGE_IDS
+END  // RESOURCE
+
+
+START RESOURCE ../src/NSmlDSSync_reg.rss
+DEPENDS nsmldssync.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+
+SOURCE  NSmlDSSyncApp.cpp 
+SOURCE  NSmlDSSyncAppUi.cpp
+SOURCE  NSmlDSSyncDocument.cpp
+SOURCE  NSmlDSSyncContainer.cpp
+//SOURCE  NSmlDSSyncAppServer.cpp
+
+USERINCLUDE . 
+USERINCLUDE ../inc
+
+// for AspSyncUtilApi.h
+USERINCLUDE     ../../../omadsappui/AspSyncUtil/inc
+
+// for nsmldssync.loc
+USERINCLUDE     ../../../omadsappui/AspSyncUtil/src
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib apparc.lib cone.lib eikcore.lib 
+LIBRARY eikcoctl.lib avkon.lib
+LIBRARY bafl.lib
+LIBRARY	aknskins.lib
+LIBRARY aspsyncutil.lib
+LIBRARY apgrfx.lib
+
+LIBRARY     estor.lib
+//LIBRARY     syncservice.lib
+
+DEBUGLIBRARY flogger.lib
\ No newline at end of file
Binary file omads/omadsappui/ui/group/aiwtestapp.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+  OPTION TARGETFILE nsmldssync.mif
+  OPTION HEADERFILE nsmldssync.mbg
+  OPTION SOURCES -c8,8 qgn_prop_sml_http -c8,8 qgn_prop_sml_http_off -c8,8 qgn_prop_cp_conn_datasync
+END
+
+START EXTENSION s60/mifconv
+  OPTION TARGETFILE nsmldssync_aif.mif
+  OPTION SOURCES -c8,8 qgn_menu_sml
+END
+
+PRJ_MMPFILES
+
+//gnumakefile omadsappui_icons_dc.mk
+/*
+#ifdef __SCALABLE_ICONS
+gnumakefile omadsappui_icons_aif_scalable_dc.mk
+#else
+gnumakefile omadsappui_icons_aif_bitmaps_dc.mk
+#endif
+*/
+
+
+./NSmlDSSync.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,74 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\SYSTEM\APPS\nsmldssync
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync.mif
+HEADERFILENAME=$(HEADERDIR)\nsmldssync.mbg
+
+
+do_nothing : 
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	/c8,8 qgn_prop_sml_http.bmp \
+	/c8,8 qgn_prop_sml_http_off.bmp \
+
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons_aif_bitmaps.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\SYSTEM\APPS\nsmldssync
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync.mbm
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_sml_lst.bmp \
+		/c8,8 qgn_menu_sml_cxt.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons_aif_bitmaps_dc.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,70 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync_aif.mbm
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_sml_lst.bmp \
+		/c8,8 qgn_menu_sml_cxt.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons_aif_scalable.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+#TARGETDIR=$(ZDIR)\SYSTEM\APPS\nsmldssync
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync_aif.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_sml.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons_aif_scalable_dc.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,68 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+#TARGETDIR=$(ZDIR)\RESOURCE\APPS\LOCALISABLEFILES
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync_aif.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_sml.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/group/omadsappui_icons_dc.mk	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,74 @@
+#
+# Copyright (c) 2004 Nokia Corporation and/or 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: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+#
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\nsmldssync.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\nsmldssync.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	/c8,8 qgn_prop_sml_http.bmp \
+	/c8,8 qgn_prop_sml_http_off.bmp \
+	/c8,8 qgn_prop_cp_conn_datasync.bmp \
+
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSync.hrh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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 NSMLDSSYNC_HRH
+#define NSMLDSSYNC_HRH
+
+
+enum TSmlMenuCommands
+    {
+	ENSmlMenuTest1 = 1,
+        ENSmlMenuTest2 = 2
+    };
+
+
+enum TAIWTestAppCommandIds
+    {
+    EAIWTestAppCmdTest = 1,
+    EAIWTestAppCmdAiwPlaceholder = 10,
+    EAIWTestAppCmdExit = 2,
+    EAiwTestAppCmdLast = 11
+    };
+
+
+
+#endif      // NSMLDSSYNC_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSyncApp.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: A sync ui application class 
+*
+*/
+
+
+
+#ifndef NSMLDSSYNC_APP_H
+#define NSMLDSSYNC_APP_H
+
+// INCLUDES
+#include <aknapp.h>
+#include <eikapp.h>
+
+// CONSTANTS
+
+// UID of the application
+const TUid KUidSmlSyncApp = { 0x101F6DE4 };
+
+
+// CLASS DECLARATION
+
+
+/**
+* Class CNSmlDSSyncApp.
+* 
+*/
+class CNSmlDSSyncApp : public CAknApplication
+    {
+    
+    private:
+
+        /**
+        * From CApaApplication, creates application document object.
+        * @param None.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID.
+        * @param None.
+        * @return App uid.
+        */
+        TUid AppDllUid() const;
+    };
+
+
+#endif  // NSMLDSSYNC_APP_H
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSyncAppServer.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: server derivation
+*
+*/
+
+
+#ifndef NSMLDSSYNCAPPSERVER_H
+#define NSMLDSSYNCAPPSERVER_H
+
+// INCLUDES
+
+#include <akndoc.h>
+#include <aknapp.h>
+#include <AknServerApp.h>
+
+
+// CLASS DECLARATION
+
+/**
+* Data synchronization Aplication Server
+*
+*/
+class CNSmlDSSyncAppServer :  public CAknAppServer
+	{
+	public:
+
+        /**
+        * C++ default constructor.
+        */
+		CNSmlDSSyncAppServer();
+        
+        /**
+        * Destructor.
+        */		
+		virtual ~CNSmlDSSyncAppServer();
+		
+    public: //from CAknServerApp
+    
+        /**
+        * CreateServiceL.
+        * @param aServiceType
+        * @return CApaAppServiceBase.
+        */
+        CApaAppServiceBase* CreateServiceL( TUid aServiceType ) const;
+        
+        /**
+        * From the base class.
+        * @param None.
+        * @return None.
+        */
+        void HandleAllClientsClosed();
+	};
+
+#endif  // NSMLDSSYNCAPPSERVER_H
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSyncAppUi.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Datasync app UI
+*
+*/
+
+
+
+#ifndef NSMLDSSYNC_APPUI_H
+#define NSMLDSSYNC_APPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+
+
+// FORWARD DECLARATIONS
+class CNSmlDSSyncContainer;
+
+
+
+// CLASS DECLARATION
+
+/**
+*  Class CNSmlDSSyncAppUi.
+*/
+class CNSmlDSSyncAppUi : public CAknAppUi
+    {
+    public: 
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CNSmlDSSyncAppUi();
+//#ifdef RD_DSUI_CP_INTEGRATION        
+        static TInt OpenDialog( TAny* aThis) ;
+//#endif
+    private:
+ 
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+    private:
+        /**
+        * From CEikAppUi, takes care of command handling.
+        * @param aCommand command to be handled
+        * @return None.
+        */
+        void HandleCommandL(TInt aCommand);
+
+        /**
+        * From CEikAppUi, handles key events.
+        * @param aKeyEvent Event to handled.
+        * @param aType Type of the key event. 
+        * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). 
+        */
+        virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+    private:
+        // container 
+//#ifdef RD_DSUI_CP_INTEGRATION      
+        CIdle *iIdle;
+//#endif
+        CNSmlDSSyncContainer* iAppContainer; 
+    };
+
+
+#endif  // NSMLDSSYNC_APPUI_H
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSyncContainer.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Datasync app view container
+*
+*/
+
+
+#ifndef NSMLDSSYNC_CONTAINER_H
+#define NSMLDSSYNC_CONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+
+// CLASS DECLARATION
+
+
+/**
+*  Class CNSmlDSSyncContainer.
+*  
+*/
+class CNSmlDSSyncContainer : public CCoeControl, MCoeControlObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        ~CNSmlDSSyncContainer();
+        
+    private: // Functions from base classes
+
+       /**
+        * From CoeControl,SizeChanged.
+		* @param None. 
+    	* @return None.
+        */
+        void SizeChanged();
+
+       /**
+        * From CoeControl,CountComponentControls.
+		* @param None. 
+    	* @return Component count.
+        */
+        TInt CountComponentControls() const;
+
+       /**
+        * From CCoeControl,ComponentControl.
+		* @param aIndex. 
+    	* @return CCoeControl.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+       /**
+        * From CCoeControl,Draw.
+		* @param aEventType	The type of control event 
+    	* @return None
+        */
+        void Draw(const TRect& aRect) const;
+       	
+		/**
+		* From MCoeControlObserver
+		* Acts upon changes in the hosted control's state. 
+		* @param aControl The control changing its state
+		* @param aEventType	The type of control event 
+    	* @return None
+		*/
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+        
+		/**
+		* From base class.
+		* Called when UI layout changes. 
+		* @param aType.
+    	* @return None.
+		*/
+        void HandleResourceChange(TInt aType);
+    };
+
+
+#endif  // NSMLDSSYNC_CONTAINER_H
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/inc/NSmlDSSyncDocument.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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: Datasync app document 
+*
+*/
+
+
+
+#ifndef NSMLDSSYNC_DOCUMENT_H
+#define NSMLDSSYNC_DOCUMENT_H
+
+
+
+// INCLUDES
+#include <AknDoc.h>
+#include "AspSyncUtilApi.h"
+#include <eikenv.h>
+
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+
+// CLASS DECLARATION
+
+
+/**
+* CNSmlDSSyncDocument class.
+*/
+class CNSmlDSSyncDocument : public CAknDocument
+    {
+    public:
+    
+        /**
+        * Two-phased constructor.
+        */
+        static CNSmlDSSyncDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CNSmlDSSyncDocument();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CNSmlDSSyncDocument(CEikApplication& aApp);
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+    public:
+
+        /**
+        * Returns application model.
+        * @param None
+		* @return Application model.
+        */
+        CSyncUtilApi* Model();
+
+    private:
+
+        /**
+        * From CEikDocument, create CAIWTestAppAppUi "App UI" object.
+        * @param None.
+		* @return App ui object.
+        */
+        CEikAppUi* CreateAppUiL();
+        
+        /**
+        * Panics application.
+        * @param aReason.
+		* @return None.
+        */
+        void Panic(TInt aReason);
+   
+    private:
+    
+        // CSyncUtilApi handles synchronize operations. 
+		CSyncUtilApi* iSyncUtilApi;
+		
+		// Eikon environment
+		CEikonEnv*                          iEikEnv;
+		
+    };
+
+#endif  // NSMLDSSYNC_DOCUMENT_H
+
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSync.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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:  
+*
+*/
+
+
+
+//  RESOURCE IDENTIFIER
+NAME    SYNC // 4 letter ID
+
+
+//  INCLUDES
+
+#include "NSmlDSSync.hrh"
+#include<NSmlDSSync.loc>
+
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+
+
+//
+// AIF icons/files
+//
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+//  RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = "NSmlDSSync"; }
+
+RESOURCE EIK_APP_INFO
+	{
+    menubar=r_smlsync_menubar;
+	status_pane=r_smlsync_status_pane;
+    hotkeys=r_smlsync_hotkeys;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+
+//
+// AIF icons/files
+//
+RESOURCE LOCALISABLE_APP_INFO r_nsmldssync_localisable_app_info
+    {
+    short_caption = qtn_apps_sml_grid;
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_apps_sml_list;
+
+#ifdef __SCALABLE_ICONS
+        number_of_icons = 1;
+        icon_file = APP_BITMAP_DIR"\\NSmlDSSync_aif.mif";
+#else
+        number_of_icons = 2;
+        icon_file = APP_BITMAP_DIR"\\NSmlDSSync_aif.mbm";
+#endif
+
+        };
+    }
+
+
+
+//------------------------------------------------------------------------------
+// r_smlsync_hotkeys.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE HOTKEYS r_smlsync_hotkeys
+	{
+    control=
+		{
+        HOTKEY { command=EAknCmdExit; key='e'; }
+		};
+	}
+
+
+//------------------------------------------------------------------------------
+// r_smlsync_menubar.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_smlsync_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_smlsync_mainmenu; txt=""; }
+        };
+    }
+
+
+//------------------------------------------------------------------------------
+// r_smlsync_status_pane.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE STATUS_PANE_APP_MODEL r_smlsync_status_pane
+	{
+	panes=
+		{
+		SPANE_PANE
+			{	
+			id = EEikStatusPaneUidTitle;
+			type = EAknCtTitlePane;
+			resource = r_overridden_smlsync;
+			}
+		};
+	}
+
+
+//------------------------------------------------------------------------------
+// r_overridden_smlsync.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_overridden_smlsync
+	{
+	txt = qtn_apps_syncml_title;
+	}	
+
+
+//------------------------------------------------------------------------------
+// r_smlsync_mainmenu.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_smlsync_mainmenu	
+	{
+	items =
+		{
+        MENU_ITEM { command=EEikCmdExit; txt=qtn_options_exit; }
+		};
+	}
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncApp.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include    "NSmlDSSyncApp.h"
+#include    "NSmlDSSyncDocument.h"
+#include    "AspDebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncApp::AppDllUid
+//
+// Returns application UID.
+// -----------------------------------------------------------------------------
+//
+TUid CNSmlDSSyncApp::AppDllUid() const
+    {
+    FLOG( _L("CNSmlDSSyncApp::AppDllUid") );
+    
+    return KUidSmlSyncApp;
+    }
+
+   
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncApp::CreateDocumentL
+//
+// Creates CAIWTestAppDocument object.
+// -----------------------------------------------------------------------------
+//
+CApaDocument* CNSmlDSSyncApp::CreateDocumentL()
+    {
+    FLOG( _L("CNSmlDSSyncApp::CreateDocumentL") );
+    
+    return CNSmlDSSyncDocument::NewL( *this );
+    }
+
+
+
+
+// ======================== OTHER EXPORTED FUNCTIONS ===========================
+
+
+
+#include <eikstart.h>
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CNSmlDSSyncApp;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
+
+
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncAppServer.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include    "NSmlDSSyncAppServer.h"
+#include    "aspdebug.h"
+
+#include    <SyncServiceSession.h>
+#include    <syncserviceconst.h>
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// ------------------------------------------------------------------------------
+// CNSmlDMSyncAppServer::CNSmlDMSyncAppServer
+//
+// ------------------------------------------------------------------------------
+//
+CNSmlDSSyncAppServer::CNSmlDSSyncAppServer()   
+	{
+	FLOG( _L("CNSmlDSSyncAppServer::CNSmlDSSyncAppServer") );	
+	}
+
+
+// ------------------------------------------------------------------------------
+// CNSmlDMSyncAppServer::~CNSmlDMSyncAppServer
+//
+// ------------------------------------------------------------------------------
+//        
+CNSmlDSSyncAppServer::~CNSmlDSSyncAppServer()
+	{
+    FLOG( _L("CNSmlDSSyncAppServer::~CNSmlDSSyncAppServer") );
+	}
+
+
+// ------------------------------------------------------------------------------
+// CNSmlDMSyncAppServer::CreateServiceL
+//
+// ------------------------------------------------------------------------------
+//
+CApaAppServiceBase* CNSmlDSSyncAppServer::CreateServiceL( TUid aServiceType ) const
+	{	
+	FLOG( _L("CNSmlDSSyncAppServer::CreateServiceL") );
+	
+	if (aServiceType == TUid::Uid(KSyncServiceUid))   
+		{
+		return new (ELeave) CSyncServiceSession;
+		}
+	else
+		{
+		return CAknAppServer::CreateServiceL(aServiceType);
+		}
+	}
+
+
+// ------------------------------------------------------------------------------
+// CNSmlDMSyncAppServer::CreateServiceL
+//
+// ------------------------------------------------------------------------------
+//
+void CNSmlDSSyncAppServer::HandleAllClientsClosed()
+    {
+   	FLOG( _L("CNSmlDMSyncAppServer::HandleAllClientsClosed") );
+        
+    // NOTE: HandleAllClientsClosed needs overriding to avoid RunAppShutter
+    }
+
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncAppUi.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "NSmlDSSyncAppUi.h"
+#include "NSmlDSSyncContainer.h" 
+#include "NSmlDSSyncDocument.h"
+
+#include <NSmlDSSync.rsg>
+#include "NSmlDSSync.hrh"
+#include "AspDebug.h"
+
+#include <eikmenup.h> 
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+//#ifdef RD_DSUI_CP_INTEGRATION
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncAppUi::ConstructL()
+    {
+    FLOG( _L("CNSmlDSSyncAppUi::ConstructL START") );
+    
+    const TInt KBufSize128 = 128;
+    const TInt KModeDialogNoWait = 4;
+    
+    BaseConstructL(EAknEnableSkin | EAknDisableHighlightAnimation | EAknEnableMSK);
+
+	TBool flag = CEikonEnv::Static()->StartedAsServerApp() ;
+	if (flag)
+		{
+		TRAP_IGNORE(iIdle = CIdle::NewL( CActive::EPriorityHigh ));
+	
+    	if ( !iIdle->IsActive() ) 
+    		{
+       		iIdle->Start( TCallBack( OpenDialog, this ) );
+    		}
+		}
+	else
+		{
+		iAppContainer = new (ELeave) CNSmlDSSyncContainer;
+	    iAppContainer->SetMopParent(this);
+	    iAppContainer->ConstructL(ClientRect());
+	    AddToStackL(iAppContainer);
+
+	    TBuf<KBufSize128> buf;
+	    CNSmlDSSyncDocument* document= STATIC_CAST(CNSmlDSSyncDocument*, Document());
+	    document->Model()->ShowSettingsL(0, KModeDialogNoWait, buf);
+		}
+
+    FLOG( _L("CNSmlDSSyncAppUi::ConstructL END") );
+    }
+    
+// ==========================================================================
+// METHOD:  OpenDialog
+//
+// DESIGN:  CIdle Callback function
+// ==========================================================================
+TInt CNSmlDSSyncAppUi::OpenDialog( TAny* /*aThis*/ )
+{
+    const TInt KBufSize128 = 128;
+         
+	// Launch the settings dialog
+ 	TBuf<KBufSize128> buf;
+    CSyncUtilApi* utilApi = CSyncUtilApi::NewL();
+	CleanupStack::PushL( utilApi );
+
+	TRAP_IGNORE( utilApi->ShowSettingsL( 0, 0, buf ) );
+
+	CleanupStack::PopAndDestroy( utilApi );
+
+	// We're done; exit
+	iAvkonAppUi->Exit();
+	
+	return KErrNone;
+} 
+
+//#else
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+/*void CNSmlDSSyncAppUi::ConstructL()
+    {
+    FLOG( _L("CNSmlDSSyncAppUi::ConstructL START") );
+    
+    const TInt KBufSize128 = 128;
+    const TInt KModeDialogNoWait = 4;
+    
+    BaseConstructL(EAknEnableSkin | EAknDisableHighlightAnimation | EAknEnableMSK);
+
+    iAppContainer = new (ELeave) CNSmlDSSyncContainer;
+    iAppContainer->SetMopParent(this);
+    iAppContainer->ConstructL(ClientRect());
+    AddToStackL(iAppContainer);
+
+    TBuf<KBufSize128> buf;
+    CNSmlDSSyncDocument* document= STATIC_CAST(CNSmlDSSyncDocument*, Document());
+    document->Model()->ShowSettingsL(0, KModeDialogNoWait, buf);
+    
+    FLOG( _L("CNSmlDSSyncAppUi::ConstructL END") );
+    }*/
+
+//#endif
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::~CNSmlDSSyncAppUi
+//
+// -----------------------------------------------------------------------------
+//
+CNSmlDSSyncAppUi::~CNSmlDSSyncAppUi()
+    {
+    FLOG( _L("CNSmlDSSyncAppUi::~CNSmlDSSyncAppUi START") );
+//#ifdef RD_DSUI_CP_INTEGRATION    
+	if ( iIdle )
+    	{
+    	delete iIdle;
+     	iIdle = NULL;
+    	}
+//#endif    	
+    if (iAppContainer)
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+        
+    FLOG( _L("CNSmlDSSyncAppUi::~CNSmlDSSyncAppUi END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::DynInitMenuPaneL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncAppUi::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::HandleKeyEventL
+//
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CNSmlDSSyncAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
+    {
+    return EKeyWasNotConsumed;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncAppUi::HandleCommandL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncAppUi::HandleCommandL(TInt aCommand)
+    {
+    FLOG( _L("CNSmlDSSyncAppUi::HandleCommandL START") );
+    
+    switch (aCommand)
+        {
+		case EAknCmdExit:
+        case EEikCmdExit:
+        case EAknSoftkeyBack:
+			{
+     		FLOG( _L("before Exit") );
+     		
+     		Exit();
+     		
+     		FLOG( _L("after Exit") );
+			break;			
+			}
+
+        default:
+			{
+            break;      
+			}
+        }
+        
+    FLOG( _L("CNSmlDSSyncAppUi::HandleCommandL END") );
+	}
+
+
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncContainer.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "NSmlDSSyncContainer.h"
+
+#include <AknUtils.h>
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+    SetRect(aRect);
+    ActivateL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::~CNSmlDSSyncContainer
+//
+// -----------------------------------------------------------------------------
+//
+CNSmlDSSyncContainer::~CNSmlDSSyncContainer()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::SizeChanged
+//
+// Called by framework when the view size is changed.
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncContainer::SizeChanged()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::CountComponentControls
+//
+// Returns number of controls inside this container.
+// -----------------------------------------------------------------------------
+//
+TInt CNSmlDSSyncContainer::CountComponentControls() const
+    {
+    return 0;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::ComponentControl
+//
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CNSmlDSSyncContainer::ComponentControl(TInt /*aIndex*/) const
+    {
+    return NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::Draw
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.SetPenStyle(CGraphicsContext::ENullPen);
+    gc.SetBrushColor(KRgbGray);
+    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+    gc.DrawRect(aRect);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::HandleControlEventL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncContainer::HandleResourceChange
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncContainer::HandleResourceChange(TInt aType)
+    {
+    if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+		DrawNow();
+		return;
+		}
+
+    CCoeControl::HandleResourceChange(aType);
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncDocument.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or 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 FILES
+#include "NSmlDSSyncDocument.h"
+#include "NSmlDSSyncAppUi.h"
+#include "AspDebug.h"
+
+
+//const TUid KUidAppSync       = { 0x101F6DE4 };
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::Constructor
+//
+// -----------------------------------------------------------------------------
+//
+CNSmlDSSyncDocument::CNSmlDSSyncDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::~CNSmlDSSyncDocument
+//
+// -----------------------------------------------------------------------------
+//
+CNSmlDSSyncDocument::~CNSmlDSSyncDocument()
+    {
+    FLOG( _L("CNSmlDSSyncDocument::~CNSmlDSSyncDocument START") );
+    
+    delete iSyncUtilApi;
+    
+    FLOG( _L("CNSmlDSSyncDocument::~CNSmlDSSyncDocument END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CNSmlDSSyncDocument::ConstructL()
+    {
+    FLOG( _L("CNSmlDSSyncDocument::ConstructL START") );
+    
+    iSyncUtilApi = CSyncUtilApi::NewL();
+    
+    iEikEnv = CEikonEnv::Static();
+    
+    FLOG( _L("CNSmlDSSyncDocument::ConstructL END") );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CNSmlDSSyncDocument* CNSmlDSSyncDocument::NewL(CEikApplication& aApp)
+    {
+    FLOG( _L("CNSmlDSSyncDocument::NewL START") );
+    
+    CNSmlDSSyncDocument* self = new (ELeave) CNSmlDSSyncDocument( aApp );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    FLOG( _L("CNSmlDSSyncDocument::NewL END") );
+    
+    return self;
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::CreateAppUiL
+//
+// -----------------------------------------------------------------------------
+//
+CEikAppUi* CNSmlDSSyncDocument::CreateAppUiL()
+    {
+    return new (ELeave) CNSmlDSSyncAppUi;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDSSyncDocument::Model
+//
+// -----------------------------------------------------------------------------
+//
+CSyncUtilApi* CNSmlDSSyncDocument::Model()
+    {
+    __ASSERT_ALWAYS(iSyncUtilApi, Panic(KErrGeneral));
+    
+    return iSyncUtilApi;
+    }
+
+
+// -------------------------------------------------------------------------------
+// CNSmlDSSyncDocument::Panic
+//
+// -------------------------------------------------------------------------------
+//
+void CNSmlDSSyncDocument::Panic(TInt aReason)
+    {
+	_LIT(KPanicCategory,"CNSmlDSSync");
+
+	User::Panic(KPanicCategory, aReason); 
+    }
+
+
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSync_caption.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application titles
+*
+*/
+
+
+
+#include <apcaptionfile.rh>
+#include<NSmlDSSync.loc>
+
+RESOURCE CAPTION_DATA
+{
+caption = qtn_apps_sml_list;
+shortcaption = qtn_apps_sml_grid;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSync_reg.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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 <appinfo.rh>
+#include <NSmlDSSync.rsg>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x101F6DE4 // Define your application UID here
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "NSmlDSSync";
+    //num_icons=1;
+    //attributes = KAppBuiltAsDll;
+    //embeddability=KAppNotEmbeddable;
+    //newfile=KAppDoesNotSupportNewFile;
+
+    localisable_resource_file = APP_RESOURCE_DIR"\\NSmlDSSync";
+    localisable_resource_id   = R_NSMLDSSYNC_LOCALISABLE_APP_INFO;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsappui/ui/src/NSmlDSSyncaif.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  RSS for creating the aif file for NSmlDSSyncApp.
+*
+*/
+
+
+#include <aiftool.rh>
+
+RESOURCE AIF_DATA
+{
+    app_uid=0x101F6DE4;
+    num_icons=1;
+    embeddability=KAppNotEmbeddable;
+    newfile=KAppDoesNotSupportNewFile;
+}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  build info file for DS data provider
+*
+*/
+
+
+#include <platform_paths.hrh>
+PRJ_EXPORTS
+../loc/101F6DD7.loc		APP_LAYER_LOC_EXPORT_PATH(101F6DD7.loc)
+PRJ_MMPFILES
+./nsmlagendadataprovider.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/bld/def/bwinscwnsmlagendadataprovideru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/bld/def/eabinsmlagendadataprovideru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI20CNSmlAgendaDataStore @ 2 NONAME ; #<TI>#
+	_ZTI23CNSmlAgendaDataProvider @ 3 NONAME ; #<TI>#
+	_ZTI23CNSmlAgendaProgressview @ 4 NONAME ; #<TI>#
+	_ZTV20CNSmlAgendaDataStore @ 5 NONAME ; #<VT>#
+	_ZTV23CNSmlAgendaDataProvider @ 6 NONAME ; #<VT>#
+	_ZTV23CNSmlAgendaProgressview @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/bld/nsmlagendadataprovider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  mmp file for DS agenda adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET		nsmlagendadataprovider.dll
+TARGETTYPE	PLUGIN
+UID			0x10009d8d 0x101F6DDE
+CAPABILITY	CAP_ECOM_PLUGIN
+VENDORID	VID_DEFAULT
+
+#if defined(ARMCC)
+DEFFILE		./def/eabinsmlagendadataprovider
+#elif defined(WINSCW)
+DEFFILE		./def/bwinscwnsmlagendadataprovider
+#endif
+
+SOURCEPATH		../src
+SOURCE			nsmlagendadataprovider.cpp
+SOURCE			nsmlagendadatastore.cpp
+SOURCE			nsmlagendaprogressview.cpp
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE	/epoc32/include/syncml 
+SYSTEMINCLUDE	/epoc32/include/ecom
+SYSTEMINCLUDE	../../inc
+
+USERINCLUDE		../inc
+USERINCLUDE		../../../datamod/inc
+
+START RESOURCE 101F6DD7.rss
+HEADER
+TARGET		nsmlagendadataprovider.rsc
+LANGUAGE_IDS
+END
+
+START RESOURCE NSmlAgendaDataStore_1_1_2.rss
+HEADER
+TARGETPATH	RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END 
+
+START RESOURCE NSmlAgendaDataStore_1_2.rss
+HEADER
+TARGETPATH	RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END 
+
+LIBRARY		ECom.lib euser.lib efsrv.lib estor.lib smlstoreformat.lib
+LIBRARY		nsmldebug.lib smldataprovider.lib nsmldatamod.lib
+LIBRARY		nsmlchangefinder.lib wbxmllib.lib bafl.lib sysutil.lib
+LIBRARY		CalInterimAPI.lib msgs.lib CalenImp.lib CalenInterimUtils2.lib
+LIBRARY 	versit.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/inc/nsmlagendadataprovider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS agenda data provider
+*
+*/
+
+
+#ifndef __NSMLAGENDADATAPROVIDER_H__
+#define __NSMLAGENDADATAPROVIDER_H__
+
+//  INCLUDES
+#include "nsmlagendadatastore.h"
+#include <SmlDataFormat.h>
+
+// CONSTANTS
+_LIT( KNSmlDSAgendaDataStoreRsc_1_1_2,"z:NSMLAGENDADATASTORE_1_1_2.RSC" );
+_LIT( KNSmlDSAgendaDataStoreRsc_1_2,"z:NSMLAGENDADATASTORE_1_2.RSC" );
+
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider provides basic interface for syncronization
+// partner to be able to access CNSmlAgendaDataStore instance.
+//
+// @lib nsmlagendadataprovider.dll
+// ------------------------------------------------------------------------------------------------
+class CNSmlAgendaDataProvider : public CSmlDataProvider
+	{
+    public:
+
+        /**
+        * Two-phased constructor.
+        */
+	    static CNSmlAgendaDataProvider* NewL();
+
+        /**
+        * Destructor.
+        */
+	    virtual ~CNSmlAgendaDataProvider();
+
+    private:
+
+        /**
+        * Not supported.
+        */
+	    void DoOnFrameworkEvent( TSmlFrameworkEvent, TInt aParam1, TInt aParam2 );
+
+        /**
+        * Returns ETrue if operation of id aOpId is supported otherwice returns EFalse.
+        */
+	    TBool DoSupportsOperation( TUid aOpId ) const;
+
+        /**
+        * Gives a reference to DataStoreFormat attribute structure.
+        */
+	    const CSmlDataStoreFormat& DoStoreFormatL();
+
+        /**
+        * Gives a reference to available datastore names structure.
+        */
+	    CDesCArray* DoListStoresLC();
+
+        /**
+        * Gives a reference to a default datastore name.
+        */
+	    const TDesC& DoDefaultStoreL();
+
+        /**
+        * Greates new CNSmlAgendaDataStore instance.
+        */
+	    CSmlDataStore* DoNewStoreInstanceLC();
+
+	    /**
+		This method returns the set of filters that can be used to send to the SyncML server.
+		* @return New filters.
+		*/
+		const RPointerArray<CSyncMLFilter>& DoSupportedServerFiltersL();
+		
+		/**
+		This method checks what filters are supported by server.
+		@param	aServerDataStoreFormat	The store format of server
+		@param	aFilters				The array that includes filters
+		@param	aChangeInfo				The change information about changes that data provider did
+		*/
+		void DoCheckSupportedServerFiltersL(const CSmlDataStoreFormat& aServerDataStoreFormat, RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo);
+		
+		/**
+		This method updates dynamic filters up-to-date.
+		@param	aFilters				The array that includes filters
+		@param	aChangeInfo				The change information about changes that data provider did
+		*/
+		void DoCheckServerFiltersL(RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo);
+		
+		/**
+		This method generates a record filter query to be sent to the SyncML server for the provided filters.
+		@param	aFilters			The filters to be used for the query generation
+		@param	aMatch				The filter match type to be used
+		@param	aFilterMimeType		The mime type of the returned filter query
+		@param	TSyncMLFilterType 	The filter type of the returned filter query
+		@param  aStoreName			The name of the used store
+		@return						The record filter query to be sent to the SyncML server - empty if no record filter involved
+									for this specific filter
+		*/
+		HBufC* DoGenerateRecordFilterQueryLC(const RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterMatchType aMatch, TDes& aFilterMimeType, TSyncMLFilterType& aFilterType, TDesC& aStoreName);
+		
+		/**
+		This method generates a field filter query to be sent to the SyncML server for the provided filters.
+		@param	aFilters		The filters to be used for the query generation
+		@param	aFilterMimeType		The mime type of the returned filter query
+		@param	aProperties		The field filter query to be sent to the SyncML server - empty if no field filter involved
+								for this specific filter
+		@param  aStoreName		The name of the used store
+		*/
+		void DoGenerateFieldFilterQueryL(const RPointerArray<CSyncMLFilter>& aFilters, TDes& aFilterMimeType, RPointerArray<CSmlDataProperty>& aProperties, TDesC& aStoreName);
+	    
+        /**
+        * C++ default constructor.
+        */
+	    CNSmlAgendaDataProvider();
+ 
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+	    
+        /**
+        * Returns data providers own supported features in a store format class.
+        */
+	    CSmlDataStoreFormat* DoOwnStoreFormatL();
+
+    private:
+        // Agenda data store
+	    CNSmlAgendaDataStore* iAgnDataStore;
+        // String ool
+	    RStringPool iStringPool;
+        // Data store format
+	    CSmlDataStoreFormat* iDSFormat;
+        // A handle to a file server session
+	    RFs iSession;
+	    // Filter array
+	    RPointerArray<CSyncMLFilter> iFilterArray;
+	};
+
+#endif // __NSMLAGENDADATAPROVIDER_H__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,577 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS agenda data store
+*
+*/
+
+
+#ifndef __NSMLAGENDADATASTORE_H__
+#define __NSMLAGENDADATASTORE_H__
+
+
+//  INCLUDES
+#include "nsmlconstants.h"
+#include "nsmlchangefinder.h"
+#include "NSmlDataModBase.h"
+#include "nsmlagendadefines.hrh"
+#include <calentry.h>
+#include <calsession.h> 
+#include <caldataexchange.h> 
+#include <calentryview.h>
+#include <f32file.h>
+#include <SmlDataProvider.h>
+#include <SmlDataFormat.h>
+#include <calprogresscallback.h>
+#include <msvapi.h>
+#include <CalenImporter.h>
+#include <CalenExporter.h>
+#include <CalenInterimUtils2.h>
+#include <versittls.h>
+
+// CONSTANTS
+const TInt KNSmlAgendaCompressLimit        = 20;
+const TInt KNSmlAgendaLittleArraySize      = 4;
+const TInt KNSmlAgendaSmallArraySize       = 8;
+const TInt KNSmlAgendaLargeArraySize       = 128;
+const TInt KNSmlAgendaOwnMaxObjectSize     = 1048576;
+const TInt KNSmlCompactAfterChanges        = 30;
+const TInt KNSmlDefaultStoreNameMaxSize    = 256;
+const TInt KNSmlItemDataExpandSize         = 1024;
+_LIT( KNSmlDriveC, "C" );
+_LIT( KNSmlAgendaStoreNameForDefaultDB, "Calendar" );
+_LIT8( KNSmlMRUtilitiesEComPlugInUID,   "AgnEntryUi" );
+_LIT8( KNSmlVersitTokenRecurrenceID, 	"RECURRENCE-ID");
+_LIT8( KNSmlVersitTokenXRecurrenceID, 	"X-RECURRENCE-ID");
+_LIT8(KNSmlVersitTokenGeoID,"GEO");
+
+
+// DATA TYPES
+enum TNSmlDataStoreStatus
+	{
+	ENSmlClosed = 0,
+	ENSmlOpenAndWaiting,
+	ENSmlItemOpen,
+	ENSmlItemCreating,
+	ENSmlItemUpdating
+	};
+	
+enum TNSmlDataEntryType
+	{
+	ENSmlVCal = 1,
+	ENSmlICal,
+	ENSmlNotSet
+	};
+
+// CLASS DECLARATIONS
+// ----------------------------------------------------------------------------
+// CNSmlAgendaProgressview provides progress observations for some calendar
+// classes.
+// @lib nsmlagendadataprovider.dll
+// ----------------------------------------------------------------------------
+class CNSmlAgendaProgressview : public CBase , public MCalProgressCallBack
+    {
+    public:
+        /**
+        * Two-phased constructor.
+        */
+    	static CNSmlAgendaProgressview* NewL();
+
+        /**
+        * Destructor.
+        */
+    	~CNSmlAgendaProgressview();
+
+    	/**
+        * This calls the observing class with the percentage complete
+        * of the current operation.
+        * @param  aPercentageCompleted    The percentage complete
+        */
+    	void Progress( TInt aPercentageCompleted );
+    	
+    	/**
+        * This calls the observing class when the current operation is
+        * finished.
+        * @param    aError  The error if the operation failed,
+        *                   or KErrNone if successful.
+        */
+    	void Completed( TInt aError );
+
+    	/**
+        * This method returns status of Completed method (see above).
+        * @return   Value based on status of Completed method.
+        *           KErrNotReady is returned if Completed method is not
+        *           called or same value is Completed status.
+        */
+    	TInt GetCompletedStatus();
+    	
+    	/**
+        * Asks the observing class whether progress callbacks are required.
+        * @return   If the observing class returns EFalse, then the Progress()
+        *           function will not be called.
+        */
+    	TBool NotifyProgress();
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+    	CNSmlAgendaProgressview();
+
+        /**
+        * Second phase constructor.
+        */
+    	void ConstructL();
+        
+    private:
+    	TInt    iCompletedStatus;
+	};
+
+// ----------------------------------------------------------------------------
+// CNSmlAgendaDataStore provides services to cope with calendar database access
+// for calendar events manipulation.
+// @lib nsmlagendadataprovider.dll
+// ----------------------------------------------------------------------------
+class CNSmlAgendaDataStore : public CSmlDataStore
+	{
+    public:
+        
+        /**
+        * Two-phased constructor.
+        */
+	    static CNSmlAgendaDataStore* NewL();
+        
+        /**
+        * Destructor.
+        */
+	    virtual ~CNSmlAgendaDataStore();
+
+    public: // New functions
+        
+        /**
+        * Returns a pointer to array of all possible Calendar database names
+        * which are provited by Symbian OS Calendar API.
+        * @param none
+        * @return Pointer to array of all possible Calendar database names 
+        */
+	    CDesCArray *DoListAgendaFilesLC() const;
+ 
+        /**
+        * Returns a reference to default calendar file name which is provited
+        * by Symbian OS Calendar API.
+        * @param none
+        * @return Reference to default calendar file name
+        */
+	    const TDesC& DoGetDefaultFileNameL() const;
+	    
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+ 	    CNSmlAgendaDataStore();
+
+        /**
+        * Returns the used store format.
+        */
+	    CSmlDataStoreFormat* DoOwnStoreFormatL();
+
+	    /**
+	    * Opens the data store specified by aStoreName asynchronously.
+	    * @param	aStoreName		The name of the data store to open.
+	    * @param	aContext		Identifies the specific synchronisation
+	    *                           relationship to use for the
+	    *                           synchronisation.
+	    * @param	aStatus			On completion of the open,
+	    *                           contains the result code.
+	    */
+	    void DoOpenL( const TDesC& aStoreName, MSmlSyncRelationship& aContext,
+	                    TRequestStatus& aStatus );
+
+	    /**
+	    * Cancel the current asynchronous request, including open. 
+	    * Only one asynchronous request may be outstanding at any one time.
+	    */
+	    void DoCancelRequest();
+
+	    /**
+	    * Returns the name of the open data store.
+	    */
+	    const TDesC& DoStoreName() const;
+
+	    /**
+	    * BeginTransactionL() starts the transaction mode. During this mode
+	    * calls to CreateItemL, ReplaceItemL, WriteItemL, CommitItemL,
+	    * MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this
+	    * transaction.
+	    * Their RequestStatus must be completed, even if the change is not
+	    * yet really executed in the Data Store.
+	    * If a RequestStatus is completed with an error code, the transaction
+	    * has failed and a rollback must be done. In this case
+	    * RevertTransaction will be called.
+	    */
+	    void DoBeginTransactionL();
+
+	    /**
+	    * CommitTransactionL() will be called at the end of a successful
+	    * transaction. At this point in time the operations within the
+	    * transaction are applied to the Data Store in an atomic way.
+	    * If all operations succeed, the RequestStatus must be completed
+	    * with KErrNone. If an operation fails, a rollback must be done and
+	    * the RequestStatus must be completed with an appropriate error code.
+	    */
+	    void DoCommitTransactionL( TRequestStatus& aStatus );
+
+	    /**
+	    * RevertTransaction() will be called to abort an ongoing transaction.
+	    * None of the operations already submitted may be applied to the Data
+	    * Store. The RequestStatus must be completed with KErrNone as a revert
+	    * cannot fail.
+	    */
+	    void DoRevertTransaction( TRequestStatus& aStatus );
+
+	    /**
+	    * BeginBatchL() starts the batch mode. During this mode calls to
+	    * CreateItemL, ReplaceItemL, WriteItemL, CommitItemL, MoveItemL,
+	    * DeleteItemL and SoftDeleteItemL will be part of this batch.
+	    * Their RequestStatus must be completed with KErrNone, which only
+	    * signals acceptance of the operation for batch processing.
+	    */
+	    void DoBeginBatchL();
+
+	    /**
+	    * CommitBatchL() will be called at the end of the batch mode. This
+	    * tells the Data Store to process the batched operations (in the
+	    * order they were submitted), and to append the error code for each
+	    * operation to aResultArray.
+	    * The error codes in aResultArray are only valid if the RequestStatus
+	    * is completed with KErrNone.
+	    * If the RequestStatus is completed with an error code none of the
+	    * operations in the batch mode were applied to the Data Store.
+	    */
+	    void DoCommitBatchL( RArray<TInt>& aResultArray,
+                        TRequestStatus& aStatus );
+
+	    /**
+	    * CancelBatch() will be called to abort an ongoing batch mode.
+	    * None of the operations already submitted may be applied to
+	    * the Data Store.
+	    */
+	    void DoCancelBatch();
+
+	    /**
+	    * Sets the SyncML server Data Format - this may optionally be used
+	    * by the Data Provider to filter out properties that the server does
+	    * not support, and should be used to avoid deleting these properties
+	    * in case the server sends a changed item to the Data Provider
+	    */
+	    void DoSetRemoteStoreFormatL(
+	                    const CSmlDataStoreFormat& aServerDataStoreFormat );
+
+	    /**
+	    * Sets the SyncML server maximum object size - this may optionally
+	    * be used by the Data Provider to not send items to the server
+	    * exceeding its maximum size. 0 means there is no limit.
+	    */
+	    void DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize );
+
+	    /**
+	    * Gets the Data Store maximum object size which is reported to
+	    * the SyncML server. 0 means there is no limit.
+	    */
+	    TInt DoMaxObjectSize() const;
+
+		/**
+		* Opens the data item specified by aUid asynchronously for reading.
+		* @param		aUid				Item UID which going to be read.
+		* @param		aFieldChange		Accept field changes.
+		* @param		aParent				Parent of the item.
+		* @param		aSize				Size of the item data.
+		* @param		aMimeType			MIME type of the item.
+		* @param		aMimeVer			MIME version used on item.
+		* @param		aStatus				On completion of the opening of
+		*                                   item, contains the result code.
+		*/
+	    void DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize,
+	                        TSmlDbItemUid& aParent, TDes8& aMimeType,
+	                        TDes8& aMimeVer, TRequestStatus& aStatus );
+
+		/**
+		* Sets the item properties and reference to aUid which will be created.
+		* @param		aUid				Reference to item UID which going
+		*                                   to be created.
+		* @param		aSize				Size of the item to be created.
+		* @param		aParent				Parent of the item.
+		* @param		aMimeType			MIME type of the item.
+		* @param		aMimeVer			MIME version used on item.
+		* @param		aStatus				On completion of the creating an
+		*                                   item, contains the result code.
+		*/
+	    void DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize,
+	                    TSmlDbItemUid aParent, const TDesC8& aMimeType,
+                        const TDesC8& aMimeVer, TRequestStatus& aStatus );
+
+		/**
+		* Opens the data item specified by aUid asynchronously to be updated.
+		* @param		aUid				Item UID which going to be updated.
+		* @param		aSize				Size of the item data.
+		* @param		aParent				Parent of the item.
+		* @param		aFieldChange		Accept field changes.
+		* @param		aStatus				On completion of the updating of
+		*                                   item, contains the result code.
+		*/
+	    void DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize,
+                        TSmlDbItemUid aParent, TBool aFieldChange,
+                        TRequestStatus& aStatus );
+
+		/**
+		* Reads data(or size of aBuffer) of an item opened in DoOpenItemL()
+		* to given aBuffer.
+		* @param		aBuffer				Buffer to item data.
+		*/
+	    void DoReadItemL( TDes8& aBuffer );
+
+		/**
+		* Writes aData of an item opened in DoCreateItemL() or DoReplaceItemL()
+		*  to be saved on database.
+		* @param		aData				Item data (or part of data).
+		*/
+	    void DoWriteItemL( const TDesC8& aData );
+
+		/**
+		* Completes an item operation started in DoCreateItemL() or
+		* DoReplaceItemL().
+		* @param		aStatus				On completion of the operation,
+		*                                   contains the result code.
+		*/
+	    void DoCommitItemL( TRequestStatus& aStatus );
+
+		/**
+		* Completes an item operation started in DoOpenItemL().
+		*/
+	    void DoCloseItem();
+
+		/**
+		* Moves item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be moved.
+		* @param		aNewParent			A new parent of the item.
+		* @param		aStatus				On completion of the moving an
+		*                                   item, contains the result code.
+		*/
+	    void DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus );
+
+		/**
+		* Deletes item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be deleted.
+		* @param		aStatus				On completion of the deleting an
+		*                                   item, contains the result code.
+		*/
+	    void DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
+
+		/**
+		* Softdeletes item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be
+		*                                   softdeleted.
+		* @param		aStatus				On completion of the softdeleting
+		*                                   an item, contains the result code.
+		*/
+	    void DoSoftDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
+
+		/**
+		* Deletes all items from opened database asynchronously.
+		* @param		aStatus				On completion of delete, contains
+		*                                   the result code.
+		*/
+	    void DoDeleteAllItemsL( TRequestStatus& aStatus );
+
+		/**
+		* Check if previous sync with opened server and context.
+		*/
+	    TBool DoHasSyncHistory() const;
+
+		/**
+		* Get all added items on client since previous synchronization.
+		*/
+	    const MSmlDataItemUidSet& DoAddedItems() const;
+
+		/**
+		* Get all deleted items on client since previous synchronization.
+		*/
+	    const MSmlDataItemUidSet& DoDeletedItems() const;
+
+		/**
+		* Get all softdeleted items on client since previous synchronization.
+		*/
+	    const MSmlDataItemUidSet& DoSoftDeletedItems() const;
+
+		/**
+		* Get all modified items on client since previous synchronization.
+		*/
+	    const MSmlDataItemUidSet& DoModifiedItems() const;
+
+		/**
+		* Get all moved items on client since previous synchronization.
+		*/
+	    const MSmlDataItemUidSet& DoMovedItems() const;
+
+		/**
+		* Resets client synchronization data => next time will be slow sync.
+		* @param		aStatus				On completion of reset, contains
+		*                                   the result code.
+		*/
+	    void DoResetChangeInfoL( TRequestStatus& aStatus );
+
+		/**
+		* Commits client synchronization changes for given aItems list.
+		* @param		aStatus				On completion of given items,
+		*                                   contains the result code.
+		* @param		aItems				Item ids to be commited.
+		*/
+	    void DoCommitChangeInfoL( TRequestStatus& aStatus,
+	                    const MSmlDataItemUidSet& aItems );
+
+		/**
+		* Commits all client synchronization changes.
+		* @param		aStatus				On completion of all items,
+		*                                   contains the result code.
+		*/
+	    void DoCommitChangeInfoL( TRequestStatus& aStatus );
+
+        /**
+        * Registers current snapshot.
+        */
+	    void RegisterSnapshotL();
+	    
+	    /**
+        * Creates new snapshot. Method gets data from database.
+        * @param	aUid    UID of item.
+        * @return   New snapshot based on item with given UID
+        */
+	    TNSmlSnapshotItem CreateSnapshotItemL( const TCalLocalUid& aUid );
+
+        /**
+        * Second phase constructor.
+        */
+	    void ConstructL();
+
+        /**
+        * Returns ETrue if indicated entry can be syncronized.
+        */
+		TBool CanBeSynchronized(
+		       const CCalEntry::TReplicationStatus& aReplicationStatus ) const;
+
+	    /**
+		* Completes an item operation started in DoCreateItemL().
+		*/
+	    void DoCommitCreateItemL();
+	    
+	    /**
+		* Completes an item operation started in DoReplaceItemL().
+		*/
+	    void DoCommitReplaceItemL();
+	    
+	    /**
+		* Gets property from old item.
+		* @param	aOldItem        Data of old item.
+		* @param	aValue          Value of searched property.
+		* @param	aProperty       Property that is searched.
+		*/
+	    void GetPropertiesFromDataL( CBufFlat* aOldItem,
+	                                 HBufC8*& aValue,
+	                                 const TDesC8& aProperty );
+	                                         
+        /**
+		* Adds property and it's value to new item.
+		* This method also removes original property and it's value.
+		* @param	aValue          Value of added property.
+		* @param	aProperty       Property that is added.
+		*/
+	    void SetPropertiesToDataL( HBufC8*& aValue,
+	                               const TDesC8& aProperty );
+        
+
+    private: // Data
+        // Key
+	    TKeyArrayFix iKey;
+        // Position of buffer
+	    TInt iPos;
+        // Flag if Synchronization history is available or not
+	    TBool iHasHistory;
+        // Modification count
+	    TInt iModificationCount;
+        // Internal state of this class
+	    TNSmlDataStoreStatus iState;
+        // Flag if SnapshotRegistered is registered or not
+	    TBool iSnapshotRegistered;
+        // Drive letter
+	    TInt iDrive;
+        // Item's ID that is to be replaced
+	    TInt iReplaceItemId;
+        // Internal entry type for received item
+	    TNSmlDataEntryType iRXEntryType;
+	    // Internal entry type for transmitted item
+	    TNSmlDataEntryType iTXEntryType;
+        // ChangeFinder
+	    CNSmlChangeFinder* iChangeFinder;
+        // DataModel
+	    CNSmlDataModBase* iDataMod;
+        // Status code from functions
+	    TRequestStatus* iCallerStatus;
+        // A handle to a file server session
+	    RFs iRfs;
+        // ServerMaxObjectSize
+	    TInt iServerMaxObjectSize;
+        // Name of the opened database
+	    HBufC* iOpenedStoreName;
+        // Default name of the database
+	    HBufC* iDefaultStoreName;
+        // Opened database ID
+	    TInt64 iOpenedStoreId;
+        // Item's ID that is to be added
+	    TInt* iAddItemId;
+        // Item's data that is to be written
+	    CBufBase* iItemData;
+        // Own store format
+	    CSmlDataStoreFormat* iOwnFormat;
+        // StringPool
+	    RStringPool iStringPool;
+        // Uids of new items
+	    CNSmlDataItemUidSet* iNewUids;
+        // Uids of deleted items
+	    CNSmlDataItemUidSet* iDeletedUids;
+        // Uids of softdeleted items
+	    CNSmlDataItemUidSet* iSoftDeletedUids;
+        // Uids of replaced items
+	    CNSmlDataItemUidSet* iReplacedUids;
+        // Uids of moved items
+	    CNSmlDataItemUidSet* iMovedUids;
+        // Session to calendar server
+	    CCalSession* iVCalSession;
+        // Internal progress notifier
+	    CNSmlAgendaProgressview* iAgendaProgressview;
+	    // Interim Utility
+	    CCalenInterimUtils2* iInterimUtils;
+	    
+        // Importer
+	    CCalenImporter* iImporter;
+	    // Exporter
+	    CCalenExporter* iExporter;
+	    
+	    // Entry view
+        CCalEntryView* iEntryView;
+        CVersitTlsData *iVersitTlsData; // for better performance
+	};
+
+#endif // __NSMLAGENDADATASTORE_H__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/inc/nsmlagendadefines.hrh	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Defines for DS agenda adapter
+*
+*/
+
+
+
+// DEFINES
+#ifdef RD_DS_ICAL_SUPPORT
+#ifdef __I_CAL_SUPPORT
+#define __NSML_USE_ICAL_FEATURE
+#endif // __I_CAL_SUPPORT
+
+#endif
+
+#ifdef __NSML_DEBUG__ 
+#define __NSML_MORE_DEBUG_FOR_ITEMS__	// If this flag is defined
+					                    // then debug dumb includes
+					                    // old item and new data at replace
+    				                    // commands
+#endif // __NSML_DEBUG__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/loc/101F6DD7.loc	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  loc file for DS agenda adapter
+*
+*/
+
+
+//d:Display name for registry info 
+//l:list_setting_pane_t1
+//
+#define qtn_nsml_agn_display_name "Calendar"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/101F6DD7.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  rss file for DS agenda adapter
+*
+*/
+
+
+#include<101F6DD7.loc>
+
+#include <registryinfo.rh>
+#include <nsmldsconstants.h>
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101F6DDE;
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDSInterfaceUid; // DS interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101F6DDE; // DS interface implementation UID
+                version_no = 1; 
+                display_name = qtn_nsml_agn_display_name;
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/NSmlAgendaDataStore_1_1_2.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,888 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Resource data for DS agenda adapter
+*
+*/
+
+
+#include <bldvariant.hrh>
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+#include "nsmlagendadefines.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT nsml_agenda_data_store
+	{
+	version=1;
+	display_name="Calendar";
+	sync_types=KSmlSyncType_TwoWay+KSmlSyncType_OneWayFromSvr+
+	           KSmlSyncType_OneWayFromClnt+KSmlSyncType_SlowSync+
+	           KSmlSyncType_RefreshFromSvr+KSmlSyncType_RefreshFromClnt;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/x-vcalendar";
+			mime_ver="1.0";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";	
+					data_type="";
+					enum_values={"1.0"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Uid";
+					name="UID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Summary";
+					name="SUMMARY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Description";
+					name="DESCRIPTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dstart";
+					name="DTSTART";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dtend";
+					name="DTEND";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Aalarm";
+					name="AALARM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Location";
+					name="LOCATION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Last Modified";
+					name="LAST-MODIFIED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Priority";
+					name="PRIORITY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Status";
+					name="STATUS";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Rrule";
+					name="RRULE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Completed";
+					name="COMPLETED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dcreated";
+					name="DCREATED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Due";
+					name="DUE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ExDate";
+					name="EXDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Categories";
+					name="CATEGORIES";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sequence";
+					name="SEQUENCE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="TZ";
+					name="TZ";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Daylight";
+					name="DAYLIGHT";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="RDate";
+					name="RDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Attendee";
+					name="ATTENDEE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Role";
+								name="ROLE";
+								data_type="";
+								enum_values={};
+								},
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Status";
+								name="STATUS";
+								data_type="";
+								enum_values={};
+								},
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="X-CN";
+								name="X-CN";
+								data_type="";
+								enum_values={};
+								},
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Role";
+								name="X-ROLE";
+								data_type="";
+								enum_values={};
+								},
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Sent by";
+								name="X-SENTBY";
+								data_type="";
+								enum_values={};
+								},
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Sent by";
+								name="X-STATUS";
+								data_type="";
+								enum_values={};
+								}
+							};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Recurrence";
+					name="X-RECURRENCE-ID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Method";
+					name="X-METHOD";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Local UID";
+					name="X-SYMBIAN-LUID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Time stamp";
+					name="X-SYMBIAN-DTSTAMP";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="X-Epoc Agenda Entry Type";
+					name="X-EPOCAGENDAENTRYTYPE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					}
+				};
+			field_level=0;
+			}
+#ifdef __NSML_USE_ICAL_FEATURE
+			,
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/calendar";
+			mime_ver="2.0";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO","STANDARD","DAYLIGHT","VTIMEZONE","VALARM"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO","STANDARD","DAYLIGHT","VTIMEZONE","VALARM"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";	
+					data_type="";
+					enum_values={"2.0"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Uid";
+					name="UID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Summary";
+					name="SUMMARY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Description";
+					name="DESCRIPTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dstart";
+					name="DTSTART";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dtend";
+					name="DTEND";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Aalarm";
+					name="AALARM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Location";
+					name="LOCATION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Last Modified";
+					name="LAST-MODIFIED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Priority";
+					name="PRIORITY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Status";
+					name="STATUS";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Recurrence-Id";
+					name="RECURRENCE-ID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Rrule";
+					name="RRULE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sequence";
+					name="SEQUENCE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Method";
+					name="METHOD";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ATTENDEE";
+					name="ATTENDEE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Categories";
+					name="CATEGORIES";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Organizer";
+					name="ORGANIZER";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Time stamp";
+					name="DTSTAMP";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Completed";
+					name="COMPLETED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Created";
+					name="CREATED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ExDate";
+					name="EXDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="RDate";
+					name="RDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Product ID";
+					name="PRODID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone ID";
+					name="TZID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone OFFSET from";
+					name="TZOFFSETFROM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone OFFSET to";
+					name="TZOFFSETTO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Alarm action";
+					name="ACTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Alarm trigger";
+					name="TRIGGER";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					}
+				};
+			field_level=0;
+			}
+#endif // __NSML_USE_ICAL_FEATURE
+		};
+#ifdef __NSML_USE_ICAL_FEATURE
+	mime_format_tx_pref=1;     // Preferred index for tx
+	mime_format_rx_pref=1;     // Preferred index for rx
+#else // __NSML_USE_ICAL_FEATURE
+  mime_format_tx_pref=0;     // Preferred index for tx
+	mime_format_rx_pref=0;     // Preferred index for rx
+#endif // __NSML_USE_ICAL_FEATURE
+	folder_properties={};
+	filter_capabilities={};
+	max_size=0; 	// no limit
+	max_items=0; 	// no limit
+	flags=0;
+	}
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/NSmlAgendaDataStore_1_2.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,866 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Resource data for DS agenda adapter
+*
+*/
+
+
+#include <bldvariant.hrh>
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+#include "nsmlagendadefines.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT nsml_agenda_data_store
+	{
+	version=1;
+	display_name="Calendar";
+	sync_types=KSmlSyncType_TwoWay+KSmlSyncType_OneWayFromSvr+
+	           KSmlSyncType_OneWayFromClnt+KSmlSyncType_SlowSync+
+	           KSmlSyncType_RefreshFromSvr+KSmlSyncType_RefreshFromClnt;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/x-vcalendar";
+			mime_ver="1.0";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";	
+					data_type="";
+					enum_values={"1.0"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Uid";
+					name="UID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Summary";
+					name="SUMMARY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Description";
+					name="DESCRIPTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dstart";
+					name="DTSTART";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dtend";
+					name="DTEND";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Aalarm";
+					name="AALARM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Alarm type";
+								name="TYPE";
+								data_type="";
+								enum_values={};
+								}
+							};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Location";
+					name="LOCATION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Last Modified";
+					name="LAST-MODIFIED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Priority";
+					name="PRIORITY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Status";
+					name="STATUS";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Rrule";
+					name="RRULE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Completed";
+					name="COMPLETED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dcreated";
+					name="DCREATED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Due";
+					name="DUE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ExDate";
+					name="EXDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Categories";
+					name="CATEGORIES";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sequence";
+					name="SEQUENCE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+		                SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="TZ";
+					name="TZ";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+         		       SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Daylight";
+					name="DAYLIGHT";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="RDate";
+					name="RDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Attendee";
+					name="ATTENDEE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Type";
+								name="TYPE";
+								data_type="";
+								enum_values={"ROLE", "STATUS", "X-CN", "X-ROLE", "X-SENTBY", "X-STATUS"};
+								}
+							};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Recurrence";
+					name="X-RECURRENCE-ID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Method";
+					name="X-METHOD";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                		SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Local UID";
+					name="X-SYMBIAN-LUID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+                		SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Time stamp";
+					name="X-SYMBIAN-DTSTAMP";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="X-Epoc Agenda Entry Type";
+					name="X-EPOCAGENDAENTRYTYPE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					}
+				};
+			field_level=0;
+			}
+#ifdef __NSML_USE_ICAL_FEATURE
+			,
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/calendar";
+			mime_ver="2.0";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO","STANDARD","DAYLIGHT","VTIMEZONE","VALARM"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCALENDAR","VEVENT","VTODO","STANDARD","DAYLIGHT","VTIMEZONE","VALARM"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";	
+					data_type="";
+					enum_values={"2.0"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Uid";
+					name="UID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Summary";
+					name="SUMMARY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Description";
+					name="DESCRIPTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dstart";
+					name="DTSTART";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Dtend";
+					name="DTEND";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Aalarm";
+					name="AALARM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params= {
+							SML_DATA_PROPERTY_PARAM
+								{
+								version=1;
+								display_name="Alarm type";
+								name="TYPE";
+								data_type="";
+								enum_values={};
+								}
+							};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Location";
+					name="LOCATION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Last Modified";
+					name="LAST-MODIFIED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Priority";
+					name="PRIORITY";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Status";
+					name="STATUS";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Recurrence-Id";
+					name="RECURRENCE-ID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Rrule";
+					name="RRULE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sequence";
+					name="SEQUENCE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Method";
+					name="METHOD";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ATTENDEE";
+					name="ATTENDEE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Categories";
+					name="CATEGORIES";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Organizer";
+					name="ORGANIZER";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Time stamp";
+					name="DTSTAMP";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Completed";
+					name="COMPLETED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Created";
+					name="CREATED";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="ExDate";
+					name="EXDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="RDate";
+					name="RDATE";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Product ID";
+					name="PRODID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone ID";
+					name="TZID";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone OFFSET from";
+					name="TZOFFSETFROM";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Timezone OFFSET to";
+					name="TZOFFSETTO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Alarm action";
+					name="ACTION";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Alarm trigger";
+					name="TRIGGER";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					}
+				};
+			field_level=0;
+			}
+#endif // __NSML_USE_ICAL_FEATURE
+		};
+#ifdef __NSML_USE_ICAL_FEATURE
+	mime_format_tx_pref=1;     // Preferred index for tx
+	mime_format_rx_pref=1;     // Preferred index for rx
+#else // __NSML_USE_ICAL_FEATURE
+  mime_format_tx_pref=0;     // Preferred index for tx
+	mime_format_rx_pref=0;     // Preferred index for rx
+#endif // __NSML_USE_ICAL_FEATURE
+	folder_properties={};
+	filter_capabilities={};
+	max_size=0; 	// no limit
+	max_items=0; 	// no limit
+	flags=0;
+	}
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/nsmlagendadataprovider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,307 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS agenda data provider
+*
+*/
+
+
+// INCLUDE FILES
+#include "nsmlagendadataprovider.h"
+#include "nsmlagendadatastore.h"
+#include "nsmldebug.h"
+#include "nsmldsimpluids.h"
+#include <SmlDataProvider.h>
+#include <ecom.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <NSmlAgendaDataStore_1_1_2.rsg>
+#include <NSmlAgendaDataStore_1_2.rsg>
+#include <SmlDataFormat.h>
+#include <implementationproxy.h>
+#include <data_caging_path_literals.hrh>
+#include <e32property.h>
+#include <DataSyncInternalPSKeys.h>
+
+// ====================================== MEMBER FUNCTIONS ========================================
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::CNSmlAgendaDataProvider
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ------------------------------------------------------------------------------------------------
+//
+CNSmlAgendaDataProvider::CNSmlAgendaDataProvider()
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::CNSmlAgendaDataProvider(): BEGIN");
+	_DBG_FILE("CNSmlAgendaDataProvider::CNSmlAgendaDataProvider(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ------------------------------------------------------------------------------------------------
+//
+void CNSmlAgendaDataProvider::ConstructL( )
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN");
+	iAgnDataStore = CNSmlAgendaDataStore::NewL();
+	iStringPool.OpenL();
+	User::LeaveIfError( iSession.Connect() );
+	_DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::NewL
+// Two-phased constructor.
+// ------------------------------------------------------------------------------------------------
+//
+CNSmlAgendaDataProvider* CNSmlAgendaDataProvider::NewL()
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN");
+	CNSmlAgendaDataProvider* self = new ( ELeave ) CNSmlAgendaDataProvider();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	_DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN");
+	return self;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider
+// Destructor.
+// ------------------------------------------------------------------------------------------------
+//
+CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider()
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider(): BEGIN");
+	delete iAgnDataStore;
+	iSession.Close();
+	delete iDSFormat;
+	iStringPool.Close();
+	iFilterArray.ResetAndDestroy();
+	iFilterArray.Close();
+	_DBG_FILE("CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoOnFrameworkEvent
+// Not supported.
+// ------------------------------------------------------------------------------------------------
+//
+void CNSmlAgendaDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent /*aEvent*/, TInt /*aParam1*/, TInt /*aParam2*/ )
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoOnFrameworkEvent: BEGIN");
+	_DBG_FILE("CNSmlAgendaDataProvider::DoOnFrameworkEvent: END");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoSupportsOperation
+// Return supported operation uid.
+// ------------------------------------------------------------------------------------------------
+//
+TBool CNSmlAgendaDataProvider::DoSupportsOperation( TUid aOpId ) const
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: BEGIN");
+	if ( aOpId == KUidSmlSupportMultipleStores )
+		{
+		_DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: END");
+		return ETrue;
+		}
+	_DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: END");
+	return EFalse;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoStoreFormatL
+// Return the current data store format.
+// ------------------------------------------------------------------------------------------------
+//
+const CSmlDataStoreFormat& CNSmlAgendaDataProvider::DoStoreFormatL()
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoStoreFormatL(): BEGIN");
+	
+	if ( iDSFormat )
+		{
+       	delete iDSFormat;
+       	iDSFormat = NULL;
+		}
+	iDSFormat = DoOwnStoreFormatL();
+	
+    return *iDSFormat;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoListStoresLC
+// Return the list of datastore names.
+// ------------------------------------------------------------------------------------------------
+//
+CDesCArray* CNSmlAgendaDataProvider::DoListStoresLC()
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoListStoresLC(): BEGIN");
+	_DBG_FILE("CNSmlAgendaDataProvider::DoListStoresLC(): END");
+	return iAgnDataStore->DoListAgendaFilesLC();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoDefaultStoreL
+// Return the name of default store name.
+// ------------------------------------------------------------------------------------------------
+//
+const TDesC& CNSmlAgendaDataProvider::DoDefaultStoreL()
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoDefaultStoreL(): BEGIN");
+	_DBG_FILE("CNSmlAgendaDataProvider::DoDefaultStoreL(): END");
+	return iAgnDataStore->DoGetDefaultFileNameL();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoNewStoreInstanceLC
+// Return instance of data store
+// ------------------------------------------------------------------------------------------------
+//
+CSmlDataStore* CNSmlAgendaDataProvider::DoNewStoreInstanceLC()
+    {
+	_DBG_FILE("CNSmlAgendaDataProvider::DoNewStoreInstanceLC(): BEGIN");
+	CNSmlAgendaDataStore* newStore = CNSmlAgendaDataStore::NewL();
+	CleanupStack::PushL( newStore );
+	_DBG_FILE("CNSmlAgendaDataProvider::DoNewStoreInstanceLC(): END");
+	return newStore;
+    } 
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoSupportedServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+const RPointerArray<CSyncMLFilter>& CNSmlAgendaDataProvider::DoSupportedServerFiltersL()
+	{
+	// This method returns empty array. It means that this Data Provider does not support filtering
+	_DBG_FILE("CNSmlAgendaDataProvider::DoSupportedServerFiltersL(): BEGIN");
+	_DBG_FILE("CNSmlAgendaDataProvider::DoSupportedServerFiltersL(): END");
+	return iFilterArray;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::CheckServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlAgendaDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::DoCheckServerFiltersL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataProvider::DoCheckServerFiltersL(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC
+// 
+// ------------------------------------------------------------------------------------------------
+HBufC* CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC(): END");
+	return NULL;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ )
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlAgendaDataProvider::DoOwnStoreFormatL
+// Read own store format from own resource file.
+// ------------------------------------------------------------------------------------------------
+//
+CSmlDataStoreFormat* CNSmlAgendaDataProvider::DoOwnStoreFormatL()
+	{
+	_DBG_FILE("CNSmlAgendaDataProvider::DoOwnStoreFormatL(): BEGIN");
+	TFileName fileName;
+	TParse parse;
+
+    // Check correct Data Sync protocol
+	TInt value( EDataSyncNotRunning );
+	TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                 KDataSyncStatus,
+                                 value );
+	if ( error == KErrNone &&
+	     value == EDataSyncRunning )
+	    {
+	    parse.Set( KNSmlDSAgendaDataStoreRsc_1_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
+	    }
+	else // error or protocol version 1.2 
+	    {
+	    parse.Set( KNSmlDSAgendaDataStoreRsc_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
+	    }		
+	
+	fileName = parse.FullName();
+	RResourceFile resourceFile;
+	BaflUtils::NearestLanguageFile( iSession, fileName );
+
+	resourceFile.OpenL( iSession, fileName );
+	CleanupClosePushL( resourceFile );
+
+	HBufC8* profileRes = resourceFile.AllocReadLC( NSML_AGENDA_DATA_STORE );
+	TResourceReader reader;
+	reader.SetBuffer( profileRes );
+
+	CSmlDataStoreFormat* dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+	CleanupStack::Pop(); // dsFormat
+	CleanupStack::PopAndDestroy( 2 ); // profileRes, resourceFile
+	_DBG_FILE("CNSmlAgendaDataProvider::DoOwnStoreFormatL(): END");
+	return dsFormat;
+	}
+
+// =================================== OTHER EXPORTED FUNCTIONS ===================================
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr ) { { aUid }, ( aFuncPtr ) }
+#endif
+
+const TImplementationProxy ImplementationTable[] = 
+    {
+	IMPLEMENTATION_PROXY_ENTRY( KNSmlAgendaAdapterImplUid, CNSmlAgendaDataProvider::NewL )
+    };
+
+// ------------------------------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Framework needs this.
+// ------------------------------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+	_DBG_FILE("ImplementationGroupProxy() for CNSmlAgendaDataProvider: begin");
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+	_DBG_FILE("ImplementationGroupProxy() for CNSmlAgendaDataProvider: end");
+    return ImplementationTable;
+	}
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1770 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS agenda data store
+*
+*/
+
+
+
+// INCLUDES
+#include "nsmldebug.h"
+#include "nsmlagendadatastore.h"
+#include "nsmlagendadataprovider.h"
+#include "nsmlchangefinder.h"
+#include "NSmlDataModBase.h"
+#include "nsmlagendadefines.hrh"
+#include <ecom.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <calsession.h> 
+#include <caldataexchange.h> 
+#include <calentryview.h>
+#include <caliterator.h>
+#include <calentry.h>
+#include <caldataformat.h>
+#include <caltime.h>
+#include <nsmldsimpluids.h>
+#include <sysutil.h>
+#include <SmlDataProvider.h>
+#include <SmlDataFormat.h>
+#include <SmlDataSyncDefs.h>
+#include <data_caging_path_literals.hrh>
+#include <NSmlAgendaDataStore_1_1_2.rsg>
+#include <NSmlAgendaDataStore_1_2.rsg>
+#include <e32property.h>
+#include <DataSyncInternalPSKeys.h>
+#include <CalenImporter.h>
+#include <CalenInterimUtils2.h>
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+// ============================= MEMBER FUNCTIONS ==============================
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::CNSmlAgendaDataStore
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNSmlAgendaDataStore::CNSmlAgendaDataStore() :
+	iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem, ItemId() ), ECmpTInt ) ),
+	iPos( -1 ),
+	iHasHistory( EFalse ),
+	iModificationCount( KNSmlCompactAfterChanges ),
+	iState( ENSmlClosed ),
+	iSnapshotRegistered( EFalse ),
+	iDrive( -1 ),
+	iReplaceItemId( -1 ),
+	iRXEntryType( ENSmlNotSet ),
+	iTXEntryType( ENSmlNotSet )
+	{
+	_DBG_FILE("CNSmlAgendaDataStore::CNSmlAgendaDataStore(): BEGIN");
+	_DBG_FILE("CNSmlAgendaDataStore::CNSmlAgendaDataStore(): END");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::ConstructL()
+	{
+	_DBG_FILE("CNSmlAgendaDataStore::ConstructL: BEGIN");
+
+	iStringPool.OpenL();
+	User::LeaveIfError( iRfs.Connect() );
+
+	iDataMod = new ( ELeave ) CNSmlVCalMod();
+	
+	iNewUids = new ( ELeave ) CNSmlDataItemUidSet();
+	iDeletedUids = new ( ELeave ) CNSmlDataItemUidSet();
+	iSoftDeletedUids = new ( ELeave ) CNSmlDataItemUidSet();
+	iMovedUids = new ( ELeave ) CNSmlDataItemUidSet();
+	iReplacedUids = new ( ELeave ) CNSmlDataItemUidSet();
+	
+	iDefaultStoreName = HBufC::NewL( KNSmlDefaultStoreNameMaxSize );
+	
+	iVersitTlsData = &CVersitTlsData::VersitTlsDataL();
+	// Create CalSession and CalEntryView instances
+	iVCalSession = CCalSession::NewL();
+	
+	TPtr obptr = iDefaultStoreName->Des();
+	obptr = iVCalSession->DefaultFileNameL(); 
+
+	iOwnFormat = DoOwnStoreFormatL();
+	iDataMod->SetOwnStoreFormat( *iOwnFormat );
+	
+    iInterimUtils = CCalenInterimUtils2::NewL();
+	
+	_DBG_FILE("CNSmlAgendaDataStore::ConstructL: END");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlAgendaDataStore* CNSmlAgendaDataStore::NewL()
+	{
+	_DBG_FILE("CNSmlAgendaDataStore::NewL: BEGIN");
+	
+	CNSmlAgendaDataStore* self = new ( ELeave ) CNSmlAgendaDataStore();
+	CleanupStack::PushL( self );
+	
+	self->ConstructL();
+	CleanupStack::Pop(); // self
+	
+	_DBG_FILE("CNSmlAgendaDataStore::NewL: END");
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::~CNSmlAgendaDataStore
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlAgendaDataStore::~CNSmlAgendaDataStore()
+	{
+	_DBG_FILE("CNSmlAgendaDataStore::~CNSmlAgendaDataStore(): BEGIN");
+
+    // Enable notifications
+    TInt error( KErrNone );
+    if ( iVCalSession )
+        {
+        TRAP_IGNORE( iVCalSession->EnablePubSubNotificationsL() );
+        TRAP_IGNORE( iVCalSession->EnableChangeBroadcast() );
+        }
+
+	delete iOwnFormat;
+	iRfs.Close();
+	iStringPool.Close();
+	
+    if ( iChangeFinder )
+		{
+		TRAP( error, iChangeFinder->CloseL() );
+		}
+	if (iVersitTlsData)
+			{
+			iVersitTlsData->VersitTlsDataClose();
+			}
+	delete iChangeFinder;
+	delete iNewUids;
+	delete iDeletedUids;
+	delete iSoftDeletedUids;
+	delete iMovedUids;
+	delete iReplacedUids;
+
+    delete iDefaultStoreName;
+    delete iOpenedStoreName;
+	delete iDataMod;
+	delete iItemData;
+
+    delete iAgendaProgressview;
+    
+	delete iImporter;
+    delete iExporter;
+    
+    delete iEntryView;
+    delete iVCalSession;
+    delete iInterimUtils;
+    
+    
+    // REComSession::FinalClose();
+	
+	_DBG_FILE("CNSmlAgendaDataStore::~CNSmlAgendaDataStore(): END");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoOpenL
+// Open calendar database for access.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoOpenL( const TDesC& aStoreName,
+                MSmlSyncRelationship& aContext, TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoOpenL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlClosed )
+		{
+		User::RequestComplete( iCallerStatus, KErrInUse );
+		return;
+		}
+
+	if( RFs::CharToDrive( aStoreName[0], iDrive ) != KErrNone )
+		{
+		RFs::CharToDrive( KNSmlDriveC()[0], iDrive );
+		}
+    
+    // Open database
+	TInt err( KErrNone );	
+	if ( aStoreName == KNSmlAgendaStoreNameForDefaultDB )
+		{
+		TRAP( err, iVCalSession->OpenL( *iDefaultStoreName ) );
+		}
+    else 
+    	{
+    	TRAP( err, iVCalSession->OpenL( aStoreName ) );
+    	}
+	if ( err )
+	    {
+	    User::RequestComplete( iCallerStatus, err );
+	    return;
+	    }
+	
+	// Disable notifications
+	TRAP_IGNORE( iVCalSession->DisablePubSubNotificationsL() );
+	TRAP_IGNORE( iVCalSession->DisableChangeBroadcast() );
+	    
+	if ( iOpenedStoreName )
+		{
+		delete iOpenedStoreName;
+		iOpenedStoreName = NULL;
+		}
+	iOpenedStoreName = aStoreName.AllocL();
+	
+	// Initialize some member variables
+	// Create importer and exporter
+    iImporter = CCalenImporter::NewL( *iVCalSession );
+	iExporter = CCalenExporter::NewL( *iVCalSession );
+
+    // Progress view
+	iAgendaProgressview = CNSmlAgendaProgressview::NewL();
+
+    iEntryView = CCalEntryView::NewL( *iVCalSession, *iAgendaProgressview );
+    CActiveScheduler::Start();
+    TInt completedStatus = iAgendaProgressview->GetCompletedStatus();
+    if ( completedStatus != KErrNone )
+        {
+        User::RequestComplete( iCallerStatus, completedStatus );
+        return;
+        }
+
+	if ( iChangeFinder )
+		{
+		iChangeFinder->CloseL();
+		delete iChangeFinder;
+		iChangeFinder = NULL;
+		}
+	iChangeFinder = CNSmlChangeFinder::NewL( aContext, iKey, iHasHistory,
+	                                         KNSmlAgendaAdapterImplUid );
+    
+    // Get ID of database
+	iVCalSession->FileIdL( iOpenedStoreId );
+	
+	if( !iSnapshotRegistered )
+		{
+		RegisterSnapshotL();
+		}
+     	
+	iState = ENSmlOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, err );
+	    
+	_DBG_FILE("CNSmlAgendaDataStore::DoOpenL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCancelRequest
+// Set internal module state to previous state.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCancelRequest()
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCancelRequest: BEGIN");
+    if ( iState == ENSmlOpenAndWaiting )
+        {
+    	iState = ENSmlClosed;
+        }
+    else
+        {
+	    iState = ENSmlOpenAndWaiting;
+        }
+	_DBG_FILE("CNSmlAgendaDataStore::DoCancelRequest: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoStoreName
+// Returns previously opened database name.
+// -----------------------------------------------------------------------------
+//
+const TDesC& CNSmlAgendaDataStore::DoStoreName() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoStoreName: BEGIN");
+	_DBG_FILE("CNSmlAgendaDataStore::DoStoreName: END");
+	return *iOpenedStoreName;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoBeginTransactionL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoBeginTransactionL()
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoBeginTransactionL: BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoBeginTransactionL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitTransactionL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitTransactionL( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitTransactionL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitTransactionL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoRevertTransaction
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoRevertTransaction( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoRevertTransaction: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoRevertTransaction: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoBeginBatchL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoBeginBatchL()
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoBeginBatchL: BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoBeginBatchL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitBatchL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitBatchL( RArray<TInt>& /*aResultArray*/,
+                TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitBatchL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitBatchL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCancelBatch
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCancelBatch()
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCancelBatch: BEGIN");
+	// Nothing to do
+	_DBG_FILE("CNSmlAgendaDataStore::DoCancelBatch: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoSetRemoteStoreFormatL
+// Set SyncML Remote Server data store format.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoSetRemoteStoreFormatL(
+                const CSmlDataStoreFormat& aServerDataStoreFormat )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: BEGIN");
+	
+	if ( iOwnFormat )
+	    {
+	    delete iOwnFormat;
+	    iOwnFormat = NULL;    
+	    }
+	
+	iOwnFormat = DoOwnStoreFormatL();
+	iDataMod->SetOwnStoreFormat( *iOwnFormat );
+	
+    iDataMod->SetPartnerStoreFormat( ( CSmlDataStoreFormat& )
+                aServerDataStoreFormat );
+    
+    // Check which calendar type (vCal/iCal) is used
+    // If server supports iCal then it is used
+    // Otherwise vCal is used
+    TInt returnValue( KErrNotSupported );
+
+#ifdef __NSML_USE_ICAL_FEATURE
+
+    _DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: Support iCal");
+   	returnValue = iDataMod->SetUsedMimeType(
+       	    iOwnFormat->MimeFormat( 1 ).MimeType(),
+           	iOwnFormat->MimeFormat( 1 ).MimeVersion() );
+
+#endif // __NSML_USE_ICAL_FEATURE
+
+    if ( returnValue == KErrNone )
+        {
+        _DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: Sets iCal");
+        iRXEntryType = ENSmlICal;
+        iTXEntryType = ENSmlICal;
+        }
+    else
+        {
+        _DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: Support vCal");
+        returnValue = iDataMod->SetUsedMimeType(
+            iOwnFormat->MimeFormat( 0 ).MimeType(),
+            iOwnFormat->MimeFormat( 0 ).MimeVersion() );
+        if ( returnValue == KErrNone )
+            {
+            _DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: Sets vCal");
+            iRXEntryType = ENSmlVCal;
+            iTXEntryType = ENSmlVCal;
+            }
+        }
+    if ( iRXEntryType == ENSmlNotSet || iTXEntryType == ENSmlNotSet )
+        {
+        // Leave if server does not support either vCal or iCal
+        _DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: MimeType Not supported");
+        User::Leave( KErrNotFound );        
+        }
+    
+	_DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteStoreFormatL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoSetRemoteMaxObjectSize
+// Set SyncML Remote Server maximum object size.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteMaxObjectSize: BEGIN");
+	iServerMaxObjectSize = aServerMaxObjectSize;
+	_DBG_FILE("CNSmlAgendaDataStore::DoSetRemoteMaxObjectSize: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoMaxObjectSize
+// Set SyncML Component maximum object size.
+// -----------------------------------------------------------------------------
+//
+TInt CNSmlAgendaDataStore::DoMaxObjectSize() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoMaxObjectSize: BEGIN");
+	_DBG_FILE("CNSmlAgendaDataStore::DoMaxObjectSize - Default: END");
+	return KNSmlAgendaOwnMaxObjectSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoOpenItemL
+// Open calendar item for reading.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange,
+                TInt& aSize, TSmlDbItemUid& /*aParent*/, TDes8& aMimeType,
+                TDes8& aMimeVer, TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoOpenItemL: BEGIN");
+    iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+		
+ 	iReplaceItemId = aUid;
+ 	
+	CCalEntry* entry = NULL;
+	TInt err( KErrNone );
+    TRAP( err, entry = iEntryView->FetchL( aUid ) );
+	CleanupStack::PushL( entry );
+	
+	if ( err || !entry )
+		{
+		CleanupStack::PopAndDestroy( entry ); // entry
+		User::RequestComplete( iCallerStatus, KErrNotFound );
+		return;
+		}
+		
+	if ( !iSnapshotRegistered )
+		{
+		RegisterSnapshotL();
+		}
+	delete iItemData;
+	iItemData = NULL;
+	iItemData = CBufFlat::NewL( KNSmlItemDataExpandSize );
+
+	RBufWriteStream writeStream( *iItemData );
+	writeStream.PushL();
+	
+	// Export item from database
+	if ( iTXEntryType == ENSmlICal )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoOpenItemL: Export - iCal DB");
+	    iExporter->ExportICalL( *entry, writeStream );
+	    aMimeType = iOwnFormat->MimeFormat( 1 ).MimeType().DesC();
+	    aMimeVer = iOwnFormat->MimeFormat( 1 ).MimeVersion().DesC();
+	    }
+    else if ( iTXEntryType == ENSmlVCal )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoOpenItemL: Export - vCal DB");
+	    iExporter->ExportVCalL( *entry, writeStream );
+	    aMimeType = iOwnFormat->MimeFormat( 0 ).MimeType().DesC();
+	    aMimeVer = iOwnFormat->MimeFormat( 0 ).MimeVersion().DesC();
+	    }
+	else
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoOpenItemL: Export - DB Not Supported");
+	    CleanupStack::PopAndDestroy( 2 ); // writeStream, entry
+	    User::RequestComplete( iCallerStatus, KErrNotSupported );
+		return;
+	    }
+	
+	writeStream.CommitL();
+	iItemData->Compress();
+	iPos = 0;
+	
+#ifdef __NSML_MORE_DEBUG_FOR_ITEMS__
+
+	DBG_DUMP( ( void* )iItemData->Ptr( 0 ).Ptr(), iItemData->Size(),
+	         _S8( "Item from database:" ) );
+
+#endif // __NSML_MORE_DEBUG_FOR_ITEMS__
+
+	
+	iDataMod->StripTxL( *iItemData );
+	CleanupStack::PopAndDestroy( 2 ); // writeStream, entry
+	
+#ifdef __NSML_MORE_DEBUG_FOR_ITEMS__
+
+	DBG_DUMP( ( void* )iItemData->Ptr( 0 ).Ptr(), iItemData->Size(),
+	         _S8( "Item from database after strip:" ) );
+
+#endif // __NSML_MORE_DEBUG_FOR_ITEMS__
+	
+	aFieldChange = EFalse;
+	aSize = iItemData->Size();
+	
+	iState = ENSmlItemOpen;
+	
+	if ( iServerMaxObjectSize == 0 || aSize <= iServerMaxObjectSize )
+		{
+		User::RequestComplete( iCallerStatus, KErrNone );
+		}
+	else
+		{
+		User::RequestComplete( iCallerStatus, KErrTooBig );
+		}
+		
+	_DBG_FILE("CNSmlAgendaDataStore::DoOpenItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCreateItemL
+// Prepare item data for writing to database. WriteItemL() writes item's data as
+// buffered.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize,
+                TSmlDbItemUid /*aParent*/, const TDesC8& aMimeType,
+                const TDesC8& /*aMimeVer*/, TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	iAddItemId = &aUid;
+	
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL - KErrNotReady: END");
+		return;
+		}
+		
+	if ( KNSmlAgendaOwnMaxObjectSize < aSize )
+		{
+		User::RequestComplete( iCallerStatus, KErrTooBig );
+		_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL - KErrTooBig: END");
+		return;
+		}
+		
+	if( SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, iDrive ) )
+		{
+		User::RequestComplete( iCallerStatus, KErrDiskFull );
+		_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL - KErrDiskFull: END");
+		return;
+		}
+
+    // Check if MIME type of new item is supported
+	TBool mimeFound( EFalse );
+	// vCal
+    if ( iOwnFormat->MimeFormat( 0 ).MimeType().DesC().Compare( aMimeType )
+         == 0 )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL: received vCal");
+	    mimeFound = ETrue;
+	    iRXEntryType = ENSmlVCal;
+	    }
+	        
+#ifdef __NSML_USE_ICAL_FEATURE
+
+     // iCal
+    else if ( iOwnFormat->MimeFormat( 1 ).MimeType().DesC().Compare( aMimeType )
+              == 0 ) 
+        {
+        _DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL: received iCal");
+        mimeFound = ETrue;
+	    iRXEntryType = ENSmlICal;
+        }
+
+#endif // __NSML_USE_ICAL_FEATURE
+
+    // Else use original iRXEntryType
+    else
+        {
+        _DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL: \
+                   mime type not received");
+        iRXEntryType = iTXEntryType;
+        }
+
+	if ( !mimeFound )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotSupported );
+		_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL -KErrNotSupported: END");
+		return;
+		}
+
+	if( !iSnapshotRegistered )
+		{
+		RegisterSnapshotL();
+		}
+	delete iItemData;
+	iItemData = NULL;
+	iItemData = CBufFlat::NewL( KNSmlItemDataExpandSize );
+	iPos = 0;
+	
+	iState = ENSmlItemCreating;
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoCreateItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoReplaceItemL
+// Prepare item data for writing and replacing item in database. WriteItemL()
+// writes item's data as buffered.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize,
+                TSmlDbItemUid /*aParent*/, TBool aFieldChange,
+                TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL - KErrNotReady: END");
+		return;
+		}
+
+	if ( KNSmlAgendaOwnMaxObjectSize < aSize )
+		{
+		User::RequestComplete( iCallerStatus, KErrTooBig );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL - KErrTooBig: END");
+		return;
+		}
+
+	if ( aFieldChange )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotSupported );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL \
+		           - KErrNotSupported: END");
+		return;
+		}
+	if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, iDrive ) )
+		{
+		User::RequestComplete( iCallerStatus, KErrDiskFull );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL - KErrDiskFull: END");
+		return;
+		}
+	
+ 	iReplaceItemId = aUid;
+
+ 	CCalEntry* entry = NULL;
+ 	TInt err( KErrNone );
+    TRAP( err, entry = iEntryView->FetchL( aUid ) );
+	CleanupStack::PushL( entry );
+ 		
+	if ( !entry || err == KErrNotFound )
+		{
+		CleanupStack::PopAndDestroy( entry ); // entry
+		User::RequestComplete( iCallerStatus, KErrNotFound );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL - KErrNotFound: END");
+		return;
+		}
+    else if ( err )
+        {
+		CleanupStack::PopAndDestroy( entry ); // entry
+		User::RequestComplete( iCallerStatus, err );
+		_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL - Error: END");
+		return;
+        }
+
+	CleanupStack::PopAndDestroy( entry ); // entry
+		
+	if ( !iSnapshotRegistered )
+		{
+		RegisterSnapshotL();
+		}
+		
+	delete iItemData;
+	iItemData = NULL;
+	iItemData = CBufFlat::NewL( KNSmlItemDataExpandSize );
+	iPos = 0;
+	iReplaceItemId = aUid;
+	
+	iState = ENSmlItemUpdating;
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoReplaceItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoReadItemL
+// Read item data to given buffer.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoReadItemL( TDes8& aBuffer )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoReadItemL: BEGIN");
+    if ( iState != ENSmlItemOpen || !iItemData )
+        {
+        iPos = -1;
+        User::Leave( KErrNotReady );
+        }
+
+    if ( iPos == -1 )
+        {
+        User::Leave( KErrEof );
+        }
+
+    if ( aBuffer.Size() < iItemData->Size() - iPos )
+        {
+        iItemData->Read( iPos, aBuffer );
+        iPos += aBuffer.Size();
+        }
+    else
+        {
+        iItemData->Read( iPos, aBuffer, iItemData->Size() - iPos );
+        iPos = -1;
+        }
+	_DBG_FILE("CNSmlAgendaDataStore::DoReadItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoWriteItemL
+// Write item data as buffered.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoWriteItemL( const TDesC8& aData )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoWriteItemL: BEGIN");
+	if ( iState == ENSmlItemCreating || iState == ENSmlItemUpdating )
+		{
+		if ( iItemData )
+			{
+			if ( iPos == -1 )
+				{
+				User::Leave( KErrEof );
+				}
+			iItemData->InsertL( iPos, aData );
+			iPos += aData.Size();
+			return;
+			}
+		}
+	User::Leave( KErrNotReady );
+	_DBG_FILE("CNSmlAgendaDataStore::DoWriteItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitItemL
+// Commit item data to database when adding or replacing item.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitItemL( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if ( iState != ENSmlItemCreating && iState != ENSmlItemUpdating )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitItemL - KErrNotReady: END");
+		return;
+		}
+	
+	iItemData->Compress();
+	TInt error( KErrNone );
+	
+	if ( iState == ENSmlItemCreating )
+		{
+		TRAP( error, DoCommitCreateItemL() );
+		}
+	else // ENSmlItemUpdating
+		{
+        TRAP( error, DoCommitReplaceItemL() );
+		}
+	iReplaceItemId = -1;
+	iPos = -1;
+	iState = ENSmlOpenAndWaiting;
+	iRXEntryType = iTXEntryType;
+    User::RequestComplete( iCallerStatus, error );    
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCloseItem
+// Return to previous state and clean item buffer.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCloseItem()
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCloseItem: BEGIN");
+	if ( iState == ENSmlItemOpen )
+		{
+		iPos = -1;
+		iState = ENSmlOpenAndWaiting;
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoCloseItem: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoMoveItemL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoMoveItemL( TSmlDbItemUid /*aUid*/,
+            TSmlDbItemUid /*aNewParent*/, TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoMoveItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoMoveItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoDeleteItemL
+// Delete item from database.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoDeleteItemL( TSmlDbItemUid aUid,
+                TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeleteItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+
+    CCalEntry* entry = NULL;
+    TInt err( KErrNone );
+    TRAP( err, entry = iEntryView->FetchL( aUid ) );
+    CleanupStack::PushL( entry );	
+
+	if ( !entry || err == KErrNotFound )
+		{
+		CleanupStack::PopAndDestroy( entry ); // entry
+		User::RequestComplete( iCallerStatus, KErrNotFound );
+		return;
+		}
+	else if ( err )
+	    {
+	    CleanupStack::PopAndDestroy( entry ); // entry
+		User::RequestComplete( iCallerStatus, err );
+		return;
+	    }
+	    
+    iEntryView->DeleteL( *entry );
+	CleanupStack::PopAndDestroy( entry ); // entry
+	
+	if ( iChangeFinder )
+		{
+		TNSmlSnapshotItem item( aUid );
+		iChangeFinder->ItemDeleted( item );
+		}
+		
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeleteItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoSoftDeleteItemL
+// Delete item from database.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/,
+                TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoSoftDeleteItemL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlAgendaDataStore::DoSoftDeleteItemL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoDeleteAllItemsL
+// Delete all items from database.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeleteAllItemsL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting ) 
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+
+	// Delete all items
+	// First searh every UIDs ...
+	TInt aNumSuccessfulDeleted( 0 );
+	RArray<TCalLocalUid> uidArray;
+	CleanupClosePushL( uidArray );
+	TCalTime zeroTime;
+	zeroTime.SetTimeUtcL( Time::NullTTime() );
+	iEntryView->GetIdsModifiedSinceDateL( zeroTime, uidArray );
+	
+	
+	// ... and then delete them
+    iEntryView->DeleteL( uidArray, aNumSuccessfulDeleted );
+	CleanupStack::PopAndDestroy( &uidArray ); // uidArray
+
+    // Update changefinder
+	if ( iChangeFinder )
+		{
+		iChangeFinder->ResetL();
+		}
+	iSnapshotRegistered = EFalse;
+	RegisterSnapshotL();
+	
+	User::RequestComplete( iCallerStatus, KErrNone );
+	
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeleteAllItemsL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoHasSyncHistory
+// Return ETrue if syncronization history is available.
+// -----------------------------------------------------------------------------
+//
+TBool CNSmlAgendaDataStore::DoHasSyncHistory() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoHasSyncHistory: BEGIN");
+	TBool ret = EFalse;
+	if ( iHasHistory )
+		{
+		if ( iOpenedStoreId != iChangeFinder->DataStoreUid() )
+			{
+			iChangeFinder->SetDataStoreUid( iOpenedStoreId );
+			}
+		else
+			{
+			ret = ETrue;
+			}
+		}
+	else
+		{
+		iChangeFinder->SetDataStoreUid( iOpenedStoreId );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoHasSyncHistory: END");
+	return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoAddedItems
+// Give uid list of added items since last syncronization.
+// -----------------------------------------------------------------------------
+//
+const MSmlDataItemUidSet& CNSmlAgendaDataStore::DoAddedItems() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoAddedItems: BEGIN");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iNewUids->Reset();
+		TRAP_IGNORE( iChangeFinder->FindNewItemsL( *iNewUids ) );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoAddedItems: END");
+	return *iNewUids;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoDeletedItems
+// Give uid list of deleted items since last syncronization.
+// -----------------------------------------------------------------------------
+//
+const MSmlDataItemUidSet& CNSmlAgendaDataStore::DoDeletedItems() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeletedItems: BEGIN");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iDeletedUids->Reset();
+		TRAP_IGNORE( iChangeFinder->FindDeletedItemsL( *iDeletedUids ) );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoDeletedItems: END");
+	return *iDeletedUids;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoSoftDeletedItems
+// Give uid list of deleted items since last syncronization.
+// -----------------------------------------------------------------------------
+//
+const MSmlDataItemUidSet& CNSmlAgendaDataStore::DoSoftDeletedItems() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoSoftDeletedItems: BEGIN");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iSoftDeletedUids->Reset();
+		TRAP_IGNORE(
+		    iChangeFinder->FindSoftDeletedItemsL( *iSoftDeletedUids ) );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoSoftDeletedItems: END");
+	return *iSoftDeletedUids;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoModifiedItems
+// Give uid list of modified items since last syncronization.
+// -----------------------------------------------------------------------------
+//
+const MSmlDataItemUidSet& CNSmlAgendaDataStore::DoModifiedItems() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoModifiedItems: BEGIN");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iReplacedUids->Reset();
+		TRAP_IGNORE( iChangeFinder->FindChangedItemsL( *iReplacedUids ) );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoModifiedItems: END");
+	return *iReplacedUids;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoMovedItems
+// Give uid list of moved items since last syncronization.
+// -----------------------------------------------------------------------------
+//
+const MSmlDataItemUidSet& CNSmlAgendaDataStore::DoMovedItems() const
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoMovedItems: BEGIN");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iMovedUids->Reset();
+		TRAP_IGNORE( iChangeFinder->FindMovedItemsL( *iMovedUids ) );
+		}
+	_DBG_FILE("CNSmlAgendaDataStore::DoMovedItems: END");
+	return *iMovedUids;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoResetChangeInfoL
+// Reset change info that exist since last syncronization.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoResetChangeInfoL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting ) 
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+	iChangeFinder->ResetL();
+	iSnapshotRegistered = EFalse;
+	if( !iSnapshotRegistered )
+		{
+		RegisterSnapshotL();
+		}
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoResetChangeInfoL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitChangeInfoL
+// Commit change info that exist since last syncronization for given uid list.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus,
+                const MSmlDataItemUidSet& aItems )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitChangeInfoL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting ) 
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+	iChangeFinder->CommitChangesL( aItems );
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitChangeInfoL: END");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitChangeInfoL
+// Commit change info that exist since last syncronization.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
+    {
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitChangeInfoL: BEGIN");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	if ( iState != ENSmlOpenAndWaiting ) 
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+	iChangeFinder->CommitChangesL();
+	User::RequestComplete( iCallerStatus, KErrNone );
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitChangeInfoL: END");
+    }
+    
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::RegisterSnapshotL
+// Register snapshot.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::RegisterSnapshotL()
+    {
+	_DBG_FILE("CNSmlAgendaAdapter::RegisterSnapshotL(): begin");
+	CArrayFixSeg<TNSmlSnapshotItem>* snapshot =
+	                new ( ELeave ) CArrayFixSeg<TNSmlSnapshotItem>( 64 );
+	CleanupStack::PushL( snapshot );
+	
+    // First find all entries ...
+	RArray<TCalLocalUid> uidArray;
+	CleanupClosePushL( uidArray );
+	TCalTime zeroTime;
+	zeroTime.SetTimeUtcL( Time::NullTTime() );
+	iEntryView->GetIdsModifiedSinceDateL( zeroTime, uidArray );
+	
+	// ... and then create snapshot items
+	for ( TInt i = 0; i < uidArray.Count(); i++ )
+	    {
+	    TNSmlSnapshotItem newItem = CreateSnapshotItemL( uidArray[i] );
+	    if ( newItem.ItemId() != 0 )
+	        {
+	        snapshot->InsertIsqL( newItem, iKey );
+	        }
+	    }
+	
+	CleanupStack::PopAndDestroy( &uidArray );
+		
+	iChangeFinder->SetNewSnapshot( snapshot );
+	
+	// iChangeFinder takes ownership of items
+	CleanupStack::Pop( snapshot );
+	iSnapshotRegistered = ETrue;
+	
+	_DBG_FILE("CNSmlAgendaAdapter::RegisterSnapshotL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::CreateSnapshotItemL
+// Creates new snapshot. Method gets data from database.
+// -----------------------------------------------------------------------------
+TNSmlSnapshotItem CNSmlAgendaDataStore::CreateSnapshotItemL(
+                const TCalLocalUid& aUid )
+    {
+    TNSmlSnapshotItem item( 0 );
+    CCalEntry* entry = iEntryView->FetchL( aUid );
+    CleanupStack::PushL( entry );
+
+    if( entry )
+		{
+		CCalEntry::TReplicationStatus replicationStatus =
+		                    entry->ReplicationStatusL();
+		if ( CanBeSynchronized( replicationStatus ) )
+			{
+			TUint intUid = entry->LocalUidL();
+			item.SetItemId( intUid );
+			item.SetLastChangedDate(
+			                entry->LastModifiedDateL().TimeUtcL() );
+			item.SetSoftDelete( EFalse );
+			}
+		}
+		
+    CleanupStack::PopAndDestroy( entry ); // entry
+	return item;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoListAgendaFilesL
+// List possible calendar database file names.
+// -----------------------------------------------------------------------------
+//
+CDesCArray* CNSmlAgendaDataStore::DoListAgendaFilesLC() const
+    {
+    CDesCArray* array = iVCalSession->ListCalFilesL();    
+	CleanupStack::PushL( array );
+	return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoGetDefaultFileNameL
+// Return default calendar database name.
+// -----------------------------------------------------------------------------
+//
+const TDesC& CNSmlAgendaDataStore::DoGetDefaultFileNameL() const
+    {
+	if ( !iDefaultStoreName )
+		{
+        User::Leave( KErrGeneral );
+		}
+	return *iDefaultStoreName;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::CanBeSynchronized
+// Return ETrue if entry can be synchronized.
+// -----------------------------------------------------------------------------
+//
+TBool CNSmlAgendaDataStore::CanBeSynchronized(
+            const CCalEntry::TReplicationStatus&
+            aReplicationStatus ) const
+	{
+	return ( aReplicationStatus != CCalEntry::ERestricted );	
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoOwnStoreFormatL
+// Returns adapters supported store format which is read from Calendar Plug
+// In Adapter own resource file.
+// -----------------------------------------------------------------------------
+//
+CSmlDataStoreFormat* CNSmlAgendaDataStore::DoOwnStoreFormatL()
+	{
+	_DBG_FILE("CNSmlAgendaDataStore:::DoOwnStoreFormatL(): BEGIN");
+	TFileName fileName;
+	TParse parse;
+	
+	// Check correct Data Sync protocol
+	TInt value( EDataSyncNotRunning );
+	TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                 KDataSyncStatus,
+                                 value );
+	if ( error == KErrNone &&
+	     value == EDataSyncRunning )
+	    {
+	    parse.Set( KNSmlDSAgendaDataStoreRsc_1_1_2,
+	               &KDC_RESOURCE_FILES_DIR, NULL );
+	    }
+	else // error or protocol version 1.2 
+	    {
+	    parse.Set( KNSmlDSAgendaDataStoreRsc_1_2,
+	               &KDC_RESOURCE_FILES_DIR, NULL );
+	    }
+	
+	fileName = parse.FullName();
+	RResourceFile resourceFile;
+	BaflUtils::NearestLanguageFile( iRfs, fileName );
+
+	TRAPD( leavecode, resourceFile.OpenL( iRfs,fileName ) );
+	if ( leavecode != 0 )
+		{
+		CleanupStack::PopAndDestroy(); // parse
+		_DBG_FILE("CNSmlAgendaDataProvider::DoStoreFormatL(): END");
+		User::Leave( leavecode );
+		}
+	CleanupClosePushL( resourceFile );
+	HBufC8* profileRes = resourceFile.AllocReadLC( NSML_AGENDA_DATA_STORE );
+	TResourceReader reader;
+	reader.SetBuffer( profileRes );
+
+	CSmlDataStoreFormat* dsFormat = CSmlDataStoreFormat::NewLC( iStringPool,
+	                                                            reader );
+	CleanupStack::Pop();
+	CleanupStack::PopAndDestroy( 2 ); // resourceFile, profileRes
+	_DBG_FILE("CNSmlAgendaDataStore:::DoOwnStoreFormatL(): END");
+	return dsFormat;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitCreateItemL
+// Commit item data to database when adding item.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitCreateItemL()
+    {
+    _DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL: BEGIN");
+    iState = ENSmlOpenAndWaiting; // iState set to closed to handle leave
+	CCalEntry::TReplicationStatus  replicationStatus;
+	
+	RBufReadStream readStream;
+	readStream.Open( *iItemData );
+	readStream.PushL();
+
+    RPointerArray<CCalEntry> rdArray;
+	CleanupStack::PushL( PtrArrCleanupItemRArr ( CCalEntry, &rdArray ) );
+	if ( iRXEntryType == ENSmlICal )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL: ImportICalendarL");
+	    iImporter->ImportICalendarL( readStream, rdArray );
+	    }
+    else if ( iRXEntryType == ENSmlVCal )
+        {
+        _DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL: ImportVCalendarL");
+        iImporter->ImportVCalendarL( readStream, rdArray );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL - \
+		           KErrNotSupported: END");
+        User::Leave( KErrNotSupported );
+        }
+    
+    // If rdArray is empty or there is multiple items then return error
+	// Multiple items are not supported
+	if ( rdArray.Count() != 1 )
+	    {
+	    CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL - \
+		           Multiple items are not supported: END");
+        User::Leave( KErrNotSupported );
+	    }
+	    
+    TInt err( KErrNone );
+
+    _DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL: before StoreL");
+    TRAP( err, iInterimUtils->StoreL( *iEntryView, *rdArray[0], ETrue ) );
+    DBG_ARGS(_S("CNSmlAgendaDataStore::DoCommitCreateItemL: after StoreL '%d'"), err );
+    if ( err )
+        {
+        CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL - \
+		           Error at storing item to database: END");
+        User::Leave( KErrGeneral );
+        }
+
+    *iAddItemId = rdArray[0]->LocalUidL();
+    
+    CCalEntry* newEntry = iEntryView->FetchL( *iAddItemId );
+    
+    if( newEntry )
+    	{
+	    CleanupStack::PushL( newEntry );
+        
+		replicationStatus = newEntry->ReplicationStatusL();
+	
+    	if ( CanBeSynchronized( replicationStatus ) )
+			{
+			if ( iChangeFinder )
+				{
+				TNSmlSnapshotItem item( *iAddItemId );
+        			item.SetLastChangedDate(
+                   	newEntry->LastModifiedDateL().TimeUtcL() );
+            	item.SetSoftDelete( EFalse );
+				TRAPD( changeFinderError, iChangeFinder->ItemAddedL( item ) );
+				if ( changeFinderError == KErrAlreadyExists )
+			    	{
+			    	iChangeFinder->ItemUpdatedL( item );
+			    	}
+				else
+			    	{
+			    	User::LeaveIfError( changeFinderError );    
+			    	}
+				}
+			}
+    	CleanupStack::PopAndDestroy();// newEntry,
+    	}
+    CleanupStack::PopAndDestroy( 2 ); //  rdArray, readStream   
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitCreateItemL: END");
+    }
+    
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::DoCommitReplaceItemL
+// Commit item data to database when replacing item.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::DoCommitReplaceItemL()
+    {
+    _DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: BEGIN");
+    iState = ENSmlOpenAndWaiting; // iState set to closed to handle leave
+	CBufFlat* oldItem = CBufFlat::NewL( KNSmlItemDataExpandSize );
+	CleanupStack::PushL( oldItem );
+	RBufWriteStream writeStream( *oldItem );
+	writeStream.PushL();
+	
+	CCalEntry* entry = NULL;
+	TInt error( KErrNone );
+    TRAP( error, entry = iEntryView->FetchL( iReplaceItemId ) );
+	if ( error || !entry )
+	{
+    	CleanupStack::PopAndDestroy( 2 ); // writeStream, oldItem
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL - \
+		           Error in fetching the item: END");
+    	User::Leave( KErrGeneral );
+    }
+    CleanupStack::PushL( entry );
+	
+	// Export item from database depending on transmitted item entry type
+	if ( iTXEntryType == ENSmlVCal )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: ExportVCalL");
+    	iExporter->ExportVCalL( *entry, writeStream );        
+    	}
+#ifdef __NSML_USE_ICAL_FEATURE
+	else if ( iTXEntryType == ENSmlICal )
+	    {
+	    _DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: ExportICalL");
+    	iExporter->ExportICalL( *entry, writeStream );
+	    }
+#endif // __NSML_USE_ICAL_FEATURE
+	else
+        {
+        CleanupStack::PopAndDestroy( 2 ); // entry, writeStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL - \
+		           KErrNotSupported: END");
+        User::Leave( KErrNotSupported );
+        }
+        
+	writeStream.CommitL();
+	oldItem->Compress();
+
+	CleanupStack::PopAndDestroy( 2 ); // entry, writeStream
+	
+	// Get original UID, geoId and Recurrence-ID properties
+	HBufC8* uid = NULL;
+	HBufC8* recurrenceId = NULL;
+	HBufC8* xRecurrenceId = NULL;
+	HBufC8* geoId = NULL;
+	GetPropertiesFromDataL( oldItem, uid, KVersitTokenUID()  );
+	GetPropertiesFromDataL( oldItem, recurrenceId, KNSmlVersitTokenRecurrenceID() );
+	GetPropertiesFromDataL( oldItem, xRecurrenceId, KNSmlVersitTokenXRecurrenceID() );
+	GetPropertiesFromDataL( oldItem, geoId, KNSmlVersitTokenGeoID() );
+	CleanupStack::PushL( uid );
+	CleanupStack::PushL( recurrenceId );
+	CleanupStack::PushL( xRecurrenceId );
+	CleanupStack::PushL( geoId );
+
+#ifdef __NSML_MORE_DEBUG_FOR_ITEMS__
+
+	DBG_DUMP( ( void* )oldItem->Ptr( 0 ).Ptr(), oldItem->Size(),
+	          _S8( "Old item from database:" ) );
+
+#endif // __NSML_MORE_DEBUG_FOR_ITEMS__
+
+   	if ( iDataMod->NeedsMerge() )
+		{
+    	// Merge data
+    	iDataMod->MergeRxL( *iItemData, *oldItem );
+		}
+	
+	// Add original UID and Recurrence-ID to merged data
+	// This first removes UID and Recurrence-ID from merged data
+	// and then adds original ones
+	if ( uid )
+	    {
+	    SetPropertiesToDataL( uid, KVersitTokenUID() );    
+	    }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+	if ( recurrenceId )
+	    {
+	    SetPropertiesToDataL( recurrenceId, KNSmlVersitTokenRecurrenceID() );    
+	    }
+	if ( xRecurrenceId )
+	    {
+	    SetPropertiesToDataL( xRecurrenceId, KNSmlVersitTokenXRecurrenceID() );    
+	    }
+	if ( geoId )
+	    {
+	    SetPropertiesToDataL( geoId, KNSmlVersitTokenGeoID() );    
+	    }
+
+#ifdef __NSML_MORE_DEBUG_FOR_ITEMS__
+
+	DBG_DUMP( ( void* )iItemData->Ptr( 0 ).Ptr(), iItemData->Size(),
+	          _S8( "New item to database:" ) );
+
+#endif // __NSML_MORE_DEBUG_FOR_ITEMS__
+	
+	CleanupStack::PopAndDestroy( 5 ); // xRecurrenceId, recurrenceId,
+	                                  // uid, oldItem, geoId
+    
+	// Replace item to database
+	RBufReadStream readStream;
+	readStream.Open( *iItemData );
+	readStream.PushL();
+
+	RPointerArray<CCalEntry> rdArray;
+	CleanupStack::PushL( PtrArrCleanupItemRArr ( CCalEntry, &rdArray ) );
+
+	// Import item to database depending on received item entry type
+	if ( iRXEntryType == ENSmlVCal )
+        {
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: ImportVCalendarL");
+    	iImporter->ImportVCalendarL( readStream, rdArray );
+        }
+#ifdef __NSML_USE_ICAL_FEATURE
+	else if ( iRXEntryType == ENSmlICal )
+		{
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: ImportICalendarL");
+		iImporter->ImportICalendarL( readStream, rdArray );
+		}
+#endif // __NSML_USE_ICAL_FEATURE
+    else
+        {
+        CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL - \
+		           KErrNotSupported: END");
+        User::Leave( KErrNotSupported );
+        }
+
+    // If rdArray is empty or there is multiple items then return error
+	// Multiple items are not supported
+	if ( rdArray.Count() != 1 )
+	    {
+	    CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL - \
+		           Multiple items are not supported: END");
+        User::Leave( KErrNotSupported );
+	    }
+	    
+	TInt err( KErrNone );
+
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: before StoreL");
+    TRAP( err, iInterimUtils->StoreL( *iEntryView, *rdArray[0], ETrue ) );
+    DBG_ARGS(_S("CNSmlAgendaDataStore::DoCommitCreateItemL: after StoreL '%d'"), err );
+    if ( err )
+        {
+        CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+		_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL - \
+		           Error at storing item to database: END");
+        User::Leave( KErrGeneral );
+        }
+
+	CCalEntry::TReplicationStatus  replicationStatus;
+	
+	CCalEntry* replacedEntry = iEntryView->FetchL( iReplaceItemId );
+	if( replacedEntry )
+	{
+    CleanupStack::PushL( replacedEntry );
+	
+    replicationStatus = replacedEntry->ReplicationStatusL();
+	            
+	if ( CanBeSynchronized( replicationStatus ) )
+		{
+		if ( iChangeFinder )
+			{
+			TNSmlSnapshotItem item( iReplaceItemId );
+			item.SetLastChangedDate(
+			            replacedEntry->LastModifiedDateL().TimeUtcL());
+			item.SetSoftDelete( EFalse );
+			iChangeFinder->ItemUpdatedL( item );
+			}
+		}
+	CleanupStack::PopAndDestroy(); // replacedEntry
+	}
+	
+	CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+
+	_DBG_FILE("CNSmlAgendaDataStore::DoCommitReplaceItemL: END");
+    }
+    
+// -----------------------------------------------------------------------------
+// CNSmlAgendaDataStore::GetPropertiesFromDataL
+// Gets property from old item.
+// -----------------------------------------------------------------------------
+//
+void CNSmlAgendaDataStore::GetPropertiesFromDataL( CBufFlat* aOldItem,
+                                                   HBufC8*& aValue,
+	                                               const TDesC8& aProperty )
+    {
+    _DBG_FILE("CNSmlAgendaDataStore::GetPropertiesFromDataL(): begin");
+    
+    // Gemerate property that is searched (Linebreak + property + tokencolon)
+    HBufC8* startBuffer = HBufC8::NewLC( KVersitTokenCRLF().Size() +
+                                         aProperty.Length() );
+    TPtr8 startBufferPtr( startBuffer->Des() );
+	startBufferPtr.Append( KVersitTokenCRLF() );
+	startBufferPtr.Append( aProperty );
+	
+	// Get start position of property value
+	TInt startPos = aOldItem->Ptr( 0 ).Find( startBufferPtr );
+	
+	TInt endPos( KErrNotFound );
+	if ( startPos != KErrNotFound )
+	    {
+	    // startPos is before UID word
+	    startPos = startPos + KVersitTokenCRLF().Length();
+	    
+	    // End end position of property value
+	    endPos = startPos + 
+	             aOldItem->Ptr( startPos ).Find( KVersitTokenCRLF() );
+	    
+	    TPtrC8 tempPtr( aOldItem->Ptr( 0 ).Mid( endPos ) );
+	    
+	    // If next char after linebreak is ' ' or '=' then it is only
+	    // linebreak inside of value. This does not work with base64 coding!
+	    while ( tempPtr[KVersitTokenCRLF().Length()] == ' ' ||
+	            tempPtr[KVersitTokenCRLF().Length()] == '=' )
+	        {
+	        endPos = endPos + KVersitTokenCRLF().Length();
+	        TInt tempPos = aOldItem->Ptr( endPos ).Find( KVersitTokenCRLF() );
+	        endPos = endPos + tempPos;
+	        tempPtr.Set( aOldItem->Ptr( 0 ).Mid( endPos ) );
+	        }
+        
+        // Then cut value to value parameter
+        delete aValue;
+		aValue = NULL;
+		TInt length = endPos - startPos;
+		aValue = HBufC8::NewLC( length );
+		TPtr8 valuePtr( aValue->Des() );
+		aOldItem->Read( startPos, valuePtr, length );
+		CleanupStack::Pop( aValue ); // aValue
+	    }
+    CleanupStack::PopAndDestroy( startBuffer ); // startBuffer
+    
+    _DBG_FILE("CNSmlAgendaDataStore::GetPropertiesFromDataL(): end");
+    }
+  
+// -----------------------------------------------------------------------------
+// Adds property and it's value to new item.
+// This method also removes original property and it's value.
+// -----------------------------------------------------------------------------
+//  
+void CNSmlAgendaDataStore::SetPropertiesToDataL( HBufC8*& aValue,
+	                                             const TDesC8& aProperty )
+    {
+    _DBG_FILE("CNSmlAgendaDataStore::SetPropertiesToDataL(): begin");
+    
+    // Gemerate property that is searched (Linebreak + property + tokencolon)
+    HBufC8* startBuffer = HBufC8::NewLC( KVersitTokenCRLF().Size() +
+                                         aProperty.Length() );
+    TPtr8 startBufferPtr( startBuffer->Des() );
+	startBufferPtr.Append( KVersitTokenCRLF() );
+	startBufferPtr.Append( aProperty );
+	
+	// Get start position of property value
+	TInt startPos = iItemData->Ptr( 0 ).Find( startBufferPtr );
+	
+	TInt endPos( KErrNotFound );
+	if ( startPos != KErrNotFound )
+	    {
+	    // startPos is before UID word
+	    startPos = startPos + KVersitTokenCRLF().Length();
+	    
+	    // End end position of property value
+	    endPos = startPos + 
+	             iItemData->Ptr( startPos ).Find( KVersitTokenCRLF() );
+	    
+	    TPtrC8 tempPtr( iItemData->Ptr( 0 ).Mid( endPos ) );
+	    
+	    // If next char after linebreak is ' ' or '=' then it is only
+	    // linebreak inside of value. This does not work with base64 coding!
+	    while ( tempPtr[KVersitTokenCRLF().Length()] == ' ' ||
+	            tempPtr[KVersitTokenCRLF().Length()] == '=' )
+	        {
+	        endPos = endPos + KVersitTokenCRLF().Length();
+	        TInt tempPos = iItemData->Ptr( endPos ).Find( KVersitTokenCRLF() );
+	        endPos = endPos + tempPos;
+	        tempPtr.Set( iItemData->Ptr( 0 ).Mid( endPos ) );
+	        }
+        
+        // Delete original property and value
+        iItemData->Delete( startPos, endPos - startPos );
+        
+	    }
+
+    // Add property and new value from parameter.
+    // First find end of VEVENT or VTODO
+    
+    // Generate VEVENT END property
+    HBufC8* endVEvent = HBufC8::NewLC( KVersitTokenCRLF().Size() + 
+                                     KVersitTokenEND().Length() +
+                                     KVersitTokenColon().Length() +
+                                     KVersitVarTokenVEVENT().Length() );
+	TPtr8 endVEventPtr( endVEvent->Des() );
+	endVEventPtr.Append( KVersitTokenCRLF() );
+	endVEventPtr.Append( KVersitTokenEND() );
+	endVEventPtr.Append( KVersitTokenColon() );
+	endVEventPtr.Append( KVersitVarTokenVEVENT() );
+	
+	// Generate VTODO END property
+    HBufC8* endVTodo = HBufC8::NewLC( KVersitTokenCRLF().Size() + 
+                                     KVersitTokenEND().Length() +
+                                     KVersitTokenColon().Length() +
+                                     KVersitVarTokenVTODO().Length() );
+	TPtr8 endVTodoPtr( endVTodo->Des() );
+	endVTodoPtr.Append( KVersitTokenCRLF() );
+	endVTodoPtr.Append( KVersitTokenEND() );
+	endVTodoPtr.Append( KVersitTokenColon() );
+	endVTodoPtr.Append( KVersitVarTokenVTODO() );
+    
+    // Find end of VEVENT or VTODO
+    endPos = iItemData->Ptr( 0 ).Find( endVEventPtr );
+    if ( endPos == KErrNotFound )
+        {
+        endPos = iItemData->Ptr( 0 ).Find( endVTodoPtr );
+        if ( endPos == KErrNotFound )
+            {
+            User::Leave( KErrNotFound );
+            }
+        }
+
+    // Add property and value from parameter
+	iItemData->InsertL( endPos, KVersitTokenCRLF() );
+	iItemData->InsertL( endPos + KVersitTokenCRLF().Size(),
+	                    aValue->Des() );
+    iItemData->Compress();
+    
+    CleanupStack::PopAndDestroy( 3 ); // endVTodo, endVEvent, startBuffer
+    
+    _DBG_FILE("CNSmlAgendaDataStore::SetPropertiesToDataL(): end");
+    }
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/agenda/src/nsmlagendaprogressview.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS agenda progress view
+*
+*/
+
+
+
+// INCLUDES
+#include "nsmldebug.h"
+#include "nsmlagendadatastore.h"
+
+// ===================================== MEMBER FUNCTIONS ======================
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CNSmlAgendaProgressview* CNSmlAgendaProgressview::NewL()
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::NewL(): BEGIN");
+	CNSmlAgendaProgressview* self = new (ELeave) CNSmlAgendaProgressview();
+	self->ConstructL();
+	_DBG_FILE("CNSmlAgendaProgressview::NewL(): END");
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::~CNSmlAgendaProgressview
+// Destructor.
+// -----------------------------------------------------------------------------
+CNSmlAgendaProgressview::~CNSmlAgendaProgressview()
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::~CNSmlAgendaProgressview(): BEGIN");
+	// Nothing to do
+	_DBG_FILE("CNSmlAgendaProgressview::~CNSmlAgendaProgressview(): END");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::Progress
+// This calls the observing class with the percentage complete of the current
+// operation.
+// -----------------------------------------------------------------------------
+void CNSmlAgendaProgressview::Progress( TInt /*aPercentageCompleted*/ )
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::Progress(): BEGIN");
+	_DBG_FILE("CNSmlAgendaProgressview::Progress(): END");
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::Completed
+// This calls the observing class when the current operation is finished.
+// -----------------------------------------------------------------------------
+void CNSmlAgendaProgressview::Completed( TInt aError )
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::Completed(): BEGIN");
+
+    iCompletedStatus = aError;
+	CActiveScheduler::Stop();
+
+    _DBG_FILE("CNSmlAgendaProgressview::Completed(): END");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::GetCompletedStatus
+// This method returns status of Completed method (see above).
+// -----------------------------------------------------------------------------
+TInt CNSmlAgendaProgressview::GetCompletedStatus()
+    {
+    return iCompletedStatus;
+    }
+	
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::NotifyProgress
+// Asks the observing class whether progress callbacks are required.
+// -----------------------------------------------------------------------------
+TBool CNSmlAgendaProgressview::NotifyProgress()
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::NotifyProgress(): BEGIN");
+	_DBG_FILE("CNSmlAgendaProgressview::NotifyProgress(): END");
+	return EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::CNSmlAgendaProgressview
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+CNSmlAgendaProgressview::CNSmlAgendaProgressview() :
+	iCompletedStatus( KErrNotReady )
+	{
+	_DBG_FILE("CNSmlAgendaProgressview::CNSmlAgendaProgressview(): BEGIN");
+	// Nothing to do
+	_DBG_FILE("CNSmlAgendaProgressview::CNSmlAgendaProgressview(): END");
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlAgendaProgressview::ConstructL
+// Second phase constructor.
+// -----------------------------------------------------------------------------
+void CNSmlAgendaProgressview::ConstructL()
+    {
+    _DBG_FILE("CNSmlAgendaProgressview::ConstructL(): BEGIN");
+    // Nothing to do
+    _DBG_FILE("CNSmlAgendaProgressview::ConstructL(): END");
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for SyncML DS Plug In adapters
+*
+*/
+
+
+PRJ_EXPORTS
+#ifdef __SYNCML_DS_CON
+#include "../contacts/bld/bld.inf"
+#endif
+
+#ifdef  __SYNCML_DS_CAL
+#include "../agenda/bld/bld.inf"
+#endif
+
+#ifdef __SYNCML_DS_SMS
+#include "../sms/group/bld.inf"
+#endif
+
+#ifdef __SYNCML_DS_BOOKMARK
+#include "../bookmark/group/bld.inf"
+#endif
+
+#ifdef __SYNCML_DS_MMS
+#include "../mms/group/bld.inf"
+#endif
Binary file omads/omadsextensions/adapters/bookmark/group/102751BA.XML has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for Bookmark DS Plugin
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./102751BA.XML              /epoc32/data/Z/private/101F99F6/capability/102751BA.XML
+./102751BA.XML              /epoc32/release/winscw/udeb/z/private/101F99F6/capability/102751BA.XML
+./bookmarkdsa_stub.sis      /epoc32/data/z/system/install/bookmarkdsa_stub.sis
+../rom/bookmarkdsa.iby      CORE_APP_LAYER_IBY_EXPORT_PATH(bookmarkdsa.iby)
+../loc/bookmarkdsa.loc      APP_LAYER_LOC_EXPORT_PATH(bookmarkdsa.loc)
+
+PRJ_MMPFILES
+./bookmarkdataprovider.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/group/bookmarkdataprovider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Bookmark DS Plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          bookmarkdataprovider.dll
+TARGETTYPE      PLUGIN
+UID             0x10009d8d 0x102751BA
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          bookmarkdataprovider.cpp
+SOURCE          bookmarkdatastore.cpp
+SOURCE          vbookmarkconverter.cpp
+SOURCE          omadsfolderobject.cpp
+SOURCE          conversionutil.cpp
+SOURCE          changefinder.cpp
+SOURCE          snapshotitem.cpp
+
+USERINCLUDE     ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  bookmarkdataprovider.rss
+HEADER
+TARGET          bookmarkdataprovider.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  bookmarkdatastore.rss
+HEADER
+TARGET          bookmarkdatastore.rsc  
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+START RESOURCE  bookmarkdsa.rss
+HEADER 
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         ecom.lib
+LIBRARY         smldataprovider.lib
+LIBRARY         favouritesengine.lib
+LIBRARY         bafl.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         efsrv.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY         SenXml.lib 
+LIBRARY         charconv.lib 
+LIBRARY         sysutil.lib
+LIBRARY         commonengine.lib        // For resource reader
+LIBRARY         FeedsServerClient.lib
+LIBRARY         hash.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/group/bookmarkdsa_stub.pkg	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,32 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+&EN
+
+; Header
+#{"Bookmark DS Plugin"},(0x102751BA),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\bookmarkdsa.rsc"
+""-"z:\resource\bookmarkdatastore.rsc"
+""-"z:\resource\plugins\bookmarkdataprovider.rsc"
+""-"z:\sys\bin\bookmarkdataprovider.dll"
Binary file omads/omadsextensions/adapters/bookmark/group/bookmarkdsa_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/bookmarkdataprovider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __BOOKMARKDATAPROVIDER_H__
+#define __BOOKMARKDATAPROVIDER_H__
+
+#include <SmlDataProvider.h>
+#include <f32file.h>
+
+class CBookmarkDataProvider : public CSmlDataProvider
+	{
+private:
+	// Default C++ constructor
+	CBookmarkDataProvider();
+
+	// 2nd phase of constructor
+	void ConstructL();
+
+public:	
+	
+	// Two-phased constructor
+	static CBookmarkDataProvider* NewL();
+	
+	// Destructor
+	virtual ~CBookmarkDataProvider();
+
+protected:
+
+	virtual void DoOnFrameworkEvent( TSmlFrameworkEvent, TInt aParam1, TInt aParam2 );
+	
+	virtual TBool DoSupportsOperation( TUid aOpId ) const;
+	
+	virtual const CSmlDataStoreFormat& DoStoreFormatL();
+	
+	virtual CDesCArray* DoListStoresLC();
+	
+	virtual const TDesC& DoDefaultStoreL();
+	
+	virtual CSmlDataStore* DoNewStoreInstanceLC();
+
+	virtual const RPointerArray<CSyncMLFilter>& DoSupportedServerFiltersL();
+	
+	virtual void DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& aServerDataStoreFormat,
+	    RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo );
+	
+	virtual void DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& aFilters,
+	    TSyncMLFilterChangeInfo& aChangeInfo );
+	
+	virtual HBufC* DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& aFilters,
+	    TSyncMLFilterMatchType aMatch, TDes& aFilterMimeType,
+	    TSyncMLFilterType& aFilterType, TDesC& aStoreName );
+	
+	virtual void DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& aFilters,
+	    TDes& aFilterMimeType, RPointerArray<CSmlDataProperty>& aProperties, TDesC& aStoreName );
+
+private:
+
+	CSmlDataStoreFormat* DoOwnStoreFormatL();
+
+private:
+	
+	CSmlDataStoreFormat*            iOwnStoreFormat;
+	RStringPool                     iStringPool;
+	RPointerArray<CSyncMLFilter>    iFilters;
+	RFs	                            iRFs;
+	
+	};
+
+#endif // __BOOKMARKDATAPROVIDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/bookmarkdataproviderdefs.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __BOOKMARKDATAPROVIDERDEFS_H__ 
+#define __BOOKMARKDATAPROVIDERDEFS_H__ 
+
+
+// ------------------------------------------------------------------------------------------------
+// Databases
+// ------------------------------------------------------------------------------------------------
+
+// Resource file for CSmlDataStoreFormat
+
+// The following works with DS plugin added into ROM image 
+_LIT(KBookmarkStoreFormatRscRom,"z:bookmarkdatastore.rsc");
+
+// The following works with DS plugin installed from SIS
+_LIT(KBookmarkStoreFormatRsc,"bookmarkdatastore.rsc");
+
+
+// ------------------------------------------------------------------------------------------------
+// Constants
+// ------------------------------------------------------------------------------------------------
+
+
+// ------------------------------------------------------------------------------------------------
+// Macros
+// ------------------------------------------------------------------------------------------------
+#define SAFEDELETE(x) {if(x) {delete x; x = NULL;}}
+#define SAFEDELETEARRAY(x) {if(x) {delete[] x; x = NULL;}}
+
+#endif // __BOOKMARKDATAPROVIDERDEFS_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/bookmarkdatastore.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __BOOKMARKDATASTORE_H__
+#define __BOOKMARKDATASTORE_H__
+
+#include <SmlDataProvider.h>
+#include <FavouritesDb.h>
+#include <nsmlchangefinder.h>
+
+#include <FeedsServerClient.h>
+#include <FeedsServerFolderItem.h>
+
+class CNSmlDataItemUidSet;
+class CFavouritesItem;
+class CBookmarkConversionUtil;
+class RFeedsServer;
+class CChangeFinder;
+class TSnapshotItem;
+
+class CBookmarkDataStore : public CSmlDataStore,
+                           public MFolderItemObserver,
+                           public MFeedsServerObserver
+	{
+private:
+
+	CBookmarkDataStore();
+	~CBookmarkDataStore();	
+	
+public:
+
+	static CBookmarkDataStore* NewL();
+	static CBookmarkDataStore* NewLC();
+	void ConstructL();	
+	
+	// Transactions (optional)
+	void DoBeginTransactionL();
+	void DoCommitTransactionL(TRequestStatus& aStatus);
+	void DoRevertTransaction(TRequestStatus& aStatus);
+
+	// Batching (optional)
+	void DoBeginBatchL();
+	void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus);
+	void DoCancelBatch();
+
+	// Opens data store asynchronously	
+	void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus);
+	// Cancels current asynchronous request
+	void DoCancelRequest();
+	// Returns the name of open database, empty if OpenL hasn't been called
+	const TDesC& DoStoreName() const;
+	// Sets remote server data format
+	void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat);
+	// Sets the remote server maximum object size
+	void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize);
+	// Returns maximum object size, reported by remote server
+	TInt DoMaxObjectSize() const;
+
+	// Opens item for reading
+	void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize,
+	    TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus);
+	// Initializes new item to data store
+	void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent,
+	    const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus);
+	// Initializes replace of item in data store
+	void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent,
+	    TBool aFieldChange, TRequestStatus& aStatus);
+	// Reads data from opened item
+	void DoReadItemL(TDes8& aBuffer);
+	// Writes data to created or replaced item
+	void DoWriteItemL(const TDesC8& aData);
+	// Commits the created or replaced item to database
+	void DoCommitItemL(TRequestStatus& aStatus);
+	// Closes the opened item
+	void DoCloseItem();
+	// Moves item in the database
+	void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus);
+	// Deletes item from the database
+	void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+	// Soft deletes item (if supported by plugin adapter), can be equal to DoDeleteItemL
+	void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+	// Deletes all items from the database
+	void DoDeleteAllItemsL(TRequestStatus& aStatus);
+
+	// Returns, whether data store has history info. EFalse means slow sync
+	TBool DoHasSyncHistory() const;
+	// Returns ids of items, which are added after previous synchronization
+	const MSmlDataItemUidSet& DoAddedItems() const;
+	// Returns ids of items, which are deleted after previous synchronization
+	const MSmlDataItemUidSet& DoDeletedItems() const;
+	// Returns ids of items, which are soft-deleted after previous synchronization
+	const MSmlDataItemUidSet& DoSoftDeletedItems() const;
+	// Returns ids of items, which are modified after previous synchronization
+	const MSmlDataItemUidSet& DoModifiedItems() const;
+	// Returns ids of items, which are moved after previous synchronization
+	const MSmlDataItemUidSet& DoMovedItems() const;
+	// Resets change information of items (makes all items new from DS point of view)
+	void DoResetChangeInfoL(TRequestStatus& aStatus);
+	// Commits the changes, that are sent into the remote server
+	void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems);
+	// Commits the changes, that are sent into the remote server
+	void DoCommitChangeInfoL(TRequestStatus& aStatus);
+	
+private: // From MFolderItemObserver
+	void FolderItemRequestCompleted(TInt aStatus, CRequestHandler::TRequestHandlerType);
+	void FolderItemChanged() {};
+private: // From MFeedsServerObserver
+    void UpdateAllProgress(TInt, TInt ) {};
+    void SettingsChanged( TInt ) {};
+private:  // From MConnectionObserver
+    virtual void NetworkConnectionNeededL(TInt* /*aConnectionPtr*/, TInt& /*aSockSvrHandle*/,
+        TBool& /*aNewConn*/, TApBearerType& /*aBearerType*/){};
+private:
+    void DoFolderItemRequestCompletedL( TInt aStatus );
+    void CreateRssItemL( TInt aRssParentUid, const TDesC& aName, const TDesC& aUrl, TBool aIsFolder );
+    void ReplaceRssItemL( TInt aRssItemUid, const TDesC& aNewName, const TDesC& aNewUrl );
+    void RssItemCreatedL();
+    void RssItemReplacedL( TBool& aMoveNeeded );
+    void RegisterSnapshotL();
+    void RegisterToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot, TInt aFolderUid );
+    void RegisterRssFeedsToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot,
+        const CFolderItem& folder );
+    void AssignString( TDes8& aDestination, const TDesC8& aSource );
+
+	// Data store states
+    enum TState
+        {
+        EClosed = 0,
+        EOpenAndWaiting,
+        EBookmarkOpen,
+        EBookmarkCreating,
+        EBookmarkUpdating,
+        EBookmarkUpdatedAndMoving,
+        EBookmarkMoving,
+        EBookmarkDeleting,
+        EBookmarkDeletingAll
+        }; 	
+        
+    TState iCurrentState;    
+
+    RFs                 iRfs;
+	RFavouritesSession 	iSession;
+	RFavouritesDb 		iDb;
+	TBool				iDataBaseOpened;
+    
+	RFeedsServer        iFeedsServer;
+	RFolderItem	    	iRootFolder;
+	
+	TRequestStatus*  iCallerStatus;
+
+    /**
+	* Key that is used in sorting snapshot.
+	*/
+    const TKeyArrayFix iKey;
+    
+    /**
+	* Change finder, used to determine db modifications.
+	*/
+    CChangeFinder* iChangeFinder;
+
+    /**
+	* Bookmark item converter, used to convert xml and vBookmark data.
+	*/
+	CBookmarkConversionUtil* iConverter;
+	
+	TInt* iCurrentItem;
+	TInt iReplaceItem;
+	TSnapshotItem* iMovedItem;
+	
+	CBufFlat* iDataBuffer;
+	TInt iWriterPosition;
+	TInt iReaderPosition;
+	
+	TBool iHasHistory;
+	
+	CNSmlDataItemUidSet* iNewItems;
+    CNSmlDataItemUidSet* iDeletedItems;
+    CNSmlDataItemUidSet* iSoftDeletedItems;
+    CNSmlDataItemUidSet* iUpdatedItems;
+    CNSmlDataItemUidSet* iMovedItems;
+    
+    CFavouritesItem::TType iMimeType;
+    TInt	    iParentFolder;
+    TFileName   iNewItemName;
+    
+    CFavouritesItem* iItemToBeReplaced;
+		
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/changefinder.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,214 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __CHANGEFINDER_H__
+#define __CHANGEFINDER_H__
+
+// INCLUDES
+#include <nsmlchangefinder.h>
+#include "snapshotitem.h"
+
+// DATATYPES
+typedef CArrayFixSeg<TSnapshotItem> CSnapshotArray;
+
+// Granularity used with dynamic array
+const TInt KSnapshotGranularity = 32;
+
+// CLASS DECLARATION
+
+/**
+* @brief CChangeFinder Class
+* This is a ChangeFinder class, which can be used to track down changes in the bookmark store.
+* It's functionality is equal to CSmlChangeFinder. Because neither of these classes contained virtual
+* functionality, the functionality of this class couldn't be inherited from the CSmlChangeFinder
+*/
+class CChangeFinder : public CBase
+	{ 
+public:
+	
+	/**
+    * Class constructor, Creates a new class instance.
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    * @return CChangeFinder*, New ChangeFinder instance.
+    */
+    static CChangeFinder* NewL( MSmlSyncRelationship& aSyncRelationship, 
+                               TKeyArrayFix aKey,
+                               TBool& aHasHistory, 
+                               TInt aStreamUid = KNSmlDefaultSnapshotStreamUID );
+
+    /**
+    * Class destructor.
+    */
+	~CChangeFinder();
+	
+    /**
+    * Close ChangeFinder object, stores snapshot.
+    */
+	void CloseL();
+
+    /**
+    * Reset change information, makes all content new from ChangeFinder point of view.
+    */
+	void ResetL();
+
+    /**
+    * Find changed items by comparing snapshots.
+    * 
+    * @param aChangedUids   IN: Array for results.
+    */
+	void FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids );
+
+    /**
+    * Find deleted items by comparing snapshots.
+    * 
+    * @param aDeletedUids   IN: Array for results.
+    */
+	void FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids );
+	
+    /**
+    * Find new items by comparing snapshots.
+    * 
+    * @param aNewUids   IN: Array for results.
+    */	
+	void FindNewItemsL(CNSmlDataItemUidSet& aNewUids);
+
+    /**
+    * Find moved items by comparing snapshots.
+    * 
+    * @param aMovedUids   IN: Array for results.
+    */	
+	void FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids );
+
+    /**
+    * Add item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to add.
+    */
+	void ItemAddedL( const TSnapshotItem& aItem );
+
+    /**
+    * Delete item from snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to delete.
+    */
+	void ItemDeletedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Update item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to update.
+    */
+	void ItemUpdatedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Move item within snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to move.
+    */
+	void ItemMovedL( const TSnapshotItem& aItem );
+
+    /**
+    * Commit all changes to snapshot, there's nothing to report anymore.
+    */
+	void CommitChangesL();
+
+    /**
+    * Commit a set of items to snapshot, these items won't be reported anymore.
+    * 
+    * @param aUids   IN: a set of items to commit.
+    */
+	void CommitChangesL( const MSmlDataItemUidSet& aUids );
+	
+	/**
+    * Sets new snapshot to compare against.
+    * 
+    * @param aNewSnapshot   IN: a new snapshot.
+    */
+	void SetNewSnapshot( CSnapshotArray* aNewSnapshot );
+	
+	/**
+    * Retrieves DataStore id number.
+    *
+    * @return TInt64, DataStore id.
+    */
+	TInt64 DataStoreUid() const;
+
+	/**
+    * Sets DataStore id number.
+    * 
+    * @param aUid   IN: a new datastore id.
+    */
+	void SetDataStoreUid( TInt64 aUid );
+	
+protected:
+	
+    /**
+    * C++ Constructor
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    */    
+	CChangeFinder( MSmlSyncRelationship& aSyncRelationship, 
+	              TKeyArrayFix aKey, 
+	              TInt aStreamUid );
+    
+    /**
+    * 2nd-phase Constructor
+    *
+    * @param aHasHistory   IN: ETrue, if there was synchronization history.
+    */    
+    void ConstructL( TBool& aHasHistory );
+
+private:
+
+    /**
+    * Allows access to streams.
+    */
+	MSmlSyncRelationship& iSyncRelationship;
+	
+    /**
+    * New snapshot to compare against.
+    */	
+	CSnapshotArray* iCurrentSnapshot;
+
+    /**
+    * Current snapshot.
+    */
+	CSnapshotArray* iOldSnapshot;
+	
+    /**
+    * Key that is used in sorting snapshot.
+    */
+	TKeyArrayFix iKey;
+	
+    /**
+    * Stream id number to access sync relationship.
+    */	
+	TInt iStreamUid;
+	
+    /**
+    * Data store id number.
+    */	
+	TInt64 iDataStoreUid;
+    };
+
+#endif // __CHANGEFINDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/conversionutil.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Conversion utility
+*
+*/
+
+
+#ifndef _CONVERSIONUTIL_H_
+#define _CONVERSIONUTIL_H_
+
+#include <FavouritesItem.h>
+
+class COMADSFolderObject;
+class CVBookmarkConverter;
+class CFolderItem;
+
+class CBookmarkConversionUtil : public CBase
+{
+public:
+    static CBookmarkConversionUtil* NewL();
+    static CBookmarkConversionUtil* NewLC();
+    
+    ~CBookmarkConversionUtil();
+    
+    void FavouritesItemToBufferL( const CFavouritesItem& aItem,
+        CBufFlat& aBuffer );
+    
+    void RssItemToBufferL( const CFolderItem& aItem,
+        CBufFlat& aBuffer);
+    
+    TInt BufferToFavouritesItemL( CFavouritesItem::TType aType,
+        CBufFlat& aBuffer, CFavouritesItem& aItem );
+        
+private:
+
+    void ConstructL();
+
+    COMADSFolderObject* iOmaConverter;
+    CVBookmarkConverter* iVBookmarkConverter;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/logger.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging macros used by DS plug-in adapters
+*
+*/
+
+
+#ifndef _LOGGER_H
+#define _LOGGER_H
+
+#ifdef _DEBUG
+    
+    #ifdef __WINS__
+        // File logging for WINS
+        #define __FLOGGING__
+    #endif //__WINS__
+    
+    #include <e32svr.h>
+    #ifdef __FLOGGING__
+        #include <f32file.h>
+        #include <flogger.h>
+    #endif
+    
+    NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+        {
+    public:
+        void Overflow(TDes16& /*aDes*/) {}
+        };
+    
+    NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+        {
+    public:
+        void Overflow(TDes8& /*aDes*/) {}
+        };
+    
+    _LIT( KLogDir, "BMKDS" );
+    _LIT( KLogFile, "BookmarkLog.txt" );
+
+    #define LOGGER_ENTERFN( name )      {TRACE_FUNC_ENTRY;}
+    #define LOGGER_LEAVEFN( name )      {TRACE_FUNC_EXIT;}
+    
+    _LIT(KTracePrefix16, "[BMKDS] ");
+    _LIT8(KTracePrefix8, "[BMKDS] ");
+    _LIT8(KFuncEntryFormat8, "%S : Begin");
+    _LIT8(KFuncExitFormat8, "%S : End");
+    _LIT8(KFuncFormat8, "><%S");
+    
+    const TInt KMaxLogLineLength = 512;
+    
+    #define LOGGER_WRITE( text )                    {_LIT( KTemp, text ); FPrint( KTemp );}
+    #define LOGGER_WRITE_1( text,par1 )             {_LIT( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_WRITE8_1( text,par1 )             {_LIT8( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_WRITE_2( text,par1,par2 )        {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );}
+    #define LOGGER_WRITE_3( text,par1,par2,par3 )   {_LIT( KTemp, text ); FPrint( KTemp, par1, par2, par3 );}
+    #define LOGGER_WRITE_IFERR_2( text, err )       {if (err) {_LIT( KTemp, text ); FPrint( KTemp, err );}}
+    
+    // New function logging macros
+    #define TRACE_FUNC_ENTRY {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncEntryFormat8, &ptr8);}
+    #define TRACE_FUNC_EXIT {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncExitFormat8, &ptr8);}
+    #define TRACE_FUNC {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncFormat8, &ptr8);}
+    
+    // Declare the FPrint function
+    inline void FPrint( TRefByValue<const TDesC16> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+    #ifdef __FLOGGING__
+        RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+    #endif
+        TBuf16<KMaxLogLineLength> theFinalString;
+        theFinalString.Append(KTracePrefix16);
+        TOverflowTruncate16 overflow;
+        theFinalString.AppendFormatList(aFmt,list,&overflow);
+        RDebug::Print(theFinalString);
+        }
+    
+    // Declare the FPrint function
+    inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list, aFmt);
+    #ifdef __FLOGGING__
+        RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    #endif
+        TOverflowTruncate8 overflow;
+        TBuf8<KMaxLogLineLength> buf8;
+        buf8.Append(KTracePrefix8);
+        buf8.AppendFormatList(aFmt, list, &overflow);
+        TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+        buf16.Copy(buf8);
+        TRefByValue<const TDesC> tmpFmt(_L("%S"));
+        RDebug::Print(tmpFmt, &buf16);
+        }
+#else
+    
+    // No loggings --> reduced code size
+    
+    #define LOGGER_ENTERFN( name )
+    #define LOGGER_LEAVEFN( name )
+    #define LOGGER_WRITE( text )
+    #define LOGGER_WRITE_1( text, par1 )
+    #define LOGGER_WRITE8_1( text,par1 )
+    #define LOGGER_WRITE_2( text, par1, par2 )
+    #define LOGGER_WRITE_3( text, par1, par2, par3 )
+    #define TRACE_FUNC_ENTRY
+    #define TRACE_FUNC_EXIT
+    #define TRACE_FUNC
+
+#endif //_DEBUG
+
+#endif // __LOGGER_H__
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/omadsfolderobject.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+
+#ifndef __OMADSFOLDEROBJECT_H__
+#define __OMADSFOLDEROBJECT_H__
+
+#include <f32file.h>
+#include <MSenContentHandlerClient.h>
+#include <FavouritesItem.h>
+
+
+const TInt KMaxFolderNameLength = KFavouritesMaxName;
+const TInt KMaxElementLength = 255;
+const TInt KMaxXmlLineLength = 1024;
+
+class CSenXmlReader;
+class CFolderItem;
+
+class COMADSFolderObject : public CBase, public MSenContentHandlerClient
+{
+public:
+
+    static COMADSFolderObject* NewLC();
+    static COMADSFolderObject* NewL();
+    ~COMADSFolderObject();
+    
+    // Get methods
+    inline const TDesC& GetName() const {return iName;}
+    inline const TDateTime& GetCreatedDate() const {return iCreatedDate;}
+    inline const TDateTime& GetModifiedDate() const {return iModifiedDate;}
+    
+    // Set methods
+    inline void SetName(const TDesC& aName) {iName.Copy(aName);}
+    inline void SetCreatedDate(const TDateTime& aDateTime) {iCreatedDate = aDateTime;}
+    inline void SetModifiedDate(const TDateTime& aDateTime) {iModifiedDate = aDateTime;}
+    
+    // Import & export
+    TInt ImportFolderXml(const TDesC8& aData);
+    TInt ImportFolderXml(RFs& aFs, const TDesC& aFilename);
+    void ExportFolderXmlL(TDes8& aBuffer);
+    void ExportFolderXmlL(CBufBase& aBuffer);    
+    void ExportDbItemL(CFavouritesItem& aItem);		
+	void ImportDbItem(const CFavouritesItem& aItem);
+	void ImportDbItem(const CFolderItem& aItem);
+    
+    // MSenContentHandlerClient virtual functionality
+	TInt StartDocument();
+	TInt EndDocument();
+	TInt StartElement(const TDesC8& aURI, 
+					  const TDesC8& aLocalName, 
+					  const TDesC8& aName, 
+					  const RAttributeArray& apAttrs);
+	TInt EndElement(const TDesC8& aURI, 
+					const TDesC8& aLocalName, 
+					const TDesC8& aName);
+    TInt Characters(const TDesC8& aBuf, TInt aStart, TInt aLength);
+	TInt Error(TInt aErrorCode);
+	
+private:
+    void ConstructL();
+    void ExportL();	
+	void WriteL(const TDesC &aData);
+	void WriteEncodedXmlL(const TDesC &aData);
+	void ReadFolderNameL( TDes& aName, const TInt aResID );
+	void Reset();
+    TInt ParseDateString(const TDesC8& aString, TDateTime& aDateTime);
+
+private:
+   	CSenXmlReader*              iXmlReader;
+    TBuf8<KMaxElementLength>    iCurrentElement;
+    TBuf8<KMaxXmlLineLength>    iTemp;
+    TBuf<KMaxFolderNameLength>  iName;
+    TDateTime   iCreatedDate;
+    TDateTime   iModifiedDate;
+    TInt        iError;
+	CBufBase*   iBuffer;
+	TInt        iWriteBufPosition;
+	TInt        iWriteBufSize;
+	TDes8*      iDesc;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/snapshotitem.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Private snapshot item header
+*
+*/
+
+
+#ifndef __SNAPSHOTITEM_H__
+#define __SNAPSHOTITEM_H__
+
+// INCLUDES
+
+#include <s32strm.h>
+#include <nsmlsnapshotitem.h>
+
+
+// CLASS DECLARATION
+
+// Defines the maximum length of a hash.
+const TInt KMaxHashLength = 20;
+typedef TBuf8<KMaxHashLength> THashValue;
+
+/**
+* @brief TSnapshotItem
+* This class represents a single item in the ChangeFinder snapshot.
+* It's derived from the generic snapshot item and extended
+* to contain the hash (name and url) information.
+*/
+class TSnapshotItem : public TNSmlSnapshotItem
+	{ 
+public:
+	
+	/**
+    * Constructor
+    */
+	TSnapshotItem();
+
+	/**
+    * Constructor
+    * 
+    * @param aItemId   IN: id of the item.
+    * @param aParent   IN: parent item, 0 as default.
+    */
+	TSnapshotItem( const TSmlDbItemUid& aItemId,
+	    const TSmlDbItemUid& aParent = 0 );
+	
+	/**
+    * Writes the item to a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is to be written.
+    */
+	void ExternalizeL( RWriteStream& aStream ) const;
+
+	/**
+    * Reads item from a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is read from.
+    */
+	void InternalizeL( RReadStream& aStream );	
+	
+	/**
+    * Creates hash from name and url
+    *
+    * @param aName, name to used
+    * @param aUrl, url to used
+    * @return none.
+    */
+	void CreateHashL( const TDesC& aName, const TDesC& aUrl );
+	
+	/**
+    * Reads hash
+    * 
+    * @return TDesC8& hash.
+    */
+	const TDesC8& Hash() const;
+	
+private:
+    
+    THashValue       iHash;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/vbookmarkconverter.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bookmark object conversion routines
+*
+*/
+
+
+#ifndef __VBOOKMARKCONVERTER_H__
+#define __VBOOKMARKCONVERTER_H__
+
+#include <e32base.h>
+
+class CFavouritesItem;
+class CFolderItem;
+
+typedef enum
+    {
+    ENoEncoding = 0,
+    EQuotedPrintable
+    } TBookmarkEncoding;
+
+class CVBookmarkConverter : public CBase
+	{
+public:
+
+	static CVBookmarkConverter* NewL();
+	static CVBookmarkConverter* NewLC();
+	~CVBookmarkConverter();
+
+	// Get
+	const TDesC& GetVersion() const;
+	const TDesC& GetUrl() const;
+	const TDesC& GetTitle() const;
+	const TDesC& GetInternetShortcut() const;	
+	
+	// Set
+	void SetVersionL( const TDesC& aVersion );
+	void SetVersionL( const TDesC8& aVersion );
+	
+	void SetUrlL( const TDesC& aUrl );
+	void SetUrlL( const TDesC8& aUrl );
+	
+	void SetTitleL( const TDesC& aTitle );
+	void SetTitleL( const TDesC8& aTitle, TBookmarkEncoding aEncoding = ENoEncoding );
+		
+	void SetInternetShortcutL( const TDesC& aInternetShortcut );
+	void SetInternetShortcutL( const TDesC8& aInternetShortcut );
+	
+	void ExportDbItemL( CFavouritesItem& aItem );		
+	void ImportDbItemL( const CFavouritesItem& aItem );
+	void ImportDbItemL( const CFolderItem& aItem );
+
+
+	// Export / Import VBookmark info from/to this object
+	void ExportVBookmarkL( TDes8& aBuffer );
+	void ExportVBookmarkL( CBufBase& aBuffer );
+	
+	TInt ImportVBookmarkL( const TDesC8& aBuffer );
+
+private:
+
+	CVBookmarkConverter();	
+	void ConstructL();
+	
+	void WriteMessageLineL( const TDesC8& aMsgLineTag, const TDesC8& aMsgLineData,
+	    const TDesC8& aSeparator );
+	
+	void WriteEnvelopeL();
+	
+	void ExportL();
+	
+	void ResetL();
+	
+	TInt ReadTagAndValue( const TDesC8& aBuffer, TInt& aPosition,
+	    TPtrC8& aTag, TPtrC8& aValue, TPtrC8& aProperties );
+	    
+	TInt ReadEnvelopeL( const TDesC8& aBuffer, TInt& aPosition );
+	
+	TInt ReadAssignment( const TDesC8& aBuffer, TInt& aPosition,
+	    TPtrC8& aTag, TPtrC8& aValue );
+	
+	void WriteL( const TDesC8 &aData );
+	
+	void IgnoreSpaces( TPtrC8& aData );
+	
+	TBookmarkEncoding Encoding( TPtrC8& aProperties );
+	
+	HBufC8* DecodeQuotedPrintableLC( const TDesC8& aEncodedData );
+	
+private:
+
+	HBufC*      iVersion;
+	HBufC*      iUrl;
+	HBufC*      iTitle;
+	HBufC*      iInternetShortcut;
+	CBufBase*   iBuffer;
+	TInt        iWriteBufPosition;
+	TInt        iWriteBufSize;
+	TDes8*      iDesc;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/loc/bookmarkdsa.loc	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localization strings for project Bookmark DS adapter
+*
+*/
+
+
+
+// d: Boomark folder "Download applications"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_applications  "Download applications"
+
+// d: Boomark folder "Download images"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_images        "Download images"
+
+// d: Boomark folder "Download tones"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_tones         "Download tones"
+
+// d: Boomark folder "Download videos"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_videos        "Download videos"
+
+// d: Boomark folder "Download skins"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_skins         "Download skins"
+
+// d: Boomark folder "Download music"
+// l: None
+// r: 5.0
+//
+#define qtn_bookmarkdsa_folder_download_music         "Download music"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/rom/bookmarkdsa.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for Bookmark DS adapter binaries
+*
+*/
+
+
+#ifndef __BOOKMARKDSA_IBY__
+#define __BOOKMARKDSA_IBY__
+
+ECOM_PLUGIN(bookmarkdataprovider.dll,bookmarkdataprovider.rsc)
+data=DATAZ_\RESOURCE_FILES_DIR\bookmarkdatastore.rsc    RESOURCE_FILES_DIR\bookmarkdatastore.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\bookmarkdsa.rsc          RESOURCE_FILES_DIR\bookmarkdsa.rsc
+data=DATAZ_\private\101F99F6\capability\102751BA.XML    private\101F99F6\capability\102751BA.XML
+data=ZSYSTEM\install\bookmarkdsa_stub.sis             	system\install\bookmarkdsa_stub.sis
+
+#endif //__BOOKMARKDSA_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdataprovider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,295 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <ecom/implementationproxy.h>
+#include <data_caging_path_literals.hrh>
+#include <bautils.h>
+#include <barsc.h> 
+#include <bookmarkdatastore.rsg>
+
+#include "bookmarkdataprovider.h"
+#include "bookmarkdatastore.h"
+#include "bookmarkdataproviderdefs.h"
+#include "logger.h"
+
+const TUint KBookmarkDataProviderImplUid = 0x102751BA;
+
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::CBookmarkDataProvider
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CBookmarkDataProvider::CBookmarkDataProvider(): iFilters( 1 )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider" );
+    LOGGER_LEAVEFN( "CBookmarkDataProvider" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CBookmarkDataProvider::ConstructL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::ConstructL" );
+    
+    User::LeaveIfError( iRFs.Connect() );
+    iStringPool.OpenL();
+    
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CBookmarkDataProvider* CBookmarkDataProvider::NewL()
+    {
+    LOGGER_ENTERFN("CBookmarkDataProvider::NewL");
+    CBookmarkDataProvider* self = new ( ELeave ) CBookmarkDataProvider();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::NewL" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::~CBookmarkDataProvider
+// Destructor.
+// -----------------------------------------------------------------------------
+CBookmarkDataProvider::~CBookmarkDataProvider()
+    {
+    LOGGER_ENTERFN( "~CBookmarkDataProvider" );
+
+    SAFEDELETE( iOwnStoreFormat );
+    iStringPool.Close();
+    iFilters.Close();
+    iRFs.Close();
+
+    LOGGER_LEAVEFN( "~CBookmarkDataProvider" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoOnFrameworkEvent
+// Not used
+// -----------------------------------------------------------------------------
+void CBookmarkDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/ )
+    {
+    LOGGER_ENTERFN("CBookmarkDataProvider::DoOnFrameworkEvent()"); 
+    LOGGER_LEAVEFN("CBookmarkDataProvider::DoOnFrameworkEvent()"); 
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoSupportsOperation
+// Checks whether data provider supports specific operation
+// -----------------------------------------------------------------------------
+TBool CBookmarkDataProvider::DoSupportsOperation( TUid /*aOpId*/ ) const
+    {
+    LOGGER_ENTERFN("CBookmarkDataProvider::DoSupportsOperation()"); 
+    LOGGER_LEAVEFN("CBookmarkDataProvider::DoSupportsOperation()"); 
+    return EFalse; // optional operations are not supported
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+const CSmlDataStoreFormat& CBookmarkDataProvider::DoStoreFormatL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoStoreFormatL" ); 
+
+    if (!iOwnStoreFormat)
+        {
+        iOwnStoreFormat = DoOwnStoreFormatL();
+        }
+    	
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::DoStoreFormatL" ); 
+    	
+    return *iOwnStoreFormat;	
+    }
+	
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoListStoresLC
+// Returns array fo data stores that can be opened
+// -----------------------------------------------------------------------------
+CDesCArray* CBookmarkDataProvider::DoListStoresLC()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoListStoresLC" ); 
+
+    CDesCArrayFlat* stores = new ( ELeave ) CDesCArrayFlat( 1 );
+    CleanupStack::PushL( stores );
+    stores->AppendL( KBrowserBookmarks );
+
+    LOGGER_LEAVEFN("CBookmarkDataProvider::DoListStoresLC"); 
+
+    return stores;	
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoDefaultStoreL
+// Returns the name of the default data store
+// -----------------------------------------------------------------------------
+const TDesC& CBookmarkDataProvider::DoDefaultStoreL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoDefaultStoreL" ); 
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::DoDefaultStoreL" ); 
+
+    return KBrowserBookmarks;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoNewStoreInstanceLC
+// Creates a new data store object, which can be used for synchronization
+// ----------------------------------------------------------------------------- 
+CSmlDataStore* CBookmarkDataProvider::DoNewStoreInstanceLC()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoNewStoreInstanceLC" ); 
+
+    CBookmarkDataStore* newStore = CBookmarkDataStore::NewLC();
+
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::DoNewStoreInstanceLC" ); 
+
+    return newStore;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+const RPointerArray<CSyncMLFilter>& CBookmarkDataProvider::DoSupportedServerFiltersL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoSupportedServerFiltersL" ); 	
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::DoSupportedServerFiltersL" ); 	
+    return iFilters; // empty array
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoCheckSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CBookmarkDataProvider::DoCheckSupportedServerFiltersL(
+    const CSmlDataStoreFormat& /*aServerDataStoreFormat*/,
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoCheckSupportedServerFiltersL" ); 	
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoCheckServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CBookmarkDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoCheckServerFiltersL" );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoGenerateRecordFilterQueryLC
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+HBufC* CBookmarkDataProvider::DoGenerateRecordFilterQueryLC(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/,
+    TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoGenerateRecordFilterQueryLC" );
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoGenerateFieldFilterQueryL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CBookmarkDataProvider::DoGenerateFieldFilterQueryL(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/,
+    RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ )
+    {	
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoGenerateFieldFilterQueryL" );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataProvider::DoOwnStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+CSmlDataStoreFormat* CBookmarkDataProvider::DoOwnStoreFormatL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataProvider::DoOwnStoreFormatL" );
+
+    TParse* parse = new ( ELeave ) TParse();
+    CleanupStack::PushL(parse);
+    TFileName fileName;
+    RResourceFile resourceFile;
+    
+    parse->Set( KBookmarkStoreFormatRscRom, &KDC_RESOURCE_FILES_DIR, NULL );
+    fileName = parse->FullName();
+    BaflUtils::NearestLanguageFile( iRFs, fileName );
+    LOGGER_WRITE_1( "file: %S", &fileName );
+    
+    TRAPD( error, resourceFile.OpenL( iRFs, fileName ) );
+    if ( error )
+        {
+        LOGGER_WRITE_1( "RResourceFile::OpenL leaved with %d - try again", error );
+        parse->Set( KBookmarkStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL );
+        fileName = parse->FullName();
+        BaflUtils::NearestLanguageFile( iRFs, fileName );
+        LOGGER_WRITE_1( "file: %S", &fileName );
+        resourceFile.OpenL( iRFs, fileName );
+        }
+    CleanupClosePushL( resourceFile );
+    HBufC8* buffer = resourceFile.AllocReadLC( BOOKMARK_DATA_STORE );
+
+    TResourceReader reader;
+    reader.SetBuffer( buffer );
+    
+    CSmlDataStoreFormat* dsFormat = NULL;
+    dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+
+    CleanupStack::Pop( dsFormat );
+    CleanupStack::PopAndDestroy( buffer );
+    CleanupStack::PopAndDestroy( &resourceFile );
+    CleanupStack::PopAndDestroy( parse );
+    
+    LOGGER_LEAVEFN( "CBookmarkDataProvider::DoOwnStoreFormatL" );
+
+    return dsFormat;
+    }
+	
+// -----------------------------------------------------------------------------
+// ImplementationTable
+// Required by ECom plugin interface, tells the entry point of the library
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KBookmarkDataProviderImplUid, CBookmarkDataProvider::NewL )
+    };
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Returns the implementation table, required by the ECom plugin interface
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdataprovider.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for Bookmark DS ECOM plug-in
+*
+*/
+
+
+#include <ecom/registryinfo.rh> 
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x102751BA; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x101F4D3A; // Constant for all DS plug ins
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x102751BA; // DS interface implementation UID
+                version_no = 1; 
+                display_name = "Bookmarks" ; // shown in UI
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdatastore.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2117 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <sysutil.h> 
+#include <FavouritesItem.h>
+#include <FavouritesItemList.h> 
+
+#include <FeedsServerClient.h>
+#include <FeedsServerFeed.h>
+#include <FeedsServerFolderItem.h>
+
+#include "bookmarkdatastore.h"
+#include "vbookmarkconverter.h"
+#include "omadsfolderobject.h"
+#include "bookmarkdataproviderdefs.h"
+#include "conversionutil.h"
+#include "changefinder.h"
+#include "logger.h"
+
+
+_LIT8( KBookmarkFolderMimeType, "application/vnd.omads-folder+xml" );
+_LIT8( KBookmarkFolderMimeVersion, "" );
+_LIT8( KBookmarkItemMimeType, "text/x-vbookmark" );
+_LIT8( KBookmarkItemMimeVersion, "" );
+_LIT( KRSSRootFolderName, "Web Feeds" );
+
+const TInt KDefaultBufferSize = 1024;
+const TInt KDataBufferNotReady = -1;
+const TInt KRssFeedsOffset = 50000;
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::CBookmarkDataStore
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+CBookmarkDataStore::CBookmarkDataStore() :
+    iDataBaseOpened( EFalse ), iFeedsServer(*this), iRootFolder(*this),
+    iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem, ItemId() ), ECmpTInt ) ),
+    iHasHistory( EFalse )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore" ); 
+    }
+    
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::ConstructL
+// Symbian 2nd phase constructor, can leave.
+// -----------------------------------------------------------------------------    
+void CBookmarkDataStore::ConstructL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::ConstructL" );
+    
+    User::LeaveIfError( iRfs.Connect() );
+    User::LeaveIfError( iSession.Connect() );
+    
+    iNewItems = new ( ELeave ) CNSmlDataItemUidSet;
+    iDeletedItems = new ( ELeave ) CNSmlDataItemUidSet;
+    iSoftDeletedItems = new ( ELeave ) CNSmlDataItemUidSet;
+    iUpdatedItems = new ( ELeave ) CNSmlDataItemUidSet;
+    iMovedItems = new ( ELeave ) CNSmlDataItemUidSet;
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::ConstructL" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::~CBookmarkDataStore
+// Destructor
+// -----------------------------------------------------------------------------    
+CBookmarkDataStore::~CBookmarkDataStore()
+    {
+    LOGGER_ENTERFN( "~CBookmarkDataStore" );
+
+    delete iDataBuffer;
+    delete iNewItems;
+    delete iDeletedItems;
+    delete iSoftDeletedItems;
+    delete iUpdatedItems;
+    delete iMovedItems;
+    delete iItemToBeReplaced;
+    
+    if ( iChangeFinder )
+        {
+        TRAPD( error, iChangeFinder->CloseL() );
+        if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1( "iChangeFinder->CloseL() leaved with %d", error );
+            }
+        }
+    delete iChangeFinder;
+    
+    delete iConverter;
+            
+    if ( iDataBaseOpened )
+        {
+        iDb.Close();
+        iRootFolder.Close();
+        iFeedsServer.Close();
+        }
+    
+    iSession.Close();
+    iRfs.Close();
+    LOGGER_LEAVEFN( "~CBookmarkDataStore" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CBookmarkDataStore* CBookmarkDataStore::NewL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::NewL" );
+    CBookmarkDataStore* self = CBookmarkDataStore::NewLC();
+    CleanupStack::Pop( self );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::NewL" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CBookmarkDataStore* CBookmarkDataStore::NewLC()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::NewLC" );
+    CBookmarkDataStore* self = new ( ELeave ) CBookmarkDataStore();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    LOGGER_LEAVEFN( "CBookmarkDataStore::NewLC" );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoOpenL
+// Opens database.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoOpenL( const TDesC& /*aStoreName*/,
+    MSmlSyncRelationship& aContext, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoOpenL" );
+    
+    iCallerStatus = &aStatus;           
+    *iCallerStatus = KRequestPending;
+    
+    if ( iDataBaseOpened )
+        {
+        User::RequestComplete( iCallerStatus, KErrInUse );
+        LOGGER_WRITE( "CBookmarkDataStore::DoOpenL failed with KErrInUse." );
+        return;
+        }
+        
+    // Create ChangeFinder
+    if ( iChangeFinder )
+        {
+        delete iChangeFinder;
+        iChangeFinder = NULL;
+        }
+    iChangeFinder = CChangeFinder::NewL( aContext, iKey, iHasHistory );
+    
+    // Create converter object
+    if ( iConverter )
+        {
+        delete iConverter;
+        iConverter = NULL;
+        }
+    iConverter = CBookmarkConversionUtil::NewL();
+    
+
+    TInt err( KErrNone );       
+    err = iDb.Open( iSession, KBrowserBookmarks );
+    if ( err )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoOpenL iDb.Open err: %d.", err );
+        User::RequestComplete( iCallerStatus, err );
+        return;
+        }
+    err = iFeedsServer.Connect();
+    if ( err )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoOpenL iFeedsServer.Connect err: %d.", err );
+        User::RequestComplete( iCallerStatus, err );
+        return;
+        }
+    err = iRootFolder.Open( iFeedsServer );
+    if ( err )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoOpenL iRootFolder.Open err: %d.", err );
+        User::RequestComplete( iCallerStatus, err );
+        return;
+        }
+        
+    iRootFolder.FetchRootFolderItemL(); // calls FolderItemRequestCompleted when completed
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoOpenL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::FolderItemRequestCompleted
+// RSS item database request is completed
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::FolderItemRequestCompleted( TInt aStatus,
+    CRequestHandler::TRequestHandlerType )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::FolderItemRequestCompleted" );
+    
+    TRAPD( err, DoFolderItemRequestCompletedL( aStatus ) );
+    
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1( "DoFolderItemRequestCompletedL leaved with err: %d", err );
+        User::RequestComplete( iCallerStatus, err );
+        }
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::FolderItemRequestCompleted" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoFolderItemRequestCompletedL
+// RSS item database request is completed
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoFolderItemRequestCompletedL( TInt aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoFolderItemRequestCompletedL" );
+    switch ( iCurrentState )
+        {
+        case EClosed : 
+            {
+            LOGGER_WRITE("Database ready");
+            iDataBaseOpened = ETrue;
+            iCurrentState = EOpenAndWaiting;
+            RegisterSnapshotL();
+            break;
+            }
+        
+        // bookmark is added (Add command)
+        case EBookmarkCreating :
+           	{
+           	// RSS Item has been created.
+           	LOGGER_WRITE_1("RSS item created, err %d", aStatus);
+           	// Restore state
+           	iCurrentState = EOpenAndWaiting;
+            if ( aStatus == KErrNone )
+                {
+                RssItemCreatedL();
+                }
+            break;
+            }
+        
+        // bookmark is updated (Replace command)
+        case EBookmarkUpdating :
+            {
+            LOGGER_WRITE("RSS item replaced");
+            if ( aStatus == KErrNone )
+                {
+                TBool moveNeeded(EFalse);
+                RssItemReplacedL( moveNeeded );
+                
+                if ( moveNeeded )
+                    {
+                    // Moving is still ongoing, don't complete request yet.
+                    return;
+                    }
+                
+                LOGGER_WRITE_1("Item ID: %d", *iCurrentItem);
+                LOGGER_WRITE_1("Parent ID: %d", iParentFolder);
+                }
+            // Restore state
+            iCurrentState = EOpenAndWaiting;
+            break;
+            }
+        
+        // bookmark is updated and moved (Replace command, 2nd phase)
+        case EBookmarkUpdatedAndMoving:
+            {
+            LOGGER_WRITE_1( "RSS item moved (replaced), err: %d", aStatus );
+            if ( aStatus == KErrNone )
+                {
+                // Inform ChangeFinder of updated item
+                iChangeFinder->ItemUpdatedL( *iMovedItem ); // ownership transferred
+                iMovedItem = NULL;
+                LOGGER_WRITE( "ItemReplacedL" );
+                }
+            else
+                {
+                delete iMovedItem;
+                iMovedItem = NULL;
+                }
+            // Restore state
+            iCurrentState = EOpenAndWaiting;
+            break;
+            }
+        
+        // bookmark is moved (Move command)
+        case EBookmarkMoving:
+            {
+            LOGGER_WRITE_1( "RSS item moved, err: %d", aStatus );
+            if ( aStatus == KErrNone )
+                {
+                iChangeFinder->ItemMovedL( *iMovedItem ); // ownership transferred
+                iMovedItem = NULL;
+                }
+            else
+                {
+                delete iMovedItem;
+                iMovedItem = NULL;
+                }
+            // Restore state
+            iCurrentState = EOpenAndWaiting;
+            break;
+            }
+            
+        case EBookmarkDeleting:
+            {
+            LOGGER_WRITE_1( "RSS item removed, err: %d", aStatus );
+            if ( aStatus == KErrNone )
+                {
+                // Inform ChangeFinder of the removed item
+                TSnapshotItem item( iReplaceItem );     
+                iChangeFinder->ItemDeletedL( item );
+                }
+            // Restore state
+            iCurrentState = EOpenAndWaiting;
+            break;
+            }
+        case EBookmarkDeletingAll:
+            {
+            LOGGER_WRITE_1( "all RSS items removed, err: %d", aStatus );
+            break;
+            }
+        
+        default :
+            LOGGER_WRITE_1( "Invalid state: %d", iCurrentState );
+            return;
+        }
+    User::RequestComplete( iCallerStatus, aStatus );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoFolderItemRequestCompletedL" ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::RssItemCreatedL
+// Rss item has been created, add item to changefinder
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::RssItemCreatedL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iRootFolder.HasRootFolderItem() )
+        {
+        LOGGER_WRITE( "rss root folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+    const CFolderItem* parent = rootFolder.Search( iParentFolder - KRssFeedsOffset );
+    if ( !parent )
+        {
+        LOGGER_WRITE( "parent folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    LOGGER_WRITE_1("parent->Id(): %d", parent->Id());
+    LOGGER_WRITE_1( "Name: %S", &iNewItemName );
+    const CFolderItem* addedItem = parent->Search( iNewItemName );
+    iNewItemName.Zero();
+    if ( addedItem )
+        {
+        LOGGER_WRITE_1("addedItem found, id: %d", addedItem->Id());
+        
+        // Output the uid value of new item
+        *iCurrentItem = addedItem->Id() + KRssFeedsOffset;
+        
+        // Inform ChangeFinder of the added item
+        TSnapshotItem snapshotItem( *iCurrentItem );
+        snapshotItem.SetParentId( iParentFolder );
+        snapshotItem.CreateHashL( addedItem->Name(), addedItem->SourceUrl() );
+        iChangeFinder->ItemAddedL( snapshotItem );
+        LOGGER_WRITE( "ItemAddedL" );
+        }
+    else
+        {
+        LOGGER_WRITE( "Added item not found" );
+        User::Leave( KErrNotFound );
+        }
+    LOGGER_WRITE_1("Item ID: %d", *iCurrentItem);
+    LOGGER_WRITE_1("Parent ID: %d", iParentFolder);
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::RssItemReplacedL
+// Rss item has been replaced, update changefinder
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::RssItemReplacedL( TBool& aMoveNeeded )
+    {
+    TRACE_FUNC_ENTRY;
+    aMoveNeeded = EFalse;
+    if ( !iRootFolder.HasRootFolderItem() )
+        {
+        LOGGER_WRITE( "rss root folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+    LOGGER_WRITE_1( "rootFolder.Search %d", iReplaceItem - KRssFeedsOffset );
+    const CFolderItem* modItem = rootFolder.Search( iReplaceItem - KRssFeedsOffset );
+    if ( modItem )
+        {
+        LOGGER_WRITE_1("Item found, id: %d", modItem->Id());
+        
+        const CFolderItem* parent = modItem->Parent();
+        if ( parent )
+            {
+            TInt currentParent = parent->Id() + KRssFeedsOffset;
+            if ( iParentFolder != parent->Id() + KRssFeedsOffset )
+                {
+                // move to another folder
+                const CFolderItem* newParent = rootFolder.Search(
+                    iParentFolder - KRssFeedsOffset );
+                if ( !newParent )
+                    {
+                    // new parent not found
+                    LOGGER_WRITE( "new parent not found" );
+                    User::Leave( KErrPathNotFound );
+                    }
+                else if ( !newParent->IsFolder() )
+                    {
+                    // not a folder
+                    LOGGER_WRITE( "parent is not a folder" );
+                    User::Leave( KErrPathNotFound );
+                    }
+                else
+                    {
+                    // Output the uid value of new item
+                    *iCurrentItem = modItem->Id() + KRssFeedsOffset;
+        
+                    iCurrentState = EBookmarkUpdatedAndMoving;
+                    RPointerArray<const CFolderItem> movedItems;
+                    CleanupClosePushL( movedItems );
+                    movedItems.Append( modItem );
+                    // FolderItemRequestCompleted is called when ready
+                    iRootFolder.MoveFolderItemsToL( movedItems, *newParent);
+                    CleanupStack::PopAndDestroy( &movedItems );
+                    aMoveNeeded = ETrue;
+                    
+                    delete iMovedItem;
+                    iMovedItem = NULL;
+                    iMovedItem = new (ELeave) TSnapshotItem( *iCurrentItem ,
+                        iParentFolder );
+                    iMovedItem->CreateHashL( modItem->Name(), modItem->SourceUrl() );
+                    LOGGER_WRITE( "ItemReplacedL,waiting to move item.." );
+                    return;
+                    }
+                
+                }
+            }
+        else
+            {
+            //parent not found
+            LOGGER_WRITE( "rss parent not defined" );
+            }
+        
+        // Output the uid value of new item
+        *iCurrentItem = modItem->Id() + KRssFeedsOffset;
+        
+        // Inform ChangeFinder of updated item
+        TSnapshotItem snapshotItem( *iCurrentItem, iParentFolder );
+        snapshotItem.CreateHashL( modItem->Name(), modItem->SourceUrl() );
+        iChangeFinder->ItemUpdatedL( snapshotItem );
+        LOGGER_WRITE( "ItemReplacedL" );
+        }
+    else
+        {
+        LOGGER_WRITE_1( "Replaced item %d not found",iReplaceItem - KRssFeedsOffset );
+        User::Leave( KErrNotFound );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCancelRequest
+// Not supported, does nothing.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCancelRequest()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCancelRequest" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCancelRequest" );    
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoStoreName
+// Returns the name of the DataStore
+// -----------------------------------------------------------------------------
+const TDesC& CBookmarkDataStore::DoStoreName() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoStoreName" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoStoreName" );
+    
+    if ( iDataBaseOpened )
+        {
+        return KBrowserBookmarks;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoBeginTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------    
+void CBookmarkDataStore::DoBeginTransactionL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoBeginTransactionL" );
+    LOGGER_WRITE( "CBookmarkDataStore::DoBeginTransactionL leaved with KErrNotSupported." )
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCommitTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCommitTransactionL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCommitTransactionL" );
+    LOGGER_WRITE( "CBookmarkDataStore::DoCommitTransactionL failed with KErrNotSupported." );
+    
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCommitTransactionL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoRevertTransaction
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoRevertTransaction( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoRevertTransaction" );
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoRevertTransaction" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoBeginBatchL
+// Batching is not supported.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoBeginBatchL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoBeginBatchL" );
+    LOGGER_WRITE( "CBookmarkDataStore::DoBeginBatchL leaved with KErrNotSupported." );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCommitBatchL
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCommitBatchL( RArray<TInt>& /*aResultArray*/, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCommitBatchL" );
+    LOGGER_WRITE( "CBookmarkDataStore::DoCommitBatchL failed with KErrNotSupported" );
+        
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCommitBatchL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCancelBatch
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCancelBatch()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCancelBatch" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCancelBatch" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoSetRemoteStoreFormatL
+// Not supported
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/ )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoSetRemoteStoreFormatL" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoSetRemoteStoreFormatL" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoSetRemoteMaxObjectSize
+// Not supported
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoSetRemoteMaxObjectSize( TInt /*aServerMaxObjectSize*/ )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoSetRemoteMaxObjectSize" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoSetRemoteMaxObjectSize" );   
+    }
+
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoMaxObjectSize
+// Reads the maximum object size from the central repository
+// -----------------------------------------------------------------------------
+TInt CBookmarkDataStore::DoMaxObjectSize() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoMaxObjectSize" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoMaxObjectSize" );    
+    return 0; // no limit
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoOpenItemL
+// Opens item in the DataStore, reads it (either completely or partially) 
+// to the temporary buffer where it can be later read to the remote database.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoOpenItemL(
+    TSmlDbItemUid aUid, 
+    TBool& aFieldChange, 
+    TInt& aSize, 
+    TSmlDbItemUid& aParent, 
+    TDes8& aMimeType, 
+    TDes8& aMimeVer, 
+    TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoOpenItemL" );
+    LOGGER_WRITE_1( "Item: %d", aUid );
+    
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    aFieldChange = EFalse;
+    
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "Warning: Unexpected current state: %d", iCurrentState );
+        }
+    
+    SAFEDELETE( iDataBuffer );
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize ); 
+    iReaderPosition = 0;
+    if ( aUid < KRssFeedsOffset )
+        {
+        LOGGER_WRITE( "Handle id as bookmark item " );
+        TInt err( KErrNone );   
+        CFavouritesItem* item = CFavouritesItem::NewLC();
+        err = iDb.Get( aUid, *item );
+        if (err)
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE_1( "RFavouritesDb::Get failed with %d", err );
+            CleanupStack::PopAndDestroy( item );
+            return;
+            }
+            
+        
+        
+        iConverter->FavouritesItemToBufferL( *item, *iDataBuffer );
+        aSize = iDataBuffer->Size();
+        aParent = item->ParentFolder();
+
+        // Set mime type according to item type
+        // The following code handles also the case, where the receiving
+        // buffer doesn't contain enough space for the type (truncated)
+        if ( item->Type() == CFavouritesItem::EItem )
+            {
+            LOGGER_WRITE("item type: EItem");
+            AssignString( aMimeType, KBookmarkItemMimeType );
+            AssignString( aMimeVer, KBookmarkItemMimeVersion );
+            }
+        else
+            {
+            LOGGER_WRITE("item type: EFolder");
+            AssignString( aMimeType, KBookmarkFolderMimeType );
+            AssignString( aMimeVer, KBookmarkFolderMimeVersion );
+            }
+
+        CleanupStack::PopAndDestroy( item );
+        }
+    else
+        {
+        LOGGER_WRITE( "Handle id as rssFeed item " );
+        
+        TInt rssId = aUid - KRssFeedsOffset;
+        LOGGER_WRITE_1( "rssId: %d", rssId );
+        
+        if ( !iRootFolder.HasRootFolderItem() )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rss root folder not found" );
+            return;
+            }
+        
+        const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+        const CFolderItem* founded = rootFolder.Search( rssId );
+        if ( founded )
+            {
+            LOGGER_WRITE( "Item found" );
+            const CFolderItem* parent = founded->Parent();
+            if ( parent )
+                {
+                LOGGER_WRITE( "parent found" );
+                aParent = parent->Id() + KRssFeedsOffset;
+                }
+            else
+                {
+                LOGGER_WRITE( "no parent (root)" );
+                aParent = KErrNotFound;// rootFolder.Id() + KRssFeedsOffset;
+                }
+            
+            if ( !founded->IsFolder() )
+                {
+                LOGGER_WRITE("item type: EItem");
+                AssignString( aMimeType, KBookmarkItemMimeType );
+                AssignString( aMimeVer, KBookmarkItemMimeVersion );
+                }
+            else
+                {
+                LOGGER_WRITE("item type: EFolder");
+                AssignString( aMimeType, KBookmarkFolderMimeType );
+                AssignString( aMimeVer, KBookmarkFolderMimeVersion );
+                }
+            iConverter->RssItemToBufferL( *founded, *iDataBuffer );
+            aSize = iDataBuffer->Size();
+            
+            }
+        else
+            {
+            LOGGER_WRITE( "Item not found" );
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            return;
+            }
+        
+        }
+    
+    User::RequestComplete( iCallerStatus, KErrNone );   
+    iCurrentState = EBookmarkOpen;
+    
+#ifdef _DEBUG
+    LOGGER_WRITE_1( "aFieldChange: %d", (TInt)aFieldChange );
+    LOGGER_WRITE_1( "aSize: %d", aSize );
+    LOGGER_WRITE_1( "aParent: %d", aParent );
+    TPtr8 bufPtr = iDataBuffer->Ptr(0);
+    LOGGER_WRITE8_1( "iDataBuffer: %S", &bufPtr);
+#endif
+
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoOpenItemL" );        
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCreateItemL
+// Create new item to the message store.
+// Return the id number of the newly created item
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCreateItemL(
+    TSmlDbItemUid& aUid, 
+    TInt aSize, 
+    TSmlDbItemUid aParent, 
+    const TDesC8& aMimeType, 
+    const TDesC8& /*aMimeVer*/, 
+    TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCreateItemL" );
+    LOGGER_WRITE_1( "aParent: %d", aParent );
+    LOGGER_WRITE8_1( "aMimeType: %S", &aMimeType );
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    delete iItemToBeReplaced;
+    iItemToBeReplaced = NULL;
+    
+    // Check MIME type
+    if ( aMimeType.Compare( KBookmarkFolderMimeType() ) == 0 )  
+        {
+        LOGGER_WRITE("item type: EFolder");
+        iMimeType = CFavouritesItem::EFolder;
+        }
+    else if ( aMimeType.Compare( KBookmarkItemMimeType() ) == 0 )
+        {
+        LOGGER_WRITE("item type: EItem");
+        iMimeType = CFavouritesItem::EItem;
+        }
+    else
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported );
+        LOGGER_WRITE( "Unexpected mime type" );
+        return;
+        }   
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "Warning: Unexpected current state: %d", iCurrentState );
+        }
+        
+    // Ensure that we've got enough disk space for the item
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, EDriveC ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE( "SysUtil::DiskSpaceBelowCriticalLevelL failed with KErrDiskFull." );
+        return;
+        }
+    
+    if ( aParent < KRssFeedsOffset )
+        {
+        LOGGER_WRITE( "Handle id as bookmark item" );
+        // Ensure that parent folder exists 
+        TBool folderExists( EFalse );   
+        TInt err = iDb.FolderExists( aParent, folderExists );
+        if ( err || !folderExists )
+            {
+            User::RequestComplete( iCallerStatus, KErrPathNotFound );
+            LOGGER_WRITE_1( "iDb.FolderExist returned %d, folder not found", err );
+            return;
+            }
+        
+        }
+    else
+        {
+        LOGGER_WRITE( "Handle id as rssFeed item " );
+        
+        TInt rssId = aParent - KRssFeedsOffset;
+        LOGGER_WRITE_1( "parentRssId: %d", rssId );
+        
+        if ( !iRootFolder.HasRootFolderItem() )
+            {
+            User::RequestComplete( iCallerStatus, KErrPathNotFound );
+            LOGGER_WRITE( "rss root folder not found" );
+            return;
+            }
+        
+        const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+        const CFolderItem* founded = rootFolder.Search( rssId );
+        TBool folderExists( EFalse );
+        if ( founded )
+            {
+            if ( founded->IsFolder() )
+                {
+                folderExists = ETrue;
+                }
+            }
+        if ( !folderExists )
+            {
+            User::RequestComplete( iCallerStatus, KErrPathNotFound );
+            LOGGER_WRITE( "Folder does not exist" );
+            return;
+            }
+        }
+    
+    iCurrentState = EBookmarkCreating;
+    // Store parent for further use 
+    iParentFolder = aParent;    
+                
+    SAFEDELETE( iDataBuffer );
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize );
+    iWriterPosition = 0;
+        
+    iCurrentItem = &aUid;   
+    
+    
+    User::RequestComplete( iCallerStatus, KErrNone );
+        
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCreateItemL" );      
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoReplaceItemL
+// Begin the replace operation, ensure that the item really exists
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoReplaceItemL(
+    TSmlDbItemUid aUid, 
+    TInt aSize, 
+    TSmlDbItemUid aParent,
+    TBool /*aFieldChange*/, 
+    TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoReplaceItemL" );
+    LOGGER_WRITE_1("aUid: %d", aUid);
+    LOGGER_WRITE_1("aParent: %d", aParent);
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    delete iItemToBeReplaced;
+    iItemToBeReplaced = NULL;
+    
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "Warning: Unexpected current state: %d", iCurrentState );
+        }
+        
+    // Ensure that we've got enough disk space for the item
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, EDriveC ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE( "SysUtil::DiskSpaceBelowCriticalLevelL failed with KErrDiskFull." );
+        return;
+        }       
+    
+    if ( aUid < KRssFeedsOffset )
+        {
+        LOGGER_WRITE( "Bookmark item" );
+        iItemToBeReplaced = CFavouritesItem::NewL();
+        // Check that item exists
+        TInt err = iDb.Get( aUid, *iItemToBeReplaced );
+        if ( err != KErrNone )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE_1( "iDb.Get failed with %d", err );
+            SAFEDELETE(iItemToBeReplaced);
+            return;
+            }
+        
+        // is parent changed
+        if ( aParent != iItemToBeReplaced->ParentFolder() )
+            {
+            if ( aParent >= KRssFeedsOffset )
+                {
+                User::RequestComplete( iCallerStatus, KErrNotSupported );
+                LOGGER_WRITE( "cannot move to RSS items folder" );
+                SAFEDELETE(iItemToBeReplaced);
+                return;
+                }
+            // parent is changed, ensure that new parent folder exists
+            TBool folderExists( EFalse ); 
+            err = iDb.FolderExists( aParent, folderExists );
+            if ( err || !folderExists )
+                {
+                User::RequestComplete( iCallerStatus, KErrPathNotFound );
+                LOGGER_WRITE_1( "iDb.FolderExist returned %d, new parent folder not found", err );
+                SAFEDELETE(iItemToBeReplaced);
+                return;
+                }
+            }
+        
+        
+        // Store some variables to be used later in commit
+        iMimeType = iItemToBeReplaced->Type();
+        iItemToBeReplaced->SetParentFolder( aParent );
+        iParentFolder = aParent;
+        iReplaceItem = aUid;
+        }
+    else
+        {
+        LOGGER_WRITE( "RSS item" );
+        if ( aParent < KRssFeedsOffset )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotSupported );
+            LOGGER_WRITE( "cannot move RSS item to normal folder" );
+            return;
+            }
+        if ( !iRootFolder.HasRootFolderItem() )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rss root folder not found" );
+            return;
+            }
+        const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+        const CFolderItem* rssItem = rootFolder.Search( aUid - KRssFeedsOffset );
+        if ( !rssItem )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rss item not found" );
+            return;
+            }
+        if ( rssItem->IsFolder() )
+            {
+            iMimeType = CFavouritesItem::EFolder;
+            }
+        else
+            {
+            iMimeType = CFavouritesItem::EItem;
+            }
+        const CFolderItem* parent = rssItem->Parent();
+        if ( parent )
+            {
+            TInt currentParent = parent->Id() + KRssFeedsOffset;
+            
+            const CFolderItem* newParent = rootFolder.Search( aParent - KRssFeedsOffset );
+            if ( !newParent )
+                {
+                User::RequestComplete( iCallerStatus, KErrPathNotFound );
+                LOGGER_WRITE( "new parent not found" );
+                return;
+                }
+            else if ( !newParent->IsFolder() )
+                {
+                User::RequestComplete( iCallerStatus, KErrPathNotFound );
+                LOGGER_WRITE( "new parent must be folder" );
+                return;
+                }
+            else
+                {
+                iParentFolder = aParent;
+                }
+            
+            }
+        else
+            {
+            iParentFolder = KErrNotFound;
+            }
+        iReplaceItem = aUid;
+        }
+    
+    
+    
+    SAFEDELETE(iDataBuffer);
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize );
+    iWriterPosition = 0;
+        
+    iCurrentItem = &aUid;   
+    iCurrentState = EBookmarkUpdating;
+    
+    User::RequestComplete( iCallerStatus, KErrNone );   
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoReplaceItemL" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoReadItemL
+// Read specified amount of data from the temporary buffer
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoReadItemL( TDes8& aBuffer )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoReadItemL" );
+    
+    if (iCurrentState != EBookmarkOpen || !iDataBuffer)
+        {
+        LOGGER_WRITE_1( "Unexpected state %d", iCurrentState );
+        User::Leave( KErrNotReady );
+        }
+        
+    if (iReaderPosition == KDataBufferNotReady)
+        {
+        LOGGER_WRITE( "No data to read" );
+        User::Leave( KErrEof );
+        }
+    
+    // Thiw is how much data there is left in the buffer    
+    TInt left = iDataBuffer->Size() - iReaderPosition;
+    
+    if ( left > 0 )
+        {
+        // This is how much there's space in the destination buffer
+        TInt destSize = aBuffer.MaxSize();
+        
+        // This is how much we can read
+        TInt toRead = destSize < left ? destSize : left;
+        
+        // Read the data from the buffer, then update the position      
+        iDataBuffer->Read( iReaderPosition, aBuffer, toRead );
+        iReaderPosition += toRead;
+        }
+    else
+        {
+        iReaderPosition = KDataBufferNotReady;
+        LOGGER_WRITE( "No data to read" );
+        User::Leave( KErrEof );
+        }   
+        
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoReadItemL" );        
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoWriteItemL
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoWriteItemL( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoWriteItemL" );
+    
+    if ( iCurrentState != EBookmarkCreating && iCurrentState != EBookmarkUpdating )
+        {
+        LOGGER_WRITE_1( "Unexpected current state: %d", iCurrentState );
+        User::Leave( KErrNotReady );
+        }
+    
+    // Calculate total size
+    TInt totalSize = aData.Size() + iDataBuffer->Size();
+
+    // Ensure that we've got enough disk space for the item
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, totalSize, EDriveC ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE("SysUtil::DiskSpaceBelowCriticalLevelL failed with KErrDiskFull.");
+        return;
+        }
+        
+    // Add data to buffer       
+    iDataBuffer->InsertL( iWriterPosition, aData );
+    iWriterPosition += aData.Size();
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoWriteItemL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCommitItemL
+// Commits item from temporary buffer to the message store
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCommitItemL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCommitItemL" );
+    LOGGER_WRITE_1("iParentFolder: %d", iParentFolder);
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EBookmarkCreating && iCurrentState != EBookmarkUpdating )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotReady );
+        LOGGER_WRITE_1( "Unexpected current state: %d", iCurrentState );
+        return;
+        }
+        
+    if ( iDataBuffer->Size() <= 0 )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotReady );
+        LOGGER_WRITE_1( "Data buffer has no data (%d)", iDataBuffer->Size() );
+        return; 
+        }
+    
+    
+    
+    // If iItemToBeReplaced exist, bookmark item is going to be replaced.
+    // iItemToBeReplaced contains original bookmark and only some of it's data is replaced.
+    CFavouritesItem* item(NULL);
+    if ( iItemToBeReplaced )
+        {
+        // Change object ownership to "item"-object, and push to cleanupStack
+        item = iItemToBeReplaced;
+        CleanupStack::PushL( item );
+        iItemToBeReplaced = NULL;
+        }
+    else
+        {
+        // Create new object.
+        item = CFavouritesItem::NewLC();
+        }
+    
+    iDataBuffer->Compress();
+    TInt err = iConverter->BufferToFavouritesItemL( iMimeType, *iDataBuffer, *item );
+    
+    if ( iParentFolder == KErrNotFound )
+        {
+        if ( item->Name().Compare( KRSSRootFolderName ) == 0 )
+            {
+            LOGGER_WRITE( "Was RSS Rootfolder" );
+            // Remove from cleanup stack
+            CleanupStack::PopAndDestroy( item );
+            
+            if ( !iRootFolder.HasRootFolderItem() )
+                {
+                User::RequestComplete( iCallerStatus, KErrNotFound );
+                LOGGER_WRITE( "rss root folder not found" );
+                return;
+                }
+            const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+            
+            *iCurrentItem = rootFolder.Id() + KRssFeedsOffset;
+            
+            // Inform ChangeFinder of updated item
+            TSnapshotItem snapshotItem( rootFolder.Id() + KRssFeedsOffset );
+            snapshotItem.SetParentId( iParentFolder );
+            snapshotItem.CreateHashL( KRSSRootFolderName, KNullDesC );
+            iChangeFinder->ItemUpdatedL( snapshotItem );
+            
+            // Destroy buffer
+            SAFEDELETE( iDataBuffer );
+            iWriterPosition = 0;
+            
+            // Restore state and signal we're done
+            LOGGER_WRITE( "Signal KErrNone" );
+            iCurrentState = EOpenAndWaiting;
+            User::RequestComplete( iCallerStatus, KErrNone );
+            
+            LOGGER_WRITE_1("Item ID: %d", *iCurrentItem);
+            LOGGER_WRITE_1("Parent ID: %d", iParentFolder);
+            LOGGER_LEAVEFN( "CBookmarkDataStore::DoCommitItemL" );
+            return;
+            }
+        }
+
+    if ( iParentFolder < KRssFeedsOffset )
+        {
+        // Convert buffer to favourites item
+        LOGGER_WRITE( "BookmarkItem" );
+        
+        if ( err == KErrNone )
+            {
+            LOGGER_WRITE_1 ( "ParentFolder: %d", iParentFolder )
+            // Creating new item
+            if ( iCurrentState == EBookmarkCreating )
+                {
+#ifdef _DEBUG                
+                LOGGER_WRITE( "Create new bookmark item" );
+                TPtrC namePtr = item->Name();
+                LOGGER_WRITE_1( "name: %S", &namePtr );
+#endif
+                // Set parent folder
+                item->SetParentFolder( iParentFolder );
+
+                // Add to database
+                err = iDb.Add( *item, EFalse );
+                LOGGER_WRITE_1("iDb.Add return: %d", err);
+                if ( err == KErrNone )
+                    {
+                    // Output the uid value of new item
+                    *iCurrentItem = item->Uid();
+                    LOGGER_WRITE_1("New item Uid: %d", *iCurrentItem);
+                    // Inform ChangeFinder of the added item
+                    TSnapshotItem snapshotItem( *iCurrentItem );
+                    snapshotItem.SetParentId( iParentFolder );
+                    snapshotItem.CreateHashL( item->Name(), item->Url() );
+                    iChangeFinder->ItemAddedL( snapshotItem );
+                    }
+                else
+                    {
+                    LOGGER_WRITE_1( "RFavouritesDb::Add failed: %d", err );
+                    }
+                }
+            // Updating existing item
+            else
+                {
+                LOGGER_WRITE( "Update existing item" );
+                item->SetParentFolder(iParentFolder);
+                err = iDb.Update( *item, iReplaceItem, EFalse );
+                if ( err == KErrNone )
+                    {
+                    // Inform ChangeFinder of updated item
+                    TSnapshotItem snapshotItem( iReplaceItem );
+                    snapshotItem.SetParentId( iParentFolder );
+                    snapshotItem.CreateHashL( item->Name(), item->Url() );
+                    iChangeFinder->ItemUpdatedL( snapshotItem );
+                    }
+                else
+                    {
+                    LOGGER_WRITE_1( "RFavouritesDb::Update failed: %d", err );
+                    }
+                }
+            }
+        else
+            {
+            LOGGER_WRITE_1( "Failed to create db item (%d)", err );
+            }
+
+        }
+    else
+        {
+        LOGGER_WRITE( "RSS item" );
+        err = iConverter->BufferToFavouritesItemL( iMimeType, *iDataBuffer, *item );
+        // Destroy buffer
+        SAFEDELETE( iDataBuffer );
+        iWriterPosition = 0;
+        if ( err == KErrNone )
+            {
+            if ( iCurrentState == EBookmarkCreating )
+                {
+                TBool isFolder = ( iMimeType == CFavouritesItem::EFolder );
+                CreateRssItemL( iParentFolder - KRssFeedsOffset, item->Name(), item->Url(), isFolder );
+                
+                CleanupStack::PopAndDestroy( item );
+                LOGGER_WRITE( "waiting FolderItemRequestCompleted..." );
+                return;    
+                }
+            else
+                {
+                LOGGER_WRITE( "Replace RSS item" );
+                ReplaceRssItemL( iReplaceItem - KRssFeedsOffset, item->Name(), item->Url());
+                
+                CleanupStack::PopAndDestroy( item );
+                LOGGER_WRITE( "waiting FolderItemRequestCompleted..." );
+                return;
+                }
+            }
+        else
+            {
+            // Data was corrupted
+            LOGGER_WRITE_1( " iConverter->BufferToFavouritesItemL err: %d", err );
+            err = KErrCorrupt;
+            }
+        }
+    
+
+    // Remove from cleanup stack
+    CleanupStack::PopAndDestroy( item );
+    
+    // Destroy buffer
+    SAFEDELETE( iDataBuffer );
+    iWriterPosition = 0;
+    
+    // Restore state and signal we're done
+    iCurrentState = EOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, err );
+    
+    LOGGER_WRITE_1("Item ID: %d", iReplaceItem);
+    LOGGER_WRITE_1("Parent ID: %d", iParentFolder);
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCommitItemL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::CreateRssItemL
+// Creates new Rss item, FolderItemRequestCompleted is called when done
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::CreateRssItemL( TInt aRssParentUid, const TDesC& aName, const TDesC& aUrl, TBool aIsFolder )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aRssParentUid: %d", aRssParentUid);
+    LOGGER_WRITE_1("aName: %S", &aName);
+    
+    if ( !iRootFolder.HasRootFolderItem() )
+        {
+        LOGGER_WRITE( "rss root folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    
+    const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+    
+    // check that parent folder exists
+    const CFolderItem* parent = rootFolder.Search( aRssParentUid );
+    if ( !parent )
+        {
+        LOGGER_WRITE( "parent folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    
+    // check that folder does not already exists
+    const CFolderItem* existingItem = parent->Search( aName );
+    if ( existingItem )
+        {
+        LOGGER_WRITE("Same name already exist, return KErrAlreadyExists");
+        User::Leave( KErrAlreadyExists );
+        }
+    
+    TInt err(KErrNone);
+    // async func. FolderItemRequestCompleted is called when completed
+    TRAP( err, iRootFolder.AddFolderItemL(
+        aName,
+        aUrl,
+        aIsFolder,
+        *parent ) );
+    LOGGER_WRITE_1( "iRootFolder.AddFolderItemL err: %d", err );
+    
+    iNewItemName.Copy( aName );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::ReplaceRssItemL
+// Replaces rss item, FolderItemRequestCompleted is called when done
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::ReplaceRssItemL( TInt aRssItemUid, const TDesC& aNewName, const TDesC& aNewUrl )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aRssItemUid: %d", aRssItemUid);
+    LOGGER_WRITE_1("aNewName: %S", &aNewName);
+    LOGGER_WRITE_1("aNewUrl: %S", &aNewUrl);
+    
+    if ( !iRootFolder.HasRootFolderItem() )
+        {
+        LOGGER_WRITE( "rss root folder not found" );
+        User::Leave( KErrNotFound );
+        }
+    const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+    LOGGER_WRITE_1( "rootFolder.Search %d", aRssItemUid );
+    const CFolderItem* rssItem = rootFolder.Search( aRssItemUid );
+    if ( !rssItem )
+        {
+        LOGGER_WRITE( "rssItem not found" );
+        User::Leave( KErrNotFound );
+        }
+    
+    // async func. FolderItemRequestCompleted is called when completed
+    if ( rssItem->IsFolder() )
+        {
+        iRootFolder.ChangeFolderItemL(
+        *rssItem,
+        aNewName,
+        KNullDesC );
+        }
+    else
+        {
+        iRootFolder.ChangeFolderItemL(
+        *rssItem,
+        aNewName,
+        aNewUrl );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCloseItem
+// Closes open item in the data store
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCloseItem()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCloseItem" );
+    
+    // Make sure that we're opened an item
+    if ( iCurrentState == EBookmarkOpen )
+        {
+        // Reset read buffer 
+        iReaderPosition = KDataBufferNotReady;
+        SAFEDELETE( iDataBuffer );
+        
+        // Start to wait for the next operation     
+        iCurrentState = EOpenAndWaiting;
+        }
+    else 
+        {
+        LOGGER_WRITE_1( "Invalid state %d.", iCurrentState );
+        }   
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCloseItem" );    
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoMoveItemL
+// Moves item from one bookmark folder to another 
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoMoveItemL( TSmlDbItemUid aUid,
+    TSmlDbItemUid aNewParent, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoMoveItemL" );
+    LOGGER_WRITE_1("aUid: %d", aUid);
+    LOGGER_WRITE_1("new parent: %d", aNewParent);
+
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+
+    TInt err( KErrNone ); 
+    
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "WARNING! Invalid state: %d", iCurrentState );
+        }
+    
+    if ( aUid < KRssFeedsOffset )
+        {
+        // Bookmark item
+        LOGGER_WRITE( "Bookmark item" );
+        // Ensure that new parent folder exists 
+        TBool folderExists( EFalse );   
+        err = iDb.FolderExists( aNewParent, folderExists );
+        if ( err || !folderExists )
+            {
+            User::RequestComplete( iCallerStatus, KErrPathNotFound );
+            LOGGER_WRITE_1( "iDb.FolderExist returned %d, new parent folder not found", err );
+            return;
+            }   
+        
+        CFavouritesItem* item = CFavouritesItem::NewLC();
+
+        err = iDb.Get( aUid, *item );
+        if ( err == KErrNone )
+            {
+            if ( item->ParentFolder() != aNewParent )
+                {
+                TTime time = item->Modified();
+                
+                // Parent was changed, set new
+                item->SetParentFolder( aNewParent );
+
+                // Update, this'll move the item
+                err = iDb.Update( *item, aUid, ETrue );
+                
+                if ( err == KErrNone )
+                    {
+                    // Do not change the timestamp, otherwise this will be
+                    // considered to be 'updated' item instead of moved one
+                    err = iDb.SetModified(aUid, time);
+                    if ( err != KErrNone )
+                        {
+                        LOGGER_WRITE_1( "iDb.SetModified(aUid, time) failed (%d).", err );
+                        }
+                        
+                    // Inform ChangeFinder of updated item
+                    TSnapshotItem snapshotItem( aUid );
+                    snapshotItem.SetParentId( iParentFolder );
+                    snapshotItem.CreateHashL( item->Name(), item->Url() );
+                    iChangeFinder->ItemMovedL( snapshotItem );
+                    }
+                else 
+                    {
+                    LOGGER_WRITE_1( "iDb.Update(*item, aUid, ETrue) failed (%d).", err );
+                    }               
+                }
+            else 
+                {
+                LOGGER_WRITE( "Ignoring move (parent was already correct)." );
+                }           
+            }
+        else
+            {
+            LOGGER_WRITE_1( "RFavouritesDb::Get failed with %d", err );
+            err = KErrNotFound;
+            }
+
+        CleanupStack::PopAndDestroy( item );
+        User::RequestComplete( iCallerStatus, err ); 
+        }
+    else
+        {
+        // RRS item
+        LOGGER_WRITE( "RSS item" );
+        if ( !iRootFolder.HasRootFolderItem() )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rss root folder not found" );
+            return;
+            }
+        const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+        const CFolderItem* rssItem = rootFolder.Search( aUid - KRssFeedsOffset );
+        if ( !rssItem )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rssItem not found" );
+            return;
+            }
+        LOGGER_WRITE_1("rssItem->Id(): %d", rssItem->Id());
+        if ( !rssItem->Parent() )
+            {
+            // this is "RSS Root" folder, can't move
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "RSS Root folder, can't move" );
+            return;
+            }
+        const CFolderItem* parent = rootFolder.Search( aNewParent - KRssFeedsOffset );
+        if ( !parent )
+            {
+            // new parent not found
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "new parent not found" );
+            return;
+            }
+        if ( !parent->IsFolder() )
+            {
+            // not a folder
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "parent is not a folder" );
+            return;
+            }
+        RPointerArray<const CFolderItem> movedItems;
+        CleanupClosePushL( movedItems );
+        movedItems.Append( rssItem );
+        // FolderItemRequestCompleted is called when ready
+        iRootFolder.MoveFolderItemsToL( movedItems, *parent);
+        CleanupStack::PopAndDestroy( &movedItems );
+              
+        delete iMovedItem;
+        iMovedItem = NULL;
+        iMovedItem = new (ELeave) TSnapshotItem( aUid, aNewParent );
+        
+        iCurrentState = EBookmarkMoving;
+        LOGGER_WRITE( "Wait for FolderItemRequestCompleted.." );
+        }   
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoMoveItemL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoDeleteItemL
+// Removes item from the message store
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoDeleteItemL" );
+    LOGGER_WRITE_1( "aUid: %d", aUid );
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CBookmarkDataStore::DoDeleteItemL, Incorrect state: %d", iCurrentState);
+        }
+    
+    TInt error( KErrNone );
+    if ( aUid < KRssFeedsOffset )
+        {
+        LOGGER_WRITE( "Delete Bookmark item" );
+        // Delete item from db and return the error code
+        error = iDb.Delete( aUid );
+        
+        if ( error == KErrNone )
+            {
+            // Inform ChangeFinder of the removed item
+            TSnapshotItem item( aUid );     
+            iChangeFinder->ItemDeletedL( item );
+            }
+        else
+            {
+            LOGGER_WRITE_1("CBookmarkDataStore::DoDeleteItemL, iDb.Delete failed: %d", error);
+            }
+        
+        User::RequestComplete( iCallerStatus, error );
+        }
+    else
+        {
+        LOGGER_WRITE( "Delete RSS item" );
+        if ( !iRootFolder.HasRootFolderItem() )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "rss root folder not found" );
+            LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeleteItemL" );
+            return;
+            }
+        const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+        const CFolderItem* item = rootFolder.Search( aUid - KRssFeedsOffset );
+        if ( !item )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound );
+            LOGGER_WRITE( "item not found" );
+            LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeleteItemL" );
+            return;
+            }
+        
+        LOGGER_WRITE_1("founded. item->Id(): %d", item->Id());
+        if ( !item->Parent() )
+            {
+            LOGGER_WRITE_1(
+            "Item parent not found, this is root folder. Return error: %d", KErrAccessDenied);
+            User::RequestComplete( iCallerStatus, KErrAccessDenied );
+            LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeleteItemL" );
+            return;
+            }
+        else
+            {
+            LOGGER_WRITE( "parent found" );
+            }
+        
+        RPointerArray<const CFolderItem> folderItems;
+        CleanupClosePushL( folderItems );
+        error = folderItems.Append( item );
+        LOGGER_WRITE_1( "folderItems.Append error: %d", error );
+        TRAP( error, iRootFolder.DeleteFolderItemsL( folderItems ) );
+        CleanupStack::PopAndDestroy( &folderItems );
+        LOGGER_WRITE_1( "Trap error: %d", error );
+        
+        iReplaceItem = aUid;
+        iCurrentState = EBookmarkDeleting;
+        LOGGER_WRITE( "Wait for FolderItemRequestCompleted.." );
+        }
+        
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeleteItemL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoSoftDeleteItemL
+// Soft delete isn't supported.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoSoftDeleteItemL(TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus)
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoSoftDeleteItemL" );
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    User::RequestComplete(iCallerStatus, KErrNotSupported); 
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoSoftDeleteItemL" );  
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoDeleteAllItemsL
+// Deletes all items in the standard folders of bookmark store
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoDeleteAllItemsL" );
+
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+
+    // Check that we're in proper state
+    if (iCurrentState != EOpenAndWaiting) 
+        {
+        LOGGER_WRITE_1( "CSmsDataStore::DoDeleteAllItemsL, Incorrect state: %d", iCurrentState );
+        }
+
+    // Reset the whole change finder
+    iChangeFinder->ResetL();
+    
+    // Delete all Bookmark items
+    LOGGER_WRITE( "Delete Bookmark items" );
+    // Loop through all items at root, and delete everything
+    CFavouritesItemList* list = new ( ELeave ) CFavouritesItemList();
+    TInt error = iDb.GetAll( *list, KFavouritesRootUid );
+    if ( error == KErrNone )  
+        {
+        // Loop through the list and delete all items
+        TInt count = list->Count();
+        LOGGER_WRITE_1("list->Count(): %d", count);
+        for ( TInt i = 0; i < count; ++i )
+            {
+            CFavouritesItem* item = (*list)[i];
+        
+            // Don't bother try to erase items, which are read only
+            if ( !item->IsFactoryItem() )
+                {
+                TInt deleted = iDb.Delete( item->Uid() );
+                if ( deleted != KErrNone )
+                    {
+                    // In the case of error, store the error value
+                    error = deleted;
+                    LOGGER_WRITE_1("CBookmarkDataStore::DoDeleteAllItemsL, iDb.Delete failed: %d", error);
+                    }
+                
+                LOGGER_WRITE_1("item->Uid(): %d", item->Uid())
+                LOGGER_WRITE_1("iDb.Delete ret: %d", error)
+                
+                }
+            else
+                {
+                LOGGER_WRITE_1("item->IsFactoryItem(): id: %d", item->Uid());
+                }
+            }
+        }
+    else
+        {
+        LOGGER_WRITE_1("CBookmarkDataStore::DoDeleteAllItemsL, iDb.GetAll failed: %d", error);
+        }
+    delete list;
+    
+    // Delete all WebFeeds
+    LOGGER_WRITE( "Delete RSS items" );
+    if ( !iRootFolder.HasRootFolderItem() )
+        {
+        User::RequestComplete( iCallerStatus, error );
+        LOGGER_WRITE( "no RSS items" );
+        return;
+        }
+    const CFolderItem& rootFolder = iRootFolder.RootFolderItem();
+    // add subfolders
+    RPointerArray<const CFolderItem> folderItems;
+    CleanupClosePushL( folderItems );
+    for ( TInt i = 0; i < rootFolder.FolderItemCount(); i++)
+        {
+        error = folderItems.Append( rootFolder.FolderItemAt( i ) );
+        LOGGER_WRITE_1( "folderItems.Append error: %d", error );
+        }
+    
+    if ( folderItems.Count() > 0 )
+        {
+        TRAP( error, iRootFolder.DeleteFolderItemsL( folderItems ) );
+        
+        LOGGER_WRITE_1( "Trap error: %d", error );
+        
+        iCurrentState = EBookmarkDeletingAll;
+        LOGGER_WRITE( "Wait for FolderItemRequestCompleted.." );
+        }
+    else
+        {
+        LOGGER_WRITE( "RSS items not found" );
+        User::RequestComplete( iCallerStatus, KErrNone ); 
+        }
+    CleanupStack::PopAndDestroy( &folderItems );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeleteAllItemsL" );          
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoHasSyncHistory
+// This method returns ETrue if Data Store has history information. 
+// Slow-sync will be used if Data Store does not have history information.
+// -----------------------------------------------------------------------------
+TBool CBookmarkDataStore::DoHasSyncHistory() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoHasSyncHistory" );
+    LOGGER_WRITE_1( "iHasHistory: %d", iHasHistory );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoHasSyncHistory" );   
+    return iHasHistory;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoAddedItems
+// This method returns UIDs of added items. Those items are added after previous
+// synchronization with current synchronization relationship. 
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CBookmarkDataStore::DoAddedItems() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoAddedItems" );
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoAddedItems, invalid state %d.", iCurrentState );
+        }
+    
+    TInt error(KErrNone);
+    
+    // Clear new-items array
+    iNewItems->Reset();
+    
+    // Search for new items
+    TRAP( error, iChangeFinder->FindNewItemsL( *iNewItems ) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error );
+        } 
+    
+    LOGGER_WRITE_1( "New item count: %d.", iNewItems->ItemCount() );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoAddedItems" );
+    
+    return *iNewItems;  
+    }
+    
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoDeletedItems
+// Returns ids of items, which are deleted after previous synchronization
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CBookmarkDataStore::DoDeletedItems() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoDeletedItemsL" );    
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoDeletedItems, invalid state %d.", iCurrentState );
+        }
+    
+    TInt error( KErrNone );
+    
+    // Clear deleted-items array
+    iDeletedItems->Reset();
+    
+    // Search for deleted items
+    TRAP( error, iChangeFinder->FindDeletedItemsL( *iDeletedItems ) );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error );
+        }
+    
+    LOGGER_WRITE_1( "Deleted item count: %d.", iDeletedItems->ItemCount() );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoDeletedItemsL" );
+    return *iDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoSoftDeletedItems
+// Not directly supported, empty list returned
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CBookmarkDataStore::DoSoftDeletedItems() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoSoftDeletedItems" );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoSoftDeletedItems" );         
+
+    // Return empty array as a result
+    iSoftDeletedItems->Reset();
+    return *iSoftDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoModifiedItems
+// Finds all modified items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CBookmarkDataStore::DoModifiedItems() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoModifiedItems" );    
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoModifiedItems, invalid state %d.", iCurrentState );
+        }
+
+    TInt error( KErrNone );
+
+    // Clear updated-items array
+    iUpdatedItems->Reset();
+    
+    // Search for updated items
+    TRAP( error, iChangeFinder->FindChangedItemsL( *iUpdatedItems ) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error );
+        }
+    
+    LOGGER_WRITE_1( "Modified item count: %d.", iUpdatedItems->ItemCount() );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoModifiedItems" );        
+    return *iUpdatedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoMovedItems
+// Finds all moved items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CBookmarkDataStore::DoMovedItems() const
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoMovedItems" );   
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoMovedItems, invalid state %d.", iCurrentState );
+        }       
+    
+    TInt error( KErrNone );
+    
+    // Clear moved-items array
+    iMovedItems->Reset();
+    
+    TRAP( error, iChangeFinder->FindMovedItemsL( *iMovedItems ) );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoMovedItems, iChangeFinder->FindMovedItemsL leaved with %d.", error );
+        }
+       
+    LOGGER_WRITE_1( "Moved item count: %d.", iMovedItems->ItemCount() );
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoMovedItems" );
+    return *iMovedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoResetChangeInfoL
+// Resets change history in the data store. All content is considered
+// new in the data store point of view.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoResetChangeInfoL" );
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoResetChangeInfoL, invalid state %d.", iCurrentState );
+        }   
+            
+    // Reset change info in ChangeFinder
+    iChangeFinder->ResetL();
+    iHasHistory = EFalse;
+    
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );   
+        
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoResetChangeInfoL" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCommitChangeInfoL
+// Commits change info. These items are no longer reported, when change
+// information is being queried.
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus,
+    const MSmlDataItemUidSet& aItems )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCommitChangeInfoL(1)" );
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState );
+        }
+
+    // Notify ChangeFinder
+    LOGGER_WRITE_1( "CBookmarkDataStore::DoCommitChangeInfoL, item count %d.", aItems.ItemCount() );
+    iChangeFinder->CommitChangesL( aItems );
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    LOGGER_LEAVEFN(" CBookmarkDataStore::DoCommitChangeInfoL(1)" ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::DoCommitChangeInfoL
+// Commits change info. There is no more nothing to report when change
+// information is being queried. 
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::DoCommitChangeInfoL(2)" );
+
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CBookmarkDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState );
+        }
+    
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL();
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+        
+    LOGGER_LEAVEFN( "CBookmarkDataStore::DoCommitChangeInfoL(2)" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::RegisterSnapshotL
+// Sets Changefinder to compare against current bookmark store content
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::RegisterSnapshotL()
+    {
+    LOGGER_ENTERFN( "CBookmarkDataStore::RegisterSnapshotL()" );
+    
+    CArrayFixSeg<TSnapshotItem>* snapshot = 
+        new ( ELeave ) CArrayFixSeg<TSnapshotItem>( KSnapshotGranularity );
+    CleanupStack::PushL( snapshot );
+    
+    
+    RegisterToSnapshotL( snapshot, KFavouritesRootUid );
+    
+    if ( iRootFolder.HasRootFolderItem() )
+        {
+        RegisterRssFeedsToSnapshotL( snapshot, iRootFolder.RootFolderItem() );
+        }
+    
+    // Set new snapshot to compare against
+    iChangeFinder->SetNewSnapshot( snapshot );
+    
+    // Changefinder takes ownership of the snapshot
+    CleanupStack::Pop( snapshot );
+    
+    LOGGER_LEAVEFN( "CBookmarkDataStore::RegisterSnapshotL()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::RegisterToSnapshotL
+// Adds recursively all the bookmark items to the snapshot
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::RegisterToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot,
+    TInt aFolderUid )
+    {
+    CFavouritesItemList* list = new ( ELeave ) CFavouritesItemList;
+    CleanupStack::PushL( list );
+    TInt error = iDb.GetAll( *list, aFolderUid );
+    if ( error == KErrNone )
+        {
+        // Loop through the list. Add folders and items to the snapshot
+        TInt count = list->Count();
+        for ( TInt i = 0; i < count; ++i )
+            {
+            CFavouritesItem* item = (*list)[i];
+            // No matter whether it's a folder or item, we'll add it to snapshot
+            TSnapshotItem snapshotItem( item->Uid() );
+            snapshotItem.SetParentId( item->ParentFolder() );
+            snapshotItem.CreateHashL( item->Name(), item->Url() );
+            TKeyArrayFix key( iKey );
+            aSnapshot->InsertIsqL( snapshotItem, key );
+
+            // Remember to add also childs in case of folder (recurse)
+            if ( item->Type() == CFavouritesItem::EFolder )
+                {
+                RegisterToSnapshotL( aSnapshot, item->Uid() );
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( list ); //list
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::RegisterRssFeedsToSnapshotL
+// Adds recursively all the rssFeed items to the snapshot
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::RegisterRssFeedsToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot,
+    const CFolderItem& folder )
+    {
+    TSnapshotItem snapshotItem( folder.Id() + KRssFeedsOffset );
+    
+    const CFolderItem* parent = folder.Parent();
+    if ( parent )
+        {
+        snapshotItem.SetParentId( parent->Id() + KRssFeedsOffset );
+        }
+    else
+        {
+        snapshotItem.SetParentId( KErrNotFound );
+        }
+    snapshotItem.CreateHashL( folder.Name(), folder.SourceUrl() );
+    
+    TKeyArrayFix key( iKey );
+    aSnapshot->InsertIsqL( snapshotItem, key );
+    
+    // add subfolders
+    for ( TInt i = 0; i < folder.FolderItemCount(); i++)
+        {
+        RegisterRssFeedsToSnapshotL( aSnapshot, *(folder.FolderItemAt( i ) ));
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CBookmarkDataStore::AssignString
+// Assigns data from one descriptor into another, truncates if too long 
+// -----------------------------------------------------------------------------
+void CBookmarkDataStore::AssignString( TDes8& aDestination, const TDesC8& aSource )
+    {
+    TInt targetLength = aSource.Length();
+    if ( aDestination.MaxLength() < targetLength )
+        {
+        targetLength = aDestination.MaxLength();
+        }
+        
+    aDestination.Copy( aSource.Ptr(), targetLength );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdatastore.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource data for Bookmark DS Plug In Adapter
+*
+*/
+
+
+#include <SmlDataFormat.rh>
+#include <SmlDataFormat.hrh>
+
+RESOURCE SML_DATA_STORE_FORMAT BOOKMARK_DATA_STORE
+    {
+    version = 1;
+    display_name = "Bookmarks";
+    sync_types = KSmlSyncType_TwoWay + KSmlSyncType_OneWayFromSvr + KSmlSyncType_OneWayFromClnt + KSmlSyncType_SlowSync + KSmlSyncType_RefreshFromSvr + KSmlSyncType_RefreshFromClnt;
+    mime_format=
+        {
+        SML_MIME_FORMAT
+            {
+            version = 1;
+            mime_type = "text/x-vBookmark";
+            mime_ver = "1.0";
+            properties= 
+                {
+                SML_DATA_PROPERTY
+                    {
+                    version = 1;
+                    display_name = "Read";
+                    name = "read";
+                    data_type = "bool";
+                    enum_values = {};
+                    flags = 0;
+                    max_size = 0;
+                    max_occur = 1;
+                    params = {};
+                    }
+                };
+            field_level = 0;
+            },
+        SML_MIME_FORMAT
+            {
+            version = 1;
+            mime_type = "application/vnd.omads-folder+xml";
+            mime_ver = "1.0";
+            properties= 
+                {
+                SML_DATA_PROPERTY
+                    {
+                    version = 1;
+                    display_name = "Read";
+                    name = "read";
+                    data_type = "bool";
+                    enum_values = {};
+                    flags = 0;
+                    max_size = 0;
+                    max_occur = 1;
+                    params = {};
+                    }
+                };
+            field_level = 0;
+            }           
+        };
+    mime_format_tx_pref = 0;    // Preferred index for tx
+    mime_format_rx_pref = 0;    // Preferred index for rx
+    folder_properties = {};     // No folder properties
+    filter_capabilities = {};   // No filter capabilities
+    max_size = 0;               // No limit
+    max_items = 0;              // No limit
+    flags = 0x00000010;         // Hierarchical sync supported
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdsa.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project Bookmark DS Plugin
+*
+*/
+
+
+
+// -----------------------------------------------------------------------------
+//  RESOURCE IDENTIFIER
+// -----------------------------------------------------------------------------
+//
+NAME BKDS
+
+// -----------------------------------------------------------------------------
+//  INCLUDE FILES
+// -----------------------------------------------------------------------------
+//
+#include <eikon.rh>	
+#include <eikon.rsg>	
+
+#include <bookmarkdsa.loc>
+
+
+RESOURCE RSS_SIGNATURE { }
+
+
+RESOURCE TBUF r_bookmarkdsa_folder_download_applications { buf = qtn_bookmarkdsa_folder_download_applications; }
+RESOURCE TBUF r_bookmarkdsa_folder_download_images { buf = qtn_bookmarkdsa_folder_download_images; }
+RESOURCE TBUF r_bookmarkdsa_folder_download_tones { buf = qtn_bookmarkdsa_folder_download_tones; }
+RESOURCE TBUF r_bookmarkdsa_folder_download_videos { buf = qtn_bookmarkdsa_folder_download_videos; }
+RESOURCE TBUF r_bookmarkdsa_folder_download_skins { buf = qtn_bookmarkdsa_folder_download_skins; }
+RESOURCE TBUF r_bookmarkdsa_folder_download_music { buf = qtn_bookmarkdsa_folder_download_music; }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/changefinder.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,588 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include "changefinder.h"
+#include "logger.h"
+
+const TUint KSnapshotFormatVersion ( 0xf0000001 ); // format version
+// -----------------------------------------------------------------------------
+// CChangeFinder::NewL
+// Static function to create CChangeFider object(s)
+// -----------------------------------------------------------------------------
+CChangeFinder* CChangeFinder::NewL( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey,
+        TBool& aHasHistory, TInt aStreamUid )
+    {
+    CChangeFinder* self = new (ELeave) CChangeFinder( aSyncRelationship, aKey, aStreamUid );
+    CleanupStack::PushL( self );
+    self->ConstructL( aHasHistory );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CChangeFinder
+// Constructor for the class
+// -----------------------------------------------------------------------------
+CChangeFinder::CChangeFinder( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey, TInt aStreamUid ) :
+iSyncRelationship( aSyncRelationship ),
+iKey( aKey ),
+iStreamUid( aStreamUid ),
+iDataStoreUid( KErrNotFound )
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::~CChangeFinder
+// Destructor for the class, closes the ChangeFinder and writes snapshot to stream
+// -----------------------------------------------------------------------------
+CChangeFinder::~CChangeFinder()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::~CChangeFinder" );
+    delete iOldSnapshot;
+	delete iCurrentSnapshot;
+    LOGGER_LEAVEFN( "CChangeFinder::~CChangeFinder" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ConstructL
+// 2nd phase constructor for the class, reads snapshot from stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::ConstructL( TBool& aHasHistory )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ConstructL" );
+    iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+	iCurrentSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+    LOGGER_WRITE("CChangeFinder::ConstructL, CSnapshotArray:s created");
+    TUid uid = {iStreamUid};
+    
+    aHasHistory = iSyncRelationship.IsStreamPresentL( uid );
+    
+    if ( aHasHistory )
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, HasHistory");
+        // Open stream for reading
+        RReadStream readStream;
+        iSyncRelationship.OpenReadStreamLC( readStream, uid );
+        
+        // Read used format version
+        TUint formatVer = readStream.ReadUint32L();
+        if ( formatVer != KSnapshotFormatVersion )
+            {
+            // Wrong version, do not try to import data
+            LOGGER_WRITE("CChangeFinder::ConstructL, Wrong format version -> no history");
+            aHasHistory = EFalse;
+            CleanupStack::PopAndDestroy( &readStream );
+            LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+            return;
+            }
+        else
+            {
+            LOGGER_WRITE("CChangeFinder::ConstructL, format is OK");
+            }
+        
+        // Read item count
+        TInt count = readStream.ReadUint32L();
+        
+        // Read items
+        for ( TInt i=0; i<count; i++ )
+            {
+            TSnapshotItem item;
+            item.InternalizeL( readStream );
+            iOldSnapshot->InsertIsqL( item, iKey );
+            }
+        iOldSnapshot->Compress();
+        
+        LOGGER_WRITE_1("iOldSnapshot done, iOldSnapshot->Count: %d", iOldSnapshot->Count() );
+        CleanupStack::PopAndDestroy( &readStream ); // readStream
+        }
+    else
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, no sync history.");
+        }
+        
+    LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CloseL
+// Closes ChangeFinder object and writes snapshot to stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::CloseL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CloseL" );
+     
+    RWriteStream writeStream;
+    
+    TUid uid = {iStreamUid};
+    
+    // Open write stream
+    iSyncRelationship.OpenWriteStreamLC( writeStream, uid );
+    
+    // Write used format version
+    writeStream.WriteUint32L( KSnapshotFormatVersion );
+    
+    // Write item count
+    TInt count = iOldSnapshot->Count();
+    writeStream.WriteUint32L( count );
+    
+    // Write items
+    for ( TInt i = 0; i < count; i++ )
+        {
+        const TSnapshotItem& item = iOldSnapshot->At( i );
+        item.ExternalizeL( writeStream );
+        }
+    
+    writeStream.CommitL();
+    CleanupStack::PopAndDestroy( &writeStream ); // writeStream
+    
+    LOGGER_LEAVEFN( "CChangeFinder::CloseL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ResetL
+// Resets synchronization history, all contetn is considered new after this call
+// -----------------------------------------------------------------------------
+void CChangeFinder::ResetL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ResetL" );
+    if ( iOldSnapshot )
+        {
+        LOGGER_WRITE("iOldSnapshot->Reset()");
+        iOldSnapshot->Reset();
+        }
+
+    // Write 'null' data to file, 
+    // this removes change history from the file
+    CloseL();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ResetL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindChangedItemsL
+// Compares snapshots, finds changed items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids )
+    {   
+    LOGGER_ENTERFN( "CChangeFinder::FindChangedItemsL" );
+    aChangedUids.Reset();
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    LOGGER_WRITE_1( "CChangeFinder::FindChangedItemsL items on iCurrentSnapshot: %d", count );
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // Find this entry from the old snapshot
+        if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            if ( currentItem.Hash().Compare( oldItem.Hash() ) != 0 )
+                {
+                // add to list
+				User::LeaveIfError( aChangedUids.AddItem( currentItem.ItemId() ) );
+                }
+            }
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindChangedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindDeletedItemsL
+// Compares snapshots, finds deleted items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindDeletedItemsL" );
+    aDeletedUids.Reset();
+    if ( !iOldSnapshot )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iOldSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iOldSnapshot->At( i );
+        
+        // If there's no current snapshot, this definately is deleted item
+        if ( !iCurrentSnapshot )
+            {
+            User::LeaveIfError( aDeletedUids.AddItem( currentItem.ItemId() ) );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the current snapshot.
+        else if ( iCurrentSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            User::LeaveIfError( aDeletedUids.AddItem( currentItem.ItemId() ) );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindNewItemsL
+// Compares snapshots, finds new items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindNewItemsL( CNSmlDataItemUidSet& aNewUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindNewItemsL" );
+    aNewUids.Reset();
+    /*if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindNewItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }*/
+
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    LOGGER_WRITE_1( "iCurrentSnapshot->Count(): %d", count );
+    LOGGER_WRITE_1( "iOldSnapshot->Count(): %d", iOldSnapshot->Count() );
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // If there's no old snapshot, all items are new
+        if ( !iOldSnapshot )
+            {
+            User::LeaveIfError( aNewUids.AddItem( currentItem.ItemId() ) );
+            LOGGER_WRITE_1( "!iOldSnapshot, Item %d was new.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the old snapshot.
+        else if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            User::LeaveIfError( aNewUids.AddItem( currentItem.ItemId() ) );
+            LOGGER_WRITE_1( "Item %d was new.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindNewItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindMovedItemsL
+// Compares snapshots, finds moved items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindMovedItemsL" );
+    aMovedUids.Reset();
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // Find this entry from the old snapshot
+        if(iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            
+            // Report only moved items in which only parent id has been changed
+            if ( oldItem.ParentId() != currentItem.ParentId()
+                && currentItem.Hash().Compare( oldItem.Hash() ) == 0 )
+                {
+                User::LeaveIfError( aMovedUids.AddItem( currentItem.ItemId() ) );
+                LOGGER_WRITE_1( "Item %d was moved.", currentItem.ItemId() );
+                }
+            }       
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindMovedItemsL" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemAddedL
+// Adds item to snapshot, this item is no longer considered new
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemAddedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemAddedL" );
+    
+    // Add this to old snapshot, if there's no old snapshot it must be created
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    LOGGER_WRITE_1( "Adding item %d.", aItem.ItemId() );
+    
+    iOldSnapshot->InsertIsqL( aItem, iKey );
+    iOldSnapshot->Compress();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ItemAddedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemDeletedL
+// Removes item to snapshot, this item is no longer considered deleted
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemDeletedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemDeletedL" );
+    
+    LOGGER_WRITE_1( "deleting item %d.", aItem.ItemId() );
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::ItemDeletedL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+    
+    // Delete item from the old snapshot
+    TInt index;
+    if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+        {
+        iOldSnapshot->Delete( index );
+        }
+    else // Skip, there wasn't such entry
+        {
+        LOGGER_WRITE( "iOldSnapshot->FindIsq, item was not found." );
+        }  
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ItemDeletedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemUpdatedL
+// Updates item to snapshot, this item is no longer considered changed
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemUpdatedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemUpdatedL" );
+
+    LOGGER_WRITE_1( "Updating item %d.", aItem.ItemId() );
+    
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            iOldSnapshot->At( index ) = aItem;
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }
+        
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::ItemUpdatedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemMovedL
+// Moves item within snapshot, this item is no longer considered moved
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemMovedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemMovedL" );
+    
+    LOGGER_WRITE_1( "Moving item %d.", aItem.ItemId() );
+            
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item's parent in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            iOldSnapshot->At(index) = aItem;
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }   
+        }
+    
+    LOGGER_LEAVEFN("CChangeFinder::ItemMovedL");    
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    // Delete everything from the old snapshot
+    iOldSnapshot->Reset();
+    
+    // Loop through all the items in current snapshot
+    TInt count = iCurrentSnapshot->Count();
+    
+    // Copy everything from current to old snapshot
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Commit it to the old array.
+        iOldSnapshot->InsertIsqL( iCurrentSnapshot->At( i ), iKey );
+        }
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot, affects only a specified group of items
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL( const MSmlDataItemUidSet& aUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    // This function commits changes from current snapshot to old snapshot
+    // But commits only the entries in the parameter array
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+    
+    for ( TInt i = 0; i < aUids.ItemCount(); i++ )
+		{
+		TSmlDbItemUid itemId = aUids.ItemAt( i );
+		TSnapshotItem temp( itemId );
+		TInt indexOld( -1 );
+		TInt indexNew( -1 );
+		if ( !iOldSnapshot->FindIsq( temp, iKey, indexOld) )
+			{
+			if ( !iCurrentSnapshot->FindIsq(temp, iKey, indexNew) )
+				{
+				// Replace, moved or softdeleted
+				iOldSnapshot->At( indexOld ) = iCurrentSnapshot->At( indexNew );
+				}
+			else
+				{
+				// Delete
+				iOldSnapshot->Delete( indexOld );
+				}
+			}
+		else
+			{
+			// Add
+			if ( !iCurrentSnapshot->FindIsq( temp, iKey, indexNew ) )
+			    {
+			    iOldSnapshot->InsertIsqL( iCurrentSnapshot->At( indexNew ), iKey );
+			    }
+			}
+		}
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetNewSnapshot
+// Sets new snapshot (to be compared against), ChangeFinder takes ownership
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetNewSnapshot( CSnapshotArray* aNewSnapshot )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetNewSnapshot" );
+    
+    // Delete existing snapshot
+    delete iCurrentSnapshot;
+    
+    // Set submitted snapshot as active
+    iCurrentSnapshot = aNewSnapshot;
+    LOGGER_LEAVEFN( "CChangeFinder::SetNewSnapshot" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::DataStoreUid
+// returns stored data store id number
+// -----------------------------------------------------------------------------
+TInt64 CChangeFinder::DataStoreUid() const
+    {
+    LOGGER_ENTERFN( "CChangeFinder::DataStoreUid" );
+    LOGGER_LEAVEFN( "CChangeFinder::DataStoreUid" );
+    return iDataStoreUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetDataStoreUid
+// Sets data store id number
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetDataStoreUid( TInt64 aUid )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetDataStoreUid" );
+    iDataStoreUid = aUid;
+    LOGGER_LEAVEFN( "CChangeFinder::SetDataStoreUid" );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/conversionutil.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Conversion utility
+*
+*/
+
+#include <FeedsServerFolderItem.h>
+#include "conversionutil.h"
+#include "omadsfolderobject.h"
+#include "vbookmarkconverter.h"
+#include "logger.h"
+
+
+// -----------------------------------------------------------------------------
+// NewL
+// Creates the object
+// ----------------------------------------------------------------------------- 
+CBookmarkConversionUtil* CBookmarkConversionUtil::NewL()
+    {
+    CBookmarkConversionUtil* self = CBookmarkConversionUtil::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// NewLC
+// Creates the object and leaves it into the cleanup stack
+// ----------------------------------------------------------------------------- 
+CBookmarkConversionUtil* CBookmarkConversionUtil::NewLC()
+    {
+    CBookmarkConversionUtil* self = new ( ELeave ) CBookmarkConversionUtil();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// ConstructL
+// 2nd phase constructor
+// ----------------------------------------------------------------------------- 
+void CBookmarkConversionUtil::ConstructL()
+    {
+    // Create OMA DS folder object converter
+    iOmaConverter = COMADSFolderObject::NewL();
+
+    // Create vBookmark converter
+    iVBookmarkConverter = CVBookmarkConverter::NewL();    
+    }
+
+// -----------------------------------------------------------------------------
+// ~CBookmarkConversionUtil
+// Destroys all allocated resources
+// ----------------------------------------------------------------------------- 
+CBookmarkConversionUtil::~CBookmarkConversionUtil()
+    {
+    delete iOmaConverter;
+    iOmaConverter = NULL;
+    
+    delete iVBookmarkConverter;
+    iVBookmarkConverter = NULL;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// FavouritesItemToBufferL
+// Converts CFavouritesItem to it's binary sync representation
+// -----------------------------------------------------------------------------  
+void CBookmarkConversionUtil::FavouritesItemToBufferL(
+    const CFavouritesItem& aItem, CBufFlat& aBuffer)
+    {
+    LOGGER_ENTERFN( "CBookmarkConversionUtil::FavouritesItemToBufferL" );
+    
+    if( aItem.Type() == CFavouritesItem::EFolder )
+        {
+        // Set input data
+        iOmaConverter->ImportDbItem(aItem);
+        
+        // Export to buffer
+        iOmaConverter->ExportFolderXmlL(aBuffer);
+        }
+    else if( aItem.Type() == CFavouritesItem::EItem )
+        {
+        // Set input data
+        iVBookmarkConverter->ImportDbItemL(aItem);
+        
+        // Export to buffer
+        iVBookmarkConverter->ExportVBookmarkL(aBuffer);
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RssItemToBufferL
+// Converts CFolderItem to it's binary sync representation
+// -----------------------------------------------------------------------------  
+void CBookmarkConversionUtil::RssItemToBufferL(
+    const CFolderItem& aItem, CBufFlat& aBuffer)
+    {
+    LOGGER_ENTERFN( "CBookmarkConversionUtil::RssItemToBufferL" );
+    
+    if( aItem.IsFolder() )
+        {
+        // Set input data
+        iOmaConverter->ImportDbItem(aItem);
+        
+        // Export to buffer
+        iOmaConverter->ExportFolderXmlL(aBuffer);
+        }
+    else
+        {
+        // Set input data
+        iVBookmarkConverter->ImportDbItemL(aItem);
+        
+        // Export to buffer
+        iVBookmarkConverter->ExportVBookmarkL(aBuffer);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// BufferToFavouritesItemL
+// Converts Binary data to CFavouritesItem
+// -----------------------------------------------------------------------------      
+TInt CBookmarkConversionUtil::BufferToFavouritesItemL(CFavouritesItem::TType aType,
+    CBufFlat& aBuffer, CFavouritesItem& aItem)
+    {
+    LOGGER_ENTERFN( "CBookmarkConversionUtil::BufferToFavouritesItemL" );
+    
+    if ( aType == CFavouritesItem::EFolder )
+        {
+        // Import XML data
+        TInt error = iOmaConverter->ImportFolderXml( aBuffer.Ptr( 0 ) );
+        
+        // Convert to CFavouritesItem
+        if ( error == KErrNone )
+            {
+            iOmaConverter->ExportDbItemL( aItem );
+            }
+     
+        return error;
+        }
+    else if ( aType == CFavouritesItem::EItem )
+        {
+        // Import vBookmark data
+        TInt error = iVBookmarkConverter->ImportVBookmarkL( aBuffer.Ptr( 0 ) );
+        
+        // Convert to CFavouritesItem
+        if ( error == KErrNone )
+            {
+            iVBookmarkConverter->ExportDbItemL( aItem );
+            }
+        
+        return error;
+        }
+    else
+        {
+        return KErrNotSupported;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/omadsfolderobject.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,490 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+#include <SenXmlUtils.h>
+#include <SenXmlReader.h>
+#include <FavouritesLimits.h>   // Localized names for folders
+#include <bookmarkdsa.rsg>
+#include <stringresourcereader.h>
+#include <bautils.h>
+#include <utf.h>
+#include <FeedsServerFolderItem.h>
+
+#include "bookmarkdataproviderdefs.h"
+#include "omadsfolderobject.h"
+#include "logger.h"
+
+_LIT( KOMADSResourceName, "\\resource\\bookmarkdsa.rsc" );
+
+_LIT8(KOMADSFolderElement, "Folder");
+_LIT8(KOMADSNameElement, "name");
+_LIT8(KOMADSCreatedElement, "created");
+_LIT8(KOMADSModifiedElement, "modified");
+
+_LIT(KFolderBeginTag, "<Folder>");
+_LIT(KFolderEndTag, "</Folder>");
+_LIT(KNameBeginTag, "<name>");
+_LIT(KNameEndTag, "</name>");
+_LIT(KCreatedBeginTag, "<created>");
+_LIT(KCreatedEndTag, "</created>");
+_LIT(KModifiedBeginTag, "<modified>");
+_LIT(KModifiedEndTag, "</modified>");
+const TInt KDateFormatLength = 15;
+_LIT(KDateFormat, "%04d%02d%02dT%02d%02d%02d");
+
+
+COMADSFolderObject* COMADSFolderObject::NewLC()
+    {
+    COMADSFolderObject* pSelf = new (ELeave) COMADSFolderObject;
+    CleanupStack::PushL(pSelf);
+    pSelf->ConstructL();
+    return pSelf;
+    }
+
+COMADSFolderObject* COMADSFolderObject::NewL()
+    {
+    COMADSFolderObject* pSelf = COMADSFolderObject::NewLC();
+    CleanupStack::Pop( pSelf );    
+    return pSelf;
+    }
+
+COMADSFolderObject::~COMADSFolderObject()
+    {
+    delete iXmlReader;
+    }
+
+void COMADSFolderObject::ConstructL()
+    {
+    iXmlReader = CSenXmlReader::NewL();
+    iXmlReader->SetContentHandler(*this);
+    }
+
+TInt COMADSFolderObject::ImportFolderXml( RFs& aFs, const TDesC& aFilename )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" );    
+        
+    TInt error;
+    
+    Reset();
+    TRAP( error, iXmlReader->ParseL( aFs, aFilename ) )
+    if( error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+TInt COMADSFolderObject::ImportFolderXml( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" ); 
+    
+    TInt error;
+    
+    Reset();
+    
+    TRAP(error, iXmlReader->ParseL(aData) );
+    if(error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL( CBufBase& aBuffer )
+    {
+    iDesc = NULL;
+    iBuffer = &aBuffer;
+    iWriteBufPosition = 0;
+    iWriteBufSize = aBuffer.Size();     
+
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL( TDes8& aBuffer )
+    {
+    iDesc = &aBuffer;
+    iBuffer = NULL;
+    
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportL()
+    {
+    // Folder
+    WriteL( KFolderBeginTag );
+    
+    // Name
+    WriteL( KNameBeginTag );
+    WriteEncodedXmlL( iName );
+    WriteL( KNameEndTag );
+    
+    // Created Date
+    TBuf<KDateFormatLength> tempdate;
+    tempdate.Format( KDateFormat, iCreatedDate.Year(), iCreatedDate.Month() + 1,
+        iCreatedDate.Day(), iCreatedDate.Hour(), iCreatedDate.Minute(), iCreatedDate.Second() );
+    
+    WriteL( KCreatedBeginTag );
+    WriteL( tempdate );
+    WriteL( KCreatedEndTag );
+    
+    // Modified Date
+    tempdate.Format( KDateFormat, iModifiedDate.Year(), iModifiedDate.Month() + 1,
+        iModifiedDate.Day(), iModifiedDate.Hour(), iModifiedDate.Minute(), iModifiedDate.Second() );
+    
+    WriteL( KModifiedBeginTag );
+    WriteL( tempdate );
+    WriteL( KModifiedEndTag );
+    
+    // Folder end
+    WriteL(KFolderEndTag);
+    }
+    
+void COMADSFolderObject::WriteL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + iTemp.Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, iTemp );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( iTemp );       
+        }   
+    }
+    
+void COMADSFolderObject::WriteEncodedXmlL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+    
+    HBufC8* xmlData = SenXmlUtils::EncodeHttpCharactersLC( iTemp ); 
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + xmlData->Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, *xmlData );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( *xmlData );
+        }   
+        
+    CleanupStack::PopAndDestroy( xmlData );   
+    }           
+    
+TInt COMADSFolderObject::StartDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::EndDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::StartElement(const TDesC8& /*aURI*/, 
+                  const TDesC8& /*aLocalName*/, 
+                  const TDesC8& aName, 
+                  const RAttributeArray& /*apAttrs*/)
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::StartElement" );
+    iCurrentElement.Copy( aName );
+    LOGGER_LEAVEFN( "COMADSFolderObject::StartElement" );
+    return KErrNone;
+    }
+                                    
+TInt COMADSFolderObject::EndElement( const TDesC8& /*aURI*/, 
+    const TDesC8& /*aLocalName*/, const TDesC8& /*aName*/ )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::EndElement" );        
+    iCurrentElement.SetLength(0);
+    LOGGER_LEAVEFN( "COMADSFolderObject::EndElement" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::Characters( const TDesC8& aBuf, TInt aStart, TInt aLength )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::Characters" );
+    
+    TInt error;
+    
+    if( iCurrentElement.Compare( KOMADSFolderElement ) == 0 )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+        return KErrNone;
+        }
+    
+    else if ( iCurrentElement.Compare( KOMADSNameElement ) == 0 )
+        {                
+        CnvUtfConverter converter;
+        TBuf<KMaxFolderNameLength> buf;
+        error = converter.ConvertToUnicodeFromUtf8( buf, aBuf.Mid( aStart, aLength ) );
+        TInt length = buf.Length() + iName.Length();
+        
+        if ( error > 0 )
+            {
+            LOGGER_WRITE_1("Too long name, number of uncorverted bytes: %d", error);
+            }
+        else if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 failed with %d", error);
+            iError = error;
+            }
+        else if ( length > iName.MaxLength() )
+            {
+            LOGGER_WRITE_1("Too long name total: %d", length);
+            }
+        else
+            {
+            iName.Append( buf );
+            }       
+        }
+    else if ( iCurrentElement.Compare( KOMADSCreatedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iCreatedDate );
+        if( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    else if ( iCurrentElement.Compare( KOMADSModifiedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iModifiedDate );
+        if ( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::ParseDateString(const TDesC8& aString, TDateTime& aDateTime)
+    {
+    // Ensure we don't read beyond the buffer limits
+    if ( aString.Length() < KDateFormatLength )
+        {
+        return KErrArgument;
+        }
+    // Extract the fields from the string
+    TLex8 yearDesc( aString.Mid( 0, 4 ) );
+    TLex8 monthDesc( aString.Mid( 4, 2 ) );
+    TLex8 dayDesc( aString.Mid( 6, 2 ) );
+    // Skip one character here, it's supposed to be 'T'
+    TLex8 hourDesc( aString.Mid( 9, 2 ) );
+    TLex8 minuteDesc( aString.Mid( 11, 2 ) );
+    TLex8 secondDesc( aString.Mid( 13, 2 ) );
+    
+
+    TInt year, month, day, hour, minute, second;
+    TInt error;
+    
+    // Fetch the values to temporary variables
+    if ( ( error = yearDesc.Val(year) ) != KErrNone )
+        return error;
+    if ( ( error = monthDesc.Val(month) ) != KErrNone )
+        return error;
+    if ( ( error = dayDesc.Val(day) ) != KErrNone )
+        return error;
+    if ( ( error = hourDesc.Val(hour) ) != KErrNone )
+        return error;
+    if ( ( error = minuteDesc.Val(minute) ) != KErrNone )
+        return error;
+    if ( ( error = secondDesc.Val(second) ) != KErrNone )
+        return error;
+
+    // Assign values to datetime object
+    if ( ( error = aDateTime.SetYear(year) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetMonth((TMonth)(month-1) )) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetDay(day) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetHour(hour) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetMinute(minute) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetSecond(second) ) != KErrNone )
+        return error;
+        
+    return KErrNone;
+    }
+
+void COMADSFolderObject::Reset()
+    {
+    iError = KErrNone;
+    iName.SetLength( 0 );
+    iCreatedDate.Set( 2005, EJanuary, 1, 0, 0, 0, 0 );
+    iModifiedDate.Set( 2005, EJanuary, 1, 0, 0, 0, 0 );
+    }
+    
+TInt COMADSFolderObject::Error( TInt aErrorCode )
+    {
+    iError = aErrorCode;
+    return KErrNone;
+    }
+	
+void COMADSFolderObject::ExportDbItemL(CFavouritesItem& aItem)
+    {
+    aItem.SetNameL(iName);
+    aItem.SetType(CFavouritesItem::EFolder);
+    }		
+
+void COMADSFolderObject::ImportDbItem(const CFavouritesItem& aItem)
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportDbItem" );
+    Reset();
+    
+    TInt resId(KErrNotFound);
+    switch( aItem.ContextId() ) // Check if the item is a seamless link folder
+        {
+        case KFavouritesApplicationContextId:
+           	{
+           	LOGGER_WRITE("DOWNLOAD_APPLICATIONS");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_APPLICATIONS;
+            LOGGER_WRITE_1( "resId: %d", resId );
+            break;
+            }
+        case KFavouritesImageContextId:
+            {
+            LOGGER_WRITE("DOWNLOAD_IMAGES");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_IMAGES;
+            break;
+            }
+        case KFavouritesAudioContextId:
+            {
+            LOGGER_WRITE("DOWNLOAD_TONES");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_TONES;
+            break;
+            }
+        case KFavouritesVideoContextId:
+            {
+            LOGGER_WRITE("DOWNLOAD_VIDEOS");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_VIDEOS;
+            break;
+            }
+        case KFavouritesSkinContextId:
+            {
+            LOGGER_WRITE("DOWNLOAD_SKINS");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_SKINS;
+            break;
+            }
+        case KFavouritesMusicContextId:
+            {
+            LOGGER_WRITE("DOWNLOAD_MUSIC");
+            resId = R_BOOKMARKDSA_FOLDER_DOWNLOAD_MUSIC;
+            break;
+            }
+        default:
+            {
+            break; // not a seamless link folder.
+            }
+        }
+     
+    if( resId != KErrNotFound )
+        {
+        LOGGER_WRITE( "before ReadFolderNameL" );
+        TRAPD( error, ReadFolderNameL( iName, resId ) );
+        LOGGER_WRITE( "after ReadFolderNameL" );
+        if ( error )
+            {
+            LOGGER_WRITE_1( "Error reading folder name: %d", error );
+            }
+        }
+    else
+        {
+        LOGGER_WRITE( "before iName = aItem.Name();" );
+        iName = aItem.Name();
+        }
+    LOGGER_WRITE( "printing foldername.." );
+    LOGGER_WRITE_1( "Foldername: %S", &iName);
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportDbItem" );
+    }
+
+
+void COMADSFolderObject::ImportDbItem( const CFolderItem& aItem )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportDbItem" );
+    Reset();
+    if ( aItem.Id() == 0 )
+        {
+        _LIT8( KRSSRootFolderName, "Web Feeds" );
+        iName.Copy( KRSSRootFolderName );
+        }
+    else
+        {
+        iName = aItem.Name();
+        }
+    
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportDbItem" );
+    }
+
+
+void COMADSFolderObject::ReadFolderNameL( TDes& aName, const TInt aResID )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ReadFolderNameL" );
+    
+    TFileName resName( KOMADSResourceName );
+    
+    // Resource can be on ROM or on C-drive, if installed from SIS.
+    TFileName dllName;
+    Dll::FileName( dllName );
+    
+    LOGGER_WRITE_1("DllFileName: %S", &dllName );
+    
+    TParse parse;
+    parse.Set( resName, &dllName, 0 );
+    resName = parse.FullName();
+    
+    LOGGER_WRITE_1( "resName: %S", &resName );
+    
+    CStringResourceReader* reader = CStringResourceReader::NewLC( resName );
+    LOGGER_WRITE_1( "readed resfile: %S", &resName );
+    
+    aName.Copy( reader->ReadResourceString( aResID ) );
+    LOGGER_WRITE("Resource Readed ok");
+    CleanupStack::PopAndDestroy( reader );
+
+    LOGGER_LEAVEFN( "COMADSFolderObject::ReadFolderNameL" );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/snapshotitem.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+#include <hash.h>
+#include <utf.h>
+#include "snapshotitem.h"
+#include "logger.h"
+
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem() : TNSmlSnapshotItem()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// Constructor, takes item id as a parameter
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
+    const TSmlDbItemUid& aParent )
+: TNSmlSnapshotItem( aItemId )
+    {
+    SetParentId( aParent );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::ExternalizeL
+// Writes the contents of this class and it's base to stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TNSmlSnapshotItem::ExternalizeL( aStream );
+    TPckgBuf<THashValue> nameBuf(iHash);
+	aStream << nameBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::InternalizeL
+// Reads the contents of this class and it's base from stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::InternalizeL( RReadStream& aStream )
+    {
+    TNSmlSnapshotItem::InternalizeL( aStream );
+    TPckgBuf<THashValue> nameBuf;
+	aStream >> nameBuf;
+	iHash = nameBuf();
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::CreateHashL
+// Create hash value from name and url
+// -----------------------------------------------------------------------------
+
+void TSnapshotItem::CreateHashL( const TDesC& aName , const TDesC& aUrl )
+    {
+    CMessageDigest* hash = CMessageDigestFactory::NewDigestLC( CMessageDigest::EMD5 );
+    HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aName );
+    CleanupStack::PushL( tempBuf );
+    hash->Update( tempBuf->Des() );
+    CleanupStack::PopAndDestroy( tempBuf );
+    tempBuf = NULL;
+    tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUrl );
+    hash->Update( tempBuf->Des() );
+    iHash.Copy( hash->Final() );
+    delete tempBuf;
+    tempBuf = NULL;
+    CleanupStack::PopAndDestroy( hash );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::Hash
+// Gets Hash
+// -----------------------------------------------------------------------------
+const TDesC8& TSnapshotItem::Hash() const
+    {
+    return iHash;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/vbookmarkconverter.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,713 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bookmark object conversion routines
+*
+*/
+
+
+// INCLUDES
+#include <utf.h>
+#include <FavouritesItem.h>
+#include <FeedsServerFolderItem.h>
+#include "vbookmarkconverter.h"
+#include "logger.h"
+
+// CONSTANTS
+_LIT8(KVBMKBegin, "BEGIN");
+_LIT8(KVBMKEnd, "END");
+_LIT8(KVBMKVbkm, "VBKM");
+_LIT8(KVBMKEnv, "ENV");
+_LIT8(KVBMKVersion, "VERSION");         
+_LIT8(KVBMKVer, "1.0");             
+_LIT8(KVBMKUrl, "URL");                 
+_LIT8(KVBMKTitle, "TITLE");     
+_LIT8(KVBMKXIrmcUrl, "X-IRMC-URL");
+_LIT8(KVBMKInternetShortcut, "[InternetShortcut]"); 
+_LIT8(KVBMKPrintable, "QUOTED-PRINTABLE");  
+_LIT8(KVBMKLinefeed, "\r\n");
+_LIT8(KVBMKColon, ":");
+_LIT8(KVBMKAssignment, "=");
+_LIT8(KVBMKSemicolon, ";");
+_LIT8(KVBMKNone, "");
+_LIT(KEmptyString, "");
+_LIT8(KVBMKCharset, "CHARSET");
+_LIT8(KVBMKUtf8, "UTF-8");
+
+// -----------------------------------------------------------------------------
+// CVBookmarkConverter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CVBookmarkConverter* CVBookmarkConverter::NewL()
+    {
+    CVBookmarkConverter* self = CVBookmarkConverter::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVBookmarkConverter::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CVBookmarkConverter* CVBookmarkConverter::NewLC()
+    {
+    CVBookmarkConverter* self = new (ELeave) CVBookmarkConverter();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVBookmarkConverter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CVBookmarkConverter::ConstructL()
+    {
+    iVersion = HBufC::NewL(1);
+    iTitle = HBufC::NewL(1);
+    iUrl = HBufC::NewL(1);
+    iInternetShortcut = HBufC::NewL(1);
+    }
+
+// -----------------------------------------------------------------------------
+// CVBookmarkConverter::CVBookmarkConverter
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CVBookmarkConverter::CVBookmarkConverter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVBookmarkConverter::~CVBookmarkConverter
+// Destructor.
+// -----------------------------------------------------------------------------
+CVBookmarkConverter::~CVBookmarkConverter()
+    {
+    delete iVersion;
+    delete iUrl;
+    delete iTitle;
+    delete iInternetShortcut;
+    }
+
+const TDesC& CVBookmarkConverter::GetVersion() const
+    {
+    return *iVersion;
+    }
+
+const TDesC& CVBookmarkConverter::GetUrl() const
+    {
+    return *iUrl;
+    }
+
+const TDesC& CVBookmarkConverter::GetTitle() const
+    {
+    return *iTitle;
+    }
+
+const TDesC& CVBookmarkConverter::GetInternetShortcut() const
+    {
+    return *iInternetShortcut;
+    }
+
+void CVBookmarkConverter::SetVersionL( const TDesC& aVersion )
+    {
+    delete iVersion;
+    iVersion = NULL;
+    iVersion = aVersion.AllocL();
+    }
+    
+void CVBookmarkConverter::SetVersionL( const TDesC8& aVersion )
+    {
+    delete iVersion;
+    iVersion = NULL;
+    iVersion = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aVersion );  
+    }   
+    
+void CVBookmarkConverter::SetUrlL( const TDesC& aUrl )
+    {
+    delete iUrl;
+    iUrl = NULL;
+    iUrl = aUrl.AllocL();
+    }
+    
+void CVBookmarkConverter::SetUrlL( const TDesC8& aUrl )
+    {
+    delete iUrl;
+    iUrl = NULL;
+    iUrl = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aUrl );      
+    }   
+    
+void CVBookmarkConverter::SetTitleL( const TDesC& aTitle )
+    {
+    delete iTitle;
+    iTitle = NULL;
+    iTitle = aTitle.AllocL();
+    }
+        
+void CVBookmarkConverter::SetTitleL( const TDesC8& aTitle, TBookmarkEncoding aEncoding )
+    {
+    delete iTitle;
+    iTitle = NULL;
+    
+    if ( aEncoding == EQuotedPrintable )
+        {
+        HBufC8* decodedData = DecodeQuotedPrintableLC( aTitle );
+        iTitle = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *decodedData );
+        CleanupStack::PopAndDestroy( decodedData );
+        }
+    else
+        {
+        iTitle = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aTitle );
+        }        
+    }
+    
+HBufC8* CVBookmarkConverter::DecodeQuotedPrintableLC( const TDesC8& aEncodedData )
+    {
+    TInt encodedLength = aEncodedData.Length();
+    
+    HBufC8* decodeBuffer = HBufC8::NewLC( encodedLength );
+    TPtr8 ptrDecodeBuffer = decodeBuffer->Des();
+    
+    TInt i(0);
+    while ( i < encodedLength )
+        {
+        TChar nextChar = aEncodedData[i++];
+        
+        if ( nextChar == '=' )
+            {
+            if ( i + 2 > encodedLength )
+                {
+                ptrDecodeBuffer.Append( '=' );
+                if ( i + 1 == encodedLength )
+                    {
+                    ptrDecodeBuffer.Append( aEncodedData[i++] );
+                    }     
+                }
+            else
+                {
+                TPtrC8 data = aEncodedData.Mid( i, 2 );
+                i += 2;    
+                
+                if ( data.Compare(KVBMKLinefeed) == 0 )
+                    {
+                    // Do nothing
+                    // '=' at the end of line is soft line break, not to be decoded
+                    }
+                else
+                    {
+                    TLex8 hexChar( data );
+                    TUint8 value( 0 );
+                    
+                    if ( hexChar.Val( value, EHex ) == KErrNone )
+                        {
+                        ptrDecodeBuffer.Append( TChar( value ) );
+                        }
+                    else
+                        {
+                        // Decoding failed, put the data at itself
+                        ptrDecodeBuffer.Append( '=' );
+                        ptrDecodeBuffer.Append( data );
+                        }    
+                    }
+                }
+            }
+        else
+            {
+            ptrDecodeBuffer.Append( nextChar );
+            }    
+        }
+        
+    return decodeBuffer;    
+    }
+
+void CVBookmarkConverter::SetInternetShortcutL( const TDesC& aInternetShortcut )
+    {
+    delete iInternetShortcut;
+    iInternetShortcut = NULL;
+    iInternetShortcut = aInternetShortcut.AllocL();
+    }
+    
+void CVBookmarkConverter::SetInternetShortcutL( const TDesC8& aInternetShortcut )
+    {
+    delete iInternetShortcut;
+    iInternetShortcut = NULL;
+    iInternetShortcut = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aInternetShortcut );        
+    }   
+
+void CVBookmarkConverter::ExportDbItemL( CFavouritesItem& aItem )
+    {
+    if ( iTitle->Des().Length() > KFavouritesMaxName )
+        {
+        TPtrC title = iTitle->Des().Left( KFavouritesMaxName );
+        aItem.SetNameL( title );
+        }
+    else
+        {
+        aItem.SetNameL( *iTitle );
+        }
+        
+    if ( iUrl->Des().Length() > KFavouritesMaxUrl )
+        {
+        TPtrC url = iUrl->Des().Left( KFavouritesMaxUrl );
+        aItem.SetUrlL( url );
+        }
+    else
+        {
+        aItem.SetUrlL( *iUrl );
+        }   
+    }
+
+void CVBookmarkConverter::ImportDbItemL( const CFavouritesItem& aItem )
+    {
+    ResetL();
+    
+    if( aItem.Type() != CFavouritesItem::EItem )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    
+    SetVersionL( KVBMKVer );
+    SetUrlL( aItem.Url() );
+    SetInternetShortcutL( aItem.Url() );
+    SetTitleL( aItem.Name() );
+    }
+
+void CVBookmarkConverter::ImportDbItemL( const CFolderItem& aItem )
+    {
+    ResetL();
+    
+    if( aItem.IsFolder() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    
+    SetVersionL( KVBMKVer );
+    SetUrlL( aItem.SourceUrl() );
+    SetInternetShortcutL( aItem.SourceUrl() );
+    SetTitleL( aItem.Name() );
+    }
+
+void CVBookmarkConverter::ExportVBookmarkL( CBufBase& aBuffer )
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ExportVBookmarkL" );
+    
+    iDesc = NULL;
+    iBuffer = &aBuffer;
+    iWriteBufPosition = 0;
+    iWriteBufSize = aBuffer.Size();     
+    
+    ExportL();  
+    iBuffer->ResizeL( iWriteBufPosition );    
+    
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ExportVBookmarkL" );
+    }
+
+void CVBookmarkConverter::ExportVBookmarkL( TDes8& aBuffer )
+    {
+    iDesc = &aBuffer;
+    iBuffer = NULL;
+    
+    ExportL();
+    }
+
+void CVBookmarkConverter::ResetL()
+    {
+    SetVersionL( KEmptyString );
+    SetUrlL( KEmptyString );
+    SetTitleL( KEmptyString );    
+    SetInternetShortcutL( KEmptyString );    
+    }
+    
+void CVBookmarkConverter::ExportL()
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ExportL" );
+    
+    WriteMessageLineL( KVBMKBegin, KVBMKVbkm, KVBMKColon ); // Begin tag
+    
+    HBufC8* version = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *iVersion );
+    CleanupStack::PushL( version );
+    WriteMessageLineL( KVBMKVersion, *version, KVBMKColon ); // Version
+    CleanupStack::PopAndDestroy( version );
+    
+    HBufC8* url = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *iUrl );
+    CleanupStack::PushL( url );
+    // Url
+    WriteL( KVBMKUrl );
+    WriteL( KVBMKSemicolon );
+    WriteL( KVBMKCharset );
+    WriteL( KVBMKAssignment );
+    WriteL( KVBMKUtf8 );
+    WriteL( KVBMKColon );
+    WriteL( *url );
+    WriteL( KVBMKLinefeed );
+    CleanupStack::PopAndDestroy( url );
+    
+    HBufC8* title = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *iTitle );
+    CleanupStack::PushL( title );
+    // Title
+    WriteL( KVBMKTitle );
+    WriteL( KVBMKSemicolon );
+    WriteL( KVBMKCharset );
+    WriteL( KVBMKAssignment );
+    WriteL( KVBMKUtf8 );
+    WriteL( KVBMKColon );
+    WriteL( *title );
+    WriteL( KVBMKLinefeed );
+    CleanupStack::PopAndDestroy( title );          
+
+    if( iInternetShortcut->Length() > 0 )
+        {
+        WriteEnvelopeL();
+        }
+        
+    WriteMessageLineL( KVBMKEnd, KVBMKVbkm, KVBMKColon ); // End tag
+    
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ExportL" );       
+    }
+    
+TInt CVBookmarkConverter::ImportVBookmarkL( const TDesC8& aBuffer )
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ImportVBookmarkL" );
+    
+    ResetL();
+        
+    TInt error = KErrNone;
+    TInt position = 0;
+    TPtrC8 tag;
+    TPtrC8 value;
+    TPtrC8 properties;
+    error = ReadTagAndValue( aBuffer, position, tag, value, properties );
+    if( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "ReadTagAndValue err: %d", error );
+        return error;
+        }
+        
+    if ( ( tag != KVBMKBegin ) || ( value != KVBMKVbkm ) )
+        {
+        LOGGER_WRITE( "Invalid tag" );
+        return KErrNotFound;
+        }
+    
+    while ( ( error = ReadTagAndValue( aBuffer, position, tag, value, properties ) ) == KErrNone )
+        {
+        // Version
+        if ( tag == KVBMKVersion )
+            {
+            SetVersionL( value );
+            }
+        
+        // Url
+        else if ( tag == KVBMKUrl )
+            {
+            SetUrlL( value );
+            }
+        
+        // Title
+        else if ( tag == KVBMKTitle )
+            {
+            TBookmarkEncoding encoding = Encoding( properties );
+            SetTitleL( value, encoding );
+            }
+            
+        // Beginning of envelope    
+        else if ( ( tag == KVBMKBegin ) && ( value == KVBMKEnv ) )
+            {
+            // Read the envelope, quit if error
+            error = ReadEnvelopeL( aBuffer, position );
+            if( error != KErrNone )
+                {
+                return error;
+                }
+            }       
+                
+        // End of Bookmark
+        else if ( ( tag == KVBMKEnd ) && ( value == KVBMKVbkm ) )
+            {
+            return error;
+            }
+        
+        else
+            {
+            // Unknown data, skip
+            }
+        }
+
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ImportVBookmarkL" );      
+    return error;
+    }
+
+void CVBookmarkConverter::WriteMessageLineL( const TDesC8& aMsgLineTag,
+    const TDesC8& aMsgLineData, const TDesC8& aSeparator )
+    {
+    WriteL( aMsgLineTag );
+    WriteL( aSeparator );
+    WriteL( aMsgLineData );
+    WriteL( KVBMKLinefeed );
+    }
+
+TInt CVBookmarkConverter::ReadTagAndValue( const TDesC8& aBuffer, TInt& aPosition, 
+    TPtrC8& aTag, TPtrC8& aValue, TPtrC8& aProperties )
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ReadTagAndValue" );   
+    
+    TPtrC8 start = aBuffer.Mid( aPosition );
+    TInt delimeter = start.Find( KVBMKColon );
+    TInt linefeed = start.Find( KVBMKLinefeed );
+    TInt semicolon = start.Find( KVBMKSemicolon );
+    
+    
+    // Did we find a linefeed?
+    if ( linefeed == KErrNotFound )
+        {
+        // Check whether file ends without newline
+        if( aBuffer.Length() <= ( aPosition + start.Length() ) )
+            {
+            // Set linefeed at the end of the file
+            linefeed = start.Length();
+            }
+        else
+            { 
+            return KErrNotFound;
+            }
+        }
+
+    // Did we find a semicolon?
+    if ( semicolon != KErrNotFound )
+        {
+        // It must be before the delimeter (property identifiers reside in this block)
+        if ( semicolon >= delimeter || semicolon < 0 )
+            {
+            semicolon = KErrNotFound;
+            }
+        }
+    
+    // Did we find the delimeter
+    if( delimeter == KErrNotFound )
+        {
+        return KErrNotFound;
+        }
+
+    // Linefeed must reside behind the delimeter
+    if ( linefeed <= delimeter )
+        {
+        return KErrNotFound;
+        }
+    
+    aTag.Set( start.Left( semicolon != KErrNotFound ? semicolon : delimeter ) );
+    IgnoreSpaces( aTag );
+
+    // Extract value
+    aValue.Set( start.Mid( delimeter + 1, (linefeed - 1) - delimeter ) );
+    IgnoreSpaces( aValue );
+    
+    // Extract properties if found
+    if ( semicolon != KErrNotFound )
+        {
+        aProperties.Set( start.Mid( semicolon, delimeter - semicolon ) );
+        IgnoreSpaces( aProperties );
+        }
+    else
+        {
+        aProperties.Set( KVBMKNone() );
+        }     
+    
+    // update position
+    aPosition += ( linefeed + KVBMKLinefeed().Length() );
+    
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ReadTagAndValue" );       
+    return KErrNone;
+    }
+    
+TInt CVBookmarkConverter::ReadEnvelopeL( const TDesC8& aBuffer, TInt& aPosition )
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ReadEnvelopeL" ); 
+        
+    TInt error = KErrNone;
+    TPtrC8 tag;
+    TPtrC8 value;
+    TPtrC8 properties;
+
+    while ( ( error = ReadTagAndValue( aBuffer, aPosition, tag, value, properties ) ) == KErrNone )
+        {
+        // End of Bookmark
+        if ( tag == KVBMKXIrmcUrl )
+            {
+            error = ReadAssignment( aBuffer, aPosition, tag, value );
+            if ( error != KErrNone )
+                {
+                return error;
+                }
+                
+            if ( tag == KVBMKInternetShortcut )
+                {
+                error = ReadAssignment( aBuffer, aPosition, tag, value );
+                if( error != KErrNone )
+                    {
+                    return error;
+                    }
+                
+                if ( tag == KVBMKUrl )
+                    {
+                    SetInternetShortcutL( value );
+                    }
+                else
+                    {
+                    return KErrNotFound;
+                    }               
+                }
+            else
+                {
+                return KErrNotFound;
+                }
+            }
+        
+        else if ( ( tag == KVBMKEnd ) && ( value == KVBMKEnv ) )
+            {
+            return error;
+            }
+        else
+            {
+            // Unknown data, skip
+            }
+        }
+
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ReadEnvelopeL" );         
+    return error;
+    }
+
+TInt CVBookmarkConverter::ReadAssignment( const TDesC8& aBuffer,
+    TInt& aPosition, TPtrC8& aTag, TPtrC8& aValue )
+    {
+    LOGGER_ENTERFN( "CVBookmarkConverter::ReadAssignment" );    
+        
+    TPtrC8 start = aBuffer.Mid( aPosition );
+    TInt assignment = start.Find( KVBMKAssignment );
+    TInt linefeed = start.Find( KVBMKLinefeed );
+    
+    // Did we find the delimeter and the linefeed
+    if ( ( assignment == KErrNotFound) || ( linefeed == KErrNotFound ) )
+        {
+        return KErrNotFound;
+        }
+    // Linefeed must reside behind the delimeter
+    if ( linefeed <= assignment )
+        {
+        return KErrNotFound;
+        }
+    // Extract tag
+    aTag.Set( start.Left( assignment ) );
+    IgnoreSpaces( aTag );
+
+    // Extract value
+    aValue.Set( start.Mid( assignment + 1, ( linefeed - 1 ) - assignment ) );
+    IgnoreSpaces( aValue );
+    
+    // update position
+    aPosition += ( linefeed + KVBMKLinefeed().Length() );
+
+    LOGGER_LEAVEFN( "CVBookmarkConverter::ReadAssignment" );        
+    return KErrNone;
+    }
+
+void CVBookmarkConverter::WriteEnvelopeL()
+    {
+    WriteMessageLineL( KVBMKBegin, KVBMKEnv, KVBMKColon ); // Begin tag
+
+    // "X-IRMC-URL;QUOTED-PRINTABLE:="
+    WriteL( KVBMKXIrmcUrl );
+    WriteL( KVBMKSemicolon );
+    WriteL( KVBMKPrintable );
+    WriteL( KVBMKColon );
+    WriteL( KVBMKAssignment );
+    WriteL( KVBMKLinefeed );
+    
+    WriteMessageLineL( KVBMKInternetShortcut, KVBMKNone, KVBMKAssignment );
+    
+    HBufC8* internetShortcut = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *iInternetShortcut );
+    CleanupStack::PushL( internetShortcut );
+    WriteMessageLineL( KVBMKUrl, *internetShortcut, KVBMKAssignment );
+    CleanupStack::PopAndDestroy( internetShortcut );
+    
+    WriteMessageLineL( KVBMKEnd, KVBMKEnv, KVBMKColon ); // End tag
+    }
+    
+void CVBookmarkConverter::WriteL( const TDesC8 &aData )
+    {
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + aData.Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expandStep = newPosition - iWriteBufSize + 100;
+            iBuffer->ExpandL( iWriteBufSize, expandStep );
+            iWriteBufSize += expandStep;
+            }
+
+        iBuffer->Write( iWriteBufPosition, aData );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( aData );       
+        }
+    }
+    
+void CVBookmarkConverter::IgnoreSpaces( TPtrC8& aData )
+    {
+    TInt last = aData.Length() - 1;
+    
+    TInt begin;
+    for ( begin = 0; begin <= last; begin++ )
+        {
+        if ( !TChar( aData[begin] ).IsSpace() )
+            {
+            break;
+            }
+        }
+        
+    TInt end;   
+    for ( end = last; end >= 0; end-- )
+        {
+        if ( !TChar( aData[end] ).IsSpace() )
+            {
+            break;
+            }
+        }
+        
+    TInt length = end - begin + 1;  
+                
+    if ( ( begin != 0 || end != last ) && length > 0 )
+        {
+        TPtrC8 newData = aData.Mid( begin, length );
+        aData.Set( newData );
+        }
+    }
+    
+TBookmarkEncoding CVBookmarkConverter::Encoding( TPtrC8& aProperties )
+    {
+    TBookmarkEncoding encoding = ENoEncoding;
+    
+    TInt length = aProperties.Length();
+    
+    if ( aProperties.Length() > 0 )
+        {
+        if ( aProperties.Find( KVBMKPrintable ) > 0 )
+            {
+            encoding = EQuotedPrintable;
+            }    
+        }
+    
+    return encoding;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  build info file for Contacts adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+PRJ_EXPORTS
+../loc/101F6DD6.loc		APP_LAYER_LOC_EXPORT_PATH(101F6DD6.loc)
+PRJ_MMPFILES
+./nsmldscontactsdataprovider.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/bld/def/bwinscwcontactsdataprovideru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/bld/def/eabicontactsdataprovideru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI22CNSmlContactsDataStore @ 2 NONAME ; #<TI>#
+	_ZTI24CNSmlContactsModsFetcher @ 3 NONAME ; #<TI>#
+	_ZTI25CNSmlContactsDataProvider @ 4 NONAME ; #<TI>#
+	_ZTIN22CNSmlContactsDataStore23CNSmlContactsBufferItemE @ 5 NONAME ; #<TI>#
+	_ZTV22CNSmlContactsDataStore @ 6 NONAME ; #<VT>#
+	_ZTV24CNSmlContactsModsFetcher @ 7 NONAME ; #<VT>#
+	_ZTV25CNSmlContactsDataProvider @ 8 NONAME ; #<VT>#
+	_ZTVN22CNSmlContactsDataStore23CNSmlContactsBufferItemE @ 9 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/bld/nsmldscontactsdataprovider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  mmp file for contacts adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+CAPABILITY CAP_ECOM_PLUGIN
+
+TARGET          nsmlcontactsdataprovider.dll
+TARGETPATH		PLUGINS_1_DIR
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F6DDD
+VENDORID		VID_DEFAULT
+
+#if defined(ARMCC)
+DEFFILE		./def/eabicontactsdataprovider
+#elif defined(WINSCW)
+DEFFILE		./def/bwinscwcontactsdataprovider
+#endif
+
+SOURCEPATH      ../src
+SOURCE          NSmlContactsDataProvider.cpp
+SOURCE          NSmlContactsDataStore.cpp
+SOURCE          NSmlContactsModsFetcher.cpp
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+SYSTEMINCLUDE 	/epoc32/include/syncml
+
+USERINCLUDE     ../inc ../../inc
+USERINCLUDE     ../../../datamod/inc
+
+START RESOURCE 101F6DD6.rss
+HEADER
+TARGET 		nsmlcontactsdataprovider.rsc       
+TARGETPATH	ECOM_RESOURCE_DIR
+END 
+
+START RESOURCE NSmlContactsDataStoreFormat_1_1_2.rss
+HEADER
+TARGET 		NSmlContactsDataStoreFormat_1_1_2.rsc       
+TARGETPATH  RESOURCE_FILES_DIR 
+LANGUAGE_IDS
+END 
+
+START RESOURCE NSmlContactsDataStoreFormat_1_2.rss
+HEADER
+TARGET 		NSmlContactsDataStoreFormat_1_2.rsc       
+TARGETPATH  RESOURCE_FILES_DIR 
+LANGUAGE_IDS
+END 
+
+LIBRARY		ECom.lib bafl.lib euser.lib efsrv.lib estor.lib nsmldebug.lib sysutil.lib
+LIBRARY		nsmlchangefinder.lib cntmodel.lib wbxmllib.lib
+LIBRARY		nsmldatamod.lib smlstoreformat.lib smldataprovider.lib
+LIBRARY		nsmldshostclient.lib
+LIBRARY		VPbkEng.lib
+LIBRARY     vpbkvcardEng.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/inc/NSmlContactsDataProvider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS contacts dataprovider.
+*
+*/
+
+
+#ifndef __NSMLCONTACTSDATAPROVIDER_H__
+#define __NSMLCONTACTSDATAPROVIDER_H__
+
+// INCLUDES
+#include <f32file.h>
+#include <SmlDataProvider.h>
+#include "NSmlContactsDataStore.h"
+
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+//  CNSmlContactsDataProvider
+//
+//  @lib nsmlcontactsdataprovider.lib
+// ------------------------------------------------------------------------------------------------
+class CNSmlContactsDataProvider : public CSmlDataProvider 
+	{
+	public:
+		/**
+		* Two-phased constructor.
+		*/
+		static CNSmlContactsDataProvider* NewL();
+
+		/**
+		* Destructor.
+		*/
+		virtual ~CNSmlContactsDataProvider();
+
+	private:
+		/**
+		* Two-phased constructor.
+		*/
+		static CNSmlContactsDataProvider* NewLC();
+
+		/**
+		* This method handles framework events.
+		* @param					Frameworks event.
+		* @param	aParam1			First parameter.
+		* @param	aParam2			Second parameter.
+		*/
+		void DoOnFrameworkEvent(TSmlFrameworkEvent, TInt aParam1, TInt aParam2);
+
+		/**
+		* Check if operation is supported by dataprovider.
+		* @param	aOpId			Operations type.
+		* @return	ETrue if the operation is supported.
+		*/
+		TBool DoSupportsOperation(TUid aOpId) const;
+
+		/**
+		* Gets dataproviders own StoreFormat.
+		*/
+		const CSmlDataStoreFormat& DoStoreFormatL();
+
+		/**
+		* Lists all contacts databases on client.
+		* @return List of contact databases.
+		*/
+		CDesCArray* DoListStoresLC();
+
+		/**
+		* Gets default storename on client.
+		* @return Default storename.
+		*/
+		const TDesC& DoDefaultStoreL();
+
+		/**
+		* Constructs new instance of datastore.
+		* @return Newly created instance.
+		*/
+		CSmlDataStore* DoNewStoreInstanceLC();
+
+		/**
+		This method returns the set of filters that can be used to send to the SyncML server.
+		* @return New filters.
+		*/
+		const RPointerArray<CSyncMLFilter>& DoSupportedServerFiltersL();
+		
+		/**
+		This method checks what filters are supported by server.
+		@param	aServerDataStoreFormat	The store format of server
+		@param	aFilters				The array that includes filters
+		@param	aChangeInfo				The change information about changes that data provider did
+		*/
+		void DoCheckSupportedServerFiltersL(const CSmlDataStoreFormat& aServerDataStoreFormat, RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo);
+		
+		/**
+		This method updates dynamic filters up-to-date.
+		@param	aFilters				The array that includes filters
+		@param	aChangeInfo				The change information about changes that data provider did
+		*/
+		void DoCheckServerFiltersL(RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo);
+		
+		/**
+		This method generates a record filter query to be sent to the SyncML server for the provided filters.
+		@param	aFilters			The filters to be used for the query generation
+		@param	aMatch				The filter match type to be used
+		@param	aFilterMimeType		The mime type of the returned filter query
+		@param	TSyncMLFilterType 	The filter type of the returned filter query
+		@param	aStoreName			The name of used store
+		@return						The record filter query to be sent to the SyncML server - empty if no record filter involved
+									for this specific filter
+		*/
+		HBufC* DoGenerateRecordFilterQueryLC(const RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterMatchType aMatch, TDes& aFilterMimeType, TSyncMLFilterType& aFilterType, TDesC& aStoreName);
+		
+		/**
+		This method generates a field filter query to be sent to the SyncML server for the provided filters.
+		@param	aFilters		The filters to be used for the query generation
+		@param	aFilterMimeType		The mime type of the returned filter query
+		@param	aProperties		The field filter query to be sent to the SyncML server - empty if no field filter involved
+								for this specific filter
+		@param  aStoreName		The name of used store
+		*/
+		void DoGenerateFieldFilterQueryL(const RPointerArray<CSyncMLFilter>& aFilters, TDes& aFilterMimeType, RPointerArray<CSmlDataProperty>& aProperties, TDesC& aStoreName);
+
+		/**
+		* C++ constructor.
+		*/
+		CNSmlContactsDataProvider();
+
+		/**
+		* 2nd phase constructor.
+		*/
+		void ConstructL();
+
+	private: // data
+		CNSmlContactsDataStore* iContactsDataStore; 
+		RPointerArray<CSyncMLFilter> iFilterArray;
+		RFs iRfs;
+		RStringPool iStringPool;
+		CSmlDataStoreFormat* iStoreFormat;
+	};
+	
+#endif // __NSMLCONTACTSDATAPROVIDER_H__
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/inc/NSmlContactsDataStore.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,753 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  DS contacts datastore.
+*
+*/
+
+
+#ifndef __NSMLCONTACTSDATASTORE_H__
+#define __NSMLCONTACTSDATASTORE_H__
+
+// INCLUDE FILES
+#include <SmlDataProvider.h>
+#include <SmlDataFormat.h>
+#include <f32file.h>
+
+//vpbk headers
+#include <CVPbkContactManager.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreObserver.h>
+#include <MVPbkBatchOperationObserver.h>
+#include <MVPbkContactViewObserver.h>
+#include <CVPbkSortOrder.h>
+#include <CVPbkContactIdConverter.h>
+#include <CVPbkContactLinkArray.h>
+#include <MVPbkContactViewBase.h>
+#include <MVPbkSingleContactOperationObserver.h>
+#include <CVPbkVCardEng.h>
+#include <MVPbkContactCopyObserver.h>
+#include <MVPbkBatchOperationObserver.h>
+#include <MVPbkContactViewObserver.h>
+#include <MVPbkContactOperationBase.h>
+#include <CVPbkSortOrder.h>
+#include <s32mem.h>
+
+#include "nsmlchangefinder.h"
+
+
+// MACROS
+#define KNSmlvCard21Version TVersion(2,1,0);
+#define KNSmlvCard30Version TVersion(3,0,0);
+
+// CONSTANTS
+_LIT(  KNSmlContactStoreNameForDefaultDB, "C:Contacts.cdb" );
+_LIT(  KNSmlDriveC, "C" );
+_LIT8( KNSmlvCard30Name, "text/vcard" );
+_LIT8( KNSmlvCard30Ver, "3.0" );
+_LIT8( KNSmlvCard21Name, "text/x-vcard" );
+_LIT8( KNSmlvCard21Ver, "2.1" );
+
+_LIT8( KVersitTokenHOME, "HOME"  );
+_LIT8( KVersitTokenWORK, "WORK"  );
+_LIT8( KVersitTokenCELL, "CELL"  );
+_LIT8( KVersitTokenPAGER,"PAGER" );
+_LIT8( KVersitTokenFAX,  "FAX"   );
+_LIT8( KVersitTokenVOICE,"VOICE" );
+_LIT8( KVersitTokenVIDEO,"VIDEO" );
+
+//CONSTANTS INTRODUCED FOR HAVING BACKWARD COMPATIBLE PHONE DB SENT TO SERVER
+//THE CHANGE WAS NEEDED AFTER ADAPTING TO VIRTUAL PHONEBOOK
+_LIT( KLegacySymbianDatabase,"C:Contacts.cdb");
+const TInt KOldSymbianDBLength = 20;
+
+_LIT( KVPbhkSymbianDBPrefix,"cntdb://");
+const TInt KVPbhkPrefixLength = 10;
+
+//End NEW CONSTANTS
+const TInt KNSmlContactsGranularity = 8;
+const TInt KNSmlCompactAfterChanges = 16;
+const TInt KNSmlDataStoreMaxSize = 102400;		// 100 k
+const TInt KNSmlDefaultStoreNameMaxSize = 256;
+const TInt KNSmlItemDataExpandSize = 1024;
+const TInt KNSmlNoError = 1;
+
+_LIT(KNSmlContactsStoreFormatRsc_1_1_2,"NSmlContactsDataStoreFormat_1_1_2.rsc");
+_LIT(KNSmlContactsStoreFormatRsc_1_2,"NSmlContactsDataStoreFormat_1_2.rsc");
+
+// FORWARD DECLARATIONS
+class CNSmlContactsModsFetcher;
+class CNSmlDataModBase;
+
+	
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataStore
+//
+// @lib nsmlcontactsdataprovider.lib
+// ------------------------------------------------------------------------------------------------
+class CNSmlContactsDataStore : public CSmlDataStore,
+								MVPbkContactStoreObserver,
+								MVPbkSingleContactOperationObserver,
+								MVPbkContactCopyObserver,
+								MVPbkBatchOperationObserver,
+								MVPbkContactViewObserver,
+								MVPbkContactOperationBase
+	{
+	public:	
+		/**
+		* Two-phased constructor.
+		*/
+		static CNSmlContactsDataStore* NewL();
+
+		/**
+		* Destructor.
+		*/
+		virtual ~CNSmlContactsDataStore();
+
+		/**
+		* Default store name of client.
+		* @return Default store name.
+		*/
+		const TDesC& DefaultStoreNameL() const;
+
+		/**
+		* Gets a list of all contacts databases on client.
+		* @return List of databases.
+		*/
+		CDesCArray* DoListStoresLC();
+		
+
+	private:
+		/**
+		* From MVPbkContactStoreListObserver  
+		* Called when a contact store is ready to use.
+		*/
+		 void StoreReady( MVPbkContactStore& aContactStore );
+		 
+		/**
+		* From MVPbkContactStoreListObserver  
+		* Called when a contact store becomes unavailable.
+		*/
+		 void StoreUnavailable(MVPbkContactStore& aContactStore,TInt aReason );
+	
+		/**
+		* From MVPbkContactStoreListObserver  
+		*  Called when changes occur in the contact store.
+		*/
+		 void HandleStoreEventL(MVPbkContactStore& aContactStore,TVPbkContactStoreEvent aStoreEvent );
+		 
+		/**
+		* From MVPbkSingleContactOperationObserver  
+		* Called when the operation is completed.
+		*/
+         void VPbkSingleContactOperationComplete(
+         	MVPbkContactOperationBase& aOperation,
+         	MVPbkStoreContact* aContact ); 
+         
+		/**
+		* From MVPbkSingleContactOperationObserver  
+		*  Called if the operation fails.
+		*/
+ 		void VPbkSingleContactOperationFailed(MVPbkContactOperationBase& aOperation, TInt aError );
+ 		
+ 		/**
+		* From MVPbkContactCopyObserver  
+		* Called when the contact has been successfully commited or
+        * copied. Caller takes the ownership of results.
+   		*/
+ 		void ContactsSaved( MVPbkContactOperationBase& aOperation,
+            MVPbkContactLinkArray* aResults ) ;
+        
+        /**
+		* From MVPbkContactCopyObserver  
+		*Called when there was en error while saving contact(s).
+		*/
+        void ContactsSavingFailed( 
+                MVPbkContactOperationBase& aOperation, 
+                TInt aError );
+        // From MVPbkBatchOperationObserver
+    
+	    /**
+	     * Called when one step of the operation is complete.
+	     * @param aOperation Operation whose step has completed
+	     * @param aStepSize Size of the performed step
+	     */     
+	    void StepComplete( MVPbkContactOperationBase& aOperation, 
+	        TInt aStepSize );
+	    
+	    /**
+	     * Called when one step of the operation fails
+	     * @param aOperation Operation whose step has failed
+	     * @param aStepSize Size of the performed step
+	     * @param aError Error that occured
+	     * @return ETrue if the batch operation should continue, 
+	     *               EFalse otherwise
+	     */     
+	    TBool StepFailed(
+	        MVPbkContactOperationBase& aOperation,
+	        TInt aStepSize,
+	        TInt aError );
+	    
+	    /**
+	     * Called when operation is completed
+	     * @param aOperation the completed operation
+	     */    
+	    void OperationComplete( MVPbkContactOperationBase& aOperation );  
+	    
+	    /**
+		* From MVPbkContactViewObserver  
+		* Called when a view is ready for use. 
+		*/
+
+		void ContactViewReady(
+		            MVPbkContactViewBase& aView ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a view is unavailable for a while. 
+		*/            
+		void ContactViewUnavailable(
+		            MVPbkContactViewBase& aView ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a contact has been added to the view.
+		*/            
+		void ContactAddedToView(
+		            MVPbkContactViewBase& aView, 
+		            TInt aIndex, 
+		            const MVPbkContactLink& aContactLink );
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a contact has been removed from a view.
+		*/            
+		void ContactRemovedFromView(
+		            MVPbkContactViewBase& aView, 
+		            TInt aIndex, 
+		            const MVPbkContactLink& aContactLink ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when an error occurs in the view.
+		*/            
+		void ContactViewError(
+		            MVPbkContactViewBase& aView, 
+		            TInt aError, 
+		            TBool aErrorNotified ) ;
+	
+	private:
+		/**
+		* 2nd phase constructor.
+		*/
+		void ConstructL();
+
+		/**
+		* DoOpenL() opens the data store specified by aStoreName asynchronously.
+		* @param		aStoreName			The name of the data store to open.
+		* @param		aContext			Identifies the specific synchronisation relationship to use for the synchronisation.
+		* @param		aStatus				On completion of the open, contains the result code.
+		*/
+		void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus);
+
+		/**
+		* DoCancelRequest() cancels the current asynchronous request, including open. Only one asynchronous request may be outstanding at any one time.
+		*/
+		void DoCancelRequest();
+
+		/**
+		* DoStoreName() returns the name of the open data store.
+		* @return The name of the currently opened data store.
+		*/
+		const TDesC& DoStoreName() const;
+
+		/**
+		* DoBeginTransactionL() starts the transaction mode. During this mode calls to CreateItemL, ReplaceItemL,
+		* WriteItemL, CommitItemL, MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this transaction.
+		* Their RequestStatus must be completed, even if the change is not yet really executed in the Data Store.
+		* If a RequestStatus is completed with an error code, the transaction has failed and a rollback must be
+		* done. In this case RevertTransaction will be called.
+		*/
+		void DoBeginTransactionL();
+
+		/**
+		* DoCommitTransactionL() will be called at the end of a successful transaction. At this point in time the
+		* operations within the transaction are applied to the Data Store in an atomic way. If all operations
+		* succeed, the RequestStatus must be completed with KErrNone. If an operation fails, a rollback must be
+		* done and the RequestStatus must be completed with an appropriate error code.
+		*/
+		void DoCommitTransactionL(TRequestStatus& aStatus);
+
+		/**
+		* DoRevertTransaction() will be called to abort an ongoing transaction. None of the operations already
+		* submitted may be applied to the Data Store. The RequestStatus must be completed with KErrNone as a revert
+		* cannot fail.
+		*/
+		void DoRevertTransaction(TRequestStatus& aStatus);
+
+		/**
+		* DoBeginBatchL() starts the batch mode. During this mode calls to CreateItemL, ReplaceItemL,
+		* WriteItemL, CommitItemL, MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this batch.
+		* Their RequestStatus must be completed with KErrNone, which only signals acceptance of the operation
+		* for batch processing.
+		*/
+		void DoBeginBatchL();
+
+		/**
+		* DoCommitBatchL() will be called at the end of the batch mode. This tells the Data Store to
+		* process the batched operations (in the order they were submitted), and to append the error code
+		* for each operation to aResultArray.
+		* The error codes in aResultArray are only valid if the RequestStatus is completed with KErrNone.
+		* If the RequestStatus is completed with an error code none of the operations in the batch mode
+		* were applied to the Data Store.
+		*/
+		void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus);
+
+		/**
+		* DoCancelBatch() will be called to abort an ongoing batch mode. None of the operations already
+		* submitted may be applied to the Data Store.
+		*/
+		void DoCancelBatch();
+
+		/**
+		* DoSetRemoteStoreFormatL() sets the SyncML server Data Format - this may optionally be used by the Data 
+		* Provider to filter out properties that the server does not support, and should be used to avoid deleting 
+		* these properties in case the server sends a changed item to the Data Provider
+		*/
+		void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat);
+
+		/**
+		* DoSetRemoteMaxObjectSize() sets the SyncML server maximum object size - this may optionally be used by the 
+		* Data Provider to not send items to the server exceeding its maximum size. 0 means there is no limit.
+		*/
+		void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize);
+
+		/**
+		* DoMaxObjectSize() gets the Data Store maximum object size which is reported to the SyncML server. 0 means 
+		* there is no limit.
+		* @return The maximum object size.
+		*/
+		TInt DoMaxObjectSize() const;
+
+		/**
+		* DoOpenItemL() opens the data item specified by aUid asynchronously for reading.
+		* @param		aUid				Item UID which going to be read.
+		* @param		aFieldChange		Accept field changes.
+		* @param		aParent				Parent of the item.
+		* @param		aSize				Size of the item data.
+		* @param		aMimeType			MIME type of the item.
+		* @param		aMimeVer			MIME version used on item.
+		* @param		aStatus				On completion of the opening of item, contains the result code.
+		*/
+		void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus);
+
+		/**
+		* DoCreateItemL() sets the item properties and reference to aUid which will be created.
+		* @param		aUid				Reference to item UID which going to be created.
+		* @param		aSize				Size of the item to be created.
+		* @param		aParent				Parent of the item.
+		* @param		aMimeType			MIME type of the item.
+		* @param		aMimeVer			MIME version used on item.
+		* @param		aStatus				On completion of the creating an item, contains the result code.
+		*/
+		void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus);
+
+		/**
+		* DoReplaceItemL() opens the data item specified by aUid asynchronously to be updated.
+		* @param		aUid				Item UID which going to be updated.
+		* @param		aSize				Size of the item data.
+		* @param		aParent				Parent of the item.
+		* @param		aFieldChange		Accept field changes.
+		* @param		aStatus				On completion of the updating of item, contains the result code.
+		*/
+		void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aFieldChange, TRequestStatus& aStatus);
+
+		/**
+		* DoReadItemL() reads data(or size of aBuffer) of an item opened in DoOpenItemL() to given aBuffer.
+		* @param		aBuffer				Buffer to item data.
+		*/
+		void DoReadItemL(TDes8& aBuffer);
+
+		/**
+		* DoWriteItemL() writes aData of an item opened in DoCreateItemL() or DoReplaceItemL() to be saved on database.
+		* @param		aData				Item data (or part of data).
+		*/
+		void DoWriteItemL(const TDesC8& aData);
+
+		/**
+		* DoCommitItemL() completes an item operation started in DoCreateItemL() or DoReplaceItemL().
+		* @param		aStatus				On completion of the operation, contains the result code.
+		*/
+		void DoCommitItemL(TRequestStatus& aStatus);
+
+		/**
+		* DoCloseItem() completes an item operation started in DoOpenItemL().
+		*/
+		void DoCloseItem();
+
+		/**
+		* DoMoveItemL() moves item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be moved.
+		* @param		aNewParent			A new parent of the item.
+		* @param		aStatus				On completion of the moving an item, contains the result code.
+		*/
+		void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus);
+
+		/**
+		* DoDeleteItemL() deletes item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be deleted.
+		* @param		aStatus				On completion of the deleting an item, contains the result code.
+		*/
+		void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+
+		/**
+		* DoSoftDeleteItemL() soft deletes item specified by aUid asynchronously.
+		* @param		aUid				Item UID which going to be softdeleted.
+		* @param		aStatus				On completion of the softdeleting an item, contains the result code.
+		*/
+		void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+
+		/**
+		* DoDeleteAllItemsL() deletes all items from opened database asynchronously.
+		* @param		aStatus				On completion of delete, contains the result code.
+		*/
+		void DoDeleteAllItemsL(TRequestStatus& aStatus);
+
+		/**
+		* DoHasSyncHistory() checks if previous sync with opened server and context.
+		* @return ETrue if there is synchonization history.
+		*/
+		TBool DoHasSyncHistory() const;
+
+		/**
+		* DoAddedItems() gets all added items on client since previous synchronization.
+		* @return Added items.
+		*/
+		const MSmlDataItemUidSet& DoAddedItems() const;
+
+		/**
+		* DoDeletedItems() gets all deleted items on client since previous synchronization.
+		* @return Deleted items.
+		*/
+		const MSmlDataItemUidSet& DoDeletedItems() const;
+
+		/**
+		* DoSoftDeletedItems() gets all softdeleted items on client since previous synchronization.
+		* @return Soft deleted items.
+		*/
+		const MSmlDataItemUidSet& DoSoftDeletedItems() const;
+
+		/**
+		* DoModifiedItems() gets all modified items on client since previous synchronization.
+		* @return Modified items.
+		*/
+		const MSmlDataItemUidSet& DoModifiedItems() const;
+
+		/**
+		* DoMovedItems() gets all moved items on client since previous synchronization.
+		* @return Moved items.
+		*/
+		const MSmlDataItemUidSet& DoMovedItems() const;
+
+		/**
+		* DoResetChangeInfoL() resets client synchronization data => next time will be slow sync.
+		* @param		aStatus				On completion of reset, contains the result code.
+		*/
+		void DoResetChangeInfoL(TRequestStatus& aStatus);
+
+		/**
+		* DoCommitChangeInfoL() commits client synchronization changes for given aItems list.
+		* @param		aStatus				On completion of given items, contains the result code.
+		* @param		aItems				Item ids to be commited.
+		*/
+		void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems);
+
+		/**
+		* DoCommitChangeInfoL() commits all client synchronization changes.
+		* @param		aStatus				On completion of all items, contains the result code.
+		*/
+		void DoCommitChangeInfoL(TRequestStatus& aStatus);
+
+		/**
+		* Default constructor.
+		*/
+		CNSmlContactsDataStore();
+
+		/**
+		* SetOwnStoreFormatL() Sets dataproviders own storeformat.
+		*/
+		void SetOwnStoreFormatL();
+
+		/**
+		* LdoFetchItemL() Fetches item data from database.
+		* @param		aUid				Items uid for fetching.
+		* @param		aItem				Items data after fetch.
+		* 
+		*/
+		void LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem );
+
+		/*
+		* LdoAddItemL() Adds item data to database.
+		* @param		aItem				Item data to be added.
+		* @param		aSize				Item data size.
+		*/
+		void LdoAddItemL( const TDesC8& aItem,
+		                  TInt aSize);
+		/*
+		* LdoAddItemL() Adds several items to database.
+		* @param		aItem				Items data to be added.
+		* @param		aSize				Items data size.
+		*/
+		void LdoAddItemsL( CBufBase*& aItems,TInt aSize);
+		
+		/**
+		* LdoUpdateItemL() Updates item data to database.
+		* 
+		*/
+		void LdoUpdateItemL();
+		
+		/**
+		* DriveBelowCriticalLevelL() Checks if there is enough space on client to store added item data.
+		* @param		aSize				Item size to be added.
+		* @return ETrue if there isn't enough drive space.
+		*/
+		TBool DriveBelowCriticalLevelL( TInt aSize );
+
+
+		/**
+		* StripPropertyL() Removes aProperty from aItem data.
+		* @param		aItem				Item data to be stripped.
+		* @param		aProperty			Property to be removed from aItem.
+		*/
+		void StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty ) const;
+
+		/**
+		* StripPropertyL() Remove aPropertys from aItem data.
+		* @param		aItem				Item(s) data to be stripped.
+		* @param		aProperty			Property to be removed from aItem.
+		*/
+		void StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty ) const;
+
+		/**
+		* ExecuteBufferL() Executes all buffered items from buffer.
+		* @param		aResultArray		Array to return statuscodes for each command.
+		*/
+		void ExecuteBufferL();
+		
+		/**
+		* ExecuteAddL() Executes all the add commands in buffer.
+		*/
+		TInt ExecuteAddL();
+		
+		/**
+		* ExecuteDeleteL() Executes all the delete commands in buffer.
+		*/
+		void ExecuteDeleteL();
+		
+		/**
+		* ExecuteBufferL() Executes all the update commands in buffer.
+		*/
+		void ExecuteUpdateL();
+		
+		/**
+		* ExecuteMoveL() Executes all the move commands in buffer.
+		*/
+		void ExecuteMoveL();
+	
+		/**
+		* AddBufferListL()Adds a new item to buffer.
+		* @param 		aUid 				New item's uid.
+		* @param 		aSize 				New item's size.
+		* @param 		aStatus 			New item's status.
+		* @return Pointer to the buffer.
+		*/
+		CBufBase* AddBufferListL(TSmlDbItemUid& aUid, TInt aSize, TInt aStatus);
+		
+		/**
+		* Checks if aItem is confidential or not.
+		* @param    aItem   Item that is checked.
+		* @return   TBool   ETrue if item is confidential.
+		*                   Otherwise EFalse is returned.
+		*/
+        TBool IsConfidentialL( MVPbkStoreContact& aItem );
+        
+        /**
+		* Leaving function called when fetch/retrieve 
+		* operation is complete
+		* @param    aContact   contact fetched/retrieved
+		* 
+		*/
+        void SingleContactOperationCompleteL(MVPbkStoreContact* aContact);
+        
+        /**
+		* Create a contact view of the store which is opened
+		*/
+        void CreateViewL();
+        
+        /**
+		* Delete all the contacts
+		*/
+        void DoDeleteAllContactsL();
+        /**
+		* Leaving function called when the operation is complete
+		*/
+        void OperationCompleteL();
+        /**
+		* Reset the contacts data buffer
+		*/
+        void ResetBuffer();
+	
+
+	private: // data
+	
+			// MODULE DATA STRUCTURES
+		enum TNSmlDataStoreStatus  // DataStore status
+			{
+			ENSmlClosed = 1,
+			ENSmlOpenAndWaiting,
+			ENSmlItemOverflow,
+			ENSmlItemOpen,
+			ENSmlItemCreating,
+			ENSmlItemUpdating
+			};
+
+		enum TNSmlCntCommand		// Modification type
+			{
+			ENSmlCntItemAdd = 1,
+			ENSmlCntItemDelete,
+			ENSmlCntItemSoftDelete,
+			ENSmlCntItemRead,
+			ENSmlCntItemMove,
+			ENSmlCntItemReplace
+			};
+			
+			enum TNSmlLastOp
+			{
+			ENSmlRetrieveOp = 1,
+			ENSmlAddOp,
+			ENSmlDeleteOp,
+			ENSMLFetchOp,
+			ENSMLDeleteAllOp,
+			ENSMLUpdateExportOp,
+			ENSMLUpdateImportOp,
+			ENSmlNone
+			};
+	
+
+		// ------------------------------------------------------------------------------------------------
+		// Buffering Stuff for BatchMode operations
+		// ------------------------------------------------------------------------------------------------
+		class CNSmlContactsBufferItem : public CBase
+			{
+			public:	
+				/**
+				* Destructor.
+				*/
+				~CNSmlContactsBufferItem();
+				
+			public: // data
+				TSmlDbItemUid	*iPUid;			// New item ID 
+				TSmlDbItemUid	iUid;			// Item ID
+				CBufBase		*iItemData;		// Item data
+				HBufC8 			*iMimeType;		// Mimetype
+				HBufC8 			*iMimeVersion;	// Mime version
+				TNSmlCntCommand iModType;		// Commands type
+				TInt			iStatus;		// Command status
+				TInt 			iSize;			// Item size
+			};
+		
+	
+		CNSmlChangeFinder* iChangeFinder;
+		TRequestStatus* iCallerStatus;
+		TBool iSnapshotRegistered;
+		TBool iBatchMode;
+		TBool iTransactionMode;
+		TBool iOpened;
+		TInt iModificationCount;
+		TInt64 iOpenedStoreId;
+
+		TPtrC8 iMimeTypeItem;
+		TPtrC8 iMimeVersionItem;
+		
+		TPtrC8 iUsedMimeType;
+		TPtrC8 iUsedMimeVersion;
+
+		RStringF iServerMimeType;
+		RStringF iServerMimeVersion;
+		
+		TInt iServerMaxObjectSize;
+		HBufC* iDefaultStoreName;
+				
+		//The symbian Db name that is used for communication with servers
+		//Changes done to mantain backward compatibility of function
+		HBufC* iPacketStoreName;
+
+		CNSmlDataModBase* iDataMod;
+		CNSmlContactsModsFetcher* iContactsModsFetcher; 
+
+		RFs iRfs;
+		TInt iDrive;
+		
+		
+		TSmlDbItemUid iUid;
+		TInt iItemSize;
+		TInt iItemPos;
+		TNSmlCntCommand iModType;
+		
+		CBufBase* iItemData;
+		CBufBase* iItemDataAddBatch;
+		CBufFlat* iMergeItem;
+
+		RPointerArray<CNSmlContactsBufferItem> iContactsBufferItemList;
+
+		TKeyArrayFix iKey;
+		TBool iSyncHistory;
+		HBufC* iStoreName;
+		
+		RStringPool iStringPool;
+		CSmlDataStoreFormat* iStoreFormat;
+		
+		CNSmlDataItemUidSet* iNewUids;
+		CNSmlDataItemUidSet* iDeletedUids;
+		CNSmlDataItemUidSet* iSoftDeletedUids;
+		CNSmlDataItemUidSet* iReplacedUids;
+		CNSmlDataItemUidSet* iMovedUids;
+
+		
+		TNSmlDataStoreStatus iState;
+		TInt iStateItem;
+		
+		RArray<TInt> iAddResultArray; 
+
+		CVPbkContactManager* iContactManager;
+        MVPbkContactStore* iStore;
+        CVPbkVCardEng* iVCardEngine ;
+        MVPbkContactLink* iContactLink;
+        CVPbkContactIdConverter* iIdConverter;
+        CVPbkContactLinkArray* iContactLnks;
+        MVPbkContactViewBase* iContactViewBase;
+        
+        TInt *iSize;
+        RBufWriteStream iWriteStream;
+        RDesReadStream iReadStream;
+        HBufC8* iBuf;
+        TInt  iRetCommand;
+        
+        TInt iIndex;
+		TInt iRetrieveCount;
+		RArray<TInt> *iResultArray;
+		TNSmlLastOp iLastOperation;
+	};
+
+
+#endif // __NSMLCONTACTSDATASTORE_H__
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/inc/NSmlContactsModsFetcher.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  DS contacts datastore.
+*
+*/
+
+
+#ifndef __NSMLCONTACTSMODSFETCHER_H__
+#define __NSMLCONTACTSMODSFETCHER_H__
+
+// INCLUDES
+#include <SmlDataProvider.h>
+#include <SmlDataFormat.h>
+#include <f32file.h>
+#include <cntdb.h>
+#include <cntitem.h>
+#include "nsmlchangefinder.h"
+
+#include <CVPbkContactManager.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactViewObserver.h>
+#include <CVPbkSortOrder.h>
+#include <MVPbkContactViewBase.h>
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactOperationBase.h>
+
+// CONSTANTS
+const TInt KNSmlSnapshotSize = 56;
+const TInt KNSmlSnapshotSmallSize = 8;
+_LIT( KNSmlContactSyncNoSync, "none" ); // Taken from phonebook
+
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher
+//
+// @lib nsmlcontactsdataprovider.lib
+// ------------------------------------------------------------------------------------------------
+class CNSmlContactsModsFetcher : public CActive,
+								MVPbkContactViewObserver,
+								MVPbkSingleContactOperationObserver,
+								MVPbkContactOperationBase
+								
+	{
+	public:
+		/**
+		* C++ constructor.
+		* @param		aSnapshotRegistered	Is snapshot registered.
+		* @param		aCntDb				Pointer to opened database.
+		* @param		aKey				Key array.
+		* @param		aChangeFinder		Pointer to Changefinder.
+		*/
+		CNSmlContactsModsFetcher( TBool& aSnapshotRegistered,CVPbkContactManager& aContactManager,MVPbkContactStore& aStore,TKeyArrayFix& aKey, CNSmlChangeFinder& aChangeFinder );
+		/**
+		* Second phase constructor.
+		*/
+		void ConstructL();
+
+		/**
+		* Reads all modifications from clients contacts databse.
+		* @param		aStatus				On completion of the operation, contains the result code.
+		*/
+		void FetchModificationsL( TRequestStatus& aStatus );
+
+		/**
+		* ~CNSmlContactsModsFetcher() desctructor.
+		*/
+		virtual ~CNSmlContactsModsFetcher();
+		
+	private:
+	
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a view is ready for use. 
+		*/
+
+		void ContactViewReady(
+		            MVPbkContactViewBase& aView ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a view is unavailable for a while. 
+		*/            
+		void ContactViewUnavailable(
+		            MVPbkContactViewBase& aView ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a contact has been added to the view.
+		*/            
+		void ContactAddedToView(
+		            MVPbkContactViewBase& aView, 
+		            TInt aIndex, 
+		            const MVPbkContactLink& aContactLink );
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when a contact has been removed from a view.
+		*/            
+		void ContactRemovedFromView(
+		            MVPbkContactViewBase& aView, 
+		            TInt aIndex, 
+		            const MVPbkContactLink& aContactLink ) ;
+		/**
+		* From MVPbkContactViewObserver  
+		* Called when an error occurs in the view.
+		*/            
+		void ContactViewError(
+		            MVPbkContactViewBase& aView, 
+		            TInt aError, 
+		            TBool aErrorNotified ) ;
+		            /**
+		* From MVPbkSingleContactOperationObserver  
+		* Called when the operation is completed.
+		*/
+         void VPbkSingleContactOperationComplete(MVPbkContactOperationBase& aOperation,MVPbkStoreContact* aContact ); 
+         
+		/**
+		* From MVPbkSingleContactOperationObserver  
+		*  Called if the operation fails.
+		*/
+ 		void VPbkSingleContactOperationFailed(
+ 					MVPbkContactOperationBase& aOperation, 
+ 					TInt aError );
+
+	private:
+		/**
+		* Fetches next chunk of data (client contacts data changes).
+		*/
+		void FetchNextContactL();
+
+		/**
+		* From CActive. Called when asynchronous operation completes.
+		*/
+		void RunL();
+		
+		/**
+		* From CActive. Called when RunL leaves.
+		*/    
+		TInt RunError( TInt aError );
+
+		/**
+		* From CActive. Cancels operation.
+		*/
+		void DoCancel();
+		
+		/**
+		* Checks if aItem is confidential or not.
+		* @param    aItem   Item that is checked.
+		* @return   TBool   ETrue if item is confidential.
+		*                   Otherwise EFalse is returned.
+		*/
+        TBool IsConfidentialL( MVPbkStoreContact& aItem );
+        /**
+		* Create a contact view of the store which is opened
+		*/
+        void CreateViewL();
+        /**
+		* Add the fetched contacts id and timestamp 
+		* to the snapshot.
+		* @param    aContact   Fetched contact to be 
+		*						added to snapshot
+		*/
+        void UpdateSnapshotL( MVPbkStoreContact* aContact );
+		
+	private: // data
+		TRequestStatus* iCallerStatus;
+		TTime iFromTime;
+		
+		
+		CArrayFixSeg<TNSmlSnapshotItem>* iSnapshot;
+		
+		TBool& iSnapshotRegistered;
+
+
+		TKeyArrayFix& iKey;
+
+		CNSmlChangeFinder& iChangeFinder;
+		TInt iCurrentSnapshotCounter;
+
+		CVPbkContactManager& iContactManager;
+        MVPbkContactStore& iStore;
+        MVPbkContactViewBase* iContactViewBase;
+        TInt iContactCount;
+
+	};
+
+#endif // __NSMLCONTACTSMODSFETCHER_H__
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/inc/nsmlcontactsdefs.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS Contacts adapter definition file.
+*
+*/
+
+
+#ifndef __NSMLCONTACTSDEFS_H__ 
+#define __NSMLCONTACTSDEFS_H__ 
+
+// DEFINES
+//#define __NSML_MODULETEST__		// Comment/uncomment to activate/deactivate moduletest
+
+// INCLUDES
+#include <e32std.h>
+
+// CONSTANTS
+_LIT( KNSmlDefaultLocalDbName, "C:\\System\\Data\\Contacts.cdb" );
+_LIT( KNSmlDefaultRemoteDbName, "" );
+
+#endif // __NSMLCONTACTSDEFS_H__ 
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/loc/101F6DD6.loc	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Registery info for DS Contacts
+*
+*/
+
+
+//d:Display name for registry info 
+//l:list_setting_pane_t1
+//
+#define qtn_nsml_cnt_display_name "Contacts" 
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/101F6DD6.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Registery info for DS Contacts
+*
+*/
+
+
+#include<101F6DD6.loc>
+
+#include <registryinfo.rh>
+#include <nsmldsconstants.h>
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101F6DDD; // DS interface implementation UID
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDSInterfaceUid; // DS interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101F6DDD; // DS interface implementation UID
+                version_no = 1; 
+                display_name = qtn_nsml_cnt_display_name;
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataProvider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,332 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  DS contacts dataprovider
+*
+*/
+
+
+// INCLUDE FILES
+#include <utf.h>
+#include <e32base.h>
+#include <s32strm.h>
+#include <cntdb.h>
+#include <e32cmn.h>
+#include <cntitem.h>
+#include <sysutil.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <SmlDataProvider.h>
+#include <implementationproxy.h>
+#include <NSmlContactsDataStoreFormat_1_1_2.rsg>
+#include <NSmlContactsDataStoreFormat_1_2.rsg>
+#include <data_caging_path_literals.hrh>
+#include <vtoken.h>
+#include <e32property.h>
+#include <DataSyncInternalPSKeys.h>
+#include "NSmlContactsDataProvider.h"
+#include "nsmldebug.h"
+#include "nsmlconstants.h"
+#include "NSmlDataModBase.h"
+#include "nsmldsimpluids.h"
+#include "nsmlchangefinder.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::NewL
+// -----------------------------------------------------------------------------
+//
+CNSmlContactsDataProvider* CNSmlContactsDataProvider::NewL()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::NewL(): begin");
+	CNSmlContactsDataProvider* self = NewLC();
+	CleanupStack::Pop();
+	_DBG_FILE("CNSmlContactsDataProvider::NewL(): end");
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::NewLC
+// -----------------------------------------------------------------------------
+//
+CNSmlContactsDataProvider* CNSmlContactsDataProvider::NewLC()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::NewLC(): begin");
+	
+	CNSmlContactsDataProvider* self = new (ELeave) CNSmlContactsDataProvider();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	_DBG_FILE("CNSmlContactsDataProvider::NewLC(): end");
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::CNSmlContactsDataProvider
+// -----------------------------------------------------------------------------
+//
+CNSmlContactsDataProvider::CNSmlContactsDataProvider()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::CNSmlContactsDataProvider(): begin");
+	_DBG_FILE("CNSmlContactsDataProvider::CNSmlContactsDataProvider(): end");
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CNSmlContactsDataProvider::ConstructL()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::ConstructL(): begin");
+	
+	User::LeaveIfError( iRfs.Connect() );
+
+	iContactsDataStore = CNSmlContactsDataStore::NewL();	
+	
+	iStringPool.OpenL();
+	
+	_DBG_FILE("CNSmlContactsDataProvider::ConstructL(): end");
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::~CNSmlContactsDataProvider
+// -----------------------------------------------------------------------------
+//
+CNSmlContactsDataProvider::~CNSmlContactsDataProvider()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::~CNSmlContactsDataProvider(): begin");
+
+	iRfs.Close();
+
+	delete iContactsDataStore;
+	delete iStoreFormat;
+	iFilterArray.ResetAndDestroy();
+	iFilterArray.Close();
+
+	iStringPool.Close();
+
+	_DBG_FILE("CNSmlContactsDataProvider::~CNSmlContactsDataProvider(): end");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoOnFrameworkEvent
+// -----------------------------------------------------------------------------
+//
+void CNSmlContactsDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent /*aFrameworkEvent*/, TInt /*aParam1*/, TInt /*aParam2*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoOnFrameworkEvent(): begin");
+	_DBG_FILE("CNSmlContactsDataProvider::DoOnFrameworkEvent(): end");
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoSupportsOperation
+// -----------------------------------------------------------------------------
+//
+TBool CNSmlContactsDataProvider::DoSupportsOperation( TUid aOpId ) const
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoSupportsOperation(): begin");
+
+	if ( aOpId == KUidSmlSupportBatch ||
+	     aOpId == KUidSmlSupportMultipleStores )
+		{
+		return ETrue;
+		}
+
+	_DBG_FILE("CNSmlContactsDataProvider::DoSupportsOperation(): end");
+
+	return EFalse; // KUidSmlSupportTransaction ,KUidSmlSupportSuspendResume, KUidSmlSupportUserSelectableMatchType
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoStoreFormatL
+// -----------------------------------------------------------------------------
+//
+const CSmlDataStoreFormat& CNSmlContactsDataProvider::DoStoreFormatL()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoStoreFormatL(): begin");
+	
+	delete iStoreFormat;
+	iStoreFormat = NULL;
+	
+	TFileName fileName;
+	TParse parse;
+	
+	// Locate the resource file
+	TFileName dllFileName;
+	Dll::FileName( dllFileName );
+    
+	TFileName resourceFileName;
+	resourceFileName.Copy( TParsePtrC( dllFileName ).Drive() );  
+	// Check correct Data Sync protocol
+    TInt value( EDataSyncNotRunning );
+    TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                 KDataSyncStatus,
+                                 value );
+    if ( error == KErrNone &&
+         value == EDataSyncRunning )
+        {
+        resourceFileName.Append(KNSmlContactsStoreFormatRsc_1_1_2);
+        parse.Set( resourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+        }
+    else // error or protocol version 1.2 
+        {
+        resourceFileName.Append(KNSmlContactsStoreFormatRsc_1_2);
+        parse.Set( resourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+        }		
+
+	fileName = parse.FullName();
+
+	RResourceFile resourceFile; 
+	BaflUtils::NearestLanguageFile( iRfs, fileName );
+
+	resourceFile.OpenL( iRfs,fileName );
+	CleanupClosePushL( resourceFile );
+	
+	HBufC8* contactsDataFormat = resourceFile.AllocReadLC( NSML_CONTACTS_DATA_STORE_FORMAT );
+
+	TResourceReader reader;
+	reader.SetBuffer( contactsDataFormat );
+
+	iStoreFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+	CleanupStack::Pop(); // iStoreFormat
+	
+	CleanupStack::PopAndDestroy( 2 ); // contactsDataFormat,resourceFile  
+	
+	_DBG_FILE("CNSmlContactsDataProvider::DoStoreFormatL(): end");
+
+	return *iStoreFormat;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoListStoresLC
+// -----------------------------------------------------------------------------
+//
+CDesCArray* CNSmlContactsDataProvider::DoListStoresLC()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoListStoresLC(): begin");
+	_DBG_FILE("CNSmlContactsDataProvider::DoListStoresLC(): end");
+	
+	return iContactsDataStore->DoListStoresLC();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoDefaultStoreL
+// -----------------------------------------------------------------------------
+//
+const TDesC& CNSmlContactsDataProvider::DoDefaultStoreL()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoIdentifier(): begin");
+	_DBG_FILE("CNSmlContactsDataProvider::DoIdentifier(): end");
+
+	return iContactsDataStore->DefaultStoreNameL();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoNewStoreInstanceLC
+// -----------------------------------------------------------------------------
+//
+CSmlDataStore* CNSmlContactsDataProvider::DoNewStoreInstanceLC()
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoNewStoreInstanceLC(): begin");
+
+	CNSmlContactsDataStore* newDataStore = CNSmlContactsDataStore::NewL();
+	CleanupStack::PushL( newDataStore );
+
+	_DBG_FILE("CNSmlContactsDataProvider::DoNewStoreInstanceLC(): end");
+
+	return newDataStore;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoSupportedServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+const RPointerArray<CSyncMLFilter>& CNSmlContactsDataProvider::DoSupportedServerFiltersL()
+	{
+	// This method returns empty array. It means that this Data Provider does not support filtering
+	_DBG_FILE("CNSmlContactsDataProvider::DoSupportedServerFiltersL(): BEGIN");
+	_DBG_FILE("CNSmlContactsDataProvider::DoSupportedServerFiltersL(): END");
+	return iFilterArray;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataProvider::CheckServerFiltersL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoCheckServerFiltersL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataProvider::DoCheckServerFiltersL(): END");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC
+// 
+// ------------------------------------------------------------------------------------------------
+HBufC* CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC(): END");
+	return NULL;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL(): BEGIN");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL(): END");
+	}
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy array
+// -----------------------------------------------------------------------------
+//
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr ) {{aUid},(aFuncPtr)}
+#endif
+
+const TImplementationProxy ImplementationTable[] = 
+    {
+	IMPLEMENTATION_PROXY_ENTRY( KNSmlContactsAdapterImplUid, CNSmlContactsDataProvider::NewL )
+    };
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+	_DBG_FILE("ImplementationGroupProxy() for CNSmlContactsDataProvider: begin");
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+	_DBG_FILE("ImplementationGroupProxy() for CNSmlContactsDataProvider: end");
+    return ImplementationTable;
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStore.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,2416 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  DS contacts dataprovider
+*
+*/
+
+
+// INCLUDE FILES
+#include <barsc.h>
+#include <bautils.h>
+#include <e32base.h>
+#include <s32strm.h>
+#include <e32cmn.h>
+#include <e32des16.h>
+#include <s32mem.h>
+#include <implementationproxy.h>
+#include <vtoken.h>
+#include <sysutil.h>
+#include <NSmlContactsDataStoreFormat_1_1_2.rsg>
+#include <NSmlContactsDataStoreFormat_1_2.rsg>
+#include <data_caging_path_literals.hrh>
+#include <SmlDataFormat.h>
+#include <SmlDataProvider.h>
+#include <e32property.h>
+#include <DataSyncInternalPSKeys.h>
+#include <e32hashtab.h>
+
+#include <CVPbkContactStoreUriArray.h>
+#include <VPbkContactStoreUris.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkStoreContactProperties.h>
+#include <MVPbkViewContact.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkStoreContact2.h>
+#include <MVPbkFieldType.h>
+#include <MVPbkContactFieldTextData.h>
+#include <CVPbkContactFieldIterator.h>
+#include <CVPbkContactViewDefinition.h>
+
+#include <MVPbkContactLink.h>
+#include <s32mem.h>
+
+#include "NSmlContactsDataStore.h"
+#include "NSmlContactsModsFetcher.h"
+#include "nsmldebug.h"
+#include "nsmlconstants.h"
+#include "NSmlDataModBase.h"
+#include "nsmlcontactsdefs.h"
+#include "nsmldsimpluids.h"
+#include "nsmlsnapshotitem.h"
+#include "nsmlchangefinder.h"
+#include <VPbkEng.rsg>
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem
+// ----------------------------------------------------------------------------
+CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem()
+	{
+	delete iItemData;
+	delete iMimeType;
+	delete iMimeVersion;
+	}
+	
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::NewL
+// ----------------------------------------------------------------------------
+CNSmlContactsDataStore* CNSmlContactsDataStore::NewL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::NewL: BEGIN");
+	CNSmlContactsDataStore* self = new ( ELeave ) CNSmlContactsDataStore();
+	CleanupStack::PushL(self);
+		
+	self->ConstructL();
+	CleanupStack::Pop(self); // self
+		
+	_DBG_FILE("CNSmlContactsDataStore::NewL: END");
+	return self;
+	}
+
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::CNSmlContactsDataStore() 
+// ----------------------------------------------------------------------------
+CNSmlContactsDataStore::CNSmlContactsDataStore() : 
+	iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem,ItemId() ),ECmpTInt )),
+	iContactManager(NULL),
+	iStore(NULL),
+	iVCardEngine(NULL),
+	iIdConverter(NULL),
+	iContactLnks(NULL),
+	iContactViewBase(NULL),
+	iSize(NULL),	
+	iBuf(NULL)
+	{
+	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): begin");
+
+	iSyncHistory = EFalse;
+	iSnapshotRegistered = EFalse;
+
+	iServerMaxObjectSize = 0; // Maximum size default value 
+	iItemPos = -1;
+	iModificationCount = KNSmlCompactAfterChanges;
+	
+	iState = ENSmlClosed;
+	iStoreName = NULL;
+	iRetCommand = KErrNone;
+	iLastOperation = ENSmlNone;
+	
+	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): end");
+	}
+	
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::ConstructL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::ConstructL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): begin");
+	
+	User::LeaveIfError( iRfs.Connect() );
+
+	iUsedMimeType.Set( KNSmlvCard21Name() );
+	iUsedMimeVersion.Set( KNSmlvCard21Ver() );
+	iStringPool.OpenL();
+	
+	// Uid Sets
+	iNewUids = new (ELeave) CNSmlDataItemUidSet();
+	iDeletedUids = new (ELeave) CNSmlDataItemUidSet();
+	iSoftDeletedUids = new (ELeave) CNSmlDataItemUidSet();
+	iMovedUids = new (ELeave) CNSmlDataItemUidSet();
+	iReplacedUids = new (ELeave) CNSmlDataItemUidSet();
+
+	// Create iDataMod
+	// This should be done after OpenL if there are more than one database
+	iDataMod = new (ELeave) CNSmlVCardMod();
+
+	SetOwnStoreFormatL();
+	// open  contact database
+	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+	uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
+	
+	iContactManager = CVPbkContactManager::NewL(*uriArray);
+	CleanupStack::PopAndDestroy(uriArray);
+	//Default store name
+	iDefaultStoreName = (VPbkContactStoreUris::DefaultCntDbUri()).AllocL();
+	
+	//Fill iPacketStoreName buffer with KLegacySymbianDatabase
+    TBuf<KOldSymbianDBLength> dataBase(KLegacySymbianDatabase);
+	iPacketStoreName = HBufC::NewL(dataBase.Length());        
+	TPtr pktStorePtr(iPacketStoreName->Des());
+	pktStorePtr.Copy(dataBase);
+		
+	_DBG_FILE("CNSmlContactsDataStore::ConstructL(): end");
+	}
+	
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::~CNSmlContactsDataStore()
+// ----------------------------------------------------------------------------
+CNSmlContactsDataStore::~CNSmlContactsDataStore()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::~CNSmlContactsDataStore(): begin");
+	
+	delete iStoreFormat; // SetOwnStoreFormatL creates
+	iStringPool.Close();
+
+	iRfs.Close();
+	iWriteStream.Close();
+	iReadStream.Close();
+	delete iBuf;
+	
+	if ( iChangeFinder )
+		{
+		TRAP_IGNORE( iChangeFinder->CloseL() );
+		delete iChangeFinder;
+		}
+	
+	if(iIdConverter)
+		{
+		delete iIdConverter;
+		}
+	if(iContactLnks)
+		{
+		delete iContactLnks;
+		}
+	if(iContactLink)
+		{
+		delete iContactLink;	
+		}
+	delete iContactViewBase;
+	if ( iContactsModsFetcher )
+		{
+		iContactsModsFetcher->Cancel(); 
+		delete iContactsModsFetcher;
+		}
+	if ( iContactManager )
+		{
+			if(iStore)
+			{
+			iStore->Close( *this );	
+			}
+	    delete iContactManager;
+		}
+	
+	
+	delete iVCardEngine;
+	//  Delete UidSets		
+	//
+	delete iNewUids;
+	delete iDeletedUids;
+	delete iSoftDeletedUids;
+	delete iMovedUids;
+	delete iReplacedUids;
+	
+	//
+	//	Empty BufferItemList if any
+	//
+	if ( iContactsBufferItemList.Count() > 0 )
+		{
+		if ( iContactsBufferItemList[iContactsBufferItemList.Count() - 1]->iItemData == iItemData )
+			{
+			iItemData = NULL;
+			}
+		}
+	iContactsBufferItemList.ResetAndDestroy();
+	delete iDataMod;
+	delete iMergeItem;
+
+	if(iItemData)
+    	{
+	    if(iItemData->Size() > 0 )
+	        {
+		    delete iItemData;       
+	        }
+	    }
+	
+	if(iItemDataAddBatch != iItemData)
+		{
+		delete iItemDataAddBatch;	
+		}
+		
+	delete iDefaultStoreName;
+	delete iPacketStoreName;
+
+	delete iStoreName;
+
+	iAddResultArray.Close();
+	
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoOpenL(const TDesC& 		  aStoreName, 
+//									    MSmlSyncRelationship& aContext,
+//									    TRequestStatus& 	  aStatus)
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoOpenL( const TDesC& aStoreName, 
+									MSmlSyncRelationship& aContext, 
+									TRequestStatus& aStatus )
+	{
+	DBG_ARGS(_S("CNSmlContactsDataStore::DoOpenL(): '%S' begin"), &aStoreName);
+
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( iState != ENSmlClosed )
+		{
+		User::RequestComplete( iCallerStatus, KErrInUse );	
+		return;	
+		}
+
+	if( RFs::CharToDrive(aStoreName[0], iDrive) != KErrNone )
+		{
+		RFs::CharToDrive( KNSmlDriveC()[0], iDrive );
+		}
+	iOpened = EFalse;
+	
+	if( iStoreName )
+		{
+		delete iStoreName;
+		iStoreName = NULL;
+		}
+		
+		if ( iChangeFinder )
+		{
+		iChangeFinder->CloseL();
+		delete iChangeFinder;
+		iChangeFinder = NULL;
+		}
+	// The Change finder maintains a list of all changes to the database.
+	iChangeFinder = CNSmlChangeFinder::NewL(
+					 aContext, iKey, iSyncHistory, KNSmlContactsAdapterImplUid );
+	
+	iState = ENSmlOpenAndWaiting;			
+	
+	//find and open the store
+	if ( aStoreName == KNSmlContactStoreNameForDefaultDB )
+	    {
+	iStore = iContactManager->ContactStoresL().Find(
+	TVPbkContactStoreUriPtr(*iDefaultStoreName));
+	    }
+	else
+	   {
+	    iStore = iContactManager->ContactStoresL().Find(
+	TVPbkContactStoreUriPtr(aStoreName));
+	    }
+	iStore->OpenL(*this);
+
+	iStoreName = aStoreName.AllocL();
+	
+	iVCardEngine = CVPbkVCardEng::NewL( *iContactManager );
+	iIdConverter = CVPbkContactIdConverter::NewL(*iStore );
+	if ( iContactsModsFetcher )
+		{
+		iContactsModsFetcher->Cancel();
+		delete iContactsModsFetcher;
+		iContactsModsFetcher = NULL;
+		}
+		
+	iContactsModsFetcher = new (ELeave) CNSmlContactsModsFetcher( 
+							iSnapshotRegistered, *iContactManager,*iStore, iKey, *iChangeFinder );
+	iContactsModsFetcher->ConstructL();
+	
+#ifdef __NSML_MODULETEST__
+	CActiveScheduler::Start();
+#endif
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoOpenL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCancelRequest()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCancelRequest()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): begin");
+		if(iContactsModsFetcher)
+		{
+		iContactsModsFetcher->Cancel();
+		}
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): NOT NEEDED end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoStoreName()
+// ----------------------------------------------------------------------------
+const TDesC& CNSmlContactsDataStore::DoStoreName() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): begin");
+	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): end");
+	return *iStoreName;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DefaultStoreNameL()
+// ----------------------------------------------------------------------------
+const TDesC& CNSmlContactsDataStore::DefaultStoreNameL() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DefaultStoreNameL(): begin");
+	
+	if ( !iDefaultStoreName )
+		{
+		return KNullDesC;
+		}
+
+	_DBG_FILE("CNSmlContactsDataStore::DefaultStoreNameL(): end");
+	//The engine methods that create syncml packet, use this information in Database fields
+	return *iPacketStoreName;
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoBeginTransactionL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoBeginTransactionL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): begin");
+	User::Leave( KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCommitTransactionL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCommitTransactionL(TRequestStatus& aStatus)
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitTransactionL(): begin");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitTransactionL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoRevertTransaction()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoRevertTransaction(TRequestStatus& aStatus)
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoRevertTransaction(): begin");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+
+	_DBG_FILE("CNSmlContactsDataStore::DoRevertTransaction(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoBeginBatchL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoBeginBatchL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoBeginBatchL(): begin");
+	
+	iBatchMode = ETrue;			// SUPPORTED on Contacts
+
+	_DBG_FILE("CNSmlContactsDataStore::DoBeginBatchL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCommitBatchL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCommitBatchL( RArray<TInt>& aResultArray, TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitBatchL(): begin");
+
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( !iBatchMode )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		_DBG_FILE("CNSmlContactsDataStore::DoCommitBatchL(): NOT ON BATCH MODE end");
+		return;
+		}
+//		
+// Go through Buffer and execute all commands return aResultArray
+//
+	
+	iResultArray = &aResultArray;
+	
+	iIndex = 0;
+	TRAPD( leavecode,ExecuteBufferL() );
+	
+	if( leavecode != KErrNone )
+		{
+		User::RequestComplete( iCallerStatus, leavecode );
+		}
+
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitBatchL(): end");
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::ExecuteBufferL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::ExecuteBufferL() 
+	{
+	_DBG_FILE("CNSmlContactsDataStore::ExecuteBufferL(): begin");
+	
+	TInt  retCommand( KErrNone );
+	
+	//
+	// Loop through buffered commands
+	//
+		if( iIndex < iContactsBufferItemList.Count())
+		{
+		
+		if( iContactsBufferItemList[iIndex]->iStatus!= KNSmlNoError )
+			{
+			retCommand = iContactsBufferItemList[iIndex]->iStatus;
+			}
+		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd )
+			{
+			retCommand = ExecuteAddL();
+			}
+		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace )
+			{
+			ExecuteUpdateL();		
+			}
+		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemMove )
+			{
+			ExecuteMoveL();
+			}
+		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete ||
+				 iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemSoftDelete )
+			{
+			ExecuteDeleteL();
+			}
+		//
+		//	Set allready set commands from iContactsBufferItemList
+		//
+		if( ( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd     ||
+		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace ||
+		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete  ||
+		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemSoftDelete ) &&
+		      iContactsBufferItemList[iIndex]->iStatus  != KNSmlNoError )
+			{
+			retCommand = iContactsBufferItemList[iIndex]->iStatus;
+			}
+			
+		
+		//if an error occurs when performing any operation
+		//return the error status 
+			else if(retCommand!=KErrNone)
+			{
+			User::RequestComplete( iCallerStatus, retCommand );	
+			}
+			
+			iRetCommand = retCommand;
+		}
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::ExecuteAddL()
+// ----------------------------------------------------------------------------
+	
+TInt CNSmlContactsDataStore::ExecuteAddL()
+	{
+	TInt  retCommand( KErrNone );
+	StripPropertyL( iItemDataAddBatch, KVersitTokenUID() ); // Remove UID's from data
+
+	TInt err( KErrNone );
+	if(iBatchMode)			
+		{
+		TRAP( err,LdoAddItemsL( iItemDataAddBatch,
+		                   iItemDataAddBatch->Ptr(0).Length()) );
+		if(err!=KErrNone)			
+			{
+			retCommand = err;
+			TInt j = iIndex;
+			while( j < iContactsBufferItemList.Count() )
+				{
+				if( iContactsBufferItemList[j]->iModType == ENSmlCntItemAdd &&
+				iContactsBufferItemList[j]->iStatus  == KNSmlNoError )
+					{
+					iContactsBufferItemList[j]->iStatus = KErrNotSupported;
+					iResultArray->AppendL(KErrNotSupported);
+					}
+				j++;
+				}
+			}			                          
+		}
+	else
+		{
+		const TPtr8 dataPtr = iItemDataAddBatch->Ptr(0);
+		TRAP( err, LdoAddItemL( dataPtr,
+					iContactsBufferItemList[iIndex]->iSize));
+		if(err!=KErrNone)			
+			{
+			retCommand = err;
+			}	
+		}
+	return retCommand; 
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::ExecuteDeleteL()
+// ----------------------------------------------------------------------------
+	
+void CNSmlContactsDataStore:: ExecuteDeleteL()
+	{
+	
+	if(iBatchMode)			
+		{
+		iContactLnks = CVPbkContactLinkArray::NewL();
+		
+		TInt j=iIndex;
+		while( j < iContactsBufferItemList.Count() )
+			{
+			if( (iContactsBufferItemList[j]->iModType == ENSmlCntItemDelete ||
+			iContactsBufferItemList[j]->iModType == ENSmlCntItemSoftDelete) &&
+			iContactsBufferItemList[j]->iStatus  == KNSmlNoError )
+				{
+				TContactItemId id = iContactsBufferItemList[j]->iUid; 
+
+				if( id != 0 )
+					{
+					MVPbkContactLink* contactLink = iIdConverter->IdentifierToLinkLC(id);
+					//check if the contact link is valid
+					TInt index = iContactViewBase->IndexOfLinkL(*contactLink);
+					if(index != KErrNotFound)
+						{
+						iContactLnks->AppendL(contactLink);	
+						}
+						else
+						{
+						iContactsBufferItemList[j]->iStatus  = KErrNotFound;
+						}
+
+					CleanupStack::Pop();//contactLink				
+					}
+					else 
+					{
+					iContactsBufferItemList[j]->iStatus  = KErrNotFound;
+					}
+				}
+			j++;
+			}
+
+		delete iContactViewBase;
+		iContactViewBase = NULL;
+
+		iContactManager->DeleteContactsL( *iContactLnks, *this );
+		iLastOperation = ENSmlDeleteOp;
+		}
+
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::ExecuteUpdateL()
+// ----------------------------------------------------------------------------
+	
+void CNSmlContactsDataStore::ExecuteUpdateL()
+	{
+	iUid  = iContactsBufferItemList[iIndex]->iUid;
+
+	iDataMod->SetUsedMimeType( iServerMimeType, iServerMimeVersion );
+
+	// Check whether merging is needed or not.
+	if( iDataMod->NeedsMerge() )
+		{
+		iMergeItem = CBufFlat::NewL(64);
+		iWriteStream.Open(*iMergeItem);
+
+		MVPbkContactLink* contactLink = iIdConverter->IdentifierToLinkLC(iUid);
+
+		iVCardEngine->ExportVCardForSyncL(iWriteStream,*contactLink,*this);
+		CleanupStack::PopAndDestroy();
+
+		iLastOperation = ENSMLUpdateExportOp;
+		}
+	else
+		{
+			LdoUpdateItemL();
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::ExecuteMoveL
+// ----------------------------------------------------------------------------
+
+void CNSmlContactsDataStore::ExecuteMoveL()
+	{
+	// move command is not supported
+	if(!iBatchMode)
+		{
+		ResetBuffer();
+		User::RequestComplete( iCallerStatus, KErrNotSupported );	
+		}
+	else
+		{
+		iResultArray->AppendL(KErrNotSupported);
+		iIndex++;
+		if(iIndex == iContactsBufferItemList.Count() )
+			{
+			ResetBuffer();
+			User::RequestComplete( iCallerStatus, KErrNone );	
+			}
+		else
+			{
+				ExecuteBufferL();
+			}		
+		}
+	}
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCancelBatch()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCancelBatch()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCancelBatch(): begin");
+	if( iBatchMode )
+		{
+		iBatchMode = EFalse;
+	//
+	//	Empty BufferItemList if any
+	//
+		iContactsBufferItemList.ResetAndDestroy();
+		iItemData = NULL;
+		}
+
+	_DBG_FILE("CNSmlContactsDataStore::DoCancelBatch(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoSetRemoteStoreFormatL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteStoreFormatL(): begin");
+	
+	TBool foundMime = EFalse;
+	
+	//
+	// KErrNotSupported is returned if server does not support same mime type 
+	// and same mime type version as Data Provider.
+	
+	TInt i=0;
+	while( i< aServerDataStoreFormat.MimeFormatCount() && !foundMime )
+		{
+		if( iUsedMimeType.MatchF(aServerDataStoreFormat.MimeFormat(i).MimeType().DesC())      ==0 &&
+		    iUsedMimeVersion.MatchF(aServerDataStoreFormat.MimeFormat(i).MimeVersion().DesC())==0 )
+			{
+			foundMime = ETrue;
+			iServerMimeType    = aServerDataStoreFormat.MimeFormat(i).MimeType();
+			iServerMimeVersion = aServerDataStoreFormat.MimeFormat(i).MimeVersion();
+			}
+		i++;
+		}
+		
+	if( !foundMime )
+		{
+		_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteStoreFormatL(): SERVER MIMETYPE NOTSUPPORTED end");
+		User::Leave( KErrNotSupported );
+		}
+		
+	iDataMod->SetPartnerStoreFormat( (CSmlDataStoreFormat&) aServerDataStoreFormat );
+	
+	SetOwnStoreFormatL();
+			
+	TInt error = iDataMod->SetUsedMimeType( iServerMimeType, iServerMimeVersion );
+	
+	User::LeaveIfError( error );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteStoreFormatL(): end");
+	return;
+	}
+	
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::SetOwnStoreFormatL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::SetOwnStoreFormatL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): begin");
+	
+	if( !iStoreFormat )
+		{
+		TFileName fileName;
+		TParse parse;
+
+		// Check correct Data Sync protocol
+        TInt value( EDataSyncNotRunning );
+        TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                     KDataSyncStatus,
+                                     value );
+        if ( error == KErrNone &&
+             value == EDataSyncRunning )
+            {
+            parse.Set( KNSmlContactsStoreFormatRsc_1_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
+            }
+        else // error or protocol version 1.2 
+            {
+            parse.Set( KNSmlContactsStoreFormatRsc_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
+            }		
+
+		fileName = parse.FullName();
+
+		RResourceFile resourceFile; 
+		BaflUtils::NearestLanguageFile( iRfs, fileName );
+
+		resourceFile.OpenL( iRfs, fileName );
+		CleanupClosePushL( resourceFile );
+		
+		HBufC8* contactsDataFormat = resourceFile.AllocReadLC( NSML_CONTACTS_DATA_STORE_FORMAT );
+
+		TResourceReader reader;
+		reader.SetBuffer( contactsDataFormat );
+
+		iStoreFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+		CleanupStack::Pop(iStoreFormat); // iStoreFormat
+		
+		CleanupStack::PopAndDestroy(2); // contactsDataFormat, resourceFile  
+		}
+		
+	iDataMod->SetOwnStoreFormat( *iStoreFormat );
+	
+	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): end");
+	return;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteMaxObjectSize(): begin");
+	
+	iServerMaxObjectSize = aServerMaxObjectSize;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteMaxObjectSize(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoMaxObjectSize()
+// ----------------------------------------------------------------------------
+TInt CNSmlContactsDataStore::DoMaxObjectSize() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize(): begin");
+	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize() 100 k: end");
+	return KNSmlDataStoreMaxSize;  // 100 k
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoOpenItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoOpenItemL( TSmlDbItemUid aUid, 
+										  TBool& aFieldChange, 
+										  TInt& aSize, 
+										  TSmlDbItemUid& aParent, 
+										  TDes8& aMimeType, 
+										  TDes8& aMimeVer, 
+										  TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoOpenItemL(): begin");
+
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		return;
+		}
+		
+	iItemPos = 0;
+	
+	aFieldChange = EFalse; // Whole item sent NOT SUPPORT ON FIELDCHANGE
+	
+	aMimeType    = iStoreFormat->MimeFormat( 0 ).MimeType().DesC();
+	aMimeVer	 = iStoreFormat->MimeFormat( 0 ).MimeVersion().DesC();
+	aParent      = KNullDataItemId;
+	
+	iModType = ENSmlCntItemRead;
+	
+	if( !iItemData )
+		{
+		iItemData= CBufFlat::NewL( KNSmlItemDataExpandSize );
+		}
+	else
+		{
+		iItemData->Reset();
+		}
+	
+	 LdoFetchItemL( aUid, *iItemData );
+	 iSize = &aSize;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoOpenItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCreateItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCreateItemL( TSmlDbItemUid& aUid, 
+											TInt aSize, 
+											TSmlDbItemUid /*aParent*/, 
+											const TDesC8& aMimeType, 
+											const TDesC8& aMimeVer, 
+											TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL(): begin");
+
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	TInt err = KErrNone;
+	
+	if ( iState != ENSmlOpenAndWaiting )
+		{
+		User::RequestComplete( iCallerStatus, KErrNotReady );
+		_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL - KErrNotReady: END");
+		return;
+		}
+		
+	iItemSize = aSize; // Size sent from server
+	iModType  = ENSmlCntItemAdd;
+	
+	iMimeTypeItem.Set( aMimeType );
+	iMimeVersionItem.Set( aMimeVer );
+	
+	if ( iItemPos == -1 || !iBatchMode )
+		{
+		iItemPos = 0;
+		}
+	
+	
+	if( iItemData )
+		{
+		iItemData->Reset();
+		}
+		
+	if( !iItemDataAddBatch )
+		{
+		iItemDataAddBatch= CBufFlat::NewL( KNSmlItemDataExpandSize );
+		}
+		
+	// Check MimeType and MimeVersion
+	if( ( aMimeType.MatchF( KNSmlvCard21Name ) < 0 ) &&
+	    ( aMimeType.MatchF( KNSmlvCard30Name ) < 0 ))
+		{
+		User::RequestComplete( iCallerStatus, KErrNotSupported );
+		_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL - KErrNotSupported: END");
+		return;
+		}
+    
+    // Is there enough space on drive 
+	if( DriveBelowCriticalLevelL( aSize ) )
+		{
+		err = KErrDiskFull;
+		}
+				
+	iItemData = AddBufferListL( aUid,aSize, err );
+	
+	if( iBatchMode )
+		{
+		iState = ENSmlItemCreating;
+		User::RequestComplete( iCallerStatus, KErrNone );
+		_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL(): begin BATCH");
+		return ; // Put into buffer
+		}
+				
+	if ( err == KErrNone )
+		{
+		iState = ENSmlItemCreating;
+		}
+	
+	User::RequestComplete( iCallerStatus, err );
+
+	_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoReplaceItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoReplaceItemL( TSmlDbItemUid aUid, 
+											 TInt aSize, 
+											 TSmlDbItemUid /*aParent*/,
+											 TBool aFieldChange, 
+											 TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoReplaceItemL(): begin");
+
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	TInt err = KErrNone;
+			
+	iUid      = aUid;
+	iItemSize = aSize;
+	iModType  = ENSmlCntItemReplace;
+	
+	if ( iItemPos == -1 || !iBatchMode )
+		{
+		iItemPos = 0;
+		}
+	
+	if ( iItemData )
+		{
+		iItemData->Reset();
+		}
+		
+	// Field change not supported
+	if( aFieldChange )
+		{
+		err = KErrNotSupported;
+		if( !iBatchMode )
+			{
+			User::RequestComplete( iCallerStatus, err );
+			return;
+			}
+		}
+		
+	iItemData = AddBufferListL( aUid, aSize, err );
+	
+	if( iBatchMode )
+		{
+		iState = ENSmlItemUpdating;
+		_DBG_FILE("CNSmlContactsDataStore::DoReplaceItemL(): BATCHMODE end");
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;
+		}
+	if ( err == KErrNone )
+	    {
+	    iState = ENSmlItemUpdating;
+	    }
+	
+	User::RequestComplete( iCallerStatus, err );
+		
+	_DBG_FILE("CNSmlContactsDataStore::DoReplaceItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoReadItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoReadItemL( TDes8& aBuffer )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoReadItemL(): begin");
+
+    if ( iState != ENSmlItemOpen || !iItemData )
+        {
+        iItemPos = -1;
+        User::Leave( KErrNotReady );
+        }
+
+    if ( iItemPos == -1 )
+        {
+        User::Leave( KErrEof );
+        }
+
+    if ( aBuffer.Size() < iItemData->Size() - iItemPos )
+        {
+        iItemData->Read( iItemPos, aBuffer );
+        iItemPos += aBuffer.Size();
+        }
+    else
+        {
+        iItemData->Read( iItemPos, aBuffer, iItemData->Size() - iItemPos );
+        iItemPos = -1;
+        }
+
+	_DBG_FILE("CNSmlContactsDataStore::DoReadItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoWriteItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoWriteItemL( const TDesC8& aData )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): begin");
+
+	/* Data must be accumulated from pieces of information */
+	if ( iState == ENSmlItemCreating || iState == ENSmlItemUpdating )
+		{
+		if ( iItemData )
+			{
+			if ( iItemPos == -1 )
+				{
+            	iStateItem = KErrEof;
+            	if( iBatchMode )
+            		{
+            		return;
+            		}
+				User::Leave( KErrEof );
+				}
+			iItemData->InsertL( iItemData->Size(), aData );
+			iItemPos += aData.Size();
+			
+			if ( aData.Size() > iItemSize )
+				{
+				iState =     ENSmlItemOverflow;
+            	iStateItem = KErrOverflow;
+            	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): KErrOverflow End");
+        		DBG_ARGS(_S("CNSmlContactsDataStore::DoWriteItemL(): Server sent=(%d) Item=(%d)"),
+        		            iItemSize, aData.Size()); 
+            	if( iBatchMode )
+            		{
+            		return;
+            		}
+				User::Leave( KErrOverflow );				
+				}
+			if ( aData.Size() == iItemSize )
+			    {
+            	iStateItem = KErrNone;
+			    }
+			return;
+			}
+		}
+		
+	iStateItem = KErrNotReady;
+
+	if( iBatchMode )
+		{
+       	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): KErrNotReady End");
+		return;
+		}
+		
+	User::Leave( KErrNotReady );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCommitItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCommitItemL( TRequestStatus& aStatus )
+	{
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitItemL(): begin");
+		
+	// Data OK => insert to total buffer
+	if (iModType   == ENSmlCntItemAdd && 
+      	iStateItem == KErrNone )
+	    {
+	    iItemDataAddBatch->InsertL( iItemDataAddBatch->Size(),iItemData->Ptr(0), iItemData->Size() );
+	    iItemDataAddBatch->InsertL( iItemDataAddBatch->Size(), KVersitTokenCRLF() );
+      	if( iContactsBufferItemList.Count() > 0 )
+      	    {
+            iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = KNSmlNoError; 
+      	    }
+	    }
+	 else if ((iModType   == ENSmlCntItemAdd ||         // If some write problems
+      	       iModType   == ENSmlCntItemReplace) && 
+      	       iStateItem != KErrNone &&
+      	       iContactsBufferItemList.Count() > 0) 
+	    {
+        iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = iStateItem; 
+	    }
+
+	if( iBatchMode )
+		{
+		iItemData = NULL;
+		iState = ENSmlOpenAndWaiting;
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;
+		}
+		
+
+	iIndex = 0;
+	ExecuteBufferL();
+	
+	iItemData = NULL;
+	iState = ENSmlOpenAndWaiting;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCloseItem()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCloseItem()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCloseItem(): begin");
+
+	if ( iState == ENSmlItemOpen )
+		{
+		iItemPos = -1;
+		if ( iItemData )
+			{
+			delete iItemData;
+			iItemData = NULL;
+			}
+		iState = ENSmlOpenAndWaiting;
+		}
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCloseItem(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoMoveItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid /*aNewParent*/, TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoMoveItemL(): begin");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( iBatchMode )
+		{
+		iModType = ENSmlCntItemMove;
+		TInt fSize = 0;
+		AddBufferListL( aUid, fSize, KErrNotSupported );	
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;
+		}
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoMoveItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoDeleteItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoDeleteItemL(): begin");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+		
+	if( iBatchMode )
+		{
+		if(iContactViewBase ==NULL)
+		{
+		CreateViewL();	
+		}
+	if( iModType != ENSmlCntItemSoftDelete ) // Treated like deletes
+		{
+		iModType  = ENSmlCntItemDelete;	
+		}
+			
+	TInt fSize = 0;
+	AddBufferListL( aUid, fSize, KErrNone );
+	User::RequestComplete( iCallerStatus, KErrNone );
+	return;
+	}
+	iUid = aUid;
+	
+	//add the contactlink to CVPbkContactLinkArray
+	MVPbkContactLink* contactLink  = iIdConverter->IdentifierToLinkLC(aUid);
+	CleanupStack::Pop();
+	CVPbkContactLinkArray* contactLnks = CVPbkContactLinkArray::NewLC();
+	contactLnks->AppendL( contactLink );
+	
+ 	iContactManager->DeleteContactsL( *contactLnks, *this );
+	CleanupStack::PopAndDestroy(); 
+	iLastOperation = ENSmlDeleteOp;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoDeleteItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoSoftDeleteItemL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeleteItemL(): begin");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	User::RequestComplete( iCallerStatus, KErrNotSupported );
+	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeleteItemL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoDeleteAllItemsL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoDeleteAllItemsL(): begin");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	//create view to get all the contactlinks to delete
+	if(iContactViewBase ==NULL)
+		{
+		CreateViewL();	
+		}
+		
+	iLastOperation = ENSMLDeleteAllOp;
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoDeleteAllItemsL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// TBool CNSmlContactsDataStore::DoHasSyncHistory()
+// ----------------------------------------------------------------------------
+TBool CNSmlContactsDataStore::DoHasSyncHistory() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoHasSyncHistory(): begin");
+	
+	TBool doHasSyncHistory = EFalse;
+	
+	if( !iOpened ) 
+		{
+		_DBG_FILE("CNSmlContactsDataStore::DoHasSyncHistory(): NOT OPEN end");
+		return doHasSyncHistory;
+		}
+	
+	if( iSyncHistory )
+		{
+		if ( iOpenedStoreId != iChangeFinder->DataStoreUid() )
+			{
+			iChangeFinder->SetDataStoreUid( iOpenedStoreId );
+			doHasSyncHistory = EFalse;
+			}
+		else
+			{
+			doHasSyncHistory = ETrue;
+			}
+		}
+	else
+		{
+		iChangeFinder->SetDataStoreUid( iOpenedStoreId );
+		}
+		
+	_DBG_FILE("CNSmlContactsDataStore::DoHasSyncHistory(): end");
+	return doHasSyncHistory;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoAddedItems()
+// ----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CNSmlContactsDataStore::DoAddedItems() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoAddedItems(): begin");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iNewUids->Reset();
+		
+		if( iChangeFinder )
+			{
+			TRAPD( err,iChangeFinder->FindNewItemsL( *iNewUids ) );
+			if( err != KErrNone )
+				{
+				_DBG_FILE("CNSmlContactsDataStore::DoAddedItems(): LEAVE end");				
+				}
+			}
+		}	
+	_DBG_FILE("CNSmlContactsDataStore::DoAddedItems(): end");
+
+	return *iNewUids;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoDeletedItems()
+// ----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CNSmlContactsDataStore::DoDeletedItems() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoDeletedItems(): begin");	
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iDeletedUids->Reset();
+		
+		if( iChangeFinder )
+			{
+			TRAPD(err,iChangeFinder->FindDeletedItemsL( *iDeletedUids ) );
+			if( err != KErrNone )
+				{
+				_DBG_FILE("CNSmlContactsDataStore::DoDeletedItems(): LEAVE end");				
+				}
+			}
+		}
+	_DBG_FILE("CNSmlContactsDataStore::DoDeletedItems(): end");
+
+	return *iDeletedUids;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoSoftDeletedItems()
+// ----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CNSmlContactsDataStore::DoSoftDeletedItems() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeletedItems(): begin");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iSoftDeletedUids->Reset();
+		
+		if( iChangeFinder )
+			{
+			TRAPD( err, iChangeFinder->FindSoftDeletedItemsL( *iSoftDeletedUids ) );
+			if( err != KErrNone )
+				{
+				_DBG_FILE("CNSmlContactsDataStore::DoSoftDeletedItems(): LEAVE end");				
+				}
+			}
+		}
+	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeletedItems: END");
+	
+	return *iSoftDeletedUids;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoModifiedItems()
+// ----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CNSmlContactsDataStore::DoModifiedItems() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoModifiedItems(): begin");
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iReplacedUids->Reset();
+		
+		if( iChangeFinder )
+			{
+			TRAPD( err, iChangeFinder->FindChangedItemsL( *iReplacedUids ) );
+			if( err != KErrNone )
+				{
+				_DBG_FILE("CNSmlContactsDataStore::DoModifiedItems(): LEAVE end");				
+				}
+			}
+		}
+	_DBG_FILE("CNSmlContactsDataStore::DoModifiedItems: END");
+	
+	return *iReplacedUids;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoMovedItems()
+// ----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CNSmlContactsDataStore::DoMovedItems() const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoMovedItems(): begin");
+	
+	if ( iState == ENSmlOpenAndWaiting )
+		{
+		iMovedUids->Reset();
+		
+		if( iChangeFinder )
+			{
+			TRAPD( err, iChangeFinder->FindMovedItemsL( *iMovedUids ) );	
+			if( err != KErrNone )
+				{
+				_DBG_FILE("CNSmlContactsDataStore::DoMovedItems(): LEAVE end");				
+				}
+			}
+		}
+	_DBG_FILE("CNSmlContactsDataStore::DoMovedItems: END");
+	
+	return *iMovedUids;
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoResetChangeInfoL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoResetChangeInfoL(): begin");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( iChangeFinder )
+		{
+		iChangeFinder->ResetL();
+		}
+		
+	iSnapshotRegistered = EFalse;
+	
+		if ( iContactsModsFetcher )
+		{
+		iContactsModsFetcher->FetchModificationsL( aStatus );
+#ifdef __NSML_MODULETEST__
+		CActiveScheduler::Start();
+#endif
+		}
+	else
+		{
+		User::RequestComplete( iCallerStatus, KErrNone );
+		}
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoResetChangeInfoL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCommitChangeInfoL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus, 
+												  const MSmlDataItemUidSet& aItems )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(aItems): begin");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( iChangeFinder )
+		{
+		iChangeFinder->CommitChangesL( aItems );
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;
+		}
+		
+	User::RequestComplete( iCallerStatus, KErrNotReady );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(aItems): end");
+	}
+
+// ----------------------------------------------------------------------------
+// void CNSmlContactsDataStore::DoCommitChangeInfoL()
+// ----------------------------------------------------------------------------
+void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(): begin");
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if( iChangeFinder )
+		{
+		iChangeFinder->CommitChangesL();
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;
+		}
+	
+	User::RequestComplete( iCallerStatus, KErrNotReady );
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
+// ----------------------------------------------------------------------------
+CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::DoListStoresLC(): begin");
+	
+	MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
+	CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(storeList.Count());
+	CleanupStack::PushL( stores );
+	
+  TBuf<KVPbhkPrefixLength> phoneDataBasePrefix(KVPbhkSymbianDBPrefix);
+	
+	for(TInt i=0 ; i< storeList.Count(); i++)
+	{
+	    TBuf<KNSmlDefaultStoreNameMaxSize>  currentStore(storeList.At(i).StoreProperties().Uri().UriDes());	    	   
+	    
+	    if(currentStore.Find(phoneDataBasePrefix) == 0)//Check if Symbian Database
+	    {	    
+	    		//For backward compatability with local and remote servers
+        	    //The Symbian Db name remains unchanged	   
+        	    //The engine methods that create syncml packet, use this information in Database fields
+	            stores->AppendL(*iPacketStoreName);
+	    }
+	    else//End Symbian Database check
+	    {
+		     stores->AppendL(storeList.At(i).StoreProperties().Uri().UriDes());
+	    }
+	}
+	
+	_DBG_FILE("CNSmlContactsDataStore::DoListStoresLC(): end");
+
+	return stores;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::LdoFetchItemL(): begin");
+	
+	 iWriteStream.Open(aItem);
+		
+	 MVPbkContactLink* contactLink  = iIdConverter->IdentifierToLinkLC(aUid);
+	 iVCardEngine->ExportVCardForSyncL(iWriteStream,*contactLink,*this);
+	 CleanupStack::PopAndDestroy();
+	 
+	 iLastOperation = ENSMLFetchOp;
+	
+	_DBG_FILE("CNSmlContactsDataStore::LdoFetchItemL(): end");
+
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlContactsDataStore::LdoAddItemL( TSmlDbItemUid& aUid,
+//                                           const TDesC8& aItem,
+//                                           TInt aSize,
+//                                           TTime& aLastModified,
+//                                           TBool& aConfidential )
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::LdoAddItemL( const TDesC8& aItem,
+                                          TInt aSize)
+	{
+	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
+
+	if( !iOpened )
+		{
+		User::Leave( KErrNotReady );
+		}
+		
+	// Is there enough space on drive 
+	if( DriveBelowCriticalLevelL( aSize ) )
+		{
+		User::Leave( KErrDiskFull );
+		}
+
+	 iBuf = aItem.AllocLC();
+	StripPropertyL( iBuf, KVersitTokenUID() );
+
+	 iReadStream.Open( *iBuf );
+	// import a vcard without checking for duplicates
+	iVCardEngine->ImportVCardForSyncL(*iStore,iReadStream,*this);
+	iLastOperation = ENSmlAddOp;
+	CleanupStack::Pop(iBuf);
+
+	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): end");
+	
+	}
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
+//                                           TInt aSize)
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
+                                          TInt aSize)
+	{
+	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
+
+	if( !iOpened )
+		{
+		User::Leave( KErrNotReady );
+		}
+		
+	// Is there enough space on drive 
+	if( DriveBelowCriticalLevelL( aSize ) )
+		{
+		User::Leave( KErrDiskFull );
+		}
+
+	iReadStream.Open( aItems->Ptr(0) );
+	 // import vcards without checking for duplicates
+	iVCardEngine->ImportVCardForSyncL(*iStore,iReadStream,*this);
+	iLastOperation = ENSmlAddOp;
+	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): end");
+	
+	}
+		
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlContactsDataStore::LdoUpdateItemL(TSmlDbItemUid aUid,
+//                                             const TDesC8& aItem,
+//                                             TInt aSize,
+//                                             TTime& aLastModified )
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::LdoUpdateItemL()
+	{
+	_DBG_FILE("CNSmlContactsDataStore::LdoUpdateItemL(): begin");
+	
+	iBuf = iContactsBufferItemList[iIndex]->iItemData->Ptr(0).AllocLC();
+	// Remove UID's from data
+	StripPropertyL( iBuf, KVersitTokenUID() );
+
+	iReadStream.Open( *iBuf );
+	MVPbkContactLink* contactLink = iIdConverter->IdentifierToLinkLC(iUid);
+	  iVCardEngine->ImportVCardMergeL(*contactLink,*iStore,iReadStream,*this);
+
+	CleanupStack::Pop();
+	iLastOperation = ENSMLUpdateImportOp;
+	CleanupStack::Pop(iBuf);
+	
+	_DBG_FILE("CNSmlContactsDataStore::LdoUpdateItemL(): end");
+
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsDataStore::DriveBelowCriticalLevelL()
+// ------------------------------------------------------------------------------------------------
+TBool CNSmlContactsDataStore::DriveBelowCriticalLevelL( TInt aSize )
+	{
+	return SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, iDrive );
+	}
+
+// ----------------------------------------------------------------------------
+// CBufBase* CNSmlContactsDataStore::AddBufferListL()
+// ----------------------------------------------------------------------------
+CBufBase* CNSmlContactsDataStore::AddBufferListL( TSmlDbItemUid& aUid, TInt aSize, TInt aStatus )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::AddBufferListL(): begin");
+	
+	CNSmlContactsBufferItem* newBufferItem = new (ELeave) CNSmlContactsBufferItem;
+	CleanupStack::PushL( newBufferItem );
+	
+	if( iModType == ENSmlCntItemAdd )
+		{
+		newBufferItem->iPUid     = &aUid;
+		newBufferItem->iItemData = CBufFlat::NewL( KNSmlItemDataExpandSize );
+    	newBufferItem->iStatus   = KErrGeneral; // Default for add
+		}
+	else
+		{
+		newBufferItem->iPUid = &aUid;
+		newBufferItem->iUid = aUid;		
+		newBufferItem->iItemData = CBufFlat::NewL( KNSmlItemDataExpandSize );
+    	newBufferItem->iStatus = KNSmlNoError; // Default if not handled
+		}		
+	
+	newBufferItem->iModType = iModType;
+	newBufferItem->iMimeType = iMimeTypeItem.AllocL();
+	newBufferItem->iMimeVersion = iMimeVersionItem.AllocL();
+	newBufferItem->iSize = aSize;
+	
+	if( aStatus != KErrNone )
+		{
+		newBufferItem->iStatus  = aStatus;
+		}
+		
+	iContactsBufferItemList.AppendL( newBufferItem );
+	
+	iMimeTypeItem.Set( KNullDesC8 ); 
+	iMimeVersionItem.Set( KNullDesC8 );
+	
+	
+	CleanupStack::Pop();	
+	
+	if( iModType == ENSmlCntItemAdd && 
+	    aStatus  == KErrNotSupported )
+		{
+		iStateItem = KErrNotSupported;
+		}
+		
+	_DBG_FILE("CNSmlContactsDataStore::AddBufferListL(): end");
+
+	return newBufferItem->iItemData;
+
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty )
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty ) const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
+
+	if( !aItem )
+		{
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): NULL pointer");
+		return;
+		}
+
+	TPtr8 hItemPtr( aItem->Des() );
+	HBufC8* propBuf = HBufC8::NewLC( aProperty.Length() + 2 );
+	TPtr8 propPtr( propBuf->Des() );
+
+	propPtr.Append( KVersitTokenCRLF() );
+	propPtr.Append( aProperty );
+	TInt propPos = hItemPtr.Find( propPtr );
+	if( propPos != KErrNotFound )
+		{
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): property found in item data -> removing it");
+		_DBG_FILE( aProperty.Ptr() );
+		TPtrC8 propPosPtr( hItemPtr.Mid( propPos + KVersitTokenCRLF().Length() ) );
+		TInt propEndPos = propPosPtr.Find( KVersitTokenCRLF() );
+		hItemPtr.Delete( propPos, propEndPos + KVersitTokenCRLF().Length() );
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): property removed");
+		}
+	CleanupStack::PopAndDestroy(); // propBuf
+	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): end");
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty )
+// ------------------------------------------------------------------------------------------------
+void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty ) const
+	{
+	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
+	
+	if( !aItem )
+		{
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): NULL pointer");
+		return;
+		}
+		
+	HBufC8* propBuf = HBufC8::NewLC( aProperty.Length() + 2 );
+	TPtr8 propPtr( propBuf->Des() );
+	propPtr.Append( KVersitTokenCRLF() );
+	propPtr.Append( aProperty );
+	TInt propPos = aItem->Ptr(0).Find( propPtr );
+	
+	while( propPos != KErrNotFound )
+		{
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): property found in item data -> removing it");
+		_DBG_FILE( aProperty.Ptr() );
+		TInt propEndPos = aItem->Ptr( propPos + KVersitTokenCRLF().Length()).Find(KVersitTokenCRLF() );
+		if( propEndPos != KErrNotFound )
+			{
+			aItem->Delete( propPos + KVersitTokenCRLF().Length(), propEndPos );		
+			}
+		
+		propPos = aItem->Ptr(0).Find( propPtr );
+		_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): property removed");
+		}
+	CleanupStack::PopAndDestroy(); // propBuf
+	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): end");
+	}
+	
+// ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::IsConfidentialL
+// ----------------------------------------------------------------------------
+//	
+TBool CNSmlContactsDataStore::IsConfidentialL(  MVPbkStoreContact& aItem )
+    {
+    _DBG_FILE("CNSmlContactsDataStore::IsConfidentialL(): begin");
+    TBool ret( EFalse );
+    
+    //find X-CLASS field type
+	const MVPbkFieldType* syncclass = 
+        iContactManager->FieldTypes().Find(R_VPBK_FIELD_TYPE_SYNCCLASS );
+	CVPbkBaseContactFieldTypeIterator* itr = 
+        CVPbkBaseContactFieldTypeIterator::NewLC( *syncclass, 
+            aItem.Fields() );
+	while ( itr->HasNext() )
+        {
+        const MVPbkBaseContactField* field = itr->Next();
+        const MVPbkContactFieldTextData& data = MVPbkContactFieldTextData::Cast(field->FieldData());
+        TPtrC ptr = data.Text();
+        //compare the sync type
+        if ( ptr.Compare( KNSmlContactSyncNoSync ) == 0 )
+            {
+            _DBG_FILE("CNSmlContactsModsFetcher::IsConfidentialL(): \
+                       find confidential");
+            ret = ETrue;
+            }
+         
+        }
+	CleanupStack::PopAndDestroy( itr );
+    
+    _DBG_FILE("CNSmlContactsDataStore::IsConfidentialL(): end");
+    return ret;
+    }
+    
+ // ----------------------------------------------------------------------------
+// CNSmlContactsDataStore::ResetBuffer
+// ----------------------------------------------------------------------------
+//	
+void CNSmlContactsDataStore:: ResetBuffer()
+	{
+	if( iItemDataAddBatch )
+		{
+		iItemDataAddBatch->Reset();
+		}
+	iContactsBufferItemList.ResetAndDestroy();
+	}
+// -----------------------------------------------------------------------------
+// From MVPbkContactStoreListObserver  
+// Called when a contact store is ready to use.
+// -----------------------------------------------------------------------------
+ 
+void CNSmlContactsDataStore::StoreReady( MVPbkContactStore& /*aContactStore*/ )
+	{
+	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): begin");
+	//The contact data base opened successfully
+	iOpened = ETrue;
+	//id to uniquely identify the opened store 
+	iOpenedStoreId = DefaultHash::Des16(
+						iStore->StoreProperties().Uri().UriDes());
+	
+	TRAPD(error,iContactsModsFetcher->FetchModificationsL( *iCallerStatus ));
+	if(error != KErrNone)
+		{
+		User::RequestComplete( iCallerStatus, error );
+		}
+	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): end");
+	}
+
+
+// ---------------------------------------------------------------------------
+//  From MVPbkContactStoreListObserver  
+//	Called when a contact store becomes unavailable.
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsDataStore::StoreUnavailable(
+        MVPbkContactStore& /*aContactStore*/,
+        TInt aReason )
+    {
+    _DBG_FILE("CNSmlContactsDataStore::StoreUnavailable(): begin");
+
+    //Unable open the default contact data base
+	iOpened = EFalse;
+	delete iStoreName;
+	iStoreName = NULL;
+	iOpenedStoreId = 0;
+	User::RequestComplete( iCallerStatus, aReason );
+	_DBG_FILE("CNSmlContactsDataStore::StoreUnavailable(): end");		
+	return;
+	
+    }
+
+// ---------------------------------------------------------------------------
+// From MVPbkContactStoreListObserver  
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsDataStore::HandleStoreEventL(
+        MVPbkContactStore& /*aContactStore*/,
+        TVPbkContactStoreEvent /*aStoreEvent*/ )
+	{
+	//Indication not needed.
+	}
+    
+// ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::VPbkSingleContactOperationComplete
+// ---------------------------------------------------------------------------
+//
+    
+ void CNSmlContactsDataStore::VPbkSingleContactOperationComplete(
+		MVPbkContactOperationBase& aOperation,
+		MVPbkStoreContact* aContact )
+	{
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+	TRAPD(error ,SingleContactOperationCompleteL(aContact));
+	delete aContact;
+	if(error!= KErrNone)
+		{
+			User::RequestComplete( iCallerStatus, error );
+		}
+	}
+
+// ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsDataStore::VPbkSingleContactOperationFailed(
+		MVPbkContactOperationBase& aOperation,
+		 TInt aError )
+	 {
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+	 if(iLastOperation == ENSMLFetchOp)
+		 {
+	 	iWriteStream.Close();
+	 	User::RequestComplete( iCallerStatus, aError );
+		 }
+		else if(iLastOperation == ENSmlRetrieveOp)
+		 {
+		 	User::RequestComplete( iCallerStatus, aError );
+		 }
+	 }
+ // ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
+// ---------------------------------------------------------------------------
+//
+ void CNSmlContactsDataStore::SingleContactOperationCompleteL(
+ 		MVPbkStoreContact* aContact)
+	{
+	if(iLastOperation == ENSMLFetchOp)
+		{
+		iWriteStream.Close();
+
+		iItemData->Compress();
+		//strip the fields not supported by server
+		iDataMod->StripTxL( *iItemData );
+		*iSize = iItemData->Size();
+		iState = ENSmlItemOpen;
+		if ( iServerMaxObjectSize == 0 || *iSize <= iServerMaxObjectSize )
+			{
+			User::RequestComplete( iCallerStatus, KErrNone );
+			}
+		else
+			{
+			User::RequestComplete( iCallerStatus, KErrTooBig );
+			}
+		}
+	else if (iLastOperation == ENSMLUpdateExportOp)
+		{
+		iDataMod->MergeRxL( *iContactsBufferItemList[iIndex]->iItemData, *iMergeItem );
+		iWriteStream.Close();
+		delete iMergeItem;
+		iMergeItem = NULL;
+		LdoUpdateItemL();
+		}
+	else if (iLastOperation == ENSMLUpdateImportOp)
+		{
+		if(!IsConfidentialL(*aContact))
+			{
+			TInt32 id = iIdConverter->LinkToIdentifier(*aContact->CreateLinkLC());
+			
+			TNSmlSnapshotItem item(id);
+			
+			MVPbkStoreContact2* tempContact = 
+					reinterpret_cast<MVPbkStoreContact2*> (aContact->StoreContactExtension (KMVPbkStoreContactExtension2Uid));
+       		
+			MVPbkStoreContactProperties *contactProterties 
+										= tempContact ->PropertiesL();;
+			CleanupDeletePushL(contactProterties);				
+			item.SetLastChangedDate(contactProterties->LastModifiedL());
+			CleanupStack::PopAndDestroy();
+			
+			item.SetSoftDelete( EFalse );
+			
+			TRAP_IGNORE(iChangeFinder->ItemUpdatedL( item ));
+			
+			CleanupStack::PopAndDestroy();
+			if(iBatchMode)
+				{
+				iResultArray->Append(KErrNone);	
+				}
+			
+			
+			delete iBuf;
+			iBuf = NULL;
+			iReadStream.Close();
+			
+			
+			iIndex++;
+			if(iIndex == iContactsBufferItemList.Count() )
+				{
+				ResetBuffer();
+				User::RequestComplete( iCallerStatus, iRetCommand );	
+				}
+			else
+				{
+					ExecuteBufferL();
+				}
+			}
+		
+		}
+	else if(iLastOperation == ENSmlRetrieveOp)
+		{
+		iRetrieveCount--;	
+		if(!IsConfidentialL(*aContact))
+			{
+			TInt32 id = iIdConverter->LinkToIdentifier(*aContact->CreateLinkLC());
+			*iContactsBufferItemList[iIndex]->iPUid = id;
+			
+			TNSmlSnapshotItem item(id);
+			
+       		MVPbkStoreContact2* tempContact = 
+       		    reinterpret_cast<MVPbkStoreContact2*> (aContact->StoreContactExtension (KMVPbkStoreContactExtension2Uid));  
+       		       			
+			MVPbkStoreContactProperties *contactProterties 
+										= tempContact ->PropertiesL();;
+			CleanupDeletePushL(contactProterties);				
+			item.SetLastChangedDate(contactProterties->LastModifiedL());
+			CleanupStack::PopAndDestroy();
+			
+			item.SetSoftDelete( EFalse );
+			// Add the snapshot item to the Change Finder.
+			TRAP_IGNORE(iChangeFinder->ItemAddedL( item ));
+			
+			CleanupStack::PopAndDestroy();
+			}
+			if(iBatchMode)
+			{
+			iResultArray->AppendL(iRetCommand);	
+			}
+			
+			iIndex++;
+			if(iIndex == iContactsBufferItemList.Count() )
+				{
+				ResetBuffer();
+				User::RequestComplete( iCallerStatus, iRetCommand );	
+				}
+			else if(!iRetrieveCount)
+				{
+					ExecuteBufferL();
+				}
+			
+			}
+ }
+ // ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::ContactsSaved.
+// ---------------------------------------------------------------------------
+//
+ void CNSmlContactsDataStore::ContactsSaved( 
+		MVPbkContactOperationBase& aOperation,
+        MVPbkContactLinkArray* aResults ) 
+	{
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+
+	if(iLastOperation == ENSmlAddOp)
+		{
+		//Count of contacts to be added from server to client 
+		TInt  cntAddCount( 0 );
+		TInt i(iIndex);
+		while( i<iContactsBufferItemList.Count() )
+			{
+			if ( iContactsBufferItemList[i]->iModType == ENSmlCntItemAdd &&
+			     iContactsBufferItemList[i]->iStatus  == KNSmlNoError )
+				{
+				cntAddCount++;
+				}
+			i++;
+			}
+		
+		//Count of contacts successfully added to client	
+		iRetrieveCount = aResults->Count();
+		
+		//Count of contacts which could not be added
+		TInt cntAddFailedCount(0);
+		cntAddFailedCount = cntAddCount-iRetrieveCount;
+		while(cntAddFailedCount > 0)
+		{
+			iContactsBufferItemList[iIndex++]->iStatus  = KErrGeneral;
+			iResultArray->Append(KErrGeneral);
+			cntAddFailedCount--;
+		}
+		
+		if ( aResults->Count() > 0 )
+			{
+			for(TInt i=0;i<aResults->Count();i++)
+				{
+				//retrieve the contact
+				TRAPD(error,iContactManager->RetrieveContactL( aResults->At(i), *this ));
+				if(error != KErrNone)
+					{
+					User::RequestComplete( iCallerStatus, error );	
+					}
+			iLastOperation = ENSmlRetrieveOp;				 	
+				}
+			}
+		delete iBuf;
+		delete aResults;
+		iBuf = NULL;
+		iReadStream.Close();	
+		}
+	
+	}
+        
+ // ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::ContactsSavingFailed
+// ---------------------------------------------------------------------------
+//       
+void CNSmlContactsDataStore::ContactsSavingFailed( 
+        MVPbkContactOperationBase& aOperation, TInt aError )
+	{
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+	
+	if(iLastOperation == ENSmlAddOp)
+	{
+	if(iBatchMode)
+		{
+		while( iIndex < iContactsBufferItemList.Count() &&
+		iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd )
+			{
+			iContactsBufferItemList[iIndex++]->iStatus  = KErrGeneral;
+			iResultArray->Append(KErrGeneral);
+			}	
+		}
+	else
+		{
+		iIndex++;			
+		}
+
+	if(iIndex == iContactsBufferItemList.Count())
+		{
+		User::RequestComplete( iCallerStatus, aError );
+		ResetBuffer();
+		delete iBuf;
+	 	iBuf = NULL;
+	 	iReadStream.Close();	
+		}
+		//Execute the remaining commands in batch
+		else
+		{
+			TRAPD(error,ExecuteBufferL());
+			if(error != KErrNone)
+			{
+			User::RequestComplete( iCallerStatus, error );	
+			}
+		}
+		}
+	}
+// ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::StepComplete
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsDataStore::StepComplete(
+		 MVPbkContactOperationBase& /*aOperation*/, 
+        TInt aStepSize )
+	{
+	if(iLastOperation == ENSmlDeleteOp)
+		{
+		if(iBatchMode)
+			{
+			for(TInt i = 0 ; i<aStepSize && iIndex < iContactsBufferItemList.Count() ;i++)
+				{
+				iResultArray->Append(KErrNone);
+				if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete &&
+			    iContactsBufferItemList[iIndex]->iStatus  == KNSmlNoError )
+					{
+					iContactsBufferItemList[iIndex]->iStatus  = KErrNone;
+					iUid  = iContactsBufferItemList[iIndex]->iUid;
+					iChangeFinder->ItemDeleted( TNSmlSnapshotItem( iUid ));
+					}						
+					else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemSoftDelete &&
+				   		 iContactsBufferItemList[iIndex]->iStatus  == KNSmlNoError )
+					{
+					
+					iContactsBufferItemList[iIndex]->iStatus  = KErrNone;
+					iUid  = iContactsBufferItemList[iIndex]->iUid;
+					TRAP_IGNORE(iChangeFinder->ItemSoftDeletedL( TNSmlSnapshotItem( iUid ) ));
+					}
+					iIndex++;
+				}
+			}
+			else
+			{
+			iChangeFinder->ItemDeleted( TNSmlSnapshotItem( iUid ) );	
+			User::RequestComplete( iCallerStatus, KErrNone );
+			}
+		}
+	}
+ // ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::StepFailed
+// ---------------------------------------------------------------------------
+//
+ TBool CNSmlContactsDataStore::StepFailed(
+        MVPbkContactOperationBase& /*aOperation*/,
+        TInt /*aStepSize*/,
+        TInt aError )
+ {
+ if(iLastOperation == ENSmlDeleteOp)
+	{
+	 	if(iBatchMode)
+	 	{
+			if( iIndex < iContactsBufferItemList.Count() &&
+			iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete )
+			{
+			iContactsBufferItemList[iIndex++]->iStatus  = KErrGeneral;
+			iResultArray->Append(KErrGeneral);
+			}
+		 	
+	 	}
+	 	else
+	 	{
+	 		User::RequestComplete( iCallerStatus, aError );	
+	 	}
+	}
+	return ETrue;
+ }
+// ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::OperationComplete
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsDataStore::OperationComplete
+		( MVPbkContactOperationBase& aOperation )
+	{
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+
+	TRAPD(error ,OperationCompleteL());	
+	if(error != KErrNone)
+		{
+		User::RequestComplete( iCallerStatus, error );
+		}
+	}
+
+// ---------------------------------------------------------------------------
+//  CNSmlContactsDataStore::OperationCompleteL
+// ---------------------------------------------------------------------------
+//
+
+void CNSmlContactsDataStore::OperationCompleteL()
+	{
+	if(iLastOperation == ENSmlDeleteOp)
+		{
+		if(iBatchMode )
+			{
+			if(iResultArray->Count() != iContactsBufferItemList.Count())
+				{
+				while( iIndex < iContactsBufferItemList.Count() && 
+				iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete 
+				&& iContactsBufferItemList[iIndex]->iStatus  == KErrNotFound )
+					{
+					iResultArray->Append(KErrNotFound);
+					iIndex++;
+					}
+				}
+			
+			if(iIndex == iContactsBufferItemList.Count())
+				{
+				if(iItemData)
+					{
+					iItemData->Reset();    
+					}
+
+				ResetBuffer();
+				User::RequestComplete( iCallerStatus, KErrNone );
+				}
+				else
+				{
+				ExecuteBufferL();
+				}	
+			}
+			else
+			{
+			
+			if(iItemData)
+				{
+				iItemData->Reset();    
+				}
+
+			ResetBuffer();
+			}
+		}
+		else
+		{
+		if( iChangeFinder )
+			{
+			iChangeFinder->ResetL();		
+			}
+		iSnapshotRegistered = EFalse;
+		
+		delete iContactLnks;
+		iContactLnks = NULL;
+		iContactLink = NULL;
+		
+		delete iContactViewBase;
+		iContactViewBase = NULL;
+		User::RequestComplete( iCallerStatus, KErrNone );	
+		
+		}
+		
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::ContactViewReady
+// Implements the view ready function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsDataStore::ContactViewReady(
+                MVPbkContactViewBase& /*aView*/ ) 
+	{
+	if(iLastOperation == ENSMLDeleteAllOp)
+		{
+		TRAPD(error,DoDeleteAllContactsL());
+		if(error != KErrNone)
+			{
+			User::RequestComplete( iCallerStatus, error );
+			}
+		}
+	}
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::PrepareForContactsDeleteL()
+// Delete all the contacts at client
+// ---------------------------------------------------------------------------	
+void CNSmlContactsDataStore::DoDeleteAllContactsL()
+	{
+	iContactLnks = CVPbkContactLinkArray::NewL();
+	TInt contactCount = iContactViewBase->ContactCountL();
+	//add all the contact links to  ContactLinkArray
+	for( TInt i = 0; i < contactCount; i++ )
+		{
+			const MVPbkViewContact& contact = 
+						iContactViewBase->ContactAtL(i);
+			iContactLink = contact.CreateLinkLC();
+			iContactLnks->AppendL(iContactLink);
+			CleanupStack::Pop();
+		}
+	
+	iContactManager->DeleteContactsL( *iContactLnks, *this );
+	
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::ContactViewUnavailable
+// Implements the view unavailable function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsDataStore::ContactViewUnavailable(
+                MVPbkContactViewBase& /*aView*/ )  
+	{
+	   
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::ContactAddedToView
+// Implements the add contact function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsDataStore::ContactAddedToView(
+            MVPbkContactViewBase& /*aView*/, 
+            TInt /*aIndex*/, 
+            const MVPbkContactLink& /*aContactLink*/ ) 
+	{
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::ContactRemovedFromView
+// Implements the remove contact function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsDataStore::ContactRemovedFromView(
+                MVPbkContactViewBase& /*aView*/, 
+                TInt /*aIndex*/, 
+                const MVPbkContactLink& /*aContactLink*/ )  
+	{
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsDataStore::ContactViewError
+// Implements the view error function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsDataStore::ContactViewError(
+            MVPbkContactViewBase& /*aView*/, 
+            TInt /*aError*/, 
+            TBool /*aErrorNotified*/ )  
+	{
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlContactsDataStore::CreateViewL()
+// Create a contact view 
+// -----------------------------------------------------------------------------
+ 
+void CNSmlContactsDataStore::CreateViewL()
+	{
+	
+	CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
+	CleanupStack::PushL( viewDef );
+	viewDef->SetType( EVPbkContactsView );
+
+	viewDef->SetUriL(iStore->StoreProperties().Uri().UriDes());
+
+	 iContactViewBase = iContactManager->CreateContactViewLC( 
+				                         *this, 
+				                         *viewDef, 
+				                         iContactManager->FieldTypes()  );
+	CleanupStack::Pop();
+	CleanupStack::PopAndDestroy(viewDef);	
+	
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStoreFormat_1_1_2.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,625 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  Resource data for ContactsDataProvider
+*
+*/
+
+
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT NSML_CONTACTS_DATA_STORE_FORMAT
+	{
+	version=1;
+	display_name="Contacts";
+	sync_types=KSmlSyncType_TwoWay+KSmlSyncType_OneWayFromSvr+
+	           KSmlSyncType_OneWayFromClnt+KSmlSyncType_SlowSync+
+	           KSmlSyncType_RefreshFromSvr+KSmlSyncType_RefreshFromClnt;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/x-vcard";
+			mime_ver="2.1";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCARD"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCARD"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";
+					data_type="";
+					enum_values={"2.1"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Revision";
+					name="REV";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Name";
+					name="N";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Address";
+					name="ADR";	
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Home address";
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Work address";
+							name="WORK";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Telephone number";
+					name="TEL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Home telephone";
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Work telephone";
+							name="WORK";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Cellular number";
+							name="CELL";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Pager number";
+							name="PAGER";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Fax number";
+							name="FAX";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Video number";
+							name="VIDEO";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Default number";
+							name="PREF";
+							data_type="";
+							enum_values={};
+							},	
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Car telephone";
+							name="CAR";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="FullName";
+					name="FN";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Email address";
+					name="EMAIL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="";
+							name="INTERNET";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Home email";
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Work email";
+							name="WORK";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Home GEO";
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Work GEO";
+							name="WORK";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="URL address";
+					name="URL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Home URL";
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Work URL";
+							name="WORK";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Note";
+					name="NOTE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Title";
+					name="TITLE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Organisation";
+					name="ORG";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Photo";
+					name="PHOTO";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Birthday";
+					name="BDAY";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sound";
+					name="SOUND";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Wireless Village Id";
+					name="X-WV-ID";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+					
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Assistant name";
+					name="X-ASSISTANT";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+					
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Assistant phone";
+					name="X-ASSISTANT-TEL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Anniversary";
+					name="X-ANNIVERSARY";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Spouse";
+					name="X-SPOUSE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Children";
+					name="X-CHILDREN";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+			 SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Nickname";
+					name="X-NICKNAME";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="X-CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="IMPP";
+					name="X-IMPP";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="PERSONAL";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="HOME";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="WORK";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="BUSINESS";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="MOBILE";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name=""; 
+							name="PREF";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+					SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Top contact";
+					name="X-FAVORITE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				      SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="SIP protocol";
+					name="X-SIP";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="POC";
+							name="POC";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="SWIS";
+							name="SWIS";
+							data_type="";
+							enum_values={};
+							},
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Voice over IP";
+							name="VOIP";
+							data_type="";
+							enum_values={};
+							}
+						};
+					},
+                    SML_DATA_PROPERTY
+                              {
+                              version=1;
+                              display_name="Categories";
+                              name="X-CATEGORIES";
+                              data_type="";
+                              enum_values={};
+                              flags= 0;
+                              max_size=256;
+                              max_occur=0;
+                              params={};
+                              }
+				};
+				field_level=0;
+				}
+			};
+		mime_format_tx_pref=0;     // Preferred index for tx
+		mime_format_rx_pref=0;     // Preferred index for rx
+		folder_properties={};
+		filter_capabilities={};
+		max_size=0; 	// no limit
+		max_items=0; 	// no limit
+		flags=0;
+	}
+	
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStoreFormat_1_2.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,469 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  Resource data for ContactsDataProvider
+*
+*/
+
+
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT NSML_CONTACTS_DATA_STORE_FORMAT
+	{
+	version=1;
+	display_name="Contacts";
+	sync_types=KSmlSyncType_TwoWay+KSmlSyncType_OneWayFromSvr+
+	           KSmlSyncType_OneWayFromClnt+KSmlSyncType_SlowSync+
+	           KSmlSyncType_RefreshFromSvr+KSmlSyncType_RefreshFromClnt;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version=1;
+			mime_type="text/x-vcard";
+			mime_ver="2.1";
+			properties=
+				{
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Begin";
+					name="BEGIN";
+					data_type="";
+					enum_values={"VCARD"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="End";
+					name="END";
+					data_type="";
+					enum_values={"VCARD"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Version";
+					name="VERSION";
+					data_type="";
+					enum_values={"2.1"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Revision";
+					name="REV";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Name";
+					name="N";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Address";
+					name="ADR";	
+					data_type="";
+					enum_values={};
+					flags=0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"HOME", "WORK"};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Telephone number";
+					name="TEL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"HOME", "WORK", "CELL", "PAGER", "FAX", "VIDEO", "PREF", "CAR"};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="FullName";
+					name="FN";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Email address";
+					name="EMAIL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"INTERNET", "HOME", "WORK"};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="GEO Address";
+					name="GEO";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"HOME", "WORK"};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="URL address";
+					name="URL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"HOME", "WORK"};
+							}
+						};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Note";
+					name="NOTE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Title";
+					name="TITLE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Organisation";
+					name="ORG";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Photo";
+					name="PHOTO";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Birthday";
+					name="BDAY";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Sound";
+					name="SOUND";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Wireless Village Id";
+					name="X-WV-ID";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Assistant name";
+					name="X-ASSISTANT";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Assistant phone";
+					name="X-ASSISTANT-TEL";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Anniversary";
+					name="X-ANNIVERSARY";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Spouse";
+					name="X-SPOUSE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Children";
+					name="X-CHILDREN";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+			 SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Nickname";
+					name="X-NICKNAME";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Class";
+					name="X-CLASS";
+					data_type="";
+					enum_values={"PUBLIC","PRIVATE","CONFIDENTIAL"};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="IMPP";
+					name="X-IMPP";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"PERSONAL", "HOME", "WORK","BUSINESS", "MOBILE", "PREF"};
+							}
+						};
+					},	
+					SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="Top Contact";
+					name="X-FAVORITE";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params={};
+					},
+				     SML_DATA_PROPERTY
+					{
+					version=1;
+					display_name="SIP protocol";
+					name="X-SIP";
+					data_type="";
+					enum_values={};
+					flags= 0;
+					max_size=256;
+					max_occur=0;
+					params=
+						{
+						SML_DATA_PROPERTY_PARAM
+							{
+							version=1;
+							display_name="Type";
+							name="TYPE";
+							data_type="";
+							enum_values={"POC", "SWIS", "VOIP"};
+							}
+						};
+					},
+	                   SML_DATA_PROPERTY
+	                        {
+	                        version=1;
+	                        display_name="Categories";
+	                        name="X-CATEGORIES";
+	                        data_type="";
+	                        enum_values={};
+	                        flags= 0;
+	                        max_size=256;
+	                        max_occur=0;
+	                        params={};
+	                        }
+				};
+				field_level=0;
+				}
+			};
+		mime_format_tx_pref=0;     // Preferred index for tx
+		mime_format_rx_pref=0;     // Preferred index for rx
+		folder_properties={};
+		filter_capabilities={};
+		max_size=0; 	// no limit
+		max_items=0; 	// no limit
+		flags=0;
+	}
+	
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsModsFetcher.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,404 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or 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:  DS contacts adapters 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <s32strm.h>
+#include <cntdb.h>
+#include <e32cmn.h>
+#include <e32des16.h>
+#include <cntitem.h>
+#include <cntfield.h>
+#include <cntfldst.h>
+
+#include "nsmlcontactsdefs.h"
+#include "NSmlContactsModsFetcher.h"
+#include "nsmldebug.h"
+#include "nsmlsnapshotitem.h"
+#include "nsmlchangefinder.h"
+
+#include <CVPbkContactViewDefinition.h>
+#include <CVPbkContactIdConverter.h>
+#include <CVPbkContactFieldIterator.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkStoreContactProperties.h>
+#include <MVPbkViewContact.h>
+#include <MVPbkFieldType.h>
+#include <MVPbkContactFieldTextData.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkStoreContact2.h>
+#include <MVPbkContactLink.h>
+#include <VPbkEng.rsg>
+
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::CNSmlContactsModsFetcher
+// ------------------------------------------------------------------------------------------------
+//
+CNSmlContactsModsFetcher::CNSmlContactsModsFetcher( TBool& aSnapshotRegistered,CVPbkContactManager& aContactManager,MVPbkContactStore& aStore,TKeyArrayFix& aKey, CNSmlChangeFinder& aChangeFinder ) :
+	CActive( EPriorityLow ), 
+	iSnapshotRegistered( aSnapshotRegistered ), 
+	iKey( aKey ), 
+	iChangeFinder( aChangeFinder ),
+	iContactManager(aContactManager) ,
+	iStore(aStore) ,
+	iContactViewBase(NULL)
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::CNSmlContactsModsFetcher(): begin");
+	CActiveScheduler::Add( this );
+	_DBG_FILE("CNSmlContactsModsFetcher::CNSmlContactsModsFetcher(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::~CNSmlContactsModsFetcher
+// ------------------------------------------------------------------------------------------------
+//
+CNSmlContactsModsFetcher::~CNSmlContactsModsFetcher()
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::~CNSmlContactsModsFetcher(): begin");
+	
+	Cancel();	
+	delete iSnapshot;
+	delete iContactViewBase;
+	
+	
+	_DBG_FILE("CNSmlContactsModsFetcher::~CNSmlContactsModsFetcher(): end");
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::FetchModificationsL
+// ------------------------------------------------------------------------------------------------
+//
+void CNSmlContactsModsFetcher::FetchModificationsL( TRequestStatus& aStatus )
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::FetchModificationsL(): begin");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	iContactCount = 0;
+	if( !iSnapshot )
+		{
+		iSnapshot = new (ELeave) CArrayFixSeg<TNSmlSnapshotItem>( KNSmlSnapshotSize );
+		}
+		
+	if(iContactViewBase)
+	{
+	delete iContactViewBase;
+	iContactViewBase = NULL;	
+	}
+	
+	CreateViewL();
+	
+	_DBG_FILE("CNSmlContactsModsFetcher::FetchModificationsL(): end");
+	
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::ConstructL
+// ------------------------------------------------------------------------------------------------
+//
+void CNSmlContactsModsFetcher::ConstructL()
+	{
+	iSnapshot = new (ELeave) CArrayFixSeg<TNSmlSnapshotItem>(KNSmlSnapshotSmallSize);
+	
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::RunL
+// ------------------------------------------------------------------------------------------------	
+//
+void CNSmlContactsModsFetcher::RunL()
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::RunL(): begin");
+	
+	if ( !iSnapshotRegistered )
+		{
+		FetchNextContactL();
+		}
+#ifdef __NSML_MODULETEST__
+	else
+		{
+		CActiveScheduler::Stop();
+		}
+#endif
+	
+	_DBG_FILE("CNSmlContactsModsFetcher::RunL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::FetchNextContactL
+// ------------------------------------------------------------------------------------------------	
+//
+void CNSmlContactsModsFetcher::FetchNextContactL()
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::FetchNextContactL(): begin");
+	if(iContactViewBase->ContactCountL() == 0)
+		{
+		User::RequestComplete( iCallerStatus, KErrNone );
+		return;	
+		}
+	if ( !iSnapshotRegistered )
+		{
+		const MVPbkViewContact& contact = iContactViewBase->ContactAtL(iContactCount);
+
+		MVPbkContactLink* contactLink = contact.CreateLinkLC();
+		iContactManager.RetrieveContactL( *contactLink, *this );
+		CleanupStack::PopAndDestroy();	
+		}
+
+	_DBG_FILE("CNSmlContactsModsFetcher::FetchNextContactL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::DoCancel
+// ------------------------------------------------------------------------------------------------	
+//
+void CNSmlContactsModsFetcher::DoCancel()
+	{
+	_DBG_FILE("CNSmlContactsModsFetcher::DoCancel(): begin");
+
+	User::RequestComplete( iCallerStatus, KErrCancel );
+	
+	_DBG_FILE("CNSmlContactsModsFetcher::DoCancel(): end");
+	}
+
+// ----------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::IsConfidentialL
+// ----------------------------------------------------------------------------
+//	
+TBool CNSmlContactsModsFetcher::IsConfidentialL( MVPbkStoreContact& aItem )
+    {
+    _DBG_FILE("CNSmlContactsModsFetcher::IsConfidentialL(): begin");
+    TBool ret( EFalse );
+    
+    //find X-CLASS field type
+	const MVPbkFieldType* syncclass = 
+        iContactManager.FieldTypes().Find(R_VPBK_FIELD_TYPE_SYNCCLASS );
+	CVPbkBaseContactFieldTypeIterator* itr = 
+        CVPbkBaseContactFieldTypeIterator::NewLC( *syncclass, 
+            aItem.Fields() );
+	while ( itr->HasNext() )
+        {
+        const MVPbkBaseContactField* field = itr->Next();
+        const MVPbkContactFieldTextData& data = 
+        	MVPbkContactFieldTextData::Cast(field->FieldData());
+        TPtrC ptr = data.Text();
+        //compare the sync type
+        if ( ptr.Compare( KNSmlContactSyncNoSync ) == 0 )
+            {
+            _DBG_FILE("CNSmlContactsModsFetcher::IsConfidentialL(): \
+                       find confidential");
+            ret = ETrue;
+            }
+         
+        }
+	CleanupStack::PopAndDestroy( itr );
+    
+    _DBG_FILE("CNSmlContactsModsFetcher::IsConfidentialL(): end");
+    return ret;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::RunError
+// ----------------------------------------------------------------------------
+ TInt CNSmlContactsModsFetcher::RunError( TInt aError )
+	{
+	DBG_FILE_CODE(aError, _S8("CNSmlContactsModsFetcher::RunError() : error code received "));
+	User::RequestComplete( iCallerStatus, aError );
+	return KErrNone;
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::CreateViewL()
+// Create a contact view of the store which is opened
+// -----------------------------------------------------------------------------
+ 
+void CNSmlContactsModsFetcher::CreateViewL()
+	{
+	CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
+	CleanupStack::PushL( viewDef );
+	viewDef->SetType( EVPbkContactsView );
+
+	viewDef->SetUriL(iStore.StoreProperties().Uri().UriDes());
+
+	 iContactViewBase = iContactManager.CreateContactViewLC( 
+				                         *this, 
+				                         *viewDef, 
+				                         iContactManager.FieldTypes()  );
+	CleanupStack::Pop();
+	CleanupStack::PopAndDestroy(viewDef);
+
+	}
+// ---------------------------------------------------------------------------
+//  CNSmlContactsModsFetcher::UpdateSnapshotL
+//  Add the fetched contacts id and timestamp 
+//  to the snapshot.
+// ---------------------------------------------------------------------------
+//
+ 
+ void CNSmlContactsModsFetcher::UpdateSnapshotL(MVPbkStoreContact* aContact)
+{
+	if(!IsConfidentialL(*aContact))
+		{
+		CVPbkContactIdConverter* idConverter = CVPbkContactIdConverter::NewL(iStore );
+		CleanupStack::PushL( idConverter );
+
+		TInt32 id = idConverter->LinkToIdentifier(
+			*iContactViewBase->ContactAtL(iContactCount).CreateLinkLC());
+		TNSmlSnapshotItem snap( id);
+		
+		MVPbkStoreContact2* tempContact = 
+		reinterpret_cast<MVPbkStoreContact2*> (aContact->StoreContactExtension (KMVPbkStoreContactExtension2Uid));  
+              
+		MVPbkStoreContactProperties *contactProterties 
+									= tempContact ->PropertiesL();
+		CleanupDeletePushL(contactProterties);				
+		snap.SetLastChangedDate(contactProterties->LastModifiedL());
+		CleanupStack::PopAndDestroy();
+				
+		iSnapshot->InsertIsqL( snap, iKey );
+		iCurrentSnapshotCounter++;
+		if ( iCurrentSnapshotCounter > 20 )
+			{
+			iSnapshot->Compress();
+			iCurrentSnapshotCounter = 0;
+			}
+		CleanupStack::PopAndDestroy();
+		CleanupStack::PopAndDestroy(idConverter);	
+		}
+	
+	iContactCount++;
+	
+	if ( iContactCount == iContactViewBase->ContactCountL() )
+		{
+		iChangeFinder.SetNewSnapshot( iSnapshot ); // changefinder takes ownership
+		iSnapshot = NULL;
+		iSnapshotRegistered = ETrue;
+		User::RequestComplete( iCallerStatus, KErrNone );
+		}
+
+}	
+// ---------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::ContactViewReady
+// Implements the view ready function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsModsFetcher::ContactViewReady(
+                MVPbkContactViewBase& /*aView*/ ) 
+	{
+    _DBG_FILE("CNSmlContactsModsFetcher::ContactViewReady(): begin");
+	
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete( status, KErrNone );	
+	
+	_DBG_FILE("CNSmlContactsModsFetcher::ContactViewReady(): end");
+	}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::ContactViewUnavailable
+// Implements the view unavailable function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsModsFetcher::ContactViewUnavailable(
+                MVPbkContactViewBase& /*aView*/ )  
+{
+   
+
+}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::ContactAddedToView
+// Implements the add contact function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsModsFetcher::ContactAddedToView(
+            MVPbkContactViewBase& /*aView*/, 
+            TInt /*aIndex*/, 
+            const MVPbkContactLink& /*aContactLink*/ ) 
+{
+}
+
+// ---------------------------------------------------------------------------
+// Implements the remove contact function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsModsFetcher::ContactRemovedFromView(
+                MVPbkContactViewBase& /*aView*/, 
+                TInt /*aIndex*/, 
+                const MVPbkContactLink& /*aContactLink*/ )  
+{
+}
+
+// ---------------------------------------------------------------------------
+// CNSmlContactsModsFetcher::ContactViewError
+// Implements the view error function of MVPbkContactViewObserver
+// --------------------------------------------------------------------------- 
+void CNSmlContactsModsFetcher::ContactViewError(
+            MVPbkContactViewBase& /*aView*/, 
+            TInt aError, 
+            TBool /*aErrorNotified*/ )  
+{
+User::RequestComplete( iCallerStatus, aError );
+}
+
+// ---------------------------------------------------------------------------
+//  CNSmlContactsModsFetcher::VPbkSingleContactOperationComplete
+//  Called when the contact operation is completed.
+// ---------------------------------------------------------------------------
+//
+ void CNSmlContactsModsFetcher::VPbkSingleContactOperationComplete(
+		MVPbkContactOperationBase& aOperation,
+		MVPbkStoreContact* aContact )
+{
+	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+	
+	TRAPD(error,UpdateSnapshotL(aContact));
+	delete aContact;
+	if(error!= KErrNone)
+	{
+	User::RequestComplete( iCallerStatus, error );	
+	}
+	else
+	{
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete( status, KErrNone );		
+	}
+	
+}
+
+// ---------------------------------------------------------------------------
+//  CNSmlContactsModsFetcher::VPbkSingleContactOperationFailed
+//  Called when the contact operation fails
+// ---------------------------------------------------------------------------
+//
+void CNSmlContactsModsFetcher::VPbkSingleContactOperationFailed(
+		MVPbkContactOperationBase& aOperation,
+		 TInt /*aError*/ )
+ {
+ 	MVPbkContactOperationBase* operation = &aOperation;
+	if ( operation )
+	{
+		delete operation;
+		operation = NULL;
+	}
+ }
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/inc/nsmldsimpluids.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  Implementation UIDs for ECOM plug-in adapters
+*
+*/
+
+
+#ifndef __NSMLIMPLUIDS_H__
+#define __NSMLIMPLUIDS_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+
+// Implementation UIDs for DS adapters
+const TUint KNSmlContactsAdapterImplUid = 0x101F6DDD;
+const TUint KNSmlAgendaAdapterImplUid = 0x101F6DDD+1;
+const TUint KNSmlEmailAdapterImplUid = 0x101F6DDD+2;
+// This one is for testing purposes only!
+const TUint KNSmlParamTestAdapterImplUid = 0x101F6DEB;
+
+#endif // __CNSMLIMPLUIDS_H__
Binary file omads/omadsextensions/adapters/mms/group/101FB0E9.XML has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for MMS DS adapter
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./101FB0E9.XML      /epoc32/data/Z/private/101F99F6/capability/101FB0E9.XML
+./101FB0E9.XML      /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/101FB0E9.XML
+./mmsdsa_stub.sis   /epoc32/data/z/system/install/mmsdsa_stub.sis
+../rom/mmsdsa.iby   CORE_APP_LAYER_IBY_EXPORT_PATH(mmsdsa.iby)
+
+PRJ_MMPFILES
+./mmsdataprovider.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/group/mmsdataprovider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project MMS DS Plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          mmsdataprovider.dll
+TARGETTYPE      PLUGIN
+UID             0x10009d8d 0x101FB0E9
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          snapshotitem.cpp
+SOURCE          changefinder.cpp
+SOURCE          mmsdataprovider.cpp
+SOURCE          mmsdatastore.cpp
+SOURCE          omadsfolderobject.cpp
+SOURCE          mmsadaptermsvapi.cpp
+
+USERINCLUDE     ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  mmsdataprovider.rss
+HEADER
+TARGET          mmsdataprovider.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  mmsdatastore.rss
+HEADER
+TARGET          mmsdatastore.rsc  
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         ecom.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         smldataprovider.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY         centralrepository.lib
+LIBRARY         msgs.lib 
+LIBRARY         bafl.lib
+LIBRARY         sysutil.lib
+LIBRARY         mmscodecclient.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         SenXml.lib 
+LIBRARY         charconv.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/group/mmsdsa_stub.pkg	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+&EN
+
+; Header
+#{"MMS DS Plugin"},(0x101FB0E9),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\mmsdatastore.rsc"
+""-"z:\resource\mmsdataprovider.rsc"
+""-"z:\sys\bin\mmsdataprovider.dll"
Binary file omads/omadsextensions/adapters/mms/group/mmsdsa_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/changefinder.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __CHANGEFINDER_H__
+#define __CHANGEFINDER_H__
+
+// INCLUDES
+#include <msvids.h>
+#include <nsmlchangefinder.h>
+#include "snapshotitem.h"
+
+// DATATYPES
+typedef CArrayFixSeg<TSnapshotItem> CSnapshotArray;
+
+// Granularity used with dynamic array
+const TInt KSnapshotGranularity = 32;
+
+// CLASS DECLARATION
+
+/**
+* @brief CChangeFinder Class
+* This is a ChangeFinder class, which can be used to track down changes in the message store.
+* It's functionality is equal to CSmlChangeFinder, except the functionality is a bit wider
+* since this class can also detect "partially updated" items. It means that if only the status
+* Bits of the message are changed, it can be detected. It is achieved by using TSnapshotItem
+* class, which contain also this information. Because neither of these classes contained virtual
+* functionality, the functionality of this class couldn't be inherited from the CSmlChangeFinder
+*/
+class CChangeFinder : public CBase
+	{ 
+public:
+	
+	/**
+    * Class constructor, Creates a new class instance.
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    * @return CChangeFinder*, New ChangeFinder instance.
+    */
+    static CChangeFinder* NewL( MSmlSyncRelationship& aSyncRelationship, 
+                               TKeyArrayFix aKey,
+                               TBool& aHasHistory, 
+                               TInt aStreamUid = KNSmlDefaultSnapshotStreamUID );
+
+    /**
+    * Class destructor.
+    */
+	~CChangeFinder();
+	
+    /**
+    * Close ChangeFinder object, stores snapshot.
+    */
+	void CloseL();
+
+    /**
+    * Reset change information, makes all content new from ChangeFinder point of view.
+    */
+	void ResetL();
+
+    /**
+    * Find changed items by comparing snapshots.
+    * 
+    * @param aChangedUids   IN: Array for results.
+    */
+	void FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids );
+
+    /**
+    * Find deleteed items by comparing snapshots.
+    * 
+    * @param aDeletedUids   IN: Array for results.
+    */
+	void FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids );
+	
+    /**
+    * Find new items by comparing snapshots.
+    * 
+    * @param aNewUids   IN: Array for results.
+    */	
+	void FindNewItemsL(CNSmlDataItemUidSet& aNewUids);
+
+    /**
+    * Find moved items by comparing snapshots.
+    * 
+    * @param aMovedUids   IN: Array for results.
+    */	
+	void FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids );
+
+    /**
+    * Add item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to add.
+    */
+	void ItemAddedL( const TSnapshotItem& aItem );
+
+    /**
+    * Delete item from snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to delete.
+    */
+	void ItemDeletedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Update item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to update.
+    */
+	void ItemUpdatedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Move item within snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to move.
+    */
+	void ItemMovedL( const TSnapshotItem& aItem );
+
+    /**
+    * Commit all changes to snapshot, there's nothing to report anymore.
+    */
+	void CommitChangesL();
+
+    /**
+    * Commit a set of items to snapshot, these items won't be reported anymore.
+    * 
+    * @param aUids   IN: a set of items to commit.
+    */
+	void CommitChangesL( const MSmlDataItemUidSet& aUids );
+	
+	/**
+    * Sets new snapshot to compare against.
+    * 
+    * @param aNewSnapshot   IN: a new snapshot.
+    */
+	void SetNewSnapshot( CSnapshotArray* aNewSnapshot );
+	
+	/**
+    * Retrieves DataStore id number.
+    *
+    * @return TInt64, DataStore id.
+    */
+	TInt64 DataStoreUid() const;
+
+	/**
+    * Sets DataStore id number.
+    * 
+    * @param aUid   IN: a new datastore id.
+    */
+	void SetDataStoreUid( TInt64 aUid );
+	
+    /**
+    * Checks whether specific item can be partially updated.
+    * 
+    * @param aUid   IN: item id.
+    * @return TBool Result, ETrue if the item contains only status change (read<->unread).
+    */
+	TBool UpdatePartialL( TSmlDbItemUid& aUid );
+	
+protected:
+	
+    /**
+    * C++ Constructor
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    */    
+	CChangeFinder( MSmlSyncRelationship& aSyncRelationship, 
+	              TKeyArrayFix aKey, 
+	              TInt aStreamUid );
+    
+    /**
+    * 2nd-phase Constructor
+    *
+    * @param aHasHistory   IN: ETrue, if there was synchronization history.
+    */    
+    void ConstructL( TBool& aHasHistory );
+
+private:
+
+    /**
+    * Allows access to streams.
+    */
+	MSmlSyncRelationship& iSyncRelationship;
+	
+    /**
+    * New snapshot to compare against.
+    */	
+	CSnapshotArray* iCurrentSnapshot;
+
+    /**
+    * Current snapshot.
+    */
+	CSnapshotArray* iOldSnapshot;
+	
+    /**
+    * Key that is used in sorting snapshot.
+    */
+	TKeyArrayFix iKey;
+	
+    /**
+    * Stream id number to access sync relationship.
+    */	
+	TInt iStreamUid;
+	
+    /**
+    * Data store id number.
+    */	
+	TInt64 iDataStoreUid;
+    };
+
+#endif // __CHANGEFINDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/logger.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging macros used by DS plug-in adapters
+*
+*/
+
+
+#ifndef __LOGGER_H__
+#define __LOGGER_H__
+
+#ifdef _DEBUG
+    #ifdef __WINS__
+        // File logging for WINS
+        #define __FLOGGING__
+    #else
+        // Logging with RDebug for target HW
+        #define __CLOGGING__
+        //#define __FLOGGING__ // enable to log file on target HW
+    #endif //__WINS__
+    
+    #include <f32file.h>
+    #include <flogger.h>
+    #include <e32std.h>
+    #include <e32def.h>
+    
+    _LIT(KLogDir,"MMS");
+    _LIT(KLogFile,"MMSDataproviderLog.txt");
+    _LIT( KLogFormat, "[MMSDS] %S");
+    
+    _LIT(KLogEnterFn, "%S : Begin");
+    _LIT(KLogLeaveFn, "%S : End");
+    
+    /**
+    * Old logging macros, for public use
+    */
+    #ifdef __FLOGGING__
+        #define LOG( AAA )      RFileLogger::Write( KLogDir,KLogFile,EFileLoggingModeAppend,AAA )
+    #else
+        #define LOG( AAA )
+    #endif
+    #define LOG2( text, par1 )       { FPrint( text, par1 ); }
+    
+    
+    /**
+    * new logging macros, for public use
+    */
+    #define LOGGER_ENTERFN( name )      {_LIT( temp, name ); FPrint( KLogEnterFn, &temp );}
+    #define LOGGER_LEAVEFN( name )      {_LIT( temp, name ); FPrint( KLogLeaveFn, &temp );}
+    
+    #define LOGGER_WRITE( text )                    {_LIT( KTemp, text ); FPrint( KTemp );}
+    #define LOGGER_WRITE_1( text,par1 )             {_LIT( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_MSG_EC( text,par1 )	                {_LIT( KTemp, text ); FPrint( KTemp, par1 );}
+    
+    
+    // Declare the FPrint function
+    inline void FPrint( TRefByValue<const TDesC> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+        #if defined ( __FLOGGING__ )
+            RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+        #endif
+        #if defined ( __CLOGGING__ )
+            const TInt KMaxLogData = 0x200;
+    	    TBuf< KMaxLogData > buf;
+    	    buf.FormatList( aFmt, list );
+    	    
+    	    RDebug::Print( KLogFormat, &buf );
+        #endif
+        }
+#else // no _DEBUG defined
+    
+    #define LOG( AAA )
+    
+    #define LOGGER_ENTERFN( name )
+    #define LOGGER_LEAVEFN( name )
+    #define LOGGER_WRITE( text )
+    #define LOGGER_WRITE_1( text,par1 )
+    #define LOGGER_MSG_EC( text,par1 )
+
+#endif // _DEBUG
+
+#endif // __LOGGER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/mmsadaptermsvapi.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CMmsAdapterMsvApi header
+*
+*/
+
+
+#ifndef MMSADAPTERMSVAPI_H
+#define MMSADAPTERMSVAPI_H
+
+//  INCLUDES
+#include <msvstd.h>         // TMsvId
+ 
+// CONSTANTS
+const TInt KMsvMyFoldersEntryIdValue = 0x1008;
+const TInt KMsvMyFoldersTemplatesFolderId = 0x1009;
+
+// FORWARD DECLARATIONS
+class CMsvSession;
+
+
+// CLASS DECLARATION
+
+/**
+* Class CMmsAdapterMsvApi
+* Internal class that provides access to SMS message store.
+*/
+class CMmsAdapterMsvApi : public CBase 
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param aMsvSession   IN: Access to message server
+        *
+        */
+        static CMmsAdapterMsvApi* NewL(CMsvSession& aMsvSession);
+                
+        /**
+        * Destructor.
+        */
+        virtual ~CMmsAdapterMsvApi();
+        
+    private: // Private constructor functions
+        
+        /**
+        * C++ default constructor.
+        * C++ default constructor can NOT contain any code, that
+        * might leave.
+        *
+        * @param aMsvSession   IN: Access to message server
+        *        
+        */
+        CMmsAdapterMsvApi(CMsvSession& aMsvSession);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();        
+
+    public: // New functions
+	    
+         
+        /**
+        * Delete user folder under My Folders
+        * 
+        * @param aUid   IN: the index to the folder, which will be deleted
+        *
+        * @return   KErrNone in success. KErrInUse if folder was not deleted because it was not empty.                             
+        */         
+        TInt DeleteUserFolderL( TMsvId aUid );
+	
+       /**
+        * Valid folder checks if the folder is valid.
+        * The caller of the function can set, if Outbox folder is valid or not.
+        * 
+        * @param aFolder   folder
+        * @param aOutboxValid if the MM is outbox is valid folder or not
+        * 
+        * @return ETrue when the folder is valid.
+        * @return EFalse when the folder is not valid.
+        */
+        TBool ValidFolderL( TMsvId aFolder , TBool aOutboxValid = ETrue );		
+		
+       /**
+        * Creates new user defined folder
+        * 
+        * @param aFolder    OUT: index of the new folder
+        * @param aName      IN: name of the new folder
+        *
+        * @return     KErrNone or error
+        */				
+		TInt AddUserFolderL( TMsvId& aFolder, const TDesC& aName );
+		
+       /**
+        * Updates name of user defined folder
+        * 
+        * @param aFolder    IN: index of the folder
+        * @param aName      IN: new name of the folder
+        *
+        * @return     KErrNone or error
+        */					
+		TInt UpdateUserFolderL( TMsvId aFolder, const TDesC& aName );
+		
+        /**
+        * Searches user folder with given UID
+        * 
+        * @param aFolder     IN: Folder UID
+        * @param aName       OUT: name of found user folder
+        * @param aDate       OUT: time stamp of found user folder 
+        *
+        * @return	Return value indicates whether folder was found or not
+        */	        
+        TBool FindUserFolderL(TMsvId aFolder, TPtrC& aName, TTime& aDate);	
+        
+        /**
+        * Searches user folder with given UID
+        * 
+        * @param aFolder     IN: Folder UID
+        *
+        * @return	Return value indicates whether folder was found or not
+        */	        
+        TBool FindUserFolderL(TMsvId aFolder);
+        
+    private:	// Internal functions
+
+        /**
+        * Check whether folder with given name exists
+        * 
+        * @param aName     IN: Folder name
+        * @parem aFolder   OUT: Folder UID if matching folder was found. 
+        *
+        * @return	Return value indicates whether folder was found or not 
+        */	       
+        TBool FindUserFolderL(const TDesC& aName, TMsvId& aFolder);		
+    
+    private:    // Data
+        
+        CMsvSession& 			iSession;
+    			
+    };
+
+#endif      //SMSADAPTERMSVAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/mmsdataprovider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __MMSDATAPROVIDER_H__
+#define __MMSDATAPROVIDER_H__
+
+// INCLUDES
+#include <SmlDataProvider.h>
+
+// FORWARD DECLARATIONS
+class CMmsDataStore;
+class CSmlDataStoreFormat;
+
+/**
+* @brief This class is derived from ECom Data Provider plugin-interface (CSmlDataProvider).
+* It makes it possible to synchronize MMS messages from the device message store.
+*/
+class CMmsDataProvider : public CSmlDataProvider, public MMsvSessionObserver
+    {
+
+public:
+    
+    /**
+    * Constructor.
+	*
+	* @return CMmsDataProvider*, a new CMmsDataProvider instance.
+    */
+    static CMmsDataProvider* NewL();
+    
+	/**
+    * Destructor.
+    */
+    virtual ~CMmsDataProvider();
+
+    /**
+    * Callback from MMsvSessionObserver.
+    */
+	void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
+
+protected: // Inherited from CSmlDataProvider
+
+	virtual void DoOnFrameworkEvent( TSmlFrameworkEvent, TInt aParam1, TInt aParam2 );
+	
+	virtual TBool DoSupportsOperation( TUid aOpId ) const;
+	
+	virtual const CSmlDataStoreFormat& DoStoreFormatL();
+	
+	virtual CDesCArray* DoListStoresLC();
+	
+	virtual const TDesC& DoDefaultStoreL();
+	
+	virtual CSmlDataStore* DoNewStoreInstanceLC();
+	
+    virtual void DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& aServerDataStoreFormat,
+        RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo );
+        
+    virtual void DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& aFilters,
+        TSyncMLFilterChangeInfo& aChangeInfo ); 
+        
+	virtual const RPointerArray<CSyncMLFilter>& DoSupportedServerFiltersL();
+	
+	virtual TBool DoSupportsUserSelectableMatchType() const;
+	
+	virtual HBufC* DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& aFilters,
+	    TSyncMLFilterMatchType aMatch, TDes& aFilterMimeType,
+	    TSyncMLFilterType& aFilterType, TDesC& aStoreName );
+	    
+	virtual void DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& aFilters,
+	    TDes& aFilterMimeType, RPointerArray<CSmlDataProperty>& aProperties, TDesC& aStoreName );
+
+private:
+	
+	/**
+    * C++ Constructor.
+    */
+    CMmsDataProvider();
+    
+	/**
+    * 2nd-phase Constructor.
+    */
+    void ConstructL();
+   
+	/**
+    * Creates new DataStore format.
+    */
+    CSmlDataStoreFormat* DoOwnStoreFormatL();
+
+private:
+
+	/**
+    * String pool, used in store format creation.
+    */
+    RStringPool iStringPool;
+
+	/**
+    * Data store format.
+    */
+    CSmlDataStoreFormat* iOwnStoreFormat;
+
+	/**
+    * Supported filters (none supported at the moment).
+    */
+    RPointerArray<CSyncMLFilter> iFilters;
+    
+	/**
+    * File system handle.
+    */
+    RFs iRFs;
+    
+	/**
+    * Message store handle.
+    */
+    CMsvSession* iMsvSession;
+
+	/**
+    * Reserved pointer for future extension.
+    */
+    TAny* iReserved;
+
+    };
+
+#endif // __MMSDATAPROVIDER_H__  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/mmsdataproviderdefs.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __MMSDATAPROVIDERDEFS_H__ 
+#define __MMSDATAPROVIDERDEFS_H__ 
+
+#include <e32def.h>
+#include <e32cmn.h>
+
+// ------------------------------------------------------------------------------------------------
+// Databases
+// ------------------------------------------------------------------------------------------------
+// Database name
+_LIT( KNSmlDefaultLocalDbName, "MmsSyncLocalDb" );
+
+// Resource file for CSmlDataStoreFormat in SIS installation
+_LIT(KMmsStoreFormatRsc,"mmsdatastore.rsc");
+
+// Must be like below in flash image
+_LIT(KMmsStoreFormatRscRom,"z:mmsdatastore.rsc");
+
+// ------------------------------------------------------------------------------------------------
+// Constants
+// ------------------------------------------------------------------------------------------------
+// max foldername
+const TInt KMaxFolderNameLength = 50;
+
+// Implementation uid
+const TUint KMmsDataProviderImplUid = 0x101FB0E9;
+
+// ------------------------------------------------------------------------------------------------
+// Macros
+// ------------------------------------------------------------------------------------------------
+#define SAFEDELETE(x) {if(x) {delete x; x = NULL;}}
+#define SAFEDELETEARRAY(x) {if(x) {delete[] x; x = NULL;}}
+
+#endif // __MMSDATAPROVIDERDEFS_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/mmsdatastore.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef __MMSDATASTORE_H__
+#define __MMSDATASTORE_H__
+
+// INCLUDES
+#include <SmlDataProvider.h>
+#include "mmsdataproviderdefs.h" 
+#include "changefinder.h"
+
+
+// FORWARD DECLARATIONS
+class CMsvSession; 
+class CNSmlDataItemUidSet;
+class CMmsCodecClient;
+class CMmsAdapterMsvApi;
+class CMsvOperationActiveSchedulerWait;
+class TNSmlSnapshotItem;
+class COMADSFolderObject;
+
+/**
+* @brief This class is derived from ECom Data Store plugin-interface (CSmlDataStore).
+* It performs the actual synchronization commands, which are received from
+* the DS engine.
+*/
+class CMmsDataStore : public CSmlDataStore
+    {
+public:  
+    
+    /**
+    * Constructor
+	*
+	* @return CMmsDataStore*, a new CSmsDataStore instance.
+    */
+    static CMmsDataStore* NewL(CMsvSession &aMsvSession);
+    
+	/**
+    * Destructor
+    */
+    virtual ~CMmsDataStore();
+
+protected:
+   
+   	// Virtual functionality from CSmlDataStore, for comments see the CSmlDataStore header file
+	virtual void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus);
+	virtual void DoCancelRequest();
+	virtual const TDesC& DoStoreName() const;
+	virtual void DoBeginTransactionL();
+	virtual void DoCommitTransactionL(TRequestStatus& aStatus);
+	virtual void DoRevertTransaction(TRequestStatus& aStatus);
+	virtual void DoBeginBatchL();
+	virtual void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus);
+	virtual void DoCancelBatch();
+	virtual void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat);
+	virtual void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize);
+	virtual TInt DoMaxObjectSize() const;
+	virtual void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize,
+	    TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus);
+	virtual void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent,
+	    const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus);
+	virtual void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent,
+	    TBool aFieldChange, TRequestStatus& aStatus);
+	virtual void DoReadItemL(TDes8& aBuffer);
+	virtual void DoWriteItemL(const TDesC8& aData);
+	virtual void DoCommitItemL(TRequestStatus& aStatus);
+	virtual void DoCloseItem();
+	virtual void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus);
+	virtual void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+	virtual void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
+	virtual void DoDeleteAllItemsL(TRequestStatus& aStatus);
+	virtual TBool DoHasSyncHistory() const;
+	virtual const MSmlDataItemUidSet& DoAddedItems() const;
+	virtual const MSmlDataItemUidSet& DoDeletedItems() const;
+	virtual const MSmlDataItemUidSet& DoSoftDeletedItems() const;
+	virtual const MSmlDataItemUidSet& DoModifiedItems() const;
+	virtual const MSmlDataItemUidSet& DoMovedItems() const;
+	virtual void DoResetChangeInfoL(TRequestStatus& aStatus);
+	virtual void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems);
+	virtual void DoCommitChangeInfoL(TRequestStatus& aStatus);
+
+private: 
+
+	/**
+    * C++ Constructor.
+    */
+    CMmsDataStore();
+    
+	/**
+    * 2nd-phase Constructor.
+    *
+    * @param aMsvSession	IN: a session handle to message store
+    */    
+    void ConstructL(CMsvSession &aMsvSession);
+	
+	/**
+    * Registers snapshot to ChangeFinder.
+    */
+	void RegisterSnapshotL() const;
+
+	/**
+    * Registers a single folder to snapshot, used by RegisterSnapshotL.
+    * 
+    * @param aSnapshot	IN: a snapshot item array.
+    * @param aId		IN: folder id.
+	* @return TInt, Not used.
+    */
+	TInt RegisterFolderL(CSnapshotArray* aSnapshot, const TMsvId& aId) const;
+	
+	/**
+    * Deletes all messages in a specified folder
+    * 
+    * @param aId	IN: a folder id, which is to be emptied
+	* @return TInt, not used.
+    */	
+	TInt DeleteAllMessagesInFolderL(TMsvId aId);
+	
+	/**
+    * Checks whether the specified MMS message exists in message store.
+    * 
+    * @param aId	IN: message ID
+	* @return TBool, ETrue if the item id exists in the message store. Otherwise EFalse.
+    */
+    TBool MmsItemExists(TMsvId aUid);
+	
+	/**
+    * This function resolves the status bits from the message entry
+    * 
+    * @param aUnread  IN: the status bits are determined from this value
+	* @return TUint8, Status byte.
+    */	
+	TUint8 ResolveStatusBits(TBool aUnread);
+	
+	/**
+    * This function reads data of opened message from MMS engine to client buffer.
+    * Data is retriveved from MMS engine in chunks whose size can be less that 
+    * client buffer size, for effectivity client buffer is allways filled with data.
+    * Recursive algorith is used for that.
+    * 
+    * @param aBuffer	   OUT: client data buffer
+	* @return TInt, KErrNone or KErrOverflow if all MMS message data has been read.
+    */		
+	TInt ReadDataRecursively(TDes8& aBuffer);
+	
+	/**
+    * This function updates MMS message status
+    * 
+    * @param aId  IN: Identifies MMS message in message store
+	* @param aUnread IN:  New status (unread/read)
+    */		
+	void UpdateMmsStatusL(TMsvId aId, TBool aUnread);
+	
+    /**
+    * Registers user folder messages to snapshot, used by RegisterSnapshotL.
+    * 
+    * @param aSnapshot	IN: a snapshot item array.
+	* @return TInt, Not used.
+    */	
+    TInt RegisterUserFoldersL(CSnapshotArray* aSnapshot) const;
+	
+    /**
+    * Cleans all user folders from SMS messages
+    *
+    * @return   KErrNone in case of success
+    */	   
+    TInt CleanUserFoldersL(); 
+	
+private: // Data members
+
+	/**
+	* @brief Data Store states:
+	* EMmsClosed:			Store is closed.
+    * EMmsOpenAndWaiting:	Store is ready to be used.
+    * EMmsItemOpen:			Item is being read.
+    * EMmsItemCreating:		Item is being created.
+    * EMmsItemUpdating:		Item is being updated.
+	*/
+    enum TState
+        {
+        EMmsClosed = 0,
+        EMmsOpenAndWaiting,
+        EMmsItemOpen,
+        EMmsItemOpenFieldUpdate,
+        EMmsItemCreating,
+        EMmsItemUpdating,
+        EFolderOpen,
+        EFolderCreating,
+        EFolderUpdating
+        };  	
+
+    /**
+	* A flag indicating the existence of synchronization history.
+	*/
+    TBool iHasHistory;
+    
+    /**
+	* Flag indicating, whether database is opened.
+	*/
+    TBool iDataBaseOpened;
+
+    /**
+	* The state of the active object.
+	*/
+	TState iCurrentState;	
+	
+    /**
+	* Access to streams, used by ChangeFinder.
+	*/
+    MSmlSyncRelationship* iContext;
+    
+    /**
+	* Key that is used in sorting snapshot.
+	*/
+    const TKeyArrayFix iKey;
+
+    /**
+	* Change finder, used to determine db modifications.
+	*/
+    CChangeFinder* iChangeFinder;
+            
+    /**
+	* Used to access MMS message store
+	*/
+    CMmsCodecClient* iCodecClient;
+    
+    /**
+	* Used to access message folders
+	*/    
+    CMmsAdapterMsvApi* iMsvApi;
+
+    /**
+	* Waiter object for asynchronous operations
+	*/
+    CMsvOperationActiveSchedulerWait* iMsvWait;
+
+    /**
+	* Message server session handle
+	*/
+    CMsvSession* iMsvSession;
+	
+    /**
+	* The location for temporary data
+	*/
+    CBufFlat* iDataBuffer;
+    
+    /**
+	* Counter of partial data reading
+	*/   
+    TInt iReadCounter;
+    
+    /**
+	* To store information whether current MMS message is unread
+	*/     
+    TBool iUnread;
+    
+    /**
+	* Data chunk used in partial data reading from MMS engine
+	*/        
+    TPtrC8 iReadDataChunk;
+    
+    /**
+	* Current read position at the data chunk from MMS engine
+	*/      
+    TInt iReadPosition;
+
+    /**
+	* Indicates wheter this is the last data chunk from MMS engine
+	*/        
+    TBool iLastDataChunk;
+    
+    /**
+	* Indicates whether all data related to current message has been read
+	*/         
+    TBool iReadAllData;
+    
+    /**
+	* Counter of partial data writing
+	*/   
+    TInt iWriteCounter;
+    
+    /**
+	* Indicates wheter this was only status update
+	*/      
+    TInt iWrittenDataLength;
+
+    /**
+	* Stores the currently active message id.
+	*/
+    TMsvId iCurrentId;
+    
+    /**
+	* Pointer to the variable, receiving the created Uid.
+	*/
+	TSmlDbItemUid* iCreatedUid;  
+
+    /**
+	* Stores the parent id of currently active message.
+	*/
+    TMsvId iParentId;
+
+    /**
+	* Used to get asynchronous return values.
+	*/
+    TRequestStatus*  iCallerStatus;
+    
+    /**
+	* Used to store new items.
+	*/
+	CNSmlDataItemUidSet* iNewItems;
+
+    /**
+	* Used to store deleted items.
+	*/
+    CNSmlDataItemUidSet* iDeletedItems;
+
+    /**
+	* Used to store updated items.
+	*/
+    CNSmlDataItemUidSet* iUpdatedItems;
+
+    /**
+	* Used to store moved items.
+	*/
+    CNSmlDataItemUidSet* iMovedItems;
+
+    /**
+	* Used to store soft-deleted items (not supported).
+	*/
+    CNSmlDataItemUidSet* iSoftDeletedItems;
+    
+    /**
+	* Used to parse OMA DS Folder Objects
+	*/    
+    COMADSFolderObject* iFolderObjectParser;   
+
+    /**
+	* Reserved pointer for future extension.
+	*/
+    TAny* iReserved;
+    };
+
+#endif // __MMSDATASTORE_H__  
+            
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/omadsfolderobject.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+
+#ifndef __OMADSFOLDEROBJECT_H__
+#define __OMADSFOLDEROBJECT_H__
+
+#include <SenXmlReader.h>
+#include <MSenContentHandlerClient.h>
+#include "mmsdataproviderdefs.h"
+
+const TInt KMaxElementLength = 255;
+const TInt KMaxXmlLineLength = 1024;
+
+class COMADSFolderObject : public CBase, public MSenContentHandlerClient
+    {
+public:
+
+    static COMADSFolderObject* NewLC();
+    static COMADSFolderObject* NewL();
+    ~COMADSFolderObject();
+
+    // Get methods
+    inline const TDesC& GetName() const {return iName;}
+    inline const TDateTime& GetCreatedDate() const {return iCreatedDate;}
+    inline const TDateTime& GetModifiedDate() const {return iModifiedDate;}
+
+    // Set methods
+    inline void SetName(const TDesC& aName) {iName.Copy(aName);}
+    inline void SetCreatedDate(const TDateTime& aDateTime) {iCreatedDate = aDateTime;}
+    inline void SetModifiedDate(const TDateTime& aDateTime) {iModifiedDate = aDateTime;}
+
+    // Import & export
+    TInt ImportFolderXml(const TDesC8& aData);
+    TInt ImportFolderXml(RFs& aFs, const TDesC& aFilename);
+    void ExportFolderXmlL(TDes8& aBuffer);
+    void ExportFolderXmlL(CBufBase& aBuffer);    
+
+    // MSenContentHandlerClient virtual functionality
+    TInt StartDocument();
+    TInt EndDocument();
+    TInt StartElement(const TDesC8& aURI, 
+    				  const TDesC8& aLocalName, 
+    				  const TDesC8& aName, 
+    				  const RAttributeArray& apAttrs);
+    TInt EndElement(const TDesC8& aURI, 
+    				const TDesC8& aLocalName, 
+    				const TDesC8& aName);
+    TInt Characters(const TDesC8& aBuf, TInt aStart, TInt aLength);
+    TInt Error(TInt aErrorCode);
+
+private:
+
+    CSenXmlReader* iXmlReader;
+    void ConstructL();
+    TBuf8<KMaxElementLength> iCurrentElement;
+    TBuf8<KMaxXmlLineLength> iTemp;
+
+    TBuf<KMaxFolderNameLength> iName;
+    TDateTime iCreatedDate;
+    TDateTime iModifiedDate;
+    TInt iError;
+
+    void Reset();
+    TInt ParseDateString(const TDesC8& aString, TDateTime& aDateTime);	
+
+    CBufBase* iBuffer;
+    TInt iWriteBufPosition;
+    TInt iWriteBufSize;
+    TDes8* iDesc;
+
+    void ExportL();	
+    void WriteL(const TDesC &aData);
+    void WriteEncodedXmlL(const TDesC &aData);
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/inc/snapshotitem.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Private snapshot item header
+*
+*/
+
+
+#ifndef __SNAPSHOTITEM_H__
+#define __SNAPSHOTITEM_H__
+
+// INCLUDES
+#include <msvids.h>
+#include <nsmlsnapshotitem.h>
+#include "mmsdataproviderdefs.h"
+
+typedef TBuf<KMaxFolderNameLength> TFolderName;
+
+// CLASS DECLARATION
+
+/**
+* @brief TSnapshotItem
+* This class represents a single item in the ChangeFinder snapshot.
+* It's derived from the generic snapshot item and extended
+* to contain the read/unread information, which is mandatory when 
+* partial update of the messages is required.
+*/
+
+class TSnapshotItem : public TNSmlSnapshotItem
+	{ 
+public:
+	
+	/**
+    * Constructor
+    */
+	TSnapshotItem();
+
+	/**
+    * Constructor
+    * 
+    * @param aItemId   IN: id of the item.
+    * @param aParent   IN: parent item, 0 as default.
+    * @param aUnread   IN: read/unread information, the default is read.
+    */
+	TSnapshotItem( const TSmlDbItemUid& aItemId,
+	    const TSmlDbItemUid& aParent = 0, TBool aUnread = EFalse );
+	
+	/**
+    * Writes the item to a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is to be written.
+    */
+	void ExternalizeL( RWriteStream& aStream ) const;
+
+	/**
+    * Reads item from a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is read from.
+    */
+	void InternalizeL( RReadStream& aStream );	
+	
+	/**
+    * Sets the read flag
+    * 
+    * @param aState   IN: a new state.
+    */
+	void SetUnread( TBool aState ); 
+	
+	/**
+    * Sets the read flag
+    * 
+    * @return TBool, ETrue if the item is not read and EFalse if it has been read.
+    */
+	TBool Unread() const;	
+	
+	void SetFolderNameL( const TDesC& aFolderName );
+	
+	const TDesC& FolderName() const;
+	
+private:
+
+    /**
+    * Read / Unread information
+    */
+	TBool       iUnread;
+	
+	TFolderName iFolderName;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/rom/mmsdsa.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for MMS DS adapter binaries
+*
+*/
+
+
+#ifndef __MMSDSA_IBY__
+#define __MMSDSA_IBY__
+
+ECOM_PLUGIN(mmsdataprovider.dll,mmsdataprovider.rsc)
+data=DATAZ_\RESOURCE_FILES_DIR\mmsdatastore.rsc         RESOURCE_FILES_DIR\mmsdatastore.rsc
+data=DATAZ_\private\101F99F6\capability\101FB0E9.XML    private\101F99F6\capability\101FB0E9.XML
+
+data=ZSYSTEM\install\mmsdsa_stub.sis             	    system\install\mmsdsa_stub.sis
+
+#endif //__MMSDSA_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/changefinder.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,697 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include "changefinder.h"
+#include "logger.h"
+
+const TUint KSnapshotFormatVersion ( 0xf0000001 ); // format version
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::NewL
+// Static function to create CChangeFider object(s)
+// -----------------------------------------------------------------------------
+CChangeFinder* CChangeFinder::NewL( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey,
+        TBool& aHasHistory, TInt aStreamUid )
+    {
+    CChangeFinder* self = new (ELeave) CChangeFinder( aSyncRelationship, aKey, aStreamUid );
+    CleanupStack::PushL( self );
+    self->ConstructL( aHasHistory );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CChangeFinder
+// Constructor for the class
+// -----------------------------------------------------------------------------
+CChangeFinder::CChangeFinder( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey, TInt aStreamUid ) :
+iSyncRelationship( aSyncRelationship ),
+iKey( aKey ),
+iStreamUid( aStreamUid ),
+iDataStoreUid( KErrNotFound )
+    {
+        
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::~CChangeFinder
+// Destructor for the class, closes the ChangeFinder and writes snapshot to stream
+// -----------------------------------------------------------------------------
+CChangeFinder::~CChangeFinder()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::~CChangeFinder" );
+    TInt error;
+    TRAP( error, CloseL() );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE( "CChangeFinder::~CChangeFinder, CloseL failed." );
+        }
+    
+    delete iCurrentSnapshot;
+    delete iOldSnapshot;
+    
+    LOGGER_LEAVEFN( "CChangeFinder::~CChangeFinder" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ConstructL
+// 2nd phase constructor for the class, reads snapshot from stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::ConstructL( TBool& aHasHistory )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ConstructL" );
+        
+    aHasHistory = EFalse;
+    RReadStream readStream;
+    
+    TUid streamId;
+    streamId.iUid = iStreamUid;
+    
+    aHasHistory = iSyncRelationship.IsStreamPresentL(streamId);
+    
+    if (aHasHistory)
+        {
+        iSyncRelationship.OpenReadStreamLC(readStream, streamId);
+        
+        // Read the index, first create snapshot array
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        
+        // Read used format version
+        TUint formatVer = readStream.ReadUint32L();
+        if ( formatVer != KSnapshotFormatVersion )
+            {
+            // Wrong version, do not try to import data
+            LOGGER_WRITE("CChangeFinder::ConstructL, Wrong format version -> no history");
+            aHasHistory = EFalse;
+            CleanupStack::PopAndDestroy(); // readStream
+            LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+            return;
+            }
+        
+        // Read item count
+        TInt count = readStream.ReadUint32L();
+        
+        // Read items
+        for ( TInt i=0; i<count; i++ )
+            {
+            TSnapshotItem item;
+            item.InternalizeL( readStream );
+            iOldSnapshot->InsertIsqL( item, iKey );
+            }
+
+        readStream.Close();
+        readStream.Pop();
+        }
+    else
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, no sync history.");
+        }
+        
+    LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CloseL
+// Closes ChangeFinder object and writes snapshot to stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::CloseL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CloseL" );
+    
+    // Write to stream
+    RWriteStream writeStream;
+    
+    TUid streamId;
+    streamId.iUid = iStreamUid; 
+
+    // Open write stream
+    iSyncRelationship.OpenWriteStreamLC( writeStream, streamId );
+    
+    // Write used format version
+    writeStream.WriteUint32L( KSnapshotFormatVersion );
+
+    // Write item count
+    TInt count(0);
+    if ( iOldSnapshot )
+        {
+        count = iOldSnapshot->Count();
+        }
+    writeStream.WriteUint32L(count);
+    
+    // Write items
+    for (TInt i=0; i<count; i++)
+        {
+        const TSnapshotItem& item = iOldSnapshot->At( i );
+        item.ExternalizeL( writeStream );
+        }
+
+    writeStream.CommitL();
+    writeStream.Close();
+    writeStream.Pop();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::CloseL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ResetL
+// Resets synchronization history, all contetn is considered new after this call
+// -----------------------------------------------------------------------------
+void CChangeFinder::ResetL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ResetL" );
+    // Delete old change information
+    if ( iOldSnapshot )
+        {
+        LOGGER_WRITE("iOldSnapshot->Reset()");
+        iOldSnapshot->Reset();
+        }
+    
+    // Write 'null' data to file, 
+    // this removes change history from the file
+    CloseL();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ResetL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindChangedItemsL
+// Compares snapshots, finds changed items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids )
+    {   
+    LOGGER_ENTERFN( "CChangeFinder::FindChangedItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        // Find this entry from the old snapshot
+        if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            // Compare times to see whether this was changed or item was read
+            if ( ( oldItem.LastChangedDate() != currentItem.LastChangedDate() )
+                || ( oldItem.Unread() && !currentItem.Unread() )
+                || ( !oldItem.Unread() && currentItem.Unread() )
+                || ( oldItem.FolderName().Compare( currentItem.FolderName() ) != 0 ) )
+                {
+                aChangedUids.AddItem( currentItem.ItemId() );
+                LOGGER_WRITE_1( "Item %d was changed.", currentItem.ItemId() );  
+                }
+            }
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindChangedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindDeletedItemsL
+// Compares snapshots, finds deleted items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindDeletedItemsL" );
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iOldSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iOldSnapshot->At( i );
+        
+        // If there's no current snapshot, this definately is deleted item
+        if ( !iCurrentSnapshot )
+            {
+            aDeletedUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the current snapshot.
+        else if ( iCurrentSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            aDeletedUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindNewItemsL
+// Compares snapshots, finds new items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindNewItemsL( CNSmlDataItemUidSet& aNewUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindNewItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindNewItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // If there's no old snapshot, all items are new
+        if ( !iOldSnapshot )
+            {
+            aNewUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was new.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the old snapshot.
+        else if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            aNewUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was new.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindNewItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindMovedItemsL
+// Compares snapshots, finds moved items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindMovedItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // Find this entry from the old snapshot
+        if(iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            
+            // Report only moved items in which only parent id has been changed
+            if ( oldItem.ParentId() != currentItem.ParentId()
+                && oldItem.LastChangedDate() == currentItem.LastChangedDate()
+                && !(oldItem.Unread() && !currentItem.Unread() )
+                && !(!oldItem.Unread() && currentItem.Unread() ) )
+                {
+                aMovedUids.AddItem( currentItem.ItemId() );
+                LOGGER_WRITE_1( "Item %d was moved.", currentItem.ItemId() );
+                }
+            }       
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindMovedItemsL" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemAddedL
+// Adds item to snapshot, this item is no longer considered new
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemAddedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemAddedL" );
+    
+    // Add this to old snapshot, if there's no old snapshot it must be created
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    LOGGER_WRITE_1( "Adding item %d.", aItem.ItemId() );
+    
+    TRAPD( error, iOldSnapshot->InsertIsqL( aItem, iKey ) );
+    if ( error == KErrAlreadyExists )
+        {
+        // It was already committed, no actions required
+        LOGGER_WRITE( "iOldSnapshot->InsertIsqL leaved with KErrAlreadyExists" );
+        }
+    else if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "iOldSnapshot->InsertIsqL leaved with %d.", error );
+        User::Leave( error );
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::ItemAddedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemDeletedL
+// Removes item to snapshot, this item is no longer considered deleted
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemDeletedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemDeleted" );
+    
+    LOGGER_WRITE_1( "deleting item %d.", aItem.ItemId() );
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::ItemDeleted leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    // Delete item from the old snapshot
+    TInt index;
+    if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+        {
+        iOldSnapshot->Delete( index );
+        }
+    else // Skip, there wasn't such entry
+        {
+        LOGGER_WRITE( "iOldSnapshot->FindIsq, item was not found." );
+        }  
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ItemDeleted" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemUpdatedL
+// Updates item to snapshot, this item is no longer considered changed
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemUpdatedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemUpdatedL" );
+
+    LOGGER_WRITE_1( "Updating item %d.", aItem.ItemId() );
+    
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            oldItem = aItem;
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }
+        
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::ItemUpdatedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemMovedL
+// Moves item within snapshot, this item is no longer considered moved
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemMovedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemMovedL" );
+    
+    LOGGER_WRITE_1( "Moving item %d.", aItem.ItemId() );
+            
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item's parent in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            oldItem.SetParentId( aItem.ParentId() );
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }   
+        }
+    
+    LOGGER_LEAVEFN("CChangeFinder::ItemMovedL");    
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    // Delete everything from the old snapshot
+    iOldSnapshot->Reset();
+    
+    // Loop through all the items in current snapshot
+    TInt count = iCurrentSnapshot->Count();
+    
+    // Copy everything from current to old snapshot
+    for ( TInt i=0; i < count; i++ )
+        {   
+        const TSnapshotItem& newItem = iCurrentSnapshot->At( i );
+
+        // Commit it to the old array.
+        TRAPD( error, iOldSnapshot->InsertIsqL( newItem, iKey ) );
+        if ( error == KErrAlreadyExists )
+            {
+            // It was already committed, this is an internal error of change finder
+            LOGGER_WRITE( "iOldSnapshot->InsertIsqL leaved with KErrAlreadyExists." );
+            User::Leave( error );
+            }
+        else if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1( "iOldSnapshot->InsertIsqL leaved with %d.", error );
+            User::Leave( error );
+            }
+        }
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot, affects only a specified group of items
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL( const MSmlDataItemUidSet& aUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    // This function commits changes from current snapshot to old snapshot
+    // But commits only the entries in the parameter array
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    // Use only these uid values
+    TInt index;
+    TInt count = aUids.ItemCount();
+    
+    for ( TInt i=0; i < count; i++ )
+        {
+        TSmlDbItemUid uid = aUids.ItemAt( i );
+        TSnapshotItem item( uid );
+        // Let's see if this uid exists in the current snapshot
+        if ( iCurrentSnapshot->FindIsq( item, iKey, index ) == KErrNone )
+            {
+            // This is the new item
+            const TSnapshotItem& newItem = iCurrentSnapshot->At( index );
+            
+            // Let's see if we can find the old one
+            if ( iOldSnapshot->FindIsq( item, iKey, index ) == KErrNone )
+                {
+                // This is the old item
+                TSnapshotItem& oldItem = iOldSnapshot->At( index );
+                
+                // Copy new item over the old one, this'll commit the change
+                oldItem = newItem;
+                }
+            else // This entry was not found. It means that it is new one
+                {
+                // Commit it to the old array.
+                ItemAddedL( newItem );
+                }
+            }
+        else 
+            {
+            // This item was deleted from the current snapshot.
+            TSnapshotItem toDelete( item );
+            ItemDeletedL( toDelete );
+            } 
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetNewSnapshot
+// Sets new snapshot (to be compared against), ChangeFinder takes ownership
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetNewSnapshot( CSnapshotArray* aNewSnapshot )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetNewSnapshot" );
+    
+    // Delete existing snapshot
+    delete iCurrentSnapshot;
+    
+    // Set submitted snapshot as active
+    iCurrentSnapshot = aNewSnapshot;
+    LOGGER_LEAVEFN( "CChangeFinder::SetNewSnapshot" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::DataStoreUid
+// returns stored data store id number
+// -----------------------------------------------------------------------------
+TInt64 CChangeFinder::DataStoreUid() const
+    {
+    LOGGER_ENTERFN( "CChangeFinder::DataStoreUid" );
+    LOGGER_LEAVEFN( "CChangeFinder::DataStoreUid" );
+    return iDataStoreUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetDataStoreUid
+// Sets data store id number
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetDataStoreUid( TInt64 aUid )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetDataStoreUid" );
+    iDataStoreUid = aUid;
+    LOGGER_LEAVEFN( "CChangeFinder::SetDataStoreUid" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::UpdatePartialL
+// Returns ETrue if item can be updated partially (only status bits are changed)
+// -----------------------------------------------------------------------------
+TBool CChangeFinder::UpdatePartialL( TSmlDbItemUid& aUid )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::UpdatePartialL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::UpdatePartialL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+
+    if ( !iOldSnapshot )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+        
+    TInt index;
+    TSnapshotItem item( aUid );
+    // Find from current snapshot, if not found -> deleted
+    if ( iCurrentSnapshot->FindIsq( item, iKey, index ) != KErrNone )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }   
+        
+    // Current item 
+    const TSnapshotItem& currentItem = iCurrentSnapshot->At( index );
+    
+    // Old item, if not found -> added
+    if ( iOldSnapshot->FindIsq( item, iKey, index ) != KErrNone )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+    else
+        {
+        // This is the old item
+        TSnapshotItem& oldItem = iOldSnapshot->At( index );
+        
+        // Status bits must have been changed to allow partial update
+        if ( oldItem.Unread() == currentItem.Unread() )
+            {
+            LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+            return EFalse;
+            }
+            
+        // Date should be same, otherwise 'just' changed item
+        if ( oldItem.LastChangedDate() == currentItem.LastChangedDate() )
+            {
+            LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+            return ETrue;
+            }
+        
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsadaptermsvapi.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,316 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <msvapi.h>
+#include <msvuids.h>
+#include <msvstd.h>
+#include <msvids.h>
+#include "mmsadaptermsvapi.h" 
+#include "logger.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::NewL
+// -----------------------------------------------------------------------------
+//
+ CMmsAdapterMsvApi* CMmsAdapterMsvApi::NewL( CMsvSession& aMsvSession )
+    {
+    CMmsAdapterMsvApi* self = new( ELeave ) CMmsAdapterMsvApi( aMsvSession );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::~CMmsAdapterMsvApi()
+// -----------------------------------------------------------------------------
+//
+CMmsAdapterMsvApi::~CMmsAdapterMsvApi()
+    {
+    LOGGER_ENTERFN( "CMmsAdapterMsvApi::~CMmsAdapterMsvApi" );
+    LOGGER_LEAVEFN( "CMmsAdapterMsvApi::~CMmsAdapterMsvApi" );
+    }
+       
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::CMmsAdapterMsvApi
+// -----------------------------------------------------------------------------
+//
+CMmsAdapterMsvApi::CMmsAdapterMsvApi( CMsvSession& aMsvSession ):
+    iSession( aMsvSession )
+    { 
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CMmsAdapterMsvApi::ConstructL()
+    {
+    LOGGER_ENTERFN( "CMmsAdapterMsvApi::ConstructL" );
+    LOGGER_LEAVEFN( "CMmsAdapterMsvApi::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::DeleteUserFolderL
+// -----------------------------------------------------------------------------
+//
+ TInt CMmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
+    {
+    LOGGER_ENTERFN( "MsvApi::DeleteUserFolderL" );
+    
+    CMsvEntry* entry = iSession.GetEntryL(aUid);
+    CleanupStack::PushL(entry);
+    
+    TMsvEntry tEntry = entry->Entry();
+    TMsvId parent = tEntry.Parent();        
+    
+    if ( tEntry.iType != KUidMsvFolderEntry || parent != KMsvMyFoldersEntryIdValue )
+        {
+        LOGGER_WRITE( "Not correct folder" );
+        CleanupStack::PopAndDestroy(entry);
+        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
+        return KErrNotSupported;
+        }
+        
+    CMsvEntrySelection* children = entry->ChildrenL();
+    TInt count = children->Count();
+    delete children;
+    
+    if ( count > 0 )
+        {
+        LOGGER_WRITE( "Folder not empty" );
+        CleanupStack::PopAndDestroy( entry );
+        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
+        return KErrInUse;
+        }
+        
+    tEntry.SetReadOnly( EFalse );
+    entry->ChangeL( tEntry );
+    
+    entry->SetEntryL( parent );
+    entry->DeleteL( aUid );
+    
+    CleanupStack::PopAndDestroy( entry );
+    LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
+    return KErrNone;
+    }   
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::ValidUserFolder
+// -----------------------------------------------------------------------------
+//
+TBool CMmsAdapterMsvApi::ValidFolderL( TMsvId aFolder, TBool aOutboxValid )
+    {
+    TBool valid(EFalse);
+    
+    switch ( aFolder )
+        {
+        case KMsvGlobalInBoxIndexEntryId:
+            valid = ETrue;  
+            break;
+        case KMsvDraftEntryId:
+           valid = ETrue;  
+           break;        
+        case KMsvSentEntryId:
+           valid = ETrue;  
+           break;
+        case KMsvGlobalOutBoxIndexEntryId:
+            if ( aOutboxValid )
+                {
+                valid = ETrue;
+                }
+            break;
+        case KMsvMyFoldersEntryIdValue:
+            valid = ETrue;
+            break;
+        default:
+            valid = FindUserFolderL( aFolder );
+        }
+    
+    return valid;          
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CMmsAdapterMsvApi::FindUserFolderL( TMsvId aFolder, TPtrC& aName, TTime& aDate )
+    {
+    TBool found( EFalse );
+    
+    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL( entry );
+     
+    CMsvEntrySelection* selection = entry->ChildrenL();
+    CleanupStack::PushL( selection );
+    
+    TMsvId serviceId;
+    TMsvEntry entryT;
+
+    for ( TInt i = 0; i < selection->Count(); i++ )
+        {
+        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
+        
+        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && entryT.Id() == aFolder )
+            {
+            found = ETrue;
+            aDate = entryT.iDate;
+            aName.Set( entryT.iDetails );
+            break;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( selection );
+    CleanupStack::PopAndDestroy( entry ); 
+    
+    return found;        
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CMmsAdapterMsvApi::FindUserFolderL( TMsvId aFolder )
+    {
+    TPtrC name;
+    TTime time;
+    
+    return FindUserFolderL( aFolder, name, time ); 
+    }    
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CMmsAdapterMsvApi::FindUserFolderL( const TDesC& aName, TMsvId& aFolder )
+    {
+    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL( entry );
+     
+    CMsvEntrySelection* selection = entry->ChildrenL();
+    CleanupStack::PushL( selection );
+    
+    TBool found( EFalse );
+    TMsvId serviceId;
+    TMsvEntry entryT;
+
+    for ( TInt i = 0; i < selection->Count(); i++ )
+        {
+        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
+        
+        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && 
+            aName.Compare(entryT.iDescription) == 0 )
+            {
+            found = ETrue;
+            aFolder = entryT.Id();
+            break;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( selection );
+    CleanupStack::PopAndDestroy( entry );
+    
+    return found;           
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::AddUserFolderL
+// Creates new user folder
+// -----------------------------------------------------------------------------        
+TInt CMmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName )
+    {
+    LOGGER_ENTERFN( "CMmsAdapterMsvApi::AddUserFolderL" );
+    LOG(aName);
+        
+    // Make sure that we are not going to add same folder twise
+    TBool found( EFalse );
+    found = FindUserFolderL( aName, aFolder );
+    if ( found )
+        {
+        LOGGER_WRITE( "Folder already exists" );
+        LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" );
+        return KErrNone;
+        } 
+        
+    CMsvEntry* entry = iSession.GetEntryL(KMsvMyFoldersEntryIdValue);
+    CleanupStack::PushL( entry );
+    
+    TTime date;
+    date.UniversalTime();    
+    
+    TMsvEntry folderEntry;
+    folderEntry.iType = KUidMsvFolderEntry;
+    folderEntry.iMtm = KUidMsvLocalServiceMtm;
+    folderEntry.iDetails.Set( aName );   
+    folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue;
+    folderEntry.iSize = sizeof( folderEntry );
+    folderEntry.iDate = date;
+    folderEntry.SetStandardFolder( EFalse );
+    folderEntry.SetVisible( ETrue );
+    folderEntry.SetComplete( ETrue );
+    folderEntry.SetInPreparation( EFalse ); 
+    folderEntry.SetReadOnly( EFalse );
+    
+    entry->CreateL( folderEntry );
+    CleanupStack::PopAndDestroy( entry );
+    
+    aFolder = folderEntry.Id();
+    
+    LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" );
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::UpdateUserFolderL
+// Updates user folder (changes name)
+// -----------------------------------------------------------------------------    
+TInt CMmsAdapterMsvApi::UpdateUserFolderL( TMsvId aFolder, const TDesC& aName )
+    {
+    LOGGER_ENTERFN( "CMmsAdapterMsvApi::UpdateUserFolderL" );
+    LOG( aName );
+    
+    CMsvEntry* entry = iSession.GetEntryL( aFolder );
+    CleanupStack::PushL( entry );
+    
+    TMsvEntry tEntry = entry->Entry();
+    
+    if ( tEntry.iType != KUidMsvFolderEntry )
+        {
+        CleanupStack::PopAndDestroy( entry );
+        LOGGER_WRITE( "No message folder" );
+        LOGGER_LEAVEFN( "CMmsAdapterMsvApi::UpdateUserFolderL" );
+        return KErrNotSupported;
+        }
+       
+    tEntry.iDetails.Set( aName );   
+    tEntry.iDescription.Set( aName );
+    
+    entry->ChangeL( tEntry );
+    
+    CleanupStack::PopAndDestroy( entry );
+    
+    LOGGER_LEAVEFN( "CMmsAdapterMsvApi::UpdateUserFolderL" );
+    return KErrNone;
+    } 
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsdataprovider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,331 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+  
+#include <f32file.h>
+#include <msvstd.h>
+#include <msvapi.h>    
+#include <bautils.h>
+#include <barsc.h> 
+#include <stringpool.h> 
+#include <data_caging_path_literals.hrh>
+#include <mmsdatastore.rsg>
+#include <SmlDataFormat.h>
+#include <ecom/implementationproxy.h>
+#include "mmsdataprovider.h"
+#include "mmsdataproviderdefs.h"
+#include "mmsdatastore.h"
+#include "logger.h"
+
+
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::CMmsDataProvider
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CMmsDataProvider::CMmsDataProvider() :
+    iOwnStoreFormat(NULL),
+    iFilters(1),
+    iMsvSession(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CMmsDataProvider::ConstructL()
+    {
+    LOGGER_ENTERFN( "CMmsDataProvider::ConstructL" ); 
+    
+    iMsvSession = CMsvSession::OpenSyncL( *this );
+    iRFs = iMsvSession->FileSession();
+    iStringPool.OpenL();
+
+    LOGGER_LEAVEFN( "CMmsDataProvider::ConstructL" )
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CMmsDataProvider* CMmsDataProvider::NewL()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::NewL()"); 
+    
+    CMmsDataProvider* self = new (ELeave) CMmsDataProvider;
+   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    LOGGER_LEAVEFN("CMmsDataProvider::NewL()"); 
+    return self;  
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::~CMmsDataProvider
+// Destructor.
+// -----------------------------------------------------------------------------
+CMmsDataProvider::~CMmsDataProvider()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::~CMmsDataProvider()");
+    
+    delete iOwnStoreFormat; 
+    delete iMsvSession;
+    
+    iStringPool.Close();
+    
+    iFilters.ResetAndDestroy();
+    iFilters.Close();
+    
+    LOGGER_LEAVEFN("CMmsDataProvider::~CMmsDataProvider()");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::HandleSessionEventL
+// virtual function from MMsvSessionObserver, does nothing
+// -----------------------------------------------------------------------------
+void CMmsDataProvider::HandleSessionEventL(TMsvSessionEvent /*aEvent*/,
+    TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/ )
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::HandleSessionEventL()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::HandleSessionEventL()"); 
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoOnFrameworkEvent
+// Not used
+// -----------------------------------------------------------------------------
+void CMmsDataProvider::DoOnFrameworkEvent(TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/)
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoOnFrameworkEvent()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::DoOnFrameworkEvent()"); 
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoSupportsOperation
+// Checks whether data provider supports specific operation
+// -----------------------------------------------------------------------------
+TBool CMmsDataProvider::DoSupportsOperation(TUid /*aOpId*/) const 
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoSupportsOperation()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::DoSupportsOperation()"); 
+    
+    // Optional operations are not supported
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+const CSmlDataStoreFormat& CMmsDataProvider::DoStoreFormatL()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoStoreFormatL()"); 
+    
+    if ( !iOwnStoreFormat )
+        {
+        iOwnStoreFormat = DoOwnStoreFormatL();
+        }
+    
+    LOGGER_LEAVEFN("CMmsDataProvider::DoStoreFormatL()"); 
+    
+    return *iOwnStoreFormat;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoListStoresLC
+// Returns array fo data stores, not implemented because only single data store
+// is supported
+// -----------------------------------------------------------------------------
+CDesCArray* CMmsDataProvider::DoListStoresLC()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoListStoresLC()");
+    
+    CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(1);
+    CleanupStack::PushL( stores );
+    stores->AppendL( KNSmlDefaultLocalDbName );   
+    
+    LOGGER_LEAVEFN("CMmsDataProvider::DoListStoresLC()");
+    
+    return stores;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoDefaultStoreL
+// Returns the name of the default data store
+// -----------------------------------------------------------------------------
+const TDesC& CMmsDataProvider::DoDefaultStoreL()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoDefaultStoreL()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::DoDefaultStoreL()"); 
+    return KNSmlDefaultLocalDbName;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoNewStoreInstanceLC
+// Creates a new data store object, which can be used for synchronization
+// ----------------------------------------------------------------------------- 
+CSmlDataStore* CMmsDataProvider::DoNewStoreInstanceLC()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoNewStoreInstanceLC");
+    CMmsDataStore* newStore = CMmsDataStore::NewL( *iMsvSession );
+    CleanupStack::PushL(newStore);
+    LOGGER_LEAVEFN("CMmsDataProvider::DoNewStoreInstanceLC");
+    return newStore;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoCheckSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMmsDataProvider::DoCheckSupportedServerFiltersL(
+    const CSmlDataStoreFormat& /*aServerDataStoreFormat*/,
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoCheckSupportedServerFiltersL()"); 
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoCheckServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMmsDataProvider::DoCheckServerFiltersL(
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/)
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoCheckServerFiltersL()"); 
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+const RPointerArray<CSyncMLFilter>& CMmsDataProvider::DoSupportedServerFiltersL()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoSupportedServerFiltersL()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::DoSupportedServerFiltersL()"); 
+    return iFilters; // empty array
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoSupportsUserSelectableMatchType
+// Not supported
+// -----------------------------------------------------------------------------        
+TBool CMmsDataProvider::DoSupportsUserSelectableMatchType() const
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoSupportsUserSelectableMatchType()"); 
+    LOGGER_LEAVEFN("CMmsDataProvider::DoSupportsUserSelectableMatchType()"); 
+    return EFalse;
+    }           
+    
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoGenerateRecordFilterQueryLC
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+HBufC* CMmsDataProvider::DoGenerateRecordFilterQueryLC(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/,
+    TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoGenerateRecordFilterQueryLC()"); 
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoGenerateFieldFilterQueryL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMmsDataProvider::DoGenerateFieldFilterQueryL(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/,
+    RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/)
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoGenerateFieldFilterQueryL()"); 
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataProvider::DoOwnStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+CSmlDataStoreFormat* CMmsDataProvider::DoOwnStoreFormatL()
+    {
+    LOGGER_ENTERFN("CMmsDataProvider::DoOwnStoreFormatL()"); 
+    
+    TParse* parse = new ( ELeave ) TParse();
+    CleanupStack::PushL(parse);
+    TFileName fileName;
+    RResourceFile resourceFile;
+    
+    parse->Set( KMmsStoreFormatRscRom, &KDC_RESOURCE_FILES_DIR, NULL );
+    fileName = parse->FullName();
+    BaflUtils::NearestLanguageFile( iRFs, fileName );
+    
+    TRAPD( error, resourceFile.OpenL( iRFs, fileName ) );
+    if ( error )
+        {
+        LOGGER_MSG_EC( "RResourceFile::OpenL leaved with %d - try again", error );
+        parse->Set( KMmsStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL );
+        fileName = parse->FullName();
+        BaflUtils::NearestLanguageFile( iRFs, fileName );
+        resourceFile.OpenL( iRFs, fileName );
+        }
+    CleanupClosePushL( resourceFile );
+
+    HBufC8* buffer = resourceFile.AllocReadLC( MMS_DATA_STORE );
+    
+    TResourceReader reader;
+    reader.SetBuffer( buffer );
+
+    CSmlDataStoreFormat* dsFormat = NULL;
+    dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+    
+    CleanupStack::Pop( dsFormat );
+    CleanupStack::PopAndDestroy( buffer );
+    CleanupStack::PopAndDestroy( &resourceFile );
+    CleanupStack::PopAndDestroy( parse );
+    
+    LOGGER_LEAVEFN("CMmsDataProvider::DoOwnStoreFormatL()"); 
+    
+    return dsFormat;
+    }
+
+
+// -----------------------------------------------------------------------------
+// ImplementationTable
+// Required by ECom plugin interface, tells the entry point of the library
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KMmsDataProviderImplUid, CMmsDataProvider::NewL)
+    };
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Returns the implementation table, required by the ECom plugin interface
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsdataprovider.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for MMS DS ECOM plug-in
+*
+*/
+
+
+#include <ecom/registryinfo.rh> 
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101FB0E9; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x101F4D3A; // Constant for all DS plug ins
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101FB0E9; // DS interface implementation UID
+                version_no = 1; 
+                display_name = "Multimedia messages"; // shown in UI
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsdatastore.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1783 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <e32base.h>      
+#include <msvstd.h>       
+#include <msvapi.h>       
+#include <msvids.h>
+#include <mtclreg.h> 
+#include <mmsconst.h>
+#include <centralrepository.h>
+#include <mmscodecclient.h>
+#include <sysutil.h>
+#include <MmsEngineInternalCRKeys.h>
+
+#include "mmsdatastore.h"
+#include "omadsfolderobject.h"
+#include "mmsadaptermsvapi.h"
+#include "mmsdataproviderdefs.h"
+#include "logger.h"
+
+_LIT8( KMmsMimeType, "application/vnd.wap.mms-message" );
+_LIT8( KMmsMimeVersion, "1.2" );
+_LIT8( KFolderMimeType, "application/vnd.omads-folder+xml" );
+_LIT8( KFolderMimeVersion, "1.2" );
+
+const TInt KDataBufferSize = 1024;
+const TUint KMMS_Flag_Read = 0x01;
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::CMmsDataStore
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+CMmsDataStore::CMmsDataStore():
+    iHasHistory(EFalse),
+    iDataBaseOpened(EFalse),
+    iKey(TKeyArrayFix(_FOFF(TSnapshotItem, ItemId()), ECmpTInt))
+    { 
+    }
+  
+// -----------------------------------------------------------------------------
+// CMmsDataStore::ConstructL
+// Symbian 2nd phase constructor, can leave.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::ConstructL(CMsvSession &aMsvSession)
+    {
+    LOGGER_ENTERFN("CMmsDataStore::ConstructL");
+    
+    iMsvSession = &aMsvSession;
+    
+    // Waiter object to be used with CodecClient
+    iMsvWait = CMsvOperationActiveSchedulerWait::NewLC();
+    CleanupStack::Pop( iMsvWait );
+    iCodecClient = CMmsCodecClient::NewL( *iMsvSession );
+    iMsvApi = CMmsAdapterMsvApi::NewL( *iMsvSession );
+    
+    // Item UID sets, used to transfer change info
+    iNewItems = new (ELeave) CNSmlDataItemUidSet;
+    iDeletedItems = new (ELeave) CNSmlDataItemUidSet;
+    iUpdatedItems = new (ELeave) CNSmlDataItemUidSet;
+    iMovedItems = new (ELeave) CNSmlDataItemUidSet;
+    iSoftDeletedItems = new (ELeave) CNSmlDataItemUidSet;
+    
+    iFolderObjectParser = COMADSFolderObject::NewL();
+    
+    LOGGER_LEAVEFN("CMmsDataStore::ConstructL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CMmsDataStore* CMmsDataStore::NewL( CMsvSession &aMsvSession)
+    {
+    CMmsDataStore* self = new (ELeave) CMmsDataStore;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aMsvSession );
+    CleanupStack::Pop( self );
+
+    return self;    
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::~CMmsDataStore
+// Destructor
+// -----------------------------------------------------------------------------
+CMmsDataStore::~CMmsDataStore()
+    {
+    LOGGER_ENTERFN("CMmsDataStore::~CMmsDataStore()");
+    
+    delete iDataBuffer;
+    
+    delete iChangeFinder;
+    delete iFolderObjectParser;
+    
+    delete iNewItems;
+    delete iDeletedItems;
+    delete iUpdatedItems;
+    delete iMovedItems;
+    delete iSoftDeletedItems;
+ 
+    delete iMsvApi;
+    delete iCodecClient;
+    delete iMsvWait;
+            
+    LOGGER_LEAVEFN("CMmsDataStore::~CMmsDataStore()");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoOpenL
+// Opens database. This operation is performed SYNCHRONOUSLY
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoOpenL( const TDesC& /*aStoreName*/,
+    MSmlSyncRelationship& aContext, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoOpenL");
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    if ( iDataBaseOpened )
+        {
+        User::RequestComplete( iCallerStatus, KErrInUse );
+        LOGGER_WRITE("CMmsDataStore::DoOpenL failed with KErrInUse.");
+        return;
+        }
+    
+    *iContext = aContext;
+
+    // Create ChangeFinder object
+    if ( iChangeFinder )
+        {
+        delete iChangeFinder;
+        iChangeFinder = NULL;
+        }
+    iChangeFinder = CChangeFinder::NewL( aContext, iKey, iHasHistory, KMmsDataProviderImplUid );
+    
+    // Set current snapshot, this will be compared against the old one   
+    RegisterSnapshotL();
+    
+    iDataBaseOpened = ETrue;
+    iCurrentState = EMmsOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, KErrNone );   
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoOpenL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCancelRequest
+// Not supported, does nothing.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCancelRequest()
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoCancelRequestL");
+    LOGGER_LEAVEFN("CMmsDataStore::DoCancelRequestL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoStoreName
+// Returns the name of the DataStore
+// -----------------------------------------------------------------------------
+const TDesC& CMmsDataStore::DoStoreName() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoStoreName");
+    
+    if ( iDataBaseOpened )
+        {
+        LOGGER_LEAVEFN( "CMmsDataStore::DoStoreName" );
+        LOGGER_MSG_EC( "Database name: %S", &KNSmlDefaultLocalDbName );
+        return KNSmlDefaultLocalDbName;
+        }
+
+    LOGGER_LEAVEFN( "CMmsDataStore::DoStoreName" );
+    return KNullDesC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoBeginTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoBeginTransactionL()
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoBeginTransactionL");
+    LOGGER_WRITE( "CMmsDataStore::DoBeginTransactionL leaved with KErrNotSupported." );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCommitTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCommitTransactionL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoCommitTransactionL" ); 
+    LOGGER_WRITE( "CMmsDataStore::DoCommitTransactionL failed with KErrNotSupported." );
+    
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoRevertTransaction
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoRevertTransaction( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoRevertTransaction" ); 
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    LOGGER_LEAVEFN( "CMmsDataStore::DoRevertTransaction" );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoBeginBatchL
+// Batching is not supported.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoBeginBatchL()
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoBeginBatchL" );
+    LOGGER_WRITE( "CMmsDataStore::DoBeginBatchL leaved with KErrNotSupported." );
+    User::Leave( KErrNotSupported );    
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCommitBatchL
+// Batching is not supported
+// -----------------------------------------------------------------------------
+//
+void CMmsDataStore::DoCommitBatchL( RArray<TInt>& /*aResultArray*/, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoCommitBatchL" );  
+    LOGGER_WRITE( "CMmsDataStore::DoCommitBatchL failed with KErrNotSupported" );
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCancelBatch
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCancelBatch()
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoCancelBatch" );
+    LOGGER_LEAVEFN( "CMmsDataStore::DoCancelBatch" );
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoSetRemoteStoreFormatL
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CMmsDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/ )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoSetRemoteStoreFormatL");
+    LOGGER_LEAVEFN("CMmsDataStore::DoSetRemoteStoreFormatL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoSetRemoteMaxObjectSize
+// Not supported
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoSetRemoteMaxObjectSize( TInt /*aServerMaxObjectSize*/ )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoSetRemoteMaxObjectSize");
+    LOGGER_LEAVEFN("CMmsDataStore::DoSetRemoteMaxObjectSize");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoMaxObjectSize
+// Reads the maximum MMS Message size from the central repository
+// -----------------------------------------------------------------------------
+TInt CMmsDataStore::DoMaxObjectSize() const
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoMaxObjectSize" );
+    
+    CRepository* repository( NULL );
+    TInt error( KErrNone );
+    TInt maxSendSize( 0 );
+    
+    // Create central repository instance
+    TRAP( error, repository = CRepository::NewL( KCRUidMmsEngine ) );  
+    if ( error == KErrNone )
+        {
+        // Obtain the size from the central repository.
+        // In the case of error we'll set the value to zero ("anything goes").
+        error = repository->Get( KMmsEngineMaximumSendSize, maxSendSize );
+        if ( error != KErrNone )
+            {
+            maxSendSize = 0;
+            }
+        
+        delete repository;
+        }
+    else
+        {
+        LOGGER_MSG_EC( "CRepository::NewL leaved with %d", error );
+        }       
+        
+    LOGGER_LEAVEFN( "CMmsDataStore::DoMaxObjectSize" );
+    return maxSendSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoOpenItemL
+// Opens item in the DataStore, reads it (either completely or partially) 
+// to the temporary buffer where it can be later read to the remote database.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, 
+    TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, 
+    TDes8& aMimeVer, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoOpenItemL" );
+
+    LOGGER_MSG_EC( "Opening item %d.", aUid );
+    
+    // Store these for later use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC( "CMmsDataStore::DoOpenItemL, invalid state %d.", iCurrentState );
+        User::RequestComplete( iCallerStatus, KErrNotReady );
+        return;
+        }
+        
+    TBool userFolderFound( EFalse );
+    TTime timeStamp;
+    TPtrC folderName;
+    userFolderFound = iMsvApi->FindUserFolderL( aUid, folderName, timeStamp );
+    
+    if ( userFolderFound )
+        {
+        // Allocate new buffer
+        SAFEDELETE( iDataBuffer );
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        
+        iFolderObjectParser->SetName( folderName );
+        iFolderObjectParser->SetCreatedDate( timeStamp.DateTime() );
+        iFolderObjectParser->SetModifiedDate( timeStamp.DateTime() );
+        iFolderObjectParser->ExportFolderXmlL( *iDataBuffer ); 
+       
+        iParentId = KMsvMyFoldersEntryIdValue;
+        
+        iCurrentState = EFolderOpen;
+        iReadPosition = 0;
+        
+        aSize = iDataBuffer->Size();
+        }
+    else // Open MMS message
+        {
+        TInt error( KErrNone );
+        
+        CMsvEntry* entry( NULL );
+        TRAP( error, entry = iMsvSession->GetEntryL(aUid) );
+        if ( error != KErrNone )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotFound ); 
+            LOGGER_MSG_EC("iMsvSession->GetEntryL failed with %d.", error);
+            return;
+            }
+        
+        TMsvEntry messageEntry = entry->Entry();
+        SAFEDELETE( entry );
+    
+        iCurrentId = aUid;
+        iParentId = messageEntry.Parent();
+        iReadCounter = 0;
+    
+        // Check whether we need to send the whole item
+        if ( iChangeFinder->UpdatePartialL( aUid ) )
+            {
+            LOGGER_WRITE("EMmsItemOpenFieldUpdate");
+            aSize = 1;
+            iCurrentState = EMmsItemOpenFieldUpdate;
+            }
+        else    
+            {
+            // Read the whole item from the message store to the buffer
+            TUint32 flags( 0 );
+            TRAP( error, iCodecClient->InitializeChunkedRetrievingL(
+                iCurrentId,
+                iParentId,
+                flags,
+                iUnread,
+                aSize,
+                iMsvWait->iStatus) );
+            
+            if ( error != KErrNone ) 
+                {
+                User::RequestComplete( iCallerStatus, error );
+                LOGGER_MSG_EC("iCodecClient->InitializeChunkedRetrievingL failed with %d.", error); 
+                return;         
+                }
+            
+            // Wait until the message has been processed
+            iMsvWait->Start();
+            
+            if ( iMsvWait->iStatus != KErrNone )
+                {
+                User::RequestComplete( iCallerStatus, iMsvWait->iStatus.Int() );
+                LOGGER_MSG_EC( "iCodecClient->InitializeChunkedRetrievingL failed with %d",
+                    iMsvWait->iStatus.Int() ); 
+                return;
+                }   
+            aSize++; // Status byte will be added also, reserve one additional byte for that.
+            iCurrentState = EMmsItemOpen;
+            }
+        } // Open MMS message
+    
+    aParent = iParentId;
+    
+    aFieldChange = iCurrentState == EMmsItemOpenFieldUpdate ? ETrue : EFalse;
+    
+    if ( iCurrentState == EFolderOpen ) // Message folder
+        {
+        TInt targetLength = KFolderMimeType().Length();
+        if ( aMimeType.MaxLength() < targetLength )
+            {
+            targetLength = aMimeType.MaxLength();
+            }
+        aMimeType.Copy( KFolderMimeType().Ptr(), targetLength );
+
+        // Set mime version (do not exceed the allocated buffer)
+        targetLength = KFolderMimeVersion().Length();
+        if ( aMimeVer.MaxLength() < targetLength )
+            {
+            targetLength = aMimeVer.MaxLength();
+            }
+        aMimeVer.Copy( KFolderMimeVersion().Ptr(), targetLength );
+        }
+    else // EMmsMessage
+        {   
+        TInt targetLength = KMmsMimeType().Length();
+        if ( aMimeType.MaxLength() < targetLength )
+            {
+            targetLength = aMimeType.MaxLength();
+            }
+        aMimeType.Copy( KMmsMimeType().Ptr(), targetLength );
+
+        // Set mime version (do not exceed the allocated buffer)
+        targetLength = KMmsMimeVersion().Length();
+        if ( aMimeVer.MaxLength() < targetLength )
+            {
+            targetLength = aMimeVer.MaxLength();
+            }
+        aMimeVer.Copy( KMmsMimeVersion().Ptr(), targetLength );
+        }
+    
+    LOGGER_WRITE_1("aSize: %d", aSize);
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone ); 
+
+    LOGGER_LEAVEFN("CMmsDataStore::DoOpenItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCreateItemL
+// Create new item to the message store.
+// Return the id number of the newly created item
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, 
+    const TDesC8& aMimeType, const TDesC8& /*aMimeVer*/, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN( "CMmsDataStore::DoCreateItemL" );
+    LOGGER_MSG_EC( "Parent folder: %d.", aParent );
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC( "Invalid state %d.", iCurrentState );
+        }
+        
+    TBool createFolder( EFalse );
+    LOG( aMimeType );
+    if ( aMimeType.Compare( KFolderMimeType() ) == 0 )  
+        {
+        createFolder = ETrue;
+        }
+    else if ( aMimeType.Compare( KMmsMimeType() ) != 0 )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported );
+        LOGGER_WRITE("Bad MIME type");
+        return;
+        }
+    
+    // Ensure that we've got enough disk space for the item
+    if ( iCodecClient->DiskSpaceBelowCriticalLevelL( aSize ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE( "Disk full" );
+        return;
+        }
+        
+    if( createFolder )
+        {
+        if ( aParent != KMsvMyFoldersEntryIdValue )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotSupported );
+            LOGGER_WRITE( "Bad parent folder" );
+            return;
+            }
+        SAFEDELETE( iDataBuffer );
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        iCurrentState = EFolderCreating;
+        iCreatedUid = &aUid;
+        iWrittenDataLength = 0;
+        }
+    else
+        {
+        // There is some problems on chunked data adding, so get all data to internal buffer
+        iCreatedUid = &aUid;
+        iCurrentState = EMmsItemCreating;
+        iWriteCounter = 0;
+        iWrittenDataLength = 0;
+        if ( iDataBuffer )
+            {
+            iDataBuffer->ResizeL( aSize );
+            }
+        else
+            {
+            iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+            iDataBuffer->ResizeL( aSize );
+            }
+        }
+        
+    iParentId = aParent; 
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoCreateItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoReplaceItemL
+// Begin the replace operation, ensure that the item really exists
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, 
+    TBool /*aFieldChange*/, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoReplaceItemL");
+    LOGGER_MSG_EC("Replacing item %d.", aUid);
+    LOGGER_MSG_EC("Parent folder: %d.", aParent);
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC("Invalid state %d.", iCurrentState);
+        }
+
+    // Ensure that we've got enough disk space for the item
+    if ( iCodecClient->DiskSpaceBelowCriticalLevelL( aSize ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE("Disk full");
+        return;
+        }
+             
+    // Find entry
+    CMsvEntry* entry(NULL);
+    TRAPD( err, entry = iMsvSession->GetEntryL( aUid ) );
+    if ( err != KErrNone )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotFound );
+        LOGGER_MSG_EC("CMsvSession::GetEntryL failed with %d.", err)
+        return;
+        }
+
+    TMsvEntry tEntry = entry->Entry();
+    delete entry;
+    
+    // Check entry type
+    TBool updateFolder(EFalse);
+    if ( tEntry.iType == KUidMsvFolderEntry )
+        {
+        updateFolder = ETrue;
+        LOGGER_WRITE("Type: folder");
+        }
+        
+   if ( ( updateFolder && aParent != KMsvMyFoldersEntryIdValue )
+        || ( !updateFolder && !iMsvApi->ValidFolderL( aParent )
+        || ( aParent != tEntry.Parent() ) ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported );
+        LOGGER_MSG_EC("Bad parent folder, message entry parent is %d", tEntry.Parent());
+        return;    
+        }           
+    
+    // Store these for further use
+    iParentId = aParent;
+    iCurrentId = aUid;
+    
+    if ( updateFolder )
+        {
+        SAFEDELETE( iDataBuffer );
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        iCurrentState = EFolderUpdating;
+        iWrittenDataLength = 0;
+        }
+    else
+        {
+        iCurrentState = EMmsItemUpdating;
+        iWriteCounter = 0;
+        iWrittenDataLength = 0;
+        if ( iDataBuffer )
+            {
+            iDataBuffer->ResizeL( aSize );
+            }
+        else
+            {
+            iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+            iDataBuffer->ResizeL( aSize );
+            }
+        }
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone );
+
+    LOGGER_LEAVEFN("CMmsDataStore::DoReplaceItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoReadItemL
+// Read specified amount of data from the temporary buffer
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoReadItemL( TDes8& aBuffer )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoReadItemL");
+    
+    if ( iCurrentState == EFolderOpen )
+        {   
+        // This is how much we've got left in the buffer
+        TInt left = iDataBuffer->Size() - iReadPosition;
+    
+        // Make sure that there's something to read
+        if ( left > 0 )
+            {
+            // This is how much there's space in the destination buffer
+            TInt destSize = aBuffer.MaxSize();
+
+            // This is how much we can read
+            TInt toRead = destSize < left ? destSize : left;
+
+            // Read the data from the buffer, then update the position
+            iDataBuffer->Read( iReadPosition, aBuffer, toRead );
+            iReadPosition += toRead;
+            }
+        else
+            {
+            LOGGER_WRITE("All data read");
+            User::Leave( KErrEof );
+            }
+        }
+    
+    else if ( iCurrentState == EMmsItemOpenFieldUpdate )
+        {
+        if ( iReadCounter++ == 0 )
+            {
+            TUint8 status = ResolveStatusBits( iUnread );
+            aBuffer.Append( &status, 1 );
+            }
+        else
+            {
+            LOGGER_WRITE("Field update done");
+            User::Leave( KErrEof );             
+            }   
+        }
+        
+    else if ( iCurrentState == EMmsItemOpen )
+        {
+        if ( iReadCounter++ == 0 )
+            {
+            TUint8 status = ResolveStatusBits( iUnread );
+            aBuffer.Append( &status, 1 );
+            iReadPosition = 0;
+            iLastDataChunk = EFalse;
+            iReadAllData = EFalse;
+            }
+        else if ( iReadAllData )
+            {
+            User::Leave( KErrEof );
+            }
+            
+        TInt error = ReadDataRecursively( aBuffer );
+        if ( error != KErrNone )
+            {
+            User::Leave( error );
+            }           
+        }
+    
+    else
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoReadItemL: bad state %d", iCurrentState);
+        User::Leave( KErrNotReady );
+        }   
+
+    LOGGER_LEAVEFN("CMmsDataStore::DoReadItemL");   
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoWriteItemL
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoWriteItemL( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoWriteItemL");
+    LOGGER_MSG_EC("%d",iWriteCounter);
+    
+    TInt dataLength = aData.Length();
+    LOGGER_MSG_EC("Data length: %d", dataLength);
+    
+    if ( !( dataLength > 0 ) ) // Should never happen...
+        {
+        LOGGER_WRITE("Error: no data");
+        User::Leave( KErrArgument );
+        }
+
+    if ( iCodecClient->DiskSpaceBelowCriticalLevelL( dataLength ) )
+        {
+        LOGGER_WRITE("Error: disk full");
+        User::Leave( KErrDiskFull );
+        }
+        
+    TInt error( KErrNone );
+    
+    if ( iCurrentState == EFolderCreating || iCurrentState == EFolderUpdating )
+        {
+        // Add data to buffer
+        iDataBuffer->InsertL( iWrittenDataLength, aData );
+        iWrittenDataLength += aData.Size();
+        }
+      
+    else if ( iCurrentState == EMmsItemCreating )
+        {
+        if ( iWriteCounter++ == 0 )
+            {
+            iUnread = aData[0] & KMMS_Flag_Read ? EFalse : ETrue;
+            if ( dataLength > 1 )
+                {
+                TPtrC8 data = aData.Mid(1);
+                iDataBuffer->Write( iWrittenDataLength, data );
+                iWrittenDataLength += data.Length();
+                }
+            }
+        else
+            {
+            TPtrC8 data = aData.Mid(0);
+            iDataBuffer->Write( iWrittenDataLength, data );
+            iWrittenDataLength += dataLength;
+            }    
+        }
+        
+    else if ( iCurrentState == EMmsItemUpdating )
+        {
+        if ( iWriteCounter++ == 0 )
+            {
+            iUnread = aData[0] & KMMS_Flag_Read ? EFalse : ETrue;
+            if ( dataLength > 1 )
+                {
+                TPtrC8 data = aData.Mid(1);
+                iDataBuffer->Write( iWrittenDataLength, data );
+                iWrittenDataLength += data.Length();
+                }
+            else // just status update
+                {
+                UpdateMmsStatusL( iCurrentId, iUnread );
+                LOGGER_MSG_EC("Message status updated: %d", iUnread);
+                }    
+            }
+        else
+            {
+            TPtrC8 data = aData.Mid(0);    
+            iDataBuffer->Write( iWrittenDataLength, data );
+            iWrittenDataLength += dataLength;
+            }    
+        }
+        
+    else
+        {
+        LOGGER_MSG_EC("Wrong state %d", iCurrentState);
+        User::Leave( KErrNotReady );
+        }
+        
+    if ( error != KErrNone )
+        {
+        LOGGER_MSG_EC("iCodecClient->NextDataPart() failed with %d", error);
+        User::Leave( error );
+        }  
+
+    LOGGER_LEAVEFN("CMmsDataStore::DoWriteItemL");  
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCommitItemL
+// Commits item from temporary buffer to the message store
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCommitItemL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoCommitItemL");
+    
+    // Store some variables
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    TInt error(KErrNone);
+    
+    if ( iCurrentState == EFolderCreating || iCurrentState == EFolderUpdating )
+        {
+        error = iFolderObjectParser->ImportFolderXml( iDataBuffer->Ptr(0) );
+        if ( error != KErrNone )
+            {
+            User::RequestComplete( iCallerStatus, error );
+            LOGGER_MSG_EC("ImportFolderXml failed with %d", error);
+            return;
+            }
+         
+         const TDesC& name = iFolderObjectParser->GetName();
+         if ( name.Length() <= 0 )
+            {
+            User::RequestComplete( iCallerStatus, KErrNotSupported );
+            LOGGER_WRITE("Folder name is empty");
+            return;
+            }
+            
+         if ( iCurrentState == EFolderCreating )
+            {
+            TMsvId id;
+            error = iMsvApi->AddUserFolderL( id, name );
+            if ( error == KErrNone )
+                {
+                *iCreatedUid = id;
+                iCurrentId = id;
+                }
+            else
+                {
+                LOGGER_MSG_EC("iMsvApi->AddFolderL failed with %d", error);
+                }    
+            }
+         else
+            {
+            error = iMsvApi->UpdateUserFolderL( iCurrentId, name );
+            if ( error != KErrNone )
+                {
+                LOGGER_MSG_EC("iMsvApi->UpdateFolderL failed with %d", error);
+                }
+            }
+        }
+    else if ( iCurrentState == EMmsItemCreating )
+        {
+        LOGGER_WRITE("Create MMS item");
+        TMsvId newId(0);
+        TUint32 flags(0);
+        
+        error = iCodecClient->CreateNewMessageEntryL( iParentId, newId );
+        if ( !error )
+            {
+            iCodecClient->AddMML( *iDataBuffer, iParentId, flags, iUnread, newId, iMsvWait->iStatus );
+            // Wait until the message has been processed
+            iMsvWait->Start();
+            error = iMsvWait->iStatus.Int();
+            LOGGER_WRITE_1("error: %d", error);
+            LOGGER_WRITE_1("AddMML newId: %d", newId);
+            *iCreatedUid = newId;
+            iCurrentId = newId;
+            }
+        }
+    else if ( iCurrentState == EMmsItemUpdating )
+        {
+        if ( iWrittenDataLength > 0 ) // if no data then just field update
+            {
+            TUint32 flags(0);
+            iCodecClient->ReplaceMML( iCurrentId, *iDataBuffer, flags, iUnread, iMsvWait->iStatus );
+            iMsvWait->Start();
+            error = iMsvWait->iStatus.Int();
+            }
+        else
+            {
+            UpdateMmsStatusL( iCurrentId, iUnread );   
+            }
+        }
+    else
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported );
+        LOGGER_MSG_EC("Bad state: %d", iCurrentState);
+        return;
+        }
+    
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    
+    if ( error == KErrNone ) // Update Change Finder
+        {
+        TMsvId service;
+        TMsvEntry msgEntry;
+        
+        // Inform ChangeFinder of added item
+        TSnapshotItem snapshotItem( iCurrentId, iParentId, iUnread );
+        error = iMsvSession->GetEntry( iCurrentId, service, msgEntry );
+        
+        if ( error == KErrNone )
+            {
+            snapshotItem.SetLastChangedDate( msgEntry.iDate );
+            if ( iCurrentState == EFolderCreating || iCurrentState == EFolderUpdating )
+                {
+                snapshotItem.SetFolderNameL( msgEntry.iDetails );
+                }
+            
+            if ( iCurrentState == EFolderCreating || iCurrentState == EMmsItemCreating )
+                {
+                iChangeFinder->ItemAddedL( snapshotItem );
+                }
+            else
+                {
+                iChangeFinder->ItemUpdatedL( snapshotItem );
+                }
+            }
+        else
+            {
+            LOGGER_MSG_EC( "CMsvSession::GetEntry failed with %d", error );
+            }
+        }
+    
+    // Send message if parent folder is Outbox
+    if ( iParentId == KMsvGlobalOutBoxIndexEntryId &&
+        iCurrentState == EMmsItemCreating &&
+        error == KErrNone )
+        {
+        LOGGER_WRITE("Sending message...");
+        iCodecClient->SendMML( iCurrentId, iMsvWait->iStatus );
+        iMsvWait->Start();
+        error = iMsvWait->iStatus.Int();
+        }
+    
+    LOGGER_WRITE_1("error: %d", error);
+    // We'll be waiting for next event, signal we're done
+    iCurrentState = EMmsOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, error );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoCommitItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCloseItem
+// Closes open item in the data store
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCloseItem()
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoCloseItem");
+    SAFEDELETE(iDataBuffer);
+    if ( iCurrentState == EFolderOpen )
+        {
+        iCurrentState = EMmsOpenAndWaiting;
+        }
+    else if ( iCurrentState == EMmsItemOpen )
+        {
+        iCodecClient->ReleaseData();
+        iCurrentState = EMmsOpenAndWaiting; 
+        }
+    else if ( iCurrentState == EMmsItemOpenFieldUpdate )
+        {
+        iCurrentState = EMmsOpenAndWaiting;
+        }
+    else 
+        {
+        LOGGER_MSG_EC("Invalid state %d.", iCurrentState);
+        }
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoCloseItem");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoMoveItemL
+// Moves item from one folder to another in the message store
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoMoveItemL( TSmlDbItemUid aUid,
+    TSmlDbItemUid aNewParent, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoMoveItemL");
+    
+    LOGGER_MSG_EC("Moving item %d.", aUid);
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+
+    // Check that we're in proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoMoveItemL, invalid state %d.", iCurrentState);
+        }
+
+    // Ensure that we have this item in the message store   
+    if ( !MmsItemExists( aUid ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported ); 
+        LOGGER_WRITE("MMS item not found");
+        return;
+        }
+    
+    iCodecClient->MoveMML( aUid, aNewParent, iMsvWait->iStatus );
+    iMsvWait->Start();  
+    
+    // Inform ChangeFinder of the moved item
+    TMsvId service;
+    TMsvEntry msgEntry;
+    User::LeaveIfError( iMsvSession->GetEntry( aUid, service, msgEntry ) );
+    TBool unread = msgEntry.Unread();
+    TSnapshotItem snapshotItem( aUid, aNewParent, unread );
+    iChangeFinder->ItemMovedL( snapshotItem );
+
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoMoveItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoDeleteItemL
+// Removes item from the message store
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus  )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoDeleteItemL");
+    LOGGER_MSG_EC("Deleting item %d.", aUid);
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    TInt error(KErrNone);
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoDeleteItemL, invalid state %d.", iCurrentState);        
+        }
+        
+    // Check if this is a user folder
+    if ( iMsvApi->FindUserFolderL( aUid ) )
+        {
+        LOGGER_WRITE("Folder");
+        error = DeleteAllMessagesInFolderL( aUid );
+        if ( error != KErrNone )
+            {
+            User::RequestComplete( iCallerStatus, error );    
+            LOGGER_MSG_EC("Deleting MMS messages in folder failed with %d", error); 
+            return;
+            }
+        error = iMsvApi->DeleteUserFolderL(aUid);  
+        if ( error != KErrNone )
+            {
+            // Note: folder is not deleted if contains other message items (like MMS)
+            // In this case DeleteUserFolderL returns KErrInUse.    
+            LOGGER_MSG_EC("Deleting folder failed with %d", error); 
+            }       
+        }
+    else if ( MmsItemExists( aUid ) )
+        {
+        // Tell CodecClient to delete this message
+        error = iCodecClient->DeleteMM( aUid );
+        if ( error != KErrNone )
+            {
+            User::RequestComplete( iCallerStatus, error );    
+            LOGGER_MSG_EC("CMmsCodecClient::DeleteMM failed with %d", error);   
+            return;
+            }
+        // Inform ChangeFinder of the removed item
+        iChangeFinder->ItemDeletedL( aUid );
+        }
+    else
+        {
+        User::RequestComplete( iCallerStatus, KErrNotFound ); 
+        LOGGER_MSG_EC("Item %d is not folder or MMS message", aUid);
+        return;
+        }
+    
+    LOGGER_WRITE_1("complete error: %d", error);
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, error );
+    LOGGER_LEAVEFN("CMmsDataStore::DoDeleteItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoSoftDeleteItemL
+// Soft delete isn't supported.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoSoftDeleteItemL"); 
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoSoftDeleteItemL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoDeleteAllItemsL
+// Deletes all items in the standard folders of message store
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoDeleteAllItemsL");
+    
+    // Store some variables for further use 
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+   // Check that we're in proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoDeleteAllItemsL, invalid state %d.", iCurrentState);
+        }
+        
+    TInt error(KErrNone);
+    TInt result(KErrNone);      
+    
+    // Delete all messages in the standard folders (except outbox)
+    error = DeleteAllMessagesInFolderL( KMsvGlobalInBoxIndexEntryId );
+    if ( error != KErrNone )
+        {
+        result = error;
+        }
+       
+    error = DeleteAllMessagesInFolderL( KMsvDraftEntryId );
+    if ( error != KErrNone )
+        {
+        result = error;
+        }   
+    
+    error = DeleteAllMessagesInFolderL( KMsvSentEntryId );
+    if ( error != KErrNone )
+        {
+        result = error;
+        }
+        
+    error = CleanUserFoldersL();
+    if ( error != KErrNone )
+        {
+        result = error;
+        }
+            
+    iChangeFinder->ResetL();
+    
+    User::RequestComplete( iCallerStatus, result );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoDeleteAllItemsL");
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DeleteAllMessagesInFolderL
+// Deletes all items in the specified folder in message store
+// -----------------------------------------------------------------------------
+TInt CMmsDataStore::DeleteAllMessagesInFolderL( TMsvId aId )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DeleteAllMessagesInFolderL");
+    LOGGER_MSG_EC("Folder: %d", aId);
+    
+    TInt error(KErrNone);
+    
+    // Get the root folder
+    CMsvEntry* msvEntry = iMsvSession->GetEntryL(aId);
+    CleanupStack::PushL(msvEntry);
+    
+    // Find all of it's childs
+    CMsvEntrySelection* messages = msvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
+    CleanupStack::PopAndDestroy(msvEntry);
+    CleanupStack::PushL(messages);
+        
+    TMsvId service;
+    TMsvEntry msg;
+    TMsvId id;
+    
+    // We are only interested of the MM content
+    for ( TInt index=0; index < messages->Count(); index++ )
+        {
+        id = messages->At( index );
+        LOGGER_MSG_EC("Message item %d:", id);
+        
+        error = iMsvSession->GetEntry( id, service, msg );
+        if ( error != KErrNone )
+            {
+            LOGGER_MSG_EC("GetEntry failed with %d", error);
+            break;
+            }
+        
+        if ( msg.iMtm == KUidMsgTypeMultimedia )
+            {
+            error = iCodecClient->DeleteMM( id );
+            if ( error != KErrNone )
+                {
+                LOGGER_MSG_EC("DeleteMM failed with %d", error);
+                break;
+                }
+            // Update Change Finder
+            iChangeFinder->ItemDeletedL( id );
+            LOGGER_WRITE("MMS message deleted");    
+            }
+        }
+    CleanupStack::PopAndDestroy(messages); 
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DeleteAllMessagesInFolderL");
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoHasSyncHistory
+// This method returns ETrue if Data Store has history information. 
+// Slow-sync will be used if Data Store does not have history information.
+// -----------------------------------------------------------------------------
+TBool CMmsDataStore::DoHasSyncHistory() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoHasSyncHistory");
+    LOGGER_LEAVEFN("CMmsDataStore::DoHasSyncHistory");      
+        
+    // iHasHistory is initialized in DoOpenL method
+    return iHasHistory;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoAddedItems
+// This method returns UIDs of added items. Those items are added after previous
+// synchronization with current synchronization relationship. 
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMmsDataStore::DoAddedItems() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoAddedItems");  
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoAddedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+
+    // Clear new-items array
+    iNewItems->Reset();
+  
+    // Search for new items
+    TRAP( error, iChangeFinder->FindNewItemsL(*iNewItems) )
+    if ( error != KErrNone )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_MSG_EC("New item count: %d.", iNewItems->ItemCount());
+    LOGGER_LEAVEFN("CMmsDataStore::DoAddedItems");      
+    
+    return *iNewItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoDeletedItems
+//
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMmsDataStore::DoDeletedItems() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoDeletedItemsL");   
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoDeletedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+    
+    // Clear deleted-items array
+    iDeletedItems->Reset();
+    
+    // Search for deleted items
+    TRAP( error, iChangeFinder->FindDeletedItemsL( *iDeletedItems ) );
+    if ( error != KErrNone )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error);
+        }           
+    
+    LOGGER_MSG_EC("Deleted item count: %d.", iDeletedItems->ItemCount());
+    LOGGER_LEAVEFN("CMmsDataStore::DoDeletedItemsL");
+    return *iDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoSoftDeletedItems
+// Not directly supported, equals to "hard" delete
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMmsDataStore::DoSoftDeletedItems() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoSoftDeletedItems");
+    LOGGER_LEAVEFN("CMmsDataStore::DoSoftDeletedItems");
+
+    iSoftDeletedItems->Reset();
+    return *iSoftDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoModifiedItems
+// Finds all modified items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMmsDataStore::DoModifiedItems() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoModifiedItems");   
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoModifiedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+    
+    // Clear updated-items array
+    iUpdatedItems->Reset();
+    
+    // Search for updated items
+    TRAP( error, iChangeFinder->FindChangedItemsL( *iUpdatedItems ) )
+    if ( error != KErrNone )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_MSG_EC("Modified item count: %d.", iUpdatedItems->ItemCount());
+    LOGGER_LEAVEFN("CMmsDataStore::DoModifiedItems");       
+    return *iUpdatedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoMovedItems
+// Finds all moved items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMmsDataStore::DoMovedItems() const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoMovedItems");  
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoMovedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+    
+    // Clear moved-items array
+    iMovedItems->Reset();
+    
+    // Search for moved items
+    TRAP( error, iChangeFinder->FindMovedItemsL( *iMovedItems ) );
+    if ( error != KErrNone )
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoMovedItems, iChangeFinder->FindMovedItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_MSG_EC("Moved item count: %d.", iMovedItems->ItemCount());
+    LOGGER_LEAVEFN("CMmsDataStore::DoMovedItems");
+    return *iMovedItems;    
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoResetChangeInfoL
+// Resets change history in the data store. All content is considered
+// new in the data store point of view.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoResetChangeInfoL");    
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoResetChangeInfoL, invalid state %d.", iCurrentState);
+        }   
+            
+    // Reset change info in ChangeFinder
+    iChangeFinder->ResetL();
+    iHasHistory = EFalse;
+    
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone ); 
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoResetChangeInfoL");
+    }
+        
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCommitChangeInfoL
+// Commits change info. These items are no longer reported, when change
+// information is being queried.
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoCommitChangeInfoL");
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+        }
+
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL(aItems);
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete(iCallerStatus, KErrNone);
+        
+    LOGGER_LEAVEFN("CMmsDataStore::DoCommitChangeInfoL");
+    }
+        
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::DoCommitChangeInfoL
+// Commits change info. There is no more nothing to report when change
+// information is being queried. 
+// -----------------------------------------------------------------------------
+void CMmsDataStore::DoCommitChangeInfoL(TRequestStatus& aStatus)
+    {
+    LOGGER_ENTERFN("CMmsDataStore::DoCommitChangeInfoL");
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_MSG_EC("CMmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+        }
+    
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL();
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::DoCommitChangeInfoL");
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::RegisterSnapshotL
+// Sets Changefinder to compare against current message store content
+// -----------------------------------------------------------------------------
+void CMmsDataStore::RegisterSnapshotL() const
+    {
+    CSnapshotArray* snapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+    CleanupStack::PushL(snapshot);
+    
+    // Use only standard folders (except outbox)
+    RegisterFolderL(snapshot, KMsvGlobalInBoxIndexEntryId);
+    RegisterFolderL(snapshot, KMsvDraftEntryId);
+    RegisterFolderL(snapshot, KMsvSentEntryId);
+    RegisterFolderL(snapshot, KMsvGlobalOutBoxIndexEntryId);    
+    RegisterUserFoldersL(snapshot);
+    
+    // Set new snapshot to compare against
+    iChangeFinder->SetNewSnapshot(snapshot);
+
+    // Changefinder takes ownership of the snapshot
+    CleanupStack::Pop(snapshot);
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::RegisterFolderL
+// Adds a single folder into the snapshot array
+// -----------------------------------------------------------------------------
+TInt CMmsDataStore::RegisterFolderL(CSnapshotArray* aSnapshot, const TMsvId& aId) const
+    {
+    // Get the root folder
+    CMsvEntry* msvEntry = iMsvSession->GetEntryL(aId);
+    CleanupStack::PushL( msvEntry );
+    
+    // Find all of it's childs
+    CMsvEntrySelection* messages = msvEntry->ChildrenWithTypeL( KUidMsvMessageEntry );
+    CleanupStack::PopAndDestroy( msvEntry );
+    CleanupStack::PushL( messages );
+    
+    TMsvId id;
+    TMsvEntry msg;
+    
+    // We are only interested of the MM content
+    for ( TInt index=0; index<messages->Count(); index++ )
+        {
+        TInt result = iMsvSession->GetEntry( messages->At( index ), id, msg );
+        User::LeaveIfError( result );
+        
+        // We're only interested about the multimedia content
+        if ( msg.iMtm == KUidMsgTypeMultimedia )
+            {
+            // Create snapshot item
+            TKeyArrayFix key(iKey);
+            TSnapshotItem item( (TUint) msg.Id() );
+            
+            item.SetLastChangedDate( msg.iDate );
+            item.SetParentId( msg.Parent() );
+            item.SetUnread( msg.Unread() ? ETrue : EFalse );
+            
+            // Add to snapshot
+            aSnapshot->InsertIsqL( item, key );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( messages );
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::MmsItemExists
+// Returns ETrue if MMS item exists in the message store, otherwise EFalse
+// -----------------------------------------------------------------------------    
+TBool CMmsDataStore::MmsItemExists( TMsvId aUid )
+    {
+    CMsvEntry* entry(NULL);
+    
+    // Try to open this item
+    TRAPD( error, entry = iMsvSession->GetEntryL( aUid ) );
+    if ( error != KErrNone )
+        {
+        return EFalse;
+        }
+        
+    TMsvEntry tEntry = entry->Entry();
+    TBool result(EFalse);
+    
+    if ( tEntry.iType == KUidMsvMessageEntry && tEntry.iMtm == KUidMsgTypeMultimedia )
+        {
+        result = ETrue;
+        }
+    
+    delete entry;
+    
+    return result;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::ResolveStatusBits
+// Creates status bit field according to TMsvEntry parameter
+// -----------------------------------------------------------------------------
+TUint8 CMmsDataStore::ResolveStatusBits(TBool aUnread)
+    {
+    // Reset the status byte, then find the correct flags
+    TUint8 data(0);
+    
+    // Set status according to the Read/Unread information iCurrentEntry   
+    if ( aUnread )
+        {
+        // Status unset
+        data &= (~KMMS_Flag_Read);
+        }
+    else
+        { 
+        // Status set
+        data |= KMMS_Flag_Read;
+        }
+    
+    return data;
+    }   
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::ReadDataRecursively
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------    
+TInt CMmsDataStore::ReadDataRecursively( TDes8& aBuffer )
+    {
+    LOGGER_ENTERFN("CMmsDataStore::ReadDataRecursively");
+    
+    TInt error(KErrNone);
+    
+    TInt freeBuffer = aBuffer.MaxLength() - aBuffer.Length();
+    
+    if ( freeBuffer == 0 )
+        {
+        LOGGER_WRITE("Destination buffer filled.");
+        return KErrNone;
+        }
+    
+    if ( iReadPosition == 0 )
+        {
+        if ( iLastDataChunk )
+            {
+            LOGGER_WRITE("All MMS data read");
+            iReadAllData = ETrue;
+            return KErrNone;
+            }
+        else
+            {
+            error = iCodecClient->GetNextDataPart( iReadDataChunk, iLastDataChunk );
+            if ( error != KErrNone )
+                {
+                LOGGER_MSG_EC("iCodecClient->GetNextDataPart failed with %d", error);
+                return error;
+                }
+            else
+                {
+                LOGGER_MSG_EC("iCodecClient->GetNextDataPart succeeded, length %d", iReadDataChunk.Length());
+                }   
+            }   
+        }
+        
+    TInt left = iReadDataChunk.Length() - iReadPosition;    
+    
+    if ( freeBuffer < left )
+        {
+        TPtrC8 data = iReadDataChunk.Mid(iReadPosition, freeBuffer);
+        aBuffer.Append(data);
+        iReadPosition += freeBuffer;
+        return KErrNone; 
+        }
+    else
+        {
+        if ( left > 0 )
+            {
+            TPtrC8 data = iReadDataChunk.Mid(iReadPosition, left);
+            aBuffer.Append(data);
+            }
+        error = iCodecClient->ReleaseData();
+        if ( error != KErrNone )
+            {
+            return error;
+            }
+        iReadPosition = 0;
+        return ReadDataRecursively( aBuffer );
+        }           
+    }   
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::UpdateMmsStatusL
+// Updates MMS message status
+// -----------------------------------------------------------------------------
+void CMmsDataStore::UpdateMmsStatusL( TMsvId aId, TBool aUnread )
+    {
+    CMsvEntry* msvEntry = iMsvSession->GetEntryL( aId );
+    const TMsvEntry& oldEntry = msvEntry->Entry();
+    
+    TMsvEntry newEntry( oldEntry );
+    newEntry.SetUnread( aUnread );
+    
+    CleanupStack::PushL( msvEntry );
+    msvEntry->ChangeL( newEntry );
+    CleanupStack::PopAndDestroy( msvEntry );   
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsDataStore::RegisterUserFoldersL
+// Adds user folder messages into the snapshot array
+// -----------------------------------------------------------------------------
+TInt CMmsDataStore::RegisterUserFoldersL( CSnapshotArray* aSnapshot ) const
+    {
+    LOGGER_ENTERFN("CMmsDataStore::RegisterUserFoldersL");     
+    
+    // Get the folder   
+    CMsvEntry* msvEntry = iMsvSession->GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL(msvEntry);
+    
+    // Find all of it's childs
+    CMsvEntrySelection* folders = msvEntry->ChildrenWithTypeL( KUidMsvFolderEntry );
+    CleanupStack::PopAndDestroy( msvEntry ); 
+    CleanupStack::PushL( folders );
+
+    for ( TInt index = 0; index < folders->Count(); index++ )
+        {
+        TMsvId folderId = folders->At(index);
+        
+        if ( folderId != KMsvMyFoldersTemplatesFolderId )
+            {
+            TMsvId service;
+            TMsvEntry folderEntry;
+            TInt result = iMsvSession->GetEntry( folderId, service, folderEntry );
+            User::LeaveIfError( result );
+            
+            TKeyArrayFix key(iKey);
+            TBool unread(EFalse);
+            TSnapshotItem item( (TUint) folderId, folderEntry.Parent(), unread );
+            item.SetLastChangedDate( folderEntry.iDate );
+            item.SetFolderNameL( folderEntry.iDetails );
+            
+            aSnapshot->InsertIsqL( item, key );
+            
+            RegisterFolderL( aSnapshot, folderId );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( folders );
+    
+    // Register also MMS messages directly under My Folders
+    RegisterFolderL( aSnapshot, KMsvMyFoldersEntryIdValue );
+    
+    LOGGER_LEAVEFN("CMmsDataStore::RegisterUserFoldersL");     
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsDataStore::CleanUserFoldersL
+// Cleans all user folders from MMS messages
+// -----------------------------------------------------------------------------
+TInt CMmsDataStore::CleanUserFoldersL() 
+    {
+    LOGGER_ENTERFN("CMmsDataStore::CleanUserFoldersL");      
+    
+    // Get the folder   
+    CMsvEntry* msvEntry = iMsvSession->GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL(msvEntry);
+    
+    // Find all of it's childs
+    CMsvEntrySelection* folders = msvEntry->ChildrenWithTypeL( KUidMsvFolderEntry );
+    CleanupStack::PopAndDestroy( msvEntry ); 
+    CleanupStack::PushL( folders );
+    
+    TInt error(KErrNone);
+    TInt result(KErrNone);
+
+    for ( TInt index = 0; index < folders->Count(); index++ )
+        {
+        TMsvId folderId = folders->At(index);
+        
+        if ( folderId != KMsvMyFoldersTemplatesFolderId )
+            {
+            error = DeleteAllMessagesInFolderL(folderId);
+            if ( error != KErrNone )
+                {
+                LOGGER_MSG_EC("Deleting messages in folder failed with %d", error); 
+                result = error;
+                }
+            error = iMsvApi->DeleteUserFolderL( folderId );
+            if ( error != KErrNone && error != KErrInUse )
+                {
+                // Note: folder is not deleted if contains other message items (like MMS)
+                // In this case DeleteUserFolderL returns KErrInUse.
+                LOGGER_MSG_EC("iMsvApi->DeleteUserFolderL failed with %d", error);
+                result = error;
+                }
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( folders );
+    
+    // Delete all messages directly under My Folders
+    DeleteAllMessagesInFolderL( KMsvMyFoldersEntryIdValue );
+    
+    LOGGER_LEAVEFN("CSmsDataStore::CleanUserFoldersL");
+    
+    return result;       
+    }
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsdatastore.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Resource data for MmsDataProvider
+*
+*/
+
+
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT MMS_DATA_STORE
+	{
+	version = 1;
+	display_name = "Multimedia messages";
+	sync_types = KSmlSyncType_TwoWay + KSmlSyncType_SlowSync;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version = 1;
+			mime_type = "application/vnd.wap.mms-message";
+			mime_ver = "1.0";
+			properties= 
+				{
+				SML_DATA_PROPERTY
+					{
+					version = 1;
+					display_name = "Read";
+					name = "read";
+					data_type = "bool";
+					enum_values = {};
+					flags = 0;
+					max_size = 0;
+					max_occur = 1;
+					params = {};
+					}
+				};
+			field_level = 0;
+			},
+		SML_MIME_FORMAT
+			{
+			version = 1;
+			mime_type = "application/vnd.omads-folder+xml";
+			mime_ver = "1.0";
+			properties= 
+				{
+				SML_DATA_PROPERTY
+					{
+					version = 1;
+					display_name = "Read";
+					name = "read";
+					data_type = "bool";
+					enum_values = {};
+					flags = 0;
+					max_size = 0;
+					max_occur = 1;
+					params = {};
+					}
+				};
+			field_level = 0;
+			}						
+		};
+	mime_format_tx_pref = 0;    	// Preferred index for tx
+	mime_format_rx_pref = 0;	// Preferred index for rx
+	folder_properties = {};		// No folder properties
+	filter_capabilities = {};	// No filter capabilities
+	max_size = 0;				// No limit
+	max_items = 0;	 			// No limit
+	flags = 0x00000010;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/omadsfolderobject.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,358 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+
+#include <SenXmlUtils.h>
+#include <utf.h>
+#include "omadsfolderobject.h"
+#include "logger.h"
+
+_LIT8(KOMADSFolderElement, "Folder");
+_LIT8(KOMADSNameElement, "name");
+_LIT8(KOMADSCreatedElement, "created");
+_LIT8(KOMADSModifiedElement, "modified");
+
+_LIT(KFolderBeginTag, "<Folder>");
+_LIT(KFolderEndTag, "</Folder>");
+_LIT(KNameBeginTag, "<name>");
+_LIT(KNameEndTag, "</name>");
+_LIT(KCreatedBeginTag, "<created>");
+_LIT(KCreatedEndTag, "</created>");
+_LIT(KModifiedBeginTag, "<modified>");
+_LIT(KModifiedEndTag, "</modified>");
+_LIT(KDateFormat, "%04d%02d%02dT%02d%02d%02d");
+
+
+COMADSFolderObject* COMADSFolderObject::NewLC()
+    {
+    COMADSFolderObject* pSelf = new (ELeave) COMADSFolderObject;
+    CleanupStack::PushL( pSelf );
+    pSelf->ConstructL();
+    return pSelf;
+    }
+
+COMADSFolderObject* COMADSFolderObject::NewL()
+    {
+    COMADSFolderObject* pSelf = COMADSFolderObject::NewLC();
+    CleanupStack::Pop( pSelf );    
+    return pSelf;
+    }
+
+COMADSFolderObject::~COMADSFolderObject()
+    {
+    delete iXmlReader;
+    }
+
+void COMADSFolderObject::ConstructL()
+    {
+    iXmlReader = CSenXmlReader::NewL();
+    iXmlReader->SetContentHandler(*this);
+    }
+
+TInt COMADSFolderObject::ImportFolderXml( RFs& aFs, const TDesC& aFilename )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" );    
+        
+    TInt error;
+    
+    Reset();
+    TRAP( error, iXmlReader->ParseL( aFs, aFilename ) )
+    if( error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+TInt COMADSFolderObject::ImportFolderXml( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" );
+    LOG(aData);     
+    
+    TInt error;
+    
+    Reset();
+    
+    TRAP(error, iXmlReader->ParseL(aData) );
+    if(error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL( CBufBase& aBuffer )
+    {
+    iDesc = NULL;
+    iBuffer = &aBuffer;
+    iWriteBufPosition = 0;
+    iWriteBufSize = aBuffer.Size();     
+
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL( TDes8& aBuffer )
+    {
+    iDesc = &aBuffer;
+    iBuffer = NULL;
+    
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportL()
+    {
+    // Folder
+    WriteL( KFolderBeginTag );
+    
+    // Name
+    WriteL( KNameBeginTag );
+    WriteEncodedXmlL( iName );
+    WriteL( KNameEndTag );
+    
+    // Created Date
+    TBuf<32> tempdate;
+    tempdate.Format( KDateFormat, iCreatedDate.Year(), iCreatedDate.Month() + 1,
+        iCreatedDate.Day(), iCreatedDate.Hour(), iCreatedDate.Minute(), iCreatedDate.Second() );
+    
+    WriteL( KCreatedBeginTag );
+    WriteL( tempdate );
+    WriteL( KCreatedEndTag );
+    
+    // Modified Date
+    tempdate.Format( KDateFormat, iModifiedDate.Year(), iModifiedDate.Month() + 1,
+        iModifiedDate.Day(), iModifiedDate.Hour(), iModifiedDate.Minute(), iModifiedDate.Second() );
+    
+    WriteL( KModifiedBeginTag );
+    WriteL( tempdate );
+    WriteL( KModifiedEndTag );
+    
+    // Folder end
+    WriteL(KFolderEndTag);
+    }
+    
+void COMADSFolderObject::WriteL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + iTemp.Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, iTemp );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( iTemp );       
+        }   
+    }
+    
+void COMADSFolderObject::WriteEncodedXmlL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+    
+    HBufC8* xmlData = SenXmlUtils::EncodeHttpCharactersLC( iTemp ); 
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + xmlData->Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, *xmlData );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( *xmlData );
+        }   
+        
+    CleanupStack::PopAndDestroy( xmlData );   
+    }           
+    
+TInt COMADSFolderObject::StartDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::EndDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::StartElement(const TDesC8& /*aURI*/, 
+                  const TDesC8& /*aLocalName*/, 
+                  const TDesC8& aName, 
+                  const RAttributeArray& /*apAttrs*/)
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::StartElement" );
+    LOG( aName );    
+    iCurrentElement.Copy( aName );
+    LOGGER_LEAVEFN( "COMADSFolderObject::StartElement" );
+    return KErrNone;
+    }
+                                    
+TInt COMADSFolderObject::EndElement( const TDesC8& /*aURI*/, 
+    const TDesC8& /*aLocalName*/, const TDesC8& /*aName*/ )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::EndElement" );        
+    iCurrentElement.SetLength(0);
+    LOGGER_LEAVEFN( "COMADSFolderObject::EndElement" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::Characters( const TDesC8& aBuf, TInt aStart, TInt aLength )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::Characters" );
+    LOG(aBuf);    
+    
+    TInt error;
+    
+    if( iCurrentElement.Compare( KOMADSFolderElement ) == 0 )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+        return KErrNone;
+        }
+    
+    else if ( iCurrentElement.Compare( KOMADSNameElement ) == 0 )
+        {                
+        CnvUtfConverter converter;
+        TBuf<KMaxFolderNameLength> buf;
+        error = converter.ConvertToUnicodeFromUtf8( buf, aBuf.Mid( aStart, aLength ) );
+        TInt length = buf.Length() + iName.Length();
+        
+        if ( error > 0 )
+            {
+            LOGGER_MSG_EC("Too long name, number of uncorverted bytes: %d", error);
+            }
+        else if ( error != KErrNone )
+            {
+            LOGGER_MSG_EC("ConvertToUnicodeFromUtf8 failed with %d", error);
+            iError = error;
+            }
+        else if ( length > iName.MaxLength() )
+            {
+            LOGGER_MSG_EC("Too long name total: %d", length);
+            }
+        else
+            {
+            iName.Append( buf );
+            }       
+        }
+    else if ( iCurrentElement.Compare( KOMADSCreatedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iCreatedDate );
+        if( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    else if ( iCurrentElement.Compare( KOMADSModifiedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iModifiedDate );
+        if ( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::ParseDateString(const TDesC8& aString, TDateTime& aDateTime)
+    {
+    // Ensure we don't read beyond the buffer limits
+    if ( aString.Length() < 15 )
+        {
+        return KErrArgument;
+        }
+    // Extract the fields from the string
+    TLex8 yearDesc( aString.Mid( 0, 4 ) );
+    TLex8 monthDesc( aString.Mid( 4, 2 ) );
+    TLex8 dayDesc( aString.Mid( 6, 2 ) );
+    // Skip one character here, it's supposed to be 'T'
+    TLex8 hourDesc( aString.Mid( 9, 2 ) );
+    TLex8 minuteDesc( aString.Mid( 11, 2 ) );
+    TLex8 secondDesc( aString.Mid( 13, 2 ) );
+    
+
+    TInt year, month, day, hour, minute, second;
+    TInt error;
+    
+    // Fetch the values to temporary variables
+    if ( ( error = yearDesc.Val(year) ) != KErrNone )
+        return error;
+    if ( ( error = monthDesc.Val(month) ) != KErrNone )
+        return error;
+    if ( ( error = dayDesc.Val(day) ) != KErrNone )
+        return error;
+    if ( ( error = hourDesc.Val(hour) ) != KErrNone )
+        return error;
+    if ( ( error = minuteDesc.Val(minute) ) != KErrNone )
+        return error;
+    if ( ( error = secondDesc.Val(second) ) != KErrNone )
+        return error;
+
+    // Assign values to datetime object
+    if ( ( error = aDateTime.SetYear(year) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetMonth((TMonth)(month-1) )) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetDay(day) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetHour(hour) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetMinute(minute) ) != KErrNone )
+        return error;
+    if ( ( error = aDateTime.SetSecond(second) ) != KErrNone )
+        return error;
+        
+    return KErrNone;
+    }
+
+void COMADSFolderObject::Reset()
+    {
+    iError = KErrNone;
+    iName.SetLength( 0 );
+    iCreatedDate.Set( 2005, EJanuary, 1, 0, 0, 0, 0 );
+    iModifiedDate.Set( 2005, EJanuary, 1, 0, 0, 0, 0 );
+    }
+    
+TInt COMADSFolderObject::Error( TInt aErrorCode )
+    {
+    iError = aErrorCode;
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/snapshotitem.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <msvuids.h>
+#include "snapshotitem.h"
+
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem() : TNSmlSnapshotItem()
+    {
+    iUnread = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// Constructor, takes item id as a parameter
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
+    const TSmlDbItemUid& aParent, TBool aUnread )
+: TNSmlSnapshotItem( aItemId )
+    {
+    SetParentId( aParent );
+    iUnread = aUnread;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::ExternalizeL
+// Writes the contents of this class and it's base to stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TNSmlSnapshotItem::ExternalizeL( aStream );
+    aStream.WriteInt32L( iUnread );
+    TPckgBuf<TFolderName> nameBuf(iFolderName);
+	aStream << nameBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::InternalizeL
+// Reads the contents of this class and it's base from stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::InternalizeL( RReadStream& aStream )
+    {
+    TNSmlSnapshotItem::InternalizeL( aStream );
+    iUnread = aStream.ReadInt32L();
+    TPckgBuf<TFolderName> nameBuf;
+	aStream >> nameBuf;
+	iFolderName = nameBuf();
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::SetUnread
+// Sets unread flag
+// -----------------------------------------------------------------------------
+void TSnapshotItem::SetUnread( TBool aState )
+    {
+    iUnread = aState;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::Unread
+// Gets unread flag
+// -----------------------------------------------------------------------------
+TBool TSnapshotItem::Unread() const
+    {
+    return iUnread;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::SetFolderNameL
+// Sets folder name
+// ----------------------------------------------------------------------------- 
+void TSnapshotItem::SetFolderNameL( const TDesC& aFolderName )
+    {
+    if ( aFolderName.Length() > KMaxFolderNameLength )
+        {
+        User::Leave( KErrTooBig );
+        }
+    iFolderName.Copy( aFolderName );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::FolderName
+// Gets folder name
+// ----------------------------------------------------------------------------- 
+const TDesC& TSnapshotItem::FolderName() const
+    {
+    return iFolderName;
+    }
Binary file omads/omadsextensions/adapters/sms/group/10206B5C.XML has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/group/SmsDataProvider.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006-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:  mmp file for SMS DS Data provider
+*
+*/
+
+
+#include <platform_paths.hrh> 
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+CAPABILITY      CAP_ECOM_PLUGIN
+TARGET          smsdataprovider.dll
+TARGETTYPE      PLUGIN
+UID             0x10009d8d 0x10206B5C
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          SmsDataProvider.cpp
+SOURCE          SmsDataStore.cpp
+SOURCE          SMSAdapterMsvApi.cpp
+SOURCE          VMessageParser.cpp
+SOURCE          ChangeFinder.cpp
+SOURCE          SnapshotItem.cpp
+SOURCE          OMADSFolderObject.cpp
+
+USERINCLUDE     ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+
+SOURCEPATH      ../src
+START RESOURCE  SmsDataProvider.rss
+HEADER
+TARGET          smsdataprovider.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  SmsDataStore.rss
+HEADER
+TARGET          smsdatastore.rsc  
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+
+LIBRARY         ecom.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         gsmu.lib
+LIBRARY         smcm.lib
+LIBRARY         smldataprovider.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY         centralrepository.lib
+LIBRARY         msgs.lib 
+LIBRARY         bafl.lib
+DEBUGLIBRARY    flogger.lib
+LIBRARY         sysutil.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         etext.lib 
+LIBRARY         cntmodel.lib 
+LIBRARY         SenXml.lib 
+LIBRARY         charconv.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build info file for SMS DS adapter
+*
+*/
+
+#include <platform_paths.hrh>
+
+#ifdef __SYNCML_DS_SMS
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./10206B5C.XML      /epoc32/data/Z/private/101F99F6/capability/10206B5C.xml
+./10206B5C.XML      /epoc32/release/winscw/udeb/z/private/101F99F6/capability/10206B5C.xml
+./smsdsa_stub.sis   /epoc32/data/z/system/install/smsdsa_stub.sis
+../rom/smsdsa.iby   CORE_APP_LAYER_IBY_EXPORT_PATH(smsdsa.iby)
+
+PRJ_MMPFILES
+./SmsDataProvider.mmp
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/group/smsdsa_stub.pkg	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+&EN
+
+; Header
+#{"SMS DS Plugin"},(0x10206B5C),1,0,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\smsdatastore.rsc"
+""-"z:\resource\plugins\smsdataprovider.rsc"
+""-"z:\sys\bin\smsdataprovider.dll"
Binary file omads/omadsextensions/adapters/sms/group/smsdsa_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/ChangeFinder.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Private change finder header
+*
+*/
+
+
+#ifndef __CHANGEFINDER_H__
+#define __CHANGEFINDER_H__
+
+// INCLUDES
+#include <msvids.h>
+#include <nsmlchangefinder.h>
+#include "SnapshotItem.h"
+
+// DATATYPES
+typedef CArrayFixSeg<TSnapshotItem> CSnapshotArray;
+
+// Granularity used with dynamic array
+const TInt KSnapshotGranularity = 32;
+
+// CLASS DECLARATION
+
+/**
+* @brief CChangeFinder Class
+* This is a ChangeFinder class, which can be used to track down changes in the message store.
+* It's functionality is equal to CSmlChangeFinder, except the functionality is a bit wider
+* since this class can also detect "partially updated" items. It means that if only the status
+* Bits of the message are changed, it can be detected. It is achieved by using TSnapshotItem
+* class, which contain also this information. Because neither of these classes contained virtual
+* functionality, the functionality of this class couldn't be inherited from the CSmlChangeFinder
+*/
+class CChangeFinder : public CBase
+	{ 
+public:
+	
+	/**
+    * Class constructor, Creates a new class instance.
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    * @return CChangeFinder*, New ChangeFinder instance.
+    */
+    static CChangeFinder* NewL( MSmlSyncRelationship& aSyncRelationship, 
+                               TKeyArrayFix aKey,
+                               TBool& aHasHistory, 
+                               TInt aStreamUid = KNSmlDefaultSnapshotStreamUID );
+
+    /**
+    * Class destructor.
+    */
+	~CChangeFinder();
+	
+    /**
+    * Close ChangeFinder object, stores snapshot.
+    */
+	void CloseL();
+
+    /**
+    * Reset change information, makes all content new from ChangeFinder point of view.
+    */
+	void ResetL();
+
+    /**
+    * Find changed items by comparing snapshots.
+    * 
+    * @param aChangedUids   IN: Array for results.
+    */
+	void FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids );
+
+    /**
+    * Find deleteed items by comparing snapshots.
+    * 
+    * @param aDeletedUids   IN: Array for results.
+    */
+	void FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids );
+	
+    /**
+    * Find new items by comparing snapshots.
+    * 
+    * @param aNewUids   IN: Array for results.
+    */	
+	void FindNewItemsL(CNSmlDataItemUidSet& aNewUids);
+
+    /**
+    * Find moved items by comparing snapshots.
+    * 
+    * @param aMovedUids   IN: Array for results.
+    */	
+	void FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids );
+
+    /**
+    * Add item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to add.
+    */
+	void ItemAddedL( const TSnapshotItem& aItem );
+
+    /**
+    * Delete item from snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to delete.
+    */
+	void ItemDeletedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Update item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to update.
+    */
+	void ItemUpdatedL( const TSnapshotItem& aItem );
+	
+    /**
+    * Move item within snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to move.
+    */
+	void ItemMovedL( const TSnapshotItem& aItem );
+
+    /**
+    * Commit all changes to snapshot, there's nothing to report anymore.
+    */
+	void CommitChangesL();
+
+    /**
+    * Commit a set of items to snapshot, these items won't be reported anymore.
+    * 
+    * @param aUids   IN: a set of items to commit.
+    */
+	void CommitChangesL( const MSmlDataItemUidSet& aUids );
+	
+	/**
+    * Sets new snapshot to compare against.
+    * 
+    * @param aNewSnapshot   IN: a new snapshot.
+    */
+	void SetNewSnapshot( CSnapshotArray* aNewSnapshot );
+	
+	/**
+    * Retrieves DataStore id number.
+    *
+    * @return TInt64, DataStore id.
+    */
+	TInt64 DataStoreUid() const;
+
+	/**
+    * Sets DataStore id number.
+    * 
+    * @param aUid   IN: a new datastore id.
+    */
+	void SetDataStoreUid( TInt64 aUid );
+	
+    /**
+    * Checks whether specific item can be partially updated.
+    * 
+    * @param aUid   IN: item id.
+    * @return TBool Result, ETrue if the item contains only status change (read<->unread).
+    */
+	TBool UpdatePartialL( TSmlDbItemUid& aUid );
+	
+protected:
+	
+    /**
+    * C++ Constructor
+    *
+    * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
+    * @param aKey               IN: Key that is used in sorting snapshot.
+    * @param aStreamUid         IN: Snapshot stream UID.
+    */    
+	CChangeFinder( MSmlSyncRelationship& aSyncRelationship, 
+	              TKeyArrayFix aKey, 
+	              TInt aStreamUid );
+    
+    /**
+    * 2nd-phase Constructor
+    *
+    * @param aHasHistory   IN: ETrue, if there was synchronization history.
+    */    
+    void ConstructL( TBool& aHasHistory );
+
+private:
+
+    /**
+    * Allows access to streams.
+    */
+	MSmlSyncRelationship& iSyncRelationship;
+	
+    /**
+    * New snapshot to compare against.
+    */	
+	CSnapshotArray* iCurrentSnapshot;
+
+    /**
+    * Current snapshot.
+    */
+	CSnapshotArray* iOldSnapshot;
+	
+    /**
+    * Key that is used in sorting snapshot.
+    */
+	TKeyArrayFix iKey;
+	
+    /**
+    * Stream id number to access sync relationship.
+    */	
+	TInt iStreamUid;
+	
+    /**
+    * Data store id number.
+    */	
+	TInt64 iDataStoreUid;
+    };
+
+#endif // __CHANGEFINDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/Logger.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,138 @@
+/*
+* Copyright (c) 2005-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:  Logging macros used by DS plug-in adapters
+*
+*/
+
+
+#ifndef __LOGGER_H__
+#define __LOGGER_H__
+
+#ifdef _DEBUG
+    #ifdef __WINS__
+        // File logging for WINS
+        #define __FLOGGING__
+    #else
+        // Logging with RDebug for target HW
+        #define __CLOGGING__
+        //#define __FLOGGING__ // enable to log file on target HW
+    #endif //__WINS__
+    
+    #include <f32file.h>
+    #include <flogger.h>
+    #include <e32std.h>
+    #include <e32def.h>
+
+    NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+        {
+    public:
+        void Overflow(TDes16& /*aDes*/) {}
+        };
+    
+    NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+        {
+    public:
+        void Overflow(TDes8& /*aDes*/) {}
+        };
+    
+    _LIT(KLogDir, "SMS");
+    _LIT(KLogFile, "SMSDataproviderLog.txt");
+    _LIT( KLogFormat, "[SMSDS] %S");
+    
+    
+    _LIT(KTracePrefix16, "[SMSDS] ");
+    _LIT8(KTracePrefix8, "[SMSDS] ");
+    _LIT8(KFuncEntryFormat8, "%S : Begin");
+    _LIT8(KFuncExitFormat8, "%S : End");
+    _LIT8(KFuncFormat8, "><%S");
+    
+    const TInt KMaxLogLineLength = 512;
+    
+    /**
+    * Old logging macros
+    */
+    #ifdef __FLOGGING__
+        #define LOG( AAA )      RFileLogger::Write( KLogDir,KLogFile,EFileLoggingModeAppend,AAA )
+    #else
+        #define LOG( AAA )
+    #endif
+    #define LOG2( text, par1 )       { FPrint( text, par1 ); }
+    
+    
+    // old function loggin macros
+    #define LOGGER_ENTERFN( name )      {TRACE_FUNC_ENTRY;}
+    #define LOGGER_LEAVEFN( name )      {TRACE_FUNC_EXIT;}
+    
+    #define LOGGER_WRITE( text )             {_LIT( KTemp, text ); FPrint( KTemp );}
+    #define LOGGER_WRITE_1( text,par1 )      {_LIT( KTemp, text ); FPrint( KTemp, par1 );}
+    #define LOGGER_WRITE_2( text,par1,par2 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );}
+    
+    // New function logging macros
+    #define TRACE_FUNC_ENTRY {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncEntryFormat8, &ptr8);}
+    #define TRACE_FUNC_EXIT {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncExitFormat8, &ptr8);}
+    #define TRACE_FUNC {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncFormat8, &ptr8);}
+    
+    
+    // Declare the FPrint function
+    inline void FPrint( TRefByValue<const TDesC16> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+    #if defined ( __FLOGGING__ )
+            RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+    #endif
+        
+        TBuf16<KMaxLogLineLength> theFinalString;
+        theFinalString.Append(KTracePrefix16);
+        TOverflowTruncate16 overflow;
+        theFinalString.AppendFormatList(aFmt,list,&overflow);
+        RDebug::Print(theFinalString);
+        }
+    
+    inline void FPrint(TRefByValue<const TDesC8> aFmt, ...)
+        {
+        VA_LIST list;
+        VA_START(list, aFmt);
+    #ifdef __FLOGGING__
+        RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    #endif
+        TOverflowTruncate8 overflow;
+        TBuf8<KMaxLogLineLength> buf8;
+        buf8.Append(KTracePrefix8);
+        buf8.AppendFormatList(aFmt, list, &overflow);
+        TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+        buf16.Copy(buf8);
+        TRefByValue<const TDesC> tmpFmt(_L("%S"));
+        RDebug::Print(tmpFmt, &buf16);
+        }
+#else // no _DEBUG defined
+    
+    #define LOG( A )
+    #define LOG2( A, B )
+    
+    #define LOGGER_ENTERFN( name )
+    #define LOGGER_LEAVEFN( name )
+    #define LOGGER_WRITE( text )
+    #define LOGGER_WRITE_1( text,par1 )
+    #define LOGGER_WRITE_2( text,par1,par2 )
+    
+    #define TRACE_FUNC_ENTRY
+    #define TRACE_FUNC_EXIT 
+    #define TRACE_FUNC
+    
+
+#endif // _DEBUG
+
+#endif // __LOGGER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/OMADSFolderObject.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+
+#ifndef __OMADSFOLDEROBJECT_H__
+#define __OMADSFOLDEROBJECT_H__
+
+#include <SenXmlReader.h>
+#include <MSenContentHandlerClient.h>
+#include "SmsDataProviderDefs.h"
+
+const TInt KMaxElementLength = 255;
+const TInt KMaxXmlLineLength = 1024;
+
+class COMADSFolderObject : public CBase, public MSenContentHandlerClient
+    {
+public:
+
+    static COMADSFolderObject* NewLC();
+    static COMADSFolderObject* NewL();
+    ~COMADSFolderObject();
+    
+    // Get methods
+    inline const TDesC& GetName() const {return iName;}
+    inline const TDateTime& GetCreatedDate() const {return iCreatedDate;}
+    inline const TDateTime& GetModifiedDate() const {return iModifiedDate;}
+    
+    // Set methods
+    inline void SetName(const TDesC& aName) {iName.Copy(aName);}
+    inline void SetCreatedDate(const TDateTime& aDateTime) {iCreatedDate = aDateTime;}
+    inline void SetModifiedDate(const TDateTime& aDateTime) {iModifiedDate = aDateTime;}
+    
+    // Import & export
+    TInt ImportFolderXml(const TDesC8& aData);
+    TInt ImportFolderXml(RFs& aFs, const TDesC& aFilename);
+    void ExportFolderXmlL(TDes8& aBuffer);
+    void ExportFolderXmlL(CBufBase& aBuffer);
+    
+    // MSenContentHandlerClient virtual functionality
+	TInt StartDocument();
+	TInt EndDocument();
+	TInt StartElement(const TDesC8& aURI, 
+					  const TDesC8& aLocalName, 
+					  const TDesC8& aName, 
+					  const RAttributeArray& apAttrs);
+	TInt EndElement(const TDesC8& aURI, 
+					const TDesC8& aLocalName, 
+					const TDesC8& aName);
+    TInt Characters(const TDesC8& aBuf, TInt aStart, TInt aLength);
+	TInt Error(TInt aErrorCode);
+	
+private:
+	
+   	CSenXmlReader* iXmlReader;
+    void ConstructL();
+    TBuf8<KMaxElementLength> iCurrentElement;
+    TBuf8<KMaxXmlLineLength> iTemp;
+    
+    TBuf<KMaxFolderNameLength> iName;
+    TDateTime iCreatedDate;
+    TDateTime iModifiedDate;
+    TInt iError;
+    
+    void Reset();
+    TInt ParseDateString(const TDesC8& aString, TDateTime& aDateTime);	
+	
+	CBufBase* iBuffer;
+	TInt iWriteBufPosition;
+	TInt iWriteBufSize;
+	TDes8* iDesc;
+	
+	void ExportL();	
+	void WriteL(const TDesC &aData);
+	void WriteEncodedXmlL(const TDesC &aData);
+};
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/SMSAdapterMsvApi.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,326 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSmsAdapterMsvApi header
+*
+*/
+
+
+
+#ifndef SMSADAPTERMSVAPI_H
+#define SMSADAPTERMSVAPI_H
+
+//  INCLUDES
+#include <e32base.h>        // CActive
+#include <msvstd.h>         // TMsvId
+#include <msvapi.h>         // CMsvOperation
+#include <mtclreg.h>		//CClientMtmRegistry
+#include <msvids.h>
+#include <mtclbase.h>
+#include <msvuids.h>
+#include <smut.h>
+ 
+// FORWARD DECLARATIONS
+class CSmsClientMtm;
+class CVMessageParser;
+class CContactDatabase;
+
+// CONSTANTS
+const TInt KMsvMyFoldersEntryIdValue = 0x1008;
+const TInt KMsvMyFoldersTemplatesFolderId = 0x1009;
+
+// CLASS DECLARATION
+
+/**
+* Class CSmsAdapterMsvApi
+* Internal class that provides access to SMS message store.
+*/
+class CSmsAdapterMsvApi : public CBase, public MMsvSessionObserver 
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+         static CSmsAdapterMsvApi* NewL();
+                
+        /**
+        * Destructor.
+        */
+        virtual ~CSmsAdapterMsvApi();
+        
+    private: // Private constructor functions
+        
+        /**
+        * C++ default constructor.
+        * C++ default constructor can NOT contain any code, that
+        * might leave.
+        */
+        CSmsAdapterMsvApi();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();        
+
+    public: // New functions
+	    
+        /**
+        * Add a SMS message. The given SMS message is stored to the target folder. 
+        * 
+        * @param aSm       IN: Contains SMS message in decoded format
+        * @param aFolder   IN: The folder in which the SM will be stored 
+        * @param aSmId     OUT: The index created for the added SM.
+        */
+		 void AddSML( 
+			CVMessageParser& aSm,
+            TMsvId aFolder,                                                                                                                                                                                                          
+            TMsvId& aSmId );
+
+        /**
+        * Replace existing SMS message
+        * 
+        * @param aSmId      IN: the index to the replaceable SM  
+        * @param aSm        IN: Contains data of the new SM        
+        */
+         void ReplaceSML (
+            TMsvId aSmId, 
+			CVMessageParser& aSm ); 
+
+        /**
+        * Delete a SMS message. 
+        * 
+        * @param aSmId   IN: the index to the SM, which will be deleted                             
+        */
+        void DeleteSML( TMsvId aSmId );
+         
+        /**
+        * Delete a SMS message. 
+        * 
+        * @param aUid   IN: the index to the SM, which will be deleted
+        *
+        * @return   KErrNone in success. KErrInUse if folder was not deleted because it was not empty.                             
+        */         
+        TInt CSmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid );
+
+        /**
+        * Retriveve SMS message from the message store.
+        * 
+        * @param aSmId      IN: Index to the SM, which will be retrieved    
+        * @param aParent    OUT: Index of parent folder        
+        * @param aSm        OUT: The SM data is stored into this object.
+        * @param aUnread    OUT: Whether the SM is unread or not 
+        */
+         void RetrieveSML(
+            TMsvId aSmId,
+            TMsvId& aParent,
+            CVMessageParser& aSM,                  
+            TBool& aUnread );
+
+        /**
+        * Sends the specified SM.
+        *  
+        * @param aSmId     IN: Index to the SM, which will be sent.
+        */
+         void SendSML( TMsvId aSmId );
+
+        /**
+        * This function can be used when client needs direct access to CMsvSession.
+        * @return	 ponter to opened message server session.
+        */
+		 CMsvSession* MsvSessionL();
+
+       /**
+        * Empties folder from SMS messages.
+        *
+        * @param    aFolderId   IN: TMsvId of the folder
+        */
+        void CleanFolderL( TMsvId aFolderId);
+        
+       /**
+        * Empties user folders under My Folders from SMS messages
+        */       
+        void CSmsAdapterMsvApi::CleanUserFoldersL(); 
+        
+       /**
+        * Empties folder from SMS messages and returns list of deleted messages
+        * Caller is responsible of deleting returned list.
+        *
+        * @param    aFolderId   IN: TMsvId of the folder
+        *
+        * @return   List of identifiers of deleted messages
+        */       
+        CMsvEntrySelection* CleanFolderGetMsvIdsL(TMsvId aFolderId);
+
+       /**
+        * Checks whether disk space is below critical level.
+        *
+        * @param    aDataSize	Size of data to be added to disk.
+        */
+		TBool DiskSpaceBelowCriticalLevelL( TInt aDataSize );
+
+        /**
+        * Updates SM status in inbox
+        * 
+        * @param aSmId      IN: the index to the SM  
+        * @param aSm        IN: Contains status of the new SM        
+        */
+		void UpdateSMStatusL( TMsvId aSmId, CVMessageParser& aSm );
+	
+        /**
+        * Moves SM to another folder
+        * 
+        * @param aSmId      IN: the index to the SM  
+        * @param aParentId  IN: Contains the target folder 
+        */		
+		void MoveSML( TMsvId aSmId, TMsvId aParentId );
+		
+       /**
+        * Valid folder checks if the folder is valid.
+        * The caller of the function can set, if Outbox folder is valid or not.
+        * 
+        * @param aFolder   folder
+        * @param aOutboxValid if the MM is outbox is valid folder or not
+        * 
+        * @return ETrue when the folder is valid.
+        * @return EFalse when the folder is not valid.
+        */
+        TBool ValidFolderL( TMsvId aFolder , TBool aOutboxValid = ETrue );		
+		
+       /**
+        * Creates new user defined folder
+        * 
+        * @param aFolder    OUT: index of the new folder
+        * @param aName      IN: name of the new folder
+        *
+        * @return     KErrNone or error
+        */				
+		TInt AddUserFolderL( TMsvId& aFolder, const TDesC& aName );
+		
+       /**
+        * Updates name of user defined folder
+        * 
+        * @param aFolder    IN: index of the folder
+        * @param aName      IN: new name of the folder
+        *
+        * @return     KErrNone or error
+        */					
+		TInt UpdateUserFolderL( TMsvId aFolder, const TDesC& aName );
+		
+        /**
+        * Searches user folder with given UID
+        * 
+        * @param aFolder     IN: Folder UID
+        * @param aFound      OUT: name of found user folder
+        * @param aDate       OUT: time stamp of found user folder 
+        *
+        * @return	Return value indicates whether folder was found or not
+        */	        
+        TBool FindUserFolderL(TMsvId aFolder, TPtrC& aName, TTime& aDate);	
+        
+        /**
+        * Searches user folder with given UID
+        * 
+        * @param aFolder     IN: Folder UID
+        *
+        * @return	Return value indicates whether folder was found or not
+        */	        
+        TBool FindUserFolderL(TMsvId aFolder);	
+        
+    protected:  // Functions from base classes
+        
+        /**
+        * From MMsvSessionObserver. Message server event handler function.
+        * 
+        * @param aEvent    the caller of the method sets the value.
+        * @param aArg1     depends on the aEvent value
+        * @param aArg2     depends on the aEvent value
+        * @param aArg3     depends on the aEvent value
+        * 
+        */
+        virtual void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
+
+    private:	// Internal functions
+
+        /**
+        * Updates existing SMS message with given values.
+		* Used internally by AddSML and ReplaceSML
+        * 
+        * @param aSmId      IN: the index to the SM  
+        * @param aSm        IN: contains data of the SM        
+		* @param aNewSm		IN: indicates whether this SM is a new one 
+        */
+		void DoUpdateSML( TMsvId aSmId, CVMessageParser& aSm, TBool aNewSm );
+         
+        /**
+        * Check whether folder with given name exists
+        * 
+        * @param aName     IN: Folder name
+        * @parem aFolder   OUT: Folder UID if matching folder was found. 
+        *
+        * @return	ETrue or EFalse 
+        */	       
+        TBool FindUserFolderL(const TDesC& aName, TMsvId& aFolder);
+
+        /**
+        * Test whether given character needs unicode coding when constructing
+		* a SMS message. 
+		* 7-bit coding is used if there are no unicoder characters in the message.
+        * 
+        * @param aValue     IN: Given character value   
+        *         
+		* @return	ETrue if unicode coding is needed, EFalse otherwise
+        */
+		TBool IsUnicode( const TUint16 aValue );
+
+        /**
+        * Convert given home time to universal time.
+        * 
+        * @param aTime     IN: Home time 
+        *
+        * @return	Universal time   
+        */		
+		TTime UniversalTimeFromHomeTime( TTime aTime );
+
+        /**
+        * Convert given universal time to home time.
+        * 
+        * @param aTime     IN: Universal time
+        *
+        * @return 	Home time   
+        */				
+		TTime HomeTimeFromUniversalTime( TTime aTime );
+		
+        /**
+        * Find contact name from address book for given number
+        * 
+        * @param aTime     IN: Phone number
+        * @param aName     OUT: Contact name, empty if suitable contact not found
+        */			
+		void FetchNameFromContactsL(const TDesC& aNumber, TDes& aName);
+		
+    
+    private:    // Data
+        
+        CMsvSession* 			iSession;
+        CClientMtmRegistry* 	iMtmReg;
+		CSmsClientMtm* 			iMtm;
+
+		RFs		iFs;
+		TInt	iMessageDrive;
+		
+		CContactDatabase* 	iContactsDb;
+		
+    };
+
+#endif      //SMSADAPTERMSVAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/SmsDataProvider.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  CSmsDataProvider header
+*
+*/
+
+
+#ifndef __SMSDATAPROVIDER_H__
+#define __SMSDATAPROVIDER_H__
+
+// INCLUDES
+#include <SmlDataProvider.h>
+
+// FORWARD DECLARATIONS
+class CSmsDataStore;
+class CSmlDataStoreFormat;
+
+// CLASS DECLARATION
+
+/**
+* Class CSmsDataProvider
+* Data Provider class of SMS DS Plug In Adapter implementation.
+* Inherited from generic CSmlDataProvider class.
+*/
+class CSmsDataProvider : public CSmlDataProvider, public MMsvSessionObserver
+    {
+public:  
+	
+    /**
+    * Constructor.
+	*
+	* @return CSmsDataProvider*, a new CSmsDataProvider instance.
+    */
+    static CSmsDataProvider* NewL();
+
+	/**
+    * Destructor.
+    */
+    virtual ~CSmsDataProvider();
+
+    /**
+    * Callback from MMsvSessionObserver.
+    */
+	void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
+
+protected: // Inherited from CSmlDataProvider
+
+	virtual void DoOnFrameworkEvent( TSmlFrameworkEvent, TInt aParam1, TInt aParam2 );
+	virtual TBool DoSupportsOperation( TUid aOpId ) const;
+	virtual const CSmlDataStoreFormat& DoStoreFormatL();
+	virtual CDesCArray* DoListStoresLC();
+	virtual const TDesC& DoDefaultStoreL();
+	virtual CSmlDataStore* DoNewStoreInstanceLC();
+    virtual void DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& aServerDataStoreFormat, RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo );
+    virtual void DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterChangeInfo& aChangeInfo ); 
+	virtual const RPointerArray<CSyncMLFilter>& DoSupportedServerFiltersL();
+	virtual TBool DoSupportsUserSelectableMatchType() const;
+	virtual HBufC* DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterMatchType aMatch, TDes& aFilterMimeType, TSyncMLFilterType& aFilterType, TDesC& aStoreName );
+	virtual void DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& aFilters, TDes& aFilterMimeType, RPointerArray<CSmlDataProperty>& aProperties, TDesC& aStoreName );
+
+private:
+	
+	/**
+    * C++ Constructor.
+    */
+    CSmsDataProvider();
+
+	/**
+    * 2nd-phase Constructor.
+    */
+    void ConstructL();
+   
+	/**
+    * Creates new DataStore format.
+    */
+    CSmlDataStoreFormat* DoOwnStoreFormatL();
+
+private:
+
+	/**
+    * String pool, used in store format creation.
+    */
+    RStringPool iStringPool;
+
+	/**
+    * Data store format.
+    */
+    CSmlDataStoreFormat* iOwnStoreFormat;
+
+	/**
+    * Supported filters (none supported at the moment).
+    */
+    RPointerArray<CSyncMLFilter> iFilters;
+    
+	/**
+    * File system handle.
+    */
+    RFs iRFs;
+
+	/**
+    * Message store handle.
+    */
+	CMsvSession* iMsvSession;
+
+	/**
+    * Reserved pointer for future extension.
+    */
+    TAny* iReserved;
+
+    };
+
+#endif      // __SMSDATAPROVIDER_H__  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/SmsDataProviderDefs.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2005-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:  Constant definitions used by SMS DS Plug-in Adapter
+*
+*/
+
+
+#ifndef __SMSDATAPROVIDERDEFS_H__
+#define __SMSDATAPROVIDERDEFS_H__ 
+
+
+// ------------------------------------------------------------------------------------------------
+// Databases
+// ------------------------------------------------------------------------------------------------
+// Database name
+_LIT( KNSmlDefaultLocalDbName, "SmsSyncLocalDb" );
+
+// Resource file for CSmlDataStoreFormat
+
+// The following works with DS plugin added into ROM image 
+_LIT( KSmsStoreFormatRscRom,"z:smsdatastore.rsc");
+
+// The following works with DS plugin installed from SIS
+_LIT( KSmsStoreFormatRsc,"smsdatastore.rsc");
+
+// ------------------------------------------------------------------------------------------------
+// Constants
+// ------------------------------------------------------------------------------------------------
+// max foldername
+const TInt KMaxFolderNameLength = 50;
+
+// Implementation uid
+const TUint KSmsDataProviderImplUid = 0x10206B5C;
+
+// ------------------------------------------------------------------------------------------------
+// Macros
+// ------------------------------------------------------------------------------------------------
+#define SAFEDELETE( x ) {delete x; x = NULL;}
+#define SAFEDELETEARRAY( x ) {delete[] x; x = NULL;}
+
+#endif // __SMSDATAPROVIDERDEFS_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/SmsDataStore.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,265 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSmsDataStore header
+*
+*/
+
+
+#ifndef __SMSDATASTORE_H__
+#define __SMSDATASTORE_H__
+
+// INCLUDES
+#include <SmlDataProvider.h>
+#include "SnapshotItem.h"
+#include "ChangeFinder.h"
+
+// FORWARD DECLARATIONS
+class CSmsAdapterMsvApi; 
+class CNSmlDataItemUidSet;
+class TNSmlSnapshotItem;
+class CVMessageParser;
+class COMADSFolderObject;
+
+// CLASS DECLARATION
+
+/**
+* Class CSmsDataStore
+* Data Store class of SMS DS Plug In Adapter implementation.
+* Inherited from generic CSmlDataStore class.
+*/
+class CSmsDataStore : public CSmlDataStore
+    {
+public:  
+    
+    /**
+    * Constructor, leaves the created instance into the CleanupStack.
+	*
+	* @return CSmsDataStore*, a new CSmsDataStore instance.
+    */
+    static CSmsDataStore* NewLC();
+
+	/**
+    * Destructor
+    */
+    virtual ~CSmsDataStore();
+
+protected:
+	
+   	// Virtual functionality from CSmlDataStore, for comments see the CSmlDataStore header file
+	virtual void DoOpenL( const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus );
+	virtual void DoCancelRequest();
+	virtual const TDesC& DoStoreName() const;
+	virtual void DoBeginTransactionL();
+	virtual void DoCommitTransactionL( TRequestStatus& aStatus );
+	virtual void DoRevertTransaction( TRequestStatus& aStatus );
+	virtual void DoBeginBatchL();
+	virtual void DoCommitBatchL( RArray<TInt>& aResultArray, TRequestStatus& aStatus );
+	virtual void DoCancelBatch();
+	virtual void DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat );
+	virtual void DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize );
+	virtual TInt DoMaxObjectSize() const;
+	virtual void DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus );
+	virtual void DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus );
+	virtual void DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aFieldChange, TRequestStatus& aStatus );
+	virtual void DoReadItemL( TDes8& aBuffer );
+	virtual void DoWriteItemL( const TDesC8& aData );
+	virtual void DoCommitItemL( TRequestStatus& aStatus );
+	virtual void DoCloseItem();
+	virtual void DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus );
+	virtual void DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
+	virtual void DoSoftDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
+	virtual void DoDeleteAllItemsL( TRequestStatus& aStatus );
+	virtual TBool DoHasSyncHistory() const;
+	virtual const MSmlDataItemUidSet& DoAddedItems() const;
+	virtual const MSmlDataItemUidSet& DoDeletedItems() const;
+	virtual const MSmlDataItemUidSet& DoSoftDeletedItems() const;
+	virtual const MSmlDataItemUidSet& DoModifiedItems() const;
+	virtual const MSmlDataItemUidSet& DoMovedItems() const;
+	virtual void DoResetChangeInfoL( TRequestStatus& aStatus );
+	virtual void DoCommitChangeInfoL( TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems );
+	virtual void DoCommitChangeInfoL( TRequestStatus& aStatus );
+
+private: 
+
+
+	/**
+    * Constructor.
+    */
+    CSmsDataStore();
+
+	/**
+    * 2nd-phase Constructor.
+    */
+    void ConstructL();
+	
+	/**
+    * Registers snapshot to ChangeFinder.
+    */
+	void RegisterSnapshotL() const;
+
+	/**
+    * Registers a single folder to snapshot, used by RegisterSnapshotL.
+    * 
+    * @param aSnapshot	IN: a snapshot item array.
+    * @param aId		IN: folder id.
+	* @return TInt, Not used.
+    */
+	TInt RegisterFolderL( CSnapshotArray* aSnapshot, const TMsvId& aId ) const;
+	
+	/**
+    * Registers user folder messages to snapshot, used by RegisterSnapshotL.
+    * 
+    * @param aSnapshot	IN: a snapshot item array.
+	* @return TInt, Not used.
+    */	
+    TInt RegisterUserFoldersL(CSnapshotArray* aSnapshot) const;
+	
+private: // Data members
+
+	/**
+	* @brief Data Store states:
+	* ESmsClosed:			Store is closed.
+    * ESmsOpenAndWaiting:	Store is ready to be used.
+    * ESmsItemOpen:			Item is being read.
+    * ESmsItemCreating:		Item is being created.
+    * ESmsItemUpdating:		Item is being updated.
+	*/
+    enum TState
+        {
+        ESmsClosed = 0,		
+        ESmsOpenAndWaiting,	
+        ESmsItemOpen,		
+        ESmsItemCreating,	
+        ESmsItemUpdating	
+        };
+
+    /**
+	* @brief Possible MIME types:
+	* EMessageFolder:		Message folder
+    * ESmsMessageItem:  	SMS message.
+	*/
+    enum TMimeType
+        {
+        EMessageFolder = 0,
+        ESmsMessage
+        };     	
+
+    /**
+	* Access to streams, used by ChangeFinder.
+	*/
+    MSmlSyncRelationship* iContext;
+	
+    /**
+	* A flag indicating the existence of synchronization history.
+	*/
+    TBool iHasHistory;
+    /**
+	* Flag indicating, whether database is opened.
+	*/
+    TBool iDataBaseOpened;
+    /**
+	* Pointer to the variable, receiving the created Uid.
+	*/
+	TSmlDbItemUid* iCreatedUid;
+	
+    /**
+	* The state of the active object.
+	*/
+	TState iCurrentState;
+	
+	/**
+	* MIME type of the active object
+	*/
+	TMimeType iMimeType;
+    
+    /**
+	* Key that is used in sorting snapshot.
+	*/
+    const TKeyArrayFix iKey;			
+    /**
+	* Change finder, used to determine db modifications.
+	*/
+    CChangeFinder* iChangeFinder;
+            
+    /**
+	* Used to access SMS message store;
+	*/
+	CSmsAdapterMsvApi* iMsvApi;
+	
+    /**
+	* The location for temporary data
+	*/
+    CBufFlat* iDataBuffer;
+    /**
+	* Current position in a temporary data buffer (write).
+	*/
+    TInt iWriterPosition;
+    /**
+	* Current position in a temporary data buffer (read).
+	*/
+    TInt iReaderPosition;
+    
+    /**
+	* Stores the currently active message id.
+	*/
+    TSmlDbItemUid iCurrentId;
+    /**
+	* Stores the parent id of currently active message.
+	*/
+    TSmlDbItemUid iParentId;
+    
+    /**
+	* Used to get asynchronous return values.
+	*/
+	TRequestStatus*  iCallerStatus;
+    
+    /**
+	* Used to store new items.
+	*/
+	CNSmlDataItemUidSet* iNewItems;
+    /**
+	* Used to store deleted items.
+	*/
+    CNSmlDataItemUidSet* iDeletedItems;
+    /**
+	* Used to store updated items.
+	*/
+    CNSmlDataItemUidSet* iUpdatedItems;
+    /**
+	* Used to store moved items.
+	*/
+    CNSmlDataItemUidSet* iMovedItems;
+    /**
+	* Used to store soft-deleted items (not supported).
+	*/
+    CNSmlDataItemUidSet* iSoftDeletedItems;
+
+    /**
+	* Used to parse VMessages
+	*/
+    CVMessageParser* iMessageParser;
+    
+    /**
+	* Used to parse OMA DS Folder Objects
+	*/    
+    COMADSFolderObject* iFolderObjectParser;
+
+    /**
+	* Reserved pointer for future extension.
+	*/
+    TAny* iReserved;
+    };
+
+#endif      // __SMSDATASTORE_H__  
+            
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/SnapshotItem.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Private snapshot item header
+*
+*/
+
+
+#ifndef __SNAPSHOTITEM_H__
+#define __SNAPSHOTITEM_H__
+
+// INCLUDES
+#include <msvids.h>
+#include <nsmlsnapshotitem.h>
+#include "SmsDataProviderDefs.h"
+
+typedef TBuf<KMaxFolderNameLength> TFolderName;
+
+// CLASS DECLARATION
+
+/**
+* @brief TSnapshotItem
+* This class represents a single item in the ChangeFinder snapshot.
+* It's derived from the generic snapshot item and extended
+* to contain the read/unread information, which is mandatory when 
+* partial update of the messages is required.
+*/
+
+class TSnapshotItem : public TNSmlSnapshotItem
+	{ 
+public:
+	
+	/**
+    * Constructor
+    */
+	TSnapshotItem();
+
+	/**
+    * Constructor
+    * 
+    * @param aItemId   IN: id of the item.
+    * @param aParent   IN: parent item, 0 as default.
+    * @param aUnread   IN: read/unread information, the default is read.
+    */
+	TSnapshotItem( const TSmlDbItemUid& aItemId, const TSmlDbItemUid& aParent = 0, TBool aUnread = EFalse );
+	
+	/**
+    * Writes the item to a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is to be written.
+    */
+	void ExternalizeL( RWriteStream& aStream ) const;
+
+	/**
+    * Reads item from a stream.
+    * 
+    * @param aStream   IN: a reference to a stream, where this item is read from.
+    */
+	void InternalizeL( RReadStream& aStream );	
+	
+	/**
+    * Sets the read flag
+    * 
+    * @param aState   IN: a new state.
+    */
+	void SetUnread( TBool aState ); 
+	
+	/**
+    * Sets the read flag
+    * 
+    * @return TBool, ETrue if the item is not read and EFalse if it has been read.
+    */
+	TBool Unread() const;	
+	
+	void SetFolderNameL( const TDesC& aFolderName );
+	
+	const TDesC& FolderName() const;
+	
+private:
+
+    /**
+    * Read / Unread information
+    */
+	TBool       iUnread;
+	
+	TFolderName iFolderName;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/inc/VMessageParser.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,352 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CVMessageParser header
+*
+*/
+
+
+#ifndef VMESSAGEPARSER_H
+#define VMESSAGEPARSER_H
+
+#include "OMADSFolderObject.h"
+
+
+// CONSTANTS
+_LIT(KVMsgTagBegin, "BEGIN:");
+_LIT(KVMsgTagEnd, "END:");
+_LIT(KVMsgTagStatus, "X-IRMC-STATUS:");
+_LIT(KVMsgTagBox, "X-IRMC-BOX:");
+_LIT(KVMsgTagVersion, "VERSION:");
+_LIT(KVMsgTagName, "N:");
+_LIT(KVMsgTagTelephone, "TEL:");
+_LIT(KVMsgTagDateTime, "X-NOK-DT:");
+_LIT(KVMsgTagDate, "Date:");
+_LIT(KVMsgSectionVMsg, "VMSG");
+_LIT(KVMsgSectionVCard, "VCARD");
+_LIT(KVMsgSectionVEnv, "VENV");
+_LIT(KVMsgSectionVBody, "VBODY");
+_LIT(KVMsgSectionEndVBody, "END:VBODY");
+_LIT(KVMsgLineFeed, "\n");
+_LIT(KDesNoData, "");
+_LIT(KVMsgVersion, "1.1");
+_LIT(KVMsgVCardVersion, "2.1");
+_LIT(KVMsgStatusRead, "READ");
+_LIT(KVMsgStatusUnread, "UNREAD");
+_LIT(KVMsgStatusSent, "SENT");
+_LIT(KVMsgStatusUnsent, "UNSENT");
+_LIT(KFolderInbox, "INBOX");
+_LIT(KFolderOutbox, "OUTBOX");
+_LIT(KFolderDraft, "DRAFT");
+_LIT(KFolderSent, "SENT");
+_LIT(KFolderMyFolders, "MY FOLDERS");
+_LIT(KFolderUnspesified, "");
+const TInt KIndentStepSize = 1;
+
+
+// FORWARD DECLARATIONS
+class CRichText;
+
+// CLASS DECLARATION
+
+const TInt KNameMaxLength = 32;
+const TInt KNumberMaxLength = 48;
+
+/**
+* Class CVMessageParser
+* Helper class for converting SMS message information to/from text/x-VMessage.
+*/
+class CVMessageParser: public CBase 
+	{
+public: // Data types
+
+	struct TTelephoneNumber
+		{
+		TBuf<KNameMaxLength> iName;
+		TBuf<KNumberMaxLength> iNumber;
+		};
+		
+public: // Constructors and destructor
+
+	/**
+    * Two-phased constructor.
+    */
+	static CVMessageParser* NewL();
+
+	/**
+    * Two-phased constructor leaving item to clenup stack
+    */
+	static CVMessageParser* NewLC();
+
+    /**
+    * Destructor.
+    */
+	~CVMessageParser();
+
+private: // Private constructors
+
+    /**
+    * C++ default constructor.
+    * C++ default constructor can NOT contain any code, that
+    * might leave.
+    */
+	CVMessageParser();
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+	void ConstructL();
+
+public: // New functions
+
+    /**
+    * This function decodes received text/x-vMessage and stores the data
+    * to member variables of this class.
+    * 
+    * @param aMessage  IN: buffer containing received text/x-vMessage
+	* @return TInt Result, Length of SMS message body or negative error code.
+    */
+	TInt ParseMessageL( const TDesC8& aMessage );
+
+    /**
+    * This function constructs a text/x-vMessage based on the data stored
+    * to member variables of this class.
+    * 
+    * @param aMessage  OUT: dynamic buffer where text/x-vMessage is constructed
+    */
+	void ConstructMessageL( CBufBase& aMessage );
+
+    /**
+    * Initialises all variables to with default values
+    */
+	void ResetAll();
+
+    /**
+    * Loads message body data to given rich text object
+    * 
+    * @param aMsgBody	where to load the data
+    */
+	void LoadMessageBodyL( CRichText& aMsgBody );
+
+    /**
+    * Stores message body data from given rich text object
+    * 
+    * @param aMsgBody	where from store the data
+    */
+	void StoreMessageBodyL( CRichText& aMsgBody );
+
+    /**
+    * Parses telephone number and name from the string containing number and possibly contact name
+    * 
+    * @param aNumberSring	IN: String from which to parse the number (like "Abc Pqr <+0123456789>")
+	* @param aNumberStore	OUT: Variable where to store the output data
+	* @return TBool		ETrue if operation was successful
+    */
+	TBool ParseTelephoneNumber(const TDesC& aNumberString, TTelephoneNumber& aNumberStore);
+
+private: // Internal functions used by ReadMessage() 
+
+    /**
+    * Reads and decodes text/x-VMessage header. 
+	*
+	* @return TInt	KErrNone or negative error code
+    */
+	TInt ReadMessageHeader();
+
+    /**
+    * Reads and decodes envelope part of text/x-VMessage header. 
+	* There can be multiple envelopes, which are handled recursively.
+	*
+	* @return TInt	KErrNone or negative error code
+    */
+	TInt ReadEnvelope();
+	
+    /**
+    * Reads and parses time stamp field found from vMessage starting from the current read position.
+    * Note that this field is optional. 
+	*
+	* @param aTimetstamp	IN: Timestamp field found from vMessage
+	* @param aUniversalTime OUT: Parsed timestand as universal time
+	* @return TInt	KErrNone if operation succeeded
+    */	
+    TInt ReadTaggedTimeStamp( TTime& aUniversalTime );
+
+    /**
+    * Reads and decodes text/x-VMessage body.
+	*
+	* @return TInt	Length of message body or negative value in error case
+    */
+	TInt ReadMessageBodyL();
+
+    /**
+    * Raeds VCARD section of text/x-vMessage - contains cotact information
+    * 
+    * @param aResult	telephone number and contact name found is stored here
+	* @return TInt Result
+    */
+	TInt ReadVCard(TTelephoneNumber& aResult);
+
+    /**
+    * Searches next given message tag with given value from text/x-VMessage
+    * 
+    * @param aMsgTag  IN: Message tag to be found 
+	* @param aValue	  IN: Expected value of the message tag to be found
+	* @return TInt Result, Starting point of the message tag. KErrNotFound if not found.
+    */
+	TInt FindMessageTagWithValue( const TDesC& aMsgTag, const TDesC& aValue );
+
+    /**
+    * Searches next given message tag from text/x-VMessage and gets it's value
+	* Value is expected to start from tag and end to newline.
+    * 
+    * @param aMsgTag  IN: Message tag to be found 
+	* @param aValue	  OUT: Value of the message tag
+	* @param aMoveReadPosition IN: whether moving start point of seach for the next field forward or not 
+	* @return TInt Result, Starting point of the message tag. KErrNotFound if not found.
+    */
+	TInt GetMessageTagValue( const TDesC& aMsgTag, TDes& aValue, TBool aMoveReadBufPos = ETrue );
+
+   /**
+    * Stores a portion of message data from text/x-vMessage to local descriptor varíable.
+	* Conversion from TDes8 to TDes16 is done and sufficient length of local descriptor
+	* is checked - no more bytes than maximum length of the descriptor will be copied.
+    * 
+    * @param aStart		 IN: Start point of data to be copied in text/x-vMessage
+	* @param aLength	 IN: Length of data to be copied
+	* @param aLocalStore OUT: Place where the data will be copied
+    */
+	void StoreMessageDataField(TInt aStart, TInt aLength, TDes& aLocalStore);
+
+private: // Internal functions used by WriteMessageL() 
+
+    /**
+    * Writes message properties to text/x-VMessage header. 
+    */
+	void WriteMessagePropertiesL();
+
+    /**
+    * Writes message VCARD information to text/x-VMessage header. 
+    */
+	void WriteMessageVCARDL(const TDesC& aName, const TDesC& aNumber);
+
+    /**
+    * Writes message envelope information to text/x-VMessage header. 
+    */
+	void WriteMessageEnvelopeL();
+	
+    /**
+    * Writes tagged timestamp field to vMessage in format
+    * X-NOK-DT:yyyymmddThhmmssZ (universal time format)
+    *
+    * @param aUniversalTime 	IN: Time value to be used
+    */	
+	void WriteTaggedTimestampL( TTime aUniversalTime );
+
+    /**
+    * Writes message body to text/x-VMessage. 
+    */
+	void WriteMessageBodyL();
+
+    /**
+    * Writes one line to text/x-vMessage
+    * 
+    * @param aMsgTag        IN: Message tag to use
+	* @param aMsgTagData	IN: Message tag value to use
+	* @param aIndent		IN: Whether indentication is used or not
+    */
+	void WriteMessageLineL( const TDesC& aMsgTag, const TDesC& aMsgTagData, TBool aIndent = EFalse );
+
+    /**
+    * Writes given data to text/x-vMessage.
+	* Size of pre-allocated dynamic buffer is checked and new size allocated if necessary.
+    * 
+    * @param aDate			IN: Data to be written
+    */
+	void WriteToMessageL( const TDesC& aData );
+
+    /**
+    * Gets currect indentication level for writing message line.
+    * 
+    * @param aMsgTag		IN: Message tag used in the line
+    */
+	TInt GetIndentLevel( const TDesC& aMsgTag );
+
+    /**
+    * Fills fixed size buffer with given data in safe way so that max size will not be exeeded.
+    * 
+    * @param aData			IN: Input data
+	* @param aBuffer		OUT: Buffer to fill
+    */
+	void AssignDataToBuffer( const TDesC& aData, TDes& aBuffer );
+	
+
+
+
+
+public: // Public member variables. Contain text/x-vMessage data.
+		
+	
+	/**
+    * Actual message body is stored here
+    */
+	HBufC*	iMessageBody;
+	
+    /**
+    * Message time stamp in universal time
+    */
+	TTime		iUniversalTime;	
+
+    /**
+    * Message time stamp in home time
+    */
+	TTime		iHomeTime;
+
+    /**
+    * Message folder name 
+    */
+	TBuf<KMaxFolderNameLength>	iFolder;
+	
+   /**
+    * Message status
+    */
+	TBuf<8>	iStatus;
+
+   /**
+    * Sender phone number
+    */
+	TTelephoneNumber	iSender;
+
+   /**
+    * Recipient phone numbers
+    */	
+	RArray<TTelephoneNumber> iRecipients;
+
+private: // Internal member variables
+		
+	/**
+    * Internal variables used for parsing vMessage
+    */
+	TInt		iReadBufPosition;
+	TPtrC		iReadBuf;
+
+	/**
+    * Internal variables used for constructing vMessage
+    */
+	TInt		iWriteBufPosition;
+	TInt		iWriteBufSize;
+	TInt		iWriteIndentLevel;
+	CBufBase*	iWriteBuf;
+
+	};
+
+#endif // VMESSAGEPARSER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/rom/smsdsa.iby	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for SMS DS adapter binaries
+*
+*/
+
+
+#ifndef __SMSDSA_IBY__
+#define __SMSDSA_IBY__
+
+#ifdef __SYNCML_DS_SMS
+
+ECOM_PLUGIN(smsdataprovider.dll,smsdataprovider.RSC)
+data=DATAZ_\RESOURCE_FILES_DIR\smsdatastore.RSC         RESOURCE_FILES_DIR\smsdatastore.RSC
+data=DATAZ_\private\101F99F6\capability\10206B5C.XML    private\101F99F6\capability\10206B5C.XML
+data=ZSYSTEM\install\smsdsa_stub.sis                    system\install\smsdsa_stub.sis
+
+#endif
+
+#endif //__SMSDSA_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/ChangeFinder.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,697 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include "ChangeFinder.h"
+#include "Logger.h"
+
+const TUint KSnapshotFormatVersion ( 0xf0000001 ); // format version
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::NewL
+// Static function to create CChangeFider object(s)
+// -----------------------------------------------------------------------------
+CChangeFinder* CChangeFinder::NewL( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey,
+        TBool& aHasHistory, TInt aStreamUid )
+    {
+    CChangeFinder* self = new (ELeave) CChangeFinder( aSyncRelationship, aKey, aStreamUid );
+    CleanupStack::PushL( self );
+    self->ConstructL( aHasHistory );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CChangeFinder
+// Constructor for the class
+// -----------------------------------------------------------------------------
+CChangeFinder::CChangeFinder( MSmlSyncRelationship& aSyncRelationship, TKeyArrayFix aKey, TInt aStreamUid ) :
+iSyncRelationship( aSyncRelationship ),
+iKey( aKey ),
+iStreamUid( aStreamUid ),
+iDataStoreUid( KErrNotFound )
+    {
+        
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::~CChangeFinder
+// Destructor for the class, closes the ChangeFinder and writes snapshot to stream
+// -----------------------------------------------------------------------------
+CChangeFinder::~CChangeFinder()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::~CChangeFinder" );
+    TInt error;
+    TRAP( error, CloseL() );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE( "CChangeFinder::~CChangeFinder, CloseL failed." );
+        }
+    
+    delete iCurrentSnapshot;
+    delete iOldSnapshot;
+    
+    LOGGER_LEAVEFN( "CChangeFinder::~CChangeFinder" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ConstructL
+// 2nd phase constructor for the class, reads snapshot from stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::ConstructL( TBool& aHasHistory )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ConstructL" );
+        
+    aHasHistory = EFalse;
+    RReadStream readStream;
+    
+    TUid streamId;
+    streamId.iUid = iStreamUid;
+    
+    aHasHistory = iSyncRelationship.IsStreamPresentL(streamId);
+    
+    if (aHasHistory)
+        {
+        iSyncRelationship.OpenReadStreamLC(readStream, streamId);
+        
+        // Read the index, first create snapshot array
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        
+        // Read used format version
+        TUint formatVer = readStream.ReadUint32L();
+        if ( formatVer != KSnapshotFormatVersion )
+            {
+            // Wrong version, do not try to import data
+            LOGGER_WRITE("CChangeFinder::ConstructL, Wrong format version -> no history");
+            aHasHistory = EFalse;
+            CleanupStack::PopAndDestroy(); // readStream
+            LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+            return;
+            }
+        
+        // Read item count
+        TInt count = readStream.ReadUint32L();
+        
+        // Read items
+        for ( TInt i=0; i<count; i++ )
+            {
+            TSnapshotItem item;
+            item.InternalizeL( readStream );
+            iOldSnapshot->InsertIsqL( item, iKey );
+            }
+
+        readStream.Close();
+        readStream.Pop();
+        }
+    else
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, no sync history.");
+        }
+        
+    LOGGER_LEAVEFN("CChangeFinder::ConstructL");
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CloseL
+// Closes ChangeFinder object and writes snapshot to stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::CloseL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CloseL" );
+    
+    // Write to stream
+    RWriteStream writeStream;
+    
+    TUid streamId;
+    streamId.iUid = iStreamUid; 
+
+    // Open write stream
+    iSyncRelationship.OpenWriteStreamLC( writeStream, streamId );
+    
+    // Write used format version
+    writeStream.WriteUint32L( KSnapshotFormatVersion );
+
+    // Write item count
+    TInt count(0);
+    if ( iOldSnapshot )
+        {
+        count = iOldSnapshot->Count();
+        }
+    writeStream.WriteUint32L(count);
+    
+    // Write items
+    for (TInt i=0; i<count; i++)
+        {
+        const TSnapshotItem& item = iOldSnapshot->At( i );
+        item.ExternalizeL( writeStream );
+        }
+
+    writeStream.CommitL();
+    writeStream.Close();
+    writeStream.Pop();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::CloseL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ResetL
+// Resets synchronization history, all contetn is considered new after this call
+// -----------------------------------------------------------------------------
+void CChangeFinder::ResetL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ResetL" );
+    // Delete old change information
+    if ( iOldSnapshot )
+        {
+        LOGGER_WRITE("iOldSnapshot->Reset()");
+        iOldSnapshot->Reset();
+        }
+    
+    // Write 'null' data to file, 
+    // this removes change history from the file
+    CloseL();
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ResetL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindChangedItemsL
+// Compares snapshots, finds changed items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids )
+    {   
+    LOGGER_ENTERFN( "CChangeFinder::FindChangedItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindChangedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        // Find this entry from the old snapshot
+        if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            // Compare times to see whether this was changed or item was read
+            if ( ( oldItem.LastChangedDate() != currentItem.LastChangedDate() )
+                || ( oldItem.Unread() && !currentItem.Unread() )
+                || ( !oldItem.Unread() && currentItem.Unread() )
+                || ( oldItem.FolderName().Compare( currentItem.FolderName() ) != 0 ) )
+                {
+                aChangedUids.AddItem( currentItem.ItemId() );
+                LOGGER_WRITE_1( "Item %d was changed.", currentItem.ItemId() );  
+                }
+            }
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindChangedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindDeletedItemsL
+// Compares snapshots, finds deleted items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindDeletedItemsL" );
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iOldSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iOldSnapshot->At( i );
+        
+        // If there's no current snapshot, this definately is deleted item
+        if ( !iCurrentSnapshot )
+            {
+            aDeletedUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the current snapshot.
+        else if ( iCurrentSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            aDeletedUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was deleted.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindDeletedItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindNewItemsL
+// Compares snapshots, finds new items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindNewItemsL( CNSmlDataItemUidSet& aNewUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindNewItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindNewItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // If there's no old snapshot, all items are new
+        if ( !iOldSnapshot )
+            {
+            aNewUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was new.", currentItem.ItemId() );
+            }
+        // It is also new if it doesn't exist int the old snapshot.
+        else if ( iOldSnapshot->FindIsq( currentItem, iKey, index ) != KErrNone )
+            {
+            aNewUids.AddItem( currentItem.ItemId() );
+            LOGGER_WRITE_1( "Item %d was new.", currentItem.ItemId() );
+            }       
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::FindNewItemsL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindMovedItemsL
+// Compares snapshots, finds moved items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindMovedItemsL( CNSmlDataItemUidSet& aMovedUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::FindMovedItemsL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no current snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::FindMovedItemsL leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+        
+    TInt index;
+    TInt count = iCurrentSnapshot->Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        const TSnapshotItem& currentItem = iCurrentSnapshot->At( i );
+        
+        // Find this entry from the old snapshot
+        if(iOldSnapshot->FindIsq( currentItem, iKey, index ) == KErrNone)
+            {
+            // This is the old item
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            
+            // Report only moved items in which only parent id has been changed
+            if ( oldItem.ParentId() != currentItem.ParentId()
+                && oldItem.LastChangedDate() == currentItem.LastChangedDate()
+                && !(oldItem.Unread() && !currentItem.Unread() )
+                && !(!oldItem.Unread() && currentItem.Unread() ) )
+                {
+                aMovedUids.AddItem( currentItem.ItemId() );
+                LOGGER_WRITE_1( "Item %d was moved.", currentItem.ItemId() );
+                }
+            }       
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::FindMovedItemsL" );     
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemAddedL
+// Adds item to snapshot, this item is no longer considered new
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemAddedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemAddedL" );
+    
+    // Add this to old snapshot, if there's no old snapshot it must be created
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    LOGGER_WRITE_1( "Adding item %d.", aItem.ItemId() );
+    
+    TRAPD( error, iOldSnapshot->InsertIsqL( aItem, iKey ) );
+    if ( error == KErrAlreadyExists )
+        {
+        // It was already committed, no actions required
+        LOGGER_WRITE( "iOldSnapshot->InsertIsqL leaved with KErrAlreadyExists" );
+        }
+    else if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "iOldSnapshot->InsertIsqL leaved with %d.", error );
+        User::Leave( error );
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::ItemAddedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemDeletedL
+// Removes item to snapshot, this item is no longer considered deleted
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemDeletedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemDeleted" );
+    
+    LOGGER_WRITE_1( "deleting item %d.", aItem.ItemId() );
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::ItemDeleted leaved, no old snapshot." );
+        User::Leave( KErrNotFound );
+        }
+
+    // Delete item from the old snapshot
+    TInt index;
+    if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+        {
+        iOldSnapshot->Delete( index );
+        }
+    else // Skip, there wasn't such entry
+        {
+        LOGGER_WRITE( "iOldSnapshot->FindIsq, item was not found." );
+        }  
+    
+    LOGGER_LEAVEFN( "CChangeFinder::ItemDeleted" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemUpdatedL
+// Updates item to snapshot, this item is no longer considered changed
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemUpdatedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemUpdatedL" );
+
+    LOGGER_WRITE_1( "Updating item %d.", aItem.ItemId() );
+    
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            oldItem = aItem;
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }
+        
+        }
+        
+    LOGGER_LEAVEFN( "CChangeFinder::ItemUpdatedL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemMovedL
+// Moves item within snapshot, this item is no longer considered moved
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemMovedL( const TSnapshotItem& aItem )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::ItemMovedL" );
+    
+    LOGGER_WRITE_1( "Moving item %d.", aItem.ItemId() );
+            
+    // There must be such entry in the snapshot after this
+    // If there isn't old snapshot, we'll create it and add the item
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        ItemAddedL( aItem );
+        }
+    else
+        {
+        // Update item's parent in the old snapshot
+        TInt index;
+        if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+            {
+            TSnapshotItem& oldItem = iOldSnapshot->At( index );
+            oldItem.SetParentId( aItem.ParentId() );
+            }
+        else 
+            {
+            // There was old snapshot but no such item. Let's add it
+            ItemAddedL( aItem );
+            }   
+        }
+    
+    LOGGER_LEAVEFN("CChangeFinder::ItemMovedL");    
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL()
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    // Delete everything from the old snapshot
+    iOldSnapshot->Reset();
+    
+    // Loop through all the items in current snapshot
+    TInt count = iCurrentSnapshot->Count();
+    
+    // Copy everything from current to old snapshot
+    for ( TInt i=0; i < count; i++ )
+        {   
+        const TSnapshotItem& newItem = iCurrentSnapshot->At( i );
+
+        // Commit it to the old array.
+        TRAPD( error, iOldSnapshot->InsertIsqL( newItem, iKey ) );
+        if ( error == KErrAlreadyExists )
+            {
+            // It was already committed, this is an internal error of change finder
+            LOGGER_WRITE( "iOldSnapshot->InsertIsqL leaved with KErrAlreadyExists." );
+            User::Leave( error );
+            }
+        else if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1( "iOldSnapshot->InsertIsqL leaved with %d.", error );
+            User::Leave( error );
+            }
+        }
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot, affects only a specified group of items
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL( const MSmlDataItemUidSet& aUids )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::CommitChangesL" );
+    
+    // This function commits changes from current snapshot to old snapshot
+    // But commits only the entries in the parameter array
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::CommitChangesL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+        
+    if ( !iOldSnapshot )
+        {
+        iOldSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+        }
+        
+    // Use only these uid values
+    TInt index;
+    TInt count = aUids.ItemCount();
+    
+    for ( TInt i=0; i < count; i++ )
+        {
+        TSmlDbItemUid uid = aUids.ItemAt( i );
+        TSnapshotItem item( uid );
+        // Let's see if this uid exists in the current snapshot
+        if ( iCurrentSnapshot->FindIsq( item, iKey, index ) == KErrNone )
+            {
+            // This is the new item
+            const TSnapshotItem& newItem = iCurrentSnapshot->At( index );
+            
+            // Let's see if we can find the old one
+            if ( iOldSnapshot->FindIsq( item, iKey, index ) == KErrNone )
+                {
+                // This is the old item
+                TSnapshotItem& oldItem = iOldSnapshot->At( index );
+                
+                // Copy new item over the old one, this'll commit the change
+                oldItem = newItem;
+                }
+            else // This entry was not found. It means that it is new one
+                {
+                // Commit it to the old array.
+                ItemAddedL( newItem );
+                }
+            }
+        else 
+            {
+            // This item was deleted from the current snapshot.
+            TSnapshotItem toDelete( item );
+            ItemDeletedL( toDelete );
+            } 
+        }
+    
+    LOGGER_LEAVEFN( "CChangeFinder::CommitChangesL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetNewSnapshot
+// Sets new snapshot (to be compared against), ChangeFinder takes ownership
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetNewSnapshot( CSnapshotArray* aNewSnapshot )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetNewSnapshot" );
+    
+    // Delete existing snapshot
+    delete iCurrentSnapshot;
+    
+    // Set submitted snapshot as active
+    iCurrentSnapshot = aNewSnapshot;
+    LOGGER_LEAVEFN( "CChangeFinder::SetNewSnapshot" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::DataStoreUid
+// returns stored data store id number
+// -----------------------------------------------------------------------------
+TInt64 CChangeFinder::DataStoreUid() const
+    {
+    LOGGER_ENTERFN( "CChangeFinder::DataStoreUid" );
+    LOGGER_LEAVEFN( "CChangeFinder::DataStoreUid" );
+    return iDataStoreUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetDataStoreUid
+// Sets data store id number
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetDataStoreUid( TInt64 aUid )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::SetDataStoreUid" );
+    iDataStoreUid = aUid;
+    LOGGER_LEAVEFN( "CChangeFinder::SetDataStoreUid" );
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::UpdatePartialL
+// Returns ETrue if item can be updated partially (only status bits are changed)
+// -----------------------------------------------------------------------------
+TBool CChangeFinder::UpdatePartialL( TSmlDbItemUid& aUid )
+    {
+    LOGGER_ENTERFN( "CChangeFinder::UpdatePartialL" );
+    
+    if ( !iCurrentSnapshot )
+        {
+        LOGGER_WRITE( "CChangeFinder::UpdatePartialL leaved, current snapshot missing." );
+        User::Leave( KErrNotFound );
+        }
+
+    if ( !iOldSnapshot )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+        
+    TInt index;
+    TSnapshotItem item( aUid );
+    // Find from current snapshot, if not found -> deleted
+    if ( iCurrentSnapshot->FindIsq( item, iKey, index ) != KErrNone )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }   
+        
+    // Current item 
+    const TSnapshotItem& currentItem = iCurrentSnapshot->At( index );
+    
+    // Old item, if not found -> added
+    if ( iOldSnapshot->FindIsq( item, iKey, index ) != KErrNone )
+        {
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+    else
+        {
+        // This is the old item
+        TSnapshotItem& oldItem = iOldSnapshot->At( index );
+        
+        // Status bits must have been changed to allow partial update
+        if ( oldItem.Unread() == currentItem.Unread() )
+            {
+            LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+            return EFalse;
+            }
+            
+        // Date should be same, otherwise 'just' changed item
+        if ( oldItem.LastChangedDate() == currentItem.LastChangedDate() )
+            {
+            LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+            return ETrue;
+            }
+        
+        LOGGER_LEAVEFN( "CChangeFinder::UpdatePartialL" );
+        return EFalse;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/OMADSFolderObject.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,355 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DS Folder object XML parser
+*
+*/
+
+
+#include <SenXmlUtils.h>
+#include "OMADSFolderObject.h"
+#include "utf.h"
+#include "Logger.h"
+
+_LIT8(KOMADSFolderElement, "Folder");
+_LIT8(KOMADSNameElement, "name");
+_LIT8(KOMADSCreatedElement, "created");
+_LIT8(KOMADSModifiedElement, "modified");
+
+_LIT(KFolderBeginTag, "<Folder>");
+_LIT(KFolderEndTag, "</Folder>");
+_LIT(KNameBeginTag, "<name>");
+_LIT(KNameEndTag, "</name>");
+_LIT(KCreatedBeginTag, "<created>");
+_LIT(KCreatedEndTag, "</created>");
+_LIT(KModifiedBeginTag, "<modified>");
+_LIT(KModifiedEndTag, "</modified>");
+_LIT(KDateFormat, "%04d%02d%02dT%02d%02d%02d");
+
+
+COMADSFolderObject* COMADSFolderObject::NewLC()
+    {
+    COMADSFolderObject* pSelf = new (ELeave) COMADSFolderObject;
+    CleanupStack::PushL( pSelf );
+    pSelf->ConstructL();
+    return pSelf;
+    }
+
+COMADSFolderObject* COMADSFolderObject::NewL()
+    {
+    COMADSFolderObject* pSelf = COMADSFolderObject::NewLC();
+    CleanupStack::Pop( pSelf );    
+    return pSelf;
+    }
+
+COMADSFolderObject::~COMADSFolderObject()
+    {
+    delete iXmlReader;
+    }
+
+void COMADSFolderObject::ConstructL()
+    {
+    iXmlReader = CSenXmlReader::NewL();
+    iXmlReader->SetContentHandler(*this);
+    }
+
+TInt COMADSFolderObject::ImportFolderXml( RFs& aFs, const TDesC& aFilename )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" );    
+        
+    TInt error;
+    
+    Reset();
+    TRAP( error, iXmlReader->ParseL( aFs, aFilename ) )
+    if( error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+TInt COMADSFolderObject::ImportFolderXml( const TDesC8& aData )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::ImportFolderXml" );
+    LOG(aData);     
+    
+    TInt error;
+    
+    Reset();
+    
+    TRAP(error, iXmlReader->ParseL(aData) );
+    if(error != KErrNone )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+        return error;
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::ImportFolderXml" );
+    return iError;
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL(CBufBase& aBuffer)
+    {
+    iDesc = NULL;
+    iBuffer = &aBuffer;
+    iWriteBufPosition = 0;
+    iWriteBufSize = aBuffer.Size();     
+
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportFolderXmlL(TDes8& aBuffer)
+    {
+    iDesc = &aBuffer;
+    iBuffer = NULL;
+    
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportL()
+    {
+    // Folder
+    WriteL(KFolderBeginTag);
+    
+    // Name
+    WriteL(KNameBeginTag);
+    WriteEncodedXmlL(iName);
+    WriteL(KNameEndTag);
+    
+    // Created Date
+    TBuf<32> tempdate;
+    tempdate.Format(KDateFormat, iCreatedDate.Year(), iCreatedDate.Month()+1, iCreatedDate.Day(),
+                                 iCreatedDate.Hour(), iCreatedDate.Minute(), iCreatedDate.Second());
+    WriteL(KCreatedBeginTag);
+    WriteL(tempdate);
+    WriteL(KCreatedEndTag);
+    
+    // Modified Date
+    tempdate.Format(KDateFormat, iModifiedDate.Year(), iModifiedDate.Month()+1, iModifiedDate.Day(),
+                                 iModifiedDate.Hour(), iModifiedDate.Minute(), iModifiedDate.Second());
+    WriteL(KModifiedBeginTag);
+    WriteL(tempdate);
+    WriteL(KModifiedEndTag);
+    
+    // Folder end
+    WriteL(KFolderEndTag);
+    }
+    
+void COMADSFolderObject::WriteL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + iTemp.Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, iTemp );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( iTemp );       
+        }   
+    }
+    
+void COMADSFolderObject::WriteEncodedXmlL( const TDesC &aData )
+    {   
+    CnvUtfConverter converter;
+    User::LeaveIfError( converter.ConvertFromUnicodeToUtf8( iTemp, aData ) );
+    
+    HBufC8* xmlData = SenXmlUtils::EncodeHttpCharactersLC( iTemp ); 
+                    
+    if ( iBuffer )
+        {
+        TInt newPosition = iWriteBufPosition + xmlData->Length();
+
+        if ( newPosition > iWriteBufSize )
+            {
+            TInt expand = newPosition - iWriteBufSize;
+            iBuffer->ExpandL( iWriteBufSize, expand );
+            iWriteBufSize += expand;
+            }
+
+        iBuffer->Write( iWriteBufPosition, *xmlData );
+        iWriteBufPosition = newPosition;
+        }
+    else if( iDesc )
+        {
+        iDesc->Append( *xmlData );
+        }   
+        
+    CleanupStack::PopAndDestroy( xmlData );   
+    }           
+    
+TInt COMADSFolderObject::StartDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::EndDocument()
+    {
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::StartElement(const TDesC8& /*aURI*/, 
+                  const TDesC8& /*aLocalName*/, 
+                  const TDesC8& aName, 
+                  const RAttributeArray& /*apAttrs*/)
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::StartElement" );  
+    iCurrentElement.Copy( aName );
+    LOGGER_LEAVEFN( "COMADSFolderObject::StartElement" );
+    return KErrNone;
+    }
+                                    
+TInt COMADSFolderObject::EndElement(const TDesC8& /*aURI*/, 
+                const TDesC8& /*aLocalName*/, 
+                const TDesC8& /*aName*/)
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::EndElement" );        
+    iCurrentElement.SetLength(0);
+    LOGGER_LEAVEFN( "COMADSFolderObject::EndElement" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::Characters( const TDesC8& aBuf, TInt aStart, TInt aLength )
+    {
+    LOGGER_ENTERFN( "COMADSFolderObject::Characters" );
+    LOG(aBuf);    
+    
+    TInt error;
+    
+    if( iCurrentElement.Compare( KOMADSFolderElement ) == 0 )
+        {
+        LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+        return KErrNone;
+        }
+    
+    else if ( iCurrentElement.Compare( KOMADSNameElement ) == 0 )
+        {                
+        CnvUtfConverter converter;
+        TBuf<KMaxFolderNameLength> buf;
+        error = converter.ConvertToUnicodeFromUtf8( buf, aBuf.Mid( aStart, aLength ) );
+        TInt length = buf.Length() + iName.Length();
+        
+        if ( error > 0 )
+            {
+            LOGGER_WRITE_1("Too long name, number of uncorverted bytes: %d", error);
+            }
+        else if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 failed with %d", error);
+            iError = error;
+            }
+        else if ( length > iName.MaxLength() )
+            {
+            LOGGER_WRITE_1("Too long name total: %d", length);
+            }
+        else
+            {
+            iName.Append( buf );
+            }       
+        }
+    else if ( iCurrentElement.Compare( KOMADSCreatedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iCreatedDate );
+        if( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    else if ( iCurrentElement.Compare( KOMADSModifiedElement ) == 0 )
+        {
+        error = ParseDateString( aBuf.Mid( aStart, aLength ), iModifiedDate );
+        if ( error != KErrNone )
+            {
+            iError = error;
+            }
+        }
+    LOGGER_LEAVEFN( "COMADSFolderObject::Characters" );
+    return KErrNone;
+    }
+
+TInt COMADSFolderObject::ParseDateString(const TDesC8& aString, TDateTime& aDateTime)
+    {
+    // Ensure we don't read beyond the buffer limits
+    if(aString.Length() < 15)
+        return KErrArgument;
+    
+    // Extract the fields from the string
+    TLex8 yearDesc(aString.Mid(0, 4));
+    TLex8 monthDesc(aString.Mid(4, 2));
+    TLex8 dayDesc(aString.Mid(6, 2));
+    // Skip one character here, it's supposed to be 'T'
+    TLex8 hourDesc(aString.Mid(9, 2));
+    TLex8 minuteDesc(aString.Mid(11, 2));
+    TLex8 secondDesc(aString.Mid(13, 2));
+    
+    TInt year, month, day, hour, minute, second;
+    TInt error;
+    
+    // Fetch the values to temporary variables
+    if((error = yearDesc.Val(year)) != KErrNone)
+        return error;
+    if((error = monthDesc.Val(month)) != KErrNone)
+        return error;
+    if((error = dayDesc.Val(day)) != KErrNone)
+        return error;
+    if((error = hourDesc.Val(hour)) != KErrNone)
+        return error;
+    if((error = minuteDesc.Val(minute)) != KErrNone)
+        return error;
+    if((error = secondDesc.Val(second)) != KErrNone)
+        return error;
+    
+    // Assign values to datetime object
+    if((error = aDateTime.SetYear(year)) != KErrNone)
+        return error;
+    if((error = aDateTime.SetMonth((TMonth)(month-1))) != KErrNone)
+        return error;
+    if((error = aDateTime.SetDay(day)) != KErrNone)
+        return error;
+    if((error = aDateTime.SetHour(hour)) != KErrNone)
+        return error;
+    if((error = aDateTime.SetMinute(minute)) != KErrNone)
+        return error;
+    if((error = aDateTime.SetSecond(second)) != KErrNone)
+        return error;
+    
+    return KErrNone;
+    }
+
+void COMADSFolderObject::Reset()
+    {
+    iError = KErrNone;
+    iName.SetLength(0);
+    iCreatedDate.Set(2005, EJanuary, 1, 0, 0, 0, 0);
+    iModifiedDate.Set(2005, EJanuary, 1, 0, 0, 0, 0);
+    }
+    
+TInt COMADSFolderObject::Error(TInt aErrorCode)
+    {
+    iError = aErrorCode;
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SMSAdapterMsvApi.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1162 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <txtrich.h>
+#include <smsclnt.h>
+#include <smutset.h>
+#include <smuthdr.h>
+#include <smscmds.h>
+#include <sysutil.h> 
+#include <gsmuelem.h>
+#include <cntdb.h>
+#include <cntitem.h>
+#include <cntfldst.h>
+#include "SMSAdapterMsvApi.h"
+#include "Logger.h" 
+#include "VMessageParser.h"
+#include "SmsDataProviderDefs.h"
+
+
+// CONSTANTS
+
+_LIT16(KSmsNonUnicodeChars, "èéùìòÇØøÅåÆæßÉ£$¥¡ÄÖÑܧ¿äöñüà");
+        
+// OTHER DEFINITIONS
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::NewL
+// -----------------------------------------------------------------------------
+//
+ CSmsAdapterMsvApi* CSmsAdapterMsvApi::NewL()
+    {
+    CSmsAdapterMsvApi* self = new( ELeave ) CSmsAdapterMsvApi;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::~CSmsAdapterMsvApi()
+// -----------------------------------------------------------------------------
+//
+CSmsAdapterMsvApi::~CSmsAdapterMsvApi()
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::~CSmsAdapterMsvApi" );
+    SAFEDELETE( iContactsDb );
+	SAFEDELETE( iMtm );
+	SAFEDELETE( iMtmReg );     
+    SAFEDELETE( iSession );
+    LOGGER_LEAVEFN( "CSmsAdapterMsvApi::~CSmsAdapterMsvApi" );
+    }
+       
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::CSmsAdapterMsvApi
+// -----------------------------------------------------------------------------
+//
+CSmsAdapterMsvApi::CSmsAdapterMsvApi()
+    {     
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::ConstructL()
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::ConstructL" );
+
+    iSession = CMsvSession::OpenSyncL( *this );
+    iMtmReg = CClientMtmRegistry::NewL( *iSession );    
+	iMtm = static_cast<CSmsClientMtm*>( iMtmReg->NewMtmL(KUidMsgTypeSMS) ); 
+
+	iFs = iSession->FileSession();
+	iMessageDrive = MessageServer::CurrentDriveL( iFs );
+	
+	iContactsDb = CContactDatabase::OpenL();
+
+    LOGGER_LEAVEFN( "CSmsAdapterMsvApi::ConstructL" ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::AddSML
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::AddSML(
+    CVMessageParser& aSm,
+    TMsvId aFolder,                                                                                                                                                                                                        
+    TMsvId& aSmId )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::AddSML" );
+   
+    if (!ValidFolderL( aFolder ))
+        {
+		LOGGER_WRITE( "AddSML: wrong folder" );
+        User::Leave( KErrArgument );
+        }
+           
+    // Set first default flags  
+    TMsvEntry newEntry;  
+    newEntry.iType = KUidMsvMessageEntry;
+    newEntry.iServiceId = KMsvLocalServiceIndexEntryId;
+    newEntry.iMtm = KUidMsgTypeSMS;
+    newEntry.SetVisible(EFalse);
+    newEntry.SetInPreparation(ETrue);           
+
+    // Create new message entry
+    CMsvEntry* entry = iSession->GetEntryL( aFolder );
+    CleanupStack::PushL( entry );   
+    entry->CreateL( newEntry );
+    aSmId = newEntry.Id();  
+    entry->SetEntryL(newEntry.Id());
+    
+    // Create message header
+
+    CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
+    CleanupStack::PushL( paraFormatLayer );
+    CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
+    CleanupStack::PushL( charFormatLayer );
+    CRichText* richText = CRichText::NewL( paraFormatLayer, charFormatLayer );
+    CleanupStack::PushL( richText ); 
+    
+    CSmsPDU::TSmsPDUType pduType;
+    
+    if (aFolder == KMsvGlobalInBoxIndexEntryId)
+        {
+        pduType = CSmsPDU::ESmsDeliver;
+        }
+    else if (aFolder == KMsvGlobalOutBoxIndexEntryId ||
+             aFolder == KMsvDraftEntryId ||
+             aFolder == KMsvSentEntryId)  
+        {
+        pduType = CSmsPDU::ESmsSubmit;
+        }
+    else if (aSm.iRecipients.Count() > 0)
+        {
+        pduType = CSmsPDU::ESmsSubmit;
+        }
+    else
+        {
+        pduType = CSmsPDU::ESmsDeliver;
+        }       
+    
+    CSmsHeader* smsHeader = CSmsHeader::NewL( pduType, *richText );
+    CleanupStack::PushL( smsHeader );
+    
+    // Set the message header in the entry's store
+    CMsvStore* store = entry->EditStoreL();
+    CleanupStack::PushL( store );
+    smsHeader->StoreL( *store );
+    store->StoreBodyTextL( *richText );
+    store->CommitL();
+    
+    CleanupStack::PopAndDestroy( store );
+    CleanupStack::PopAndDestroy( smsHeader );
+    CleanupStack::PopAndDestroy( richText );
+    CleanupStack::PopAndDestroy( charFormatLayer );
+    CleanupStack::PopAndDestroy( paraFormatLayer );
+    CleanupStack::PopAndDestroy( entry );
+   
+	DoUpdateSML( aSmId, aSm, ETrue );
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::AddSML" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::ReplaceSML
+// -----------------------------------------------------------------------------
+//
+ void CSmsAdapterMsvApi::ReplaceSML( TMsvId aSmId, CVMessageParser& aSm ) 
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::ReplaceSML" );
+	DoUpdateSML( aSmId, aSm, EFalse );
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::ReplaceSML" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::DeleteSML
+// -----------------------------------------------------------------------------
+//
+ void CSmsAdapterMsvApi::DeleteSML( TMsvId aSmId )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::DeleteSML" );
+    
+    iMtm->SwitchCurrentEntryL( aSmId );
+    
+    TMsvEntry tEntry = iMtm->Entry().Entry();  		
+    if (tEntry.iType != KUidMsvMessageEntry || tEntry.iMtm != KUidMsgTypeSMS)
+        {
+        LOGGER_WRITE( "Not SMS entry" );
+        User::Leave(KErrNotSupported);
+        }
+    
+	iMtm->SwitchCurrentEntryL( tEntry.Parent() );
+	iMtm->Entry().DeleteL( aSmId );
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::DeleteSML" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::DeleteUserFolderL
+// -----------------------------------------------------------------------------
+//
+ TInt CSmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::DeleteUserFolderL" );
+    
+    iMtm->SwitchCurrentEntryL( aUid );
+    CMsvEntry& entry = iMtm->Entry();
+    TMsvEntry tEntry = entry.Entry();  		
+    
+    if (tEntry.iType != KUidMsvFolderEntry || tEntry.Parent() != KMsvMyFoldersEntryIdValue)
+        {
+        LOGGER_WRITE( "Not correct folder" );
+        User::Leave(KErrNotSupported);
+        }
+        
+    CMsvEntrySelection* children = entry.ChildrenL();
+    TInt count = children->Count();
+    delete children;
+    
+  	if (count > 0)
+	    {
+	    LOGGER_WRITE( "Folder not empty" );
+	    return KErrInUse;
+	    }
+	    
+	tEntry.SetReadOnly(EFalse);
+	entry.ChangeL( tEntry );
+       
+	iMtm->SwitchCurrentEntryL( tEntry.Parent() );	
+	iMtm->Entry().DeleteL( aUid );
+	
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::DeleteUserFolderL" );
+	return KErrNone;
+    }   
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::RetrieveSML
+// -----------------------------------------------------------------------------
+//
+ void CSmsAdapterMsvApi::RetrieveSML(
+    TMsvId aSmId,
+    TMsvId& aParent,
+    CVMessageParser& aSm,
+    TBool& aUnread)
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::RetrieveSML" );
+                          
+    iMtm->SwitchCurrentEntryL( aSmId );
+    iMtm->LoadMessageL();
+    
+    CRichText& mtmBody = iMtm->Body();
+	aSm.StoreMessageBodyL( mtmBody );
+       
+    TMsvEntry tEntry = iMtm->Entry().Entry();
+    
+    aUnread = tEntry.Unread();
+	if (aUnread)
+		{
+		aSm.iStatus = KVMsgStatusUnread;
+		}
+	else
+		{
+		aSm.iStatus = KVMsgStatusRead;
+		}
+	
+	aSm.iUniversalTime = tEntry.iDate;	
+	aSm.iHomeTime = HomeTimeFromUniversalTime( aSm.iUniversalTime );
+    
+	aParent = tEntry.Parent();	
+	switch (aParent)
+		{
+		case KMsvGlobalInBoxIndexEntryId:
+			aSm.iFolder = KFolderInbox;
+			break;
+		case KMsvGlobalOutBoxIndexEntryId:
+			aSm.iFolder = KFolderOutbox;
+			break;
+		case KMsvDraftEntryId:
+			aSm.iFolder = KFolderDraft;
+			break;
+		case KMsvSentEntryId:
+			aSm.iFolder = KFolderSent;
+			break;
+		case KMsvMyFoldersEntryIdValue:
+		    aSm.iFolder = KFolderMyFolders;    
+			break;
+		default:
+		    TPtrC folderName;
+		    TTime time;
+		    TBool found = FindUserFolderL(aParent, folderName, time);
+		    if (found && folderName.Length() <= KMaxFolderNameLength)
+		        {
+		        aSm.iFolder = folderName;
+		        }
+		    else
+		        {
+		        LOGGER_WRITE_1( "Not folder name found for folder: %d", aParent );
+		        }       	
+		}
+		LOG( aSm.iFolder );
+		
+	const CSmsHeader& smsHeader = iMtm->SmsHeader();
+	
+	if ( smsHeader.Type() == CSmsPDU::ESmsDeliver )
+	    {
+		TPtrC fromAddr = smsHeader.FromAddress();
+		aSm.ParseTelephoneNumber( fromAddr, aSm.iSender );
+		}
+	else
+		{
+		const CMsvRecipientList& recipients = iMtm->AddresseeList();
+		for (TInt i = 0; i < recipients.Count(); i++)
+			{
+			CVMessageParser::TTelephoneNumber recipientInfo;
+			aSm.ParseTelephoneNumber( recipients[i], recipientInfo );
+			aSm.iRecipients.Append( recipientInfo );
+			}
+		}	
+
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::RetrieveSML" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::SendSML
+// -----------------------------------------------------------------------------
+//
+ void CSmsAdapterMsvApi::SendSML( TMsvId aSmId )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::SendSML" );
+   
+	iMtm->SwitchCurrentEntryL( aSmId );
+
+	TMsvEntry msvEntry = iMtm->Entry().Entry();	
+	
+	if (msvEntry.Parent() != KMsvGlobalOutBoxIndexEntryId)
+		{
+ 		LOGGER_WRITE_1( "Wrong folder, parent: %d", msvEntry.Parent() );
+ 		return;
+ 		}
+
+	iMtm->LoadMessageL();
+
+	msvEntry.SetInPreparation( EFalse );
+	msvEntry.SetSendingState( KMsvSendStateWaiting );
+	msvEntry.iDate.UniversalTime();
+	
+	iMtm->RestoreServiceAndSettingsL();
+	CSmsHeader& header = iMtm->SmsHeader();
+	
+	CSmsSettings* sendOptions = CSmsSettings::NewL();
+	CleanupStack::PushL( sendOptions );
+		
+	sendOptions->CopyL( iMtm->ServiceSettings() );
+	sendOptions->SetDelivery( ESmsDeliveryImmediately );
+
+	TSmsDataCodingScheme::TSmsAlphabet dataCoding = TSmsDataCodingScheme::ESmsAlphabet7Bit;
+	CRichText& msgBody = iMtm->Body();
+	HBufC* msgBodyBuf = HBufC::NewLC( msgBody.DocumentLength() );
+	TPtr16 ptrBody = msgBodyBuf->Des();
+	msgBody.Extract( ptrBody, 0, msgBody.DocumentLength() );
+	LOG(ptrBody);
+
+	for (TInt i = 0; i < ptrBody.Length(); i++)
+		{
+		if (IsUnicode( ptrBody[i] ))
+			{
+			LOGGER_WRITE_1( "Character %d is unicode", i );
+			dataCoding = TSmsDataCodingScheme::ESmsAlphabetUCS2;
+			break;
+			}
+		}
+
+	sendOptions->SetCharacterSet( dataCoding );
+	CleanupStack::PopAndDestroy( msgBodyBuf ); 
+		
+	header.SetSmsSettingsL( *sendOptions );
+	if( header.Message().ServiceCenterAddress().Length() == 0 )
+		{
+		LOGGER_WRITE( "header.Message().ServiceCenterAddress().Length() == 0" );    
+		
+		CSmsSettings* serviceSettings = &( iMtm->ServiceSettings() );
+        
+		if (!serviceSettings->ServiceCenterCount())
+			{
+			LOGGER_WRITE("Cervice Center not found, could not send message");
+			User::Leave( KErrCompletion );
+			}
+		else
+			{
+			CSmsServiceCenter* sc =  &serviceSettings->GetServiceCenter( serviceSettings->DefaultServiceCenter() );
+			header.Message().SetServiceCenterAddressL( sc->Address() );	
+			}				
+		}
+
+    const CMsvRecipientList& addrList = iMtm->AddresseeList();
+    if ( addrList.Count() == 0 )
+        {
+		LOGGER_WRITE( "SendSML: no recipient" );
+        User::Leave( KErrGeneral );
+        }
+   
+	CMsvEntry* entry = &( iMtm->Entry() );
+	entry->ChangeL( msvEntry );	
+	iMtm->SaveMessageL();
+
+	CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection;
+	CleanupStack::PushL( sel );
+	sel->AppendL( entry->EntryId() );
+
+	TBuf8<1> dummy;
+	CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC();
+	waiter->iStatus = KRequestPending;
+	CMsvOperation* op = iMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy, *sel, dummy, waiter->iStatus );
+	CleanupStack::PushL( op );
+	waiter->Start();
+	
+	LOGGER_WRITE_1( "InvokeAsyncFunctionL: status %d", waiter->iStatus.Int());
+    
+	CleanupStack::PopAndDestroy( 4 ); // op, waiter, sel, sendOptions	
+	
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::SendSML" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::HandleSessionEventL
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::HandleSessionEventL( TMsvSessionEvent aEvent, TAny*, TAny*, TAny* )
+    {
+    LOGGER_WRITE_1( "CSmsAdapterMsvApi::HandleSessionEventL: %d", aEvent);
+    
+    switch ( aEvent )
+        {
+        case EMsvCloseSession: // The client should immediately close the session with the Message Server.
+        case EMsvServerTerminated: // The Message Server has been terminated.
+                                   // All clients must close their sessions immediately. 
+            {
+            if (iSession)
+                {
+				SAFEDELETE( iMtm );
+				SAFEDELETE( iMtmReg );
+                SAFEDELETE( iSession );
+                }
+            }   
+            break;
+        
+        default:
+            // Nothing is done
+            break;
+        } 
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::MsvSession
+// -----------------------------------------------------------------------------
+//
+CMsvSession* CSmsAdapterMsvApi::MsvSessionL()
+	{
+	if (!iSession)
+		{
+		User::Leave( KErrGeneral );
+		}
+	return iSession;
+	}
+
+// -----------------------------------------------------------------------------
+//	CSmsAdapterMsvApi::CleanFolderGetMsvIdsL
+// -----------------------------------------------------------------------------
+//
+CMsvEntrySelection* CSmsAdapterMsvApi::CleanFolderGetMsvIdsL(TMsvId aFolderId)
+    {
+    LOGGER_ENTERFN( "CMsvEntrySelection::CleanFolderGetMsvIdsL" );
+    
+    CMsvEntry* cEntry = iSession->GetEntryL( KMsvRootIndexEntryId );
+    CleanupStack::PushL( cEntry );
+    
+    cEntry->SetEntryL( aFolderId );
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, EFalse ) );
+    CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeSMS );
+    
+    CleanupStack::PopAndDestroy( cEntry );
+    CleanupStack::PushL( msvEntrySelection );
+    
+    for (TInt i = 0; i < msvEntrySelection->Count(); i++)
+        {
+        CMsvEntry* entry = iSession->GetEntryL( msvEntrySelection->At(i) );
+        CleanupStack::PushL( entry );
+        TMsvEntry tEntry = entry->Entry();
+        tEntry.SetReadOnly( EFalse );
+        entry->ChangeL( tEntry );
+        DeleteSML( msvEntrySelection->At(i) );
+        CleanupStack::PopAndDestroy(); //entry
+        }
+        
+    CleanupStack::Pop(msvEntrySelection);
+    LOGGER_LEAVEFN( "CSmsAdapterMsvApi::CleanFolderGetMsvIdsL" );
+    return msvEntrySelection;
+    }
+    
+// -----------------------------------------------------------------------------
+//	CSmsAdapterMsvApi::CleanFolderL
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::CleanFolderL(TMsvId aFolderId)
+    {
+    CMsvEntrySelection* msvEntrySelection = CleanFolderGetMsvIdsL(aFolderId);
+    delete msvEntrySelection;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::CleanUserFoldersL
+// Cleans all user folders from SMS messages
+// -----------------------------------------------------------------------------
+void CSmsAdapterMsvApi::CleanUserFoldersL() 
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::CleanUserFoldersL" );
+    
+    // Get the folder	
+	CMsvEntry* msvEntry = iSession->GetEntryL(KMsvMyFoldersEntryIdValue);
+	CleanupStack::PushL(msvEntry);
+	
+	// Find all of it's childs
+	CMsvEntrySelection* folders = msvEntry->ChildrenWithTypeL(KUidMsvFolderEntry);
+	CleanupStack::PopAndDestroy(msvEntry); 
+	CleanupStack::PushL(folders);
+	
+	TInt error(KErrNone);
+
+    for (TInt index = 0; index < folders->Count(); index++)
+        {
+        TMsvId folderId = folders->At(index);
+        
+        if (folderId != KMsvMyFoldersTemplatesFolderId)
+            {
+            CleanFolderL(folderId);
+            error = DeleteUserFolderL(folderId);
+            if (error != KErrNone)
+                {
+                // Note: folder is not deleted if contains other message items (like MMS)
+                // In this case DeleteUserFolderL returns KErrInUse.
+                LOGGER_WRITE_1("iMsvApi->DeleteUserFolderL failed with %d", error);
+                }
+            }
+        }
+	
+	CleanupStack::PopAndDestroy(folders);
+	
+	// Delete also SMS messages directly under My Folders
+	CleanFolderL(KMsvMyFoldersEntryIdValue);
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::CleanUserFoldersL" );
+    }
+   
+// -----------------------------------------------------------------------------
+//	CSmsAdapterMsvApi::DiskSpaceBelowCriticalLevelL
+// -----------------------------------------------------------------------------
+//
+TBool CSmsAdapterMsvApi::DiskSpaceBelowCriticalLevelL( TInt aDataSize )
+    {
+    return SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aDataSize, iMessageDrive );
+    }
+
+// -----------------------------------------------------------------------------
+//	CSmsAdapterMsvApi::UpdateSMStatusL
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::UpdateSMStatusL( TMsvId aSmId, CVMessageParser &aSm )
+    {
+	LOGGER_ENTERFN( "CSmsAdapterMsvApi::UpdateSMStatusL" );
+
+	iMtm->SwitchCurrentEntryL( aSmId );
+
+	CMsvEntry& msvEntry = iMtm->Entry();
+	const TMsvEntry& oldEntry = msvEntry.Entry();
+	
+	TMsvEntry newEntry( oldEntry );
+
+	// STATUS
+	if (aSm.iStatus.Compare( KVMsgStatusUnread ) == 0)
+		{
+		newEntry.SetUnread( ETrue );
+		}
+	else if (aSm.iStatus.Compare( KVMsgStatusRead ) == 0)
+		{
+		newEntry.SetUnread( EFalse );
+		}
+	else 
+		{
+		LOGGER_WRITE( "Unexpected status, not updated" );
+		LOG( aSm.iStatus );
+		}
+
+	msvEntry.ChangeL( newEntry );
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::UpdateSMStatusL" );
+    }
+
+// -----------------------------------------------------------------------------
+//	CSmsAdapterMsvApi::DoUpdateSML
+// -----------------------------------------------------------------------------
+//
+void CSmsAdapterMsvApi::DoUpdateSML( TMsvId aSmId, CVMessageParser &aSm, TBool aNewSm )
+    {
+	LOGGER_WRITE_1( "CSmsAdapterMsvApi::DoUpdateSML: %d", aSmId );
+	TInt i;
+
+	iMtm->SwitchCurrentEntryL( aSmId );
+	iMtm->LoadMessageL();	
+	CMsvEntry& msvEntry = iMtm->Entry();
+	const TMsvEntry& oldEntry = msvEntry.Entry();
+	TMsvEntry newEntry(oldEntry);
+
+	// Set message status
+	if (aSm.iStatus.Compare( KVMsgStatusUnread ) == 0)
+		{
+		newEntry.SetUnread( ETrue );
+		}
+	else if (aSm.iStatus.Compare( KVMsgStatusRead ) == 0)
+		{
+		newEntry.SetUnread( EFalse );
+		}
+	else if (aNewSm)
+		{
+		newEntry.SetUnread( EFalse ); // by default msg is not unread, if we don't know
+		}	
+
+	// Set time. store format is universal
+	if ( aSm.iUniversalTime.Int64() > 0 )
+		{
+		newEntry.iDate = aSm.iUniversalTime;
+		}
+	else if ( aSm.iHomeTime.Int64() > 0 )
+		{
+		newEntry.iDate = UniversalTimeFromHomeTime( aSm.iHomeTime );
+		}
+	else
+		{
+		newEntry.iDate.UniversalTime();
+		}	
+	
+	// ADDRESS INFORMATION
+	TMsvId parent = newEntry.Parent();
+	LOGGER_WRITE_1( "Parent is %d", parent );
+	
+	TBuf<KNameMaxLength> addrBookName;
+	
+	CSmsHeader& header = iMtm->SmsHeader();
+	
+	if (header.Type() == CSmsPDU::ESmsDeliver)
+		{
+		if (aSm.iSender.iName.Length() > 0)
+			{
+			newEntry.iDetails.Set( aSm.iSender.iName );
+			header.SetFromAddressL( aSm.iSender.iName );
+			}
+		else if (aSm.iSender.iNumber.Length() > 0)
+			{
+			FetchNameFromContactsL(aSm.iSender.iNumber, addrBookName);
+			if (addrBookName.Length() > 0)
+				{
+				newEntry.iDetails.Set( addrBookName );
+				header.SetFromAddressL( addrBookName );
+				}
+			else
+				{		
+				newEntry.iDetails.Set( aSm.iSender.iNumber );
+				header.SetFromAddressL( aSm.iSender.iNumber );
+				}
+			}
+		CSmsMessage& smsMsg = header.Message();
+		CSmsPDU& smsPdu = smsMsg.SmsPDU();
+		CSmsDeliver* smsDeliver = reinterpret_cast<CSmsDeliver*>( &smsPdu );	
+		smsDeliver->SetServiceCenterTimeStamp( newEntry.iDate );
+		}
+	else // message to be sent
+		{
+		if (!aNewSm)
+			{
+			const CMsvRecipientList& addrList = iMtm->AddresseeList();
+    		TInt numOldAddr = addrList.Count();		
+    		for (i = 0; i < numOldAddr; i++)
+    			{
+    			iMtm->RemoveAddressee( i );
+    			}	
+			}		
+		
+		TInt numRecipients = aSm.iRecipients.Count();
+		
+		if (numRecipients > 0)
+			{
+			if (aSm.iRecipients[0].iName.Length() > 0)
+				{
+				newEntry.iDetails.Set( aSm.iRecipients[0].iName );
+				}
+			else if (aSm.iRecipients[0].iNumber.Length() > 0)
+				{
+				FetchNameFromContactsL(aSm.iRecipients[0].iNumber, addrBookName);
+				if (addrBookName.Length() > 0)
+					{
+					newEntry.iDetails.Set( addrBookName );
+					}
+				else
+					{
+					newEntry.iDetails.Set( aSm.iRecipients[0].iNumber );
+					}	
+				}
+			}
+			
+		for (i = 0; i < numRecipients; i++)
+			{
+			if (aSm.iRecipients[i].iNumber.Length() > 0)
+				{
+				if (aSm.iRecipients[i].iName.Length() > 0)
+					{
+					iMtm->AddAddresseeL( aSm.iRecipients[i].iNumber, aSm.iRecipients[i].iName );
+					}
+				else
+					{
+					FetchNameFromContactsL( aSm.iRecipients[i].iNumber, addrBookName );
+					iMtm->AddAddresseeL( aSm.iRecipients[i].iNumber, addrBookName );
+					}	
+				}
+			} 			
+		} // else
+
+	// MESSAGE BODY
+	LOGGER_WRITE( "Add message body" );
+	CRichText& mtmBody = iMtm->Body();
+	mtmBody.Reset();
+	aSm.LoadMessageBodyL( mtmBody );
+
+    TBuf<KSmsDescriptionLength> description;
+	description.Zero();
+	if (aSm.iMessageBody)
+		{
+		TPtrC16 leftBody = aSm.iMessageBody->Left( KSmsDescriptionLength );	
+		description.Copy( leftBody );
+		
+		for (i = 0; i < description.Length(); i++)
+			{
+			if (description[i] == '\n' || description[i] == '\r')
+				{
+				description[i] = ' ';
+				}
+			}	
+		newEntry.iDescription.Set( description );
+		}
+		
+	newEntry.SetVisible( ETrue );
+    newEntry.SetComplete( ETrue );
+    newEntry.SetInPreparation( EFalse );    
+    newEntry.SetSendingState( KMsvSendStateUponRequest );		
+
+	msvEntry.ChangeL( newEntry );
+
+	LOGGER_WRITE( "Save message" );
+	iMtm->SaveMessageL(); 
+	
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::DoUpdateSML" );		
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::ValidUserFolder
+// -----------------------------------------------------------------------------
+//
+TBool CSmsAdapterMsvApi::ValidFolderL( TMsvId aFolder, TBool aOutboxValid )
+    {
+    TBool valid(EFalse);
+    
+    switch ( aFolder )
+        {
+        case KMsvGlobalInBoxIndexEntryId:
+            valid = ETrue;  
+            break;
+        case KMsvDraftEntryId:
+           valid = ETrue;  
+           break;        
+        case KMsvSentEntryId:
+           valid = ETrue;  
+           break;
+        case KMsvGlobalOutBoxIndexEntryId:
+            if (aOutboxValid)
+                {
+                valid = ETrue;
+                }
+            break;
+        case KMsvMyFoldersEntryIdValue:
+           valid = ETrue;  
+           break;             
+        default:
+            valid = FindUserFolderL(aFolder);
+        }
+    
+    return valid;          
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CSmsAdapterMsvApi::FindUserFolderL(TMsvId aFolder, TPtrC& aName, TTime& aDate)
+    {
+    TBool found(EFalse);
+    
+    CMsvEntry* entry = iSession->GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL( entry );
+     
+    CMsvEntrySelection* selection = entry->ChildrenL();
+    CleanupStack::PushL( selection );
+    
+    TMsvId serviceId;
+    TMsvEntry entryT;
+
+    for( TInt i = 0; i < selection->Count(); i++ )
+        {
+        User::LeaveIfError( iSession->GetEntry( selection->At( i ), serviceId, entryT ) );
+        
+        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && entryT.Id() == aFolder )
+            {
+            found = ETrue;
+            aDate = entryT.iDate;
+            aName.Set(entryT.iDetails);
+            break;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( 2 ); // entry, selection    
+    
+    return found;        
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CSmsAdapterMsvApi::FindUserFolderL(TMsvId aFolder)
+    {
+    TPtrC name;
+    TTime time;
+    
+    return FindUserFolderL(aFolder, name, time); 
+    }    
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::FindUserFolderL
+// -----------------------------------------------------------------------------
+//    
+TBool CSmsAdapterMsvApi::FindUserFolderL(const TDesC& aName, TMsvId& aFolder)
+    {
+    CMsvEntry* entry = iSession->GetEntryL( KMsvMyFoldersEntryIdValue );
+    CleanupStack::PushL( entry );
+     
+    CMsvEntrySelection* selection = entry->ChildrenL();
+    CleanupStack::PushL( selection );
+    
+    TBool found(EFalse);
+    TMsvId serviceId;
+    TMsvEntry entryT;
+
+    for( TInt i = 0; i < selection->Count(); i++ )
+        {
+        User::LeaveIfError( iSession->GetEntry( selection->At( i ), serviceId, entryT ) );
+        
+        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && 
+            aName.Compare(entryT.iDescription) == 0 )
+            {
+            found = ETrue;
+            aFolder = entryT.Id();
+            break;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( 2 ); // entry, selection    
+    
+    return found;           
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::IsUnicode
+// -----------------------------------------------------------------------------
+//
+TBool CSmsAdapterMsvApi::IsUnicode( const TUint16 aValue )
+    {
+	if ( aValue > 0x7F && KSmsNonUnicodeChars().Locate( aValue ) < 0 )
+		{
+		LOGGER_WRITE_1( "IsUnicode: Found UC char %d", aValue );
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::MoveSML
+// Moves SM to another folder.
+// -----------------------------------------------------------------------------
+void CSmsAdapterMsvApi::MoveSML( TMsvId aSmId, TMsvId aParentId )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::MoveSML starts" );
+    
+    if ( !ValidFolderL( aParentId ) )
+        {
+		LOGGER_WRITE( "MoveSML: wrong folder" );
+        User::Leave( KErrArgument );
+        }
+	
+	// Find the parent
+	CMsvEntry* clientEntry( NULL );
+	
+	// Find this entry and put it to cleanup stack
+	clientEntry = iSession->GetEntryL( aSmId );
+	CleanupStack::PushL( clientEntry );
+	
+	// Check that this is a SMS message
+	TMsvEntry entryT = clientEntry->Entry();
+	if (entryT.iType != KUidMsvMessageEntry || entryT.iMtm != KUidMsgTypeSMS)
+	    {
+	    LOGGER_WRITE( "MoveSML: wrong entry type" );
+	    User::Leave( KErrArgument );
+	    }
+   
+	// Find parent id, we'll be moving it's childs
+	TMsvId parentId = entryT.Parent();
+	
+	// Make sure that the parent has changed
+	if (parentId != aParentId)
+		{
+	    // Set parent as context
+	    clientEntry->SetEntryL( parentId );
+
+		// Move the child item to another branch, use temporary waiter object
+		CMsvOperationActiveSchedulerWait* w = CMsvOperationActiveSchedulerWait::NewLC();
+		CMsvOperation* op = clientEntry->MoveL( aSmId, aParentId, w->iStatus );
+		w->Start();
+		SAFEDELETE( op );
+		CleanupStack::PopAndDestroy();
+		
+		}
+	else
+		{
+		LOGGER_WRITE( "CSmsAdapterMsvApi::MoveSML, identical parents." );
+		}		  
+	
+ 	CleanupStack::PopAndDestroy(); // entry
+ 	
+ 	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::MoveSML" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::AddUserFolderL
+// Creates new user folder
+// -----------------------------------------------------------------------------        
+TInt CSmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::AddUserFolderL" );
+    LOG(aName);
+        
+    // Make sure that we are not going to add same folder twise
+    TBool found(EFalse);
+    found = FindUserFolderL(aName, aFolder);
+    if ( found )
+        {
+        LOGGER_WRITE( "Folder already exists" );
+        return KErrNone;
+        } 
+        
+    CMsvEntry* entry = iSession->GetEntryL(KMsvMyFoldersEntryIdValue);
+    CleanupStack::PushL( entry );
+    
+    TTime date;
+    date.UniversalTime();      
+    
+    TMsvEntry folderEntry;
+    folderEntry.iType = KUidMsvFolderEntry;
+    folderEntry.iMtm = KUidMsvLocalServiceMtm;
+    folderEntry.iDetails.Set(aName);   
+    folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue;
+    folderEntry.iSize = sizeof(folderEntry);
+    folderEntry.iDate = date;
+    folderEntry.SetStandardFolder(EFalse);
+    folderEntry.SetVisible(ETrue);
+    folderEntry.SetComplete(ETrue);
+    folderEntry.SetInPreparation(EFalse); 
+    folderEntry.SetReadOnly(EFalse);  
+    
+    entry->CreateL(folderEntry);
+    CleanupStack::PopAndDestroy(entry);
+    
+    aFolder = folderEntry.Id();
+    LOGGER_LEAVEFN( "CSmsAdapterMsvApi::AddUserFolderL" );
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::UpdateUserFolderL
+// Updates user folder (changes name)
+// -----------------------------------------------------------------------------    
+TInt CSmsAdapterMsvApi::UpdateUserFolderL( TMsvId aFolder, const TDesC& aName )
+    {
+    LOGGER_ENTERFN( "CSmsAdapterMsvApi::UpdateUserFolderL" );
+    LOG(aName);
+    
+    CMsvEntry* entry = iSession->GetEntryL( aFolder );
+    CleanupStack::PushL( entry );
+    
+    TMsvEntry tEntry = entry->Entry();
+    
+    if ( tEntry.iType != KUidMsvFolderEntry )
+        {
+        CleanupStack::PopAndDestroy( entry );
+        LOGGER_WRITE( "No message folder" );
+        return KErrGeneral;
+        }
+       
+    tEntry.iDetails.Set(aName);   
+    tEntry.iDescription.Set(aName);
+    
+    entry->ChangeL(tEntry);
+    
+    CleanupStack::PopAndDestroy( entry );
+    LOGGER_LEAVEFN( "CSmsAdapterMsvApi::UpdateUserFolderL" );
+    return KErrNone;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::UniversalTimeFromHomeTime
+// Converts local time to universal time.
+// -----------------------------------------------------------------------------    
+TTime CSmsAdapterMsvApi::UniversalTimeFromHomeTime( TTime aTime )
+	{	
+	TLocale locale;
+	locale.Refresh();
+	
+	TTimeIntervalSeconds universalTimeOffset = locale.UniversalTimeOffset();
+	aTime -= universalTimeOffset;
+	
+	if (locale.QueryHomeHasDaylightSavingOn())
+    	{
+    	TTimeIntervalHours daylightSaving( 1 );
+    	aTime -= daylightSaving;
+    	}	
+	
+	return aTime;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::HomeTimeFromUniversalTime
+// Converts universal time to local time.
+// -----------------------------------------------------------------------------    
+TTime CSmsAdapterMsvApi::HomeTimeFromUniversalTime( TTime aTime )
+	{
+	TLocale locale;
+	locale.Refresh();
+	
+	TTimeIntervalSeconds universalTimeOffset = locale.UniversalTimeOffset();
+	aTime += universalTimeOffset;
+	
+	if (locale.QueryHomeHasDaylightSavingOn())
+    	{
+    	TTimeIntervalHours daylightSaving( 1 );
+    	aTime += daylightSaving;
+    	}
+	
+	return aTime;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSmsAdapterMsvApi::FetchNameFromContactsL
+// Searches contact name of given number from phone book
+// If not found, empty descriptor is returned.
+// -----------------------------------------------------------------------------    
+void CSmsAdapterMsvApi::FetchNameFromContactsL(const TDesC& aNumber, TDes& aName)
+	{
+	LOGGER_ENTERFN( "CSmsAdapterMsvApi::FetchNameFromContactsL" );
+	LOG(aNumber);
+	
+	aName.Zero(); 
+	
+	const TInt KNumDigitsToMatch(8);			
+	CContactIdArray* contactIds = iContactsDb->MatchPhoneNumberL(aNumber, KNumDigitsToMatch);		
+	if (contactIds->Count() != 1)
+		{
+		delete contactIds;
+		return;
+		}
+	CleanupStack::PushL(contactIds);		
+ 
+	CContactItem* item = iContactsDb->ReadContactLC((*contactIds)[0]);
+	CContactItemFieldSet& fieldSet = item->CardFields();
+		
+	TPtrC familyName;
+	TPtrC givenName;
+	TInt pos;
+	
+	pos = fieldSet.Find(KUidContactFieldFamilyName);
+	if (pos >= 0)
+		{
+		CContactItemField& itemField=fieldSet[pos];
+		if (!(itemField.IsHidden()) && !(itemField.IsDisabled()))
+			{
+			CContactTextField* textField = itemField.TextStorage();
+			familyName.Set(textField->Text());
+			}				
+		}
+	pos = fieldSet.Find(KUidContactFieldGivenName);
+	if (pos >= 0)
+		{
+		CContactItemField& itemField=fieldSet[pos];
+		if (!(itemField.IsHidden()) && !(itemField.IsDisabled()))
+			{
+			CContactTextField* textField = itemField.TextStorage();
+			givenName.Set(textField->Text());
+			}				
+		}	
+	
+	TInt spaceLeft = aName.MaxLength();
+	
+	if (familyName.Length() <= spaceLeft)
+		{
+		aName.Append(familyName);
+		aName.Trim();
+		spaceLeft -= aName.Length();
+		}
+		
+	if ((givenName.Length() + 1) <= spaceLeft)
+		{
+		aName.Append(' ');
+		aName.Append(givenName);
+		aName.Trim();
+		}
+		
+	LOG(aName);	
+	
+	CleanupStack::PopAndDestroy(2); // item, contactIds
+	LOGGER_LEAVEFN( "CSmsAdapterMsvApi::FetchNameFromContactsL" );
+	}
+		
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SmsDataProvider.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,311 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+  
+#include <f32file.h>
+#include <msvstd.h>
+#include <msvapi.h>    
+#include <bautils.h>
+#include <barsc.h> 
+#include <stringpool.h> 
+#include <data_caging_path_literals.hrh>
+#include <smsdatastore.rsg>
+#include <SmlDataFormat.h>
+#include <ecom/implementationproxy.h>
+#include "SmsDataProvider.h"
+#include "SmsDataProviderDefs.h"
+#include "Logger.h" 
+#include "SmsDataStore.h"
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::CSmsDataProvider
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CSmsDataProvider::CSmsDataProvider() :
+    iOwnStoreFormat( NULL ),
+    iFilters( 1 ),
+    iMsvSession( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CSmsDataProvider::ConstructL()
+    {
+    LOGGER_ENTERFN( "ConstructL" ); 
+    
+  	User::LeaveIfError( iRFs.Connect() );
+  	iStringPool.OpenL();
+
+    LOGGER_LEAVEFN( "ConstructL" )
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CSmsDataProvider* CSmsDataProvider::NewL()
+    {
+    LOGGER_ENTERFN( "CSmsDataProvider::NewL()" ); 
+    
+    CSmsDataProvider* self = new (ELeave) CSmsDataProvider;
+   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+	LOGGER_LEAVEFN( "CSmsDataProvider::NewL()" ); 
+	return self;  
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::~CSmsDataProvider
+// Destructor.
+// -----------------------------------------------------------------------------
+CSmsDataProvider::~CSmsDataProvider()
+    {
+    LOGGER_ENTERFN( "~CSmsDataProvider()" );
+    
+    SAFEDELETE( iOwnStoreFormat );	
+	
+    iStringPool.Close();
+    iFilters.Close();
+    
+    LOGGER_LEAVEFN( "~CSmsDataProvider()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::HandleSessionEventL
+// virtual function from MMsvSessionObserver, does nothing
+// -----------------------------------------------------------------------------
+void CSmsDataProvider::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/ )
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::HandleSessionEventL()" ); 
+	LOGGER_LEAVEFN( "CSmsDataProvider::HandleSessionEventL()" ); 
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoOnFrameworkEvent
+// Not used
+// -----------------------------------------------------------------------------
+void CSmsDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/ )
+    {
+    LOGGER_ENTERFN( "CSmsDataProvider::DoOnFrameworkEvent()" ); 
+    LOGGER_LEAVEFN( "CSmsDataProvider::DoOnFrameworkEvent()" ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoSupportsOperation
+// Checks whether data provider supports specific operation
+// -----------------------------------------------------------------------------
+TBool CSmsDataProvider::DoSupportsOperation( TUid /*aOpId*/ ) const 
+    {
+    LOGGER_ENTERFN( "CSmsDataProvider::DoSupportsOperation()" ); 
+  	LOGGER_LEAVEFN( "CSmsDataProvider::DoSupportsOperation()" ); 
+  	
+	// Optional operations are not supported
+	return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+const CSmlDataStoreFormat& CSmsDataProvider::DoStoreFormatL()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoStoreFormatL()" ); 
+	
+	if (!iOwnStoreFormat)
+	    {
+		iOwnStoreFormat = DoOwnStoreFormatL();
+		}
+	
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoStoreFormatL()" ); 
+	
+	return *iOwnStoreFormat;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoListStoresLC
+// Returns array fo data stores, not implemented because only single data store
+// is supported
+// -----------------------------------------------------------------------------
+CDesCArray* CSmsDataProvider::DoListStoresLC()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoListStoresLC()" );
+	
+	CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat( 1 );
+	CleanupStack::PushL( stores );
+	stores->AppendL( KNSmlDefaultLocalDbName );	
+	
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoListStoresLC()" );
+	
+	return stores;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoDefaultStoreL
+// Returns the name of the default data store
+// -----------------------------------------------------------------------------
+const TDesC& CSmsDataProvider::DoDefaultStoreL()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoDefaultStoreL()" ); 
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoDefaultStoreL()" ); 
+    return KNSmlDefaultLocalDbName;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoNewStoreInstanceLC
+// Creates a new data store object, which can be used for synchronization
+// ----------------------------------------------------------------------------- 
+CSmlDataStore* CSmsDataProvider::DoNewStoreInstanceLC()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoNewStoreInstanceLC" );
+    CSmsDataStore* newStore = CSmsDataStore::NewLC();
+    LOGGER_LEAVEFN( "CSmsDataProvider::DoNewStoreInstanceLC" );
+    return newStore;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoCheckSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CSmsDataProvider::DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    LOGGER_ENTERFN( "CSmsDataProvider::DoCheckSupportedServerFiltersL()" ); 
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoCheckServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CSmsDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    LOGGER_ENTERFN( "CSmsDataProvider::DoCheckServerFiltersL()" ); 
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+const RPointerArray<CSyncMLFilter>& CSmsDataProvider::DoSupportedServerFiltersL()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoSupportedServerFiltersL()" ); 
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoSupportedServerFiltersL()" ); 
+	return iFilters; // empty array
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoSupportsUserSelectableMatchType
+// Not supported
+// ----------------------------------------------------------------------------- 		
+TBool CSmsDataProvider::DoSupportsUserSelectableMatchType() const
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoSupportsUserSelectableMatchType()" ); 
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoSupportsUserSelectableMatchType()" ); 
+	return EFalse;
+	}			
+	
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoGenerateRecordFilterQueryLC
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+HBufC* CSmsDataProvider::DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoGenerateRecordFilterQueryLC()" ); 
+	User::Leave( KErrNotSupported );
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoGenerateFieldFilterQueryL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CSmsDataProvider::DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ )
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoGenerateFieldFilterQueryL()" ); 
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataProvider::DoOwnStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+CSmlDataStoreFormat* CSmsDataProvider::DoOwnStoreFormatL()
+	{
+	LOGGER_ENTERFN( "CSmsDataProvider::DoOwnStoreFormatL()" ); 
+	
+	TParse* parse = new ( ELeave ) TParse();
+	CleanupStack::PushL(parse);
+	TFileName fileName;
+	RResourceFile resourceFile;
+	
+	parse->Set( KSmsStoreFormatRscRom, &KDC_RESOURCE_FILES_DIR, NULL );
+	fileName = parse->FullName();
+	BaflUtils::NearestLanguageFile( iRFs, fileName );
+	
+	TRAPD( error, resourceFile.OpenL( iRFs, fileName ) );
+	if ( error )
+		{
+		LOGGER_WRITE_1( "RResourceFile::OpenL leaved with %d - try again", error );
+		parse->Set( KSmsStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL );
+		fileName = parse->FullName();
+		BaflUtils::NearestLanguageFile( iRFs, fileName );
+		resourceFile.OpenL( iRFs, fileName );
+		}
+	CleanupClosePushL( resourceFile );
+
+	HBufC8* buffer = resourceFile.AllocReadLC( SMS_DATA_STORE );
+	
+	TResourceReader reader;
+	reader.SetBuffer( buffer );
+
+	CSmlDataStoreFormat* dsFormat = NULL;
+	dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader );
+	
+	CleanupStack::Pop(); // dsFormat
+	CleanupStack::PopAndDestroy( 3 ); // buffer, resourceFile, parse
+
+	LOGGER_LEAVEFN( "CSmsDataProvider::DoOwnStoreFormatL()" ); 
+	
+	return dsFormat;	
+	}
+
+
+// -----------------------------------------------------------------------------
+// ImplementationTable
+// Required by ECom plugin interface, tells the entry point of the library
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+	{
+	IMPLEMENTATION_PROXY_ENTRY( KSmsDataProviderImplUid, CSmsDataProvider::NewL )
+	};
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Returns the implementation table, required by the ECom plugin interface
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+	{
+	aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+	return ImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SmsDataProvider.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for SMS DS ECOM plug-in
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x10206B5C; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x101F4D3A; // Constant for all DS plug ins
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x10206B5C; // DS interface implementation UID
+                version_no = 1; 
+                display_name = "SMS"; // default name in UI
+                }
+            };
+          }
+      };
+  }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SmsDataStore.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,1362 @@
+/*
+* Copyright (c) 2005-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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <e32base.h>
+#include <msvstd.h>
+#include <msvapi.h>
+#include <msvids.h>
+#include <mtclreg.h>
+#include <centralrepository.h>
+#include "SmsDataStore.h"
+#include "SmsDataProviderDefs.h"
+#include "Logger.h"
+#include "SMSAdapterMsvApi.h"
+#include "VMessageParser.h"
+#include "OMADSFolderObject.h"
+
+// This is used, when databuffer is not initialized
+const TInt KDataBufferNotReady = -1;
+// Size for internal CBufFlat, used to buffer SMS messages
+const TInt KDataBufferSize = 1024;
+
+_LIT8(KSmsMimeType, "text/x-vMessage");
+_LIT8(KSmsMimeVersion, "1.2");
+_LIT8(KFolderMimeType, "application/vnd.omads-folder+xml");
+_LIT8(KFolderMimeVersion, "1.2");
+
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::CSmsDataStore
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+CSmsDataStore::CSmsDataStore():
+    iHasHistory(EFalse),
+    iDataBaseOpened(EFalse),
+    iKey(TKeyArrayFix(_FOFF(TSnapshotItem, ItemId()), ECmpTInt))
+    { 
+    }
+  
+// -----------------------------------------------------------------------------
+// CSmsDataStore::ConstructL
+// Symbian 2nd phase constructor, can leave.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::ConstructL()
+    {
+	LOGGER_ENTERFN("CSmsDataStore::ConstructL");
+    
+    iMsvApi = CSmsAdapterMsvApi::NewL();
+    
+	// Item UID sets, used to transfer change info
+    iNewItems = new (ELeave) CNSmlDataItemUidSet;
+    iDeletedItems = new (ELeave) CNSmlDataItemUidSet;
+    iUpdatedItems = new (ELeave) CNSmlDataItemUidSet;
+    iMovedItems = new (ELeave) CNSmlDataItemUidSet;
+    iSoftDeletedItems = new (ELeave) CNSmlDataItemUidSet;
+	
+	iMessageParser = CVMessageParser::NewL();
+	iFolderObjectParser = COMADSFolderObject::NewL();
+	
+	LOGGER_LEAVEFN("CSmsDataStore::ConstructL");
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CSmsDataStore* CSmsDataStore::NewLC()
+    {
+    CSmsDataStore* self = new (ELeave) CSmsDataStore;
+    
+	CleanupStack::PushL(self);
+  	self->ConstructL();
+
+    return self;    
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CSmsDataStore::~CSmsDataStore
+// Destructor
+// -----------------------------------------------------------------------------
+CSmsDataStore::~CSmsDataStore()
+    {
+    LOGGER_ENTERFN("CSmsDataStore::~CSmsDataStore()");
+    
+    SAFEDELETE(iFolderObjectParser);
+    SAFEDELETE(iMessageParser);
+    
+    SAFEDELETE(iMsvApi);
+	SAFEDELETE(iChangeFinder); 	
+ 
+	// UID sets
+	SAFEDELETE(iNewItems);
+	SAFEDELETE(iDeletedItems);
+	SAFEDELETE(iSoftDeletedItems);
+	SAFEDELETE(iUpdatedItems);
+	SAFEDELETE(iMovedItems);
+	
+	SAFEDELETE(iDataBuffer);
+	
+	LOGGER_LEAVEFN("CSmsDataStore::~CSmsDataStore()");
+    }
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoOpenL
+// Opens database. This operation is performed SYNCHRONOUSLY
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoOpenL(const TDesC& /*aStoreName*/, MSmlSyncRelationship& aContext, 
+    TRequestStatus& aStatus)
+    {
+	LOGGER_ENTERFN("CSmsDataStore::DoOpenL");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	if (iDataBaseOpened)
+		{
+		User::RequestComplete(iCallerStatus, KErrInUse);
+		LOGGER_WRITE("CSmsDataStore::DoOpenL failed with KErrInUse.");
+		return;
+		}
+	
+    *iContext = aContext;
+
+	// Create ChangeFinder object
+    iChangeFinder = CChangeFinder::NewL(aContext, iKey, iHasHistory, KSmsDataProviderImplUid);
+    
+    RegisterSnapshotL();
+  
+    iDataBaseOpened = ETrue;
+    iCurrentState = ESmsOpenAndWaiting;
+	User::RequestComplete(iCallerStatus, KErrNone);	
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoOpenL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCancelRequest
+// Not supported, does nothing.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCancelRequest()
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCancelRequestL");
+	LOGGER_LEAVEFN("CSmsDataStore::DoCancelRequestL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoStoreName
+// Returns the name of the DataStore
+// -----------------------------------------------------------------------------
+const TDesC& CSmsDataStore::DoStoreName() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoStoreName");
+	
+	if (iDataBaseOpened)
+		{
+		LOGGER_LEAVEFN("CSmsDataStore::DoStoreName");
+	    return KNSmlDefaultLocalDbName;
+	    }
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoStoreName");
+    return KNullDesC;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoBeginTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoBeginTransactionL()
+ 	{
+ 	LOGGER_ENTERFN("CSmsDataStore::DoBeginTransactionL");
+ 	LOGGER_WRITE("CSmsDataStore::DoBeginTransactionL leaved with KErrNotSupported.")
+ 	User::Leave(KErrNotSupported);
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCommitTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCommitTransactionL(TRequestStatus& aStatus)
+    {
+	LOGGER_ENTERFN("CSmsDataStore::DoCommitTransactionL"); 
+	LOGGER_WRITE("CSmsDataStore::DoCommitTransactionL failed with KErrNotSupported.");
+	
+	iCallerStatus = &aStatus;
+	User::RequestComplete(iCallerStatus, KErrNotSupported);
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoCommitTransactionL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoRevertTransaction
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoRevertTransaction(TRequestStatus& aStatus)
+    {
+	LOGGER_ENTERFN("CSmsDataStore::DoRevertTransaction"); 
+	iCallerStatus = &aStatus;
+	User::RequestComplete(iCallerStatus, KErrNone);	
+	LOGGER_LEAVEFN("CSmsDataStore::DoRevertTransaction");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoBeginBatchL
+// Batching is not supported.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoBeginBatchL()
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoBeginBatchL");
+	LOGGER_WRITE("CSmsDataStore::DoBeginBatchL leaved with KErrNotSupported.");
+	User::Leave(KErrNotSupported);	
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCommitBatchL
+// Batching is not supported
+// -----------------------------------------------------------------------------
+//
+void CSmsDataStore::DoCommitBatchL(RArray<TInt>& /*aResultArray*/, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCommitBatchL");	
+	LOGGER_WRITE("CSmsDataStore::DoCommitBatchL failed with KErrNotSupported");
+	
+	iCallerStatus = &aStatus;
+	User::RequestComplete(iCallerStatus, KErrNotSupported);
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoCommitBatchL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCancelBatch
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCancelBatch()
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCancelBatch");
+	LOGGER_LEAVEFN("CSmsDataStore::DoCancelBatch");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoSetRemoteStoreFormatL
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CSmsDataStore::DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& /*aServerDataStoreFormat*/)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoSetRemoteStoreFormatL");
+	LOGGER_LEAVEFN("CSmsDataStore::DoSetRemoteStoreFormatL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoSetRemoteMaxObjectSize
+// Not supported
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoSetRemoteMaxObjectSize(TInt /*aServerMaxObjectSize*/)
+ 	{
+	LOGGER_ENTERFN("CSmsDataStore::DoSetRemoteMaxObjectSize");
+	LOGGER_LEAVEFN("CSmsDataStore::DoSetRemoteMaxObjectSize");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoMaxObjectSize
+// 
+// -----------------------------------------------------------------------------
+TInt CSmsDataStore::DoMaxObjectSize() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoMaxObjectSize");
+    LOGGER_LEAVEFN("CSmsDataStore::DoMaxObjectSize");
+    return 0;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoOpenItemL
+// Opens item in the DataStore, reads it (either completely or partially) 
+// to the temporary buffer where it can be later read to the remote database.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, 
+	TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, 
+	TDes8& aMimeVer, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoOpenItemL");
+
+    LOGGER_WRITE_1("Opening item %d.", aUid);
+    
+	// Store these for later use
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	// Check that we're in a proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoOpenItemL, Incorrect state: %d", iCurrentState);
+		}
+    
+    // Allocate new buffer
+    SAFEDELETE(iDataBuffer);
+    iDataBuffer = CBufFlat::NewL(KDataBufferSize);
+
+    TBool userFolderFound(EFalse);
+    TTime timeStamp;
+    TPtrC folderName;
+    userFolderFound = iMsvApi->FindUserFolderL(aUid, folderName, timeStamp);
+    if (userFolderFound)
+        {
+        iMimeType = EMessageFolder;
+        iParentId = KMsvMyFoldersEntryIdValue;
+        
+        iFolderObjectParser->SetName(folderName);
+        iFolderObjectParser->SetCreatedDate(timeStamp.DateTime());
+        iFolderObjectParser->SetModifiedDate(timeStamp.DateTime());
+        iFolderObjectParser->ExportFolderXmlL(*iDataBuffer); 
+        }
+    else
+        {
+        iMimeType = ESmsMessage;        
+        iMessageParser->ResetAll();
+        
+        TBool unread;
+        TMsvId parent;
+        TRAPD(error, iMsvApi->RetrieveSML(aUid, parent, *iMessageParser, unread));
+        if(error != KErrNone)
+		    {
+		    User::RequestComplete(iCallerStatus, KErrNotFound); 
+		    LOGGER_WRITE_1("RetrieveSML(aUid, &parser, flags) leaved with %d.", error);
+		    return;
+		    }
+		    
+        iParentId = parent;
+        iMessageParser->ConstructMessageL(*iDataBuffer);
+        }
+    
+    // Adjust buffer
+    iDataBuffer->Compress();
+    iReaderPosition = 0;
+    iCurrentState = ESmsItemOpen;		
+
+	// Return these
+	aFieldChange = EFalse;
+	aParent = iParentId;
+    aSize = iDataBuffer->Size();
+    	
+    if (iMimeType == EMessageFolder)
+        {
+        TInt targetLength = KFolderMimeType().Length();
+    	if (aMimeType.MaxLength() < targetLength)
+    	    targetLength = aMimeType.MaxLength();
+    	aMimeType.Copy(KFolderMimeType().Ptr(), targetLength);
+
+        // Set mime version (do not exceed the allocated buffer)
+    	targetLength = KFolderMimeVersion().Length();
+    	if (aMimeVer.MaxLength() < targetLength)
+    	    targetLength = aMimeVer.MaxLength();
+    	aMimeVer.Copy(KFolderMimeVersion().Ptr(), targetLength);
+        }
+    else // ESmsMessage
+        {   
+    	TInt targetLength = KSmsMimeType().Length();
+    	if (aMimeType.MaxLength() < targetLength)
+    	    targetLength = aMimeType.MaxLength();
+    	aMimeType.Copy(KSmsMimeType().Ptr(), targetLength);
+
+        // Set mime version (do not exceed the allocated buffer)
+    	targetLength = KSmsMimeVersion().Length();
+    	if (aMimeVer.MaxLength() < targetLength)
+    	    targetLength = aMimeVer.MaxLength();
+    	aMimeVer.Copy(KSmsMimeVersion().Ptr(), targetLength);
+        }
+		
+   	// Signal we're complete
+	User::RequestComplete(iCallerStatus, KErrNone); 
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoOpenItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCreateItemL
+// Create new item to the message store.
+// Return the id number of the newly created item
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, 
+    TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& /*aMimeVer*/, 
+    TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCreateItemL");
+	
+	// Store some variables for further use
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	// Ensure that we're in proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+		{
+		LOGGER_WRITE_1("Incorrect state: %d", iCurrentState);
+		}	
+
+	// Check MIME type
+	LOG(aMimeType);
+	if (aMimeType.Compare( KFolderMimeType() ) == 0)	
+		{
+		iMimeType = EMessageFolder;
+		}
+	else if (aMimeType.Compare( KSmsMimeType() ) == 0)
+		{
+		iMimeType = ESmsMessage;
+		}
+	else
+		{
+		User::RequestComplete( iCallerStatus, KErrNotSupported );
+		LOGGER_WRITE("Bad MIME type");
+		return;
+		}
+	
+	LOGGER_WRITE_1( "Parent folder: %d", aParent);
+	if ((iMimeType == EMessageFolder && aParent != KMsvMyFoldersEntryIdValue) ||
+	    (iMimeType == ESmsMessage && !iMsvApi->ValidFolderL(aParent)))
+	    {
+		User::RequestComplete( iCallerStatus, KErrNotSupported );
+		LOGGER_WRITE( "Bad parent folder");
+		return;	    
+	    }
+
+	// Ensure that we've got enough disk space for the item
+	if(iMsvApi->DiskSpaceBelowCriticalLevelL(aSize))
+		{
+		User::RequestComplete(iCallerStatus, KErrDiskFull);
+		LOGGER_WRITE("Disk full");
+		return;
+		}	
+			
+    // Store uid values
+    iCreatedUid = &aUid;
+	iParentId = aParent; 
+    
+    // Create message buffer, item will be written into this buffer
+	SAFEDELETE(iDataBuffer);
+	iDataBuffer = CBufFlat::NewL(KDataBufferSize);
+	iWriterPosition = 0;
+	iCurrentState = ESmsItemCreating;
+	
+	// Signal we're complete
+	User::RequestComplete( iCallerStatus, KErrNone );
+    
+    LOGGER_LEAVEFN("CSmsDataStore::DoCreateItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoReplaceItemL
+// Begin the replace operation, ensure that the item really exists
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, 
+    TBool /*aFieldChange*/, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoReplaceItemL");
+	LOGGER_WRITE_1("Replacing item %d.", aUid);
+	LOGGER_WRITE_1("Parent folder: %d.", aParent);
+	
+	// Store some variables for further use
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	// Ensure proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+		{
+		LOGGER_WRITE_1("Incorrect state: %d", iCurrentState);
+		}
+	 
+	// Ensure that we've got enough disk space for the item
+	if (iMsvApi->DiskSpaceBelowCriticalLevelL(aSize))
+		{
+		User::RequestComplete(iCallerStatus, KErrDiskFull);
+		LOGGER_WRITE("Disk full");
+		return;
+		}
+			 
+	// Find entry
+	CMsvEntry* entry(NULL);
+	TRAPD(error, entry = iMsvApi->MsvSessionL()->GetEntryL(aUid));
+	if (error != KErrNone)
+		{
+		User::RequestComplete(iCallerStatus, KErrNotFound);
+		LOGGER_WRITE("Item not found");
+		return;
+		}
+
+	// This is the representation of the actual message
+	TMsvEntry tEntry = entry->Entry();
+	
+	// Not needed anymore
+	SAFEDELETE(entry);	
+	
+	// Check entry type
+	if (tEntry.iType == KUidMsvFolderEntry)
+	    {
+	    iMimeType = EMessageFolder;
+	    LOGGER_WRITE("Type: folder");
+	    }
+	else
+	    {
+	    iMimeType = ESmsMessage;
+	    LOGGER_WRITE("Type: SMS message");
+	    }   
+    
+    if ((iMimeType == EMessageFolder && aParent != KMsvMyFoldersEntryIdValue) ||
+        (iMimeType == ESmsMessage && !iMsvApi->ValidFolderL(aParent) ||
+        (aParent != tEntry.Parent())))
+        {
+        User::RequestComplete(iCallerStatus, KErrNotSupported);
+        LOGGER_WRITE_1("Bad parent folder, message entry parent is %d", tEntry.Parent());
+        return;    
+        }    
+	
+	// Store these for further use
+	iParentId = aParent;
+	iCurrentId = aUid;
+
+	// Create temporary buffer for message data, item will be written here
+    SAFEDELETE(iDataBuffer);
+    iDataBuffer = CBufFlat::NewL(KDataBufferSize);
+	iWriterPosition = 0;
+	iCurrentState = ESmsItemUpdating;
+	
+	// Signal we're complete
+	User::RequestComplete(iCallerStatus, KErrNone);
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoReplaceItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoReadItemL
+// Read specified amount of data from the temporary buffer
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoReadItemL(TDes8& aBuffer)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoReadItemL");
+	
+	// Check that we're in proper state
+	if (iCurrentState != ESmsItemOpen || !iDataBuffer)
+		{
+		LOGGER_WRITE("CSmsDataStore::DoReadItemL leaved with KErrNotReady.");
+		User::Leave(KErrNotReady);
+		}
+
+	if (iReaderPosition == KDataBufferNotReady)
+		{
+		LOGGER_WRITE("CSmsDataStore::DoReadItemL leaved with KErrEof.");
+		User::Leave(KErrEof);
+		}
+		
+	// This is how much we've got left in the buffer
+	TInt left = iDataBuffer->Size() - iReaderPosition;
+	
+	// Make sure that there's something to read
+	if(left > 0)
+		{
+		// This is how much there's space in the destination buffer
+		TInt destSize = aBuffer.MaxSize();
+
+		// This is how much we can read
+		TInt toRead = destSize < left ? destSize : left;
+
+		// Read the data from the buffer, then update the position
+		iDataBuffer->Read(iReaderPosition, aBuffer, toRead);
+		iReaderPosition += toRead;
+		}
+	else
+		{
+		iReaderPosition = KDataBufferNotReady;
+		LOGGER_WRITE("CSmsDataStore::DoReadItemL leaved with KErrEof.");
+		User::Leave(KErrEof);
+		}
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoReadItemL");	
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoWriteItemL
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoWriteItemL(const TDesC8& aData)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoWriteItemL");
+
+	// Ensure that we're in proper state
+    if ( iCurrentState != ESmsItemCreating && iCurrentState != ESmsItemUpdating )
+    	{
+    	LOGGER_WRITE("CSmsDataStore::DoWriteItemL leaved with KErrNotReady.");
+    	User::Leave( KErrNotReady );
+    	}
+    		
+	// Calculate total size
+	TInt totalSize = aData.Size() + iDataBuffer->Size();
+	    
+    // Check that we have enough disk space to store this much data
+	if ( iMsvApi->DiskSpaceBelowCriticalLevelL( totalSize ) )
+	    {
+	    LOGGER_WRITE("CSmsDataStore::DoWriteItemL leaved with KErrDiskFull.");
+	    User::Leave(KErrDiskFull);
+	    }
+	    
+	// Add data to buffer
+    iDataBuffer->InsertL( iWriterPosition, aData );
+    iWriterPosition += aData.Size();
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoWriteItemL");	
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCommitItemL
+// Commits item from temporary buffer to the message store
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCommitItemL(TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCommitItemL");
+	TInt error(KErrNone);
+	
+	// Store some variables
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	// Check that we're in proper state
+	if ((iCurrentState != ESmsItemCreating && iCurrentState != ESmsItemUpdating) || !iDataBuffer)
+		{
+		User::RequestComplete(iCallerStatus, KErrNotReady);
+		LOGGER_WRITE_1("Bad state: %d", iCurrentState);
+		return;
+		}
+
+	iDataBuffer->Compress();
+	TInt size = iDataBuffer->Size();
+	
+	// Variable to hold the information whether SMS message is unread or not for Change Finder.
+	// For message folders this information is not relevant and value is EFalse by default.	
+	TBool unread(EFalse);
+	
+	if ( iMimeType == ESmsMessage )
+		{
+		// Reset parser
+        iMessageParser->ResetAll();
+        
+        // This function returns the index, where the parsing ends (>=0)
+        // (the error codes are in the range below 0)
+        error = iMessageParser->ParseMessageL(iDataBuffer->Ptr(0));
+        
+		if ( error >= 0 )
+		    {
+    		unread = iMessageParser->iStatus.Compare(KVMsgStatusUnread) == 0 ? ETrue : EFalse;
+    		    		
+    		// Check the datastore state. We're either creating or updating an item.
+    		if (iCurrentState == ESmsItemCreating)
+    			{
+    			TMsvId id;
+    			TMsvId temporaryParent = iParentId;
+    			// in message sending case, save message first to drafts folder
+    			if ( iParentId == KMsvGlobalOutBoxIndexEntryId )
+    			    {
+    			    temporaryParent = KMsvDraftEntryId;
+    			    }
+    			
+    			TRAP(error, iMsvApi->AddSML(*iMessageParser, temporaryParent, id));
+    			if ( error == KErrNone )
+    				{
+        			*iCreatedUid = id;
+        			iCurrentId = id;
+    				}
+    			else
+        			{
+    				LOGGER_WRITE_1("iMsvApi->AddSML leaved with %d.", error);
+    	    		}
+    			}
+    		else // EItemUpdating
+    			{
+    		    if ( iParentId == KMsvGlobalInBoxIndexEntryId )
+    		    	{
+    		    	// For arrived message in Inbox only status is updated
+    		    	TRAP(error, iMsvApi->UpdateSMStatusL( iCurrentId, *iMessageParser));
+    		    	}
+    		    else
+    		    	{
+	    			TRAP(error, iMsvApi->ReplaceSML(iCurrentId, *iMessageParser));
+    		    	}
+    			if(error != KErrNone)
+    			    {
+    				LOGGER_WRITE_1("iMsvApi->ReplaceSML leaved with %d.", error);
+    				}
+    			}
+		    }
+    	else
+    	    {
+   		    LOGGER_WRITE_1("iMessageParser->ParseMessageL failed with %d.", error);
+   		    }
+		} // if (iMimeType == ESmsMessage)
+		
+	else // EMessageFolder
+	    {
+	    error = iFolderObjectParser->ImportFolderXml(iDataBuffer->Ptr(0));
+	    
+	    if ( error == KErrNone )
+	        {
+	        const TDesC& name = iFolderObjectParser->GetName();
+	        
+	        if ( name.Length() > 0 )
+	            {
+	            if ( iCurrentState == ESmsItemCreating )
+	                {
+	                TMsvId id;
+	                error = iMsvApi->AddUserFolderL( id, name );
+	                if ( error == KErrNone )
+	                    {
+	                    *iCreatedUid = id;
+	                    iCurrentId = id;
+	                    }
+	                else
+	                    {
+	                    LOGGER_WRITE_1("iMsvApi->AddFolderL failed with %d", error);
+	                    }    
+	                }
+	            else // Updating
+	                {
+	                error = iMsvApi->UpdateUserFolderL( iCurrentId, name );
+	                if ( error != KErrNone )
+	                    {
+	                    LOGGER_WRITE_1("iMsvApi->UpdateFolderL failed with %d", error);
+	                    }
+	                }    
+	            }
+	        else
+	            {
+	            LOGGER_WRITE("No folder name available");
+	            error = KErrArgument;
+	            }    
+	        }
+	    }
+	
+	// Send the message if the parent folder is outbox
+    if( iParentId == KMsvGlobalOutBoxIndexEntryId &&
+        iMimeType == ESmsMessage &&
+        iCurrentState == ESmsItemCreating &&
+        error == KErrNone )
+		{
+		LOGGER_WRITE("CSmsDataStore::DoCommitItemL, sending message.");
+		
+		TRAP( error, iMsvApi->MoveSML( iCurrentId, iParentId ) );
+		if( error != KErrNone )
+			{
+			LOGGER_WRITE_1("Moving to folder failed with %d", error);
+			iMsvApi->DeleteSML( iCurrentId );
+			}
+		else
+			{
+			TRAP( error, iMsvApi->SendSML(iCurrentId) );
+			if ( error != KErrNone )
+				{
+				LOGGER_WRITE_1("iMsvApi->SendSML failed with %d.", error);
+				iMsvApi->DeleteSML( iCurrentId );
+				}
+			}
+		}   
+    
+    if ( error == KErrNone ) // Update Change Finder
+        {
+        CMsvSession* msvSession = iMsvApi->MsvSessionL();   
+        TMsvId service;
+        TMsvEntry msgEntry;
+        
+        // Inform ChangeFinder of added item
+        TSnapshotItem snapshotItem( iCurrentId, iParentId, unread );
+        error = msvSession->GetEntry( iCurrentId, service, msgEntry );
+   
+        if ( error == KErrNone )
+            {
+            snapshotItem.SetLastChangedDate( msgEntry.iDate );
+            if ( iMimeType == EMessageFolder )
+                {
+                snapshotItem.SetFolderNameL( msgEntry.iDetails );
+                }
+        
+            if ( iCurrentState == ESmsItemCreating )
+                {
+                iChangeFinder->ItemAddedL( snapshotItem );
+                }
+            else
+                {
+                iChangeFinder->ItemUpdatedL( snapshotItem );
+                }    
+            }
+        else
+            {
+            LOGGER_WRITE_1("CMsvSession::GetEntry failed with %d", error);
+            }    
+        }
+		
+	// Reset and destroy write buffer, it's no longer needed
+	iWriterPosition = KDataBufferNotReady;
+	SAFEDELETE(iDataBuffer);
+		
+	// We'll be waiting for next event, signal we're done
+	iCurrentState = ESmsOpenAndWaiting;
+	User::RequestComplete(iCallerStatus, error);
+ 
+ 	LOGGER_LEAVEFN("CSmsDataStore::DoCommitItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCloseItem
+// Closes open item in the data store
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCloseItem()
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCloseItem");
+	
+	// Make sure that we're opened an item
+	if ( iCurrentState == ESmsItemOpen )
+		{
+		// Reset read buffer 
+		iReaderPosition = KDataBufferNotReady;
+		SAFEDELETE(iDataBuffer);
+		
+		// Start to wait for the next operation		
+		iCurrentState = ESmsOpenAndWaiting;
+		}
+	else 
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoCloseItem, invalid state %d.", iCurrentState);
+		}
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoCloseItem");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoMoveItemL
+// Moves item from one folder to another in the message store
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoMoveItemL");
+	
+	LOGGER_WRITE_1("Moving item %d.", aUid);
+	
+	// Store some variables for further use
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+
+    // Check that we're in proper state
+	if (iCurrentState != ESmsOpenAndWaiting) 
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoMoveItemL, Incorrect state: %d", iCurrentState);
+		}
+
+    TInt error_move(KErrNone);
+	TRAP(error_move, iMsvApi->MoveSML(aUid, aNewParent));
+	if(error_move != KErrNone)
+		{
+		User::RequestComplete(iCallerStatus, error_move); 
+		LOGGER_WRITE_1("iMsvApi->MoveSML leaved with %d.", error_move);
+		return;
+		}
+
+	// Inform ChangeFinder of the moved item
+	TSnapshotItem snapshotItem(aUid, aNewParent);
+	iChangeFinder->ItemMovedL(snapshotItem);
+
+   	// Signal we're done
+    User::RequestComplete(iCallerStatus, KErrNone);
+    
+    LOGGER_LEAVEFN("CSmsDataStore::DoMoveItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoDeleteItemL
+// Removes item from the message store
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoDeleteItemL");
+
+	// Store some variables for further use
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+	if (iCurrentState != ESmsOpenAndWaiting) 
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoDeleteItemL, Incorrect state: %d", iCurrentState);
+		}
+		
+    TInt error(KErrNone);	
+		
+	// Check if this is a user folder
+	TBool userFolder = iMsvApi->FindUserFolderL(aUid);
+	
+	if (userFolder)
+	    {
+	    LOGGER_WRITE_1("Delete user folder %d", aUid);
+	    
+	    // First delete SMS messages under the folder
+	    CMsvEntrySelection* deletedItems = iMsvApi->CleanFolderGetMsvIdsL(aUid);
+	    CleanupStack::PushL(deletedItems);
+	    
+	    for (TInt i = 0; i < deletedItems->Count(); i++)
+	        {
+	        TMsvId id = deletedItems->At(i);
+	        TSnapshotItem item(id);
+	        iChangeFinder->ItemDeletedL(item);
+	        }
+	    CleanupStack::PopAndDestroy(deletedItems);    
+	    
+	    // Then delete the actual folder
+	    // Note: folder is not deleted if it contains other message items (like MMS)
+        TRAP(error, iMsvApi->DeleteUserFolderL(aUid));
+	    }
+	else
+	    {
+    	LOGGER_WRITE_1("Delete SMS message %d", aUid);
+    	TRAP(error, iMsvApi->DeleteSML(aUid))
+	    }
+	    
+	if ( error != KErrNone )
+	    {
+		User::RequestComplete(iCallerStatus, error); 
+		LOGGER_WRITE_1("iMsvApi function call leaved with %d", error);
+		return;	    
+	    }
+	    
+	// Inform ChangeFinder of the removed item
+	TSnapshotItem item(aUid);
+	iChangeFinder->ItemDeletedL(item);
+    	
+	// Signal we're done
+	User::RequestComplete(iCallerStatus, KErrNone);
+
+	LOGGER_LEAVEFN("CSmsDataStore::DoDeleteItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoSoftDeleteItemL
+// Soft delete is not supported.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoSoftDeleteItemL(TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoSoftDeleteItemL");	
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	User::RequestComplete(iCallerStatus, KErrNotSupported);
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoSoftDeleteItemL");
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoDeleteAllItemsL
+// Deletes all items in the standard folders of message store
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoDeleteAllItemsL(TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoDeleteAllItemsL");
+	
+	// Store some variables for further use	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+   // Check that we're in proper state
+	if (iCurrentState != ESmsOpenAndWaiting) 
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoDeleteAllItemsL, Incorrect state: %d", iCurrentState);
+		}	
+	
+	// Delete all messages in the standard folders (except outbox)
+	iMsvApi->CleanFolderL(KMsvGlobalInBoxIndexEntryId);
+	iMsvApi->CleanFolderL(KMsvDraftEntryId);
+	iMsvApi->CleanFolderL(KMsvSentEntryId);
+	
+	iMsvApi->CleanUserFoldersL();
+	
+	iChangeFinder->ResetL();
+	
+    User::RequestComplete(iCallerStatus, KErrNone);
+    
+    LOGGER_LEAVEFN("CSmsDataStore::DoDeleteAllItemsL");
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoHasSyncHistory
+// This method returns ETrue if Data Store has history information. 
+// Slow-sync will be used if Data Store does not have history information.
+// -----------------------------------------------------------------------------
+TBool CSmsDataStore::DoHasSyncHistory() const
+	{
+	LOGGER_WRITE_1("CSmsDataStore::DoHasSyncHistory return %d", (TInt)iHasHistory );	
+	
+	// iHasHistory is initialized in DoOpenL method
+	return iHasHistory;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoAddedItems
+// This method returns UIDs of added items. Those items are added after previous
+// synchronization with current synchronization relationship. 
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CSmsDataStore::DoAddedItems() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoAddedItems");	
+	
+	// Ensure that we're in a proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoAddedItems, invalid state %d.", iCurrentState);
+		}
+		
+	TInt error(KErrNone);
+
+	// Clear new-items array
+	iNewItems->Reset();
+	
+    // Search for new items
+    TRAP( error, iChangeFinder->FindNewItemsL(*iNewItems) );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("CSmsDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error);
+        }
+	
+	LOGGER_WRITE_1("New item count: %d.", iNewItems->ItemCount());
+	LOGGER_LEAVEFN("CSmsDataStore::DoAddedItems");		
+	
+	return *iNewItems;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoDeletedItems
+//
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CSmsDataStore::DoDeletedItems() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoDeletedItemsL");	
+	
+	// Ensure that we're in a proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+	    {
+	    LOGGER_WRITE_1("CSmsDataStore::DoDeletedItems, invalid state %d.", iCurrentState);
+	    }
+
+	TInt error(KErrNone);
+	
+	// Clear deleted-items array
+	iDeletedItems->Reset();
+	
+    // Search for deleted items
+    TRAP( error, iChangeFinder->FindDeletedItemsL(*iDeletedItems) );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("CSmsDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error);
+        }
+	
+	
+	LOGGER_WRITE_1("Deleted item count: %d.", iDeletedItems->ItemCount());
+	LOGGER_LEAVEFN("CSmsDataStore::DoDeletedItemsL");
+	return *iDeletedItems;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoSoftDeletedItems
+// Not directly supported, equals to "hard" delete
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CSmsDataStore::DoSoftDeletedItems() const
+	{
+	TRACE_FUNC;
+	
+    // Return empty array as a result
+    iSoftDeletedItems->Reset();
+	return *iSoftDeletedItems;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoModifiedItems
+// Finds all modified items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CSmsDataStore::DoModifiedItems() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoModifiedItems");	
+	
+	// Ensure that we're in a proper state
+	if (iCurrentState != ESmsOpenAndWaiting)
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoModifiedItems, invalid state %d.", iCurrentState);
+		}
+
+	TInt error(KErrNone);
+
+	// Clear updated-items array
+	iUpdatedItems->Reset();
+	
+    // Search for updated items
+    TRAP( error, iChangeFinder->FindChangedItemsL(*iUpdatedItems) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("CSmsDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error);
+        }
+    else
+        {
+        TRAP( error, iChangeFinder->FindMovedItemsL(*iUpdatedItems) );
+        if( error != KErrNone )
+            {
+            LOGGER_WRITE_1("CSmsDataStore::DoModifiedItems, iChangeFinder->FindMovedItemsL leaved with %d.", error);
+            }		    
+        }
+	
+	LOGGER_WRITE_1("Modified item count: %d.", iUpdatedItems->ItemCount());
+	LOGGER_LEAVEFN("CSmsDataStore::DoModifiedItems");		
+	return *iUpdatedItems;
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoMovedItems
+// Moved items not supported (handled as replaced items)
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CSmsDataStore::DoMovedItems() const
+	{
+	TRACE_FUNC;	
+	
+	// Clear moved-items array
+	iMovedItems->Reset();
+	
+	return *iMovedItems;	
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoResetChangeInfoL
+// Resets change history in the data store. All content is considered
+// new in the data store point of view.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoResetChangeInfoL(TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoResetChangeInfoL");	
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+    // Check that we're in proper state
+	if (iCurrentState != ESmsOpenAndWaiting) 
+		{
+		LOGGER_WRITE_1("CSmsDataStore::DoResetChangeInfoL, invalid state %d.", iCurrentState);
+		}	
+			
+	// Reset change info in ChangeFinder
+	iChangeFinder->ResetL();
+	iHasHistory = EFalse;
+	
+    // Signal we're done
+    User::RequestComplete(iCallerStatus, KErrNone);	
+    
+    LOGGER_LEAVEFN("CSmsDataStore::DoResetChangeInfoL");
+	}
+		
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCommitChangeInfoL
+// Commits change info. These items are no longer reported, when change
+// information is being queried.
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCommitChangeInfoL(MSmlDataItemUidSet)");	
+	LOGGER_WRITE_1("Item count: %d", aItems.ItemCount());
+	
+	iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if (iCurrentState != ESmsOpenAndWaiting) 
+	    {
+		LOGGER_WRITE_1("CSmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+		}
+
+	// Notify ChangeFinder
+    iChangeFinder->CommitChangesL(aItems);
+    iHasHistory = ETrue;
+	    
+	// Signal we're done
+	User::RequestComplete(iCallerStatus, KErrNone);
+	    
+	LOGGER_LEAVEFN("CSmsDataStore::DoCommitChangeInfoL");
+	}
+		
+	
+// -----------------------------------------------------------------------------
+// CSmsDataStore::DoCommitChangeInfoL
+// Commits change info. There is no more nothing to report when change
+// information is being queried. 
+// -----------------------------------------------------------------------------
+void CSmsDataStore::DoCommitChangeInfoL(TRequestStatus& aStatus)
+	{
+	LOGGER_ENTERFN("CSmsDataStore::DoCommitChangeInfoL");
+	
+	iCallerStatus = &aStatus;
+	*iCallerStatus = KRequestPending;
+	
+	// Ensure that we're in a proper state
+	if (iCurrentState != ESmsOpenAndWaiting) 
+	    {
+		LOGGER_WRITE_1("CSmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+		}
+	
+	// Notify ChangeFinder
+	iChangeFinder->CommitChangesL();
+	iHasHistory = ETrue;
+	    
+	// Signal we're done
+	User::RequestComplete(iCallerStatus, KErrNone);
+	
+	LOGGER_LEAVEFN("CSmsDataStore::DoCommitChangeInfoL");
+	}
+		
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::RegisterSnapshotL
+// Sets Changefinder to compare against current message store content
+// -----------------------------------------------------------------------------
+void CSmsDataStore::RegisterSnapshotL() const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::RegisterSnapshotL");
+	
+    CSnapshotArray* snapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+    CleanupStack::PushL(snapshot);
+	
+	// Use only standard folders (outbox isn't synchronized)
+	LOGGER_WRITE( "KMsvGlobalInBoxIndexEntryId" );
+	RegisterFolderL(snapshot, KMsvGlobalInBoxIndexEntryId);
+	LOGGER_WRITE( "KMsvDraftEntryId" );
+	RegisterFolderL(snapshot, KMsvDraftEntryId);
+	LOGGER_WRITE( "KMsvSentEntryId" );
+	RegisterFolderL(snapshot, KMsvSentEntryId);
+	LOGGER_WRITE( "KMsvGlobalOutBoxIndexEntryId" );
+	RegisterFolderL(snapshot, KMsvGlobalOutBoxIndexEntryId);
+	RegisterUserFoldersL(snapshot);
+	
+	// Set new snapshot to compare against
+	iChangeFinder->SetNewSnapshot(snapshot);
+
+	// Changefinder takes ownership of the snapshot
+	CleanupStack::Pop();
+	
+	LOGGER_LEAVEFN("CSmsDataStore::RegisterSnapshotL");	
+	}
+
+// -----------------------------------------------------------------------------
+// CSmsDataStore::RegisterFolderL
+// Adds a single folder into the snapshot array
+// -----------------------------------------------------------------------------
+TInt CSmsDataStore::RegisterFolderL(CSnapshotArray* aSnapshot, const TMsvId& aId) const
+	{
+	LOGGER_ENTERFN("CSmsDataStore::RegisterFolderL");	
+	
+	CMsvSession* msvSession = iMsvApi->MsvSessionL();
+
+	// Get the folder	
+	CMsvEntry* msvEntry = msvSession->GetEntryL(aId);
+	CleanupStack::PushL(msvEntry);
+	
+	// Find all of it's childs
+	CMsvEntrySelection* messages = msvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
+	CleanupStack::PopAndDestroy(); // msvEntry
+	CleanupStack::PushL(messages);
+	
+    TMsvId id;
+    TMsvEntry msg;
+    LOGGER_WRITE_1( "messages count %d", messages->Count() );
+	for(TInt index=0; index<messages->Count(); index++)
+		{
+		TInt result = msvSession->GetEntry(messages->At(index), id, msg);
+		User::LeaveIfError(result);
+		
+		// We're only interested about the SMS content
+		if(msg.iMtm == KUidMsgTypeSMS)
+			{
+			// Create snapshot item
+			TKeyArrayFix key(iKey);
+			TSnapshotItem item((TUint) msg.Id(), msg.Parent(), msg.Unread());
+			
+			item.SetLastChangedDate(msg.iDate);
+			LOGGER_WRITE_1( "item id %d", msg.Id() );
+			// Add to snapshot
+			aSnapshot->InsertIsqL(item, key);
+			}
+	    else
+	        {
+	        LOGGER_WRITE("Wrong type");
+	        }
+		}
+
+	CleanupStack::PopAndDestroy(); // messages
+	
+    LOGGER_LEAVEFN("CSmsDataStore::RegisterFolderL");	
+
+	return KErrNone;
+	}
+	
+// -----------------------------------------------------------------------------
+// CSmsDataStore::RegisterUserFoldersL
+// Adds user folder messages into the snapshot array
+// -----------------------------------------------------------------------------
+TInt CSmsDataStore::RegisterUserFoldersL(CSnapshotArray* aSnapshot) const
+    {
+ 	LOGGER_ENTERFN("CSmsDataStore::RegisterUserFoldersL");	   
+    
+    CMsvSession* msvSession = iMsvApi->MsvSessionL();
+    
+    // Get the folder	
+	CMsvEntry* msvEntry = msvSession->GetEntryL(KMsvMyFoldersEntryIdValue);
+    CleanupStack::PushL(msvEntry);
+    
+    // Find all of it's childs
+    CMsvEntrySelection* folders = msvEntry->ChildrenWithTypeL( KUidMsvFolderEntry );
+    CleanupStack::PopAndDestroy( msvEntry ); 
+    CleanupStack::PushL( folders );
+    LOGGER_WRITE_1("Folders: %d", folders->Count());
+    for ( TInt index = 0; index < folders->Count(); index++ )
+        {
+        TMsvId folderId = folders->At(index);
+        
+        if ( folderId != KMsvMyFoldersTemplatesFolderId )
+            {
+            TMsvId service;
+            TMsvEntry folderEntry;
+            TInt result = msvSession->GetEntry(folderId, service, folderEntry);
+            User::LeaveIfError( result );
+            
+            TKeyArrayFix key(iKey);
+            TBool unread(EFalse);
+            TSnapshotItem item( (TUint) folderId, folderEntry.Parent(), unread );
+            item.SetLastChangedDate( folderEntry.iDate );
+            item.SetFolderNameL( folderEntry.iDetails );
+            
+            aSnapshot->InsertIsqL( item, key );
+            
+            RegisterFolderL( aSnapshot, folderId );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( folders );
+	
+	// Register also SMS messages directly under My Folders
+    RegisterFolderL( aSnapshot, KMsvMyFoldersEntryIdValue );
+    
+	LOGGER_LEAVEFN("CSmsDataStore::RegisterUserFoldersL");	   
+    
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SmsDataStore.rss	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Resource data for SmsDataProvider
+*
+*/
+
+
+#include "SmlDataFormat.rh"
+#include "SmlDataFormat.hrh"
+
+RESOURCE SML_DATA_STORE_FORMAT SMS_DATA_STORE
+	{
+	version = 1;
+	display_name = "Text messages";
+	sync_types = KSmlSyncType_TwoWay + KSmlSyncType_SlowSync;
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version = 1;
+			mime_type = "text/x-vMessage";
+			mime_ver = "1.0";
+			properties= 
+				{
+				SML_DATA_PROPERTY
+					{
+					version = 1;
+					display_name = "Read";
+					name = "read";
+					data_type = "bool";
+					enum_values = {};
+					flags = 0;
+					max_size = 0;
+					max_occur = 1;
+					params = {};
+					}
+				};
+			field_level = 0;
+			},
+		SML_MIME_FORMAT
+			{
+			version = 1;
+			mime_type = "application/vnd.omads-folder+xml";
+			mime_ver = "1.0";
+			properties= 
+				{
+				SML_DATA_PROPERTY
+					{
+					version = 1;
+					display_name = "Read";
+					name = "read";
+					data_type = "bool";
+					enum_values = {};
+					flags = 0;
+					max_size = 0;
+					max_occur = 1;
+					params = {};
+					}
+				};
+			field_level = 0;
+			}				
+		};
+	mime_format_tx_pref = 0;    	// Preferred index for tx
+	mime_format_rx_pref = 0;	// Preferred index for rx
+	folder_properties = {};		// No folder properties
+	filter_capabilities = {};	// No filter capabilities
+	max_size = 0;				// No limit
+	max_items = 0;	 			// No limit
+	flags = 0x00000010;			// Hierarchical sync supported
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/SnapshotItem.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <msvuids.h>
+#include "SnapshotItem.h"
+
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem() : TNSmlSnapshotItem()
+    {
+    iUnread = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// Constructor, takes item id as a parameter
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
+    const TSmlDbItemUid& aParent, TBool aUnread )
+: TNSmlSnapshotItem( aItemId )
+    {
+    SetParentId( aParent );
+    iUnread = aUnread;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::ExternalizeL
+// Writes the contents of this class and it's base to stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TNSmlSnapshotItem::ExternalizeL( aStream );
+    aStream.WriteInt32L( iUnread );
+    TPckgBuf<TFolderName> nameBuf(iFolderName);
+	aStream << nameBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::InternalizeL
+// Reads the contents of this class and it's base from stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::InternalizeL( RReadStream& aStream )
+    {
+    TNSmlSnapshotItem::InternalizeL( aStream );
+    iUnread = aStream.ReadInt32L();
+    TPckgBuf<TFolderName> nameBuf;
+	aStream >> nameBuf;
+	iFolderName = nameBuf();
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::SetUnread
+// Sets unread flag
+// -----------------------------------------------------------------------------
+void TSnapshotItem::SetUnread( TBool aState )
+    {
+    iUnread = aState;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::Unread
+// Gets unread flag
+// -----------------------------------------------------------------------------
+TBool TSnapshotItem::Unread() const
+    {
+    return iUnread;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::SetFolderNameL
+// Sets folder name
+// ----------------------------------------------------------------------------- 
+void TSnapshotItem::SetFolderNameL( const TDesC& aFolderName )
+    {
+    if ( aFolderName.Length() > KMaxFolderNameLength )
+        {
+        User::Leave( KErrTooBig );
+        }
+    iFolderName.Copy( aFolderName );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::FolderName
+// Gets folder name
+// ----------------------------------------------------------------------------- 
+const TDesC& TSnapshotItem::FolderName() const
+    {
+    return iFolderName;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/VMessageParser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,848 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#include <e32std.h>
+#include <msvids.h>
+#include <txtrich.h>
+#include "VMessageParser.h"
+#include "Logger.h"
+
+
+const TInt KVersionMaxLength = 4;
+const TInt KDateMaxLength = 48;
+const TInt KTagAndValueMaxLength = 48;
+const TInt KDefaultWriteBufSize = 1024;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVMessageParser* CVMessageParser::NewL()
+// -----------------------------------------------------------------------------
+//
+CVMessageParser* CVMessageParser::NewL()
+	{
+	CVMessageParser* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser* CVMessageParser::NewLC()
+// -----------------------------------------------------------------------------
+//
+CVMessageParser* CVMessageParser::NewLC()
+	{
+	CVMessageParser* self = new( ELeave ) CVMessageParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::~CVMessageParser()
+// -----------------------------------------------------------------------------
+//
+CVMessageParser::~CVMessageParser()
+	{
+	iRecipients.Close();
+	delete iMessageBody;
+	iMessageBody = NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::CVMessageParser()
+// -----------------------------------------------------------------------------
+//
+CVMessageParser::CVMessageParser()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::ConstructL()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadMessage()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::ParseMessageL( const TDesC8& aVMessage )
+	{
+	LOGGER_ENTERFN( "CVMessageParser::ParseMessageL" );
+
+	const TUint8* ptr8 = aVMessage.Ptr();	
+	const TUint16* ptr16 = reinterpret_cast<const TUint16*>( ptr8 );
+	iReadBuf.Set( ptr16, aVMessage.Length()/2 );
+	LOG(iReadBuf);	
+	
+	iReadBufPosition = 0;
+
+	TInt err = ReadMessageHeader();
+	
+	if (err < 0)
+		{
+		LOGGER_WRITE_1( "ReadMessageHeader() failed with %d", err );
+		}
+	else
+		{
+		err = ReadMessageBodyL();
+		LOGGER_WRITE_1( "ReadMessageBody() result: %d", err );
+		}
+    LOGGER_LEAVEFN( "CVMessageParser::ParseMessageL" );
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ConstructMessageL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::ConstructMessageL( CBufBase& aVMessage )
+	{
+	LOGGER_ENTERFN( "CVMessageParser::ConstructMessageL" );
+	LOGGER_WRITE_1( "Initial buffer size: %d", aVMessage.Size() );
+
+	iWriteBuf = &aVMessage;
+	iWriteBufPosition = 0,
+	iWriteIndentLevel = 0;
+
+	iWriteBufSize = KDefaultWriteBufSize;
+	if (iMessageBody)
+		{
+		iWriteBufSize += iMessageBody->Size();
+		}
+
+	iWriteBuf->ResizeL( iWriteBufSize );
+	LOGGER_WRITE_1( "Buffer size resized to %d", iWriteBuf->Size() );
+	
+	WriteMessageLineL( KVMsgTagBegin, KVMsgSectionVMsg ); // BEGIN:VMSG
+	WriteMessagePropertiesL();
+	WriteMessageVCARDL( iSender.iName, iSender.iNumber );
+	WriteMessageEnvelopeL();
+	WriteMessageLineL( KVMsgTagEnd, KVMsgSectionVMsg ); // END:VMSG
+
+	iWriteBuf->ResizeL( iWriteBufPosition );
+
+	LOGGER_WRITE_1( "Message length: %d", iWriteBufPosition );
+	LOGGER_LEAVEFN( "CVMessageParser::ConstructMessageL" );
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ResetAll()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::ResetAll()
+	{
+	// Public data 
+
+	iHomeTime = 0;
+	iUniversalTime = 0;
+	iFolder.Zero();
+	iStatus.Zero();
+	iSender.iNumber.Zero();
+	iSender.iName.Zero();
+	iRecipients.Reset();
+	if (iMessageBody)
+		{
+		delete iMessageBody;
+		iMessageBody = NULL;
+		}
+
+
+	// Private variables
+	iReadBufPosition = 0;
+	iWriteBufPosition = 0;
+	iWriteIndentLevel = 0;
+	iWriteBuf = NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::LoadMessageBodyL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::LoadMessageBodyL( CRichText &aMsgBody )
+	{
+	if (iMessageBody)
+		{
+		aMsgBody.InsertL(0, *iMessageBody);
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::StoreMessageBodyL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::StoreMessageBodyL( CRichText &aMsgBody )
+	{
+	if (iMessageBody)
+		{
+		LOGGER_WRITE( "Message body not empty" );
+		User::Leave( KErrGeneral );
+		}
+
+	TInt bodyLenght =  aMsgBody.DocumentLength();
+
+	if (bodyLenght > 0)
+		{
+		iMessageBody = HBufC::NewL( bodyLenght );
+		TPtr16 ptrBody = iMessageBody->Des();
+		aMsgBody.Extract( ptrBody );
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ParseTelephoneNumber()
+// -----------------------------------------------------------------------------
+//
+TBool CVMessageParser::ParseTelephoneNumber( const TDesC &aNumberString, TTelephoneNumber &aNumberStore )
+	{
+	_LIT( KStartMarker, "<" );
+	_LIT( KEndMarker, ">" );
+    LOGGER_WRITE_1("aNumberString: %S", &aNumberString );
+	TInt startMarker = aNumberString.Find( KStartMarker );
+
+	if (startMarker >= 0)
+		{
+		TInt endMarker = aNumberString.Find( KEndMarker );
+		if (endMarker <= (startMarker + 1))
+			{
+			LOGGER_WRITE( "Incorrect number" );
+			return EFalse;
+			}
+		else // case 1: Abc Pqr <+01234567890>
+			{
+			TPtrC16 name = aNumberString.Left( startMarker );
+			TPtrC16 number = aNumberString.Mid( (startMarker + 1), (endMarker - startMarker - 1) ); 
+			AssignDataToBuffer( name, aNumberStore.iName );
+			AssignDataToBuffer( number, aNumberStore.iNumber );
+			}
+		}
+	else // just number
+		{
+		AssignDataToBuffer( aNumberString, aNumberStore.iNumber );
+		aNumberStore.iName.Zero();
+		}
+    LOGGER_WRITE_1("aNumberStore.iName: %S", &aNumberStore.iName);
+
+	return ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadMessageHeader()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::ReadMessageHeader()
+	{
+	LOGGER_WRITE( "CVMessageParser::ReadMessageHeader()" );
+
+	TInt err;
+
+	err = FindMessageTagWithValue( KVMsgTagBegin, KVMsgSectionVMsg );
+	if (err < 0)
+		{
+		return err;
+		}
+		
+	err = ReadTaggedTimeStamp( iUniversalTime );
+	if ( err == KErrNone )
+		{
+		LOGGER_WRITE( "Time stamp tag found, universal time set" );
+		}		
+				
+	err = GetMessageTagValue( KVMsgTagStatus, iStatus );
+	if (err < 0)
+		{
+		return err;
+		}		
+	err = GetMessageTagValue( KVMsgTagBox, iFolder );
+	if (err < 0)
+		{
+		return err;
+		}
+	err = FindMessageTagWithValue( KVMsgTagBegin, KVMsgSectionVCard );
+	if (err < 0)
+		{
+		return err;
+		}
+	err = ReadVCard( iSender );
+	if (err < 0)
+		{
+		return err;
+		}
+	err = FindMessageTagWithValue( KVMsgTagBegin, KVMsgSectionVEnv );
+	if (err < 0)
+		{
+		return err;
+		}
+	else
+		{
+		err = ReadEnvelope();
+		}
+
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadEnvelope()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::ReadEnvelope()
+	{
+	TBuf<KTagAndValueMaxLength> tagValue;
+	TInt err( KErrNone );
+
+	err = GetMessageTagValue( KVMsgTagBegin, tagValue );
+	if (err < 0)
+		{
+		return err;
+		}
+	else if (tagValue.Compare( KVMsgSectionVCard ) == 0)
+		{
+		TTelephoneNumber recipient;
+		err = ReadVCard( recipient );
+		if (err < 0)
+			{
+			return err;
+			}
+		else
+			{
+			if (recipient.iNumber.Length() > 0)
+			    {
+			    iRecipients.Append( recipient );
+			    }
+			    
+			err = FindMessageTagWithValue( KVMsgTagBegin, KVMsgSectionVEnv );
+			if (err >= 0)
+				{
+				err = ReadEnvelope();
+				}
+			}
+		}
+	else if (tagValue.Compare( KVMsgSectionVBody ) == 0)
+		{
+		err = KErrNone;
+		}
+	else
+		{
+		LOGGER_WRITE( "Unexpected message tag value" );
+		return KErrGeneral;
+		}
+
+	return err;
+	}
+	
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadTaggedTimestamp()
+// Read and parse tagged timestamp from vMessage (optional feature)
+// Format: X-NOK-DT:yyyymmddThhmmssZ (example: X-NOK-DT:20060329T091530Z)
+// -----------------------------------------------------------------------------
+//	
+TInt CVMessageParser::ReadTaggedTimeStamp( TTime& aUniversalTime )
+	{
+	LOGGER_WRITE( "CVMessageParser::ReadTaggedTimestamp" );	
+	
+	TInt err( KErrNone );
+	TBuf<20> timeStamp;
+	
+	err = GetMessageTagValue( KVMsgTagDateTime, timeStamp, EFalse );
+	if ( err < 0 )
+		{
+		return KErrNotFound;
+		}
+	
+	LOG( timeStamp );
+	
+	if (timeStamp.Length() != 16 || timeStamp[8] != 'T' || timeStamp[15] != 'Z')
+		{
+		return KErrNotSupported;
+		}
+
+	TLex lexYear( timeStamp.Mid( 0, 4 ) );
+	TLex lexMonth( timeStamp.Mid( 4, 2 ) );
+	TLex lexDay( timeStamp.Mid( 6, 2 ) );
+	TLex lexHour( timeStamp.Mid( 9, 2 ) );
+	TLex lexMinute( timeStamp.Mid( 11, 2 ) );
+	TLex lexSecond( timeStamp.Mid( 13, 2 ) );		
+	
+	TInt valYear( 0 );
+	TInt valMonth( 0 );
+	TInt valDay( 0 );
+	TInt valHour( 0 );
+	TInt valMinute( 0 );
+	TInt valSecond( 0 );
+
+	TBool parseDone( EFalse );		
+	if ( lexYear.Val( valYear ) == KErrNone )
+		{
+		if ( lexMonth.Val( valMonth ) == KErrNone )
+			{
+			if ( lexDay.Val( valDay ) == KErrNone )
+				{
+				if ( lexHour.Val( valHour ) == KErrNone )
+					{
+					if ( lexMinute.Val( valMinute ) == KErrNone )
+						{
+						if ( lexSecond.Val( valSecond ) == KErrNone )
+							{
+							parseDone = ETrue;
+							}
+						}
+					}
+				}
+			}		
+		}
+	if ( !parseDone )
+		{
+		return KErrNotSupported;
+		}
+		
+	TDateTime dateTime;
+	TMonth month = static_cast<TMonth>(--valMonth);
+	err = dateTime.Set( valYear, month, --valDay, valHour, valMinute, valSecond, 0 );	
+	if ( err != KErrNone )
+		{
+		return KErrNotSupported;
+		}
+		
+	aUniversalTime = dateTime;	
+	
+	return KErrNone; 	
+	}		
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadVCard()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::ReadVCard( TTelephoneNumber &aResult )
+	{		
+	TInt err = KErrNone;
+	TBuf<KVersionMaxLength> version;
+
+	err = GetMessageTagValue( KVMsgTagVersion, version );
+	if (err < 0)
+		{
+		return err;
+		}
+
+	err = GetMessageTagValue( KVMsgTagName, aResult.iName );
+	if (err < 0)
+		{
+		return err;
+		}
+
+	err = GetMessageTagValue( KVMsgTagTelephone, aResult.iNumber );
+	if (err < 0)
+		{
+		return err;
+		}
+
+	err = FindMessageTagWithValue( KVMsgTagEnd, KVMsgSectionVCard );
+	if (err < 0)
+		{
+		return err;
+		}
+
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::ReadMessageBody()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::ReadMessageBodyL()
+	{
+	LOGGER_WRITE( "CVMessageParser::ReadMessageBody()" );
+
+	TInt err;
+	
+	TPtrC pBuf = iReadBuf.Mid( iReadBufPosition );
+	err = pBuf.Find( KVMsgLineFeed );
+	if (err < 0)
+		{
+		return err;
+		}
+	
+	iReadBufPosition += ( err + KVMsgLineFeed().Length() );
+	TInt bodyStart = iReadBufPosition;
+
+	TBuf<KDateMaxLength> dateBuf;
+	err = GetMessageTagValue(KVMsgTagDate, dateBuf);
+	if (err < 0)
+		{
+		LOGGER_WRITE( "No date field in message body" );
+		iReadBufPosition = bodyStart;
+		}
+	else
+		{
+		for (TInt i = 0; i < dateBuf.Length(); i++)
+			{
+			// This is needed, because TTime::Parse() can not handle
+			// situation where '.' character is used as a delimiter in date.
+			// Expected date format is like 18.1.2005 17:32:50.
+			//
+			if (dateBuf[i] == ' ')
+				{
+				break;
+				}
+			else if (dateBuf[i] == '.')
+				{
+				dateBuf[i] = '/';
+				}
+			}
+		
+        TLocale locale;
+        TDateFormat originalFormat = locale.DateFormat();
+        locale.SetDateFormat( EDateEuropean );
+        locale.Set(); // transfer the new locale settings to the system
+        
+		err = iHomeTime.Parse( dateBuf );
+		if ( err < 0 )
+			{
+			LOGGER_WRITE_1( "Parsing date from message body failed with %d", err );
+			iHomeTime = 0;
+			}
+		locale.SetDateFormat( originalFormat );
+		locale.Set(); // transfer the original locale settings back to the system
+
+		TPtrC pDateStart = iReadBuf.Mid( iReadBufPosition );
+		err = pDateStart.Find( KVMsgLineFeed );
+		if (err < 0)
+			{
+			return err;
+			}
+		iReadBufPosition += ( err + KVMsgLineFeed().Length() );
+		bodyStart = iReadBufPosition;
+		}
+
+	err = FindMessageTagWithValue( KVMsgTagEnd, KVMsgSectionVBody );
+	if (err < 0)
+		{
+		return err;
+		}
+	else
+		{
+		TInt bodyLength = err - bodyStart;
+		iMessageBody = HBufC::NewL( bodyLength );
+		TPtrC pData = iReadBuf.Mid( bodyStart, bodyLength );
+		TPtr pMsgBody = iMessageBody->Des();
+		pMsgBody.Copy( pData );
+		pMsgBody.Trim();
+		err = pMsgBody.Length();
+		LOG( pMsgBody );
+		}
+
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::FindMessageTagWithValue()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::FindMessageTagWithValue( const TDesC& aMsgTag, const TDesC& aValue )
+	{
+	TBuf<KTagAndValueMaxLength> tagAndValue( aMsgTag );
+	tagAndValue.Append( aValue );
+
+	TPtrC pBuf = iReadBuf.Mid( iReadBufPosition );
+
+	TInt err;
+	TInt tagStartPosition;
+		
+	err = pBuf.Find( tagAndValue );
+	if (err < 0)
+		{
+		LOGGER_WRITE( "Message tag with value not found" );
+		return err;
+		}
+	else 
+		{
+		tagStartPosition = iReadBufPosition + err; // position before tag and value
+		iReadBufPosition += ( err + tagAndValue.Length() ); // position after tag and value
+		}
+
+	return tagStartPosition; 
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::GetMessageTagValue()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::GetMessageTagValue( const TDesC& aMsgTag, TDes& aValue, TBool aMoveReadBufPosition )
+	{
+	TInt err;
+	TInt valueLength;
+	TInt readBufPosition( iReadBufPosition );
+
+	TPtrC pBuf = iReadBuf.Mid( readBufPosition );
+	
+	err = pBuf.Find( aMsgTag );
+	if (err < 0)
+		{	
+		LOGGER_WRITE( "Message tag not found" );
+		return err; 
+		}
+	else
+		{
+		readBufPosition += (err + aMsgTag.Length());
+		}
+
+	TPtrC pValueStart = iReadBuf.Mid( readBufPosition ); 
+
+	err = pValueStart.Find( KVMsgLineFeed );
+	if (err < 0)
+		{
+		return err; 
+		}
+	else
+		{
+		valueLength = err;
+		}
+
+	StoreMessageDataField( readBufPosition, valueLength, aValue );
+	
+	if ( aMoveReadBufPosition )
+		{
+		iReadBufPosition = readBufPosition;
+		}
+
+	return valueLength;
+	}
+	
+// -----------------------------------------------------------------------------
+// CVMessageParser::StoreMessageDataField()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::StoreMessageDataField(TInt aStart, TInt aLength, TDes &aLocalStore)
+	{
+	TInt copyLength;
+
+	copyLength = aLength > aLocalStore.MaxLength() ? aLocalStore.MaxLength() : aLength;
+
+	TPtrC pData = iReadBuf.Mid( aStart, copyLength );
+	aLocalStore.Copy( pData );
+	aLocalStore.Trim();
+
+	if (copyLength < aLength)
+		{
+		LOGGER_WRITE_2( "Data length: %d, stored: %d", aLength, copyLength );	
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteMessagePropertiesL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteMessagePropertiesL()
+	{
+	LOGGER_WRITE( "CVMessageParser::WriteMessagePropertiesL()" );
+	WriteMessageLineL( KVMsgTagVersion, KVMsgVersion );
+	WriteMessageLineL( KVMsgTagStatus, iStatus );
+	WriteMessageLineL( KVMsgTagBox, iFolder );
+	WriteTaggedTimestampL( iUniversalTime );
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteMessageVCARDL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteMessageVCARDL(const TDesC& aName, const TDesC& aNumber)
+	{
+	LOGGER_WRITE( "CVMessageParser::WriteMessageVCARDL()" );
+	WriteMessageLineL( KVMsgTagBegin, KVMsgSectionVCard );
+	WriteMessageLineL( KVMsgTagVersion, KVMsgVCardVersion );
+	WriteMessageLineL( KVMsgTagName, aName );
+	WriteMessageLineL( KVMsgTagTelephone, aNumber );
+	WriteMessageLineL( KVMsgTagEnd, KVMsgSectionVCard );
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteMessageEnvelopeL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteMessageEnvelopeL()
+	{
+	LOGGER_WRITE( "CVMessageParser::WriteMessageEnvelopeL()" );
+
+	TInt i;
+	TInt numRecipients = iRecipients.Count();
+
+	for (i = 0; i < numRecipients; i++)
+		{
+		WriteMessageLineL( KVMsgTagBegin, KVMsgSectionVEnv );
+		WriteMessageVCARDL( iRecipients[i].iName, iRecipients[i].iNumber );		
+		}
+
+	WriteMessageLineL( KVMsgTagBegin, KVMsgSectionVEnv );
+	WriteMessageBodyL();
+	WriteMessageLineL( KVMsgTagEnd, KVMsgSectionVEnv );
+
+	for (i = 0; i < numRecipients; i++)
+		{
+		WriteMessageLineL( KVMsgTagEnd, KVMsgSectionVEnv );	
+		}	
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteTaggedTimestampL()
+// -----------------------------------------------------------------------------
+//	
+void CVMessageParser::WriteTaggedTimestampL( TTime aUniversalTime )
+	{
+	LOGGER_WRITE( "CVMessageParser::WriteTaggedTimestamp()" );
+	
+	TDateTime dateTime = aUniversalTime.DateTime();
+	
+	TBuf<16> timestamp;
+	
+	// Default timesamp format: yyyymmddThhmmssZ - like 20060329T091530Z	
+	_LIT( KTimestampFormat, "%+04d%+02d%+02dT%+02d%+02d%+02dZ" );
+	timestamp.Format( KTimestampFormat, 
+		dateTime.Year(),
+		dateTime.Month() + 1,
+		dateTime.Day() + 1,
+		dateTime.Hour(),
+		dateTime.Minute(),
+		dateTime.Second() );
+		
+	WriteMessageLineL( KVMsgTagDateTime, timestamp );	
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteMessageBodyL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteMessageBodyL()
+	{
+	LOGGER_WRITE( "CVMessageParser::WriteMessageBodyL()" );
+
+	WriteMessageLineL( KVMsgTagBegin, KVMsgSectionVBody );
+
+    // "Date" field is always device local time, not UTC
+	TBuf<KDateMaxLength> dateStr;
+	_LIT( KDateFormat, "%F%*D.%*M.%Y% %H:%T:%S" );
+	iHomeTime.FormatL( dateStr, KDateFormat );
+	WriteMessageLineL(KVMsgTagDate, dateStr );
+
+	if (iMessageBody)
+		{
+		LOG(*iMessageBody);
+		WriteMessageLineL( KDesNoData, *iMessageBody, EFalse );
+		}
+	else
+		{
+		LOGGER_WRITE( "Message body empty" );
+		}
+
+	WriteMessageLineL( KVMsgTagEnd, KVMsgSectionVBody );
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteMessageLineL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteMessageLineL( const TDesC& aMsgLineTag, const TDesC& aMsgLineData, TBool aIndent )
+	{
+	if (aIndent)
+		{
+		TInt indent = GetIndentLevel( aMsgLineTag );
+		TBuf<KTagAndValueMaxLength> indentSpace;
+		indentSpace.AppendFill( TChar(' '), indent );
+		WriteToMessageL( indentSpace );
+		}
+
+	if (aMsgLineTag.Length() > 0)
+		{
+		WriteToMessageL( aMsgLineTag );
+		}
+
+	WriteToMessageL( aMsgLineData );	
+	WriteToMessageL( KVMsgLineFeed );
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::WriteToMessageL()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::WriteToMessageL( const TDesC &aData )
+	{
+	TPtrC8 writeData;
+
+	const TUint16* ptr16 = aData.Ptr();
+	const TUint8* ptr8 = reinterpret_cast<const TUint8*>(ptr16);
+	writeData.Set( ptr8, aData.Length()*2 );
+
+	TInt newPosition = iWriteBufPosition + writeData.Length();
+
+	if (newPosition > iWriteBufSize)
+		{
+		LOGGER_WRITE( "Expand write buffer" );
+		TInt expandStep = newPosition - iWriteBufSize + 100;
+		iWriteBuf->ExpandL( iWriteBufSize, expandStep );
+		iWriteBufSize += expandStep;
+		LOGGER_WRITE_1( "Write buffer expanded to %d bytes", iWriteBufSize );
+		}
+
+	iWriteBuf->Write( iWriteBufPosition, writeData );
+	iWriteBufPosition = newPosition;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::GetIndentLevel()
+// -----------------------------------------------------------------------------
+//
+TInt CVMessageParser::GetIndentLevel( const TDesC& aMsgLineTag )
+	{
+	if (aMsgLineTag.Compare( KVMsgTagEnd ) == 0)
+		{
+		iWriteIndentLevel--;
+		}
+	TInt result = iWriteIndentLevel * KIndentStepSize;
+
+	if (aMsgLineTag.Compare( KVMsgTagBegin ) == 0)
+		{
+		iWriteIndentLevel++;
+		}
+	return result;
+	}
+
+// -----------------------------------------------------------------------------
+// CVMessageParser::AssignDataToBuffer()
+// -----------------------------------------------------------------------------
+//
+void CVMessageParser::AssignDataToBuffer( const TDesC &aData, TDes &aBuffer )
+	{
+	aBuffer.Zero();
+
+	if (aBuffer.MaxLength() >= aData.Length())
+		{
+		aBuffer = aData;
+		}
+	else
+		{
+		LOGGER_WRITE_1( "AssignDataToBuffer: too short buffer for data: %d", aBuffer.MaxLength() );
+		LOG( aData );
+		aBuffer = aData.Left( aBuffer.MaxLength() );
+		}
+	}
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  build info file for DS datamod
+*
+*/
+
+
+PRJ_MMPFILES
+./nsmldatamod.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/bld/def/bwinscwdatamodu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	??0CNSmlVCalMod@@QAE@XZ @ 1 NONAME ; CNSmlVCalMod::CNSmlVCalMod(void)
+	??0CNSmlVCardMod@@QAE@XZ @ 2 NONAME ; CNSmlVCardMod::CNSmlVCardMod(void)
+	??1CNSmlDataModBase@@UAE@XZ @ 3 NONAME ; CNSmlDataModBase::~CNSmlDataModBase(void)
+	?MergeRxL@CNSmlDataModBase@@QAEXAAVCBufBase@@0H@Z @ 4 NONAME ; void CNSmlDataModBase::MergeRxL(class CBufBase &, class CBufBase &, int)
+	?NeedsMerge@CNSmlDataModBase@@QAEHXZ @ 5 NONAME ; int CNSmlDataModBase::NeedsMerge(void)
+	?SetOwnStoreFormat@CNSmlDataModBase@@QAEXAAVCSmlDataStoreFormat@@@Z @ 6 NONAME ; void CNSmlDataModBase::SetOwnStoreFormat(class CSmlDataStoreFormat &)
+	?SetPartnerStoreFormat@CNSmlDataModBase@@QAEXAAVCSmlDataStoreFormat@@@Z @ 7 NONAME ; void CNSmlDataModBase::SetPartnerStoreFormat(class CSmlDataStoreFormat &)
+	?SetUsedMimeType@CNSmlDataModBase@@QAEHVRStringF@@0@Z @ 8 NONAME ; int CNSmlDataModBase::SetUsedMimeType(class RStringF, class RStringF)
+	?StripTxL@CNSmlDataModBase@@QAEXAAVCBufBase@@@Z @ 9 NONAME ; void CNSmlDataModBase::StripTxL(class CBufBase &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/bld/def/eabidatamodu.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,21 @@
+EXPORTS
+	_ZN12CNSmlVCalModC1Ev @ 1 NONAME
+	_ZN12CNSmlVCalModC2Ev @ 2 NONAME
+	_ZN13CNSmlVCardModC1Ev @ 3 NONAME
+	_ZN13CNSmlVCardModC2Ev @ 4 NONAME
+	_ZN16CNSmlDataModBase10NeedsMergeEv @ 5 NONAME
+	_ZN16CNSmlDataModBase15SetUsedMimeTypeE8RStringFS0_ @ 6 NONAME
+	_ZN16CNSmlDataModBase17SetOwnStoreFormatER19CSmlDataStoreFormat @ 7 NONAME
+	_ZN16CNSmlDataModBase21SetPartnerStoreFormatER19CSmlDataStoreFormat @ 8 NONAME
+	_ZN16CNSmlDataModBase8MergeRxLER8CBufBaseS1_i @ 9 NONAME
+	_ZN16CNSmlDataModBase8StripTxLER8CBufBase @ 10 NONAME
+	_ZN16CNSmlDataModBaseD0Ev @ 11 NONAME
+	_ZN16CNSmlDataModBaseD1Ev @ 12 NONAME
+	_ZN16CNSmlDataModBaseD2Ev @ 13 NONAME
+	_ZTI12CNSmlVCalMod @ 14 NONAME ; #<TI>#
+	_ZTI13CNSmlVCardMod @ 15 NONAME ; #<TI>#
+	_ZTI16CNSmlDataModBase @ 16 NONAME ; #<TI>#
+	_ZTV12CNSmlVCalMod @ 17 NONAME ; #<VT>#
+	_ZTV13CNSmlVCardMod @ 18 NONAME ; #<VT>#
+	_ZTV16CNSmlDataModBase @ 19 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/bld/nsmldatamod.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  mmp file for DS Data Modification
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include 		"defaultcaps.hrh"
+
+TARGET          nsmldatamod.dll
+TARGETTYPE      DLL
+UID             0x1000008d 0x101F6DE4
+CAPABILITY 		CAP_GENERAL_DLL
+VENDORID		VID_DEFAULT
+
+#if defined(ARMCC)
+DEFFILE			./def/eabidatamod
+#elif defined(WINSCW)
+DEFFILE			./def/bwinscwdatamod
+#endif
+
+APP_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE		../inc
+
+SOURCEPATH      ../src
+SOURCE          nsmldatamodbase.cpp
+SOURCE          NSmlProperty.cpp
+SOURCE          NSmlVCalMod.cpp
+SOURCE          NSmlVCardMod.cpp
+
+LIBRARY         euser.lib 
+LIBRARY			versit.lib 
+LIBRARY			estor.lib 
+LIBRARY			vcal.lib 
+LIBRARY			vcard.lib
+LIBRARY			bafl.lib
+LIBRARY			smlstoreformat.lib
+LIBRARY			nsmldebug.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/inc/NSmlDataModBase.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Stripper and merger base class for versit data and 
+*				 implementation for vCard and vCalendar stripping and merging.
+*
+*/
+
+
+#ifndef __NSMLDATABASE_H__
+#define __NSMLDATABASE_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <vprop.h>
+#include <SmlDataFormat.h>
+
+
+// CLASS DECLARATION
+
+/**
+* Class that is inherited from CParserProperty to make it possible to handle parameters.
+*
+* @lib nsmldatamod.lib
+*/
+class CNSmlProperty : public CParserProperty
+	{
+	public:
+		/**
+	    * Creates new property based on given parameters.
+	    * @param aPropertyValue. 	Value of property.
+	    * @param aName. 			Name of property.
+	    * @param aArrayOfParams. 	Parameters of property.
+	    * @return 					New instance of this class.
+	    */
+		static CNSmlProperty* NewL( CParserPropertyValue& aPropertyValue, const TDesC8& aName, CArrayPtr<CParserParam>* aArrayOfParams );
+		
+		/**
+	    * Returns paramaters of property.
+	    * @return	Parameters of property.
+	    */
+		CArrayPtr<CParserParam>* Parameters() const;
+		
+		/**
+	    * Returns count of paramaters.
+	    * @return	Count of paramaters.
+	    */
+		TInt ParamCount() const;
+		
+		/**
+	    * Compares names of two properties
+	    * @param aFirst. 	First property to compare.
+	    * @param aSecond. 	Second property to compare.
+	    * @return 			Returns 0 if names are equal.
+	    */
+		static TInt Compare( const CNSmlProperty& aFirst, const CNSmlProperty& aSecond );
+		
+	protected:
+		/**
+	    * Basic constructor of class
+	    */
+		CNSmlProperty( CParserPropertyValue& aPropertyValue, CArrayPtr<CParserParam>* aArrayOfParams );
+	};
+
+/**
+* Base class for Calendar and Contacts Data Modifications.
+*
+* @lib nsmldatamod.lib
+*/
+class CNSmlDataModBase : public CBase
+	{
+	public:
+	    /**
+	    * C++ destructor.
+	    */
+		IMPORT_C virtual ~CNSmlDataModBase();
+		
+		/**
+	    * Sets own database format.
+	    * @param aOwnStoreFormat.	Own database format.
+	    */
+		IMPORT_C void SetOwnStoreFormat( CSmlDataStoreFormat& aOwnStoreFormat );
+
+		/**
+	    * Sets remote database format.
+	    * @param aRemoteStoreFormat.	Remote database format.
+	    */
+		IMPORT_C void SetPartnerStoreFormat( CSmlDataStoreFormat& aRemoteStoreFormat );
+
+		/**
+	    * Sets mime type that is used for sending and receiving.
+	    * This method can be called separately before every item.
+	    * @param aMimeType.		Mime type.
+	    * @param aMimeVersion.	Mime type version.
+	    * @return				KErrNone if partnerStoreFormat is passed and same mime type with same version
+	    *						can be found. Otherwise KErrNotFound is returned.
+	    */
+		IMPORT_C TInt SetUsedMimeType( const RStringF aMimeType, const RStringF aMimeVersion );
+		
+		/**
+	    * Strips data that is to be transmitted to the sync partner.
+	    * @param aItem	Item's data. On returns this data may have changed due to stripping.
+	    */
+		IMPORT_C void StripTxL( CBufBase& aItem );
+
+		/**
+	    * Merges received item with item in exported from the local database.
+	    * @param aNewItem 	Received item. On return aItem contains merged item.
+		* @param aOldItem 	Item exported from the local database with which aNewItem is merged.
+	    */
+		IMPORT_C void MergeRxL( CBufBase& aNewItem, CBufBase& aOldItem, TBool aFieldLevel = EFalse );
+
+		/**
+	    * Checks whether merging is needed or not.
+		* @return	ETrue if mergins is needed EFalse otherwise.
+	    */
+		IMPORT_C TBool NeedsMerge();
+
+	protected:
+		/**
+	    * Basic constructor of class.
+	    */
+		CNSmlDataModBase();
+		
+		/**
+	    * Creates correct type of parser for each Data Modifications.
+		* @return	Correct type of versit parser.
+	    */
+		virtual CVersitParser* ChildCreateParserLC() = 0;
+
+		/**
+	    * Strips data that is to be transmitted to the sync partner.
+	    * @param aItem	Item's data. On returns this data may have changed due to stripping.
+	    */
+		void StripL( TDes8& aItem );
+		
+		/**
+	    * Strips data that is to be transmitted to the sync partner from entity.
+	    * @param aEntity	Item's data. On returns this data may have changed due to stripping.
+	    * @param aModified	If item's data is modified then this is ETrue at return. Otherwise EFalse.
+	    */
+		void StripEntityL( CVersitParser* aEntity, TBool& aModified ) const;
+		
+		/**
+	    * Strips all data from entity that is supported by remote server.
+	    * @param aEntity			Item's data. On returns this data may have changed due to stripping.
+	    * @param aModified			If item's data is modified then this is ETrue at return. Otherwise EFalse.
+	    * @param aParamLevelCheck	This is used to decide if parameters are compared when properties are stripped or not.
+	    */
+		void StripAllOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck = ETrue ) const;
+		
+		/**
+	    * Strips all data from entity that is not supported by remote server.
+	    * @param aEntity			Item's data. On returns this data may have changed due to stripping.
+	    * @param aModified			If item's data is modified then this is ETrue at return. Otherwise EFalse.
+	    * @param aParamLevelCheck	This is used to decide if parameters are compared when properties are stripped or not.
+	    */
+		void StripAllNotOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck = ETrue ) const;
+		
+		/**
+	    * Merges data from old item to new item.
+	    * @param aNewItem		Data of receive item. On returns this data may have changed due to merging.
+	    * @param aOldData		Data of old item.
+	    * @param aFieldLevel	This is used to decide if operation is field level update or not. Are all supported
+	    *						properties updated or just received properties.
+	    */
+		void MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel );
+		
+		/**
+	    * Merges data from old entity to new entity.
+	    * @param aNewEntity		Data of receive entity. On returns this data may have changed due to merging.
+	    * @param aOldEntity		Data of old entity.
+	    * @param aModified		If aNewEntity is modified then this is ETrue at return. Otherwise EFalse.
+	    * @param aFieldLevel	This is used to decide if operation is field level update or not. Are all supported
+	    *						properties updated or just received properties.
+	    */
+		void MergeEntityL( CVersitParser* aNewEntity, CVersitParser* aOldEntity, TBool& aModified, TBool aFieldLevel ) const;
+
+	private:
+		CSmlDataStoreFormat* iOwnStoreFormat;
+		CSmlDataStoreFormat* iRemoteStoreFormat;
+		TInt iUsedOwnMimeType;
+		TInt iUsedRemoteMimeType;
+		RStringF iMimeType;
+		RStringF iMimeVersion;
+	};
+
+
+/**
+* Data Modifications for Calendar.
+*
+* @lib nsmldatamod.lib
+*/
+class CNSmlVCalMod : public CNSmlDataModBase
+	{
+	public:
+		/**
+	    * Constuctor
+	    */
+		IMPORT_C CNSmlVCalMod();
+		
+	protected:
+		/**
+	    * Creates correct type of parser for Calendar Data Modifications.
+		* @return	Correct type of versit parser.
+	    */
+		CVersitParser* ChildCreateParserLC();
+	};
+
+/**
+* Data Modifications for Contacts.
+*
+* @lib nsmldatamod.lib
+*/
+class CNSmlVCardMod : public CNSmlDataModBase
+	{
+	public:
+		/**
+	    * Constuctor
+	    */
+		IMPORT_C CNSmlVCardMod();
+		
+	protected:
+		/**
+	    * Creates correct type of parser for Contacts Data Modifications.
+		* @return	Correct type of versit parser.
+	    */
+		CVersitParser* ChildCreateParserLC();
+	};
+
+
+#endif // __NSMLDATABASE_H__
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/src/NSmlProperty.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Property class
+*
+*/
+
+
+
+// INCLUDES
+#include "NSmlDataModBase.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlProperty::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlProperty* CNSmlProperty::NewL( CParserPropertyValue& aPropertyValue, const TDesC8& aName, CArrayPtr<CParserParam>* aArrayOfParams )
+	{
+	CNSmlProperty* self = new ( ELeave ) CNSmlProperty( aPropertyValue, aArrayOfParams );
+	CleanupStack::PushL( self );
+	ConstructSelfL( *self, aName );
+	CleanupStack::Pop(); // self
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlProperty::Parameters
+// -----------------------------------------------------------------------------
+//
+CArrayPtr<CParserParam>* CNSmlProperty::Parameters() const
+	{
+	return iArrayOfParams;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlProperty::ParamCount
+// -----------------------------------------------------------------------------
+//
+TInt CNSmlProperty::ParamCount() const
+	{
+	if ( iArrayOfParams )
+		{
+		return iArrayOfParams->Count();
+		}
+	return 0;
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlProperty::Compare
+// -----------------------------------------------------------------------------
+//
+TInt CNSmlProperty::Compare( const CNSmlProperty& aFirst, const CNSmlProperty& aSecond )
+	{
+	return aFirst.Name().Compare( aSecond.Name() );
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlProperty::CNSmlProperty
+// -----------------------------------------------------------------------------
+//
+CNSmlProperty::CNSmlProperty( CParserPropertyValue& aPropertyValue, CArrayPtr<CParserParam>* aArrayOfParams ) : CParserProperty(aPropertyValue, aArrayOfParams)
+	{
+	}
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/src/NSmlVCalMod.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Versit data stripper and merger for calendar.
+*
+*/
+
+
+
+// INCLUDES
+#include "NSmlDataModBase.h"
+#include <vcal.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlVCalMod::CNSmlVCalMod
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlVCalMod::CNSmlVCalMod() : CNSmlDataModBase()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlVCalMod::ChildCreateParserLC
+// Creates correct type of parser for Calendar Data Modifications.
+// -----------------------------------------------------------------------------
+//
+CVersitParser* CNSmlVCalMod::ChildCreateParserLC()
+	{
+	CVersitParser* p = CParserVCal::NewL();
+	CleanupStack::PushL( p );
+	return p;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/src/NSmlVCardMod.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Versit data stripper and merger for contacts.
+*
+*/
+
+
+
+// INCLUDES
+#include "NSmlDataModBase.h"
+#include <vcard.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlVCardMod::CNSmlVCardMod
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlVCardMod::CNSmlVCardMod() : CNSmlDataModBase()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlVCardMod::ChildCreateParserLC
+// Creates correct type of parser for Contacts Data Modifications.
+// -----------------------------------------------------------------------------
+//
+CVersitParser* CNSmlVCardMod::ChildCreateParserLC()
+	{
+	CVersitParser* p = CParserVCard::NewL();
+	CleanupStack::PushL( p );
+	return p;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/datamod/src/nsmldatamodbase.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,724 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or 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:  Versit data stripper and merger.
+*
+*/
+
+
+// INCLUDES
+#include "NSmlDataModBase.h"
+#include "nsmldebug.h"
+#include "nsmlconstants.h"
+
+#include <versit.h>
+#include <vcal.h>
+#include <vcard.h>
+#include <s32mem.h>
+#include <stringpool.h>
+#include <vtoken.h>
+#include <e32property.h>
+#include <DataSyncInternalPSKeys.h>
+
+//Fix to Remove the Bad Compiler Warnings
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::~CNSmlDataModBase
+// Destructor.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C CNSmlDataModBase::~CNSmlDataModBase()
+	{
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::SetOwnStoreFormat
+// Sets own database format.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C void CNSmlDataModBase::SetOwnStoreFormat( CSmlDataStoreFormat& aOwnStoreFormat )
+	{
+	_DBG_FILE("CNSmlDataModBase::SetOwnStoreFormat(): begin");
+	iOwnStoreFormat = &aOwnStoreFormat;
+	_DBG_FILE("CNSmlDataModBase::SetOwnStoreFormat(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::SetPartnerStoreFormat
+// Sets remote database format.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C void CNSmlDataModBase::SetPartnerStoreFormat( CSmlDataStoreFormat& aRemoteStoreFormat )
+	{
+	_DBG_FILE("CNSmlDataModBase::SetPartnerStoreFormat(): begin");
+	iRemoteStoreFormat = &aRemoteStoreFormat;
+	_DBG_FILE("CNSmlDataModBase::SetPartnerStoreFormat(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::SetUsedMimeType
+// Sets mime type that is used for sending and receiving. 
+// This method can be called separately before every item.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C TInt CNSmlDataModBase::SetUsedMimeType( const RStringF aMimeType, const RStringF aMimeVersion )
+	{
+	_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL(): begin");
+	iUsedRemoteMimeType = -1;
+	if ( !iRemoteStoreFormat )
+		{
+		_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end");
+		return KErrNotFound;
+		}
+	else
+		{
+		for ( TInt i = 0; i < iRemoteStoreFormat->MimeFormatCount(); i++ )
+			{
+			if ( iRemoteStoreFormat->MimeFormat( i ).MimeType().DesC().Compare( aMimeType.DesC() ) == 0 )
+				{
+				if ( iRemoteStoreFormat->MimeFormat( i ).MimeVersion().DesC().Compare( aMimeVersion.DesC() ) == 0 )
+					{
+					iUsedRemoteMimeType = i;
+					iMimeType = iRemoteStoreFormat->MimeFormat( i ).MimeType();
+					iMimeVersion = iRemoteStoreFormat->MimeFormat( i ).MimeVersion();
+					_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Found: end");
+					return KErrNone;
+					}
+				}
+			}
+		}
+	_DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end");
+	return KErrNotFound;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::StripTxL
+// Strips data that is to be transmitted to the sync partner.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C void CNSmlDataModBase::StripTxL( CBufBase& aItem )
+	{
+	_DBG_FILE("CNSmlDataModBase::StripTxL(): begin");
+	HBufC8* buf = HBufC8::NewLC(aItem.Size() * 2);
+	*buf = aItem.Ptr(0);
+	TPtr8 ptrBuf = buf->Des();
+
+	StripL(ptrBuf);
+
+	aItem.Reset();
+	aItem.InsertL(0, ptrBuf);
+	CleanupStack::PopAndDestroy(); // buf
+	_DBG_FILE("CNSmlDataModBase::StripTxL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::MergeRxL
+// Merges received item with item in exported from the local database.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C void CNSmlDataModBase::MergeRxL( CBufBase& aNewItem, CBufBase& aOldItem, TBool aFieldLevel )
+	{
+	_DBG_FILE("CNSmlDataModBase::MergeRxL(): begin");
+	if( NeedsMerge() )
+		{
+		HBufC8* b1 = HBufC8::NewLC(aNewItem.Size() + aOldItem.Size());
+		*b1 = aNewItem.Ptr(0);
+		TPtr8 ptrB1 = b1->Des();
+		TPtr8 p2 = aOldItem.Ptr(0);
+
+		MergeL( ptrB1, p2, aFieldLevel );
+
+		aNewItem.Reset();
+		aNewItem.InsertL(0, ptrB1);
+		CleanupStack::PopAndDestroy(); // b1
+		}
+	else if ( iUsedRemoteMimeType == -1 )
+		{
+		User::Leave( KErrNotFound );
+		}
+	_DBG_FILE("CNSmlDataModBase::MergeRxL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::NeedsMerge
+// Checks whether merging is needed or not.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C TBool CNSmlDataModBase::NeedsMerge()
+	{
+	_DBG_FILE("CNSmlDataModBase::NeedsMerge(): begin");
+	iUsedRemoteMimeType = -1;
+	if ( !iRemoteStoreFormat )
+		{
+		_DBG_FILE("CNSmlDataModBase::NeedsMerge() - EFalse: end");
+		return EFalse;
+		}
+	else
+		{
+		for ( TInt i = 0; i < iRemoteStoreFormat->MimeFormatCount(); i++ )
+			{
+			if ( iRemoteStoreFormat->MimeFormat( i ).MimeType().DesC().Compare( iMimeType.DesC() ) == 0 )
+				{
+				if ( iRemoteStoreFormat->MimeFormat( i ).MimeVersion().DesC().Compare( iMimeVersion.DesC() ) == 0 )
+					{
+					iUsedRemoteMimeType = i;
+					if ( iRemoteStoreFormat->MimeFormat( i ).PropertyCount() > 0 )
+						{
+						_DBG_FILE("CNSmlDataModBase::NeedsMerge() - ETrue: end");
+						return ETrue;
+						}
+					}
+				}
+			}
+		}
+	_DBG_FILE("CNSmlDataModBase::NeedsMerge() - EFalse: end");
+	return EFalse;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::CNSmlDataModBase
+// Basic constructor of class.
+// ------------------------------------------------------------------------------------------------
+CNSmlDataModBase::CNSmlDataModBase()
+	{
+	iUsedOwnMimeType = -1;
+	iUsedRemoteMimeType = -1;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::StripL
+// Strips data that is to be transmitted to the sync partner.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::StripL( TDes8& aItem )
+	{
+	_DBG_FILE("CNSmlDataModBase::StripL(): begin");
+	if ( !NeedsMerge() )
+		{
+		if ( iUsedRemoteMimeType == -1 )
+			{
+			User::Leave( KErrNotFound );
+			}
+		return;
+		}
+	TBool modified( EFalse );
+	CVersitParser* parser = ChildCreateParserLC();
+	RDesReadStream drs( aItem );
+	CleanupClosePushL( drs );
+	parser->InternalizeL( drs );
+
+	// Now we're ready to start analysis
+	CArrayPtr<CVersitParser>* entities = parser->ArrayOfEntities( EFalse );
+	if( entities )
+		{
+		for( TInt i = 0; i < entities->Count(); i++ )
+			{
+			StripEntityL( entities->At( i ), modified );
+			}
+		}
+	else
+		{
+		StripEntityL( parser, modified );
+		}
+
+	// Only update if anything was modified in process
+	if( modified )
+		{
+		aItem.Zero();
+		RDesWriteStream dws( aItem );
+		CleanupClosePushL( dws );
+		parser->ExternalizeL( dws );
+		dws.CommitL();
+		CleanupStack::PopAndDestroy(); // dws
+		}
+	CleanupStack::PopAndDestroy( 2 ); // drs, parser
+	_DBG_FILE("CNSmlDataModBase::StripL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::StripEntityL
+// Strips data that is to be transmitted to the sync partner from entity.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::StripEntityL( CVersitParser* aEntity, TBool& aModified ) const
+	{
+	_DBG_FILE("CNSmlDataModBase::StripEntityL(): begin");
+	StripAllNotOnPartnerListL( aEntity, aModified, ETrue );
+	_DBG_FILE("CNSmlDataModBase::StripEntityL(): end");
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::StripAllOnPartnerListL
+// Strips all data from entity that is supported by remote server.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::StripAllOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck ) const
+	{
+    _DBG_FILE("CNSmlDataModBase::StripAllOnPartnerListL(): begin");
+
+    if( iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount() )
+        {
+        
+        // Check correct Data Sync protocol
+        TInt value( EDataSyncNotRunning );
+        TSmlProtocolVersion usedSyncProtocol( ESmlVersion1_2 );
+        TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                     KDataSyncStatus,
+                                     value );
+        if ( error == KErrNone &&
+             value == EDataSyncRunning )
+            {
+            usedSyncProtocol = ESmlVersion1_1_2;
+            }
+        
+        TBool wasModified( EFalse );
+
+        CArrayPtr<CParserProperty>* allProps = aEntity->ArrayOfProperties( EFalse );
+        for( TInt i = 0; i < allProps->Count(); ) // Variable i is not increased here because size of count might be changes during loop
+            {
+            const CParserProperty& ownProperty = *allProps->At( i );
+            CParserPropertyValue* ownValue = ownProperty.Value();
+
+            TBool removeMe( EFalse );
+            
+            for( TInt i2 = 0; i2 < iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); i2++ )
+                {
+                const CSmlDataProperty& remoteProperty = iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).Property( i2 );
+                if( !ownProperty.Name().Compare( remoteProperty.Field().Name().DesC() ) )
+                    {
+                    if( remoteProperty.ParamCount() > 0 && aParamLevelCheck )
+                        {
+                        if ( usedSyncProtocol == ESmlVersion1_1_2 )
+                            {
+                            for( TInt i3 = 0; i3 < remoteProperty.ParamCount(); i3++ )
+                                {
+                                if( ownProperty.Param( remoteProperty.Param( i3 ).Field().Name().DesC() ) )
+                                    {
+                                    removeMe = ETrue;
+                                    }
+                                }                           
+                            }
+                        else // ESmlVersion1_2
+                            {
+                            CArrayPtr<CParserParam>* ownerparamarray = ownProperty.ParamArray();
+                            if(ownerparamarray != NULL)
+                                {
+                                for(TInt ownerparam = 0; ownerparam < ownerparamarray->Count(); ownerparam++)
+                                    {
+                                    removeMe = EFalse;
+                                    const CParserParam& ownParam = *ownerparamarray->At( ownerparam );
+                                     TPtrC8 ownparamname = ownParam.Name();
+                                     TPtrC8 ownparamvalue = ownParam.Value();
+                                     if(ownparamvalue == _L8(""))
+                                        {
+                                         for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++)
+                                            {
+                                            TDesC8 remoteparamname = remoteProperty.Param( remoteparam ).Field().Name().DesC();
+                                            const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field();
+											if(field.EnumValueCount() > 0)
+												{
+	                                            for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ )
+													{
+	                                                TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC();
+													if( rmtenumvalue.Compare(ownparamname)== 0 )
+	                                                    {
+	                                                    removeMe = ETrue;
+														break;
+	                                                    }  
+	                                                } 
+												}
+											else
+												{
+												removeMe = ETrue;
+												break;
+												}
+                                            }
+                                        }
+                                     else
+                                        {
+										//Handling when the device supports VersitTokenType as "Encoding"    
+										if(ownparamname == KVersitTokenENCODING)
+											{
+											removeMe = ETrue;
+											}
+										else
+											{
+	                                         for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++)
+	                                            {
+	                                            if(ownparamname.Compare(remoteProperty.Param( remoteparam ).Field().Name().DesC()) == 0)
+	                                                {
+	                                                const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field();
+													if( field.EnumValueCount() > 0 )
+														{
+		                                                for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ )
+		                                                    {
+		                                                     TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC();
+		                                                     if( rmtenumvalue.Compare(ownparamvalue)== 0 )
+		                                                         {
+		                                                         removeMe = ETrue;
+																 break;
+		                                                         }  
+		                                                    } 
+														}
+													else
+														{
+														removeMe = ETrue;
+														break;
+														}
+	                                                }                                               
+	                                            }
+											}
+                                        }
+                                    	if( !removeMe )
+                                        {
+                                        	break;
+                                        }	    
+                                    } 
+                                }
+                            else
+                                {
+                                removeMe = ETrue;
+                                }
+                            }
+                        }
+                    else
+                        {
+                        removeMe = ETrue;
+                        }
+
+                    if( removeMe )
+                        {
+                        break;
+                        }
+                    }
+                }
+            if( removeMe )
+                {
+                #ifdef __NSML_DEBUG__
+                    TPtrC8 pn( ownProperty.Name() );
+                    DBG_ARGS8(_S8("CNSmlDataModBase::StripAllOnPartnerListL(): Dropping %S"), &pn);
+                #endif // __NSML_DEBUG__
+                delete allProps->At( i );
+                allProps->Delete( i );
+                wasModified = ETrue;
+                aModified = ETrue;
+                }
+            else
+                {
+                #ifdef __NSML_DEBUG__
+                    TPtrC8 pn( ownProperty.Name() );
+                    DBG_ARGS8(_S8("CNSmlDataModBase::StripAllOnPartnerListL(): NOT dropping %S"), &pn);
+                #endif // __NSML_DEBUG__
+                i++;
+                }
+            }
+        // can't use aModified as that may have been set earlier!
+        if( wasModified )
+            {
+            allProps->Compress();
+            }
+        }
+    _DBG_FILE("CNSmlDataModBase::StripAllOnPartnerListL(): end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::StripAllNotOnPartnerListL
+// Strips all data from entity that is not supported by remote server.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::StripAllNotOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck ) const
+	{
+    _DBG_FILE("CNSmlDataModBase::StripAllNotOnPartnerListL(): begin");
+    TInt remotepropertycount = iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount();
+    if( iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount() )
+        {
+        
+        // Check correct Data Sync protocol
+        TInt value( EDataSyncNotRunning );
+        TSmlProtocolVersion usedSyncProtocol( ESmlVersion1_2 );
+        TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
+                                     KDataSyncStatus,
+                                     value );
+        if ( error == KErrNone &&
+             value == EDataSyncRunning )
+            {
+            usedSyncProtocol = ESmlVersion1_1_2;
+            }
+
+        TBool wasModified( EFalse );
+
+        CArrayPtr<CParserProperty>* allProps = aEntity->ArrayOfProperties( EFalse );
+        for( TInt i = 0; i < allProps->Count(); ) // Variable i is not increased here because size of count might be changes during loop
+            {
+            const CParserProperty& ownProperty = *allProps->At( i );
+            TBuf8<30> name = ownProperty.Name();
+            CParserPropertyValue* ownValue = ownProperty.Value();
+
+            TBool removeMe( ETrue );
+            
+            for( TInt i2 = 0; i2 < iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); i2++ )
+                {
+                const CSmlDataProperty& remoteProperty = iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).Property( i2 );
+                TPtrC8 remotename = remoteProperty.Field().Name().DesC();
+                if( !ownProperty.Name().Compare( remoteProperty.Field().Name().DesC() ) )
+                    {
+                    TInt remoteparamcount = remoteProperty.ParamCount();
+                    if( remoteProperty.ParamCount() > 0 && aParamLevelCheck )
+                        {
+                        if ( usedSyncProtocol == ESmlVersion1_1_2 )
+                            {
+                            const CParserProperty* p = allProps->At( i );
+                            TInt entityParamCount = (( CNSmlProperty* )p)->ParamCount();
+                            if( entityParamCount > 0)
+                            {
+                            for( TInt i3 = 0; i3 < remoteProperty.ParamCount(); i3++ )
+                                {
+                                TPtrC8 remoteparamname = remoteProperty.Param( i3 ).Field().Name().DesC();
+                                if( ownProperty.Param( remoteProperty.Param( i3 ).Field().Name().DesC() ) )
+                                    {
+                                    removeMe = EFalse;
+                                    }
+                                }                           
+                            }
+                            else
+                            {
+                                removeMe = EFalse;
+                            }
+                            }
+                        else // ESmlVersion1_2
+                            {
+                            CArrayPtr<CParserParam>* ownerparamarray = ownProperty.ParamArray();
+                            if(ownerparamarray != NULL)
+                                {
+                                for(TInt ownerparam = 0; ownerparam < ownerparamarray->Count(); ownerparam++)
+                                    {
+									removeMe = ETrue;
+                                    const CParserParam& ownParam = *ownerparamarray->At( ownerparam );
+                                     TPtrC8 ownparamname = ownParam.Name();
+                                     TPtrC8 ownparamvalue = ownParam.Value();
+                                     if(ownparamvalue == _L8(""))
+                                        {
+                                         for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++)
+                                            {
+                                            TDesC8 remoteparamname = remoteProperty.Param( remoteparam ).Field().Name().DesC();
+                                            const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field();
+											if( field.EnumValueCount() > 0)
+												{
+												for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ )
+													{
+													TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC();
+													if( rmtenumvalue.Compare(ownparamname)== 0 )
+														{
+														removeMe = EFalse;
+														break;
+														}
+													} 
+												}
+											else
+												{
+												removeMe = EFalse;
+												break;
+												}											
+                                            }
+                                        }
+                                     else
+                                        {
+										//Handling when the device supports VersitTokenType as "Encoding"    
+										if(ownparamname == KVersitTokenENCODING)
+											{
+											removeMe = EFalse;
+											}
+										else
+											{
+	                                         for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++)
+	                                            {
+	                                            TDesC8 remoteparamname = remoteProperty.Param( remoteparam ).Field().Name().DesC();
+	                                            if(ownparamname.Compare(remoteProperty.Param( remoteparam ).Field().Name().DesC()) == 0)
+	                                                {
+	                                                const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field();
+													if( field.EnumValueCount() > 0)
+														{
+		                                                for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ )
+		                                                    {
+		                                                     TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC();
+		                                                     if( rmtenumvalue.Compare(ownparamvalue)== 0 )
+		                                                         {
+		                                                         removeMe = EFalse;
+																 break;
+		                                                         }  
+		                                                    }
+														}
+													else
+														{
+														removeMe = EFalse;
+														break;
+														}
+	                                                }
+												}
+											}                                 
+                                        }
+                                        if( removeMe )
+                                        {
+                                        	break;
+                                        }	
+                                    } 
+                                }
+                            else
+                                {
+                                removeMe = EFalse;
+                                }
+                            }
+                        }
+                    else
+                        {
+                        removeMe = EFalse;
+                        }
+
+                    if( !removeMe )
+                        {
+                        break;
+                        }
+                    }
+                }
+            if( removeMe )
+                {
+                #ifdef __NSML_DEBUG__
+                    TPtrC8 pn( ownProperty.Name() );
+                    DBG_ARGS8(_S8("CNSmlDataModBase::StripAllNotOnPartnerListL(): Dropping %S"), &pn);
+                #endif // __NSML_DEBUG__
+                delete allProps->At( i );
+                allProps->Delete( i );
+                wasModified = ETrue;
+                aModified = ETrue;
+                }
+            else
+                {
+                #ifdef __NSML_DEBUG__
+                    TPtrC8 pn( ownProperty.Name() );
+                    DBG_ARGS8(_S8("CNSmlDataModBase::StripAllNotOnPartnerListL(): NOT dropping %S"), &pn);
+                #endif // __NSML_DEBUG__
+                i++;
+                }
+            }
+        // can't use aModified as that may have been set earlier!
+        if( wasModified )
+            {
+            allProps->Compress();
+            }
+        }
+    _DBG_FILE("CNSmlDataModBase::StripAllNotOnPartnerListL(): end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::MergeL
+// Merges data from old item to new item.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel )
+	{
+	TBool modified( EFalse );
+	CVersitParser* newItemParser = ChildCreateParserLC();
+	RDesReadStream newStream( aNewItem );
+	CleanupClosePushL( newStream );
+	newItemParser->InternalizeL( newStream );
+	CVersitParser* oldItemParser = ChildCreateParserLC();
+	RDesReadStream oldStream( aOldItem );
+	CleanupClosePushL( oldStream );
+	oldItemParser->InternalizeL( oldStream );
+
+	// Now we're ready to start analysis
+	CArrayPtr<CVersitParser>* newEntities = newItemParser->ArrayOfEntities( EFalse );
+	CArrayPtr<CVersitParser>* oldEntities = oldItemParser->ArrayOfEntities( ETrue );
+
+	if( newEntities && oldEntities )
+		{
+		CleanupPtrArrayPushL( oldEntities );
+		for( TInt i = 0; ( i < newEntities->Count() ) && ( i < oldEntities->Count() ); i++ )
+			{
+			MergeEntityL( newEntities->At( i ), oldEntities->At( i ), modified, aFieldLevel );
+			}
+		CleanupStack::PopAndDestroy(); // oldEntities
+		}
+	else
+		{
+		MergeEntityL( newItemParser, oldItemParser, modified, aFieldLevel );
+		}
+
+	// Only update if anything was modified in process
+	if ( modified )
+		{
+		aNewItem.Zero();
+		RDesWriteStream dws( aNewItem );
+		CleanupClosePushL( dws );
+		newItemParser->ExternalizeL( dws );
+		dws.CommitL();
+		CleanupStack::PopAndDestroy(); // dws
+		}
+
+	CleanupStack::PopAndDestroy( 4 ); // oldStream, oldItemParser, newStream, newItemParser
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDataModBase::MergeEntityL
+// Merges data from old entity to new entity.
+// ------------------------------------------------------------------------------------------------
+void CNSmlDataModBase::MergeEntityL( CVersitParser* aNewEntity, CVersitParser* aOldEntity, TBool& aModified, TBool aFieldLevel ) const
+	{
+	_DBG_FILE("CNSmlDataModBase::MergeEntityL(): begin");
+
+	// Remove all data that was not supposed to be supported by the partner but
+	// it was still sent to us.
+	StripAllNotOnPartnerListL( aNewEntity, aModified );
+	
+	// Remove all properties from old item that are supported by remote server.
+	// If it is field level then old this is not done.
+	if( !aFieldLevel )
+		{
+		StripAllOnPartnerListL( aOldEntity, aModified, ETrue );
+		CArrayPtr<CParserProperty>* mergeProps = aOldEntity->ArrayOfProperties( ETrue );
+		if( mergeProps )
+		    {
+			CleanupStack::PushL( mergeProps );
+			
+			for( TInt i = 0; i < mergeProps->Count(); i++ )
+				{
+				aNewEntity->AddPropertyL( mergeProps->At( i ), ETrue );
+				}
+			
+			CleanupStack::PopAndDestroy(); // mergeProps
+		    }
+		}
+	else
+		{
+		User::Leave( KErrNotSupported );
+		}
+	
+	#ifdef __NSML_DEBUG__
+		CArrayPtr<CParserProperty>* props = aNewEntity->ArrayOfProperties( EFalse );
+		for( TInt i = 0; i < props->Count(); i++ )
+			{
+			TBuf8<512> b;
+			const CParserProperty* p = props->At( i );
+			b = p->Name();
+			const CArrayPtr<CParserParam>* pa = ( ( CNSmlProperty* )p )->Parameters();
+			if( pa )
+				{
+				for( TInt i2 = 0; i2 < pa->Count(); i2++ )
+					{
+					b.Append( _L8(":") );
+					b.Append( pa->At( i2 )->Name() );
+					}
+				}
+			DBG_ARGS8(_S8("CNSmlDataModBase::MergeEntityL(): %S"), &b);
+			}
+	#endif // __NSML_DEBUG__
+	_DBG_FILE("CNSmlDataModBase::MergeEntityL(): end");
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  CGI Script Utils build file.
+*
+*/
+
+
+PRJ_MMPFILES
+./nsmlCGIScriptParser.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/bld/def/bwinscwcgiscriptparseru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,16 @@
+EXPORTS
+	??0TNSmlCGIScriptParser@@QAE@XZ @ 1 NONAME ; TNSmlCGIScriptParser::TNSmlCGIScriptParser(void)
+	?AddL@CNSmlCGIScript@@QAEXPAUTNSmlCGIScriptPart@@@Z @ 2 NONAME ; void CNSmlCGIScript::AddL(struct TNSmlCGIScriptPart *)
+	?CGIScript@CNSmlCGIScript@@QBEPAVHBufC16@@XZ @ 3 NONAME ; class HBufC16 * CNSmlCGIScript::CGIScript(void) const
+	?Clear@CNSmlCGIScript@@QAEXXZ @ 4 NONAME ; void CNSmlCGIScript::Clear(void)
+	?Count@CNSmlCGIScript@@QBEHXZ @ 5 NONAME ; int CNSmlCGIScript::Count(void) const
+	?GenerateL@TNSmlCGIScriptParser@@QBEXAAVCNSmlCGIScript@@@Z @ 6 NONAME ; void TNSmlCGIScriptParser::GenerateL(class CNSmlCGIScript &) const
+	?Get@CNSmlCGIScript@@QBEPBUTNSmlCGIScriptPart@@H@Z @ 7 NONAME ; struct TNSmlCGIScriptPart const * CNSmlCGIScript::Get(int) const
+	?LogicalOperator@CNSmlCGIScript@@QBE?AW4TNSmlCGIScriptLogicalOperator@@XZ @ 8 NONAME ; enum TNSmlCGIScriptLogicalOperator CNSmlCGIScript::LogicalOperator(void) const
+	?NewL@CNSmlCGIScript@@SAPAV1@XZ @ 9 NONAME ; class CNSmlCGIScript * CNSmlCGIScript::NewL(void)
+	?NewLC@CNSmlCGIScript@@SAPAV1@XZ @ 10 NONAME ; class CNSmlCGIScript * CNSmlCGIScript::NewLC(void)
+	?ParseL@TNSmlCGIScriptParser@@QBEXAAVCNSmlCGIScript@@ABV?$CArrayPtr@UTNSmlDataTypesForCGIScriptNames@@@@@Z @ 11 NONAME ; void TNSmlCGIScriptParser::ParseL(class CNSmlCGIScript &, class CArrayPtr<struct TNSmlDataTypesForCGIScriptNames> const &) const
+	?Remove@CNSmlCGIScript@@QAEPAUTNSmlCGIScriptPart@@H@Z @ 12 NONAME ; struct TNSmlCGIScriptPart * CNSmlCGIScript::Remove(int)
+	?SetCGIScriptL@CNSmlCGIScript@@QAEXABVTDesC16@@@Z @ 13 NONAME ; void CNSmlCGIScript::SetCGIScriptL(class TDesC16 const &)
+	?SetLogicalOperator@CNSmlCGIScript@@QAEXW4TNSmlCGIScriptLogicalOperator@@@Z @ 14 NONAME ; void CNSmlCGIScript::SetLogicalOperator(enum TNSmlCGIScriptLogicalOperator)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/bld/def/eabicgiscriptparseru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,19 @@
+EXPORTS
+	_ZN14CNSmlCGIScript13SetCGIScriptLERK7TDesC16 @ 1 NONAME
+	_ZN14CNSmlCGIScript18SetLogicalOperatorE29TNSmlCGIScriptLogicalOperator @ 2 NONAME
+	_ZN14CNSmlCGIScript4AddLEP18TNSmlCGIScriptPart @ 3 NONAME
+	_ZN14CNSmlCGIScript4NewLEv @ 4 NONAME
+	_ZN14CNSmlCGIScript5ClearEv @ 5 NONAME
+	_ZN14CNSmlCGIScript5NewLCEv @ 6 NONAME
+	_ZN14CNSmlCGIScript6RemoveEi @ 7 NONAME
+	_ZN20TNSmlCGIScriptParserC1Ev @ 8 NONAME
+	_ZN20TNSmlCGIScriptParserC2Ev @ 9 NONAME
+	_ZNK14CNSmlCGIScript15LogicalOperatorEv @ 10 NONAME
+	_ZNK14CNSmlCGIScript3GetEi @ 11 NONAME
+	_ZNK14CNSmlCGIScript5CountEv @ 12 NONAME
+	_ZNK14CNSmlCGIScript9CGIScriptEv @ 13 NONAME
+	_ZNK20TNSmlCGIScriptParser6ParseLER14CNSmlCGIScriptRK9CArrayPtrI31TNSmlDataTypesForCGIScriptNamesE @ 14 NONAME
+	_ZNK20TNSmlCGIScriptParser9GenerateLER14CNSmlCGIScript @ 15 NONAME
+	_ZTI14CNSmlCGIScript @ 16 NONAME ; #<TI>#
+	_ZTV14CNSmlCGIScript @ 17 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/bld/nsmlCGIScriptParser.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  CGI Script Utils mmp file
+*
+*/
+
+
+#include "defaultcaps.hrh"
+#include <platform_paths.hrh>
+
+TARGET          nsmlCGIScriptParser.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x101F6DE4
+CAPABILITY 	CAP_GENERAL_DLL
+VENDORID 	VID_DEFAULT
+
+
+#if defined(ARMCC)
+DEFFILE		./def/eabicgiscriptparser
+#elif defined(WINSCW)
+DEFFILE		./def/bwinscwcgiscriptparser
+#elif defined(WINS)
+DEFFILE		./def/bwinscgiscriptparser
+#else
+DEFFILE		./def/bmarmcgiscriptparser
+#endif
+
+APP_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../inc
+
+SOURCEPATH      ../src
+SOURCE		nsmlcgiscriptparser.cpp
+SOURCE          NSmlCGIScript.cpp
+SOURCE          NSmlCGIScriptParseStateInfo.cpp
+SOURCE          NSmlCGIScriptParseData.cpp
+
+LIBRARY         euser.lib InetProtUtil.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/inc/nsmlcgiscriptparser.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,493 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  CGI parser and generator
+*
+*/
+
+
+#ifndef __TNSMLCGISCRIPTPARSER_H__
+#define __TNSMLCGISCRIPTPARSER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <s32strm.h>
+#include <e32std.h>
+#include <badesca.h>
+
+// CONSTANTS
+_LIT( KNSmlCGIParserReservedChars, ";/?:@&=+,$[]" );
+_LIT( KNSmlCGIParserDateTimeFormat, "%04u%02u%02uT%02u%02u%02uZ" );
+_LIT( KNSmlCGIParserDateFormat, "%04u%02u%02u" );
+
+_LIT(KNSmlCGIScriptComparatorEqualToCaseSensitiveStr, "&EQ;");
+_LIT(KNSmlCGIScriptComparatorEqualToCaseInSensitiveStr, "&iEQ;");
+_LIT(KNSmlCGIScriptComparatorNotEqualToCaseSensitiveStr, "&NE;");
+_LIT(KNSmlCGIScriptComparatorNotEqualToCaseInSensitiveStr, "&iNE;");
+_LIT(KNSmlCGIScriptComparatorGreaterThanCaseSensitiveStr, "&GT;");
+_LIT(KNSmlCGIScriptComparatorGreaterThanCaseInSensitiveStr, "&iGT;");
+_LIT(KNSmlCGIScriptComparatorGreaterThanOrEqualToCaseSensitiveStr, "&GE;");
+_LIT(KNSmlCGIScriptComparatorGreaterThanOrEqualToCaseInSensitiveStr, "&iGE;");
+_LIT(KNSmlCGIScriptComparatorLessThanCaseSensitiveStr, "&LT;");
+_LIT(KNSmlCGIScriptComparatorLessThanCaseInSensitiveStr, "&iLT;");
+_LIT(KNSmlCGIScriptComparatorLessThanOrEqualCaseSensitiveStr, "&LE;");
+_LIT(KNSmlCGIScriptComparatorLessThanOrEqualCaseInSensitiveStr, "&iLE;");
+_LIT(KNSmlCGIScriptComparatorContainsValueCaseSensitiveStr, "&CON;");
+_LIT(KNSmlCGIScriptComparatorContainsValueCaseInSensitiveStr, "&iCON;");
+
+_LIT(KNSmlCGIScriptLogicalSeparatorAndStr, "&AND;");
+_LIT(KNSmlCGIScriptLogicalSeparatorOrStr, "&OR;");
+
+_LIT(KNSmlCGIScriptNullValue, "&NULL;");
+_LIT(KNSmlCGIScriptLuidValue, "&LUID;");
+
+_LIT(KNSmlCGIScriptNullStr,"");
+
+_LIT(KNSmlCGIScriptBoolTrue, "TRUE");
+_LIT(KNSmlCGIScriptBoolFalse, "FALSE");
+
+const TInt KNSmlCGIScriptLogSepCount = 2;
+const TInt KNSmlCGIParserLogOpsCount = 15;
+const TInt KNSmlCGIScriptSpecialUsageStringsCount = 2;
+
+const TInt KNSmlCGIParserDateTimeLen = 16;
+const TInt KNSmlCGIParserDateLen = 8;
+
+// DATA TYPES
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIScriptDataType
+// ------------------------------------------------------------------------------------------------
+enum TNSmlCGIScriptDataType
+	{
+	ENSmlCGIScriptDataTypeHBufC,
+	ENSmlCGIScriptDataTypeDate,
+	ENSmlCGIScriptDataTypeDateTime,
+	ENSmlCGIScriptDataTypeNumber,
+	ENSmlCGIScriptDataTypeBoolean,
+    ENSmlCGIScriptDataTypeNoValue,
+	ENSmlCGIScriptDataTypeNull,
+	ENSmlCGIScriptDataTypeUnKnown
+	};
+
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIScriptLogicalOperator
+// ------------------------------------------------------------------------------------------------
+enum TNSmlCGIScriptLogicalOperator
+	{
+	ENSmlCGIScriptLogicalOperatorAnd,
+	ENSmlCGIScriptLogicalOperatorOr,
+    ENSmlCGIScriptLogicalOperatorNull
+	};
+
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIScriptComparator
+// ------------------------------------------------------------------------------------------------
+enum TNSmlCGIScriptComparator
+	{
+	ENSmlCGIScriptComparatorEqualToCaseSensitive,
+	ENSmlCGIScriptComparatorEqualToCaseInSensitive,
+	ENSmlCGIScriptComparatorNotEqualToCaseSensitive,
+	ENSmlCGIScriptComparatorNotEqualToCaseInSensitive,
+	ENSmlCGIScriptComparatorGreaterThanCaseSensitive,
+	ENSmlCGIScriptComparatorGreaterThanCaseInSensitive,
+	ENSmlCGIScriptComparatorGreaterThanOrEqualToCaseSensitive,
+	ENSmlCGIScriptComparatorGreaterThanOrEqualToCaseInSensitive,
+	ENSmlCGIScriptComparatorLessThanCaseSensitive,
+	ENSmlCGIScriptComparatorLessThanCaseInSensitive,
+	ENSmlCGIScriptComparatorLessThanOrEqualCaseSensitive,
+	ENSmlCGIScriptComparatorLessThanOrEqualCaseInSensitive,
+	ENSmlCGIScriptComparatorContainsValueCaseSensitive,
+	ENSmlCGIScriptComparatorContainsValueCaseInSensitive,
+    ENSmlCGIScriptComparatorNull
+	};
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIScriptPart
+// ------------------------------------------------------------------------------------------------
+struct TNSmlCGIScriptPart
+    {
+    HBufC* iName;
+	TAny* iData;
+	TNSmlCGIScriptDataType iDataType;
+	TNSmlCGIScriptComparator iComparator;
+    };
+
+// ------------------------------------------------------------------------------------------------
+// TNSmlDataTypesForCGIScriptNames
+// ------------------------------------------------------------------------------------------------
+struct TNSmlDataTypesForCGIScriptNames
+	{
+	HBufC* iKeywordOrProperty;
+	TNSmlCGIScriptDataType iDataType;
+	};
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlCGIScript
+// ------------------------------------------------------------------------------------------------
+class CNSmlCGIScript : public CBase
+	{
+public:
+	/**
+    * CNSmlCGIScript NewL.
+    */
+	IMPORT_C static CNSmlCGIScript* NewL();
+
+	/**
+    * CNSmlCGIScript NewLC.
+    */
+	IMPORT_C static CNSmlCGIScript* NewLC();
+	
+	/**
+    * CNSmlCGIScript destructor.
+	* 
+    */
+	~CNSmlCGIScript();
+
+	/**
+    * Returns logical Separator of CNSmlCGIScript.
+    */
+	IMPORT_C TNSmlCGIScriptLogicalOperator LogicalOperator() const;
+
+	/**
+    * Sets logical Separator.
+	* @param aSeparator sets logical Separator of CNSmlCGIScript.
+    */
+	IMPORT_C void SetLogicalOperator( const TNSmlCGIScriptLogicalOperator aSeparator );
+
+	/**
+    * Returns script of CNSmlCGIScript.
+    */
+	IMPORT_C HBufC* CGIScript() const;
+
+	/**
+    * Sets script of CNSmlCGIScript.
+	* @param aCGIScript sets script of CNSmlCGIScript.
+    */
+	IMPORT_C void SetCGIScriptL( const TDesC& aCGIScript );
+
+	/**
+    * Returns number of records in list.
+	* @return TInt Number of records in list.
+    */
+	IMPORT_C TInt Count() const;
+
+	/**
+    * Returns script part at index aIndex from list.
+    * @param aIndex - value between 0 - Count()-1
+	* @return TNSmlCGIScriptPart pointer to script part at index aIndex.
+    */
+	IMPORT_C const TNSmlCGIScriptPart* Get( TInt aIndex ) const;
+
+	/**
+    * Adds new script part to the list.
+	* @param aScriptPart Pointer to script part to add to the list.
+    */
+	IMPORT_C void AddL( TNSmlCGIScriptPart* aScriptPart );
+
+	/**
+    * Removes script part at index aIndex from list.
+	* @param aIndex Index to script part to be removed.
+	* @return TNSmlCGIScriptPart* Pointer to removed script part.
+    */
+	IMPORT_C TNSmlCGIScriptPart* Remove( TInt aIndex );
+
+    /**
+    * Removes all script parts.
+    */
+    IMPORT_C void Clear();
+
+protected:
+	CNSmlCGIScript();
+	void ConstructL();
+	
+private:
+	TNSmlCGIScriptLogicalOperator iSeparator;
+	HBufC* iCGIScript;
+	CArrayPtrFlat<TNSmlCGIScriptPart>* iScriptParts;
+	TAny* iReserved;
+	};
+
+// ------------------------------------------------------------------------------------------------
+//  CGI parser/generator
+// ------------------------------------------------------------------------------------------------
+class TNSmlCGIScriptParser
+    {
+    public:
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIParserError
+// ------------------------------------------------------------------------------------------------
+        enum TNSmlCGIParserError
+	        {
+	        ENSmlCGIParserErrorOk,
+	        ENSmlCGIParserErrorDataTypeNotFound,
+            ENSmlCGIParserErrorConversion,
+	        ENSmlCGIParserErrorWrongOperator,
+            ENSmlCGIParserErrorWrongSeparator,
+            ENSmlCGIParserErrorParsing,
+            ENSmlCGIParserErrorNoKeyword
+	        };
+
+
+    private:
+        // Private helper classes:
+// ------------------------------------------------------------------------------------------------
+// TNSmlCGIScriptParseState
+// ------------------------------------------------------------------------------------------------
+        enum TNSmlCGIScriptParseState 
+            {
+            ENSmlCGIScriptParseStateKeyWord, 
+            ENSmlCGIScriptParseStateLogOp, 
+            ENSmlCGIScriptParseStateValue, 
+            ENSmlCGIScriptParseStateLogSep
+            };
+
+        // ----------------------------------------------------------------------------------------
+        // TNSmlCGIScriptParseStateInfo
+        // ----------------------------------------------------------------------------------------
+        struct TNSmlCGIScriptParseStateInfo
+            {
+            TNSmlCGIScriptParseStateInfo(
+                const TDesC* aCGIScript,
+                const CArrayPtr<TNSmlDataTypesForCGIScriptNames>* aDatatypes);
+            TNSmlCGIScriptParseState iState;
+            TNSmlCGIScriptParseState iNextState;
+            const TDesC* iCGIScript;
+            const CArrayPtr<TNSmlDataTypesForCGIScriptNames>* iDatatypes;
+            TInt iStartPos;
+            TInt iCurrPos;
+            };
+        // ----------------------------------------------------------------------------------------
+        // TNSmlCGIScriptParseData
+        // ----------------------------------------------------------------------------------------
+        struct TNSmlCGIScriptParseData
+            {
+            TNSmlCGIScriptParseData();
+            TPtrC iKeyword;
+            TNSmlCGIScriptDataType iDataType;
+            TPtrC iValue;
+            TNSmlCGIScriptComparator iComparator;
+            TNSmlCGIScriptLogicalOperator iSeparator;
+            TBool iParseDataReady;
+            };
+
+        friend struct TNSmlCGIScriptParseStateInfo;
+
+    public:  // Constructors and destructor
+
+        
+        /**
+        * constructor.
+        */
+        IMPORT_C TNSmlCGIScriptParser();
+        
+    public: // New functions
+        
+        /**
+        * Converts cgi-script to a data structure.
+        * @param aSp contains cgi-script (=source) and methods to add parsed data structure (=dest.) there.
+        * @param aDatatypes contains all acceptable keyword and property names and their datatypes.
+        */
+        IMPORT_C void ParseL(CNSmlCGIScript& aSp, 
+            const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes) const;
+
+        /**
+        * Converts data structure to cgi-script
+        * @param aS contains the data structure (=source) and method to set the generated cgi-script.
+        */
+        IMPORT_C void GenerateL(CNSmlCGIScript& aS) const;
+        
+    protected:  // New functions
+
+    private:
+
+        /**
+        * In parsing cgi-script, determines whether to split cgi-script at a certain point or not. 
+        * @param aCGIScript - cgi-script
+        * @param aStartFrom - index to cgi-script
+        * @return ETrue if there is split point at aCGIScript[aStartFrom], EFalse otherwise.
+        */
+        TBool IsParseSplitPoint(const TDesC& aCGIScript, TInt aStartFrom) const;
+
+        /**
+        * Does the parsing of cgi-script.
+        * @param aPSInfo contains state information needed for parsing (=source)
+        * @param aPD is filled with data, that is parsed (=dest.)
+        * @return EFalse, if ready for handling of next split point, ETrue, if must be called again before next split point.
+        */
+        TBool ParseStateL(TNSmlCGIScriptParseStateInfo& aPSInfo, TNSmlCGIScriptParseData& aPD) const;
+
+        /**
+        * adds script part to aSp
+        * @param aSp - script to add script part. (=dest)
+        * @param aPD - parsed data, has the data needed for script part.(=source)
+        * @return ETrue, if script part was added, EFalse otherwise.
+        */
+        static TBool AddScriptPartL(CNSmlCGIScript& aSp, TNSmlCGIScriptParseData& aPD);
+
+        /**
+        * parses the script's value.
+        * @param aSp - struct's iData - member receives the parsed value.
+        * @param aValue - value to parse.
+        * @return ETrue, if aSp should be used, EFalse if it should be ignored.
+        */
+        static TBool ParseScriptPartDataLC(TNSmlCGIScriptPart& aSp, const TPtrC& aValue);
+
+        /**
+        * finds datatype for a keyword (=script's keyword or propertyname)
+        * @param aDatatypes - array where to search.
+        * @param aKeyword - keyword to search
+        * @return datatype, leaves if not found
+        */
+        static TNSmlCGIScriptDataType FindDataTypeL(const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes, const TPtrC& aKeyword);
+
+        /**
+        * similar to FindDataTypeL, but doesn't leave if datatype not found, instead returns TNSmlCGIScriptDataTypeUnKnown.
+        * @param aDatatypes - array where to search.
+        * @param aKeyword - keyword to search
+        * @return datatype, leaves if not found
+        */
+        static TNSmlCGIScriptDataType FindDataType(const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes, const TPtrC& aKeyword);
+
+        /**
+        * converts script part to string.
+        * @param aSp - script part to convert
+        * @return converted string.
+        */
+        HBufC* GenerateScriptPartL(const TNSmlCGIScriptPart& aSp) const;
+
+        /**
+        * generates the script's value.
+        * @param aDataType - datatype for value.
+        * @param aValue - value to convert. (=source)
+        * @param aPtr receives the generated value (=dest.)
+        */
+        static void GenerateScriptPartValueL(TNSmlCGIScriptDataType aDataType, const TAny* aValue, TPtr& aPtr);
+
+        /**
+        * collects script-parts to one cgi-script.
+        * @param aSp - where to set the script (=dest)
+        * @param aBufParts - scripts parts to collect (=source)
+        */
+        void SetCGIScriptL(CNSmlCGIScript& aSp, CArrayPtr<HBufC>& aBufParts) const;
+
+        /**
+        * converts cgi-script date to TDateTime.
+        * @param aDateTime receives the parsed datetime(=dest.)
+        * @param aDes - descriptor where date is to be parsed (= source)
+        * @param aStartFrom - index to aDes, where date-string should start.
+        * @return how many letters from aDes[aStartFrom] was needed to get the datetime. 
+        */
+        static TInt ParseDateTimeL(TDateTime& aDateTime, const TDesC& aDes, TInt aStartFrom = 0);
+
+        /**
+        * converts TDateTime to string-format used by cgi-script.
+        * @param aDateTime - the date to convert(=source.)
+        * @param aDes receives the converted date-string. (=dest.)
+        * @param aUseTimePart is ETrue, if timepart (= hour, minute, second) should be converted too.
+        */
+        static void GenerateDateTimeValue(const TDateTime& aDateTime, TDes& aDes, TBool aUseTimePart = ETrue);
+
+        /**
+        * converts boolean value to string-format used by cgi-script.
+        * @param aBool - source boolean value.
+        * @return boolean value as descriptor.
+        */
+        static const TDesC& GenerateBoolValue(TBool aBool);
+
+        /**
+        * converts number as descriptor to TInt.
+        * @param aDes - source number.
+        * @param aStartFrom - index to aDes, where the number should be.
+        * @param aLength - how many numbers follows aDes[aStartFrom].
+        * @return the number as integer.
+        */
+        static TInt ParseIntL(const TDesC& aDes, TInt aStartFrom, TInt aLength);
+
+        /**
+        * converts boolean-value as descriptor to TBool
+        * @param aDes - source boolean-value.
+        * @param aStartFrom - index to aDes, where the boolean-value should be.
+        * @return the boolean-value as TBool.
+        */
+        static TBool ParseBoolL(const TDesC& aDes, TInt aStartFrom = 0);
+        
+        /**
+        * get logical operator as descriptor.
+        * @param aComp - comparator 
+        * @return comparator as string.
+        */
+        const TDesC& LogOpL(TNSmlCGIScriptComparator aComp) const;
+
+        /**
+        * gets comparator from descriptor.
+        * @param aDes - descriptor, where comparator should be.
+        * @param aInd - index to aDes where comparator should be. aInd should point to next letter following '&'.
+        * @return comparator at aDes[aInd] or else leaves.
+        */
+        TNSmlCGIScriptComparator LogOpL(const TDesC& aDes, TInt aInd) const;
+
+        /**
+        * get logical separator as descriptor.
+        * @param aLogSep - separator
+        * @return separator as string.
+        */
+        const TDesC& LogSepL(TNSmlCGIScriptLogicalOperator aLogSep) const;
+
+        /**
+        * gets separator from descriptor.
+        * @param aDes - descriptor, where comparator should be.
+        * @param aInd - index to aDes, where comparator should be. aInd should point to next letter following '&'.
+        * @return separator at aDes[aInd] or else leaves.
+        */
+        TNSmlCGIScriptLogicalOperator LogSepL(const TDesC& aDes, TInt aInd) const;
+
+        /**
+        * compares comparator to one of equality-operators.
+        * @param aComp - comparator to compare.
+        * @return ETrue, if aComp was one of equality-operators, EFalse otherwise.
+        */
+        static TBool IsEqualityOperator(TNSmlCGIScriptComparator aComp);
+
+        /**
+        * checks, if scriptPart-data is valid. Leaves if not.
+        * @param aSp - scriptpart to check.
+        */
+        static void CheckScriptPartValidityL(const TNSmlCGIScriptPart& aSp);
+
+        /**
+        * compares descriptors 
+        * @param aWhat - what to compare.
+        * @param aWhere - where to compare
+        * @param aStartFrom - index to aWhere. 
+        * @return ETrue if aWhat is found exactly at aWhere[aStartFrom], but aWhere can contain letters after the found string.
+        */
+        static TBool Compare(const TDesC& aWhat, const TDesC& aWhere, TInt aStartFrom);
+
+    public:     // Data
+    
+    protected:  // Data
+        
+    private:    // Data
+        const TDesC* KNSmlCGIScriptLogSep[KNSmlCGIScriptLogSepCount];
+        const TDesC* KNSmlCGIScriptLogOps[KNSmlCGIParserLogOpsCount];
+        const TDesC* KNSmlCGIScriptSpecialUsageStrings[KNSmlCGIScriptSpecialUsageStringsCount];        
+    };
+
+#endif      // __TNSMLCGISCRIPTPARSER_H__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScript.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or 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:  CGI parser and generator
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "nsmlcgiscriptparser.h"
+
+
+// CONSTANTS
+const TInt KNSmlGranularity = 4;
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::CNSmlCGIScript
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlCGIScript::CNSmlCGIScript()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlCGIScript* CNSmlCGIScript::NewL()
+	{
+	CNSmlCGIScript* self = NewLC();
+	CleanupStack::Pop(); // self
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlCGIScript* CNSmlCGIScript::NewLC()
+	{
+	CNSmlCGIScript* self = new ( ELeave ) CNSmlCGIScript();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::~CNSmlCGIScript
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlCGIScript::~CNSmlCGIScript()
+	{
+	delete iCGIScript;
+	Clear();
+	delete iScriptParts;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::ConstructL
+// Symbian 2nd phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CNSmlCGIScript::ConstructL()
+	{
+	iSeparator = ENSmlCGIScriptLogicalOperatorAnd;
+	iScriptParts = new (ELeave) CArrayPtrFlat<TNSmlCGIScriptPart>( KNSmlGranularity );
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::LogicalOperator
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlCGIScriptLogicalOperator CNSmlCGIScript::LogicalOperator() const
+	{
+	return iSeparator;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::SetLogicalOperator
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlCGIScript::SetLogicalOperator( const TNSmlCGIScriptLogicalOperator aSeparator )
+	{
+	iSeparator = aSeparator;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::CGIScript
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC* CNSmlCGIScript::CGIScript() const
+	{
+	return iCGIScript;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::SetCGIScriptL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlCGIScript::SetCGIScriptL( const TDesC& aCGIScript )
+	{
+		if ( iCGIScript )
+		{
+		delete iCGIScript;
+		iCGIScript = NULL;
+		}
+	iCGIScript = HBufC::NewL( aCGIScript.Length() );
+	*iCGIScript = aCGIScript;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::Count
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlCGIScript::Count() const
+	{
+	return iScriptParts->Count();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::Get
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TNSmlCGIScriptPart* CNSmlCGIScript::Get( TInt aIndex ) const
+	{
+	return iScriptParts->At( aIndex );
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::AddL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlCGIScript::AddL( TNSmlCGIScriptPart* aRecordPart )
+	{
+	iScriptParts->AppendL( aRecordPart );
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::Remove
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlCGIScriptPart* CNSmlCGIScript::Remove( TInt aIndex )
+	{
+	TNSmlCGIScriptPart* temp = iScriptParts->At( aIndex );
+	iScriptParts->Delete( aIndex );
+	return temp;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlCGIScript::Clear
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlCGIScript::Clear()
+    {
+    for ( TInt i = 0; i < iScriptParts->Count(); i++ )
+		{
+		TNSmlCGIScriptPart* temp = iScriptParts->At( i );
+		delete temp->iName;
+        temp->iName = NULL;
+		delete temp->iData;
+        temp->iData = NULL;
+		}
+  	iScriptParts->ResetAndDestroy();
+    }
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScriptParseData.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or 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:  CGI parser and generator
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "nsmlcgiscriptparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParseData::TNSmlCGIScriptParseData
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptParser::TNSmlCGIScriptParseData::TNSmlCGIScriptParseData() :
+    iDataType(ENSmlCGIScriptDataTypeUnKnown),
+    iComparator(ENSmlCGIScriptComparatorNull),
+    iSeparator(ENSmlCGIScriptLogicalOperatorNull),
+    iParseDataReady(EFalse){}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/src/NSmlCGIScriptParseStateInfo.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or 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:  CGI parser and generator
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "nsmlcgiscriptparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParseStateInfo::TNSmlCGIScriptParseStateInfo
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptParser::TNSmlCGIScriptParseStateInfo::TNSmlCGIScriptParseStateInfo(
+    const TDesC* aCGIScript,
+    const CArrayPtr<TNSmlDataTypesForCGIScriptNames>* aDatatypes) : 
+
+    iState(ENSmlCGIScriptParseStateKeyWord), 
+    iNextState(ENSmlCGIScriptParseStateKeyWord),
+    iCGIScript(aCGIScript),
+    iDatatypes(aDatatypes),
+    iStartPos(0),
+    iCurrPos(0){}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/cgiscriptutils/src/nsmlcgiscriptparser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,889 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or 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:  CGI parser and generator
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <escapeutils.h>
+
+#include "nsmlcgiscriptparser.h"
+#include "nsmlconstants.h" //PtrArrCleanupItem
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::TNSmlCGIScriptParser
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlCGIScriptParser::TNSmlCGIScriptParser()
+    {
+    //logical separator table initialization
+    KNSmlCGIScriptLogSep[ENSmlCGIScriptLogicalOperatorAnd] = &KNSmlCGIScriptLogicalSeparatorAndStr;
+    KNSmlCGIScriptLogSep[ENSmlCGIScriptLogicalOperatorOr] = &KNSmlCGIScriptLogicalSeparatorOrStr;
+
+    //logical operator table initialization
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorEqualToCaseSensitive] = &KNSmlCGIScriptComparatorEqualToCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorEqualToCaseInSensitive] = &KNSmlCGIScriptComparatorEqualToCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorNotEqualToCaseSensitive] = &KNSmlCGIScriptComparatorNotEqualToCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorNotEqualToCaseInSensitive] = &KNSmlCGIScriptComparatorNotEqualToCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorGreaterThanCaseSensitive] = &KNSmlCGIScriptComparatorGreaterThanCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorGreaterThanCaseInSensitive] = &KNSmlCGIScriptComparatorGreaterThanCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorGreaterThanOrEqualToCaseSensitive] = &KNSmlCGIScriptComparatorGreaterThanOrEqualToCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorGreaterThanOrEqualToCaseInSensitive] = &KNSmlCGIScriptComparatorGreaterThanOrEqualToCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorLessThanCaseSensitive] = &KNSmlCGIScriptComparatorLessThanCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorLessThanCaseInSensitive] = &KNSmlCGIScriptComparatorLessThanCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorLessThanOrEqualCaseSensitive] = &KNSmlCGIScriptComparatorLessThanOrEqualCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorLessThanOrEqualCaseInSensitive] = &KNSmlCGIScriptComparatorLessThanOrEqualCaseInSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorContainsValueCaseSensitive] = &KNSmlCGIScriptComparatorContainsValueCaseSensitiveStr; 
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorContainsValueCaseInSensitive] = &KNSmlCGIScriptComparatorContainsValueCaseInSensitiveStr;
+    KNSmlCGIScriptLogOps[ENSmlCGIScriptComparatorNull] = &KNSmlCGIScriptNullStr;
+
+    //special usage table initialization
+    KNSmlCGIScriptSpecialUsageStrings[0] = &KNSmlCGIScriptNullValue;
+    KNSmlCGIScriptSpecialUsageStrings[1] = &KNSmlCGIScriptLuidValue;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TNSmlCGIScriptParser::ParseL(
+    CNSmlCGIScript& aSp, 
+    const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes) const
+    {
+
+    aSp.Clear();
+
+    TNSmlCGIScriptParseStateInfo psInfo(aSp.CGIScript(), &aDatatypes);
+    
+    if (psInfo.iCGIScript == NULL)
+        {
+        return;
+        }
+    
+    TNSmlCGIScriptParseData pd;
+
+    //Main parse loop
+    for ( psInfo.iCurrPos = 0; psInfo.iCurrPos < psInfo.iCGIScript->Length();
+        psInfo.iCurrPos++ )
+        {
+        if ( IsParseSplitPoint(*psInfo.iCGIScript, psInfo.iCurrPos) )
+            {
+            for (psInfo.iState = psInfo.iNextState; ParseStateL(psInfo, pd); 
+                 psInfo.iState = psInfo.iNextState )
+                {
+                }
+
+            if ( pd.iParseDataReady )
+                {
+                AddScriptPartL( aSp, pd );
+                pd.iParseDataReady = EFalse;
+                }
+            psInfo.iStartPos = psInfo.iCurrPos + 1;
+            }
+        }
+
+    // parsing script's last value
+    psInfo.iState = psInfo.iNextState;
+    ParseStateL( psInfo, pd );
+    if ( pd.iParseDataReady )
+        {
+        AddScriptPartL( aSp, pd );
+        }
+    else{
+        User::Leave( ENSmlCGIParserErrorParsing );
+        }
+
+    aSp.SetLogicalOperator( pd.iSeparator );
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::GenerateL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TNSmlCGIScriptParser::GenerateL(CNSmlCGIScript& aSp) const
+    {
+    typedef CArrayPtrFlat<HBufC> CBufParts;
+    CBufParts* bufParts = new (ELeave) CBufParts(aSp.Count());
+    CleanupStack::PushL( PtrArrCleanupItem(HBufC, bufParts) );
+    TInt i;
+
+    //generates all script parts and appends them to array.
+    for (i = 0;i < aSp.Count();i++)
+        {
+        const TNSmlCGIScriptPart* sp = aSp.Get(i);
+        HBufC* bufTmp = GenerateScriptPartL(*sp);
+
+        CleanupStack::PushL(bufTmp);
+        bufParts->AppendL(bufTmp);
+        CleanupStack::Pop(bufTmp);
+        }
+
+    //collects all parts to a single CGI script.
+    SetCGIScriptL(aSp, *bufParts);
+        
+    CleanupStack::PopAndDestroy(bufParts);
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::IsParseSplitPoint
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::IsParseSplitPoint(const TDesC& aCGIScript, TInt aStartFrom) const
+    {
+    if (aCGIScript[aStartFrom] == '&')
+        {
+        for (TInt i(0); i < KNSmlCGIScriptSpecialUsageStringsCount; i++)
+            {
+            if (Compare(*KNSmlCGIScriptSpecialUsageStrings[i], aCGIScript, aStartFrom))
+                {
+                return EFalse;
+                }
+            }
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseStateL
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::ParseStateL(
+    TNSmlCGIScriptParseStateInfo & aPSInfo, 
+    TNSmlCGIScriptParseData & aPD) const
+    {
+    TBool retV(ETrue);
+
+    switch (aPSInfo.iState)
+        {
+        case ENSmlCGIScriptParseStateKeyWord:
+            aPD.iKeyword.Set(aPSInfo.iCGIScript->Mid(aPSInfo.iStartPos, 
+                aPSInfo.iCurrPos - aPSInfo.iStartPos));
+            aPD.iDataType = FindDataTypeL(*aPSInfo.iDatatypes, aPD.iKeyword);
+
+            if (aPD.iDataType == ENSmlCGIScriptDataTypeNoValue)
+                {
+                aPSInfo.iNextState = ENSmlCGIScriptParseStateLogSep;
+                aPD.iValue.Set(TPtrC());
+                aPD.iComparator = ENSmlCGIScriptComparatorNull;
+                aPD.iParseDataReady = ETrue;
+                }
+            else
+                {
+                aPSInfo.iNextState = ENSmlCGIScriptParseStateLogOp;
+                }
+            break;
+        case ENSmlCGIScriptParseStateLogOp:
+            aPD.iComparator = LogOpL(*aPSInfo.iCGIScript,
+                aPSInfo.iCurrPos + 1);
+            aPSInfo.iCurrPos += LogOpL(aPD.iComparator).Length() - 1;
+            aPSInfo.iNextState = ENSmlCGIScriptParseStateValue;
+            retV = EFalse;
+            break;
+        case ENSmlCGIScriptParseStateValue:
+            {
+            aPD.iValue.Set(aPSInfo.iCGIScript->Mid(aPSInfo.iStartPos, 
+                aPSInfo.iCurrPos - aPSInfo.iStartPos));
+
+            aPSInfo.iNextState = ENSmlCGIScriptParseStateLogSep;
+            aPD.iParseDataReady = ETrue;
+            break;
+            }
+        case ENSmlCGIScriptParseStateLogSep:
+            {
+            TNSmlCGIScriptLogicalOperator loTmp(
+                LogSepL(*aPSInfo.iCGIScript, aPSInfo.iCurrPos + 1) );
+
+            if ( aPD.iSeparator != ENSmlCGIScriptLogicalOperatorNull && 
+                (loTmp != aPD.iSeparator) )
+                {
+                //Error: query may contain only 1 type of logical separator
+                User::Leave(ENSmlCGIParserErrorWrongSeparator);
+                }
+            aPD.iSeparator = loTmp;
+
+            aPSInfo.iCurrPos += LogSepL( aPD.iSeparator ).Length() - 1;
+            aPSInfo.iNextState = ENSmlCGIScriptParseStateKeyWord;
+            retV = EFalse;
+            }
+            break;
+        default:
+            User::Leave(ENSmlCGIParserErrorParsing);
+            break;
+        }
+    return retV;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::AddScriptPartL
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::AddScriptPartL(CNSmlCGIScript& aSp, 
+    TNSmlCGIScriptParseData& aPD)
+    {
+
+    TNSmlCGIScriptDataType datatype(aPD.iDataType);
+
+    TNSmlCGIScriptPart* sp = new (ELeave) TNSmlCGIScriptPart;
+    CleanupStack::PushL(sp);
+
+    sp->iData = NULL;
+    sp->iName = HBufC::NewLC(aPD.iKeyword.Length());
+    *(sp->iName) = aPD.iKeyword;
+
+    sp->iComparator = aPD.iComparator;
+    sp->iDataType = datatype;
+
+    TBool retV = ParseScriptPartDataLC(*sp, aPD.iValue);
+
+    CheckScriptPartValidityL(*sp);
+
+    if (retV)
+        {
+        aSp.AddL(sp);
+        CleanupStack::Pop(3); //ParseScriptPartDataLC:stä, sp->iName,sp;
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy(2); //sp->iName, sp
+        sp->iName = NULL;
+        sp = NULL;
+        }
+    return retV;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseScriptPartDataLC
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::ParseScriptPartDataLC(
+    TNSmlCGIScriptPart& aSp, 
+    const TPtrC& aValue)
+    {
+    TNSmlCGIScriptDataType datatype( (aValue == KNSmlCGIScriptNullValue) 
+        ? ENSmlCGIScriptDataTypeNull : aSp.iDataType );
+
+    TBool retV(ETrue);
+
+    // in each case - sentence, either push something to cleanupstack, 
+    // set retV to EFalse or leave
+    switch (datatype)
+        {
+        case ENSmlCGIScriptDataTypeHBufC:
+            {
+            aSp.iData = EscapeUtils::EscapeDecodeL(aValue);
+            CleanupStack::PushL(aSp.iData);
+            }
+            break;
+        case ENSmlCGIScriptDataTypeDateTime:
+        case ENSmlCGIScriptDataTypeDate:
+            {
+            TDateTime* dt = new (ELeave) TDateTime();
+            CleanupStack::PushL(dt);
+            TInt num = ParseDateTimeL(*dt, aValue);
+
+            switch(num)
+                {
+                case KNSmlCGIParserDateTimeLen:
+                    aSp.iDataType = ENSmlCGIScriptDataTypeDateTime;
+                    break;
+                case KNSmlCGIParserDateLen:
+                    aSp.iDataType = ENSmlCGIScriptDataTypeDate;
+                    break;
+                default:
+                    User::Leave(ENSmlCGIParserErrorConversion);
+                    break;
+                }
+            aSp.iData = dt;
+            }
+            break;
+        case ENSmlCGIScriptDataTypeNumber:
+            {
+            TInt* num = new (ELeave) TInt();
+            CleanupStack::PushL(num);
+            *num = ParseIntL(aValue, 0, aValue.Length());
+            aSp.iData = num;
+            }
+            break;
+        case ENSmlCGIScriptDataTypeBoolean:
+            {
+            TBool* bln = new (ELeave) TBool;
+            CleanupStack::PushL(bln);
+            *bln = ParseBoolL(aValue);
+            aSp.iData = bln;
+            }
+            break;
+        case ENSmlCGIScriptDataTypeNoValue:
+        case ENSmlCGIScriptDataTypeNull:
+            aSp.iData = NULL;
+            CleanupStack::PushL(aSp.iData);
+            break;
+        default: // TNSmlCGIScriptDataTypeUnKnown
+            User::Leave(ENSmlCGIParserErrorConversion);
+            break;
+        }
+
+    return retV;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::FindDataTypeL
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptDataType TNSmlCGIScriptParser::FindDataTypeL(
+    const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes, 
+    const TPtrC& aKeyword)
+    {
+    TNSmlCGIScriptDataType dt(FindDataType(aDatatypes, aKeyword));
+    if (dt == ENSmlCGIScriptDataTypeUnKnown)
+        {
+        User::Leave(ENSmlCGIParserErrorDataTypeNotFound);
+        }
+    return dt;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::FindDataType
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptDataType TNSmlCGIScriptParser::FindDataType(
+    const CArrayPtr<TNSmlDataTypesForCGIScriptNames>& aDatatypes, 
+    const TPtrC& aKeyword)
+    {
+    TNSmlDataTypesForCGIScriptNames* tmp;
+
+    for (TInt i = 0; i < aDatatypes.Count(); i++)
+        {
+        tmp = aDatatypes[i];
+        if (*tmp->iKeywordOrProperty == aKeyword)
+            {
+            return tmp->iDataType;
+            }
+        }
+    return ENSmlCGIScriptDataTypeUnKnown;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::GenerateScriptPartL
+// -----------------------------------------------------------------------------
+//
+HBufC* TNSmlCGIScriptParser::GenerateScriptPartL(
+    const TNSmlCGIScriptPart& aSp) const
+    {
+
+    CheckScriptPartValidityL(aSp);
+
+    TInt len(LogOpL(aSp.iComparator).Length() + aSp.iName->Length());
+    TAny* value = NULL;
+    TBool destroyValue(EFalse);
+    TNSmlCGIScriptDataType dataType(aSp.iDataType);
+
+    if (aSp.iData == NULL && dataType != ENSmlCGIScriptDataTypeNoValue)
+        {
+        dataType = ENSmlCGIScriptDataTypeNull;
+        }
+
+    if (dataType == ENSmlCGIScriptDataTypeHBufC)
+        {
+        HBufC* buf = EscapeUtils::EscapeEncodeL( 
+            *reinterpret_cast<HBufC*>(aSp.iData), KNSmlCGIParserReservedChars );
+        CleanupStack::PushL(buf);
+        len += buf->Length();
+        destroyValue = ETrue;
+        value = buf;
+        }
+    else
+        {
+        len += 32;              //enough for datetime, number, boolean etc.
+        value = reinterpret_cast<TAny*>(aSp.iData);
+        }
+
+    HBufC* bufTmp = HBufC::NewLC(len);
+    TPtr ptr(bufTmp->Des());
+
+    ptr.Append(*aSp.iName);
+    ptr.Append( LogOpL(aSp.iComparator) );
+    GenerateScriptPartValueL(dataType, value, ptr);
+
+    CleanupStack::Pop(bufTmp);
+
+    if (destroyValue)
+        {
+        CleanupStack::PopAndDestroy(value);
+        }
+
+    return bufTmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::GenerateScriptPartValueL
+// -----------------------------------------------------------------------------
+//
+void TNSmlCGIScriptParser::GenerateScriptPartValueL(
+    TNSmlCGIScriptDataType aDataType, 
+    const TAny *aValue,
+    TPtr & aPtr)
+    {
+
+    switch (aDataType)
+        {
+        case ENSmlCGIScriptDataTypeHBufC:
+            {
+            aPtr.Append( *reinterpret_cast<const HBufC*>(aValue) );
+            break;
+            }
+        case ENSmlCGIScriptDataTypeDate:
+            {
+            const TDateTime* dt = reinterpret_cast<const TDateTime*>(aValue);
+            TBuf<KNSmlCGIParserDateLen> des;
+            GenerateDateTimeValue(*dt, des, EFalse);
+            aPtr.Append(des);
+            }
+            break;
+        case ENSmlCGIScriptDataTypeDateTime:
+            {
+            const TDateTime* dt = reinterpret_cast<const TDateTime*>(aValue);
+            TBuf<KNSmlCGIParserDateTimeLen> des;
+            GenerateDateTimeValue(*dt, des, ETrue);
+            aPtr.Append(des);
+            }
+            break;
+        case ENSmlCGIScriptDataTypeNumber:
+            {
+            TBuf<32> des;
+            const TInt* num = reinterpret_cast<const TInt*>(aValue);
+            des.Num(*num);
+            aPtr.Append(des);
+            }
+            break;
+        case ENSmlCGIScriptDataTypeBoolean:
+            {
+            const TBool* bln = reinterpret_cast<const TBool*>(aValue);
+            aPtr.Append(GenerateBoolValue(*bln));
+            }
+            break;
+        case ENSmlCGIScriptDataTypeNull:
+            aPtr.Append(KNSmlCGIScriptNullValue);
+            break;
+        case ENSmlCGIScriptDataTypeNoValue:
+            //empty
+            break;
+        default: //TNSmlCGIScriptDataTypeUnKnown
+            User::Leave(ENSmlCGIParserErrorConversion);
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::SetCGIScriptL
+// -----------------------------------------------------------------------------
+//
+void TNSmlCGIScriptParser::SetCGIScriptL(
+    CNSmlCGIScript& aSp, 
+    CArrayPtr<HBufC>& aBufParts ) const
+    {
+
+    TInt bufPartsCount(aBufParts.Count());
+    TInt i(0);
+    TInt scriptLen(0);
+
+    if (bufPartsCount > 0)
+        {
+
+        //length of entire script
+        for (i = 0; i < bufPartsCount; i++)
+            {
+            scriptLen += aBufParts.At(i)->Length();
+            }
+
+        //adds length of separator between two scriptparts
+        if (bufPartsCount > 1)
+            {
+            scriptLen += (bufPartsCount - 1) * 
+                LogSepL(aSp.LogicalOperator()).Length();
+            }
+
+        //reserves needed memory
+        HBufC* bufTmp = HBufC::NewLC(scriptLen);
+        TPtr ptr(bufTmp->Des());
+
+        //appends all parts to a full script.
+        for (i = 0; i < bufPartsCount;i++)
+            {
+            ptr.Append(*aBufParts.At(i));
+            if (i < (bufPartsCount - 1))
+                {
+                ptr.Append(LogSepL(aSp.LogicalOperator()));
+                }
+            }
+
+        aSp.SetCGIScriptL(*bufTmp);
+        CleanupStack::PopAndDestroy(bufTmp);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseDateTimeL
+// -----------------------------------------------------------------------------
+//
+TInt TNSmlCGIScriptParser::ParseDateTimeL(
+    TDateTime& aDateTime, 
+    const TDesC& aDes, 
+    TInt aStartFrom)
+    {
+
+    enum TDateParseState{ 
+        EDateParseStateDate, 
+        EDateParseStateTime, 
+        EDateParseStateCheckUTC, 
+        EDateParseStateDone};
+
+    TDateParseState stateAfterDate(EDateParseStateTime);
+
+    switch (aDes.Length())
+        {
+        case KNSmlCGIParserDateLen:
+            stateAfterDate = EDateParseStateDone;
+            break;
+        case KNSmlCGIParserDateTimeLen:
+            stateAfterDate = EDateParseStateTime;
+            break;
+        default:
+            User::Leave(ENSmlCGIParserErrorConversion);
+        }
+
+    TInt ind(aStartFrom);
+    const TInt8 DateItemLengths[] = {4, 2, 2, 2, 2, 2};
+    TInt DateValues[6] = {0, 0, 0, 0, 0, 0};
+
+    TDateParseState state(EDateParseStateDate);
+    TDateParseState nextState(state);
+
+    TInt i(0);
+    TInt upto(0);
+
+    while (state != EDateParseStateDone)
+        {
+        switch (state)
+            {
+            case EDateParseStateDate:
+                i = 0;
+                upto = 3;
+                nextState = stateAfterDate;
+                break;
+            case EDateParseStateTime:
+                if (aDes[ind] != 'T')
+                    {
+                    User::Leave(ENSmlCGIParserErrorConversion);
+                    }
+                ind++;
+                upto = 6;
+                nextState = EDateParseStateCheckUTC;
+                break;
+            case EDateParseStateCheckUTC:
+
+                // must be UTC, marked by Z
+                if (aDes[ind] != 'Z')
+                    {
+                    User::Leave(ENSmlCGIParserErrorConversion);
+                    }
+                ind++;
+                state = EDateParseStateDone;
+                break;
+            default:
+                User::Leave(KErrGeneral);
+                break;
+            }
+
+        if (state != EDateParseStateDone)
+            {
+            for (; i < upto;i++)
+                {
+                TInt len(DateItemLengths[i]);
+                DateValues[i] = ParseIntL(aDes, ind, len);
+                ind += len;
+                }
+            state = nextState;
+            }
+        }
+    
+    TInt err(aDateTime.Set(DateValues[0], 
+        static_cast<TMonth>(DateValues[1] - 1), DateValues[2], 
+        DateValues[3], DateValues[4], DateValues[5], 0));
+
+    User::LeaveIfError(err);
+    return(ind - aStartFrom);
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::GenerateDateTimeValue
+// -----------------------------------------------------------------------------
+//
+void TNSmlCGIScriptParser::GenerateDateTimeValue(
+    const TDateTime& aDateTime, 
+    TDes& aDes, 
+    TBool aUseTimePart)
+    {
+
+    if (aUseTimePart)
+        {
+        aDes.Format(KNSmlCGIParserDateTimeFormat, aDateTime.Year(), 
+            aDateTime.Month() + 1, aDateTime.Day(), 
+            aDateTime.Hour(), aDateTime.Minute(), aDateTime.Second());
+        }
+    else
+        {
+        aDes.Format(KNSmlCGIParserDateFormat, aDateTime.Year(),
+            aDateTime.Month() + 1, aDateTime.Day());
+        }
+}
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::GenerateBoolValue
+// -----------------------------------------------------------------------------
+//
+const TDesC & TNSmlCGIScriptParser::GenerateBoolValue(TBool aBool)
+    {
+
+    if (aBool)
+        {
+        return KNSmlCGIScriptBoolTrue;
+        }
+    else
+        {
+        return KNSmlCGIScriptBoolFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseIntL
+// -----------------------------------------------------------------------------
+//
+TInt TNSmlCGIScriptParser::ParseIntL(
+    const TDesC& aDes, 
+    TInt aStartFrom, 
+    TInt aLength)
+    {
+
+    TInt num(0);
+    TPtrC des(aDes.Mid(aStartFrom, aLength));
+    TLex lex(des);    
+    TInt t = lex.Val(num);
+    if (t != KErrNone)
+        {
+        User::Leave(t);
+        }
+    if (!lex.Eos())
+        {
+        User::Leave(ENSmlCGIParserErrorConversion);
+        }
+    return num;
+
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::ParseBoolL
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::ParseBoolL(
+    const TDesC& aDes, 
+    TInt aStartFrom)
+    {
+    TBool bln(EFalse);
+    const TDesC* cmp = NULL;
+
+    if ( Compare(*(cmp = &GenerateBoolValue(ETrue)), aDes, aStartFrom) )
+        {
+        bln = ETrue;
+        }
+    else if ( Compare(*(cmp = &GenerateBoolValue(EFalse)), aDes, aStartFrom) )
+        {
+        bln = EFalse;
+        }
+    else
+        {
+        User::Leave(ENSmlCGIParserErrorConversion);
+        }
+
+    if ( cmp->Length() != (aDes.Length() - aStartFrom) )
+        {
+        User::Leave(ENSmlCGIParserErrorConversion);
+        }
+    
+    return bln;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::LogOpL
+// -----------------------------------------------------------------------------
+//
+const TDesC& TNSmlCGIScriptParser::LogOpL(TNSmlCGIScriptComparator aComp) const
+    {
+    if ( aComp < KNSmlCGIParserLogOpsCount) //range check
+        {
+        return *KNSmlCGIScriptLogOps[aComp];
+        }
+    else
+        {
+        User::Leave(ENSmlCGIParserErrorWrongOperator);
+        }
+    return KNSmlCGIScriptNullStr;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::LogOpL
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptComparator TNSmlCGIScriptParser::LogOpL(
+    const TDesC& aDes, 
+    TInt aInd) const
+    {
+
+     for (TInt i = 0; i < KNSmlCGIParserLogOpsCount; i++)
+        {
+        TNSmlCGIScriptComparator lo(
+            static_cast<TNSmlCGIScriptComparator>(i));
+
+        if (Compare(LogOpL(lo), aDes, aInd-1))
+            {
+            return lo;
+            }
+        }
+    User::Leave(ENSmlCGIParserErrorWrongOperator);
+
+    return ENSmlCGIScriptComparatorNull;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::LogSepL
+// -----------------------------------------------------------------------------
+//
+const TDesC & TNSmlCGIScriptParser::LogSepL(
+    TNSmlCGIScriptLogicalOperator aLogSep) const
+    {
+    
+    if ( aLogSep < KNSmlCGIScriptLogSepCount) //range check
+        {
+        return *KNSmlCGIScriptLogSep[aLogSep];
+        }
+    else
+        {
+        User::Leave(ENSmlCGIParserErrorWrongSeparator);
+        }
+
+    return KNSmlCGIScriptNullStr;
+
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::LogSepL
+// -----------------------------------------------------------------------------
+//
+TNSmlCGIScriptLogicalOperator TNSmlCGIScriptParser::LogSepL(
+    const TDesC& aDes, 
+    TInt aInd) const
+    {
+
+    for (TInt i = 0; i < KNSmlCGIScriptLogSepCount; i++)
+        {
+        TNSmlCGIScriptLogicalOperator lo(
+            static_cast<TNSmlCGIScriptLogicalOperator>(i));
+
+        if (Compare(LogSepL(lo), aDes, aInd-1))
+            {
+            return lo;
+            }
+        }
+    User::Leave(ENSmlCGIParserErrorWrongSeparator);
+    return ENSmlCGIScriptLogicalOperatorNull;
+
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::IsEqualityOperator
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::IsEqualityOperator(TNSmlCGIScriptComparator comp)
+    {
+    if (comp >= ENSmlCGIScriptComparatorEqualToCaseSensitive 
+        && comp <= ENSmlCGIScriptComparatorNotEqualToCaseInSensitive)
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::CheckScriptPartValidityL
+// -----------------------------------------------------------------------------
+//
+void TNSmlCGIScriptParser::CheckScriptPartValidityL(const TNSmlCGIScriptPart & aSp)
+    {
+    if (aSp.iData == NULL)
+        {
+        if (aSp.iDataType == ENSmlCGIScriptDataTypeNoValue)
+            {
+            if (aSp.iComparator != ENSmlCGIScriptComparatorNull)
+                {
+                User::Leave(ENSmlCGIParserErrorWrongOperator);
+                }
+            }
+        else if ( !IsEqualityOperator(aSp.iComparator) )
+            {
+            User::Leave(ENSmlCGIParserErrorWrongOperator);
+            }
+        }
+    else
+        {
+        if (aSp.iDataType == ENSmlCGIScriptDataTypeNoValue)
+            {
+            User::Leave(ENSmlCGIParserErrorConversion);
+            }
+        if (aSp.iComparator == ENSmlCGIScriptComparatorNull)
+            {
+            User::Leave(ENSmlCGIParserErrorWrongOperator);
+            }
+        }
+    if (aSp.iName == NULL)
+        {
+        User::Leave(ENSmlCGIParserErrorNoKeyword);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TNSmlCGIScriptParser::Compare
+// -----------------------------------------------------------------------------
+//
+TBool TNSmlCGIScriptParser::Compare(
+    const TDesC& aWhat, 
+    const TDesC& aWhere, 
+    TInt aStartFrom)
+    {
+
+    if((aWhere.Length() - aStartFrom) < aWhat.Length())
+        {
+        return EFalse; //aWhat is longer than what's left in aWhere. No match
+        }
+    TBuf<32> buf( aWhere.Mid(aStartFrom, aWhat.Length()) );
+    return ( buf.Compare(aWhat) == 0 );
+
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/bld/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  EMail XML Utils build file.
+*
+*/
+
+
+PRJ_MMPFILES
+./nsmlxmlparser.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/bld/def/bwinscwxmlparseru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,45 @@
+EXPORTS
+	??0CNSmlXmlParser@@QAE@XZ @ 1 NONAME ; CNSmlXmlParser::CNSmlXmlParser(void)
+	??0TNSmlFolderAttributeData@@QAE@XZ @ 2 NONAME ; TNSmlFolderAttributeData::TNSmlFolderAttributeData(void)
+	??1CNSmlEmailFileParser@@UAE@XZ @ 3 NONAME ; CNSmlEmailFileParser::~CNSmlEmailFileParser(void)
+	??1CNSmlEmailParser@@UAE@XZ @ 4 NONAME ; CNSmlEmailParser::~CNSmlEmailParser(void)
+	??1CNSmlExtData@@UAE@XZ @ 5 NONAME ; CNSmlExtData::~CNSmlExtData(void)
+	??1CNSmlFolderParser@@UAE@XZ @ 6 NONAME ; CNSmlFolderParser::~CNSmlFolderParser(void)
+	??1CNSmlTruncatedData@@UAE@XZ @ 7 NONAME ; CNSmlTruncatedData::~CNSmlTruncatedData(void)
+	??1CNSmlXmlParser@@UAE@XZ @ 8 NONAME ; CNSmlXmlParser::~CNSmlXmlParser(void)
+	?AddAttachmentL@CNSmlTruncatedData@@QAEXPAVHBufC8@@H0@Z @ 9 NONAME ; void CNSmlTruncatedData::AddAttachmentL(class HBufC8 *, int, class HBufC8 *)
+	?AddBodyL@CNSmlTruncatedData@@QAEXHPAVHBufC8@@@Z @ 10 NONAME ; void CNSmlTruncatedData::AddBodyL(int, class HBufC8 *)
+	?AddExtL@CNSmlEmailParser@@QAEXPAVCNSmlExtData@@@Z @ 11 NONAME ; void CNSmlEmailParser::AddExtL(class CNSmlExtData *)
+	?AddExtL@CNSmlFolderParser@@QAEXPAVCNSmlExtData@@@Z @ 12 NONAME ; void CNSmlFolderParser::AddExtL(class CNSmlExtData *)
+	?AddXValL@CNSmlExtData@@QAEXPAVHBufC8@@@Z @ 13 NONAME ; void CNSmlExtData::AddXValL(class HBufC8 *)
+	?AttributeCount@TNSmlFolderAttributeData@@QBEHXZ @ 14 NONAME ; int TNSmlFolderAttributeData::AttributeCount(void) const
+	?ConvertIntoEntitiesL@CNSmlExtData@@QAEXPBVCNSmlXmlParser@@@Z @ 15 NONAME ; void CNSmlExtData::ConvertIntoEntitiesL(class CNSmlXmlParser const *)
+	?ConvertIntoEntitiesL@CNSmlTruncatedData@@QAEXPBVCNSmlXmlParser@@@Z @ 16 NONAME ; void CNSmlTruncatedData::ConvertIntoEntitiesL(class CNSmlXmlParser const *)
+	?CountXmlSize@CNSmlExtData@@QBEHPBVCNSmlXmlParser@@@Z @ 17 NONAME ; int CNSmlExtData::CountXmlSize(class CNSmlXmlParser const *) const
+	?CountXmlSize@TNSmlFolderAttributeData@@QBEHPBVCNSmlXmlParser@@@Z @ 18 NONAME ; int TNSmlFolderAttributeData::CountXmlSize(class CNSmlXmlParser const *) const
+	?CountXmlSizeL@CNSmlEmailFileParser@@UAEHXZ @ 19 NONAME ; int CNSmlEmailFileParser::CountXmlSizeL(void)
+	?CountXmlSizeL@CNSmlEmailParser@@UAEHXZ @ 20 NONAME ; int CNSmlEmailParser::CountXmlSizeL(void)
+	?CountXmlSizeL@CNSmlFolderParser@@UAEHXZ @ 21 NONAME ; int CNSmlFolderParser::CountXmlSizeL(void)
+	?CountXmlSizeL@CNSmlTruncatedData@@QBEHPBVCNSmlXmlParser@@@Z @ 22 NONAME ; int CNSmlTruncatedData::CountXmlSizeL(class CNSmlXmlParser const *) const
+	?GenerateXml@CNSmlEmailFileParser@@UAE?AW4TNSmlParserGeneratorError@@AAPAVHBufC8@@@Z @ 23 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailFileParser::GenerateXml(class HBufC8 * &)
+	?GenerateXml@CNSmlEmailFileParser@@UAE?AW4TNSmlParserGeneratorError@@AAVRWriteStream@@@Z @ 24 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailFileParser::GenerateXml(class RWriteStream &)
+	?GenerateXml@CNSmlEmailParser@@UAE?AW4TNSmlParserGeneratorError@@AAPAVHBufC8@@@Z @ 25 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailParser::GenerateXml(class HBufC8 * &)
+	?GenerateXml@CNSmlFolderParser@@UAE?AW4TNSmlParserGeneratorError@@AAPAVHBufC8@@@Z @ 26 NONAME ; enum TNSmlParserGeneratorError CNSmlFolderParser::GenerateXml(class HBufC8 * &)
+	?GenerateXml@TNSmlFolderAttributeData@@QBEXAAVTPtr8@@PBVCNSmlXmlParser@@@Z @ 27 NONAME ; void TNSmlFolderAttributeData::GenerateXml(class TPtr8 &, class CNSmlXmlParser const *) const
+	?GenerateXmlL@CNSmlExtData@@QBEXAAVTPtr8@@PBVCNSmlXmlParser@@@Z @ 28 NONAME ; void CNSmlExtData::GenerateXmlL(class TPtr8 &, class CNSmlXmlParser const *) const
+	?GenerateXmlL@CNSmlTruncatedData@@QBEXAAVTPtr8@@PBVCNSmlXmlParser@@@Z @ 29 NONAME ; void CNSmlTruncatedData::GenerateXmlL(class TPtr8 &, class CNSmlXmlParser const *) const
+	?NewL@CNSmlEmailFileParser@@SAPAV1@XZ @ 30 NONAME ; class CNSmlEmailFileParser * CNSmlEmailFileParser::NewL(void)
+	?NewL@CNSmlEmailParser@@SAPAV1@XZ @ 31 NONAME ; class CNSmlEmailParser * CNSmlEmailParser::NewL(void)
+	?NewL@CNSmlExtData@@SAPAV1@XZ @ 32 NONAME ; class CNSmlExtData * CNSmlExtData::NewL(void)
+	?NewL@CNSmlFolderParser@@SAPAV1@XZ @ 33 NONAME ; class CNSmlFolderParser * CNSmlFolderParser::NewL(void)
+	?NewL@CNSmlTruncatedData@@SAPAV1@XZ @ 34 NONAME ; class CNSmlTruncatedData * CNSmlTruncatedData::NewL(void)
+	?NewLC@CNSmlEmailFileParser@@SAPAV1@XZ @ 35 NONAME ; class CNSmlEmailFileParser * CNSmlEmailFileParser::NewLC(void)
+	?NewLC@CNSmlEmailParser@@SAPAV1@XZ @ 36 NONAME ; class CNSmlEmailParser * CNSmlEmailParser::NewLC(void)
+	?NewLC@CNSmlExtData@@SAPAV1@XZ @ 37 NONAME ; class CNSmlExtData * CNSmlExtData::NewLC(void)
+	?NewLC@CNSmlFolderParser@@SAPAV1@XZ @ 38 NONAME ; class CNSmlFolderParser * CNSmlFolderParser::NewLC(void)
+	?NewLC@CNSmlTruncatedData@@SAPAV1@XZ @ 39 NONAME ; class CNSmlTruncatedData * CNSmlTruncatedData::NewLC(void)
+	?ParseXml@CNSmlEmailFileParser@@UAE?AW4TNSmlParserGeneratorError@@AAVRReadStream@@@Z @ 40 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailFileParser::ParseXml(class RReadStream &)
+	?ParseXml@CNSmlEmailFileParser@@UAE?AW4TNSmlParserGeneratorError@@PAVHBufC8@@@Z @ 41 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailFileParser::ParseXml(class HBufC8 *)
+	?ParseXml@CNSmlEmailParser@@UAE?AW4TNSmlParserGeneratorError@@PAVHBufC8@@@Z @ 42 NONAME ; enum TNSmlParserGeneratorError CNSmlEmailParser::ParseXml(class HBufC8 *)
+	?ParseXml@CNSmlFolderParser@@UAE?AW4TNSmlParserGeneratorError@@PAVHBufC8@@@Z @ 43 NONAME ; enum TNSmlParserGeneratorError CNSmlFolderParser::ParseXml(class HBufC8 *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/bld/def/eabixmlparseru.def	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,70 @@
+EXPORTS
+	_ZN12CNSmlExtData20ConvertIntoEntitiesLEPK14CNSmlXmlParser @ 1 NONAME
+	_ZN12CNSmlExtData4NewLEv @ 2 NONAME
+	_ZN12CNSmlExtData5NewLCEv @ 3 NONAME
+	_ZN12CNSmlExtData8AddXValLEP6HBufC8 @ 4 NONAME
+	_ZN12CNSmlExtDataD0Ev @ 5 NONAME
+	_ZN12CNSmlExtDataD1Ev @ 6 NONAME
+	_ZN12CNSmlExtDataD2Ev @ 7 NONAME
+	_ZN14CNSmlXmlParserC2Ev @ 8 NONAME
+	_ZN14CNSmlXmlParserD0Ev @ 9 NONAME
+	_ZN14CNSmlXmlParserD1Ev @ 10 NONAME
+	_ZN14CNSmlXmlParserD2Ev @ 11 NONAME
+	_ZN16CNSmlEmailParser11GenerateXmlERP6HBufC8 @ 12 NONAME
+	_ZN16CNSmlEmailParser13CountXmlSizeLEv @ 13 NONAME
+	_ZN16CNSmlEmailParser4NewLEv @ 14 NONAME
+	_ZN16CNSmlEmailParser5NewLCEv @ 15 NONAME
+	_ZN16CNSmlEmailParser7AddExtLEP12CNSmlExtData @ 16 NONAME
+	_ZN16CNSmlEmailParser8ParseXmlEP6HBufC8 @ 17 NONAME
+	_ZN16CNSmlEmailParserD0Ev @ 18 NONAME
+	_ZN16CNSmlEmailParserD1Ev @ 19 NONAME
+	_ZN16CNSmlEmailParserD2Ev @ 20 NONAME
+	_ZN17CNSmlFolderParser11GenerateXmlERP6HBufC8 @ 21 NONAME
+	_ZN17CNSmlFolderParser13CountXmlSizeLEv @ 22 NONAME
+	_ZN17CNSmlFolderParser4NewLEv @ 23 NONAME
+	_ZN17CNSmlFolderParser5NewLCEv @ 24 NONAME
+	_ZN17CNSmlFolderParser7AddExtLEP12CNSmlExtData @ 25 NONAME
+	_ZN17CNSmlFolderParser8ParseXmlEP6HBufC8 @ 26 NONAME
+	_ZN17CNSmlFolderParserD0Ev @ 27 NONAME
+	_ZN17CNSmlFolderParserD1Ev @ 28 NONAME
+	_ZN17CNSmlFolderParserD2Ev @ 29 NONAME
+	_ZN18CNSmlTruncatedData14AddAttachmentLEP6HBufC8iS1_ @ 30 NONAME
+	_ZN18CNSmlTruncatedData20ConvertIntoEntitiesLEPK14CNSmlXmlParser @ 31 NONAME
+	_ZN18CNSmlTruncatedData4NewLEv @ 32 NONAME
+	_ZN18CNSmlTruncatedData5NewLCEv @ 33 NONAME
+	_ZN18CNSmlTruncatedData8AddBodyLEiP6HBufC8 @ 34 NONAME
+	_ZN18CNSmlTruncatedDataD0Ev @ 35 NONAME
+	_ZN18CNSmlTruncatedDataD1Ev @ 36 NONAME
+	_ZN18CNSmlTruncatedDataD2Ev @ 37 NONAME
+	_ZN20CNSmlEmailFileParser11GenerateXmlER12RWriteStream @ 38 NONAME
+	_ZN20CNSmlEmailFileParser11GenerateXmlERP6HBufC8 @ 39 NONAME
+	_ZN20CNSmlEmailFileParser13CountXmlSizeLEv @ 40 NONAME
+	_ZN20CNSmlEmailFileParser4NewLEv @ 41 NONAME
+	_ZN20CNSmlEmailFileParser5NewLCEv @ 42 NONAME
+	_ZN20CNSmlEmailFileParser8ParseXmlEP6HBufC8 @ 43 NONAME
+	_ZN20CNSmlEmailFileParser8ParseXmlER11RReadStream @ 44 NONAME
+	_ZN20CNSmlEmailFileParserD0Ev @ 45 NONAME
+	_ZN20CNSmlEmailFileParserD1Ev @ 46 NONAME
+	_ZN20CNSmlEmailFileParserD2Ev @ 47 NONAME
+	_ZN24TNSmlFolderAttributeDataC1Ev @ 48 NONAME
+	_ZN24TNSmlFolderAttributeDataC2Ev @ 49 NONAME
+	_ZNK12CNSmlExtData12CountXmlSizeEPK14CNSmlXmlParser @ 50 NONAME
+	_ZNK12CNSmlExtData12GenerateXmlLER5TPtr8PK14CNSmlXmlParser @ 51 NONAME
+	_ZNK18CNSmlTruncatedData12GenerateXmlLER5TPtr8PK14CNSmlXmlParser @ 52 NONAME
+	_ZNK18CNSmlTruncatedData13CountXmlSizeLEPK14CNSmlXmlParser @ 53 NONAME
+	_ZNK24TNSmlFolderAttributeData11GenerateXmlER5TPtr8PK14CNSmlXmlParser @ 54 NONAME
+	_ZNK24TNSmlFolderAttributeData12CountXmlSizeEPK14CNSmlXmlParser @ 55 NONAME
+	_ZNK24TNSmlFolderAttributeData14AttributeCountEv @ 56 NONAME
+	_ZTI12CNSmlExtData @ 57 NONAME ; #<TI>#
+	_ZTI14CNSmlXmlParser @ 58 NONAME ; #<TI>#
+	_ZTI16CNSmlEmailParser @ 59 NONAME ; #<TI>#
+	_ZTI17CNSmlFolderParser @ 60 NONAME ; #<TI>#
+	_ZTI18CNSmlTruncatedData @ 61 NONAME ; #<TI>#
+	_ZTI20CNSmlEmailFileParser @ 62 NONAME ; #<TI>#
+	_ZTV12CNSmlExtData @ 63 NONAME ; #<VT>#
+	_ZTV14CNSmlXmlParser @ 64 NONAME ; #<VT>#
+	_ZTV16CNSmlEmailParser @ 65 NONAME ; #<VT>#
+	_ZTV17CNSmlFolderParser @ 66 NONAME ; #<VT>#
+	_ZTV18CNSmlTruncatedData @ 67 NONAME ; #<VT>#
+	_ZTV20CNSmlEmailFileParser @ 68 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/bld/nsmlxmlparser.mmp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  EMail XML Parser mmp file
+*
+*/
+
+
+#include "defaultcaps.hrh"
+#include <platform_paths.hrh>
+
+CAPABILITY	CAP_GENERAL_DLL
+VENDORID 	VID_DEFAULT
+TARGET          nsmlxmlparser.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x101F6DE4
+
+#if defined(ARMCC)
+DEFFILE		./def/eabixmlparser
+#elif defined(WINSCW)
+DEFFILE		./def/bwinscwxmlparser
+#elif defined(WINS)
+DEFFILE		./def/bwinsxmlparser
+#else
+DEFFILE		./def/bmarmxmlparser
+#endif
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE	../../../adapters/email/mtm/inc
+USERINCLUDE     ../inc
+
+SOURCEPATH      ../src
+SOURCE		nsmlxmlparser.cpp
+SOURCE          NSmlExtData.cpp
+SOURCE          NSmlFolderAttributeData.cpp
+SOURCE          NSmlTruncatedData.cpp
+SOURCE          NSmlEmailParser.cpp
+SOURCE          NSmlEmailFileParser.cpp
+SOURCE          NSmlFolderParser.cpp
+
+LIBRARY         euser.lib estor.lib efsrv.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/inc/nsmlxmlparser.h	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,659 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Email XML parser
+*
+*/
+
+
+// 1.2 Changes: nsmlxmlparser module added
+
+
+#ifndef __NSMLXMLPARSER_H__
+#define __NSMLXMLPARSER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include <s32strm.h>
+#include "nsmlEmailmtmdefs.h"
+
+
+// ------------------------------------------------------------------------------------------------
+// Defines for binary size optimization
+// ------------------------------------------------------------------------------------------------
+#define __NO_XML_COMMENTS_
+//#define __NO_EMPTY_ELEMENTS_
+
+
+// ------------------------------------------------------------------------------------------------
+// Class forward declarations
+// ------------------------------------------------------------------------------------------------
+class CNSmlXmlParser;
+class CNSmlExtData;
+
+
+// ------------------------------------------------------------------------------------------------
+// Typedefs
+// ------------------------------------------------------------------------------------------------
+// the array used for xval-values
+typedef CArrayPtrFlat<HBufC8> CNSmlXValArray;
+// the array used for extension data
+typedef CArrayPtrFlat<CNSmlExtData> CNSmlExtDataArray;
+// the array used for truncate info attachments data
+typedef RPointerArray<CNSmlAttachmentTruncateInfo> RNSmlAttachArray;
+// the array used for truncate info body data
+typedef RPointerArray<CNSmlBodyTruncateInfo> RNSmlBodyArray;
+
+
+// ------------------------------------------------------------------------------------------------
+// constants
+// ------------------------------------------------------------------------------------------------
+
+// the maximum length of an integer in characters
+const TInt KIntegerMaxLength = 12;
+
+// the length of a datetime in characters
+const TInt KDateTimeLength = 16;
+
+// the length of element start (<) and end (>)
+const TInt KElementStartEndWidth = 2;
+
+// constants used with files
+const TInt KReadDataLength = 512;
+const TUint KFileReadAccess	= EFileRead|EFileShareAny;
+const TUint KFileWriteAccess = EFileWrite|EFileShareExclusive;
+const TInt KMaxEmailItemFileNameLength = 256;
+_LIT(KEmailItemFile, "c:\\system\\temp\\emailitem.txt");
+_LIT(KEmailItemPath, "c:\\system\\temp\\");
+
+const TInt KNSmlEmailItemDrive = EDriveC;
+
+// Whitespace characters
+const TText KWhitespaceEmpty = ' ';
+const TText KWhitespaceLineFeed = '\r';
+const TText KWhitespaceNewLine = '\n';
+const TText KWhitespaceTabular = '\t';
+const TText KWhitespaceLineFeedNewLine = '\r\n';
+
+const TText KCharacterSlash = '/';
+
+// CData
+_LIT8(KCDataStart,		"<![CDATA[");
+_LIT8(KCDataEnd,		"]]>");
+_LIT8(KCDataInnerEnd,	"]]]]>&gt;<![CDATA[");
+
+#ifndef __NO_XML_COMMENTS_
+// Xml comments
+_LIT8(KCommentStart,	"<!--");
+_LIT8(KCommentEnd,		"-->");
+#endif
+
+const TText KElementStart = '<';
+const TText KElementEnd = '>';
+
+// Xml entities
+_LIT8(KEntityLT,	"&lt;");
+_LIT8(KEntityGT,	"&gt;");
+_LIT8(KEntityAMP,	"&amp;");
+_LIT8(KEntityAPOS,	"&apos;");
+_LIT8(KEntityQUOT,	"&quot;");
+
+// special characters
+_LIT8(KLessThan,	"<");
+_LIT8(KGreaterThan,	">");
+_LIT8(KAmpersand,	"&");
+_LIT8(KApostrophe,	"\'");
+_LIT8(KQuotation,	"\"");
+
+// boolean string representations
+_LIT8(KStringTrue,	"true");
+_LIT8(KStringFalse,	"false");
+
+// empty string
+_LIT8(KStringEmpty,	"");
+
+// email spesific elements
+_LIT8(KEmailElement,			"Email");
+_LIT8(KEmailReadElement,		"read");
+_LIT8(KEmailForwardedElement,	"forwarded");
+_LIT8(KEmailRepliedElement,		"replied");
+_LIT8(KEmailReceivedElement,	"received");
+_LIT8(KEmailCreatedElement,		"created");
+_LIT8(KEmailModifiedElement,	"modified");
+_LIT8(KEmailDeletedElement,		"deleted");
+_LIT8(KEmailFlaggedElement,		"flagged");
+_LIT8(KEmailItemElement,		"emailitem");
+
+// truncated info spesific elements
+_LIT8(KTruncatedElement,		"truncated");
+_LIT8(KTruncatedBodyElement,	"body");
+_LIT8(KTruncatedAttachElement,	"attach");
+_LIT8(KTruncatedSizeElement,	"size");
+_LIT8(KTruncatedTypeElement,	"type");
+_LIT8(KTruncatedNameElement,	"name");
+
+// extension spesific elements
+_LIT8(KExtElement,		"Ext");
+_LIT8(KExtXNamElement,	"XNam");
+_LIT8(KExtXValElement,	"XVal");
+
+// folder spesific elements
+_LIT8(KFolderElement,			"Folder");
+_LIT8(KFolderNameElement,		"name");
+_LIT8(KFolderCreatedElement,	"created");
+_LIT8(KFolderModifiedElement,	"modified");
+_LIT8(KFolderAccessedElement,	"accessed");
+_LIT8(KFolderAttributesElement,	"attributes");
+_LIT8(KFolderRoleElement,		"role");
+
+// folder attributes
+_LIT8(KAttributeHiddenElement,		"h");
+_LIT8(KAttributeSystemElement,		"s");
+_LIT8(KAttributeArchivedElement,	"a");
+_LIT8(KAttributeDeleteElement,		"d");
+_LIT8(KAttributeWritableElement,	"w");
+_LIT8(KAttributeReadableElement,	"r");
+_LIT8(KAttributeExecutableElement,	"x");
+
+
+// The error values returned from parser and generator functions
+enum TNSmlParserGeneratorError
+	{
+	EErrorNone,				// no error
+	EOutOfMemory,			// out of memory
+	EMandatoryFieldNotFound,// XNam inside Ext missing
+	EInvalidBooleanValue,	// Invalid value inside boolean elements
+	EInvalidIntegerValue,	// Invalid value inside integer elements
+	EInvalidDatetimeValue,	// Invalid value inside datetime elements
+	EInvalidCDataStructure,	// CDATA error
+	EInvalidXmlError, 		// Xml includes invalid data, i.e. xml generally against dtd
+	EInvalidFilename,		// file was not found or the filename was otherwise erroneous
+	EUnknownError			// Unknown error
+	};
+
+
+// enumeration for boolean values
+enum TNSmlBoolean
+	{
+	EBooleanMissing = 0, // not included in the xml
+	EBooleanTrue,
+	EBooleanFalse
+	};
+
+
+// extension data (found in both email and folder)
+class CNSmlExtData : public CBase
+	{
+public:
+	IMPORT_C static CNSmlExtData* NewL();
+	IMPORT_C static CNSmlExtData* NewLC();
+	IMPORT_C virtual ~CNSmlExtData();
+
+	IMPORT_C void AddXValL( HBufC8* aXVal );
+
+	IMPORT_C void GenerateXmlL( TPtr8& aXml, const CNSmlXmlParser* aParser ) const;
+	IMPORT_C TInt CountXmlSize( const CNSmlXmlParser* aParser ) const;
+	IMPORT_C void ConvertIntoEntitiesL( const CNSmlXmlParser* aParser );
+
+private:
+	CNSmlExtData();
+	void ConstructL();
+
+public:
+	HBufC8* iXNam;
+	CNSmlXValArray* iXVals;
+	};
+
+
+// folder attributes
+struct TNSmlFolderAttributeData
+	{
+	IMPORT_C TNSmlFolderAttributeData();
+
+	/*
+	* Returns the count of attributes that are not EBooleanMissing.
+	*/
+	IMPORT_C TInt AttributeCount() const;
+
+	IMPORT_C void GenerateXml( TPtr8& aXml, const CNSmlXmlParser* aParser ) const;
+	IMPORT_C TInt CountXmlSize( const CNSmlXmlParser* aParser ) const;
+
+	TNSmlBoolean iHidden;
+	TNSmlBoolean iSystem;
+	TNSmlBoolean iArchived;
+	TNSmlBoolean iDelete;
+	TNSmlBoolean iWritable;
+	TNSmlBoolean iReadable;
+	TNSmlBoolean iExecutable;
+	};
+
+
+// truncate info data
+class CNSmlTruncatedData : public CBase
+	{
+public:
+	IMPORT_C static CNSmlTruncatedData* NewL();
+	IMPORT_C static CNSmlTruncatedData* NewLC();
+	IMPORT_C virtual ~CNSmlTruncatedData();
+
+	IMPORT_C void AddAttachmentL(HBufC8* aName, TInt aSize, HBufC8* aType);
+	IMPORT_C void AddBodyL(TInt aSize, HBufC8* aType);
+
+	IMPORT_C void GenerateXmlL( TPtr8& aXml, const CNSmlXmlParser* aParser ) const;
+	IMPORT_C TInt CountXmlSizeL( const CNSmlXmlParser* aParser ) const;
+	IMPORT_C void ConvertIntoEntitiesL( const CNSmlXmlParser* aParser );
+
+private:
+	CNSmlTruncatedData();
+	void ConstructL();
+
+public:
+	RNSmlBodyArray iBodys;
+	RNSmlAttachArray iAttachments;
+	};
+
+
+// Base class for actual parsergenerators. 
+// Implements basic utilities for parsing and generating the xml.
+class CNSmlXmlParser : public CBase  
+	{
+public:
+	/*
+	* The constructor.
+	*/
+	IMPORT_C CNSmlXmlParser();
+
+	/*
+	* The destructor.
+	*/
+	IMPORT_C virtual ~CNSmlXmlParser();
+
+	/*
+	* Parses through the given xml and places the data it contains to 
+	* member variables.	Removes all the comments from the original string.
+	* @param aXml The xml to be parsed.
+	* @return 
+	*/
+	virtual TNSmlParserGeneratorError ParseXml( HBufC8* aXml ) =0;
+
+	/*
+	* Generates xml using the data in member variables of the child class. 
+	* aXml contains the generated xml when method returns successfully. 
+	* Caller should not instantiate 
+	* the buffer, since this method counts the size of the xml and 
+	* instantiates the buffer using the size as its maximum size.
+	* Caller gets the control of the buffer when method returns.
+	* @param aXml A pointer to a buffer, which is instantiated in this 
+	* method and contains the xml when method returns succesfully.
+	* @return 
+	*/
+	virtual TNSmlParserGeneratorError GenerateXml( HBufC8*& aXml ) =0;
+
+	/*
+	* Counts the size of the generated xml, when the xml would be generated 
+	* using the data in child class' member variables.
+	*/
+	virtual TInt CountXmlSizeL() =0;
+
+	/* utility functions */
+
+	void PreProcessL( HBufC8* aXml ) const;
+
+	TPtrC8 BooleanToString( const TNSmlBoolean aValue ) const;
+	TBuf8<KDateTimeLength> DateTimeToStringL( const TTime& aValue ) const;
+	TBuf8<KIntegerMaxLength> IntegerToString( const TInt aValue ) const;
+
+	TNSmlBoolean StringToBooleanL( const TPtrC8& aValue ) const;
+	TInt StringToIntegerL( const TPtrC8& aValue ) const;
+	// Note: Ignores UTC-times (Z-ending) and treats them as local time!
+	TTime StringToTTimeL( TPtrC8& aValue ) const;
+
+	void AppendElement( TPtr8& aPtr, const TDesC8& aElementName, const TDesC8& aValue ) const;
+	void AppendElement( TPtr8& aPtr, const TDesC8& aElementName ) const;
+	void AppendEndElement( TPtr8& aPtr, const TDesC8& aElementName ) const;
+
+	TInt SizeOfElements( const TDesC8& aElementName ) const;
+	TInt SizeOfBoolean( const TNSmlBoolean aValue, const TDesC8& aElementName ) const;
+	TInt SizeOfDatetime( const TDesC8& aElementName ) const;
+	TInt SizeOfInteger( const TDesC8& aElementName ) const;
+	TInt SizeOfString( const HBufC8* aValue, const TDesC8& aElementName ) const;
+
+	TInt EntitiesToCharactersL( HBufC8*& aXml, TInt aStartPos, TInt aEndPos ) const;
+	TInt CharactersToEntitiesL( HBufC8*& aXml, TInt aStartPos, TInt aEndPos ) const;
+
+	TBool IsWhitespace( const TDesC8& aText ) const;
+	void LeaveIfNotWhiteSpaceL( const TDesC8& aText ) const;
+
+	TNSmlParserGeneratorError CheckError( const TInt error ) const;
+
+protected:
+	// parsing methods
+	void ParseL( TPtrC8& aXml );
+	void AddToCompleteL( const TPtrC8 aStr );
+	void ResetBufferL( HBufC8*& aBuf ) const;
+	void AddToBufferL( const TText c, HBufC8*& aBuf ) const;
+
+	virtual void NextElementL( TPtrC8 aElement ) =0;
+	virtual void NextDataL( TPtrC8 aData ) =0;
+
+private:
+	TInt ReplaceL( HBufC8*& aText, const TDesC8& aTarget, const TDesC8& aItem, TInt aStartPos, TInt aEndPos ) const;
+	void CheckDatetimeErrorL( const TInt error ) const;
+
+protected:
+	HBufC8* iBuffer;
+	HBufC8* iCompleteBuffer;
+	};
+
+
+
+// Email parser. Implements the parsing and generating of Email xml.
+class CNSmlEmailParser : public CNSmlXmlParser
+	{
+public:
+	IMPORT_C static CNSmlEmailParser* NewL();
+	IMPORT_C static CNSmlEmailParser* NewLC();
+	IMPORT_C virtual ~CNSmlEmailParser();
+
+	IMPORT_C virtual TNSmlParserGeneratorError ParseXml( HBufC8* aXml );
+	IMPORT_C virtual TNSmlParserGeneratorError GenerateXml( HBufC8*& aXml );
+	IMPORT_C virtual TInt CountXmlSizeL();
+
+	IMPORT_C void AddExtL( CNSmlExtData* aExt );
+
+protected:
+	virtual void NextElementL( TPtrC8 aElement );
+	virtual void NextDataL( TPtrC8 aData );
+
+	virtual void HandleNextEmailItemDataL( TPtrC8 aData );
+	virtual void HandleNextEmailItemStartL() {}; // nothing to do
+	virtual void HandleNextEmailItemEndL() {}; // nothing to do
+
+	void ConvertIntoEntitiesL();
+
+	CNSmlEmailParser();
+	void ConstructL();
+
+protected:
+	
+	// the email elements (states) in the order they appear in DTD
+	enum TNSmlCurrentEmailElement
+		{
+		ENone = 0,
+		EEmail,
+		ERead, 
+		EForwarded,
+		EReplied,
+		EReceived,
+		ECreated,
+		EModified,
+		EDeleted,
+		EFlagged,
+		EEmailItem,
+		ETrunc,
+		ETruncBody,
+		ETruncBodySize,
+		ETruncBodyType,
+		ETruncAttach,
+		ETruncAttachName,
+		ETruncAttachSize,
+		ETruncAttachType, 
+		EExt,
+		EExtXNam,
+		EExtXVal
+		};
+	
+	// struct used in email parsing to know which members are already set
+	struct TNSmlSetEmailValues
+		{
+		TNSmlSetEmailValues();
+		void Reset();
+		
+		TBool iEmail;
+		TBool iRead;
+		TBool iForwarded;
+		TBool iReplied;
+		TBool iDeleted;
+		TBool iFlagged;
+		TBool iReceived;
+		TBool iCreated;
+		TBool iModified;
+		TBool iEmailItem;
+		TBool iTrunc;
+		TBool iTruncBodySize;
+		TBool iTruncBodyType;
+		TBool iTruncAttachSize;
+		TBool iTruncAttachType;
+		TBool iTruncAttachName;
+		TBool iXNam;
+		};
+	
+private:
+	void StartElementStateChangeL( TNSmlCurrentEmailElement aCurrentState, TNSmlCurrentEmailElement aNextState, TBool aIsSet = EFalse );
+	void EndElementStateChangeL( TNSmlCurrentEmailElement aCurrentState, TNSmlCurrentEmailElement aNextState );
+	
+	void GenerateEmailXmlL( HBufC8*& aXml );
+
+public:
+
+	/*
+	* The values of the data below is treated as follows:
+	* When constructing this data from an xml, boolean values 
+	* are EBooleanTrue, when <field>true</field>, EBooleanFalse 
+	* when <field>false</field> OR <field/>, and EBooleanMissing 
+	* when the field is not present in the xml. Datetime values 
+	* are equal to Time::NullTTime when the field is missing (they should 
+	* never be empty). Text values (HBufC8*) are NULL when the field is 
+	* missing, an empty string when <field></field> OR <field/> and the 
+	* actual value between elements if there is data between those 
+	* elements. iExt is never NULL, but when iExt->Count() 
+	* equals to zero, there are no extensions present in the xml.
+	*
+	* These same rules are used when generating xml from 
+	* this data object.
+	*/
+
+	TNSmlBoolean iRead;
+	TNSmlBoolean iForwarded;
+	TNSmlBoolean iReplied;
+	TTime iReceived;
+	TTime iCreated;
+	TTime iModified;
+	HBufC8* iEmailItem;
+	TNSmlBoolean iDeleted;
+	TNSmlBoolean iFlagged;
+	CNSmlTruncatedData* iTruncated;
+	CNSmlExtDataArray* iExt;
+
+protected:
+	TNSmlSetEmailValues iSetValues;
+	TNSmlCurrentEmailElement iCurrentState;
+	TNSmlCurrentEmailElement iLastState;
+
+private:
+
+	TInt iTruncSize;
+	HBufC8* iTruncType;
+	HBufC8* iTruncName;
+	CNSmlExtData* iExtData;
+	};
+
+
+
+// ------------------------------------------------------------------------------------------------
+// Parses and generates the xml using files/streams. If emailitem is present, it is 
+// stored in a file.
+// ------------------------------------------------------------------------------------------------
+class CNSmlEmailFileParser : public CNSmlEmailParser
+	{
+public:
+	IMPORT_C static CNSmlEmailFileParser* NewL();
+	IMPORT_C static CNSmlEmailFileParser* NewLC();
+	IMPORT_C virtual ~CNSmlEmailFileParser();
+
+	IMPORT_C virtual TNSmlParserGeneratorError ParseXml( HBufC8* aXml );
+	IMPORT_C virtual TNSmlParserGeneratorError ParseXml( RReadStream& aRs );
+	IMPORT_C virtual TNSmlParserGeneratorError GenerateXml( HBufC8*& aXml );
+	IMPORT_C virtual TNSmlParserGeneratorError GenerateXml( RWriteStream& aWs );
+	IMPORT_C virtual TInt CountXmlSizeL();
+
+protected:
+	virtual void HandleNextEmailItemDataL( TPtrC8 aData );
+	virtual void HandleNextEmailItemStartL();
+	virtual void HandleNextEmailItemEndL();
+
+private:
+	void ParseFromStreamL( RReadStream& rs );
+	void ParsePieceL( TPtrC8& aXml, TBool aLastPiece = EFalse );
+	TUint RemoveIncompleteL( HBufC8* aPiece, RReadStream& aStream );
+	TUint CheckPiece( const TPtrC8 aEnd ) const;
+	void PreProcessPieceL( HBufC8* aXml );
+
+	void GenerateEmailXmlL( RWriteStream& aWs );
+
+	void ResetParserL();
+	void ResetPreProcessor();
+
+	HBufC* Buf8ToBuf16( const HBufC8* buf8 ) const;
+
+	CNSmlEmailFileParser();
+	void ConstructL();
+
+public:
+
+	TBool iUseEmailItem; // whether or not emailitem should be used in generation
+
+private:
+
+	// xml parsing state
+	TBool iReadingElementName;
+	TBool iReadingCData;
+#ifndef __NO_XML_COMMENTS_
+	TBool iReadingComment;
+#endif
+	TBool iReadingEmailItemData;
+
+	// pre-processing state
+	TInt iCdataStartPos;
+	TInt iCdataEndPos;
+
+	// file handling
+	RFs iRfs;
+	RFileWriteStream iWriteStream;
+	
+	HBufC* iEmailItemFile;
+	TBool iFirstPiece;
+	TBool iCdataFoundFromFirstPiece;
+	};
+
+
+
+
+// Folder parser. Implements parsing and generating of Folder xml.
+class CNSmlFolderParser : public CNSmlXmlParser
+	{
+public:
+	IMPORT_C static CNSmlFolderParser* NewL();
+	IMPORT_C static CNSmlFolderParser* NewLC();
+	IMPORT_C virtual ~CNSmlFolderParser();
+
+	IMPORT_C virtual TNSmlParserGeneratorError ParseXml( HBufC8* aXml );
+	IMPORT_C virtual TNSmlParserGeneratorError GenerateXml( HBufC8*& aXml );
+	IMPORT_C virtual TInt CountXmlSizeL() ;
+
+	IMPORT_C void AddExtL( CNSmlExtData* aExt );
+
+protected:
+	virtual void NextElementL( TPtrC8 aElement );
+	virtual void NextDataL( TPtrC8 aData );
+
+protected:
+	
+	// the folder elements (states) in the order they appear in DTD
+	enum TNSmlCurrentFolderElement
+		{
+		EFolderNone = 0,
+		EFolder,
+		EFolderName, 
+		EFolderCreated,
+		EFolderModified,
+		EFolderAccessed,
+		EAttributes,
+		EAttributesH,
+		EAttributesS,
+		EAttributesA,
+		EAttributesD,
+		EAttributesW,
+		EAttributesR,
+		EAttributesX,
+		EFolderRole,
+		EFolderExt,
+		EFolderExtXNam,
+		EFolderExtXVal
+		};
+	
+	// struct used in folder parsing (which members are already set)
+	struct TNSmlSetFolderValues
+		{
+		TNSmlSetFolderValues();
+		void Reset();
+		
+		TBool iFolder;
+		TBool iName;
+		TBool iCreated;
+		TBool iModified;
+		TBool iAccessed;
+		TBool iAttributes;
+		TBool iAttributesH;
+		TBool iAttributesS;
+		TBool iAttributesA;
+		TBool iAttributesD;
+		TBool iAttributesW;
+		TBool iAttributesR;
+		TBool iAttributesX;
+		TBool iRole;
+		TBool iXNam;
+		};
+	
+private:
+	void StartElementStateChangeL( TNSmlCurrentFolderElement aCurrentState, TNSmlCurrentFolderElement aNextState, TBool aIsSet = EFalse );
+	void EndElementStateChangeL( TNSmlCurrentFolderElement aCurrentState, TNSmlCurrentFolderElement aNextState );
+
+	void GenerateFolderXmlL( HBufC8*& aXml );
+	void ConvertIntoEntitiesL();
+
+	CNSmlFolderParser();
+	void ConstructL();
+
+public:
+	HBufC8* iName;
+	TTime iCreated;
+	TTime iModified;
+	TTime iAccessed;
+	TNSmlFolderAttributeData iAttributes;
+	HBufC8* iRole;
+	CNSmlExtDataArray* iExt;
+
+private:
+	TNSmlCurrentFolderElement iCurrentState;
+	TNSmlCurrentFolderElement iLastState;
+	TNSmlSetFolderValues iSetValues;
+
+	CNSmlExtData* iExtData;
+	};
+
+
+
+#endif // __NSMLXMLPARSER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlEmailFileParser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,814 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailFileParser* CNSmlEmailFileParser::NewL()
+	{
+	CNSmlEmailFileParser* self = CNSmlEmailFileParser::NewLC();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailFileParser* CNSmlEmailFileParser::NewLC()
+	{
+	CNSmlEmailFileParser* self = new (ELeave) CNSmlEmailFileParser();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::~CNSmlEmailFileParser
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailFileParser::~CNSmlEmailFileParser()
+	{
+	// close rfs and open streams
+	if ( iWriteStream.Sink() )
+		iWriteStream.Close();
+
+	iRfs.Close();
+	delete iEmailItemFile;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ParseXml
+// Parses the email xml, that is located in the file whose name is given 
+// as aXml (path and filename)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailFileParser::ParseXml( HBufC8* aXml )
+	{
+	if ( !aXml )
+		return EInvalidFilename;
+
+	HBufC* filename = Buf8ToBuf16( aXml );
+	if ( !filename )
+		{
+		return EOutOfMemory;
+		}
+
+	// open the stream and parse
+	TNSmlParserGeneratorError err = EErrorNone;
+	RFileReadStream rs;
+	if ( rs.Open(iRfs, *filename, KFileReadAccess) != KErrNone )
+		{
+		err = EInvalidFilename;
+		}
+	else
+		{
+		err = ParseXml( rs );
+		rs.Close();
+		}
+
+	delete filename;
+
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ParseXml
+// Parses the xml from the given stream, and writes the emailitem - if present - to a temp file
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailFileParser::ParseXml( RReadStream& aRs )
+	{
+	iSetValues.Reset();
+	iCurrentState = ENone;
+	iLastState = ENone;
+
+	TRAPD(err, ParseFromStreamL( aRs ));
+
+	if( err == EErrorNone && iCurrentState != ENone )
+		return EInvalidXmlError;
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::GenerateXml
+// Generates the xml and writes it to the file whose name is given in aXml (path 
+// and filename).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailFileParser::GenerateXml( HBufC8*& aXml )
+	{
+	if ( !aXml )
+		return EInvalidFilename;
+
+	HBufC* filename = Buf8ToBuf16( aXml );
+	if ( !filename )
+		{
+		return EOutOfMemory;
+		}
+
+	// open the stream and generate
+	iWriteStream.Replace(iRfs, *filename, KFileWriteAccess);
+	TNSmlParserGeneratorError err = GenerateXml( iWriteStream );
+	iWriteStream.Close();
+
+	delete filename;
+
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::GenerateXml
+// Generates the xml and writes it to the given stream.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailFileParser::GenerateXml( RWriteStream& aWs )
+	{
+	TRAPD( err, GenerateEmailXmlL( aWs ) );
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::GenerateEmailXmlL
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::GenerateEmailXmlL( RWriteStream& aWs )
+	{
+	ConvertIntoEntitiesL();
+
+	// count the size of the xml (does not include emailitem, since it is - if present - in a file)
+	TInt size = CNSmlEmailParser::CountXmlSizeL();
+	if ( iUseEmailItem ) size += 20; // extra for emailitem tags
+
+	// create a buffer for using the size
+	HBufC8* xml = HBufC8::NewLC(size);
+	TPtr8 ptr = xml->Des();
+
+	// append data to buffer
+	AppendElement(ptr, KEmailElement());
+
+	if ( iRead )
+		{
+		AppendElement(ptr, KEmailReadElement(), BooleanToString( iRead ));
+		}
+
+	if ( iForwarded )
+		{
+		AppendElement(ptr, KEmailForwardedElement(), BooleanToString( iForwarded ));
+		}
+
+	if ( iReplied )
+		{
+		AppendElement(ptr, KEmailRepliedElement(), BooleanToString( iReplied ));
+		}
+
+	if (iReceived != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailReceivedElement(), DateTimeToStringL(iReceived));
+		}
+
+	if (iCreated != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailCreatedElement(), DateTimeToStringL(iCreated));
+		}
+
+	if (iModified != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailModifiedElement(), DateTimeToStringL(iModified));
+		}
+
+	if ( iDeleted )
+		{
+		AppendElement(ptr, KEmailDeletedElement(), BooleanToString( iDeleted ));
+		}
+
+	if ( iFlagged )
+		{
+		AppendElement(ptr, KEmailFlaggedElement(), BooleanToString( iFlagged ));
+		}
+
+	// if emailitem should be used in generation, write it to the stream
+	if ( iUseEmailItem )
+		{
+		// append start tag and cdata start
+		AppendElement(ptr, KEmailItemElement());
+		ptr.Append(KCDataStart);
+
+		// open a stream to emailitem
+		RFileReadStream rs;
+		TInt err = rs.Open( iRfs, *iEmailItemFile, KFileReadAccess );
+		if ( err != KErrNone )
+			User::Leave( EInvalidFilename );
+		
+		CleanupClosePushL(rs);
+		
+		// write the buffer to the stream
+		aWs.WriteL(ptr);
+		
+		// write emailitem from stream
+		aWs.WriteL(rs);
+		
+		// close the opened read stream
+		CleanupStack::Pop(); // rs
+
+		// empty the buffer (i.e. set the length to zero)
+		ptr.SetLength(0);
+
+		// append emailitem end tag and cdata inner end
+		ptr.Append(KCDataEnd);
+		AppendEndElement(ptr, KEmailItemElement());
+		}
+
+	// append the rest of the data to the buffer
+	if ( iTruncated )
+		{
+		iTruncated->GenerateXmlL(ptr, this);
+		}
+
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			iExt->At(i)->GenerateXmlL(ptr, this);
+			}
+
+		}
+
+	AppendEndElement(ptr, KEmailElement());
+
+	// write the buffer to the stream and commit
+	aWs.WriteL(ptr);
+	aWs.CommitL();
+
+	CleanupStack::PopAndDestroy(); // xml
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::CountXmlSizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlEmailFileParser::CountXmlSizeL()
+	{
+	// counting the size is not essential, since xml is written to a file
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::HandleNextEmailItemDataL
+// Next emailitem data
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::HandleNextEmailItemDataL( TPtrC8 aData )
+	{
+	// write the given piece of data into a file (stream)
+	iWriteStream.WriteL(aData);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::HandleNextEmailItemStartL
+// Emailitem element starts
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::HandleNextEmailItemStartL()
+	{
+	// open the write stream
+	User::LeaveIfError( iWriteStream.Replace( iRfs, *iEmailItemFile, KFileWriteAccess ) );
+	iReadingEmailItemData = ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::HandleNextEmailItemEndL
+// Emailitem element ends
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::HandleNextEmailItemEndL()
+	{
+	// close the write stream
+	iWriteStream.Close();
+	iReadingEmailItemData = EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ParseFromStreamL
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::ParseFromStreamL( RReadStream& aRs )
+	{
+
+	// reset preprocess variables and parser
+	ResetPreProcessor();
+	ResetParserL();
+
+	// read and process the data piece by piece
+	HBufC8* piece = HBufC8::NewLC(KReadDataLength);
+	TPtr8 ptr = piece->Des();
+	TInt dataSize = aRs.Source()->SizeL();
+
+	TInt pos = 0;
+	iFirstPiece = ETrue;
+	for( pos = KReadDataLength; pos <= dataSize ; pos += KReadDataLength )
+		{
+		// read piece of data from the stream
+		aRs.ReadL(ptr, KReadDataLength);
+
+		// check that there are no incomplete cdata/comment/entity at the end
+		dataSize += RemoveIncompleteL( piece, aRs );
+
+		// pre-process
+		PreProcessPieceL( piece );
+
+		// parsing
+		TPtrC8 temp( *piece );
+		ParsePieceL( temp );
+		
+		iFirstPiece = EFalse;
+		}
+
+	TInt lastPartLength = dataSize - pos + KReadDataLength;
+	aRs.ReadL(ptr, lastPartLength);
+
+	PreProcessPieceL( piece );
+
+	// parsing
+	TPtrC8 temp( *piece );
+	ParsePieceL( temp, ETrue );
+
+	CleanupStack::PopAndDestroy(); // piece
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ParsePieceL
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::ParsePieceL( TPtrC8& aXml, TBool aLastPiece )
+	{
+
+	// check if last cdata has not ended yet
+	if ( iReadingCData )
+		{
+		TInt endPos = aXml.Find(KCDataEnd);
+		TPtrC8 cdata = _L8("");
+
+		if ( endPos == KErrNotFound && aLastPiece )
+			{
+			User::Leave(EInvalidCDataStructure);
+			}
+		else if ( endPos == KErrNotFound )
+			{
+			// cdata end was not found, read the whole piece as cdata
+			NextDataL( aXml );
+			return;
+			}
+		else 
+			{
+			// add data until cdata end to buffer
+			cdata.Set( aXml.Left( endPos ) );
+			aXml.Set( aXml.Right( aXml.Length() - endPos - KCDataEnd().Length() ) );			
+			iReadingCData = EFalse;
+			}
+
+		AddToCompleteL(cdata);
+		NextDataL(*iCompleteBuffer);
+		ResetBufferL(iCompleteBuffer);
+
+		}
+#ifndef __NO_XML_COMMENTS_
+	else if ( iReadingComment ) // check if last comment has not ended yet
+		{
+		TInt endPos = aXml.Find(KCommentEnd);
+
+		if ( endPos == KErrNotFound && aLastPiece )
+			{ // this is the last piece of data and end of comment has not been found -> error
+			User::Leave(EInvalidXmlError);
+			}
+		else if ( endPos == KErrNotFound )
+			{
+			// end of comment was not found, no need to parse this piece of data
+			return;
+			}
+		else 
+			{
+			// end of cdata was found, jump to that position
+			aXml.Set( aXml.Right( aXml.Length() - endPos - KCommentEnd().Length() ) );
+			iReadingComment = EFalse;
+			}
+		}
+#endif
+
+	// parse through the string
+	TText c;
+
+	for( TInt i=0; i < aXml.Length(); ++i )
+		{
+		c = aXml[i];
+		switch(c)
+			{
+			case KElementStart:
+				// if currently reading element, error
+				if( iReadingElementName )
+					{
+					User::Leave(EInvalidXmlError);
+					}
+
+				if( aXml.Length()-i >= KCDataStart().Length() &&
+					!aXml.Mid(i, KCDataStart().Length()).Compare(KCDataStart()) )
+					{ // cdata
+					aXml.Set( aXml.Right( aXml.Length() - i ) );
+					TInt endPos = aXml.Find(KCDataEnd);
+
+					TPtrC8 cdata = _L8("");
+					if ( endPos == KErrNotFound && aLastPiece )
+						{
+						User::Leave(EInvalidCDataStructure);
+						}
+					else if ( endPos == KErrNotFound )
+						{
+						// cdata end was not found, read all the rest as cdata
+						cdata.Set( aXml.Right( aXml.Length() - KCDataStart().Length() ) );
+						i = aXml.Length(); // move to the end
+						iReadingCData = ETrue;
+						}
+					else 
+						{
+						cdata.Set( aXml.Mid( KCDataStart().Length(), endPos - KCDataStart().Length() ) );
+						aXml.Set( aXml.Right( aXml.Length() - endPos - KCDataEnd().Length() ) );
+
+						i = -1;
+						}
+
+					// add current buffer to complete buffer
+					EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+					AddToCompleteL(*iBuffer);
+					ResetBufferL(iBuffer);
+					AddToCompleteL(cdata);
+					}
+#ifndef __NO_XML_COMMENTS_
+				else if( aXml.Length()-i >= KCommentStart().Length() &&
+					!aXml.Mid(i, KCommentStart().Length()).Compare(KCommentStart()) )
+					{ // comment
+					aXml.Set( aXml.Right( aXml.Length() - i ) );
+					TInt endPos = aXml.Find(KCommentEnd);
+
+					if ( endPos == KErrNotFound && aLastPiece)
+						{
+						// this is the last piece of data, and end of comment was not found -> error
+						User::Leave(EInvalidXmlError);
+						}
+					else if ( endPos == KErrNotFound )
+						{
+						// the end was not found, no need to parse the rest since it is comment
+						iReadingComment = ETrue;
+						return;
+						}
+					else
+						{
+						// the end of comment was found, move to the end of comment and start parsing 
+						// from there on
+						aXml.Set( aXml.Right( aXml.Length() - endPos - KCommentEnd().Length() ) );
+						}
+
+					i = -1;
+					}
+#endif
+				else 
+					{
+					// send the buffer
+					EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+					AddToCompleteL(*iBuffer);
+					NextDataL(*iCompleteBuffer);
+					ResetBufferL(iBuffer);
+					ResetBufferL(iCompleteBuffer);
+					iReadingElementName = ETrue;
+					}
+
+				break;
+			case KElementEnd:
+				// stop reading element name
+				if( !iReadingElementName )
+					{
+					User::Leave(EInvalidXmlError);
+					}
+				else 
+					{
+					NextElementL(*iBuffer);
+					ResetBufferL(iBuffer);
+					iReadingElementName = EFalse;
+					}
+				break;
+			default:
+				// add char to buffer
+				AddToBufferL(c, iBuffer);
+				break;
+			}
+		}
+
+	// send the data in the buffer
+	if ( ( iReadingEmailItemData || aLastPiece ) && !iReadingElementName )
+		{
+		EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+		AddToCompleteL(*iBuffer);
+		NextDataL(*iCompleteBuffer);
+		ResetBufferL(iBuffer);
+		ResetBufferL(iCompleteBuffer);
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::RemoveIncompleteL
+// Checks if there is incomplete cdata/comment/entity at the end of the given
+// piece. If one is found, it is removed from aPiece and the read mark of the
+// stream is moved backwards the length of the removed item (i.e. the incomplete
+// item will be read to the next piece as a whole).
+// -----------------------------------------------------------------------------
+//
+TUint CNSmlEmailFileParser::RemoveIncompleteL( HBufC8* aPiece, RReadStream& aStream )
+	{
+	// we need to check only the last nine characters
+	TUint removeSize = CheckPiece( aPiece->Right( 9 ) );
+
+	if ( removeSize )
+		{
+		// remove the incomplete item from aPiece
+		TPtr8 ptr = aPiece->Des();
+		ptr.Delete( aPiece->Length() - removeSize, removeSize );
+
+		// move backwards in reading the stream
+		aStream.Source()->SeekL( MStreamBuf::ERead, aStream.Source()->TellL(MStreamBuf::ERead) - removeSize );
+		}
+
+	// no need to loop the rest of aPiece. If xml is not correctly formed,
+	// an error occures later in the parser
+
+	return removeSize;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::CheckPiece
+// -----------------------------------------------------------------------------
+//
+TUint CNSmlEmailFileParser::CheckPiece( const TPtrC8 aEnd ) const
+	{
+	// check that there are no incomplete cdata/comment/entity at the end	
+	// (cdata start, cdata end, cdata inner end, comment start, comment end, entities)
+	// ( <![CDATA[ , ]]> , <!-- , --> , &xxxx; , ]]]]>&gt; , ]]]]&gt;> )
+	// do not change the order
+
+	// possible inner cdata end
+	TInt pos = aEnd.Find( _L8("]]]") );
+	if ( pos != KErrNotFound )
+		{
+		return aEnd.Length() - pos;
+		}
+
+	// beginning part of comment or cdata
+	pos = aEnd.Find( _L8("<!") );
+	if ( pos != KErrNotFound )
+		{
+		return aEnd.Length() - pos;
+		}
+
+	// end of cdata
+	TText lastChar = aEnd[aEnd.Length()-1];
+	TText secondLastChar = aEnd[aEnd.Length()-2];
+	if ( lastChar == ']' && secondLastChar == ']' )
+		{
+		return 2;
+		}
+
+#ifndef __NO_XML_COMMENTS_
+	// comment end
+	if ( lastChar == '-' && secondLastChar == '-' )
+		{
+		return 2;
+		}
+#endif
+
+	// special chars
+	if ( lastChar == '<' || lastChar == ']' || lastChar == '-' )
+		{
+		return 1;
+		}
+
+	// possible entity
+	pos = aEnd.Find( _L8("&") );
+	if ( pos != KErrNotFound )
+		{
+		return aEnd.Length() - pos;
+		}
+
+	return 0;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::PreProcessPieceL
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::PreProcessPieceL( HBufC8* aXml )
+	{
+	// take a modifiable pointer
+	TPtr8 xml = aXml->Des();
+
+	// the string used for searching and moving in the string
+	TPtrC8 searchString(*aXml);
+
+	// the current position in the original string
+	TInt searchStartPos = 0;
+
+	// if start has been found and end has not, try to find end first
+	if ( iCdataEndPos == KErrNotFound && iCdataStartPos != KErrNotFound && iCdataFoundFromFirstPiece )
+		{
+		// we're looking for a cdata end
+		iCdataEndPos = searchString.Find(KCDataEnd);
+
+		// if the end was found, remove it and start looking for a cdata start
+		if ( iCdataEndPos != KErrNotFound )
+			{
+			// remove cdata end
+			xml.Delete(iCdataEndPos, KCDataEnd().Length());
+			searchStartPos = iCdataEndPos;
+			searchString.Set( xml.Right(xml.Length() - searchStartPos) );
+			}
+		else
+			{
+			// end was not found, return
+			return;
+			}
+		}
+	
+	iCdataStartPos = searchString.Find(KCDataStart);
+	
+	// If CDATA is not found from beginning then data is not inside CDATA and then
+	// preprocessing is not needed
+	if ( iCdataStartPos != 0 && iFirstPiece )
+	    {
+	    return;
+	    }
+	else if ( !iFirstPiece && !iCdataFoundFromFirstPiece )
+		{
+		return;
+		}
+	else if ( iCdataStartPos == 0 && iFirstPiece )
+		{
+		iCdataFoundFromFirstPiece = ETrue;	
+		}
+	
+	
+	// while cdata is found
+	while ( iCdataStartPos != KErrNotFound )
+		{
+		iCdataStartPos += searchStartPos;
+		
+		// find an end of cdata before entities are converted
+		iCdataEndPos = searchString.Find(KCDataEnd);
+		
+		// convert entities between search start and cdata start
+		TInt entityChange = EntitiesToCharactersL(aXml, searchStartPos, iCdataStartPos);
+		xml.Set(aXml->Des());
+		iCdataStartPos += entityChange;
+		
+		if ( iCdataEndPos != KErrNotFound )
+			{
+			iCdataEndPos += entityChange;
+			iCdataEndPos += searchStartPos;
+			
+			// if the end is before start -> error
+			if ( iCdataEndPos < iCdataStartPos )
+				User::Leave( EInvalidCDataStructure );
+			
+			// remove cdata end
+			xml.Delete(iCdataEndPos, KCDataEnd().Length());
+			// remove cdata start
+			xml.Delete(iCdataStartPos, KCDataStart().Length());
+			
+			searchStartPos = iCdataEndPos - KCDataStart().Length();
+			searchString.Set( xml.Right(xml.Length() - searchStartPos) );
+			}
+		else
+			{
+			// remove cdata start
+			xml.Delete(iCdataStartPos, KCDataStart().Length());
+			
+			// since there was no end found, return
+			return;
+			}
+		
+		// find a new cdata start that is after the found end
+		iCdataStartPos = searchString.Find(KCDataStart);
+		
+		}
+	
+	if ( iCdataStartPos == KErrNotFound )
+		{
+		EntitiesToCharactersL(aXml, searchStartPos, aXml->Length());
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ResetParserL
+// Resets the state of the parser, should be called before starting the parsing.
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::ResetParserL()
+	{
+	ResetBufferL(iBuffer);
+	ResetBufferL(iCompleteBuffer);
+	iReadingElementName = EFalse;
+	iReadingCData = EFalse;
+	iReadingEmailItemData = EFalse;
+	iFirstPiece = EFalse;
+	iCdataFoundFromFirstPiece = EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ResetPreProcessor
+// Resets the variables used in preprocessor.
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::ResetPreProcessor()
+	{
+	iCdataStartPos = KErrNotFound;
+	iCdataEndPos = KErrNotFound;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::Buf8ToBuf16
+// -----------------------------------------------------------------------------
+//
+HBufC* CNSmlEmailFileParser::Buf8ToBuf16( const HBufC8* buf8 ) const
+	{
+	HBufC* buf16 = HBufC::New(buf8->Length());
+	if ( buf16 )
+		{
+		TPtr ptr = buf16->Des();
+		ptr.Copy( *buf8 );
+		}
+
+	return buf16;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::CNSmlEmailFileParser
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlEmailFileParser::CNSmlEmailFileParser()
+	: iUseEmailItem(ETrue)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailFileParser::ConstructL
+// Second phase construction.
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailFileParser::ConstructL()
+	{
+	CNSmlEmailParser::ConstructL();
+	User::LeaveIfError( iRfs.Connect() );
+	
+	// create path+filename for emailitem
+    iEmailItemFile = HBufC::NewL( KMaxEmailItemFileNameLength );
+    TPtr file = iEmailItemFile->Des();
+
+	file.Append( KEmailItemFile );
+
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlEmailParser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,793 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailParser* CNSmlEmailParser::NewL()
+	{
+	CNSmlEmailParser* self = CNSmlEmailParser::NewLC();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailParser* CNSmlEmailParser::NewLC()
+	{
+	CNSmlEmailParser* self = new (ELeave) CNSmlEmailParser();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::~CNSmlEmailParser
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlEmailParser::~CNSmlEmailParser()
+	{
+	if( iTruncated )
+		delete iTruncated;
+
+	if( iExt ) 
+		{
+		iExt->ResetAndDestroy();
+		delete iExt;
+		}
+
+	if( iEmailItem ) delete iEmailItem;
+
+	if( iTruncType ) delete iTruncType;
+	if( iTruncName ) delete iTruncName;
+	if( iExtData ) delete iExtData;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::ParseXml
+// Parses through the given XML and puts the data it contains 
+// to member variables. 
+// Note: The string-values in CNSmlEmailParser are NOT copies, but 
+// references to aXml. The method does not check, if member variables 
+// already contain data, but just writes it (if some of them are already 
+// instantiated dynamically, they should be deleted before this method is called).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailParser::ParseXml( HBufC8* aXml )
+	{
+
+	// pre-process the data (remove cdata over <Data>)
+	TRAPD( cdataErr, PreProcessL(aXml));
+	if (cdataErr != EErrorNone)
+		return (TNSmlParserGeneratorError)cdataErr;
+
+	// reset state
+	iSetValues.Reset();
+	iCurrentState = ENone;
+	iLastState = ENone;
+	TPtrC8 ptr(*aXml);
+
+	// parse
+	TRAPD(err, ParseL( ptr ));
+
+	// return error, if in wrong state
+	if( err == EErrorNone && iCurrentState != ENone )
+		return EInvalidXmlError;
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::GenerateXml
+// Generates Email-XML using the data in member variables. aXml contains the 
+// generated xml when the function returns successfully. Note: caller should not 
+// instantiate the HBufC8, since this method first counts the size of the xml to
+// be generated and then instatiates the HBufC8 with a correct maximum size. If
+// the given buffer is not NULL, it is destroyed and a new one is instantiated.
+// However, the caller gets the control of the HBufC8 when the function returns.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlEmailParser::GenerateXml( HBufC8*& aXml ) 
+	{
+
+	TRAPD( err, GenerateEmailXmlL( aXml ) );
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::GenerateEmailXmlL
+// Private method that does the actual email xml generation
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::GenerateEmailXmlL( HBufC8*& aXml )
+	{
+	ConvertIntoEntitiesL();
+
+	// count the size of the xml
+	TInt size = CountXmlSizeL();
+
+	// create buffer for the xml
+
+	if ( aXml )
+		{
+		delete aXml;
+		aXml = NULL;
+		}
+
+	aXml = HBufC8::NewLC(size);
+	TPtr8 ptr = aXml->Des();
+
+	// append data to buffer
+	AppendElement(ptr, KEmailElement());
+
+	if ( iRead )
+		{
+		AppendElement(ptr, KEmailReadElement(), BooleanToString( iRead ));
+		}
+
+	if ( iForwarded )
+		{
+		AppendElement(ptr, KEmailForwardedElement(), BooleanToString( iForwarded ));
+		}
+
+	if ( iReplied )
+		{
+		AppendElement(ptr, KEmailRepliedElement(), BooleanToString( iReplied ));
+		}
+
+	if (iReceived != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailReceivedElement(), DateTimeToStringL(iReceived));
+		}
+
+	if (iCreated != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailCreatedElement(), DateTimeToStringL(iCreated));
+		}
+
+	if (iModified != Time::NullTTime())
+		{
+		AppendElement(ptr, KEmailModifiedElement(), DateTimeToStringL(iModified));
+		}
+
+	if ( iDeleted )
+		{
+		AppendElement(ptr, KEmailDeletedElement(), BooleanToString( iDeleted ));
+		}
+
+	if ( iFlagged )
+		{
+		AppendElement(ptr, KEmailFlaggedElement(), BooleanToString( iFlagged ));
+		}
+
+	if ( iEmailItem )
+		{
+		AppendElement(ptr, KEmailItemElement());
+		ptr.Append(KCDataStart);
+		ptr.Append( *iEmailItem );
+		ptr.Append(KCDataEnd);
+		AppendEndElement(ptr, KEmailItemElement());
+		}
+
+	if ( iTruncated )
+		{
+		iTruncated->GenerateXmlL(ptr, this);
+		}
+
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			iExt->At(i)->GenerateXmlL(ptr, this);
+			}
+
+		}
+
+
+	AppendEndElement(ptr, KEmailElement());
+
+	CleanupStack::Pop(); // aXml
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::CountXmlSizeL
+// Counts how long the xml string will be if it was generated using 
+// the values currently in member variables.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlEmailParser::CountXmlSizeL()
+	{
+	TInt size = 0;
+
+	size += KCDataStart().Length() + KCDataEnd().Length();
+	size += SizeOfElements( KEmailElement() );
+
+	if ( iRead )
+		{
+		size += SizeOfBoolean( iRead, KEmailReadElement() );
+		}
+
+	if ( iForwarded )
+		{
+		size += SizeOfBoolean( iForwarded, KEmailForwardedElement() );
+		}
+
+	if ( iReplied )
+		{
+		size += SizeOfBoolean( iReplied, KEmailRepliedElement() );
+		}
+
+	if (iReceived != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KEmailReceivedElement() );
+		}
+
+	if (iCreated != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KEmailCreatedElement() );
+		}
+
+	if (iModified != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KEmailModifiedElement() );
+		}
+
+	if ( iDeleted )
+		{
+		size += SizeOfBoolean( iDeleted, KEmailDeletedElement() );
+		}
+
+	if ( iFlagged )
+		{
+		size += SizeOfBoolean( iFlagged, KEmailFlaggedElement() );
+		}
+
+	if ( iEmailItem )
+		{
+		size += SizeOfString( iEmailItem, KEmailItemElement() );
+		size += KCDataStart().Length() + KCDataInnerEnd().Length();
+		}
+
+	if ( iTruncated )
+		{
+		size += iTruncated->CountXmlSizeL( this );
+		}
+
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			size += iExt->At(i)->CountXmlSize( this );
+			}
+		}
+
+	return size;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::AddExtL
+// Adds the given extension to iExt
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlEmailParser::AddExtL( CNSmlExtData* aExt )
+	{
+	iExt->AppendL(aExt);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::NextElementL
+// Base class' ParseL method calls this method, when a new element is found. aElement 
+// is the name of that element (string inside '<' and '>' characters).
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::NextElementL( TPtrC8 aElement )
+	{
+	if (aElement.Length() == 0)
+		User::Leave(EInvalidXmlError);
+
+	TBool startElement = ETrue;
+
+	if(aElement[0] == KCharacterSlash)
+		{
+		// take off the '/' character from the beginning
+		aElement.Set(aElement.Right(aElement.Length()-1));
+		// end element
+		startElement = EFalse;
+		}
+#ifndef __NO_EMPTY_ELEMENTS_
+	else if (aElement[aElement.Length()-1] == KCharacterSlash)
+		{
+		// take off the '/' character from the end
+		aElement.Set(aElement.Left(aElement.Length()-1));
+
+		// empty element == start element, empty data, end element
+		NextElementL( aElement ); // simulates start element
+		NextDataL( _L8("") ); // simulates empty data
+
+		// create the end element
+		HBufC8* end = HBufC8::NewLC(aElement.Length()+1);
+		TPtr8 ptr = end->Des();
+		ptr.Append( _L8("/") );
+		ptr.Append( aElement );
+
+		NextElementL( ptr ); // simulates end element
+
+		CleanupStack::PopAndDestroy(); // end
+
+		return;
+		}
+#endif
+
+	// variables used for state, init to <Email> and not set
+	TNSmlCurrentEmailElement inner = EEmail;
+	TNSmlCurrentEmailElement outer = EEmail;
+	TBool isSet = EFalse;
+
+	// check which element we've got
+	if( aElement == KEmailElement )
+		{
+		outer = ENone;
+		isSet = iSetValues.iEmail;
+		if ( startElement ) iSetValues.iEmail = ETrue;
+		}
+	else if( aElement == KEmailReadElement )
+		{
+		inner = ERead;
+		isSet = iSetValues.iRead;
+		}
+	else if( aElement == KEmailForwardedElement )
+		{
+		inner = EForwarded;
+		isSet = iSetValues.iForwarded;
+		}
+	else if( aElement == KEmailRepliedElement )
+		{
+		inner = EReplied;
+		isSet = iSetValues.iReplied;
+		}
+	else if( aElement == KEmailReceivedElement )
+		{
+		inner = EReceived;
+		isSet = iSetValues.iReceived;
+		}
+	else if( aElement == KEmailCreatedElement )
+		{
+		inner = ECreated;
+		isSet = iSetValues.iCreated;
+		}
+	else if( aElement == KEmailModifiedElement )
+		{
+		inner = EModified;
+		isSet = iSetValues.iModified;
+		}
+	else if( aElement == KEmailDeletedElement )
+		{
+		inner = EDeleted;
+		isSet = iSetValues.iDeleted;
+		}
+	else if( aElement == KEmailFlaggedElement )
+		{
+		inner = EFlagged;
+		isSet = iSetValues.iFlagged;
+		}
+	else if( aElement == KEmailItemElement )
+		{
+		inner = EEmailItem;
+		isSet = iSetValues.iEmailItem;
+		if ( startElement ) 
+			HandleNextEmailItemStartL();
+		else
+			HandleNextEmailItemEndL();
+		}
+	else if( aElement == KTruncatedElement )
+		{
+		inner = ETrunc;
+		isSet = iSetValues.iTrunc;
+
+		if ( startElement )
+			{
+			if ( !iTruncated )
+				iTruncated = CNSmlTruncatedData::NewL();
+			iSetValues.iTrunc = ETrue;
+			}
+		}
+	else if( aElement == KTruncatedBodyElement )
+		{
+		inner = ETruncBody;
+		outer = ETrunc;
+		if ( startElement )
+			{
+			if( iTruncType )
+				{
+				delete iTruncType;
+				iTruncType = NULL;
+				}
+			iTruncSize = KErrNotFound;
+
+			iSetValues.iTruncBodySize = EFalse;
+			iSetValues.iTruncBodyType = EFalse;
+			}
+		else
+			{
+			iTruncated->AddBodyL(iTruncSize, iTruncType);
+			}
+		}
+	else if( aElement == KTruncatedAttachElement )
+		{
+		inner = ETruncAttach;
+		outer = ETrunc;
+		if ( startElement )
+			{
+			if( iTruncType )
+				{
+				delete iTruncType;
+				iTruncType = NULL;
+				}
+			if( iTruncName )
+				{
+				delete iTruncName;
+				iTruncName = NULL;
+				}
+			iTruncSize = KErrNotFound;
+
+			iSetValues.iTruncAttachName = EFalse;
+			iSetValues.iTruncAttachType = EFalse;
+			iSetValues.iTruncAttachSize = EFalse;
+			}
+		else
+			{
+			iTruncated->AddAttachmentL(iTruncName, iTruncSize, iTruncType);
+			}
+		}
+	else if( aElement == KTruncatedSizeElement )
+		{
+		if ( (startElement && iCurrentState == ETruncBody) 
+				|| (!startElement && iCurrentState == ETruncBodySize) )
+			{
+			inner = ETruncBodySize;
+			outer = ETruncBody;
+			isSet = iSetValues.iTruncBodySize;
+			}
+		else if ( (startElement && iCurrentState == ETruncAttach) 
+				|| (!startElement && iCurrentState == ETruncAttachSize) )
+			{
+			inner = ETruncAttachSize;
+			outer = ETruncAttach;
+			isSet = iSetValues.iTruncAttachSize;
+			}
+		else
+			{
+			User::Leave(EInvalidXmlError); // wrong state
+			}
+		}
+	else if( aElement == KTruncatedTypeElement )
+		{
+		if ( (startElement && iCurrentState == ETruncBody) 
+			|| (!startElement && iCurrentState == ETruncBodyType) )
+			{
+			inner = ETruncBodyType;
+			outer = ETruncBody;
+			isSet = iSetValues.iTruncBodyType;
+			}
+		else if ( (startElement && iCurrentState == ETruncAttach)
+				|| (!startElement && iCurrentState == ETruncAttachType) )
+			{
+			inner = ETruncAttachType;
+			outer = ETruncAttach;
+			isSet = iSetValues.iTruncAttachType;
+			}
+		else
+			{
+			User::Leave(EInvalidXmlError); // wrong state
+			}
+		}
+	else if( aElement == KTruncatedNameElement )
+		{
+		inner = ETruncAttachName;
+		outer = ETruncAttach;
+		isSet = iSetValues.iTruncAttachName;
+		}
+	else if( aElement == KExtElement )
+		{
+		inner = EExt;
+		if ( startElement )
+			{
+			if( iExtData )
+				{
+				delete iExtData;
+				iExtData = NULL;
+				}
+			iExtData = CNSmlExtData::NewL();
+			iSetValues.iXNam = EFalse;
+			}
+		else
+			{
+			if( !iSetValues.iXNam ) User::Leave(EMandatoryFieldNotFound); // xnam not set
+			iExt->AppendL(iExtData);
+			iExtData = NULL;
+			}
+		}
+	else if( aElement == KExtXNamElement )
+		{
+		inner = EExtXNam;
+		outer = EExt;
+		isSet = iSetValues.iXNam;
+		}
+	else if( aElement == KExtXValElement )
+		{
+		inner = EExtXVal;
+		outer = EExt;
+		}
+	else
+		{ // unknown element
+		User::Leave(EInvalidXmlError);
+		}
+
+
+	// finally, change state depending on was the element start or end element
+	if ( startElement )
+		{
+		StartElementStateChangeL( outer, inner, isSet );
+		}
+	else
+		{
+		EndElementStateChangeL( inner, outer );
+		}
+
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::NextDataL
+// Base class' ParseL method calls this method, when a data is read from xml, but that 
+// data is not element name (data inside or between elements).
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::NextDataL( TPtrC8 aData )
+	{
+	switch(iCurrentState)
+		{
+		case ENone:
+		case EEmail:
+		case ETrunc:
+		case ETruncBody:
+		case ETruncAttach:
+		case EExt:
+			LeaveIfNotWhiteSpaceL( aData );
+			break;
+		case ERead:
+			iRead = StringToBooleanL(aData);
+			iSetValues.iRead = ETrue;
+			break;
+		case EForwarded:
+			iForwarded = StringToBooleanL(aData);
+			iSetValues.iForwarded = ETrue;
+			break;
+		case EReplied:
+			iReplied = StringToBooleanL(aData);
+			iSetValues.iReplied = ETrue;
+			break;
+		case EDeleted:
+			iDeleted = StringToBooleanL(aData);
+			iSetValues.iDeleted = ETrue;
+			break;
+		case EFlagged:
+			iFlagged = StringToBooleanL(aData);
+			iSetValues.iFlagged = ETrue;
+			break;
+		case EReceived:
+			iReceived = StringToTTimeL(aData);
+			iSetValues.iReceived = ETrue;
+			break;
+		case ECreated:
+			iCreated = StringToTTimeL(aData);
+			iSetValues.iCreated = ETrue;
+			break;
+		case EModified:
+			iModified = StringToTTimeL(aData);
+			iSetValues.iModified = ETrue;
+			break;
+		case EEmailItem:
+			HandleNextEmailItemDataL( aData ); // implementation dependent behavior
+			iSetValues.iEmailItem = ETrue;
+			break;
+		case ETruncBodySize:
+			iTruncSize = StringToIntegerL(aData);
+			iSetValues.iTruncBodySize = ETrue;
+			break;
+		case ETruncBodyType:
+			iTruncType = aData.AllocL();
+			iSetValues.iTruncBodyType = ETrue;
+			break;
+		case ETruncAttachSize:
+			iTruncSize = StringToIntegerL(aData);
+			iSetValues.iTruncAttachSize = ETrue;
+			break;
+		case ETruncAttachName:
+			iTruncName = aData.AllocL();
+			iSetValues.iTruncAttachName = ETrue;
+			break;
+		case ETruncAttachType:
+			iTruncType = aData.AllocL();
+			iSetValues.iTruncAttachType = ETrue;
+			break;
+		case EExtXNam:
+			iExtData->iXNam = aData.AllocL();
+			iSetValues.iXNam = ETrue;
+			break;
+		case EExtXVal:
+			iExtData->AddXValL(aData.AllocL());
+			break;
+		default:
+			User::Leave(EUnknownError); // should never happen
+			break;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::HandleNextEmailItemDataL
+// Next emailitem data
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::HandleNextEmailItemDataL( TPtrC8 aData )
+	{
+	iEmailItem = aData.AllocL();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::StartElementStateChangeL
+// Checks that the state change (new start element) is legal (right order of 
+// elements and element not already set) and changes the state.
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::StartElementStateChangeL(TNSmlCurrentEmailElement aCurrentState, 
+											    TNSmlCurrentEmailElement aNextState, 
+											    TBool aIsSet)
+	{
+	if( aIsSet || iCurrentState != aCurrentState || aNextState < iLastState )
+		{
+		User::Leave(EInvalidXmlError);
+		}
+
+	iLastState = iCurrentState;
+	iCurrentState = aNextState;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::EndElementStateChangeL
+// Checks that the state change (new end element) is legal (right order of 
+// elements and element not already set) and changes the state.
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::EndElementStateChangeL(TNSmlCurrentEmailElement aCurrentState, 
+											  TNSmlCurrentEmailElement aNextState )
+	{
+	if( iCurrentState != aCurrentState )
+		{
+		User::Leave(EInvalidXmlError);
+		}
+
+	iLastState = iCurrentState;
+	iCurrentState = aNextState;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::ConvertIntoEntitiesL
+// Converts special characters of this email-dataobject to corresponding 
+// characters. Emailitem needs not to be changed, since it is always 
+// placed inside cdata (when generating xml).
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::ConvertIntoEntitiesL()
+	{
+
+	// truncate info
+	if ( iTruncated )
+		{
+		iTruncated->ConvertIntoEntitiesL(this);
+		}
+
+	// extensions
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			iExt->At(i)->ConvertIntoEntitiesL(this);
+			}
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::CNSmlEmailParser
+// Private constructor
+// -----------------------------------------------------------------------------
+//
+CNSmlEmailParser::CNSmlEmailParser()
+	: iReceived(Time::NullTTime()), iCreated(Time::NullTTime()), iModified(Time::NullTTime()),
+	iTruncSize(KErrNotFound)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlEmailParser::ConstructL
+// Second phase construction
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::ConstructL()
+	{
+	iExt = new (ELeave) CNSmlExtDataArray(3);
+	}
+
+// -----------------------------------------------------------------------------
+// TNSmlSetEmailValues::TNSmlSetEmailValues
+// -----------------------------------------------------------------------------
+//
+CNSmlEmailParser::TNSmlSetEmailValues::TNSmlSetEmailValues()
+	{
+	Reset();
+	}
+
+
+// -----------------------------------------------------------------------------
+// TNSmlSetEmailValues::Reset
+// -----------------------------------------------------------------------------
+//
+void CNSmlEmailParser::TNSmlSetEmailValues::Reset()
+	{
+	iEmail = EFalse;
+	iRead = EFalse;
+	iForwarded = EFalse;
+	iReplied = EFalse;
+	iDeleted = EFalse;
+	iFlagged = EFalse;
+	iReceived = EFalse;
+	iCreated = EFalse;
+	iModified = EFalse;
+	iEmailItem = EFalse;
+	iTrunc = EFalse;
+	iTruncBodySize = EFalse;
+	iTruncBodyType = EFalse;
+	iXNam = EFalse;
+	iTruncAttachSize = EFalse;
+	iTruncAttachType = EFalse;
+	iTruncAttachName = EFalse;
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlExtData.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,178 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlExtData* CNSmlExtData::NewL()
+	{
+	CNSmlExtData* self = CNSmlExtData::NewLC();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlExtData* CNSmlExtData::NewLC()
+	{
+	CNSmlExtData* self = new (ELeave) CNSmlExtData();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::~CNSmlExtData
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlExtData::~CNSmlExtData()
+	{
+	if (iXVals) 
+		{
+		iXVals->ResetAndDestroy();
+		delete iXVals;
+		}
+
+	if (iXNam) delete iXNam;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::AddXValL
+// Adds given buffer to iXVals.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlExtData::AddXValL( HBufC8* aXVal )
+	{
+	iXVals->AppendL(aXVal);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::GenerateXmlL
+// Generates ext data xml using aParser and appends the xml to aXml.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlExtData::GenerateXmlL( TPtr8& aXml, const CNSmlXmlParser* aParser) const
+	{
+	if ( aParser == NULL )
+		return;
+
+	aParser->AppendElement(aXml, KExtElement());
+
+	if( iXNam )
+		{
+		aParser->AppendElement(aXml, KExtXNamElement(), *iXNam);
+		}
+	else
+		User::Leave(EMandatoryFieldNotFound);
+
+	if ( iXVals )
+		{
+		for (TInt i=0; i < iXVals->Count(); ++i)
+			{
+			aParser->AppendElement(aXml, KExtXValElement(), *iXVals->At(i));
+			}
+		}
+
+	aParser->AppendEndElement(aXml, KExtElement());
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::CountXmlSize
+// Counts the size of the ext data xml if it was generated with current 
+// values in member variables.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlExtData::CountXmlSize( const CNSmlXmlParser* aParser ) const
+	{
+	TInt size = 0;
+	size += aParser->SizeOfElements( KExtElement() );
+
+	if( iXNam )
+		{
+		size += aParser->SizeOfString( iXNam, KExtXNamElement() );
+		}
+
+	if ( iXVals )
+		{
+		for (TInt i=0; i < iXVals->Count(); ++i)
+			{
+			size += aParser->SizeOfString( iXVals->At(i), KExtXValElement() );
+			}
+		}
+
+	return size;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::ConvertIntoEntitiesL
+// Converts special characters in member variables into entities.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlExtData::ConvertIntoEntitiesL( const CNSmlXmlParser* aParser )
+	{
+	if( iXNam )
+		aParser->CharactersToEntitiesL(iXNam, 0, iXNam->Length());
+
+	if( iXVals )
+		{
+		for (TInt i=0; i < iXVals->Count(); ++i)
+			{
+			aParser->CharactersToEntitiesL(iXVals->At(i), 0, iXVals->At(i)->Length());
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::CNSmlExtData
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CNSmlExtData::CNSmlExtData()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlExtData::ConstructL
+// Second phase construction.
+// -----------------------------------------------------------------------------
+//
+void CNSmlExtData::ConstructL()
+	{
+	iXVals = new (ELeave) CNSmlXValArray(3);
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlFolderAttributeData.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TNSmlFolderAttributeData::TNSmlFolderAttributeData
+// Constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlFolderAttributeData::TNSmlFolderAttributeData()
+: iHidden(EBooleanMissing), iSystem(EBooleanMissing), 
+iArchived(EBooleanMissing), iDelete(EBooleanMissing),
+iWritable(EBooleanMissing), iReadable(EBooleanMissing),
+iExecutable(EBooleanMissing)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// TNSmlFolderAttributeData::AttributeCount
+// Returns the amount of fields that are not EBooleanMissing
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt TNSmlFolderAttributeData::AttributeCount() const
+	{
+	TInt count = 0;
+
+	if ( iHidden ) count++;
+	if ( iSystem ) count++;
+	if ( iArchived ) count++;
+	if ( iDelete ) count++;
+	if ( iWritable ) count++;
+	if ( iReadable ) count++;
+	if ( iExecutable ) count++;
+
+	return count;
+	}
+
+// -----------------------------------------------------------------------------
+// TNSmlFolderAttributeData::GenerateXml
+// Generates attribute xml
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TNSmlFolderAttributeData::GenerateXml( TPtr8& aXml, const CNSmlXmlParser* aParser ) const
+	{
+	aParser->AppendElement(aXml, KFolderAttributesElement());
+
+	if ( iHidden )
+		{
+		aParser->AppendElement(aXml, KAttributeHiddenElement(), aParser->BooleanToString( iHidden ));
+		}
+
+	if ( iSystem )
+		{
+		aParser->AppendElement(aXml, KAttributeSystemElement(), aParser->BooleanToString( iSystem ));
+		}
+
+	if ( iArchived )
+		{
+		aParser->AppendElement(aXml, KAttributeArchivedElement(), aParser->BooleanToString( iArchived ));
+		}
+
+	if ( iDelete )
+		{
+		aParser->AppendElement(aXml, KAttributeDeleteElement(), aParser->BooleanToString( iDelete ));
+		}
+
+	if ( iWritable )
+		{
+		aParser->AppendElement(aXml, KAttributeWritableElement(), aParser->BooleanToString( iWritable ));
+		}
+
+	if ( iReadable )
+		{
+		aParser->AppendElement(aXml, KAttributeReadableElement(), aParser->BooleanToString( iReadable ));
+		}
+
+	if ( iExecutable )
+		{
+		aParser->AppendElement(aXml, KAttributeExecutableElement(), aParser->BooleanToString( iExecutable ));
+		}
+
+	aParser->AppendEndElement(aXml, KFolderAttributesElement());
+	}
+
+// -----------------------------------------------------------------------------
+// TNSmlFolderAttributeData::CountXmlSize
+// Coounts the size of the xml if it was generated using the values currently in 
+// member variables
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt TNSmlFolderAttributeData::CountXmlSize( const CNSmlXmlParser* aParser ) const
+	{
+	TInt size = 0;
+	size += aParser->SizeOfElements( KFolderAttributesElement() );
+
+	if ( iHidden )
+		{
+		size += aParser->SizeOfBoolean( iHidden, KAttributeHiddenElement() );
+		}
+
+	if ( iSystem )
+		{
+		size += aParser->SizeOfBoolean( iSystem, KAttributeSystemElement() );
+		}
+
+	if ( iArchived )
+		{
+		size += aParser->SizeOfBoolean( iArchived, KAttributeArchivedElement() );
+		}
+
+	if ( iDelete )
+		{
+		size += aParser->SizeOfBoolean( iDelete, KAttributeDeleteElement() );
+		}
+
+	if ( iWritable )
+		{
+		size += aParser->SizeOfBoolean( iWritable, KAttributeWritableElement() );
+		}
+
+	if ( iReadable )
+		{
+		size += aParser->SizeOfBoolean( iReadable, KAttributeReadableElement() );
+		}
+
+	if ( iExecutable )
+		{
+		size += aParser->SizeOfBoolean( iExecutable, KAttributeExecutableElement() );
+		}
+
+	return size;
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlFolderParser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,631 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlFolderParser* CNSmlFolderParser::NewL()
+	{
+	CNSmlFolderParser* self = CNSmlFolderParser::NewLC();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlFolderParser* CNSmlFolderParser::NewLC()
+	{
+	CNSmlFolderParser* self = new (ELeave) CNSmlFolderParser();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::~CNSmlFolderParser
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlFolderParser::~CNSmlFolderParser()
+	{
+	if(iExt) 
+		{
+		iExt->ResetAndDestroy();
+		delete iExt;
+		}
+
+	if(iName) delete iName;
+	if(iRole) delete iRole;
+
+	if( iExtData ) delete iExtData;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::ParseXml
+// Parses through the given XML and places the data to member variables.
+// Note: The string-values in CNSmlEmailParser are NOT copies, but 
+// references to aXml. The method does not check whether the member variables 
+// already contains data or not, but just writes it (if some of them are already 
+// instantiated dynamically, they should be deleted before this method is called).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlFolderParser::ParseXml( HBufC8* aXml )
+	{
+
+	TRAPD(cdataErr, PreProcessL(aXml));
+	if (cdataErr != EErrorNone)
+		return (TNSmlParserGeneratorError)cdataErr;
+
+	iSetValues.Reset();
+	iCurrentState = EFolderNone;
+	iLastState = EFolderNone;
+	TPtrC8 ptr(*aXml);
+
+	TRAPD(err, ParseL( ptr ));
+
+	if( err == EErrorNone && iCurrentState != EFolderNone )
+		return EInvalidXmlError;
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::GenerateXml
+// Generates Folder-XML using the values in member variables. aXml contains the 
+// generated xml when the function returns successfully. Note: caller should not 
+// instantiate the HBufC8, since this method first counts the size of the 
+// xml to be generated and then instatiates the HBufC8 with a correct maximum size.
+// If the given buffer is not NULL, it is destroyed and a new one is instantiated.
+// Caller gets the control of the HBufC8 when the function returns.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TNSmlParserGeneratorError CNSmlFolderParser::GenerateXml( HBufC8*& aXml ) 
+	{
+
+	TRAPD( err, ConvertIntoEntitiesL(); // convert special characters into entities
+	
+			GenerateFolderXmlL( aXml ) );
+
+	return CheckError(err);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::GenerateFolderXmlL
+// Private methods that does the actual folder xml generation
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::GenerateFolderXmlL( HBufC8*& aXml )
+	{
+	// count the size of the xml
+	TInt size = CountXmlSizeL();
+
+	// create buffer for the xml
+
+	if ( aXml )
+		{
+		delete aXml;
+		aXml = NULL;
+		}
+
+	aXml = HBufC8::NewLC(size);
+	TPtr8 ptr = aXml->Des();
+
+	AppendElement(ptr, KFolderElement());
+
+	if ( iName )
+		{
+		AppendElement(ptr, KFolderNameElement(), *iName);
+		}
+
+	if (iCreated != Time::NullTTime())
+		{
+		AppendElement(ptr, KFolderCreatedElement(), DateTimeToStringL(iCreated));
+		}
+
+	if (iModified != Time::NullTTime())
+		{
+		AppendElement(ptr, KFolderModifiedElement(), DateTimeToStringL(iModified));
+		}
+
+	if (iAccessed != Time::NullTTime())
+		{
+		AppendElement(ptr, KFolderAccessedElement(), DateTimeToStringL(iAccessed));
+		}
+
+	if (iAttributes.AttributeCount() > 0)
+		{
+		iAttributes.GenerateXml(ptr, this);
+		}
+
+	if ( iRole )
+		{
+		AppendElement(ptr, KFolderRoleElement(), *iRole);
+		}
+
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			iExt->At(i)->GenerateXmlL(ptr, this);
+			}
+
+		}
+
+	AppendEndElement(ptr, KFolderElement());
+
+	CleanupStack::Pop(); // aXml
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::CountXmlSizeL
+// Counts how long the xml string will be if it was generated using 
+// the values currently in member variables.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlFolderParser::CountXmlSizeL()
+	{
+	TInt size = 0;
+
+	size += SizeOfElements( KFolderElement() );
+	size += KCDataStart().Length() + KCDataEnd().Length();
+
+	if ( iName )
+		{
+		size += SizeOfString( iName, KFolderNameElement() );
+		}
+
+	if (iCreated != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KFolderCreatedElement() );
+		}
+
+	if (iModified != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KFolderModifiedElement() );
+		}
+
+	if (iAccessed != Time::NullTTime())
+		{
+		size += SizeOfDatetime( KFolderAccessedElement() );
+		}
+
+	// attributes, if any present
+	if (iAttributes.AttributeCount() > 0)
+		{
+		size += iAttributes.CountXmlSize( this );
+		}
+
+	if ( iRole )
+		{
+		size += SizeOfString( iRole, KFolderRoleElement() );
+		}
+
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			size += iExt->At(i)->CountXmlSize( this );
+			}
+		}
+
+	return size;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::AddExtL
+// Adds the given extension to iExt
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlFolderParser::AddExtL( CNSmlExtData* aExt )
+	{
+	iExt->AppendL(aExt);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::NextElementL
+// Base class' ParseL method calls this method, when a new element is found. aElement 
+// is the name of that element (string inside '<' and '>' characters).
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::NextElementL( TPtrC8 aElement )
+	{
+	if (aElement.Length() == 0)
+		User::Leave(EInvalidXmlError);
+
+	TBool startElement = ETrue;
+
+	if(aElement[0] == KCharacterSlash)
+		{
+		// end element
+		// remove the '/' character from the beginning
+		aElement.Set( aElement.Right( aElement.Length() - 1 ) );
+		startElement = EFalse;
+		}
+#ifndef __NO_EMPTY_ELEMENTS_
+	else if (aElement[aElement.Length()-1] == KCharacterSlash)
+		{
+		// empty element
+		// remove the '/' character from the end
+		aElement.Set( aElement.Left( aElement.Length() - 1 ) );
+
+		// empty element == start element, empty data, end element
+		NextElementL( aElement ); // simulates start element
+		NextDataL( _L8("") ); // simulates the empty data
+
+		HBufC8* end = HBufC8::NewLC(aElement.Length()+1);
+		TPtr8 ptr = end->Des();
+		ptr.Append( _L8("/") );
+		ptr.Append( aElement );
+
+		NextElementL( ptr ); // simulates end element
+
+		CleanupStack::PopAndDestroy(); // end
+
+		return;
+		}
+#endif
+
+	// variables used for state, init to <Folder> and not set
+	TNSmlCurrentFolderElement inner = EFolder;
+	TNSmlCurrentFolderElement outer = EFolder;
+	TBool isSet = EFalse;
+
+	if( aElement == KFolderElement )
+		{
+		outer = EFolderNone;
+		isSet = iSetValues.iFolder;
+		if ( startElement ) iSetValues.iFolder = ETrue;
+		}
+	else if( aElement == KFolderNameElement )
+		{
+		inner = EFolderName;
+		isSet = iSetValues.iName;
+		}
+	else if( aElement == KFolderCreatedElement )
+		{
+		inner = EFolderCreated;
+		isSet = iSetValues.iCreated;
+		}
+	else if( aElement == KFolderModifiedElement )
+		{
+		inner = EFolderModified;
+		isSet = iSetValues.iModified;
+		}
+	else if( aElement == KFolderAccessedElement )
+		{
+		inner = EFolderAccessed;
+		isSet = iSetValues.iAccessed;
+		}
+	else if( aElement == KFolderAttributesElement )
+		{
+		inner = EAttributes;
+		isSet = iSetValues.iAttributes;
+		if ( startElement) iSetValues.iAttributes = ETrue;
+		}
+	else if( aElement == KAttributeHiddenElement )
+		{
+		inner = EAttributesH;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesH;
+		}
+	else if( aElement == KAttributeSystemElement )
+		{
+		inner = EAttributesS;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesS;
+		}
+	else if( aElement == KAttributeArchivedElement )
+		{
+		inner = EAttributesA;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesA;
+		}
+	else if( aElement == KAttributeDeleteElement )
+		{
+		inner = EAttributesD;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesD;
+		}
+	else if( aElement == KAttributeWritableElement )
+		{
+		inner = EAttributesW;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesW;
+		}
+	else if( aElement == KAttributeReadableElement )
+		{
+		inner = EAttributesR;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesR;
+		}
+	else if( aElement == KAttributeExecutableElement )
+		{
+		inner = EAttributesX;
+		outer = EAttributes;
+		isSet = iSetValues.iAttributesX;
+		}
+	else if( aElement == KFolderRoleElement )
+		{
+		inner = EFolderRole;
+		isSet = iSetValues.iRole;
+		}
+	else if( aElement == KExtElement )
+		{
+		inner = EFolderExt;
+
+		if ( startElement )
+			{
+			if( iExtData )
+				{
+				delete iExtData;
+				iExtData = NULL;
+				}
+			iExtData = CNSmlExtData::NewL();
+			iSetValues.iXNam = EFalse;
+			}
+		else
+			{
+			if( !iSetValues.iXNam ) User::Leave(EMandatoryFieldNotFound); // xnam not set
+			iExt->AppendL(iExtData);
+			iExtData = NULL;
+			}
+		}
+	else if( aElement == KExtXNamElement )
+		{
+		inner = EFolderExtXNam;
+		outer = EFolderExt;
+		isSet = iSetValues.iXNam;
+		}
+	else if( aElement == KExtXValElement )
+		{
+		inner = EFolderExtXVal;
+		outer = EFolderExt;
+		}
+	else
+		{
+		User::Leave(EInvalidXmlError);
+		}
+
+
+	// finally, change state depending on was the element start or end element
+	if ( startElement )
+		{
+		StartElementStateChangeL( outer, inner, isSet );
+		}
+	else
+		{
+		EndElementStateChangeL( inner, outer );
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::NextDataL
+// Base class' ParseL method calls this method, when a data is read from xml,
+// but that data is not element name (data inside or between elements).
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::NextDataL( TPtrC8 aData )
+	{
+	switch(iCurrentState)
+		{
+		case EFolderNone:
+		case EFolder:
+		case EAttributes:
+		case EFolderExt:
+			LeaveIfNotWhiteSpaceL( aData );
+			break;
+		case EFolderName:
+			iName = aData.AllocL();
+			iSetValues.iName = ETrue;
+			break;
+		case EFolderCreated:
+			iCreated = StringToTTimeL(aData);
+			iSetValues.iCreated = ETrue;
+			break;
+		case EFolderModified:
+			iModified = StringToTTimeL(aData);
+			iSetValues.iModified = ETrue;
+			break;
+		case EFolderAccessed:
+			iAccessed = StringToTTimeL(aData);
+			iSetValues.iAccessed = ETrue;
+			break;
+		case EAttributesH:
+			iAttributes.iHidden = StringToBooleanL(aData);
+			iSetValues.iAttributesH = ETrue;
+			break;
+		case EAttributesS:
+			iAttributes.iSystem = StringToBooleanL(aData);
+			iSetValues.iAttributesS = ETrue;
+			break;
+		case EAttributesA:
+			iAttributes.iArchived = StringToBooleanL(aData);
+			iSetValues.iAttributesA = ETrue;
+			break;
+		case EAttributesD:
+			iAttributes.iDelete = StringToBooleanL(aData);
+			iSetValues.iAttributesD = ETrue;
+			break;
+		case EAttributesW:
+			iAttributes.iWritable = StringToBooleanL(aData);
+			iSetValues.iAttributesW = ETrue;
+			break;
+		case EAttributesR:
+			iAttributes.iReadable = StringToBooleanL(aData);
+			iSetValues.iAttributesR = ETrue;
+			break;
+		case EAttributesX:
+			iAttributes.iExecutable = StringToBooleanL(aData);
+			iSetValues.iAttributesX = ETrue;
+			break;
+		case EFolderRole:
+			iRole = aData.AllocL();
+			iSetValues.iRole = ETrue;
+			break;
+		case EFolderExtXNam:
+			iExtData->iXNam = aData.AllocL();
+			iSetValues.iXNam = ETrue;
+			break;
+		case EFolderExtXVal:
+			iExtData->AddXValL(aData.AllocL());
+			break;
+		default:
+			User::Leave(EUnknownError); // should never happen
+			break;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::StartElementStateChangeL
+// Checks that the state change (new start element) is legal (right order of 
+// elements and element not already set) and changes the state.
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::StartElementStateChangeL(TNSmlCurrentFolderElement aCurrentState, 
+											     TNSmlCurrentFolderElement aNextState, 
+											     TBool aIsSet)
+	{
+	if( aIsSet || iCurrentState != aCurrentState || aNextState < iLastState )
+		{
+		User::Leave(EInvalidXmlError);
+		}
+
+	iLastState = iCurrentState;
+	iCurrentState = aNextState;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::EndElementStateChangeL
+// Checks that the state change (new end element) is legal (right order of 
+// elements and element not already set) and changes the state.
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::EndElementStateChangeL(TNSmlCurrentFolderElement aCurrentState, 
+											   TNSmlCurrentFolderElement aNextState )
+	{
+	if( iCurrentState != aCurrentState )
+		{
+		User::Leave(EInvalidXmlError);
+		}
+
+	iLastState = iCurrentState;
+	iCurrentState = aNextState;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::ConvertIntoEntitiesL
+// Converts special characters of this email-dataobject to corresponding 
+// characters. 
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::ConvertIntoEntitiesL()
+	{
+	// name
+	if ( iName )
+		{
+		CharactersToEntitiesL(iName, 0, iName->Length());
+		}
+
+	// role
+	if ( iRole )
+		{
+		CharactersToEntitiesL(iRole, 0, iRole->Length());
+		}
+
+	// extensions
+	if ( iExt )
+		{
+		for (TInt i=0; i < iExt->Count(); ++i)
+			{
+			iExt->At(i)->ConvertIntoEntitiesL(this);
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::CNSmlFolderParser
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CNSmlFolderParser::CNSmlFolderParser()
+	: iCreated(Time::NullTTime()), iModified(Time::NullTTime()), 
+	iAccessed(Time::NullTTime())
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::ConstructL
+// Second phase construction
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::ConstructL()
+	{
+	iExt = new (ELeave) CNSmlExtDataArray(3);
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::TNSmlSetFolderValues::TNSmlSetFolderValues
+// -----------------------------------------------------------------------------
+//
+CNSmlFolderParser::TNSmlSetFolderValues::TNSmlSetFolderValues()
+	{
+	Reset();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlFolderParser::TNSmlSetFolderValues::Reset
+// -----------------------------------------------------------------------------
+//
+void CNSmlFolderParser::TNSmlSetFolderValues::Reset()
+	{
+	iFolder = EFalse;
+	iName = EFalse;
+	iCreated = EFalse;
+	iModified = EFalse;
+	iAccessed = EFalse;
+	iAttributes = EFalse;
+	iAttributesH = EFalse;
+	iAttributesS = EFalse;
+	iAttributesA = EFalse;
+	iAttributesD = EFalse;
+	iAttributesW = EFalse;
+	iAttributesR = EFalse;
+	iAttributesX = EFalse;
+	iXNam = EFalse;
+	iRole = EFalse;
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/NSmlTruncatedData.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,305 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32buf.h>
+#include <s32file.h>
+
+#include "nsmlxmlparser.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlTruncatedData* CNSmlTruncatedData::NewL()
+	{
+	CNSmlTruncatedData* self = CNSmlTruncatedData::NewLC();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlTruncatedData* CNSmlTruncatedData::NewLC()
+	{
+	CNSmlTruncatedData* self = new (ELeave) CNSmlTruncatedData();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::~CNSmlTruncatedData
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNSmlTruncatedData::~CNSmlTruncatedData()
+	{
+	iAttachments.ResetAndDestroy();
+	iAttachments.Close();
+
+	iBodys.ResetAndDestroy();
+	iBodys.Close();
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::AddAttachmentL
+// Adds an attachment to iAttachments. Takes copies of buffers, caller must
+// destroy the original buffers.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlTruncatedData::AddAttachmentL(HBufC8* aName, TInt aSize, HBufC8* aType)
+	{
+	CNSmlAttachmentTruncateInfo* attach = new (ELeave) CNSmlAttachmentTruncateInfo();
+	CleanupStack::PushL(attach);
+
+	attach->SetMembersL(aName, aType, aSize);
+
+	iAttachments.Append(attach);
+
+	CleanupStack::Pop(); // attach
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::AddBodyL
+// Adds a body. Takes copies of buffers, caller must destroy the 
+// original buffers.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlTruncatedData::AddBodyL(TInt aSize, HBufC8* aType)
+	{
+	CNSmlBodyTruncateInfo* body = new (ELeave) CNSmlBodyTruncateInfo();
+	CleanupStack::PushL(body);
+
+	body->SetMembersL(aType, aSize);
+
+	iBodys.Append(body);
+
+	CleanupStack::Pop(); // body
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::GenerateXmlL
+// Generates truncate data xml
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlTruncatedData::GenerateXmlL( TPtr8& aXml, const CNSmlXmlParser* aParser ) const
+	{
+	aParser->AppendElement(aXml, KTruncatedElement());
+	
+	TInt size = 0;
+	HBufC8* type = 0;
+	HBufC8* name = 0;
+
+	for ( TInt j = 0; j < iBodys.Count(); ++j )
+		{
+		iBodys[j]->GetMembersL(type, size);
+
+		aParser->AppendElement(aXml, KTruncatedBodyElement());
+
+		if ( size != KErrNotFound )
+			{
+			aParser->AppendElement(aXml, KTruncatedSizeElement(), aParser->IntegerToString(size));
+			}
+
+		if ( type )
+			{
+			aParser->AppendElement(aXml, KTruncatedTypeElement(), *type);
+			delete type; type = NULL;
+			}
+
+		aParser->AppendEndElement(aXml, KTruncatedBodyElement());
+		}
+
+	for ( TInt i = 0; i < iAttachments.Count(); ++i )
+		{
+		size = 0;
+		type = NULL;
+		name = NULL;
+
+		iAttachments[i]->GetMembersL(name, type, size);
+
+		aParser->AppendElement(aXml, KTruncatedAttachElement());
+
+		if ( name )
+			{
+			aParser->AppendElement(aXml, KTruncatedNameElement(), *name);
+			delete name; name = NULL;
+			}
+
+		if ( size != KErrNotFound )
+			{
+			aParser->AppendElement(aXml, KTruncatedSizeElement(), aParser->IntegerToString(size));
+			}
+
+		if ( type )
+			{
+			aParser->AppendElement(aXml, KTruncatedTypeElement(), *type);
+			delete type; type = NULL;
+			}
+
+		aParser->AppendEndElement(aXml, KTruncatedAttachElement());
+		}
+
+	aParser->AppendEndElement(aXml, KTruncatedElement());
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::CountXmlSizeL
+// Counts the size of truncate data xml if it was generated using current values
+// in member variables.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CNSmlTruncatedData::CountXmlSizeL( const CNSmlXmlParser* aParser ) const
+	{
+	TInt size = 0;
+	size += aParser->SizeOfElements( KTruncatedElement() );
+		
+	for ( TInt j = 0; j < iBodys.Count(); ++j )
+		{
+		TInt bodySize = 0;
+		HBufC8* bodyType = 0;
+		iBodys[j]->GetMembersL(bodyType, bodySize);
+
+		size += aParser->SizeOfElements( KTruncatedBodyElement() );
+
+		if ( bodySize != KErrNotFound )
+			{
+			size += aParser->SizeOfInteger( KTruncatedSizeElement() );
+			}
+
+		if ( bodyType )
+			{
+			size += aParser->SizeOfString( bodyType, KTruncatedTypeElement() );
+			delete bodyType; bodyType = NULL;
+			}
+
+		}
+
+	for ( TInt i = 0; i < iAttachments.Count(); ++i )
+		{
+		TInt attachSize = 0;
+		HBufC8* attachType = 0;
+		HBufC8* attachName = 0;
+		iAttachments[i]->GetMembersL(attachName, attachType, attachSize);
+
+		size += aParser->SizeOfElements( KTruncatedAttachElement() );
+
+		if ( attachName )
+			{
+			size += aParser->SizeOfString( attachName, KTruncatedNameElement() );
+			delete attachName; attachName = NULL;
+			}
+
+		if ( attachSize != KErrNotFound )
+			{
+			size += aParser->SizeOfInteger( KTruncatedSizeElement() );
+			}
+
+		if ( attachType )
+			{
+			size += aParser->SizeOfString( attachType, KTruncatedTypeElement() );
+			delete attachType; attachType = NULL;
+			}
+
+		}
+
+	return size;
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::ConvertIntoEntitiesL
+// Converts special characters in strings into entities.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNSmlTruncatedData::ConvertIntoEntitiesL( const CNSmlXmlParser* aParser )
+	{
+	TInt size = 0;
+	HBufC8* type = NULL;
+	HBufC8* name = NULL;
+
+	for ( TInt j = 0; j < iBodys.Count(); ++j )
+		{
+		iBodys[j]->GetMembersL(type, size);
+		CleanupStack::PushL(type);
+
+		if( type )
+			aParser->CharactersToEntitiesL(type, 0, type->Length());
+
+		iBodys[j]->SetMembersL(type, size);
+		CleanupStack::Pop(); // type
+		delete type; type = NULL;
+		}
+
+	for ( TInt i = 0; i < iAttachments.Count(); ++i )
+		{
+		iAttachments[i]->GetMembersL(name, type, size);
+		CleanupStack::PushL(type);
+		CleanupStack::PushL(name);
+
+		if( name )
+			{
+			aParser->CharactersToEntitiesL(name, 0, name->Length());
+			}
+		if( type )
+			{
+			aParser->CharactersToEntitiesL(type, 0, type->Length());
+			}
+
+		iAttachments[i]->SetMembersL(name, type, size);
+		CleanupStack::Pop(2); // name, type
+
+		delete name; name = NULL;
+		delete type; type = NULL;
+		}
+
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::CNSmlTruncatedData
+// Private constructor
+// -----------------------------------------------------------------------------
+//
+CNSmlTruncatedData::CNSmlTruncatedData()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CNSmlTruncatedData::ConstructL
+// Second phase construction
+// -----------------------------------------------------------------------------
+//
+void CNSmlTruncatedData::ConstructL()
+	{
+	iAttachments.Reset();
+	iBodys.Reset();
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/dsutils/emailxmlutils/src/nsmlxmlparser.cpp	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,797 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  Sources
+*
+*/
+
+
+// 1.2 Changes: nsmlxmlparser module added
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <s32buf.h>
+#include <s32file.h>
+#include "nsmlxmlparser.h"
+
+
+// ------------------------------------------------------------------------------------------------
+// 
+// CNSmlXmlParser methods
+// 
+// ------------------------------------------------------------------------------------------------
+
+// ------------------------------------------------------------------------------------------------
+// Constructor
+// ------------------------------------------------------------------------------------------------
+EXPORT_C CNSmlXmlParser::CNSmlXmlParser()
+	{
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Destructor.
+// ------------------------------------------------------------------------------------------------
+EXPORT_C CNSmlXmlParser::~CNSmlXmlParser()
+	{
+	if( iBuffer ) delete iBuffer;
+	if ( iCompleteBuffer ) delete iCompleteBuffer;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Parses the given string for cdata areas and entitys. If a cdata area is 
+// found, the data in it is skipped over. The entities outside cdata are converted 
+// into characters they represent (but only if cdata is found).
+// Note: This method is intended for processing the CDATA used right after <Data>. 
+// I.e. this method removes the cdata-elements used for wrapping the whole xml data 
+// and processes the string so that the inner cdatas used in the xml become valid.
+// THIS METHOD SHOULD BE CALLED RIGHT IN THE BEGINNING OF PARSING IF <Data>-BLOCK 
+// IS WRAPPED WITHIN CDATA.
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::PreProcessL( HBufC8* aXml ) const
+	{
+	// take a modifiable pointer
+	TPtr8 xml = aXml->Des();
+
+	// the string used for searching and moving in the string
+	TPtrC8 searchString(*aXml);
+
+	// the current position in the original string
+	TInt searchStartPos = 0;
+
+	// find the first cdata start
+	TInt cdataStartPos = searchString.Find(KCDataStart);
+	
+	// If CDATA is not found from beginning then data is not inside CDATA and then
+	// preprocessing is not needed
+	if ( cdataStartPos != 0 )
+	    {
+	    return;
+	    }
+
+	TInt cdataEndPos = KErrNotFound;
+
+	// while cdata is found
+	while ( cdataStartPos != KErrNotFound )
+		{
+		cdataStartPos += searchStartPos;
+
+		// find an end of cdata before entities are converted
+		cdataEndPos = searchString.Find(KCDataEnd);
+
+		// convert entities between search start and cdata start
+		TInt entityChange = EntitiesToCharactersL(aXml, searchStartPos, cdataStartPos);
+		xml.Set(aXml->Des());
+		cdataStartPos += entityChange;
+
+		if ( cdataEndPos != KErrNotFound )
+			{
+			cdataEndPos += entityChange;
+			cdataEndPos += searchStartPos;
+
+			// if the end is before start -> error
+			if (cdataEndPos < cdataStartPos)
+				User::Leave( EInvalidCDataStructure );
+				
+			// remove cdata end
+			xml.Delete(cdataEndPos, KCDataEnd().Length());
+			// remove cdata start
+			xml.Delete(cdataStartPos, KCDataStart().Length());
+
+			searchStartPos = cdataEndPos - KCDataStart().Length();
+			searchString.Set( xml.Right(xml.Length() - searchStartPos) );
+			}
+		else 
+			{
+			// the end of cdata was not found or cdata end was before start -> error
+			User::Leave( EInvalidCDataStructure );
+			}
+
+		// find a new cdata start that is after the found end
+		cdataStartPos = searchString.Find(KCDataStart);
+
+		}
+
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Return the TNSmlBoolean-value's string-representation.
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlXmlParser::BooleanToString( const TNSmlBoolean aValue ) const
+	{
+	TPtrC8 str;
+	switch(aValue)
+		{
+		case EBooleanTrue:
+			{
+			str.Set(KStringTrue);
+			break;
+			}
+		case EBooleanFalse:
+			{
+			str.Set(KStringFalse);
+			break;
+			}
+		default:
+			{
+			str.Set(KStringEmpty);
+			}
+		}
+
+	return str;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the TTime-value's string-representation.
+// ------------------------------------------------------------------------------------------------
+TBuf8<KDateTimeLength> CNSmlXmlParser::DateTimeToStringL( const TTime& aValue ) const
+	{
+	TBuf<KDateTimeLength> str;
+	
+	// aValue is not changed but Z character is added to the end of string.
+	// Messaging uses UTC times and that is reason why time is not changed.
+	aValue.FormatL( str, _L("%F%Y%M%DT%H%T%SZ") );
+
+	// from 16-bit to 8-bit
+	TBuf8<KDateTimeLength> dt;
+	dt.Copy(str);
+
+	return dt;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the integer value's string-representation.
+// ------------------------------------------------------------------------------------------------
+TBuf8<KIntegerMaxLength> CNSmlXmlParser::IntegerToString( const TInt aValue ) const
+	{
+	TBuf8<KIntegerMaxLength> str;
+	str.AppendNum(aValue);
+	return str;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the boolean representation of the string or leaves if error (EInvalidBooleanValue).
+// ------------------------------------------------------------------------------------------------
+TNSmlBoolean CNSmlXmlParser::StringToBooleanL( const TPtrC8& aValue ) const
+	{
+	if( aValue == KStringTrue )
+		return EBooleanTrue;
+	else if( aValue == KStringFalse || aValue == KStringEmpty )
+		return EBooleanFalse;
+	else
+		User::Leave(EInvalidBooleanValue);
+
+	return EBooleanMissing;
+	}
+
+	
+// ------------------------------------------------------------------------------------------------
+// Returns the integer representation of the string or leaves if error (EInvalidIntegerValue).
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::StringToIntegerL( const TPtrC8& aValue ) const
+	{
+	if (aValue.Length() <= 0)
+		return 0;
+
+	// convert the data to an integer
+	TLex8 lex(aValue);
+	TUint uValue = 0;
+	TBool isNegative = EFalse;
+
+	TChar c = lex.Peek();
+
+	// check for a minus or plus sign
+	if ( c == '-' )
+		{
+		isNegative = ETrue;
+		lex.Inc();
+		}
+	else if ( c == '+' )
+		{
+		lex.Inc();
+		}
+
+	TRadix radix = EDecimal;
+	c = lex.Peek();
+
+	if (c == '0') // octal or hex
+		{
+		lex.Get();
+		c = lex.Get();
+		if ( c == 'x' || c == 'X' )
+			{
+			radix = EHex;
+			}
+		else
+			{
+			radix = EOctal;
+			lex.UnGet(); // back up
+			}
+		}
+
+	TInt err = lex.Val(uValue, radix);
+	if ( err != KErrNone )
+		User::Leave(EInvalidIntegerValue);
+
+	TInt value = uValue;
+
+	return isNegative ? value*(-1) : value;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the TTime representation of the string or leaves if error (EInvalidDatetimeValue).
+// UTC times are not supported, i.e. datetimes that have Z-ending are treated as 
+// local times.
+// ------------------------------------------------------------------------------------------------
+TTime CNSmlXmlParser::StringToTTimeL( TPtrC8& aValue ) const
+	{
+	// check that there is data
+	if (aValue.Length() <= 0)
+		User::Leave( EInvalidDatetimeValue );
+
+	// format the data into a TTime
+
+	if (aValue[aValue.Length()-1] == 'Z')
+		{
+		// The datetime is in UTC, which is not supported
+		// no correction done, treat as local time
+		aValue.Set( aValue.Left( aValue.Length()-1 ) );
+		}
+
+	TDateTime datetime(0,(TMonth)0,0,0,0,0,0);
+
+	// read datetime and check errors
+
+	TInt error = KErrNone;
+
+	// read year
+	TPtrC8 str = aValue.Left(4);
+	TLex8 lex(str);
+	TInt value;
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	error  = datetime.SetYear(value);
+	CheckDatetimeErrorL( error );
+
+	// read month
+	str.Set(aValue.Mid(4, 2));
+	lex.Assign(str);
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	--value;
+	error = datetime.SetMonth((TMonth)value);
+	CheckDatetimeErrorL( error );
+
+	// read day
+	str.Set(aValue.Mid(6, 2));
+	lex.Assign(str);
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	--value;
+	error = datetime.SetDay(value);
+	CheckDatetimeErrorL( error );
+
+	// Skip character 'T' and read hour
+	str.Set(aValue.Mid(9, 2));
+	lex.Assign(str);
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	error = datetime.SetHour(value);
+	CheckDatetimeErrorL( error );
+
+	// minutes
+	str.Set(aValue.Mid(11, 2));
+	lex.Assign(str);
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	error = datetime.SetMinute(value);
+	CheckDatetimeErrorL( error );
+
+	// seconds
+	str.Set(aValue.Mid(13, 2));
+	lex.Assign(str);
+	error = lex.Val(value);
+	CheckDatetimeErrorL( error );
+	error = datetime.SetSecond(value);
+	CheckDatetimeErrorL( error );
+
+	return TTime(datetime);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Adds start element, the value and end element to aPtr.
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::AppendElement( TPtr8& aPtr, const TDesC8& aElementName, const TDesC8& aValue ) const
+	{
+	// start element
+	aPtr.Append(KElementStart);
+	aPtr.Append(aElementName);
+	aPtr.Append(KElementEnd);
+
+	// value
+	aPtr.Append(aValue);
+
+	// end element
+	aPtr.Append(KElementStart);
+	aPtr.Append(KCharacterSlash);
+	aPtr.Append(aElementName);
+	aPtr.Append(KElementEnd);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Forms an element using the given element name and appends it to the given string.
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::AppendElement( TPtr8& aPtr, const TDesC8& aElementName ) const
+	{
+	aPtr.Append(KElementStart);
+	aPtr.Append(aElementName);
+	aPtr.Append(KElementEnd);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Forms an end element using the given element name and appends it to the given string.
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::AppendEndElement( TPtr8& aPtr, const TDesC8& aElementName ) const
+	{
+	aPtr.Append(KElementStart);
+	aPtr.Append(KCharacterSlash);
+	aPtr.Append(aElementName);
+	aPtr.Append(KElementEnd);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the total length of start and end tag.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::SizeOfElements( const TDesC8& aElementName ) const
+	{
+	TInt size = 0;
+
+	// start element plus end element ( 1 = length of '/' char )
+	size += 2*aElementName.Length() + 1;
+	size += 2*KElementStartEndWidth; // '<' and '>'
+
+	return size;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the length of the given boolean element and it's data if it was a string.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::SizeOfBoolean( const TNSmlBoolean aValue, const TDesC8& aElementName ) const
+	{
+	TInt size = 0;
+	size += SizeOfElements( aElementName );
+	switch ( aValue )
+		{
+		case EBooleanTrue:
+			return size+4; // "true"
+		case EBooleanFalse:
+			return size+5; // "false"
+		default:
+			return 0;
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the length of the given datetime element and it's data if it was a string.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::SizeOfDatetime( const TDesC8& aElementName ) const
+	{
+	TInt size = SizeOfElements( aElementName ) + KDateTimeLength;
+	return size;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the maximum length of the given integer element and it's data if it was a string.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::SizeOfInteger( const TDesC8& aElementName ) const
+	{
+	TInt size = SizeOfElements( aElementName ) + KIntegerMaxLength;
+	return size;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns the length of the given string element and it's data if it was a string.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::SizeOfString( const HBufC8* aValue, const TDesC8& aElementName ) const
+	{
+	TInt size = SizeOfElements( aElementName ) + aValue->Length();
+	return size;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Finds entities and replaces them with the characters they represent. Returns 
+// an integer indicating the size change in aXml.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::EntitiesToCharactersL( HBufC8*& aXml, TInt aStartPos, TInt aEndPos ) const
+	{
+	TInt change = 0;
+	TInt changeSum = 0;
+
+	change = ReplaceL(aXml, KEntityLT, KLessThan, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KEntityGT, KGreaterThan, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KEntityAMP, KAmpersand, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KEntityAPOS, KApostrophe, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KEntityQUOT, KQuotation, aStartPos, aEndPos);
+	changeSum += change;
+
+	return changeSum;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Finds special characters and replaces them with corresponding entities. Returns 
+// an integer indicating the size change in aXml.
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::CharactersToEntitiesL( HBufC8*& aXml, TInt aStartPos, TInt aEndPos ) const
+	{
+	TInt change = 0;
+	TInt changeSum = 0;
+
+	// Note: this replace has to be the first one, since it changes 
+	// &-characters to &amp;s and all the other replaces generate 
+	// &-characters as they are entities.
+	change = ReplaceL(aXml, KAmpersand, KEntityAMP, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KLessThan, KEntityLT, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KGreaterThan, KEntityGT, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KApostrophe, KEntityAPOS, aStartPos, aEndPos);
+	changeSum += change;
+	aEndPos += change;
+
+	change = ReplaceL(aXml, KQuotation, KEntityQUOT, aStartPos, aEndPos);
+	changeSum += change;
+
+	return changeSum;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Returns ETrue if all the characters in the given text are whitespace 
+// characters, else EFalse.
+// ------------------------------------------------------------------------------------------------
+TBool CNSmlXmlParser::IsWhitespace( const TDesC8& aText ) const
+	{
+	// loop the string character by character
+	TText c;
+	for ( TInt i=0; i < aText.Length(); ++i )
+		{
+		c = aText[i];
+		switch( c )
+			{
+			case KWhitespaceEmpty:
+				break;
+			case KWhitespaceLineFeed:
+				break;
+			case KWhitespaceNewLine:
+				break;
+			case KWhitespaceTabular:
+				break;
+			case KWhitespaceLineFeedNewLine:
+				break;
+			default:
+				return EFalse;
+			}
+		}
+
+	return ETrue;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Leaves with EInvalidXmlError if the given string is not whitespace.
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::LeaveIfNotWhiteSpaceL( const TDesC8& aText ) const
+	{
+	if ( !IsWhitespace( aText ) )
+		{
+		User::Leave( EInvalidXmlError );
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Maps the given value to TNSmlParserGeneratorError.
+// ------------------------------------------------------------------------------------------------
+TNSmlParserGeneratorError CNSmlXmlParser::CheckError( const TInt error ) const
+	{
+	if ( error == KErrNoMemory )
+		{
+		return EOutOfMemory;
+		}
+	else if ( error < KErrNone )
+		{
+		// some system wide error, should not occur
+		return EUnknownError;
+		}
+	else if ( error != EErrorNone )
+		{
+		return (TNSmlParserGeneratorError)error;
+		}
+
+	return EErrorNone;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Parses the given xml and calls NextDataL and NextElementL methods when finds 
+// data or element. 
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::ParseL( TPtrC8& aXml )
+	{
+
+	ResetBufferL(iBuffer);
+	ResetBufferL(iCompleteBuffer);
+
+	// boolean indicating if reading element name (true) or insides of 
+	// an element (false)
+	TBool readingElementName = EFalse;
+	TText c;
+
+	for( TInt i=0; i < aXml.Length(); ++i )
+		{
+		c = aXml[i];
+		switch(c)
+			{
+			case KElementStart:
+				// if currently reading element, error
+				if( readingElementName )
+					{
+					User::Leave(EInvalidXmlError);
+					}
+
+				if( aXml.Length()-i >= KCDataStart().Length() &&
+					!aXml.Mid(i, KCDataStart().Length()).Compare(KCDataStart()) )
+					{ // cdata
+					aXml.Set( aXml.Right( aXml.Length() - i ) );
+					TInt endPos = aXml.Find(KCDataEnd);
+
+					TPtrC8 cdata = _L8("");
+					if ( endPos == KErrNotFound )
+						{
+						User::Leave(EInvalidCDataStructure);
+						}
+
+					cdata.Set( aXml.Mid( KCDataStart().Length(), endPos - KCDataStart().Length() ) );
+					aXml.Set( aXml.Right( aXml.Length() - endPos - KCDataEnd().Length() ) );
+
+					i = -1;
+
+					// add current buffer to complete buffer
+					EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+					AddToCompleteL(*iBuffer);
+					ResetBufferL(iBuffer);
+					AddToCompleteL(cdata);
+					}
+#ifndef __NO_XML_COMMENTS_
+				else if( aXml.Length()-i >= KCommentStart().Length() &&
+					!aXml.Mid(i, KCommentStart().Length()).Compare(KCommentStart()) )
+					{ // comment
+					aXml.Set( aXml.Right( aXml.Length() - i ) );
+					TInt endPos = aXml.Find(KCommentEnd);
+
+					if ( endPos != KErrNotFound )
+						{
+						aXml.Set( aXml.Right( aXml.Length() - endPos - KCommentEnd().Length() ) );
+						}
+					else
+						{
+						User::Leave(EInvalidXmlError);
+						}
+
+					i = -1;
+					}
+#endif
+				else 
+					{
+					// send the buffer
+					EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+					AddToCompleteL(*iBuffer);
+					NextDataL(*iCompleteBuffer);
+					ResetBufferL(iBuffer);
+					ResetBufferL(iCompleteBuffer);
+					readingElementName = ETrue;
+					}
+
+				break;
+			case KElementEnd:
+				// stop reading element name
+				if( !readingElementName )
+					{
+					User::Leave(EInvalidXmlError);
+					}
+				else 
+					{
+					NextElementL(*iBuffer);
+					ResetBufferL(iBuffer);
+					readingElementName = EFalse;
+					}
+				break;
+			default:
+				// add char to buffer
+				AddToBufferL(c, iBuffer);
+				break;
+			}
+		}
+
+	EntitiesToCharactersL( iBuffer, 0, iBuffer->Length() );
+	AddToCompleteL(*iBuffer);
+	NextDataL(*iCompleteBuffer);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Adds the given string to iCompleteBuffer
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::AddToCompleteL( const TPtrC8 aStr )
+	{
+	if(!iCompleteBuffer)
+		{
+		iCompleteBuffer = HBufC8::NewL(aStr.Length());
+		}
+
+	TPtr8 ptr = iCompleteBuffer->Des();
+	if( ptr.MaxLength() < iCompleteBuffer->Length()+aStr.Length() )
+		{
+		iCompleteBuffer = iCompleteBuffer->ReAllocL(iCompleteBuffer->Length()+aStr.Length());
+		ptr.Set(iCompleteBuffer->Des());
+		}
+
+	ptr.Append(aStr);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Deletes the given buffer and initializes it again to length 10
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::ResetBufferL( HBufC8*& aBuf ) const
+	{
+	if( aBuf )
+		{
+		delete aBuf;
+		aBuf = NULL;
+		}
+
+	aBuf = HBufC8::NewL(10);
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// Adds the given char to given buffer
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::AddToBufferL( const TText c, HBufC8*& aBuf ) const
+	{
+	TPtr8 ptr = aBuf->Des();
+	if( ptr.MaxLength() == aBuf->Length()+1 )
+		{
+		aBuf = aBuf->ReAllocL(aBuf->Length()+10);
+		ptr.Set(aBuf->Des());
+		}
+
+	TChar str = c;
+	ptr.Append(str);
+	}
+
+
+
+// ------------------------------------------------------------------------------------------------
+// Replaces all occurances of aTarget in aText with aItem. Returns an integer indicating 
+// the size change in aText. aStartPos and aEndPos indicate the start and end positions 
+// of aText to be parsed (if whole string should be parsed, use 0 and aText.Length()).
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlXmlParser::ReplaceL( HBufC8*& aText, const TDesC8& aTarget, const TDesC8& aItem, TInt aStartPos, TInt aEndPos ) const
+	{
+	TInt change = 0;
+	TInt searchPos = aStartPos;
+	TPtrC8 text = aText->Mid(aStartPos, aEndPos-aStartPos);
+	TInt pos = text.Find(aTarget);
+
+	while ( pos != KErrNotFound )
+		{
+		pos += searchPos;
+
+		TInt currentChange = aItem.Length() - aTarget.Length();
+		change += currentChange;
+		aEndPos += currentChange;
+		searchPos = pos;
+
+		if ( currentChange > 0 )
+			{
+			searchPos += currentChange;
+
+			// check that aText is large enough
+			if ( aText->Des().MaxLength() < aText->Length()+currentChange )
+				{
+				aText = aText->ReAllocL(aText->Length()+currentChange);
+				}
+			}
+
+		// the actual replace
+		aText->Des().Replace(pos, aTarget.Length(), aItem);
+
+		text.Set( aText->Mid(searchPos, aEndPos-searchPos) );
+		pos = text.Find(aTarget);
+		}
+
+	return change;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// 
+// ------------------------------------------------------------------------------------------------
+void CNSmlXmlParser::CheckDatetimeErrorL( const TInt error ) const
+	{
+	if ( error != KErrNone )
+		{
+		User::Leave( EInvalidDatetimeValue );
+		}
+	}
+
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/group/bld.inf	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or 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:  build info file for SyncML DS Plug In adapters
+*
+*/
+
+
+#include "../dsutils/cgiscriptutils/bld/bld.inf"
+#include "../datamod/bld/bld.inf"
+#include "../adapters/bld/bld.inf"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="contentcontrol" name="Content Control Daemons" levels="plugin app">
+    <collection id="applicationmanagement" name="Application Management" level="app">
+	   	<!-- could this collection be collapsed into a single component? Do all these need to be noted separately? --> 
+      <component id="options" filter="s60" name="Install Options">
+        <unit bldFile="applicationmanagement/options/group"/>
+      </component>
+      <component id="applicationmanagement_client" filter="s60" name="AM Client">
+        <unit bldFile="applicationmanagement/client/group"/>
+      </component>
+      <component id="applicationmanagement_server" filter="s60" name="AM Server">
+        <unit bldFile="applicationmanagement/server/group"/>
+      </component>
+      <component id="rfsplugin" filter="s60" name="AM RFS Plugin" class="plugin">
+        <unit bldFile="applicationmanagement/rfsplugin/group"/>
+      </component>
+      <component id="amadapter2" filter="s60" name="AM Adapter" class="plugin">
+        <unit bldFile="applicationmanagement/amadapter2/group"/>
+      </component>
+      <component id="applicationmanagement_build" filter="s60" name="AM Build">
+		<!-- can the exports be moved into the other components? -->
+        <unit bldFile="applicationmanagement/group"/>
+      </component>
+    </collection>
+    <collection id="customization" name="DM Customization Adapters" level="plugin">
+      <component id="dmutils" name="DM Utils" filter="s60">
+        <unit bldFile="customization/dmutils/bld"/>
+      </component>
+      <component id="uisettingssrv" filter="s60" name="UI Settings Server">
+        <unit bldFile="customization/uisettingssrv/bld"/>
+      </component>
+      <component id="isadapter" filter="s60" name="Idle State Adapter" class="plugin">
+        <unit bldFile="customization/isadapter/bld"/>
+      </component>
+      <component id="supadapter" filter="s60" name="Startup Adapter" class="plugin">
+        <unit bldFile="customization/supadapter/bld"/>
+      </component>
+      <component id="wallpaperadapter" filter="s60" name="Wallpaper Adapter" class="plugin">
+        <unit bldFile="customization/wallpaperadapter/bld"/>
+      </component>
+      <component id="operatorlogoadapter" filter="s60" name="Operator Logo Adapter" class="plugin">
+        <unit bldFile="customization/operatorlogoadapter/bld"/>
+      </component>
+      <component id="screensaveradapter" filter="s60" name="Screen Saver Adapter" class="plugin">
+        <unit bldFile="customization/screensaveradapter/bld"/>
+      </component>
+      <component id="themesadapter" filter="s60" name="Themes Adapter" class="plugin">
+        <unit bldFile="customization/themesadapter/bld"/>
+      </component>
+      <component id="embeddedlinkadapter" filter="s60" name="Embedded Link Adapter" class="plugin">
+        <unit bldFile="customization/embeddedlinkadapter/bld"/>
+      </component>
+      <component id="customization_build" filter="s60" name="DM Customization Build">
+		<!-- can these exports be included in one of the above components? -->
+        <unit bldFile="customization/group"/>
+      </component>
+    </collection>
+    <collection id="omads" name="OMA Data Sync" level="app">
+      <component id="omadsappui" filter="s60" name="OMA DS Application UI">
+        <unit bldFile="omads/omadsappui/group"/>
+      </component>
+      <component id="omadsextensions" filter="s60" name="OMA DS Extensions" class="plugin">
+        <unit bldFile="omads/omadsextensions/group"/>
+        	<!-- should this bld.inf be #included?  -->
+        <!-- <unit bldFile="omads/omadsextensions/dsutils/emailxmlutils/bld"/> -->
+      </component>
+    </collection>
+    <collection id="contentcontrol_info" name="Content Control Daemons Info" level="app">
+      <component id="contentctrl_plat" filter="s60" class="api" name="Content Control Daemons Platforn Interfaces">
+        <unit bldFile="contentctrl_plat/group"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Mon Nov 23 14:46:41 2009 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>