Revision: 201025
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 14:06:02 +0300
changeset 36 9ba7f05d28a5
parent 35 0ca79e3612d9
child 41 e32446434994
child 49 392bf116d9ed
Revision: 201025 Kit: 2010127
connectivitymodules/SeCon/clients/syncclient/bwins/sconsyncclientu.def
connectivitymodules/SeCon/clients/syncclient/eabi/sconsyncclientu.def
connectivitymodules/SeCon/clients/syncclient/group/bld.inf
connectivitymodules/SeCon/clients/syncclient/group/sconsyncclient.mmp
connectivitymodules/SeCon/clients/syncclient/inc/scondataproviderinfo.h
connectivitymodules/SeCon/clients/syncclient/inc/sconsyncclient.h
connectivitymodules/SeCon/clients/syncclient/rom/sconsyncclient.iby
connectivitymodules/SeCon/clients/syncclient/src/scondataproviderinfo.cpp
connectivitymodules/SeCon/clients/syncclient/src/sconsyncclient.cpp
connectivitymodules/SeCon/cntparser/bld/bld.inf
connectivitymodules/SeCon/cntparser/rom/cntparser.iby
connectivitymodules/SeCon/cntparser/src/cntparserserverexe.cpp
connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h
connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp
connectivitymodules/SeCon/group/bld.inf
connectivitymodules/SeCon/group/stubs/secon_stub.SIS
connectivitymodules/SeCon/group/stubs/secon_stub.pkg
connectivitymodules/SeCon/inc/debug.h
connectivitymodules/SeCon/plugins/ftp/bld/bld.inf
connectivitymodules/SeCon/plugins/ftp/rom/sconftpplugin.iby
connectivitymodules/SeCon/plugins/pcconn/bld/bld.inf
connectivitymodules/SeCon/plugins/pcconn/rom/sconpcconnplugin.iby
connectivitymodules/SeCon/rom/cntparser.iby
connectivitymodules/SeCon/rom/sconcsc.iby
connectivitymodules/SeCon/rom/sconftp.iby
connectivitymodules/SeCon/rom/sconftpplugin.iby
connectivitymodules/SeCon/rom/sconftpresources.iby
connectivitymodules/SeCon/rom/sconpcconnplugin.iby
connectivitymodules/SeCon/rom/sconpcd.iby
connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp
connectivitymodules/SeCon/servers/pcconn/inc/sconbtengine.h
connectivitymodules/SeCon/servers/pcconn/inc/sconfolderlister.h
connectivitymodules/SeCon/servers/pcconn/inc/sconimsireader.h
connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h
connectivitymodules/SeCon/servers/pcconn/src/sconbtengine.cpp
connectivitymodules/SeCon/servers/pcconn/src/sconfolderlister.cpp
connectivitymodules/SeCon/servers/pcconn/src/sconimsireader.cpp
connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp
connectivitymodules/SeCon/servers/syncserver/group/bld.inf
connectivitymodules/SeCon/servers/syncserver/group/sconsyncserver.mmp
connectivitymodules/SeCon/servers/syncserver/inc/cscontimeout.h
connectivitymodules/SeCon/servers/syncserver/inc/debug.h
connectivitymodules/SeCon/servers/syncserver/inc/logdatastoreformat.h
connectivitymodules/SeCon/servers/syncserver/inc/sconasynchandler.h
connectivitymodules/SeCon/servers/syncserver/inc/sconsyncclientserver.h
connectivitymodules/SeCon/servers/syncserver/inc/sconsyncrelationship.h
connectivitymodules/SeCon/servers/syncserver/inc/sconsyncserver.h
connectivitymodules/SeCon/servers/syncserver/inc/sconsyncsession.h
connectivitymodules/SeCon/servers/syncserver/rom/sconsyncserver.iby
connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp
connectivitymodules/SeCon/servers/syncserver/src/sconasynchandler.cpp
connectivitymodules/SeCon/servers/syncserver/src/sconsyncrelationship.cpp
connectivitymodules/SeCon/servers/syncserver/src/sconsyncserver.cpp
connectivitymodules/SeCon/servers/syncserver/src/sconsyncsession.cpp
connectivitymodules/SeCon/services/csc/bld/101F99F6.xml
connectivitymodules/SeCon/services/csc/bld/bld.inf
connectivitymodules/SeCon/services/csc/rom/sconcsc.iby
connectivitymodules/SeCon/services/csc/src/caplist.cpp
connectivitymodules/SeCon/services/csc/src/caputils.cpp
connectivitymodules/SeCon/services/csc/src/stringlist.cpp
connectivitymodules/SeCon/services/ftp/bld/bld.inf
connectivitymodules/SeCon/services/ftp/inc/sconconsts.h
connectivitymodules/SeCon/services/ftp/inc/sconftp.h
connectivitymodules/SeCon/services/ftp/rom/sconftp.iby
connectivitymodules/SeCon/services/ftp/rom/sconftpresources.iby
connectivitymodules/SeCon/services/ftp/src/sconfshandler.cpp
connectivitymodules/SeCon/services/ftp/src/sconftp.cpp
connectivitymodules/SeCon/services/oviaccounthandler/bwins/sconoviaccounthandleru.def
connectivitymodules/SeCon/services/oviaccounthandler/eabi/sconoviaccounthandleru.def
connectivitymodules/SeCon/services/oviaccounthandler/group/bld.inf
connectivitymodules/SeCon/services/oviaccounthandler/group/sconoviaccounthandler.mmp
connectivitymodules/SeCon/services/oviaccounthandler/inc/sconoviaccounthandler.h
connectivitymodules/SeCon/services/oviaccounthandler/rom/sconoviaccounthandler.iby
connectivitymodules/SeCon/services/oviaccounthandler/src/sconoviaccounthandler.cpp
connectivitymodules/SeCon/services/pcd/bld/bld.inf
connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp
connectivitymodules/SeCon/services/pcd/inc/sconbackuprestore.h
connectivitymodules/SeCon/services/pcd/inc/sconbrqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconinstaller.h
connectivitymodules/SeCon/services/pcd/inc/sconinstqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconpcd.h
connectivitymodules/SeCon/services/pcd/inc/sconpcdconsts.h
connectivitymodules/SeCon/services/pcd/inc/sconqueue.h
connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h
connectivitymodules/SeCon/services/pcd/inc/sconsynchandler.h
connectivitymodules/SeCon/services/pcd/rom/sconpcd.iby
connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp
connectivitymodules/SeCon/services/pcd/src/sconbrqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp
connectivitymodules/SeCon/services/pcd/src/sconinstqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp
connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp
connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp
connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp
connectivitymodules/SeCon/services/pcd/src/sconsynchandler.cpp
connectivitymodules/SeCon/services/pcd/src/sconvideoparser.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlgenerator.cpp
connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlhandler.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/group/createstub.bat
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/sis/backup_registration.xml
omads/omadsextensions/adapters/bookmark/sis/bookmarkdsa.pkg
omads/omadsextensions/adapters/bookmark/sis/bookmarkdsa_debug.pkg
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/src/NSmlContactsDataProvider.cpp
omads/omadsextensions/adapters/contactsgroup/group/101ff972.xml
omads/omadsextensions/adapters/contactsgroup/group/bld.inf
omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdataprovider.mmp
omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdsa_stub.pkg
omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdsa_stub.sis
omads/omadsextensions/adapters/contactsgroup/group/createstub.bat
omads/omadsextensions/adapters/contactsgroup/inc/changefinder.h
omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpconverter.h
omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdataprovider.h
omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdataproviderdefs.h
omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdatastore.h
omads/omadsextensions/adapters/contactsgroup/inc/logger.h
omads/omadsextensions/adapters/contactsgroup/inc/snapshotitem.h
omads/omadsextensions/adapters/contactsgroup/rom/contactsgrpdsa.iby
omads/omadsextensions/adapters/contactsgroup/sis/backup_registration.xml
omads/omadsextensions/adapters/contactsgroup/sis/contactsgrp.pkg
omads/omadsextensions/adapters/contactsgroup/sis/contactsgrp_debug.pkg
omads/omadsextensions/adapters/contactsgroup/src/changefinder.cpp
omads/omadsextensions/adapters/contactsgroup/src/contactsgrpconverter.cpp
omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdataprovider.cpp
omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdataprovider.rss
omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdatastore.cpp
omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdatastore.rss
omads/omadsextensions/adapters/contactsgroup/src/snapshotitem.cpp
omads/omadsextensions/adapters/mediads/group/2001a9a1.xml
omads/omadsextensions/adapters/mediads/group/bld.inf
omads/omadsextensions/adapters/mediads/group/createstub.bat
omads/omadsextensions/adapters/mediads/group/mediads.mmp
omads/omadsextensions/adapters/mediads/group/mediads_stub.pkg
omads/omadsextensions/adapters/mediads/group/mediads_stub.sis
omads/omadsextensions/adapters/mediads/inc/changefinder.h
omads/omadsextensions/adapters/mediads/inc/cmdemanager.h
omads/omadsextensions/adapters/mediads/inc/logger.h
omads/omadsextensions/adapters/mediads/inc/mediadsprovider.h
omads/omadsextensions/adapters/mediads/inc/mediadsproviderdefs.h
omads/omadsextensions/adapters/mediads/inc/mediadsstore.h
omads/omadsextensions/adapters/mediads/inc/mediamanager.h
omads/omadsextensions/adapters/mediads/inc/omadsfolderobject.h
omads/omadsextensions/adapters/mediads/inc/playlistitem.h
omads/omadsextensions/adapters/mediads/inc/sconmetadatafielddefs.h
omads/omadsextensions/adapters/mediads/inc/snapshotitem.h
omads/omadsextensions/adapters/mediads/inc/songitem.h
omads/omadsextensions/adapters/mediads/rom/mediads.iby
omads/omadsextensions/adapters/mediads/sis/backup_registration.xml
omads/omadsextensions/adapters/mediads/sis/mediads.pkg
omads/omadsextensions/adapters/mediads/sis/mediads_debug.pkg
omads/omadsextensions/adapters/mediads/src/changefinder.cpp
omads/omadsextensions/adapters/mediads/src/cmdemanager.cpp
omads/omadsextensions/adapters/mediads/src/mediadsprovider.cpp
omads/omadsextensions/adapters/mediads/src/mediadsprovider.rss
omads/omadsextensions/adapters/mediads/src/mediadsstore.cpp
omads/omadsextensions/adapters/mediads/src/mediadsstore.rss
omads/omadsextensions/adapters/mediads/src/mediamanager.cpp
omads/omadsextensions/adapters/mediads/src/omadsfolderobject.cpp
omads/omadsextensions/adapters/mediads/src/playlistitem.cpp
omads/omadsextensions/adapters/mediads/src/snapshotitem.cpp
omads/omadsextensions/adapters/mediads/src/songitem.cpp
omads/omadsextensions/adapters/mms/group/101fb0e9.xml
omads/omadsextensions/adapters/mms/group/bld.inf
omads/omadsextensions/adapters/mms/group/createstub.bat
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/sis/backup_registration.xml
omads/omadsextensions/adapters/mms/sis/mms.pkg
omads/omadsextensions/adapters/mms/sis/mms_debug.pkg
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/bld.inf
omads/omadsextensions/adapters/sms/group/createstub.bat
omads/omadsextensions/adapters/sms/group/smsdataprovider.mmp
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/sis/backup_registration.xml
omads/omadsextensions/adapters/sms/sis/sms.pkg
omads/omadsextensions/adapters/sms/sis/sms_debug.pkg
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/bwins/sconsyncclientu.def	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,43 @@
+EXPORTS
+	??0RSconSyncSession@@QAE@XZ @ 1 NONAME ; RSconSyncSession::RSconSyncSession(void)
+	??1CSconDataproviderInfo@@UAE@XZ @ 2 NONAME ; CSconDataproviderInfo::~CSconDataproviderInfo(void)
+	??1RSconSyncSession@@QAE@XZ @ 3 NONAME ; RSconSyncSession::~RSconSyncSession(void)
+	?AddedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 4 NONAME ; void RSconSyncSession::AddedItemsL(class RArray<int> &) const
+	?CancelRequest@RSconSyncSession@@QAEXXZ @ 5 NONAME ; void RSconSyncSession::CancelRequest(void)
+	?Close@RSconSyncSession@@QAEXXZ @ 6 NONAME ; void RSconSyncSession::Close(void)
+	?CloseDataStore@RSconSyncSession@@QBEXXZ @ 7 NONAME ; void RSconSyncSession::CloseDataStore(void) const
+	?CommitChangeInfoL@RSconSyncSession@@QAEXABV?$RArray@H@@@Z @ 8 NONAME ; void RSconSyncSession::CommitChangeInfoL(class RArray<int> const &)
+	?Connect@RSconSyncSession@@QAEHXZ @ 9 NONAME ; int RSconSyncSession::Connect(void)
+	?CreateItemL@RSconSyncSession@@QAEXAAHHABVTDesC8@@11@Z @ 10 NONAME ; void RSconSyncSession::CreateItemL(int &, int, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &)
+	?CreateItemL@RSconSyncSession@@QAEXAAV?$TPckg@H@@HABVTDesC8@@11AAVTRequestStatus@@@Z @ 11 NONAME ; void RSconSyncSession::CreateItemL(class TPckg<int> &, int, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class TRequestStatus &)
+	?DefaultStoreL@CSconDataproviderInfo@@QAEAAVTDesC16@@XZ @ 12 NONAME ; class TDesC16 & CSconDataproviderInfo::DefaultStoreL(void)
+	?DeleteAllItems@RSconSyncSession@@QAEXAAVTRequestStatus@@@Z @ 13 NONAME ; void RSconSyncSession::DeleteAllItems(class TRequestStatus &)
+	?DeleteItemL@RSconSyncSession@@QAEXH@Z @ 14 NONAME ; void RSconSyncSession::DeleteItemL(int)
+	?DeletedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 15 NONAME ; void RSconSyncSession::DeletedItemsL(class RArray<int> &) const
+	?DisplayNameL@CSconDataproviderInfo@@QAEAAVTDesC16@@XZ @ 16 NONAME ; class TDesC16 & CSconDataproviderInfo::DisplayNameL(void)
+	?ExternalizeL@CSconDataproviderInfo@@QBEXAAVRWriteStream@@@Z @ 17 NONAME ; void CSconDataproviderInfo::ExternalizeL(class RWriteStream &) const
+	?GetParent@RSconSyncSession@@QAEHHAAH@Z @ 18 NONAME ; int RSconSyncSession::GetParent(int, int &)
+	?GetSyncTimeStampL@RSconSyncSession@@QBEXHHAAVTDateTime@@@Z @ 19 NONAME ; void RSconSyncSession::GetSyncTimeStampL(int, int, class TDateTime &) const
+	?HasSyncHistoryL@RSconSyncSession@@QBEHXZ @ 20 NONAME ; int RSconSyncSession::HasSyncHistoryL(void) const
+	?ImplementationUid@CSconDataproviderInfo@@QBE?AVTUid@@XZ @ 21 NONAME ; class TUid CSconDataproviderInfo::ImplementationUid(void) const
+	?InternalizeL@CSconDataproviderInfo@@QAEXAAVRReadStream@@@Z @ 22 NONAME ; void CSconDataproviderInfo::InternalizeL(class RReadStream &)
+	?ListAllImplementationsL@RSconSyncSession@@QAEXAAV?$RPointerArray@VCSconDataproviderInfo@@@@@Z @ 23 NONAME ; void RSconSyncSession::ListAllImplementationsL(class RPointerArray<class CSconDataproviderInfo> &)
+	?ListStoresL@CSconDataproviderInfo@@QBEPAVCDesC16Array@@XZ @ 24 NONAME ; class CDesC16Array * CSconDataproviderInfo::ListStoresL(void) const
+	?ModifiedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 25 NONAME ; void RSconSyncSession::ModifiedItemsL(class RArray<int> &) const
+	?MoveItemL@RSconSyncSession@@QAEXHH@Z @ 26 NONAME ; void RSconSyncSession::MoveItemL(int, int)
+	?MovedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 27 NONAME ; void RSconSyncSession::MovedItemsL(class RArray<int> &) const
+	?NewL@CSconDataproviderInfo@@SAPAV1@XZ @ 28 NONAME ; class CSconDataproviderInfo * CSconDataproviderInfo::NewL(void)
+	?OpenDataStoreL@RSconSyncSession@@QAEXHABVTDesC16@@H@Z @ 29 NONAME ; void RSconSyncSession::OpenDataStoreL(int, class TDesC16 const &, int)
+	?OpenItemL@RSconSyncSession@@QAEXHAAH0AAVTDes8@@1AAVCBufFlat@@@Z @ 30 NONAME ; void RSconSyncSession::OpenItemL(int, int &, int &, class TDes8 &, class TDes8 &, class CBufFlat &)
+	?ReplaceItemL@RSconSyncSession@@QAEXHHHABVTDesC8@@@Z @ 31 NONAME ; void RSconSyncSession::ReplaceItemL(int, int, int, class TDesC8 const &)
+	?ReplaceItemL@RSconSyncSession@@QAEXHHHABVTDesC8@@AAVTRequestStatus@@@Z @ 32 NONAME ; void RSconSyncSession::ReplaceItemL(int, int, int, class TDesC8 const &, class TRequestStatus &)
+	?ResetChangeInfoL@RSconSyncSession@@QAEXXZ @ 33 NONAME ; void RSconSyncSession::ResetChangeInfoL(void)
+	?SetDefaultStoreL@CSconDataproviderInfo@@QAEXABVTDesC16@@@Z @ 34 NONAME ; void CSconDataproviderInfo::SetDefaultStoreL(class TDesC16 const &)
+	?SetDisplayNameL@CSconDataproviderInfo@@QAEXABVTDesC16@@@Z @ 35 NONAME ; void CSconDataproviderInfo::SetDisplayNameL(class TDesC16 const &)
+	?SetImplementationUid@CSconDataproviderInfo@@QAEXVTUid@@@Z @ 36 NONAME ; void CSconDataproviderInfo::SetImplementationUid(class TUid)
+	?SetRemoteStoreFormatL@RSconSyncSession@@QAEXABVCSmlDataStoreFormat@@@Z @ 37 NONAME ; void RSconSyncSession::SetRemoteStoreFormatL(class CSmlDataStoreFormat const &)
+	?SetStoresL@CSconDataproviderInfo@@QAEXABVCDesC16Array@@@Z @ 38 NONAME ; void CSconDataproviderInfo::SetStoresL(class CDesC16Array const &)
+	?SoftDeleteItemL@RSconSyncSession@@QAEXH@Z @ 39 NONAME ; void RSconSyncSession::SoftDeleteItemL(int)
+	?SoftDeletedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 40 NONAME ; void RSconSyncSession::SoftDeletedItemsL(class RArray<int> &) const
+	?StoreFormatL@RSconSyncSession@@QAEPAVCSmlDataStoreFormat@@ABVRStringPool@@@Z @ 41 NONAME ; class CSmlDataStoreFormat * RSconSyncSession::StoreFormatL(class RStringPool const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/eabi/sconsyncclientu.def	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,49 @@
+EXPORTS
+	_ZN16RSconSyncSession11CreateItemLER5TPckgIiEiRK6TDesC8S5_S5_R14TRequestStatus @ 1 NONAME
+	_ZN16RSconSyncSession11CreateItemLERiiRK6TDesC8S3_S3_ @ 2 NONAME
+	_ZN16RSconSyncSession11DeleteItemLEi @ 3 NONAME
+	_ZN16RSconSyncSession12ReplaceItemLEiiiRK6TDesC8 @ 4 NONAME
+	_ZN16RSconSyncSession12ReplaceItemLEiiiRK6TDesC8R14TRequestStatus @ 5 NONAME
+	_ZN16RSconSyncSession12StoreFormatLERK11RStringPool @ 6 NONAME
+	_ZN16RSconSyncSession13CancelRequestEv @ 7 NONAME
+	_ZN16RSconSyncSession14DeleteAllItemsER14TRequestStatus @ 8 NONAME
+	_ZN16RSconSyncSession14OpenDataStoreLEiRK7TDesC16i @ 9 NONAME
+	_ZN16RSconSyncSession15SoftDeleteItemLEi @ 10 NONAME
+	_ZN16RSconSyncSession16ResetChangeInfoLEv @ 11 NONAME
+	_ZN16RSconSyncSession17CommitChangeInfoLERK6RArrayIiE @ 12 NONAME
+	_ZN16RSconSyncSession21SetRemoteStoreFormatLERK19CSmlDataStoreFormat @ 13 NONAME
+	_ZN16RSconSyncSession23ListAllImplementationsLER13RPointerArrayI21CSconDataproviderInfoE @ 14 NONAME
+	_ZN16RSconSyncSession5CloseEv @ 15 NONAME
+	_ZN16RSconSyncSession7ConnectEv @ 16 NONAME
+	_ZN16RSconSyncSession9GetParentEiRi @ 17 NONAME
+	_ZN16RSconSyncSession9MoveItemLEii @ 18 NONAME
+	_ZN16RSconSyncSession9OpenItemLEiRiS0_R5TDes8S2_R8CBufFlat @ 19 NONAME
+	_ZN16RSconSyncSessionC1Ev @ 20 NONAME
+	_ZN16RSconSyncSessionC2Ev @ 21 NONAME
+	_ZN16RSconSyncSessionD1Ev @ 22 NONAME
+	_ZN16RSconSyncSessionD2Ev @ 23 NONAME
+	_ZN21CSconDataproviderInfo10SetStoresLERK12CDesC16Array @ 24 NONAME
+	_ZN21CSconDataproviderInfo12DisplayNameLEv @ 25 NONAME
+	_ZN21CSconDataproviderInfo12InternalizeLER11RReadStream @ 26 NONAME
+	_ZN21CSconDataproviderInfo13DefaultStoreLEv @ 27 NONAME
+	_ZN21CSconDataproviderInfo15SetDisplayNameLERK7TDesC16 @ 28 NONAME
+	_ZN21CSconDataproviderInfo16SetDefaultStoreLERK7TDesC16 @ 29 NONAME
+	_ZN21CSconDataproviderInfo20SetImplementationUidE4TUid @ 30 NONAME
+	_ZN21CSconDataproviderInfo4NewLEv @ 31 NONAME
+	_ZN21CSconDataproviderInfoD0Ev @ 32 NONAME
+	_ZN21CSconDataproviderInfoD1Ev @ 33 NONAME
+	_ZN21CSconDataproviderInfoD2Ev @ 34 NONAME
+	_ZNK16RSconSyncSession11AddedItemsLER6RArrayIiE @ 35 NONAME
+	_ZNK16RSconSyncSession11MovedItemsLER6RArrayIiE @ 36 NONAME
+	_ZNK16RSconSyncSession13DeletedItemsLER6RArrayIiE @ 37 NONAME
+	_ZNK16RSconSyncSession14CloseDataStoreEv @ 38 NONAME
+	_ZNK16RSconSyncSession14ModifiedItemsLER6RArrayIiE @ 39 NONAME
+	_ZNK16RSconSyncSession15HasSyncHistoryLEv @ 40 NONAME
+	_ZNK16RSconSyncSession17GetSyncTimeStampLEiiR9TDateTime @ 41 NONAME
+	_ZNK16RSconSyncSession17SoftDeletedItemsLER6RArrayIiE @ 42 NONAME
+	_ZNK21CSconDataproviderInfo11ListStoresLEv @ 43 NONAME
+	_ZNK21CSconDataproviderInfo12ExternalizeLER12RWriteStream @ 44 NONAME
+	_ZNK21CSconDataproviderInfo17ImplementationUidEv @ 45 NONAME
+	_ZTI21CSconDataproviderInfo @ 46 NONAME ; #<TI>#
+	_ZTV21CSconDataproviderInfo @ 47 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project SyncClient
+*
+*/
+
+
+PRJ_EXPORTS
+../rom/sconsyncclient.iby      CORE_APP_LAYER_IBY_EXPORT_PATH(sconsyncclient.iby)
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+sconsyncclient.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/group/sconsyncclient.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side of sconsyncserver
+*
+*/
+
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          sconsyncclient.dll
+TARGETTYPE      dll
+
+CAPABILITY      CAP_CLIENT_DLL
+
+UID             0x1000008d 0x2001A963
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          sconsyncclient.cpp
+SOURCE          scondataproviderinfo.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// Server
+USERINCLUDE     ../../../servers/syncserver/inc
+
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         bafl.lib
+LIBRARY         charconv.lib
+LIBRARY         smlstoreformat.lib
+DEBUGLIBRARY    flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/inc/scondataproviderinfo.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconDataproviderInfo header
+*
+*/
+
+
+#ifndef SCONDATAPROVIDERINFO_H_
+#define SCONDATAPROVIDERINFO_H_
+
+#include <e32base.h>
+#include <badesca.h>
+
+class RWriteStream;
+class RReadStream;
+
+/**
+ * Contains information about DataSync dataprovider.
+ */
+class CSconDataproviderInfo : public CBase
+{
+public:
+    IMPORT_C static CSconDataproviderInfo* NewL();
+    IMPORT_C ~CSconDataproviderInfo();
+    
+    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+    IMPORT_C void InternalizeL( RReadStream& aStream );
+    
+    IMPORT_C TUid        ImplementationUid() const;
+    IMPORT_C void        SetImplementationUid( const TUid aUid );
+    IMPORT_C TDesC&      DisplayNameL();
+    IMPORT_C void        SetDisplayNameL( const TDesC& aName );
+    IMPORT_C TDesC&      DefaultStoreL();
+    IMPORT_C void        SetDefaultStoreL( const TDesC& aStore );
+    IMPORT_C CDesCArray* ListStoresL() const;
+    IMPORT_C void        SetStoresL( const CDesCArray& aStores );
+private:
+	CSconDataproviderInfo();
+	void ConstructL();
+	
+private:
+    TInt        iUid;
+    HBufC*      iName;
+    HBufC*      iDefaultStore;
+    CDesCArrayFlat* iStores;
+};
+
+typedef RPointerArray<CSconDataproviderInfo> RSconDataProviderInfoArray;
+
+#endif /*SCONDATAPROVIDERINFO_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/inc/sconsyncclient.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RSconSyncSession header
+*
+*/
+
+
+#ifndef _SCONSYNCCLIENT_H_
+#define _SCONSYNCCLIENT_H_
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ecom/ImplementationInformation.h>
+#include <SmlDataProvider.h>
+
+#include "scondataproviderinfo.h"
+
+
+
+class CNSmlDataItemUidSet;
+
+class RSconSyncSession : public RSessionBase
+{
+public:
+    IMPORT_C RSconSyncSession();
+    IMPORT_C ~RSconSyncSession();
+        
+    IMPORT_C TInt Connect();
+    IMPORT_C void Close();
+    
+    IMPORT_C void ListAllImplementationsL( RSconDataProviderInfoArray& aInfoArray );
+    
+    IMPORT_C void OpenDataStoreL( const TSmlDataProviderId aProviderId, const TDesC& aStoreName, const TInt aContextId );
+
+    IMPORT_C void OpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange,
+            TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer,
+            CBufFlat& aItemData );
+    
+    IMPORT_C void CreateItemL(TSmlDbItemUid& aUid, TSmlDbItemUid aParent,
+            const TDesC8& aMimeType, const TDesC8& aMimeVer, const TDesC8& aData);
+    IMPORT_C void CreateItemL(TPckg<TSmlDbItemUid>& aUidPckg, TSmlDbItemUid aParent,
+            const TDesC8& aMimeType, const TDesC8& aMimeVer, const TDesC8& aData,
+            TRequestStatus& aStatus );
+      
+    IMPORT_C void ReplaceItemL(TSmlDbItemUid aUid, TSmlDbItemUid aParent,
+            TBool aFieldChange, const TDesC8& aData);
+    IMPORT_C void ReplaceItemL(TSmlDbItemUid aUid, TSmlDbItemUid aParent,
+            TBool aFieldChange, const TDesC8& aData,
+            TRequestStatus& aStatus );
+    
+    IMPORT_C void MoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent);
+    IMPORT_C void DeleteItemL(TSmlDbItemUid aUid);
+    IMPORT_C void SoftDeleteItemL(TSmlDbItemUid aUid);
+    IMPORT_C void DeleteAllItems( TRequestStatus& aStatus );
+    
+    IMPORT_C TBool HasSyncHistoryL() const;
+    IMPORT_C void AddedItemsL( RArray<TSmlDbItemUid>& aItems ) const;
+    IMPORT_C void DeletedItemsL( RArray<TSmlDbItemUid>& aItems ) const;
+    IMPORT_C void SoftDeletedItemsL( RArray<TSmlDbItemUid>& aItems ) const;
+    IMPORT_C void ModifiedItemsL( RArray<TSmlDbItemUid>& aItems ) const;
+    IMPORT_C void MovedItemsL( RArray<TSmlDbItemUid>& aItems ) const;
+    
+    IMPORT_C void CloseDataStore() const;
+    
+    IMPORT_C void ResetChangeInfoL();
+    IMPORT_C void CommitChangeInfoL(const RArray<TSmlDbItemUid>& aItems );
+    
+    IMPORT_C void GetSyncTimeStampL( const TSmlDataProviderId aProviderId, const TInt aContextId, TDateTime& aTimeStamp ) const;
+    
+    IMPORT_C CSmlDataStoreFormat* StoreFormatL( const RStringPool& aStringPool );
+    IMPORT_C void SetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat );
+    
+    
+    IMPORT_C void CancelRequest();
+    
+    IMPORT_C TInt GetParent( TSmlDbItemUid aUid, TSmlDbItemUid& aParent );
+private:
+    TInt StartServer();
+    TInt CreateAndSendChunkHandle();
+private:
+    RChunk iChunk;
+    TIpcArgs iArgs;
+    
+};
+
+#endif  // _SCONSYNCCLIENT_H_   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/rom/sconsyncclient.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for SconSyncClient
+*
+*/
+
+#ifndef _SCONSYNCCLIENT_IBY_
+#define _SCONSYNCCLIENT_IBY_
+
+#include <data_caging_paths_for_iby.hrh>
+
+file=ABI_DIR\BUILD_DIR\sconsyncclient.dll   SHARED_LIB_DIR\sconsyncclient.dll
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/src/scondataproviderinfo.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,220 @@
+/*
+* 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:  CSconDataproviderInfo implementation
+*
+*/
+
+
+#include "scondataproviderinfo.h"
+#include <s32strm.h>
+#include <badesca.h>
+#include <utf.h>  // for CnvUtfConverter
+#include "debug.h"
+
+CSconDataproviderInfo::CSconDataproviderInfo()
+    {
+    }
+
+EXPORT_C CSconDataproviderInfo::~CSconDataproviderInfo()
+    {
+    delete iName;
+    delete iDefaultStore;
+    delete iStores;
+    }
+
+EXPORT_C CSconDataproviderInfo* CSconDataproviderInfo::NewL()
+    {
+    return new (ELeave) CSconDataproviderInfo();
+    }
+
+EXPORT_C void CSconDataproviderInfo::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("iUid: 0x%x", iUid);
+    aStream.WriteInt32L( iUid );
+    if ( iName )
+        {
+        HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iName->Des() );
+        CleanupStack::PushL( temp );
+        TPtrC8 tempPtr = temp->Des();
+        aStream.WriteUint16L( tempPtr.Length() );
+        aStream.WriteL( tempPtr );
+        CleanupStack::PopAndDestroy( temp );
+        }
+    else
+        {
+        aStream.WriteUint16L( 0 );
+        }
+    
+    if ( iDefaultStore )
+        {
+        HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iDefaultStore->Des() );
+        CleanupStack::PushL( temp );
+        TPtrC8 tempPtr = temp->Des();
+        aStream.WriteUint16L( tempPtr.Length() );
+        aStream.WriteL( tempPtr );
+        CleanupStack::PopAndDestroy( temp );
+        }
+    else
+        {
+        aStream.WriteUint16L( 0 );
+        }
+    if ( iStores )
+        {
+        aStream.WriteUint16L( iStores->Count() );
+        for ( TInt i=0; i<iStores->Count(); i++ )
+            {
+            TPtrC storePtr = (*iStores)[i];
+            HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( storePtr );
+            CleanupStack::PushL( temp );
+            TPtrC8 tempPtr = temp->Des();
+            aStream.WriteUint16L( tempPtr.Length() );
+            if ( tempPtr.Length() > 0 )
+                {
+                aStream.WriteL( tempPtr );
+                }
+            CleanupStack::PopAndDestroy( temp );
+            }
+        }
+    else
+        {
+        aStream.WriteUint16L( 0 );
+        }
+    aStream.CommitL();
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void CSconDataproviderInfo::InternalizeL( RReadStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    delete iName;
+    iName = NULL;
+    delete iDefaultStore;
+    iDefaultStore = NULL;
+    delete iStores;
+    iStores = NULL;
+    iStores = new ( ELeave ) CDesCArrayFlat( 1 );
+    iUid = aStream.ReadInt32L();
+    TInt len = aStream.ReadUint16L();
+    if ( len > 0 )
+        {
+        HBufC8* tempBuf = HBufC8::NewLC( len );
+        TPtr8 tempPtr = tempBuf->Des();
+        aStream.ReadL( tempPtr, len );
+        
+        iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr );
+        CleanupStack::PopAndDestroy( tempBuf );
+        }
+    
+    len = aStream.ReadUint16L();
+    if ( len > 0 )
+        {
+        HBufC8* tempBuf = HBufC8::NewLC( len );
+        TPtr8 tempPtr = tempBuf->Des();
+        aStream.ReadL( tempPtr, len );
+        
+        iDefaultStore = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr );
+        CleanupStack::PopAndDestroy( tempBuf );
+        }
+    
+    TInt storeCount = aStream.ReadUint16L();
+    for (TInt i=0; i<storeCount; i++ )
+        {
+        len = aStream.ReadUint16L();
+        if ( len > 0 )
+            {
+            HBufC8* tempBuf8 = HBufC8::NewLC( len );
+            TPtr8 tempPtr8 = tempBuf8->Des();
+            aStream.ReadL( tempPtr8, len );
+            
+            HBufC* temp = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr8 );
+            CleanupStack::PushL( temp );
+            TPtr tempPtr = temp->Des();
+            iStores->AppendL( tempPtr );
+            CleanupStack::PopAndDestroy( temp );
+            CleanupStack::PopAndDestroy( tempBuf8 );
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C TUid CSconDataproviderInfo::ImplementationUid() const
+    {
+    return TUid::Uid( iUid );
+    }
+
+EXPORT_C void CSconDataproviderInfo::SetImplementationUid( const TUid aUid )
+    {
+    iUid = aUid.iUid;
+    }
+
+EXPORT_C TDesC& CSconDataproviderInfo::DisplayNameL()
+    {
+    if ( iName )
+        {
+        return *iName;
+        }
+    else
+        {
+        iName = KNullDesC().AllocL();
+        return *iName;
+        }
+    }
+
+EXPORT_C void CSconDataproviderInfo::SetDisplayNameL( const TDesC& aName )
+    {
+    delete iName;
+    iName = NULL;
+    iName = aName.AllocL();
+    }
+
+EXPORT_C TDesC& CSconDataproviderInfo::DefaultStoreL()
+    {
+    if ( iDefaultStore )
+        {
+        return *iDefaultStore;
+        }
+    else
+        {
+        iDefaultStore = KNullDesC().AllocL();
+        return *iDefaultStore;
+        }
+    }
+
+EXPORT_C void CSconDataproviderInfo::SetDefaultStoreL( const TDesC& aStore )
+    {
+    delete iDefaultStore;
+    iDefaultStore = NULL;
+    iDefaultStore = aStore.AllocL();
+    }
+
+EXPORT_C CDesCArray* CSconDataproviderInfo::ListStoresL() const
+    {
+    if ( !iStores )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return iStores;
+    }
+
+EXPORT_C void CSconDataproviderInfo::SetStoresL( const CDesCArray& aStores )
+    {
+    delete iStores;
+    iStores = NULL;
+    iStores = new ( ELeave ) CDesCArrayFlat( 1 );
+    for ( TInt i=0; i<aStores.Count(); i++ )
+        {
+        iStores->AppendL( aStores[i] );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/clients/syncclient/src/sconsyncclient.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,668 @@
+/*
+* 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:  RSconSyncSession implementation
+*
+*/
+
+
+#include "sconsyncclient.h"
+
+#include <SmlDataProvider.h>
+#include <s32mem.h>
+
+#include "sconsyncclientserver.h"
+#include "debug.h"
+
+const TInt KSConSyncChunkSize = 0xFFFF; // 65535 bytes;
+const TInt KSConSyncChunkMaxSize = 0x400000; // 4194304 bytes
+
+EXPORT_C RSconSyncSession::RSconSyncSession()
+    {
+    TRACE_FUNC;
+    }
+
+EXPORT_C RSconSyncSession::~RSconSyncSession()
+    {
+    TRACE_FUNC;
+    }
+
+EXPORT_C TInt RSconSyncSession::Connect()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt retryCount = 2;
+    TInt error = KErrNone;
+    while(retryCount)
+        {
+        error = CreateSession(KSconSyncServerName, TVersion(1,0,0));
+        if ( error != KErrNotFound && error != KErrServerTerminated )
+            {
+            break;
+            }
+        error = StartServer();
+        if( error != KErrNone && error != KErrAlreadyExists )
+            {
+            break;
+            }
+        --retryCount;
+        }
+    
+    if ( error == KErrNone )
+        {
+        error = CreateAndSendChunkHandle();
+        if ( error != KErrNone )
+            {
+            LOGGER_WRITE("CreateAndSendChunkHandle failed, close session");
+            Close();
+            }
+        }
+    TRACE_FUNC_EXIT;
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RSconSyncSession::Close()
+// Closes the server connection
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSconSyncSession::Close()
+    {
+    TRACE_FUNC_ENTRY;
+    iChunk.Close();
+    RSessionBase::Close();
+    TRACE_FUNC_EXIT
+    }
+
+EXPORT_C void RSconSyncSession::ListAllImplementationsL( RSconDataProviderInfoArray& aInfoArray )
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EListImplementations, args );
+    
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::ListAllImplementationsL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    
+    // copy data from the chunk
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    TInt count( readStream.ReadUint16L() );
+    LOGGER_WRITE_1("count: %d", count);
+    for ( TInt i=0; i<count; i++ )
+        {
+        LOGGER_WRITE_1("Import[%d]", i);
+        CSconDataproviderInfo *dpInfo = CSconDataproviderInfo::NewL();
+        CleanupStack::PushL( dpInfo );
+        
+        dpInfo->InternalizeL( readStream );
+        aInfoArray.AppendL( dpInfo );
+        CleanupStack::Pop( dpInfo );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::OpenDataStoreL( const TSmlDataProviderId aProviderId, const TDesC& aStoreName, TInt aContextId )
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iChunk.Adjust( 
+            sizeof(TInt32)
+            + sizeof(TInt32)
+            + aStoreName.Size()
+            + sizeof(TInt) ));
+    
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    writeBuf.WriteInt32L( aProviderId );
+    
+    writeBuf.WriteInt32L( aStoreName.Length() );
+    writeBuf.WriteL( aStoreName );
+    
+    writeBuf.WriteInt32L( aContextId );
+
+    writeBuf.CommitL();
+    writeBuf.Close();
+    
+    TIpcArgs args;
+    TInt ret = SendReceive ( EOpenStore, args );
+    
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::OpenDataStoreL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::OpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange,
+        TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, CBufFlat& aItemData )
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args( aUid );
+    TInt ret = SendReceive ( EOpenItem, args );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::OpenItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    
+    // copy data from the chunk
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    TInt32 length ( 0 );
+
+    aItemData.Reset();
+    length = readStream.ReadInt32L();
+    
+    HBufC8* data = HBufC8::NewLC( length );
+    TPtr8 dataPtr = data->Des();
+    
+    readStream.ReadL( dataPtr, length );
+    aItemData.ExpandL( 0, length );
+    aItemData.Write ( 0, dataPtr );
+    
+    CleanupStack::PopAndDestroy( data );
+
+    aFieldChange = readStream.ReadInt8L();
+    
+    aParent = readStream.ReadInt32L();
+    length = readStream.ReadInt32L();
+    readStream.ReadL( aMimeType, length );
+    
+    length = readStream.ReadInt32L();
+    readStream.ReadL( aMimeVer, length );
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::CreateItemL(TSmlDbItemUid& aUid/*, TInt aSize*/,
+        TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer,
+        const TDesC8& aData)
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iChunk.Adjust( 
+        sizeof(TInt32)
+        + sizeof(TInt32)
+        + aMimeType.Length()
+        + sizeof(TInt32)
+        + aMimeVer.Length()
+        + sizeof(TInt32)
+        + aData.Length() ));
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( writeBuf );
+    writeBuf.WriteInt32L( aParent );
+    writeBuf.WriteInt32L( aMimeType.Length() );
+    writeBuf.WriteL( aMimeType );
+    writeBuf.WriteInt32L( aMimeVer.Length() );
+    writeBuf.WriteL( aMimeVer );
+    writeBuf.WriteInt32L( aData.Length() );
+    writeBuf.WriteL( aData );
+        
+    writeBuf.CommitL();
+    CleanupStack::PopAndDestroy( &writeBuf );
+    
+
+    
+    TPckg<TSmlDbItemUid> pckg(aUid);
+    iArgs = TIpcArgs( &pckg );
+    
+    TInt ret = SendReceive ( ECreateItem, iArgs );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::CreateItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    LOGGER_WRITE_1("aUid: %d", aUid);
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::CreateItemL(TPckg<TSmlDbItemUid>& aUidPckg,
+        TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer,
+        const TDesC8& aData, TRequestStatus& aStatus)
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iChunk.Adjust( 
+        sizeof(TInt32)
+        + sizeof(TInt32)
+        + aMimeType.Length()
+        + sizeof(TInt32)
+        + aMimeVer.Length()
+        + sizeof(TInt32)
+        + aData.Length() ));
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( writeBuf );
+    writeBuf.WriteInt32L( aParent );
+    writeBuf.WriteInt32L( aMimeType.Length() );
+    writeBuf.WriteL( aMimeType );
+    writeBuf.WriteInt32L( aMimeVer.Length() );
+    writeBuf.WriteL( aMimeVer );
+    writeBuf.WriteInt32L( aData.Length() );
+    writeBuf.WriteL( aData );
+        
+    writeBuf.CommitL();
+    CleanupStack::PopAndDestroy( &writeBuf );
+    
+    iArgs = TIpcArgs( &aUidPckg );
+    SendReceive( ECreateItem, iArgs, aStatus );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::ReplaceItemL(TSmlDbItemUid aUid,
+        TSmlDbItemUid aParent, TBool aFieldChange, const TDesC8& aData)
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iChunk.Adjust( 
+        sizeof(TInt32)
+        + sizeof(TInt32)
+        + sizeof(TInt8)
+        + sizeof(TInt32)
+        + aData.Length() ));
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( writeBuf );
+    writeBuf.WriteInt32L( aUid );
+    writeBuf.WriteInt32L( aParent );
+    writeBuf.WriteInt8L( aFieldChange );
+    writeBuf.WriteInt32L( aData.Length() );
+    writeBuf.WriteL( aData );
+    writeBuf.CommitL();
+    CleanupStack::PopAndDestroy( &writeBuf );
+    
+    TIpcArgs args;
+    TInt ret = SendReceive( EReplaceItem, args );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::ReplaceItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::ReplaceItemL(TSmlDbItemUid aUid,
+        TSmlDbItemUid aParent, TBool aFieldChange, const TDesC8& aData,
+        TRequestStatus& aStatus)
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( iChunk.Adjust( 
+        sizeof(TInt32)
+        + sizeof(TInt32)
+        + sizeof(TInt8)
+        + sizeof(TInt32)
+        + aData.Length() ));
+    RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( writeBuf );
+    writeBuf.WriteInt32L( aUid );
+    writeBuf.WriteInt32L( aParent );
+    writeBuf.WriteInt8L( aFieldChange );
+    writeBuf.WriteInt32L( aData.Length() );
+    writeBuf.WriteL( aData );
+    writeBuf.CommitL();
+    CleanupStack::PopAndDestroy( &writeBuf );
+    
+    TIpcArgs args;
+    SendReceive( EReplaceItem, args, aStatus );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::MoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TIpcArgs args(aUid, aNewParent);
+    TInt ret = SendReceive ( EMoveItem, args );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::MoveItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::DeleteItemL( TSmlDbItemUid aUid )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TIpcArgs args( aUid );
+    TInt ret = SendReceive ( EDeleteItem, args );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::DeleteItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    TRACE_FUNC_EXIT;
+    }
+
+
+EXPORT_C void RSconSyncSession::SoftDeleteItemL( TSmlDbItemUid aUid )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TIpcArgs args( aUid );
+    TInt ret = SendReceive ( ESoftDeleteItem, args );
+    if ( ret != KErrNone) 
+        {
+        LOGGER_WRITE_1( "RSconSyncSession::SoftDeleteItemL() :\
+         Send Receive failed with code %d", ret );
+        User::Leave( ret );
+        };
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::DeleteAllItems( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    SendReceive( EDeleteAllItems, args, aStatus );
+    TRACE_FUNC_EXIT;
+    }
+
+    
+EXPORT_C TBool RSconSyncSession::HasSyncHistoryL() const
+    {
+    TRACE_FUNC;
+    TBool history(EFalse);
+    TPckg<TBool> pck(history);
+    TIpcArgs args(&pck);
+    TInt ret = SendReceive ( EHasHistory, args );
+    User::LeaveIfError( ret );
+    TRACE_FUNC_EXIT;
+    return history;
+    }
+
+EXPORT_C void RSconSyncSession::AddedItemsL( RArray<TSmlDbItemUid>& aItems) const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EAddedItems, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    aItems.Reset();
+    TInt itemCount = readStream.ReadInt32L();
+    for (TInt i=0; i<itemCount; i++)
+        {
+        aItems.AppendL( readStream.ReadInt32L() );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::DeletedItemsL( RArray<TSmlDbItemUid>& aItems) const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EDeletedItems, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    aItems.Reset();
+    TInt itemCount = readStream.ReadInt32L();
+    for (TInt i=0; i<itemCount; i++)
+        {
+        aItems.AppendL( readStream.ReadInt32L() );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::SoftDeletedItemsL( RArray<TSmlDbItemUid>& aItems) const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( ESoftDeletedItems, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    aItems.Reset();
+    TInt itemCount = readStream.ReadInt32L();
+    for (TInt i=0; i<itemCount; i++)
+        {
+        aItems.AppendL( readStream.ReadInt32L() );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::ModifiedItemsL( RArray<TSmlDbItemUid>& aItems) const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EModifiedItems, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    aItems.Reset();
+    TInt itemCount = readStream.ReadInt32L();
+    for (TInt i=0; i<itemCount; i++)
+        {
+        aItems.AppendL( readStream.ReadInt32L() );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::MovedItemsL( RArray<TSmlDbItemUid>& aItems) const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EMovedItems, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    aItems.Reset();
+    TInt itemCount = readStream.ReadInt32L();
+    for (TInt i=0; i<itemCount; i++)
+        {
+        aItems.AppendL( readStream.ReadInt32L() );
+        }
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::CloseDataStore() const
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    SendReceive ( ECloseStore, args );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::ResetChangeInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EResetChangeInfo, args );
+    User::LeaveIfError( ret );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::CommitChangeInfoL(const RArray<TSmlDbItemUid>& aItems )
+    {
+    TRACE_FUNC_ENTRY;
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    LOGGER_WRITE_1("items count: %d", aItems.Count());
+    stream.WriteInt32L( aItems.Count() );
+    for (TInt i=0; i < aItems.Count(); i++ )
+        {
+        LOGGER_WRITE("Write item");
+        stream.WriteInt32L( aItems[i] );
+        }
+    stream.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+        
+    TIpcArgs args;
+    TInt ret = SendReceive ( ECommitChangeInfo, args );
+    User::LeaveIfError( ret );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::GetSyncTimeStampL( const TSmlDataProviderId aProviderId, const TInt aContextId, TDateTime& aTimeStamp ) const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TPckg<TDateTime> timeBuf( aTimeStamp );
+    TIpcArgs args( aProviderId, aContextId, &timeBuf );
+    TInt ret = SendReceive ( EGetSyncTimeStamp, args );
+    User::LeaveIfError( ret );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C CSmlDataStoreFormat* RSconSyncSession::StoreFormatL( const RStringPool& aStringPool )
+    {
+    TRACE_FUNC_ENTRY;
+    TIpcArgs args;
+    TInt ret = SendReceive ( EExportStoreFormat, args );
+    User::LeaveIfError( ret );
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    TInt len = readStream.ReadInt32L();
+    LOGGER_WRITE_1("data size from server: %d", len);
+    LOGGER_WRITE("CSmlDataStoreFormat::NewLC");
+    CSmlDataStoreFormat* tempStoreFormat = CSmlDataStoreFormat::NewLC( aStringPool, readStream );
+    LOGGER_WRITE("CSmlDataStoreFormat::NewLC -ok");
+    CleanupStack::Pop( tempStoreFormat );
+    
+    LOGGER_WRITE("PopAndDestroy( &readStream )");
+    CleanupStack::PopAndDestroy( &readStream );
+    LOGGER_WRITE("return");
+    TRACE_FUNC_EXIT;
+    return tempStoreFormat;
+    }
+
+EXPORT_C void RSconSyncSession::SetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat )
+    {
+    TRACE_FUNC_ENTRY;
+    const TInt KMaximumDataStoreFormatSize = 100000; // 100kb should be enought
+    User::LeaveIfError( iChunk.Adjust( KMaximumDataStoreFormatSize ));
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    
+    aServerDataStoreFormat.ExternalizeL( stream );
+    
+    stream.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+    
+    TIpcArgs args;
+    TInt ret = SendReceive ( ESetRemoteStoreFormat, args );
+    User::LeaveIfError( ret );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C void RSconSyncSession::CancelRequest()
+    {
+    TRACE_FUNC_ENTRY;
+    SendReceive( ECancelRequest, TIpcArgs() );
+    TRACE_FUNC_EXIT;
+    }
+
+EXPORT_C TInt RSconSyncSession::GetParent( TSmlDbItemUid aUid, TSmlDbItemUid& aParent )
+    {
+    TRACE_FUNC_ENTRY;
+    TPckg<TSmlDbItemUid> pckg(aParent);
+    TIpcArgs args( aUid, &pckg );
+    TInt ret = SendReceive( EReadParent, args );
+    TRACE_FUNC_EXIT;
+    return ret;
+    }
+
+TInt RSconSyncSession::StartServer()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    RProcess server;
+    TInt error = server.Create(KSconSyncServerExe, KNullDesC);
+    if ( error != KErrNone )
+        {
+        return error;
+        }
+    // start server and wait for signal before proceeding    
+    TRequestStatus status;
+    server.Rendezvous(status);
+    if ( status.Int() != KRequestPending )
+        {
+        server.Kill(0);
+        }
+    else
+        {
+        server.Resume();
+        }
+    
+    User::WaitForRequest( status );
+    error = server.ExitType() == EExitPanic ? KErrGeneral : status.Int();
+    server.Close();
+    TRACE_FUNC_EXIT;
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RSconSyncSession::CreateAndSendChunkHandle()
+// Creates a chunk and sends a handle to server
+// -----------------------------------------------------------------------------
+//  
+TInt RSconSyncSession::CreateAndSendChunkHandle()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt err = iChunk.CreateGlobal( KNullDesC, 
+                                    KSConSyncChunkSize, 
+                                    KSConSyncChunkMaxSize );
+    if ( err != KErrNone )
+        {
+        LOGGER_WRITE_1("iChunk.CreateGlobal failed, err: %d", err);
+        return err;
+        }                           
+    TIpcArgs args;
+    args.Set( 0, iChunk );
+    err = SendReceive( ESendChunkHandle, args );
+    
+    LOGGER_WRITE_1("RSconSyncSession::CreateAndSendChunkHandle : returned: %d", err);
+    return err;
+    }
+
+// End of File
--- a/connectivitymodules/SeCon/cntparser/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/cntparser/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -16,6 +16,8 @@
 */
 
 
+PRJ_EXPORTS
+../rom/cntparser.iby         CORE_APP_LAYER_IBY_EXPORT_PATH(cntparser.iby)
 
 PRJ_PLATFORMS
 DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/cntparser/rom/cntparser.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for Contact Parser Client and Server.
+*
+*/
+
+
+#ifndef _CNTPARSER_IBY_
+#define _CNTPARSER_IBY_
+
+file=ABI_DIR\BUILD_DIR\cntparserserverexe.exe   PROGRAMS_DIR\cntparserserverexe.exe
+file=ABI_DIR\BUILD_DIR\cntparserserver.dll      SHARED_LIB_DIR\cntparserserver.dll
+
+#endif
\ No newline at end of file
--- a/connectivitymodules/SeCon/cntparser/src/cntparserserverexe.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/cntparser/src/cntparserserverexe.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -261,7 +261,7 @@
 	{
 	LOGGER_WRITE( "CntParserServer: Complete phonebook request" );
 	iSessionIter.SetToFirst();
-	while( iSessionIter!=NULL )	//Go through all sessions
+	while( iSessionIter )	//Go through all sessions
 		{
 		( (CCntParserServerSession*) (iSessionIter++) )->CompletePhoneBookRequest( aErr );
 		}
--- a/connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h	Tue Jul 06 14:06:02 2010 +0300
@@ -287,6 +287,7 @@
         //used only with reply
         TBool               iComplete;      //task complete
         TInt                iProgress;      //task progress 
+        HBufC8*             iData;
     };  
     
 //============================================================
@@ -309,6 +310,7 @@
         //used only with reply
         TBool               iComplete;      //task complete
         TInt                iProgress;      //task progress 
+        HBufC8*             iData;
     };  
     
 //============================================================
--- a/connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -25,7 +25,7 @@
 // 
 // -----------------------------------------------------------------------------
 //
-CSConReboot::CSConReboot() : iComplete( EFalse ), iProgress( 0 )
+CSConReboot::CSConReboot()
     {
     }
         
@@ -117,13 +117,7 @@
 // 
 // -----------------------------------------------------------------------------
 //  
-CSConUpdateDeviceInfo::CSConUpdateDeviceInfo() : 
-            iInstallSupp(EFalse), iUninstallSupp(EFalse), 
-            iInstParamsSupp(EFalse), iInstAppsSupp(EFalse), 
-            iDataOwnersSupp(EFalse), iSetBURModeSupp(EFalse),
-            iGetSizeSupp(EFalse), iReqDataSupp(EFalse), 
-            iSupplyDataSupp(EFalse), iRebootSupp(EFalse),
-            iComplete( EFalse ), iProgress( 0 )
+CSConUpdateDeviceInfo::CSConUpdateDeviceInfo()
     {
     }
     
@@ -187,7 +181,7 @@
 // 
 // -----------------------------------------------------------------------------
 //      
-CSConListInstApps::CSConListInstApps() : iComplete( EFalse ), iProgress( 0 )
+CSConListInstApps::CSConListInstApps()
     {
     //Initialize iDriveList with zeros
     iDriveList.Fill( '\x0' );
@@ -271,7 +265,7 @@
 // 
 // -----------------------------------------------------------------------------
 //      
-CSConInstall::CSConInstall() : iMode( EUnknown ), iComplete( EFalse ), iProgress( 0 ) 
+CSConInstall::CSConInstall() : iMode( EUnknown ) 
     {
     }
 
@@ -282,6 +276,7 @@
 //              
 CSConInstall::~CSConInstall()
     {
+    delete iData;
     }
 
 // -----------------------------------------------------------------------------
@@ -297,6 +292,11 @@
             
     copy->iComplete = iComplete;
     copy->iProgress = iProgress;
+    
+    if ( iData )
+        {
+        copy->iData = iData->Alloc();
+        }
             
     return copy;
     }
@@ -306,7 +306,7 @@
 // 
 // -----------------------------------------------------------------------------
 //  
-CSConUninstall::CSConUninstall() : iMode( EUnknown ), iComplete( EFalse ), iProgress( 0 )
+CSConUninstall::CSConUninstall() : iMode( EUnknown )
     {
     }
 
@@ -317,6 +317,7 @@
 //          
 CSConUninstall::~CSConUninstall()
     {
+    delete iData;
     }
 
 // -----------------------------------------------------------------------------
@@ -334,6 +335,11 @@
             
     copy->iComplete = iComplete;
     copy->iProgress = iProgress;
+    
+    if ( iData )
+        {
+        copy->iData = iData->Alloc();
+        }
             
     return copy;
     }
@@ -343,7 +349,7 @@
 // 
 // -----------------------------------------------------------------------------
 //      
-CSConListDataOwners::CSConListDataOwners() : iComplete( EFalse ), iProgress( 0 )
+CSConListDataOwners::CSConListDataOwners()
     {
     }
     
@@ -398,7 +404,7 @@
 // 
 // -----------------------------------------------------------------------------
 //      
-CSConSetBURMode::CSConSetBURMode() : iComplete( EFalse ), iProgress( 0 )
+CSConSetBURMode::CSConSetBURMode()
     {
     //Initialize iDriveList with zeros
     iDriveList.Fill( '\x0' );
@@ -436,7 +442,7 @@
 // 
 // -----------------------------------------------------------------------------
 //          
-CSConGetDataSize::CSConGetDataSize() : iComplete( EFalse ), iProgress( 0 )
+CSConGetDataSize::CSConGetDataSize()
     {
     }
 
@@ -490,7 +496,7 @@
 // 
 // -----------------------------------------------------------------------------
 //  
-CSConListPublicFiles::CSConListPublicFiles() : iComplete( EFalse ), iProgress( 0 )
+CSConListPublicFiles::CSConListPublicFiles()
     {
     }
     
@@ -545,8 +551,7 @@
 // 
 // -----------------------------------------------------------------------------
 //
-CSConRequestData::CSConRequestData() : iDataOwner( NULL ), iBackupData( NULL ), 
-    iMoreData( EFalse ), iComplete( EFalse ), iProgress( 0 )
+CSConRequestData::CSConRequestData()
     {
     iDataOwner = new CSConDataOwner();
     }
@@ -633,7 +638,7 @@
 // 
 // -----------------------------------------------------------------------------
 //      
-CSConGetDataOwnerStatus::CSConGetDataOwnerStatus() : iComplete( EFalse ), iProgress( 0 )
+CSConGetDataOwnerStatus::CSConGetDataOwnerStatus()
     {
     }
 
@@ -688,8 +693,7 @@
 // 
 // -----------------------------------------------------------------------------
 //  
-CSConSupplyData::CSConSupplyData() : iDataOwner( NULL ), iRestoreData( NULL ),
-    iComplete( EFalse ), iProgress( 0 )
+CSConSupplyData::CSConSupplyData()
     {
     iDataOwner = new CSConDataOwner();
     }
@@ -760,8 +764,7 @@
 // 
 // -----------------------------------------------------------------------------
 //  
-CSConGetMetadata::CSConGetMetadata() : iData( NULL ),
-    iMoreData( EFalse ), iComplete( EFalse ), iProgress( 0 )
+CSConGetMetadata::CSConGetMetadata()
     {
     }
     
@@ -772,11 +775,7 @@
 //          
 CSConGetMetadata::~CSConGetMetadata()
     {
-    if ( iData )
-        {
-        delete iData;
-        iData = NULL;
-        }
+    delete iData;
     }
     
 // -----------------------------------------------------------------------------
@@ -1687,7 +1686,7 @@
 // 
 // -----------------------------------------------------------------------------
 // 
-CSConStatusReply::CSConStatusReply() : iNoTasks( EFalse )
+CSConStatusReply::CSConStatusReply()
     {
     }
    
--- a/connectivitymodules/SeCon/group/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -22,9 +22,15 @@
 #include "../services/csc/bld/bld.inf"
 #include "../services/ftp/bld/bld.inf"
 #include "../services/pcd/bld/bld.inf"
+// #include "../services/oviaccounthandler/group/bld.inf"
+
 #include "../wbxml/conmlhandler/bld/bld.inf"
 #include "../servers/pcconn/bld/bld.inf"
+#include "../servers/syncserver/group/bld.inf"
+
 #include "../clients/pcconn/bld/bld.inf"
+#include "../clients/syncclient/group/bld.inf"
+
 #include "../plugins/pcconn/bld/bld.inf"
 #include "../plugins/ftp/bld/bld.inf"
 #include "../plugins/hapticsconnplugin/group/bld.inf"
@@ -36,12 +42,6 @@
 stubs/sconpcconnplugin_stub.sis     /epoc32/data/z/system/install/sconpcconnplugin_stub.sis
 stubs/sconftpplugin_stub.sis        /epoc32/data/z/system/install/sconftpplugin_stub.sis
 
-../rom/sconpcd.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcd.iby)
-../rom/sconpcconnplugin.iby         CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcconnplugin.iby)
-../rom/sconpcconnclientserver.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(sconpcconnclientserver.iby)
-../rom/sconftpresources.iby         LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(sconftpresources.iby)
-../rom/sconftpplugin.iby            CORE_MW_LAYER_IBY_EXPORT_PATH(sconftpplugin.iby)
-../rom/sconftp.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconftp.iby)
-../rom/sconcsc.iby                  CORE_MW_LAYER_IBY_EXPORT_PATH(sconcsc.iby)
-../rom/cntparser.iby                CORE_MW_LAYER_IBY_EXPORT_PATH(cntparser.iby)
+../rom/sconpcconnclientserver.iby   CORE_APP_LAYER_IBY_EXPORT_PATH(sconpcconnclientserver.iby)
 
+
Binary file connectivitymodules/SeCon/group/stubs/secon_stub.SIS has changed
--- a/connectivitymodules/SeCon/group/stubs/secon_stub.pkg	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/group/stubs/secon_stub.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 ;
-; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ; All rights reserved.
 ; This component and the accompanying materials are made available
 ; under the terms of "Eclipse Public License v1.0"
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Service Controllers"},(0x101F99F6),1,0,0, TYPE=SA
+#{"Service Controllers"},(0x101F99F6),1,72,0, TYPE=SA
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/connectivitymodules/SeCon/inc/debug.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/inc/debug.h	Tue Jul 06 14:06:02 2010 +0300
@@ -21,10 +21,8 @@
 
 #ifdef _DEBUG
     
-    #ifdef __WINS__
-        // Enable file logging
-        #define __FLOGGING__
-    #endif //__WINS__
+    // Enable file logging
+    #define __FLOGGING__
     
     #include <e32svr.h>
     #ifdef __FLOGGING__
--- a/connectivitymodules/SeCon/plugins/ftp/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/plugins/ftp/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -14,7 +14,8 @@
 * Description:  File Transfer Profile Plug-in build information file.
 *
 */
-
+PRJ_EXPORTS
+../rom/sconftpplugin.iby         CORE_APP_LAYER_IBY_EXPORT_PATH(sconftpplugin.iby)
 
 PRJ_PLATFORMS  
 DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/rom/sconftpplugin.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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: Image description file for FTPplugin
+*
+*/
+
+
+#ifndef __SCONFTP_PLUGIN_IBY__
+#define __SCONFTP_PLUGIN_IBY__
+//file content
+
+ECOM_PLUGIN(sconftpplugin.dll,101F9686.RSC)
+
+#endif
--- a/connectivitymodules/SeCon/plugins/pcconn/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/plugins/pcconn/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -15,6 +15,8 @@
 *
 */
 
+PRJ_EXPORTS
+../rom/sconpcconnplugin.iby         CORE_APP_LAYER_IBY_EXPORT_PATH(sconpcconnplugin.iby)
 
 PRJ_PLATFORMS  
 DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/pcconn/rom/sconpcconnplugin.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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: Image description file for PC Connectivity Plug-in.
+*
+*/
+#ifndef __SCONPCCONN_PLUGIN_IBY__
+#define __SCONPCCONN_PLUGIN_IBY__
+//file content
+
+ECOM_PLUGIN(sconpcconnplugin.dll,101F9688.RSC)
+
+file=ABI_DIR\BUILD_DIR\catalogspcconnectivityplugin.dll              SHARED_LIB_DIR\catalogspcconnectivityplugin.dll
+
+#endif
--- a/connectivitymodules/SeCon/rom/cntparser.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for Contact Parser Client and Server.
-*
-*/
-
-
-file=ABI_DIR\BUILD_DIR\cntparserserverexe.exe   PROGRAMS_DIR\cntparserserverexe.exe
-file=ABI_DIR\BUILD_DIR\cntparserserver.dll      SHARED_LIB_DIR\cntparserserver.dll
-
--- a/connectivitymodules/SeCon/rom/sconcsc.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
-* 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:  Image description file for project SConCSC
-*
-*/
-
-
-#ifndef __SCONCSC_IBY__
-#define __SCONCSC_IBY__
-//file content
-
-file=ABI_DIR\BUILD_DIR\sconcsc.dll              SHARED_LIB_DIR\sconcsc.dll
-data=ZPRIVATE\101F99F6\capability\101F9698.xml  PRIVATE\101F99F6\capability\101F9698.xml
-data=ZPRIVATE\101F99F6\capability\fwdcomp.xml   PRIVATE\101F99F6\capability\fwdcomp.xml
-data=ZPRIVATE\101F99F6\capability\101F99F6.xml  PRIVATE\101F99F6\capability\101F99F6.xml
-#endif
--- a/connectivitymodules/SeCon/rom/sconftp.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for CSConFTP
-*
-*/
-
-
-#ifndef __SCONFTP_IBY__
-#define __SCONFTP_IBY__
-//file content
-
-file=ABI_DIR\BUILD_DIR\sconftp.dll              SHARED_LIB_DIR\sconftp.dll
-
-#endif
--- a/connectivitymodules/SeCon/rom/sconftpplugin.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for FTPplugin
-*
-*/
-
-
-#ifndef __SCONFTP_PLUGIN_IBY__
-#define __SCONFTP_PLUGIN_IBY__
-//file content
-
-ECOM_PLUGIN(sconftpplugin.dll,101F9686.RSC)
-
-#endif
--- a/connectivitymodules/SeCon/rom/sconftpresources.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for SConFTP resources.
-*
-*/
-
-#ifndef __SCONFTP_RESOURCE_IBY__
-#define __SCONFTP_RESOURCE_IBY__
-
-data=DATAZ_\RESOURCE_FILES_DIR\sconftp.rsc	RESOURCE_FILES_DIR\sconftp.rsc
-
-#endif
\ No newline at end of file
--- a/connectivitymodules/SeCon/rom/sconpcconnplugin.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for PC Connectivity Plug-in.
-*
-*/
-#ifndef __SCONPCCONN_PLUGIN_IBY__
-#define __SCONPCCONN_PLUGIN_IBY__
-//file content
-
-ECOM_PLUGIN(sconpcconnplugin.dll,101F9688.RSC)
-
-file=ABI_DIR\BUILD_DIR\catalogspcconnectivityplugin.dll              SHARED_LIB_DIR\catalogspcconnectivityplugin.dll
-
-#endif
--- a/connectivitymodules/SeCon/rom/sconpcd.iby	Wed Jun 23 18:02:53 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Image description file for SConPCD.
-*
-*/
-#ifndef __SCONPCD_IBY__
-#define __SCONPCD_IBY__
-//file content
-
-file=ABI_DIR\BUILD_DIR\sconpcd.dll		system\libs\sconpcd.dll
-
-data=ZPRIVATE\10202D56\sbeconfig.xml	PRIVATE\10202D56\sbeconfig.xml
-
-#endif
--- a/connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -27,7 +27,7 @@
 TARGET          sconpcconnserver.exe
 TARGETTYPE      exe
 
-EPOCSTACKSIZE   49152
+EPOCSTACKSIZE   0x10000
 EPOCHEAPSIZE    0x10000 0x800000
 
 UID             0 0x101F99F6
@@ -35,6 +35,9 @@
 // Server
 SOURCEPATH      ../src
 SOURCE          sconpcconnserver.cpp
+SOURCE          sconimsireader.cpp
+SOURCE          sconfolderlister.cpp
+SOURCE          sconbtengine.cpp
 
 // ConML
 SOURCEPATH      ../../../wbxml/conmlhandler/src
@@ -49,6 +52,7 @@
 USERINCLUDE     ../../../common/conmltask/inc
 USERINCLUDE     ../../../services/pcd/inc 
 USERINCLUDE     ../../../services/csc/inc
+USERINCLUDE     ../../../services/oviaccounthandler/inc
 USERINCLUDE     ../../../wbxml/conmlhandler/inc
 
 // Default system include paths.
@@ -58,4 +62,17 @@
 LIBRARY         estor.lib       // RMemWriteStream, RMemReadStream
 LIBRARY         efsrv.lib       // Rfs, RFile
 LIBRARY         charconv.lib    // For Unicode conversion
+
+LIBRARY         etel3rdparty.lib
+LIBRARY         platformenv.lib         // For pathinfo
+LIBRARY         directorylocalizer.lib  // For localizing directories
+LIBRARY	        centralrepository.lib
+LIBRARY         commonengine.lib        // For resource reader
+LIBRARY         bafl.lib                // Basic Application Framework Library
+LIBRARY         btengdevman.lib
+LIBRARY         btmanclient.lib
+LIBRARY         btdevice.lib
+LIBRARY         bluetooth.lib
+LIBRARY         btengsettings.lib
 DEBUGLIBRARY    flogger.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconbtengine.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconBtEngine declaration
+*
+*/
+
+
+
+#ifndef SCONBTENGINE_H_
+#define SCONBTENGINE_H_
+
+#include <e32std.h>
+#include <e32base.h>
+#include <s32mem.h>
+#include <BTEngDevMan.h>
+#include <btengsettings.h>
+
+const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize;
+
+class CSconBtEngine : public CBase,
+                      public MBTEngDevManObserver,
+                      public MBTEngSettingsObserver
+    {
+public:
+    static CSconBtEngine* NewL();
+    ~CSconBtEngine();
+    
+    void ReadBTInfoL( RBufWriteStream& aStream );
+    
+    void SetBtAuthorizedL( const TDesC& aBtDevAddress, TBool aAuthorized );
+    
+    TInt SetBtPowerState( TBool aPower );
+    
+    TInt SetBtName( const TDesC& aBtName );
+    
+protected:
+    // From MBTEngDevManObserver
+    void HandleDevManComplete( TInt aErr );
+    void HandleGetDevicesComplete( TInt aErr, 
+           CBTDeviceArray* aDeviceArray );
+    
+    // From MBTEngSettingsObserver
+    void PowerStateChanged( TBTPowerStateValue aState );
+    void VisibilityModeChanged( TBTVisibilityMode aState );
+    
+private:
+    CSconBtEngine();
+    void ConstructL();
+    
+    void PrintDevicesL();
+    
+private:
+    enum TState
+        {
+        EIdle,
+        ERequestBtInfo,
+        EChangeBtState,
+        EChangeAuthorized
+        };
+    TState iState;
+    TInt   iOperationError;
+    CActiveSchedulerWait    iWait;
+    RBufWriteStream*        iStream;
+    CBTEngDevMan*           iBtEng;
+    CBTDeviceArray*         iBtDevArray;
+    CBTEngSettings*         iBtSettings;
+    TBool                   iAuthorizedValue;
+    TBuf<KCenRepAddrBufSize> iBtAddress;
+    };
+
+#endif /* SCONBTENGINE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconfolderlister.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,136 @@
+/*
+* 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:  CSconFolderLister declaration
+*
+*/
+
+
+#ifndef CSCONFOLDERLISTER_H
+#define CSCONFOLDERLISTER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <s32mem.h> // For RMemReadStream
+#include <f32file.h>
+// CLASS DECLARATION
+
+class TSconDriveInfoEntry
+    {
+public:
+    TUint8 iDriveType;
+    TUint8 iDriveTypeCount;
+    TInt64 iSize;
+    TInt64 iFree;
+    };
+
+class TSconDriveInfo : public TSconDriveInfoEntry
+    {
+public:
+    TUint iDriveStatus;
+    TBuf16<2> iDriveLetter;
+    TUint iDriveAttr;
+    TBufC<KMaxFileName> iVolumeName;
+    };
+
+
+class CSconFolderEntry : public CBase
+    {
+public:
+    static CSconFolderEntry* NewLC();
+    static CSconFolderEntry* NewLC( const TEntry& aEntry );
+    ~CSconFolderEntry();
+private:
+    CSconFolderEntry();
+    void ConstructL( const TEntry& aEntry );
+    
+public:
+    TUint iAtt;
+    TTime iModified;
+    HBufC *iName;
+    HBufC *iLabel;
+    TBool iDriveInfoEntryExists;
+    TSconDriveInfoEntry iDriveInfoEntry;
+    };
+
+
+class CDirectoryLocalizer;
+
+/**
+ *  CSconFolderLister
+ * 
+ */
+class CSconFolderLister : public CBase
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~CSconFolderLister();
+    
+    /**
+     * Two-phased constructor.
+     */
+    static CSconFolderLister* NewL( RFs& aFs );
+    
+    /**
+     * 
+     * @param aStream
+     * @param aStartPath
+     * @param aLevelsToSearch -1 = Search all levels, 0 = Search only current level, 1..N Search N levels
+     */
+    void GenerateFolderListL( RBufWriteStream& aStream, const TDesC& aStartPath, const TInt aLevelsToSearch );
+    
+private:  
+    
+    void ListAllDrivesL( RBufWriteStream& aStream, const TInt aLevelsToSearch );
+    void ListDriveAndPathL( RBufWriteStream& aStream, TInt aDrive, const TDesC& aStartPath, const TInt aLevelsToSearch );
+    
+    void ExportDriveL( RBufWriteStream& aStream, const TSconDriveInfo& aDriveInfo,
+            const TDesC& aPathName, const TInt aLevelsToSearch );
+    
+    /**
+     * 
+     * @param aStream
+     * @param aPathName
+     */
+    void ExportPathL( RBufWriteStream& aStream, const TDesC& aPathName, 
+            const CSconFolderEntry& aEntry, const TBool aLocalize, const TInt aLevelsToSearch );
+    
+    void GetDriveTypeNumberL( TInt aDrive , TUint driveStatus, TInt& aTypeNumber);
+    
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CSconFolderLister( RFs& aFs );
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+    
+    TBool IsDirectoryPrintable( const TDesC& aParentPath, const TEntry& aFolderEntry );
+    
+    void GetLocalizedVolumeNameL( CSconFolderEntry& aDriveEntry );
+private:
+    RFs&    iFs;
+    TInt    iFolders;
+    TInt    iFiles;
+    TInt    iCriticalLevel;
+    CDirectoryLocalizer* iLocalizer;
+    };
+
+#endif // CSCONFOLDERLISTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconimsireader.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Imsi reader
+*
+*/
+
+
+#ifndef __SCONIMSIREADER_H__
+#define __SCONIMSIREADER_H__
+
+#include <e32base.h>
+#include <Etel3rdParty.h>
+
+enum TImsiReaderStatus
+    {
+    EIdle,
+    ERequestingImsi,
+    ERequestingNetworkStatus
+    };
+ 
+class CSconImsiReader : public CActive
+    {
+    public:
+        
+        static TInt GetImsiL( TDes& aImsi );
+        
+        static TInt GetNetworkStatusL( CTelephony::TRegistrationStatus& aRegistrationStatus );
+ 
+    private:
+        CSconImsiReader( TDes& aImsi, CTelephony::TRegistrationStatus& aRegistrationStatus );
+        void ConstructL();
+        ~CSconImsiReader();
+        
+        void RequestImsi();
+        void RequestNetworkStatus();
+        
+    private: // From CActive
+        
+        void RunL();
+        void DoCancel();
+        
+    private: // data
+        TDes& iImsi;
+        CTelephony::TRegistrationStatus& iNetworkStatus;
+        CTelephony* iTelephony;
+        CTelephony::TSubscriberIdV1 iSubscriberIdV1;
+        CTelephony::TSubscriberIdV1Pckg iSubscriberIdV1Pckg;
+        
+        CTelephony::TNetworkRegistrationV1     iNetworkRegistrationV1;
+        CTelephony::TNetworkRegistrationV1Pckg iNetworkRegistrationV1Pckg;
+        TImsiReaderStatus iImsiReaderStatus;
+    };
+
+#endif // __SCONIMSIREADER_H__
--- a/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h	Tue Jul 06 14:06:02 2010 +0300
@@ -127,6 +127,10 @@
 
     };
 
+
+class CSconFolderLister;
+class CSconBtEngine;
+
 //**********************************
 //CSConPCConnSession - Server session class, handles the requested operations
 //**********************************
@@ -216,7 +220,9 @@
     TDesC8& HashToDesLC( const TDesC& aBuf );
     TPtr DesToHashLC( const TDesC8& aDes );
     TBool IsJavaHash( const TDesC8& aDes );
-        
+    
+    TInt ReadOviAccountInfoL( RWriteStream& aAccountInfoStream );
+    
 // data
 private:
     CSConPCConnServer& iServer;
@@ -232,6 +238,10 @@
     RChunk iChunk;
     CBufFlat* iBuffer;  
     TInt iResult;
+    
+    CSconFolderLister* iFolderLister;
+    RFs iFs;
+    CSconBtEngine*  iBtEngine;
     };
 
 #endif // __SCONPCCONNSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/src/sconbtengine.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,415 @@
+/*
+* 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:  CSconBtEngine implementation
+*
+*/
+
+
+
+#include <centralrepository.h>
+#include <btengdomaincrkeys.h>
+
+#include <e32property.h>
+#include <bttypes.h> 
+#include <bt_subscribe.h>
+
+#include "sconbtengine.h"
+#include "debug.h"
+
+CSconBtEngine* CSconBtEngine::NewL()
+    {
+    TRACE_FUNC;
+    CSconBtEngine* self = new (ELeave) CSconBtEngine();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CSconBtEngine::~CSconBtEngine()
+    {
+    TRACE_FUNC;
+    if ( iBtEng )
+        {
+        iBtEng->Cancel();
+        delete iBtEng;
+        }
+    
+    delete iBtSettings;
+    }
+
+CSconBtEngine::CSconBtEngine()
+    {
+    }
+
+void CSconBtEngine::ConstructL()
+    {
+    iBtEng = CBTEngDevMan::NewL( this );
+    iBtSettings = CBTEngSettings::NewL( this );
+    iState = EIdle;
+    }
+
+void CSconBtEngine::ReadBTInfoL( RBufWriteStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iState != EIdle )
+        {
+        User::Leave( KErrInUse );
+        }
+    iStream = &aStream;
+    iOperationError = KErrNone;
+    
+    // Write local name (8 bit name length + unicode name)
+    TBuf<100> localName;
+    TInt err = iBtSettings->GetLocalName( localName );
+    User::LeaveIfError( err );
+    LOGGER_WRITE_1("localName: %S", &localName);
+    iStream->WriteUint8L( localName.Length() );
+    iStream->WriteL( localName, localName.Length() );
+    
+    if ( iBtAddress.Length() == 0 )
+        {
+        LOGGER_WRITE("Try to read bt address");
+        
+        CRepository* cenRep = NULL;
+        // Use TRAP to catch a leave if the CenRep key does not exist.
+        TRAP( err, cenRep = CRepository::NewL( KCRUidBluetoothLocalDeviceAddress ) );
+        CleanupStack::PushL( cenRep );
+        if( !err )
+            {
+            err = cenRep->Get( KBTLocalDeviceAddress, iBtAddress );
+            LOGGER_WRITE_1("cenRep->Get err: %d", err);
+            }
+        CleanupStack::PopAndDestroy( cenRep );
+        
+        if ( err )
+            {
+            iBtAddress.Zero();
+            }
+        }
+    
+    // Write bt address (8 bit addr length + unicode address)
+    if ( iBtAddress.Length() > 0 )
+        {
+        LOGGER_WRITE_1("btAddr: %S", &iBtAddress);
+        iStream->WriteUint8L( iBtAddress.Length() );
+        iStream->WriteL( iBtAddress, iBtAddress.Length() );
+        }
+    else
+        {
+        iStream->WriteUint8L( 0 );
+        }
+    
+    // Write BT Power State (8-bit, 0=Off, 1=On)
+    TBTPowerStateValue state;
+    err = iBtSettings->GetPowerState( state );
+    User::LeaveIfError( err );
+    LOGGER_WRITE_1("PowerState: %d", state);
+    iStream->WriteUint8L( state );
+    
+    // Get device info
+    TBTRegistrySearch crit;
+    crit.FindAll();
+    if ( !iBtDevArray )
+        {
+        LOGGER_WRITE("create arr");
+        iBtDevArray = new (ELeave) CBTDeviceArray(5);
+        LOGGER_WRITE("create arr -ok");
+        }
+    else
+        {
+        iBtDevArray->ResetAndDestroy();
+        }
+    err = iBtEng->GetDevices( crit, iBtDevArray );
+    LOGGER_WRITE_1("GetDevices err: %d", err);
+    User::LeaveIfError( err );
+    iState = ERequestBtInfo;
+    
+    // Wait until completed
+    iWait.Start();
+    iState = EIdle;
+    if ( iOperationError )
+        {
+        LOGGER_WRITE_1("Operation failed, leave %d", iOperationError);
+        User::Leave( iOperationError );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconBtEngine::SetBtAuthorizedL( const TDesC& aBtDevAddress, TBool aAuthorized )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iState != EIdle )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    TBTRegistrySearch crit;
+    TBTDevAddr addr;
+    addr.SetReadable( aBtDevAddress );
+    crit.FindAddress( addr );
+    
+    if ( !iBtDevArray )
+        {
+        LOGGER_WRITE("create arr");
+        iBtDevArray = new (ELeave) CBTDeviceArray(5);
+        LOGGER_WRITE("create arr -ok");
+        }
+    else
+        {
+        iBtDevArray->ResetAndDestroy();
+        }
+    TInt err = iBtEng->GetDevices( crit, iBtDevArray );
+    LOGGER_WRITE_1("GetDevices err: %d", err);
+    User::LeaveIfError( err );
+    iState = EChangeAuthorized;
+    iOperationError = KErrNone;
+    iAuthorizedValue = aAuthorized;
+    
+    // Wait until completed
+    iWait.Start();
+    iState = EIdle;
+    if ( iOperationError )
+        {
+        LOGGER_WRITE_1("Operation failed, leave %d", iOperationError);
+        User::Leave( iOperationError );
+        
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+TInt CSconBtEngine::SetBtPowerState( TBool aPower )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iState != EIdle )
+        {
+        return KErrInUse;
+        }
+    
+    TBTPowerStateValue state;
+    iOperationError = iBtSettings->GetPowerState( state );
+    if ( iOperationError )
+        {
+        return iOperationError;
+        }
+    else if ( ( aPower && state == EBTPowerOn )
+            || ( !aPower && state == EBTPowerOff ) )
+        {
+        // No need to change state
+        return KErrNone;
+        }
+    
+    state = EBTPowerOff;
+    if ( aPower )
+        {
+        state = EBTPowerOn;
+        }
+    iOperationError = iBtSettings->SetPowerState( state );
+    if ( iOperationError )
+        {
+        return iOperationError;
+        }
+    iState = EChangeBtState;
+    
+    // Wait until completed
+    iWait.Start();
+    
+    iState = EIdle;
+    TRACE_FUNC_RET( iOperationError );
+    return iOperationError;
+    }
+
+TInt CSconBtEngine::SetBtName( const TDesC& aBtName )
+    {
+    LOGGER_WRITE_1("SetBtName aBtName: %S", &aBtName);
+    TInt err = iBtSettings->SetLocalName( static_cast<const TDes&>( aBtName ) );
+    TRACE_FUNC_RET( err );
+    return err;
+    }
+
+// From MBTEngDevManObserver
+void CSconBtEngine::HandleDevManComplete( TInt aErr )
+    {
+    TRACE_FUNC;
+    LOGGER_WRITE_1("aErr: %d", aErr );
+    if ( iState == EChangeAuthorized )
+        {
+        if ( iWait.IsStarted() )
+            {
+            iOperationError = aErr;
+            iWait.AsyncStop();
+            }
+        }
+    
+    }
+
+void CSconBtEngine::HandleGetDevicesComplete( TInt aErr, 
+       CBTDeviceArray* aDeviceArray )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aErr: %d", aErr);
+    //iBtReqOngoing = EFalse;
+    if ( iState == ERequestBtInfo )
+        {
+        // Continue to write devices info
+        TRAP( iOperationError, PrintDevicesL() );
+        LOGGER_WRITE_1("PrintDevicesL err: %d", iOperationError);
+        
+        if ( iWait.IsStarted() )
+            {
+            iWait.AsyncStop();
+            }
+        }
+    else if ( iState == EChangeAuthorized )
+        {
+        iOperationError = aErr;
+        if ( !aErr && aDeviceArray->Count() == 1 )
+            {
+            CBTDevice* btRef = aDeviceArray->At(0);
+            TBTDeviceSecurity devSec = btRef->GlobalSecurity();
+            if ( btRef->IsPaired() && !devSec.Banned() )
+                {
+                LOGGER_WRITE8_1("btAdrr: %S", &btRef->BDAddr().Des() );
+                CBTDevice* btDevice = CBTDevice::NewLC( btRef->BDAddr() );
+                
+                btDevice->SetPaired( ETrue );
+                
+                btDevice->SetDeviceNameL( btRef->DeviceName() );
+                btDevice->SetFriendlyNameL( btRef->FriendlyName() );
+                LOGGER_WRITE8_1("name: %S", &btRef->DeviceName());
+                LOGGER_WRITE8_1("FriendlyName: %S", &btRef->FriendlyName());
+                
+                LOGGER_WRITE_1("iAuthorizedValue: %d", iAuthorizedValue);
+                // Set as authorized and store the device
+                TBTDeviceSecurity security;
+                security.SetNoAuthenticate( EFalse );
+                security.SetNoAuthorise( iAuthorizedValue );
+                security.SetBanned( EFalse );
+                
+                btDevice->SetGlobalSecurity (security );
+                
+                //iOperationError = iBtEng->ModifyDevice(*aDeviceArray->At(0));
+                iOperationError = iBtEng->ModifyDevice( *btDevice );
+                LOGGER_WRITE_1( "ModifyDevice err: %d", iOperationError );
+                CleanupStack::PopAndDestroy( btDevice );
+                }
+            else
+                {
+                LOGGER_WRITE("Device was not paired or it's banned")
+                iOperationError = KErrAccessDenied;
+                }
+            }
+        
+        // If error occured stop waiting, otherwise continue waiting until
+        // HandleDevManComplete has been called
+        if ( iOperationError && iWait.IsStarted() )
+            {
+            iWait.AsyncStop();
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconBtEngine::PrintDevicesL()
+    {
+    TRACE_FUNC_ENTRY;
+    // calculate devices count
+    TInt devCount(0);
+    
+    for ( TInt i=0 ; i<iBtDevArray->Count(); i++ )
+        {
+        CBTDevice* device = iBtDevArray->At(i);
+        // show only paired and banned devices
+        if ( device->IsPaired() || device->GlobalSecurity().Banned() )
+            {
+            devCount++;
+            }
+        }
+    
+    // Print info
+    iStream->WriteUint8L( devCount );
+    
+    for ( TInt i=0 ; i<iBtDevArray->Count(); i++ )
+        {
+        CBTDevice* device = iBtDevArray->At(i);
+        
+        const TBTDeviceSecurity btSec = device->GlobalSecurity();
+        
+        // show only paired and banned devices
+        if ( device->IsPaired() || btSec.Banned() )
+            {
+            LOGGER_WRITE_1("IsValidDeviceName: %d", device->IsValidDeviceName());
+            const TDesC8& deviceName = device->DeviceName();
+            LOGGER_WRITE8_1("DeviceName: %S", &deviceName );
+            iStream->WriteUint8L( deviceName.Length() );
+            iStream->WriteL( deviceName, deviceName.Length() );
+            
+            LOGGER_WRITE_1("IsValidFriendlyName: %d", device->IsValidFriendlyName());
+            LOGGER_WRITE_1("FriendlyName: %S", &device->FriendlyName() );
+            
+            const TBTDevAddr& addr = device->BDAddr();
+            
+            TBuf<100> readable;
+            addr.GetReadable( readable );
+            LOGGER_WRITE_1("readable addr: %S", &readable);
+            iStream->WriteUint8L( readable.Length() );
+            iStream->WriteL( readable, readable.Length() );
+            
+            LOGGER_WRITE_1("paired: %d", device->IsPaired() );
+            LOGGER_WRITE_1("IsValidPaired: %d", device->IsValidPaired() );
+            TUint8 paired(0);
+            if ( device->IsPaired() && device->IsValidPaired() )
+                {
+                paired = 1;
+                }
+            iStream->WriteUint8L( paired );
+            
+            TUint8 noAuthorise(0);
+            if ( btSec.NoAuthorise() )
+                {
+                noAuthorise = 1;
+                }
+            iStream->WriteUint8L( noAuthorise );
+            
+            TUint8 banned(0);
+            if ( btSec.Banned() )
+                {
+                banned = 1;
+                }
+            iStream->WriteUint8L( banned );
+            
+            LOGGER_WRITE("");
+            }
+        }
+    iStream->CommitL();
+    iStream = NULL; //delete reference only
+    TRACE_FUNC_EXIT;
+    }
+
+// From MBTEngSettingsObserver
+void CSconBtEngine::PowerStateChanged( TBTPowerStateValue /*aState*/ )
+    {
+    TRACE_FUNC;
+    if ( iState == EChangeBtState && iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    }
+
+void CSconBtEngine::VisibilityModeChanged( TBTVisibilityMode /*aState*/ )
+    {
+    TRACE_FUNC;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/src/sconfolderlister.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,717 @@
+/*
+* 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:  CSconFolderLister implementation
+*
+*/
+
+
+#include "sconfolderlister.h"
+
+#include <driveinfo.h>
+#include <centralrepository.h>
+#include <sysutildomaincrkeys.h>
+#include <CDirectoryLocalizer.h>
+#include <stringresourcereader.h>
+#include <sconftp.rsg>
+#include <bautils.h>
+
+#include "debug.h"
+
+const TUint16 KFormatVersion( 1 );
+
+// Obex package size
+const TInt KPackageSize = 65536;
+
+const TInt KMaxLevelsToSearch = 80;
+
+_LIT( KSConResourceName, "z:\\Resource\\sconftp.rsc" );
+
+CSconFolderEntry* CSconFolderEntry::NewLC()
+    {
+    CSconFolderEntry* self = new (ELeave) CSconFolderEntry();
+    CleanupStack::PushL( self );
+    return self;
+    }
+CSconFolderEntry* CSconFolderEntry::NewLC( const TEntry& aEntry )
+    {
+    CSconFolderEntry* self = new (ELeave) CSconFolderEntry();
+    CleanupStack::PushL( self );
+    self->ConstructL( aEntry );
+    return self;
+    }
+CSconFolderEntry::CSconFolderEntry()
+    {
+    }
+CSconFolderEntry::~CSconFolderEntry()
+    {
+    delete iName;
+    delete iLabel;
+    }
+
+
+void CSconFolderEntry::ConstructL( const TEntry& aEntry )
+    {
+    iAtt = aEntry.iAtt;
+    iModified = aEntry.iModified.Int64();
+    iName = aEntry.iName.AllocL();
+    }
+
+CSconFolderLister::CSconFolderLister( RFs& aFs ) : iFs(aFs)
+    {
+    // No implementation required
+    }
+
+CSconFolderLister::~CSconFolderLister()
+    {
+    TRACE_FUNC;
+    delete iLocalizer;
+    }
+
+CSconFolderLister* CSconFolderLister::NewL( RFs& aFs )
+    {
+    TRACE_FUNC_ENTRY;
+    CSconFolderLister* self = new (ELeave) CSconFolderLister( aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+void CSconFolderLister::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iLocalizer = CDirectoryLocalizer::NewL();
+    
+    // set free memory up to critical level for all drives
+    CRepository* repository = CRepository::NewLC( KCRUidDiskLevel );
+    TInt iCriticalLevel(0);
+    User::LeaveIfError( repository->Get( KDiskCriticalThreshold, iCriticalLevel ) );
+    CleanupStack::PopAndDestroy( repository );
+    iCriticalLevel += KPackageSize; // add obex package size to critical level
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconFolderLister::GenerateFolderListL( RBufWriteStream& aStream, const TDesC& aStartPath, 
+        const TInt aLevelsToSearch )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aStartPath: %S", &aStartPath );
+    LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch );
+    TInt levelsToSearch = aLevelsToSearch;
+    if ( levelsToSearch > KMaxLevelsToSearch || levelsToSearch == KErrNotFound )
+        levelsToSearch = KMaxLevelsToSearch;
+    iFolders = 0;
+    iFiles = 0;
+    const TInt KDriveNameLength( 3 );
+    
+    if ( aStartPath.CompareF( _L("\\") ) == 0 )
+        {
+        LOGGER_WRITE("List all drives");
+        aStream.WriteUint16L( KFormatVersion );
+        ListAllDrivesL( aStream, levelsToSearch );
+        }
+    else if ( aStartPath.Length() >= KDriveNameLength )
+        {
+        if ( aStartPath.Length() > KDriveNameLength )
+            {
+            // check root path permissions, is listing allowed
+            TPtrC path = aStartPath.Mid(KDriveNameLength);
+            LOGGER_WRITE_1("pathFromRoot: %S", &path);
+            TInt pathEndMark = path.Locate(TChar('\\'));
+            if ( pathEndMark == KErrNotFound )
+                {
+                User::Leave( KErrArgument );
+                }
+            //"private\" locate = 7"
+            TPtrC pathName = aStartPath.Left( KDriveNameLength+pathEndMark );
+            LOGGER_WRITE_1("pathName: %S", &path);
+            TEntry pathEntry;
+            User::LeaveIfError( iFs.Entry(pathName, pathEntry) );
+            
+            TBool printable = IsDirectoryPrintable( aStartPath.Left(3), pathEntry );
+            if ( !printable )
+                {
+                // access denied
+                LOGGER_WRITE("Access denied!");
+                User::Leave( KErrAccessDenied );
+                }
+            User::LeaveIfError( iFs.Entry(aStartPath, pathEntry) );
+            if ( pathEntry.IsSystem() )
+                {
+                // access denied
+                LOGGER_WRITE("System folder, Access denied!");
+                User::Leave( KErrAccessDenied );
+                }
+            }
+        
+        
+        aStream.WriteUint16L( KFormatVersion );
+        
+        TInt drive;
+        User::LeaveIfError( iFs.CharToDrive( aStartPath[0], drive) );
+        ListDriveAndPathL( aStream, drive, aStartPath, levelsToSearch);
+
+        }
+    else
+        {
+        LOGGER_WRITE("aStartPath KErrArgument");
+        User::Leave( KErrArgument );
+        }
+    
+    
+    LOGGER_WRITE_1("iFolders: %d", iFolders);
+    LOGGER_WRITE_1("iFiles: %d", iFiles);
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconFolderLister::ListAllDrivesL( RBufWriteStream& aStream, const TInt aLevelsToSearch )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt devDriveCount = 0;
+    TInt mmcDriveCount = 0;
+    TChar driveLetter;
+    TBuf8<1> driveBuf;
+    RArray<TSconDriveInfo>  sconDriveInfo(5);
+    
+    // Write all drives to folderlisting object
+    TDriveList driveList;
+    // Get all drives that are visible to the user.
+    TInt driveCount;
+    User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
+    
+    for( TInt i = EDriveA; i < KMaxDrives; i++ )
+        {
+        if( driveList[i] )
+            {
+            TUint driveStatus;
+            User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
+            //LOGGER_WRITE_1( "DriveInfo for drive: %d", i);
+
+            if( !(driveStatus & DriveInfo::EDrivePresent )
+                || driveStatus & DriveInfo::EDriveCorrupt
+                || (driveStatus & DriveInfo::EDriveRemote) )
+                {
+                //LOGGER_WRITE_1( "skip drive %d", i);
+                continue;
+                }
+            
+            User::LeaveIfError( iFs.DriveToChar( i, driveLetter ) );
+            //Letter to uppercase form.
+            driveLetter.UpperCase();
+            
+            TSconDriveInfo info;
+            info.iDriveStatus = driveStatus;
+            info.iDriveLetter.Zero();
+            info.iDriveLetter.Append( driveLetter );
+            info.iDriveLetter.Append( _L(":") );
+            
+            
+            info.iDriveAttr = KEntryAttNormal; // ReadWrite
+            
+            if( driveStatus & DriveInfo::EDriveInternal && devDriveCount==0 )
+                {
+                //permission always R for first internal drive
+                info.iDriveAttr = KEntryAttReadOnly;
+                }
+            
+            //memory type
+            if( driveStatus & DriveInfo::EDriveInternal )
+                {
+                LOGGER_WRITE( "DriveInfo::EDriveInternal" );
+                devDriveCount++;
+                info.iDriveType = DriveInfo::EDriveInternal; // =1
+                info.iDriveTypeCount = devDriveCount;
+                
+                }
+            else if( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                LOGGER_WRITE( "DriveInfo::EDriveRemovable" );
+                mmcDriveCount++;
+                info.iDriveType = DriveInfo::EDriveRemovable;; // =2
+                info.iDriveTypeCount = mmcDriveCount;
+                }
+            
+            TVolumeInfo volumeInfo;
+            User::LeaveIfError( iFs.Volume( volumeInfo, i) );
+            
+            info.iVolumeName = volumeInfo.iName;
+            if ( volumeInfo.iFree > iCriticalLevel )
+                {
+                volumeInfo.iFree = volumeInfo.iFree - iCriticalLevel;
+                }       
+            else
+                {
+                volumeInfo.iFree = 0;
+                }
+            
+            info.iFree = volumeInfo.iFree;
+            info.iSize = volumeInfo.iSize;
+            
+            
+            sconDriveInfo.AppendL( info );
+            
+            }
+        }
+    
+    LOGGER_WRITE_1("Drives: %d", sconDriveInfo.Count());
+    aStream.WriteUint8L( sconDriveInfo.Count() );
+    for ( TInt i=0; i < sconDriveInfo.Count(); i++ )
+        {
+        
+        TBuf<3> path(KNullDesC);
+        path.Copy(sconDriveInfo[i].iDriveLetter);
+        path.Append(_L("\\"));
+        
+        ExportDriveL( aStream, sconDriveInfo[i], path, aLevelsToSearch);
+        }
+    sconDriveInfo.Close();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconFolderLister::ListDriveAndPathL( RBufWriteStream& aStream, TInt aDrive, const TDesC& aStartPath, const TInt aLevelsToSearch )
+    {
+    TRACE_FUNC_ENTRY;
+    TVolumeInfo volumeInfo;
+    User::LeaveIfError( iFs.Volume(volumeInfo, aDrive) );
+    TInt driveCount(0);
+    TUint driveStatus;
+    User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, aDrive, driveStatus ) );
+    GetDriveTypeNumberL( aDrive, driveStatus, driveCount );
+    
+    
+    TSconDriveInfo info;
+    info.iDriveLetter.Copy( aStartPath.Left(2) );
+    info.iVolumeName = volumeInfo.iName;
+    
+    info.iDriveAttr = KEntryAttNormal; // ReadWrite   
+    if( driveStatus & DriveInfo::EDriveInternal && driveCount==0 )
+        {
+        //permission always R for first internal drive
+        info.iDriveAttr = KEntryAttReadOnly;
+        }
+    info.iDriveType = 0;
+    if( driveStatus & DriveInfo::EDriveInternal )
+        {
+        info.iDriveType = DriveInfo::EDriveInternal; // =1
+        }
+    else if( driveStatus & DriveInfo::EDriveRemovable )
+        {
+        info.iDriveType = DriveInfo::EDriveRemovable;; // =2
+        }
+    
+    if ( volumeInfo.iFree > iCriticalLevel )
+        {
+        volumeInfo.iFree = volumeInfo.iFree - iCriticalLevel;
+        }       
+    else
+        {
+        volumeInfo.iFree = 0;
+        }
+    
+    info.iFree = volumeInfo.iFree;
+    info.iSize = volumeInfo.iSize;
+    
+    aStream.WriteUint8L( 1 );
+    ExportDriveL( aStream, info, aStartPath, aLevelsToSearch);
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconFolderLister::ExportDriveL( RBufWriteStream& aStream, const TSconDriveInfo& aDriveInfo,
+        const TDesC& aPathName, const TInt aLevelsToSearch )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("Drive: %S", &aDriveInfo.iDriveLetter);
+    LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch );
+    
+    CSconFolderEntry* driveEntry = CSconFolderEntry::NewLC();
+    driveEntry->iName = aDriveInfo.iDriveLetter.AllocL();
+    
+    if ( driveEntry->iLabel )
+        {
+        LOGGER_WRITE_1("Label: %S", &driveEntry->iLabel->Des());
+        }
+    driveEntry->iAtt = aDriveInfo.iDriveAttr;
+
+    driveEntry->iDriveInfoEntryExists = ETrue;
+    driveEntry->iDriveInfoEntry.iDriveType = aDriveInfo.iDriveType;
+    driveEntry->iDriveInfoEntry.iDriveTypeCount = aDriveInfo.iDriveTypeCount;
+             
+    driveEntry->iDriveInfoEntry.iFree = aDriveInfo.iFree;
+    driveEntry->iDriveInfoEntry.iSize = aDriveInfo.iSize;
+    
+    driveEntry->iLabel = aDriveInfo.iVolumeName.AllocL();
+    GetLocalizedVolumeNameL( *driveEntry );
+    
+    ExportPathL( aStream, aPathName, *driveEntry, ETrue, aLevelsToSearch );
+    CleanupStack::PopAndDestroy( driveEntry );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconFolderLister::GetLocalizedVolumeNameL( CSconFolderEntry& aDriveEntry )
+    {
+    TRACE_FUNC_ENTRY;
+    // Get localized names
+    if ( aDriveEntry.iDriveInfoEntry.iDriveType == DriveInfo::EDriveInternal 
+            && aDriveEntry.iDriveInfoEntry.iDriveTypeCount > 1 )
+        {
+        LOGGER_WRITE("Internal mass memory");
+        // internal second memory (Mass memory)
+        TFileName file( KSConResourceName );
+        BaflUtils::NearestLanguageFile( iFs, file );
+        
+        CStringResourceReader* reader = CStringResourceReader::NewL( file );
+        if ( aDriveEntry.iLabel )
+            {
+            delete aDriveEntry.iLabel;
+            aDriveEntry.iLabel = NULL;
+            }
+        aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_MASS_STORAGE ).AllocL();
+        delete reader;
+        }
+    else if ( aDriveEntry.iLabel && aDriveEntry.iLabel->Length()>0 )
+        {
+        LOGGER_WRITE("Use normal volume label");
+        
+        }
+    else
+        {
+        TFileName file( KSConResourceName );
+        BaflUtils::NearestLanguageFile( iFs, file );
+        CStringResourceReader* reader = CStringResourceReader::NewL( file );
+        if (aDriveEntry.iLabel)
+            {
+            delete aDriveEntry.iLabel;
+            aDriveEntry.iLabel = NULL;
+            }
+        if ( aDriveEntry.iDriveInfoEntry.iDriveType == DriveInfo::EDriveRemovable )
+            {
+            LOGGER_WRITE("EDriveRemovable");
+            // read default MMC name
+            aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_MMC ).AllocL();
+            }
+        else
+            {
+            LOGGER_WRITE("EDriveInternal");
+            // read default DEV name
+            aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_DEVICE ).AllocL();
+            }
+        delete reader;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSconFolderLister::GetDriveTypeNumberL()
+// 
+// -----------------------------------------------------------------------------
+//  
+void CSconFolderLister::GetDriveTypeNumberL( TInt aDrive, TUint aDriveStatus , TInt& aTypeNumber)
+    {
+    TRACE_FUNC_ENTRY;
+    aTypeNumber = 0;
+    
+    //TUint driveStatus;
+    //
+    // if true, search internal drives, else search removable drives
+    TBool searchInternalDrives = (aDriveStatus & DriveInfo::EDriveInternal);
+    
+    TInt driveCount;
+    TDriveList driveList;
+    
+    User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
+    
+    for( TInt i = EDriveA; i <= aDrive; i++ )
+        {
+        if( driveList[i] )
+            {
+            TUint driveStatus;
+            User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
+
+            if( !(driveStatus & DriveInfo::EDrivePresent )
+                || driveStatus & DriveInfo::EDriveCorrupt )
+                {
+                LOGGER_WRITE( "not present or corrupted" );
+                continue;
+                }
+            
+            if( driveStatus & DriveInfo::EDriveInternal )
+                {
+                if( searchInternalDrives )
+                    {
+                    aTypeNumber++;
+                    }
+                }
+            else if( driveStatus & DriveInfo::EDriveRemovable )
+                {
+                if( !searchInternalDrives )
+                    {
+                    aTypeNumber++;
+                    }
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconFolderLister::ExportPathL( RBufWriteStream& aStream, const TDesC& aPathName,
+        const CSconFolderEntry& aEntry, const TBool aLocalize, const TInt aLevelsToSearch )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aPathName: %S", &aPathName );
+    LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch );
+    
+    LOGGER_WRITE_1("aEntry.iName: %S", &aEntry.iName->Des() );
+    
+    TBool localized(EFalse); 
+    
+    // foldername length + name
+    aStream.WriteUint8L( aEntry.iName->Length() );
+    aStream.WriteL( aEntry.iName->Des() );
+    
+    TUint att = aEntry.iAtt;
+    
+    if ( aEntry.iLabel && aEntry.iLabel->Length() > 0 )
+        {
+        aStream.WriteUint8L( aEntry.iLabel->Length() );
+        aStream.WriteL( aEntry.iLabel->Des() );
+        }
+    else
+        {
+        if ( aLocalize )
+            {
+            // initialize Localizer
+            iLocalizer->SetFullPath( aPathName );
+            localized = iLocalizer->IsLocalized();
+            }
+        
+        if( localized )
+            {
+            const TDesC& localizedName = iLocalizer->LocalizedName();
+            aStream.WriteUint8L( localizedName.Length() );
+            aStream.WriteL( localizedName );
+            LOGGER_WRITE_1("LocalizedName: %S", &localizedName );
+            }
+        else if ( aPathName.CompareF(_L("C:\\Data\\")) == 0 )
+            {
+            TFileName file( KSConResourceName );
+            
+            BaflUtils::NearestLanguageFile( iFs, file );
+               
+            CStringResourceReader* reader = CStringResourceReader::NewL( file );
+            CleanupStack::PushL( reader );
+            
+            const TDesC& localizedName = reader->ReadResourceString( R_SECON_DATA_FOLDER );
+            aStream.WriteUint8L( localizedName.Length() );
+            aStream.WriteL( localizedName );
+            LOGGER_WRITE_1("LocalizedName: %S", &localizedName );
+            
+            CleanupStack::PopAndDestroy( reader );
+            localized = ETrue;
+            }
+        else
+            {
+            aStream.WriteUint8L( 0 );
+            }
+        // attributes
+        if ( localized )
+            {
+            // localized folder, set readonly flag
+            att = att | KEntryAttReadOnly;
+            }
+        }
+    
+    if ( aPathName.Length() == 3 && aLocalize )
+        {
+        // enable subfolder localization, even when root cannot be localized
+        localized = ETrue;
+        }
+    
+    // DriveInfoEntry
+    if ( aEntry.iDriveInfoEntryExists )
+        {
+        aStream.WriteUint8L( 1 );
+        aStream.WriteUint8L( aEntry.iDriveInfoEntry.iDriveType );
+        aStream.WriteUint8L( aEntry.iDriveInfoEntry.iDriveTypeCount );
+        aStream << aEntry.iDriveInfoEntry.iFree;
+        aStream << aEntry.iDriveInfoEntry.iSize;
+        }
+    else
+        {
+        aStream.WriteUint8L( 0 );
+        }
+    
+    
+    // modified time
+    TDateTime time = aEntry.iModified.DateTime();
+    aStream.WriteInt16L( time.Year() );
+    aStream.WriteInt8L( time.Month()+1 ); // range 1...12
+    aStream.WriteInt8L( time.Day()+1 );
+    aStream.WriteInt8L( time.Hour() );
+    aStream.WriteInt8L( time.Minute() );
+    aStream.WriteInt8L( time.Second() );
+    
+    // write attribute
+    aStream.WriteUint32L( att );
+    
+    
+    if ( aLevelsToSearch == 0 )
+        {
+        // don't list directory content
+        LOGGER_WRITE("Not listing directory content");
+        aStream.WriteInt16L( 0 ); // files count
+        aStream.WriteInt16L( 0 ); // directory count
+        return;
+        }
+    
+    CDir *fileList = 0;
+    CDir *dirList = 0;
+    
+    // show normal and hidden files and folders
+    TUint entryAttMask = KEntryAttNormal | KEntryAttHidden;
+    
+    // get folders and files
+    TInt err = iFs.GetDir( aPathName, entryAttMask, ESortByName, 
+            fileList, dirList );
+    
+    if ( err )
+        {
+        LOGGER_WRITE_1( "ParseFolderListL GetDir returned: %d", err );
+        User::Leave( err );
+        }
+    
+    CleanupStack::PushL( dirList );
+    CleanupStack::PushL( fileList );
+    
+    
+    LOGGER_WRITE_1("files: %d", fileList->Count());
+    aStream.WriteUint16L( fileList->Count() );
+    
+    // Print files to folder listing object
+    for( TInt i = 0; i < fileList->Count(); i++ )
+        {
+        const TEntry& fileEntry = ( *fileList )[i];
+        iFiles++;
+        LOGGER_WRITE_1("fileEntry.iName: %S", &fileEntry.iName);
+        // filename length + name
+        aStream.WriteUint8L( fileEntry.iName.Length() );
+        aStream.WriteL( fileEntry.iName );
+        
+        // modified time
+        TDateTime time = fileEntry.iModified.DateTime();
+        aStream.WriteInt16L( time.Year() );
+        aStream.WriteInt8L( time.Month()+1 ); // range 1...12
+        aStream.WriteInt8L( time.Day()+1 );
+        aStream.WriteInt8L( time.Hour() );
+        aStream.WriteInt8L( time.Minute() );
+        aStream.WriteInt8L( time.Second() );
+        
+        // attributes
+        aStream.WriteUint32L( fileEntry.iAtt );
+        
+        // file size
+        aStream.WriteUint32L( fileEntry.iSize );
+        }
+    CleanupStack::PopAndDestroy( fileList );
+    
+    
+    // calculate ow many directories we are going to list
+    TInt directoryCount(0);
+    for( TInt i = 0; i < dirList->Count(); i++ )
+        {
+        if ( IsDirectoryPrintable(aPathName, ( *dirList )[i] ) )
+            {
+            directoryCount++;
+            }
+        }
+    LOGGER_WRITE_1("directories: %d", directoryCount);
+    aStream.WriteUint16L( directoryCount );
+    
+    HBufC* fullpath = HBufC::NewL( KMaxPath );
+    TPtr fullpathPtr = fullpath->Des();
+    CleanupStack::PushL( fullpath );
+    
+    // Print folders to folder listing object
+    for( TInt i = 0; i < dirList->Count(); i++ )
+        {
+        const TEntry& folderEntry = ( *dirList )[i];
+        if ( !IsDirectoryPrintable(aPathName, folderEntry) )
+            {
+            continue;
+            }
+        iFolders++;
+        
+        fullpathPtr.Copy( aPathName );
+        fullpathPtr.Append( folderEntry.iName );
+        fullpathPtr.Append( _L("\\") );
+        CSconFolderEntry* subFolderEntry = CSconFolderEntry::NewLC( folderEntry );
+        if ( aLevelsToSearch == KErrNotFound )
+            {
+            ExportPathL( aStream, fullpathPtr, *subFolderEntry, localized, aLevelsToSearch);
+            }
+        else
+            {
+            ExportPathL( aStream, fullpathPtr, *subFolderEntry, localized, aLevelsToSearch-1);
+            }
+        CleanupStack::PopAndDestroy( subFolderEntry );
+        }
+    CleanupStack::PopAndDestroy( fullpath );
+    CleanupStack::PopAndDestroy( dirList );
+    
+    TRACE_FUNC_EXIT;
+    }
+TBool CSconFolderLister::IsDirectoryPrintable( const TDesC& aParentPath, const TEntry& aFolderEntry )
+    {
+    if ( aFolderEntry.IsSystem() )
+        {
+        LOGGER_WRITE_1("folder '%S' was system folder", &aFolderEntry.iName);
+        return EFalse;
+        }
+    if ( aParentPath.Length() == 3 )
+        {
+        if ( aParentPath.FindF(_L("C:\\")) == 0 && aFolderEntry.iName.CompareF(_L("data")) != 0 )
+            {
+            // C root not visible, exept Data folder
+            LOGGER_WRITE_1("folder '%S' not visible to user in c-root", &aFolderEntry.iName);
+            return EFalse;
+            }
+        
+        if ( aFolderEntry.iName.CompareF(_L("private")) == 0 )
+            {
+            LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName);
+            return EFalse;
+            }
+        else if ( aFolderEntry.iName.CompareF(_L("sys")) == 0 )
+            {
+            LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName);
+            return EFalse;
+            }
+        else if ( aFolderEntry.iName.CompareF(_L("system")) == 0 )
+            {
+            LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName);
+            return EFalse;
+            }
+        else if ( aFolderEntry.iName.CompareF(_L("resource")) == 0 )
+            {
+            LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName);
+            return EFalse;
+            }
+        }
+    return ETrue;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/pcconn/src/sconimsireader.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconImsiReader implementation
+*
+*/
+
+
+#include "sconimsireader.h"
+#include "debug.h"
+
+TInt CSconImsiReader::GetImsiL( TDes& aImsi )
+    {
+    TRACE_FUNC_ENTRY;
+    CTelephony::TRegistrationStatus temp;
+    CSconImsiReader* self = new (ELeave) CSconImsiReader(aImsi, temp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    
+    self->RequestImsi();
+    
+    TInt err = self->iStatus.Int();
+    CleanupStack::PopAndDestroy(self);
+    TRACE_FUNC_RET(err);
+    return err;
+    }
+
+TInt CSconImsiReader::GetNetworkStatusL( CTelephony::TRegistrationStatus& aRegistrationStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    TBuf<CTelephony::KIMSISize> temp;
+    CSconImsiReader* self = new (ELeave) CSconImsiReader(temp, aRegistrationStatus);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    
+    self->RequestNetworkStatus();
+    
+    TInt err = self->iStatus.Int();
+    CleanupStack::PopAndDestroy(self);
+    TRACE_FUNC_RET(err);
+    return err;
+    }
+ 
+void CSconImsiReader::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iTelephony = CTelephony::NewL();
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconImsiReader::RequestImsi()
+    {
+    iImsiReaderStatus = ERequestingImsi;
+    iTelephony->GetSubscriberId(iStatus,iSubscriberIdV1Pckg);
+    SetActive();
+    CActiveScheduler::Start();
+    }
+
+void CSconImsiReader::RequestNetworkStatus()
+    {
+    iImsiReaderStatus = ERequestingNetworkStatus;
+    iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegistrationV1Pckg);
+    SetActive();
+    CActiveScheduler::Start();
+    }
+
+CSconImsiReader::~CSconImsiReader()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iTelephony;
+    TRACE_FUNC_EXIT;
+    }
+ 
+CSconImsiReader::CSconImsiReader(TDes& aImsi, CTelephony::TRegistrationStatus& aRegistrationStatus): CActive(EPriorityStandard),
+    iImsi(aImsi), iNetworkStatus(aRegistrationStatus), iSubscriberIdV1Pckg(iSubscriberIdV1), iNetworkRegistrationV1Pckg(iNetworkRegistrationV1)
+    {
+    }
+ 
+void CSconImsiReader::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("iStatus: %d", iStatus.Int() );
+    if ( iStatus == KErrNone )
+        {
+        if ( iImsiReaderStatus == ERequestingImsi )
+            {
+            iImsi = iSubscriberIdV1.iSubscriberId;
+            LOGGER_WRITE_1("iImsi: %S", &iImsi);
+            }
+        else if ( iImsiReaderStatus == ERequestingNetworkStatus )
+            {
+            iNetworkStatus = iNetworkRegistrationV1.iRegStatus;
+            LOGGER_WRITE_1( "iNetworkStatus: %d", (TInt)iNetworkStatus);
+            }
+        }
+    CActiveScheduler::Stop();
+    TRACE_FUNC_EXIT;
+    }
+ 
+void CSconImsiReader::DoCancel()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iImsiReaderStatus == ERequestingImsi )
+        {
+        iTelephony->CancelAsync( CTelephony::EGetSubscriberIdCancel );
+        }
+    else if ( iImsiReaderStatus == ERequestingNetworkStatus )
+        {
+        iTelephony->CancelAsync( CTelephony::EGetNetworkRegistrationStatusCancel );
+        }
+    TRACE_FUNC_EXIT;
+    }
--- a/connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -18,12 +18,18 @@
 
 #include <s32mem.h> // For RMemReadStream
 #include <utf.h>
+#include <Etel3rdParty.h>
+#include <f32file.h>
 
 #include "sconpcconnclientserver.h"
 #include "sconpcconnserver.h"
 #include "sconpcd.h"
 #include "sconcsc.h"
 #include "sconconmlhandler.h"
+#include "sconimsireader.h"
+#include "sconoviaccounthandler.h"
+#include "sconfolderlister.h"
+#include "sconbtengine.h"
 #include "debug.h"
 
 #ifdef DEBUG_XML
@@ -33,6 +39,15 @@
 #endif
 
 _LIT( KSCONGetMetadataRequest, "METADATA:" );
+_LIT8( KSCONSyncRequest, "SYNC:" );
+_LIT( KSCONReadImsi, "READIMSI");
+_LIT( KSCONReadNetworkInfo, "READNETWORKINFO");
+_LIT( KSCONReadOviAccount, "READOVIACCOUNT");
+_LIT( KSCONListPath, "LISTP:");
+_LIT( KSCONReadBtInfo, "READBTINFO" );
+_LIT( KSCONSetBtPower, "SETBTPOWER:" );
+_LIT( KSCONSetBtName, "SETBTNAME:" );
+_LIT( KSCONSetBtAuthorized, "SETBTAUTHORIZED:" );
 
 //------------------------------------------------------------
 // Global functions 
@@ -272,7 +287,12 @@
         }
         
     iChunk.Close();
-        
+    delete iFolderLister;
+    
+    iFs.Close();
+    
+    delete iBtEngine;
+     
     TRACE_FUNC_EXIT;
     }
 
@@ -304,21 +324,18 @@
     TInt ret ( KErrNone );
     iResult = KErrNone;
     
+    User::LeaveIfError( iFs.Connect() );
+    
 #ifdef DEBUG_XML
     // create log file 
-    RFs fs;
-    User::LeaveIfError( fs.Connect () );
-    CleanupClosePushL( fs );
     
     RFile file;
-    TInt err = file.Create ( fs, KSConConMLDebugFile, EFileWrite );
+    TInt err = file.Create ( iFs, KSConConMLDebugFile, EFileWrite );
     if( err == KErrNone )
         {
         // file created, close it
         file.Close();
-        }       
-    
-    CleanupStack::PopAndDestroy( &fs );               
+        }              
 #endif
     
     // initialize buffer
@@ -355,7 +372,9 @@
             User::Leave ( ret );
             }
         }
-
+    
+    iFolderLister = CSconFolderLister::NewL( iFs );
+    
     TRACE_FUNC_EXIT;
     }
 
@@ -457,9 +476,14 @@
     iBuffer->Reset();
 
     length = buf.ReadInt32L();
-    HBufC8* name = HBufC8::NewLC( length );
-    TPtr8 namePtr = name->Des();
-    buf.ReadL( namePtr, length);
+    HBufC8* name8 = HBufC8::NewLC( length );
+    TPtr8 namePtr8 = name8->Des();
+    buf.ReadL( namePtr8, length);
+    
+    const TUint8* ptr8 = namePtr8.Ptr();
+    const TUint16* ptr16 = reinterpret_cast<const TUint16*>( ptr8 );
+    TPtrC namePtr;
+    namePtr.Set( ptr16, length/2 );
         
     length = buf.ReadInt32L();
     HBufC8* type = HBufC8::NewLC( length );
@@ -478,12 +502,9 @@
     buf.Close();
     
 #ifdef DEBUG_XML
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
 
     RFile file;
-    if ( file.Open( fs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
+    if ( file.Open( iFs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
         {
         RFileWriteStream fws;
         TInt fileSize;
@@ -507,11 +528,25 @@
  
         CleanupStack::PopAndDestroy( &fws );
         }
-    file.Close();   
-    CleanupStack::PopAndDestroy( &fs );
+    file.Close();
 #endif
-    
-    if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || 
+    if ( ( ( typePtr.CompareC( KSConPCDWBXMLObjectType)== KErrNone ) || 
+                 ( typePtr.CompareC( KSConPCDWBXMLObjectType2 )== KErrNone ) )
+                 && namePtr8.Find(KSCONSyncRequest) == 0 )
+        {
+        LOGGER_WRITE_1("Sync request: %S", &namePtr);
+        RBufReadStream stream( *iBuffer );
+        
+        CleanupClosePushL( stream );
+        TRAP( ret, iPCDHandler->HandlePutSyncRequestL( namePtr8, stream ));
+        if ( ret )
+            {
+            LOGGER_WRITE_1("HandlePutSyncRequestL() Leaved with %d", ret);
+            }
+        
+        CleanupStack::PopAndDestroy( &stream );
+        }
+    else if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || 
          ( typePtr.Compare( KSConPCDWBXMLObjectType2 )== KErrNone) )
         {
         LOGGER_WRITE( "CSConPCConnSession::HandlePutMessageL() : Object type PCD " );
@@ -533,7 +568,7 @@
         }
     CleanupStack::PopAndDestroy( data );
     CleanupStack::PopAndDestroy( type );
-    CleanupStack::PopAndDestroy( name );
+    CleanupStack::PopAndDestroy( name8 );
     LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() end : Heap count : %d", User::Heap().Count() );
     LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() : returned %d", ret );    
     return ret;
@@ -587,12 +622,9 @@
         ret = iCSCHandler->CapabilityObject( *iBuffer );
         
 #ifdef DEBUG_XML
-        RFs fs;
-        User::LeaveIfError(fs.Connect());
-        CleanupClosePushL(fs);
-
+        
         RFile file;
-        if ( file.Open(fs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
+        if ( file.Open(iFs, KSConConMLDebugFile, EFileWrite ) == KErrNone )
             {
             RFileWriteStream fws;
             TInt fileSize;
@@ -616,13 +648,218 @@
             CleanupStack::PopAndDestroy( &fws );
             }
         file.Close();
-        CleanupStack::PopAndDestroy( &fs );
 #endif
 
         }
     else if (  typePtr.CompareC( KSConPCDWBXMLObjectType) == KErrNone )
         {
-        ret = HandleWBXMLGetRequestL( namePtr );
+        if ( namePtr8.Find(KSCONSyncRequest) == 0 ) // 8-bit search
+            {
+            LOGGER_WRITE("Sync request");
+            
+            RBufWriteStream stream( *iBuffer );
+                
+            CleanupClosePushL( stream );
+            
+            TRAP( ret, iPCDHandler->HandleGetSyncRequestL( namePtr8, stream, iChunk.MaxSize() - sizeof(TInt32) ));
+            if ( ret )
+                {
+                LOGGER_WRITE_1("HandleGetSyncRequestL() Leaved with %d", ret);
+                }
+            stream.CommitL();
+            CleanupStack::PopAndDestroy( &stream );
+            
+            LOGGER_WRITE_1("iBuffer size: %d", iBuffer->Size());
+            
+            }
+        else if ( namePtr.Find(KSCONReadImsi) == 0 ) // 16-bit search
+            {
+            LOGGER_WRITE("Read IMSI");
+            TBuf<CTelephony::KIMSISize> imsi;
+            ret = CSconImsiReader::GetImsiL( imsi );
+            
+            if ( ret == KErrNone )
+                {
+                TBuf8<CTelephony::KIMSISize> imsi8;
+                User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8(imsi8,imsi) );
+                
+                iBuffer->ResizeL( imsi8.Length() );
+                iBuffer->Write( 0, imsi8 );
+                }
+            else
+                {
+                // Change error code more generic
+                ret = KErrNotFound;
+                }
+            }
+        else if ( namePtr.Find(KSCONReadNetworkInfo) == 0 ) // 16-bit search
+            {
+            LOGGER_WRITE("Read NetworkInfo");
+            CTelephony::TRegistrationStatus regStatus;
+            ret = CSconImsiReader::GetNetworkStatusL( regStatus );
+            
+            if ( ret == KErrNone )
+                {
+                RBufWriteStream stream( *iBuffer );
+                CleanupClosePushL( stream );
+                stream.WriteInt8L( regStatus );
+                stream.CommitL();
+                CleanupStack::PopAndDestroy( &stream );
+                }
+            else
+                {
+                // Change error code more generic
+                ret = KErrNotFound;
+                }
+            }
+        else if ( namePtr.Find(KSCONReadOviAccount) == 0 )
+            {
+            LOGGER_WRITE("Read Ovi account");
+            RBufWriteStream stream( *iBuffer );
+            CleanupClosePushL( stream );
+            
+            ret = ReadOviAccountInfoL( stream );
+            stream.CommitL();
+            CleanupStack::PopAndDestroy( &stream );
+            
+            }
+        else if ( namePtr.Find(KSCONListPath) == 0 )
+            {
+            LOGGER_WRITE("List path");
+            // LISTP:0:pathname
+            if ( namePtr.Length() > KSCONListPath().Length()+2)
+                {
+                TPtrC pathname = namePtr.Mid( KSCONListPath().Length()+2 );
+            
+                const TUint16 levelsChar = namePtr[ KSCONListPath().Length() ];
+                TInt level(KErrNotFound);
+                if ( levelsChar >= TChar('0') )
+                    {
+                    level = levelsChar - TChar('0');
+                    }
+                
+                RBufWriteStream stream( *iBuffer );
+                CleanupClosePushL( stream );
+                TRAP( ret, iFolderLister->GenerateFolderListL( stream, pathname, level ));
+                LOGGER_WRITE_1("GenerateFolderListL leaved with err: %d", ret);
+                stream.CommitL();
+                CleanupStack::PopAndDestroy( &stream );
+                }
+            else
+                {
+                ret = KErrArgument;
+                }
+            
+            }
+        else if ( namePtr.Find(KSCONReadBtInfo) == 0 )
+            {
+            LOGGER_WRITE( "Read BT info");
+            if ( !iBtEngine )
+                {
+                iBtEngine = CSconBtEngine::NewL();
+                }
+            RBufWriteStream stream( *iBuffer );
+            CleanupClosePushL( stream );
+            TRAP( ret, iBtEngine->ReadBTInfoL( stream ) );
+            LOGGER_WRITE_1("ReadBTInfoL leaved with err: %d", ret);
+            stream.CommitL();
+            CleanupStack::PopAndDestroy( &stream );
+            }
+        else if ( namePtr.Find(KSCONSetBtPower) == 0 )
+            {
+            LOGGER_WRITE( "Change BT Power state");
+            if ( namePtr.Length() == KSCONSetBtPower().Length()+1 )
+                {
+                const TUint16 lastChar = namePtr[ KSCONSetBtPower().Length() ];
+                TBool changeBtOn;
+                if ( lastChar == TChar('0') )
+                    {
+                    changeBtOn = EFalse;
+                    }
+                else if ( lastChar == TChar('1') )
+                    {
+                    changeBtOn = ETrue;
+                    }
+                else
+                    {
+                    ret = KErrArgument;
+                    }
+                
+                if ( !ret )
+                    {
+                    if ( !iBtEngine )
+                       {
+                       iBtEngine = CSconBtEngine::NewL();
+                       }
+                    TInt err = iBtEngine->SetBtPowerState( changeBtOn );
+                    
+                    RBufWriteStream stream( *iBuffer );
+                    CleanupClosePushL( stream );
+                    stream.WriteInt32L( err );
+                    stream.CommitL();
+                    CleanupStack::PopAndDestroy( &stream );
+                    }
+                }
+            else
+                {
+                ret = KErrArgument;
+                }
+            }
+        else if ( namePtr.Find(KSCONSetBtName) == 0 )
+            {
+            LOGGER_WRITE( "Set BT Name");
+            TPtrC btName = namePtr.Mid( KSCONSetBtName().Length() );
+            TInt err = iBtEngine->SetBtName( btName  );
+            
+            RBufWriteStream stream( *iBuffer );
+            CleanupClosePushL( stream );
+            stream.WriteInt32L( err );
+            stream.CommitL();
+            CleanupStack::PopAndDestroy( &stream );
+            }
+        else if ( namePtr.Find(KSCONSetBtAuthorized) == 0 )
+            {
+            LOGGER_WRITE( "Set BT Authorized");
+            ret = KErrArgument;
+            // SETBTAUTHORIZED:0:00245f8d6a26
+            // 1. param = auth. state ("0"=off, "1"=true)
+            // 2. param = bt address (hex string)
+            
+            if ( namePtr.Length() > KSCONSetBtAuthorized().Length()+2)
+                {
+                TPtrC btAddr = namePtr.Mid( KSCONSetBtAuthorized().Length()+2 );
+                
+                const TUint16 authStateChar = namePtr[ KSCONSetBtAuthorized().Length() ];
+                TBool authorize(EFalse);
+                if ( authStateChar == TChar('0') )
+                    {
+                    authorize = EFalse;
+                    ret = KErrNone;
+                    }
+                else if ( authStateChar == TChar('1') )
+                    {
+                    authorize = ETrue;
+                    ret = KErrNone;
+                    }
+                
+                if ( !iBtEngine )
+                   {
+                   iBtEngine = CSconBtEngine::NewL();
+                   }
+                TRAPD(err, iBtEngine->SetBtAuthorizedL( btAddr, authorize ) );
+                
+                RBufWriteStream stream( *iBuffer );
+                CleanupClosePushL( stream );
+                stream.WriteInt32L( err );
+                stream.CommitL();
+                CleanupStack::PopAndDestroy( &stream );
+                }
+            
+            }
+        else 
+            {
+            ret = HandleWBXMLGetRequestL( namePtr );
+            }
         }
     else
         {
@@ -760,6 +997,59 @@
     return ret;
     }
 
+
+// -----------------------------------------------------------------------------
+// CSConPCConnSession::ReadOviAccountInfoL()
+// Reads ovi account information to stream
+// -----------------------------------------------------------------------------
+//
+TInt CSConPCConnSession::ReadOviAccountInfoL( RWriteStream& aAccountInfoStream )
+    {
+	TRACE_FUNC_ENTRY;
+    RLibrary oviaccounthandlerLib;
+    CleanupClosePushL( oviaccounthandlerLib );
+    // Dynamically load DLL
+    TInt err = oviaccounthandlerLib.Load( KSconOviAccountHandlerDllName );
+    if ( err )
+        {
+        LOGGER_WRITE_1("oviaccounthandlerLib.Load err: %d", err);
+        err = KErrNotSupported;
+        }
+    else if( oviaccounthandlerLib.Type()[1] != KSconOviAccountHandlerDllUid )
+        {
+        LOGGER_WRITE_1( "KSconOviAccountHandlerDllUid incorrect... (0x%08X)",oviaccounthandlerLib.Type()[1].iUid  );
+        err = KErrNotSupported;
+        }
+    
+    if ( err == KErrNone )
+        {
+        TSConCreateCSconOviAccountHandlerFunc CreateCSconOviAccountHandlerL =
+        (TSConCreateCSconOviAccountHandlerFunc)oviaccounthandlerLib.Lookup(1);
+        
+        CSconOviAccountHandler* oviAccountHandler = (CSconOviAccountHandler*)CreateCSconOviAccountHandlerL();
+        
+        TRAP(err, oviAccountHandler->GetOviAccountDetailsL( aAccountInfoStream ) );
+        LOGGER_WRITE_1("GetOviAccountDetailsL err: %d", err);
+        
+        delete oviAccountHandler;
+        oviAccountHandler = NULL;
+        
+        if ( err )
+            {
+            // change error code
+            err = KErrNotFound;
+            }
+        }
+    else
+        {
+        err = KErrNotSupported;
+        }
+	
+    CleanupStack::PopAndDestroy( &oviaccounthandlerLib );
+	TRACE_FUNC_EXIT;
+    return err;
+    }
+
 // -----------------------------------------------------------------------------
 // CSConPCConnSession::HandleResetMessage()
 // Resets the PCCS service
@@ -878,12 +1168,8 @@
     
 #ifdef DEBUG_XML
     iConMLHandler->GenerateDocument( aContent );
-    RFs fs;
-    User::LeaveIfError(fs.Connect());
-    CleanupClosePushL(fs);
     RFile file;
-    
-    if ( file.Open(fs, KSConConMLDebugFile, EFileWrite) == KErrNone )
+    if ( file.Open(iFs, KSConConMLDebugFile, EFileWrite) == KErrNone )
         {
         RFileWriteStream fws;
         TInt fileSize;
@@ -910,7 +1196,6 @@
         CleanupStack::PopAndDestroy( &fws );
         }
     file.Close();
-    CleanupStack::PopAndDestroy( &fs );
     
 #endif
 
@@ -2216,6 +2501,12 @@
             aContent->complete = new ( ELeave ) pcdata_t();
             }
         AppendProgressL( aContent, aResult->iProgress );
+        
+        if ( aResult->iData && aResult->iData->Length() > 0 )
+            {
+            aContent->data = new ( ELeave ) pcdata_t();
+            aContent->data->SetDataL( aResult->iData->Des() );
+            }
         }
     TRACE_FUNC_EXIT;
     }
@@ -2238,6 +2529,12 @@
             }
         LOGGER_WRITE_1( "CSConPCConnSession::AppendUninstallResultsL() iProgress: %d", aResult->iProgress );
         AppendProgressL( aContent, aResult->iProgress );
+        
+        if ( aResult->iData && aResult->iData->Length() > 0 )
+            {
+            aContent->data = new ( ELeave ) pcdata_t();
+            aContent->data->SetDataL( aResult->iData->Des() );
+            }
         }
     TRACE_FUNC_EXIT;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project SyncServer
+*
+*/
+
+
+PRJ_EXPORTS
+../rom/sconsyncserver.iby      CORE_APP_LAYER_IBY_EXPORT_PATH(sconsyncserver.iby)
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+sconsyncserver.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/group/sconsyncserver.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  sconsyncserver mmp file
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+
+TARGET          sconsyncserver.exe
+TARGETTYPE      exe
+
+// Same capabilities than in DS Ui application
+CAPABILITY      LocalServices ReadUserData WriteUserData ReadDeviceData WriteDeviceData NetworkServices UserEnvironment ProtServ SwEvent NetworkControl Location
+
+UID             0x0 0x2001A964
+VENDORID        VID_DEFAULT
+
+EPOCSTACKSIZE   0x2000
+EPOCHEAPSIZE	0x500 0x800000 	// minimum and maximum heap sizes
+
+SOURCEPATH      ../src
+SOURCE          sconsyncserver.cpp
+SOURCE          sconsyncsession.cpp
+SOURCE          sconsyncrelationship.cpp
+SOURCE          sconasynchandler.cpp
+SOURCE          cscontimeout.cpp
+
+// common components (dataproviderinfo)
+SOURCEPATH      ../../../clients/syncclient/src
+USERINCLUDE     ../../../clients/syncclient/inc
+SOURCE          scondataproviderinfo.cpp
+
+USERINCLUDE     ..\inc
+
+// Default system include paths
+APP_LAYER_SYSTEMINCLUDE
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         ecom.lib
+LIBRARY         estor.lib // CDictionaryFileStore
+LIBRARY         smldataprovider.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY         charconv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/cscontimeout.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCSconTimeOut header file
+*
+*/
+
+
+#ifndef CSCONTIMEOUT_H
+#define CSCONTIMEOUT_H
+
+#include <e32base.h>	// For CActive, link against: euser.lib
+#include <e32std.h>		// For RTimer, link against: euser.lib
+
+class MTimeOutObserver
+    {
+public:
+    virtual void TimeOut() = 0;
+    };
+
+class CCSconTimeOut : public CActive
+    {
+public:
+    // Cancel and destroy
+    ~CCSconTimeOut();
+
+    // Two-phased constructor.
+    static CCSconTimeOut* NewL( MTimeOutObserver& aTimeOutObserver );
+    
+public:
+    // New functions
+    // Function for making the timeout request
+    void Start(TTimeIntervalMicroSeconds32 aDelay);
+    
+private:
+    // C++ constructor
+    CCSconTimeOut( MTimeOutObserver& aTimeOutObserver );
+    
+    // Second-phase constructor
+    void ConstructL();
+    
+private:
+    // From CActive
+    // Handle completion
+    void RunL();
+    
+    // How to cancel me
+    void DoCancel();
+    
+    // Override to handle leaves from RunL(). Default implementation causes
+    // the active scheduler to panic.
+    TInt RunError(TInt aError);
+    
+private:
+    enum TCSconTimeOutState
+        {
+        EUninitialized, // Uninitialized
+        EInitialized, // Initalized
+        EError
+        // Error condition
+        };
+
+private:
+    TInt iState; // State of the active object
+    RTimer iTimer; // Provides async timing service
+    MTimeOutObserver& iTimeOutObserver;
+    };
+
+#endif // CSCONTIMEOUT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/debug.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,130 @@
+/*
+* 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:  Debug utility for SyncServer
+*
+*/
+
+
+#ifndef _SECON_DEBUG_H
+#define _SECON_DEBUG_H
+
+#ifdef _DEBUG
+    
+    // File logging
+    #define __FLOGGING__
+    
+    #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, "SECON" );
+    _LIT( KLogFile, "SeconDebug.txt" );
+    
+    _LIT(KTracePrefix16, "[SeConSync] ");
+    _LIT8(KTracePrefix8, "[SeConSync] ");
+    _LIT8(KFuncEntryFormat8, "%S : Begin");
+    _LIT8(KFuncExitFormat8, "%S : End");
+    _LIT8(KFuncFormat8, "><%S");
+    
+    const TInt KMaxLogLineLength = 512;
+    
+    // old function loggin macros
+    #define FLOG(a) {FPrint(a);}
+    #define FLOG_1(a,b) {FPrint(a,b);}
+    #define FLOG_2(a,b,c) {FPrint(a,b,c);}
+    #define FTRACE(a) {a;}
+    #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_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 );}
+    
+    // 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 FLOG(a)
+    #define FLOG_1(a,b)
+    #define FLOG_2(a,b,c)
+    #define FTRACE(a)
+    #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 // SECON_DEBUG_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/logdatastoreformat.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Simple class for tracing datastore format
+*
+*/
+
+#ifndef LOGDATASTOREFORMAT_H_
+#define LOGDATASTOREFORMAT_H_
+
+//
+#include "debug.h"
+
+NONSHARABLE_CLASS(TLogDataStoreFormat)
+    {
+    public:
+#ifndef _DEBUG
+// does nothing on release version
+static void TLogDataStoreFormat::LogDataStoreFormatL( const TDesC& /*aLogInfo*/, const CSmlDataStoreFormat& /*aDataStoreFormat*/ )
+    {
+    }
+#else
+static void TLogDataStoreFormat::LogDataStoreFormatL( const TDesC& aLogInfo, const CSmlDataStoreFormat& aDataStoreFormat )
+    {
+    LOGGER_WRITE_1("LogDataStoreFormatL, aLogInfo: %S", &aLogInfo);
+    LOGGER_WRITE_1("DisplayName: %S", &aDataStoreFormat.DisplayName());
+    TBool hasMaxSize = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHasMaxSize );
+    TBool hasMaxItems = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHasMaxItems );
+    TBool hierarcial = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHierarchial );
+    LOGGER_WRITE_1("hasMaxSize: %d", (TInt)hasMaxSize);
+    LOGGER_WRITE_1("hasMaxItems: %d", (TInt)hasMaxItems);
+    LOGGER_WRITE_1("hierarcial: %d", (TInt)hierarcial);
+    LOGGER_WRITE_1("MimeFormatCount: %d", aDataStoreFormat.MimeFormatCount());
+    for ( TInt i = 0; i < aDataStoreFormat.MimeFormatCount(); i++)
+        {
+        LOGGER_WRITE_1("  MimeFormat(%d)",i);
+        const CSmlMimeFormat& mimeformat = aDataStoreFormat.MimeFormat(i);
+        LOGGER_WRITE8_1("  MimeType: %S", &mimeformat.MimeType().DesC());
+        LOGGER_WRITE8_1("  MimeVersion: %S", &mimeformat.MimeVersion().DesC());
+        LOGGER_WRITE_1( "  FieldLevel, bool: %d", (TInt) mimeformat.FieldLevel());
+        LOGGER_WRITE_1( "  PropertyCount: %d", mimeformat.PropertyCount());
+        for ( TInt j=0; j<mimeformat.PropertyCount(); j++ )
+            {
+            LOGGER_WRITE_1("    MimeFormat property(%d)",j);
+            const CSmlDataProperty& dataProp = mimeformat.Property(j);
+            const CSmlDataField& dataField = dataProp.Field();
+            LOGGER_WRITE8_1("    dataField: %S", &dataField.Name().DesC());
+            LOGGER_WRITE_1( "    DisplayName: %S", &dataField.DisplayName());
+            LOGGER_WRITE_1( "    HasMaxSize: %d", (TInt)dataProp.HasMaxSize());
+            LOGGER_WRITE_1( "    MaxSize: %d", dataProp.MaxSize());
+            LOGGER_WRITE_1( "    HasMaxOccur: %d", (TInt)dataProp.HasMaxOccur());
+            LOGGER_WRITE_1( "    MaxOccur: %d", dataProp.MaxOccur());
+            TBool OptionNoTruncate = dataProp.IsSupported(CSmlDataProperty::EOptionNoTruncate);
+            LOGGER_WRITE_1( "    EOptionNoTruncate: %d", (TInt)OptionNoTruncate);
+            LOGGER_WRITE8_1("    DataType(): %S", &dataField.DataType().DesC());
+            LOGGER_WRITE_1( "    EnumValueCount(): %d", dataField.EnumValueCount());
+            for ( TInt k=0; k<dataField.EnumValueCount(); k++)
+                {
+                LOGGER_WRITE8_1("      EnumValue(): %S", &dataField.EnumValue(k).DesC());
+                }
+            LOGGER_WRITE_1("    ParamCount: %d", dataProp.ParamCount());
+            for ( TInt k=0; k<dataProp.ParamCount(); k++)
+                {
+                LOGGER_WRITE_1( "      dataParamField(%d)", k);
+                const CSmlDataPropertyParam& param = dataProp.Param(k);
+                const CSmlDataField& field = param.Field();
+                LOGGER_WRITE8_1("      dataParamField: %S", &field.Name().DesC());
+                LOGGER_WRITE_1( "      dataParamDisplayName: %S", &field.DisplayName());
+                LOGGER_WRITE8_1("      dataParamDataType(): %S", &field.DataType().DesC());
+                LOGGER_WRITE_1( "      dataParamEnumValueCount(): %d", field.EnumValueCount());
+                for ( TInt l=0; l<field.EnumValueCount(); l++)
+                    {
+                    LOGGER_WRITE8_1("        dataParamEnumValue(): %S", &field.EnumValue(l).DesC());
+                    }
+                
+                LOGGER_WRITE("      ---------------");
+                }
+            LOGGER_WRITE(   "    -----------------");
+            }
+        
+        LOGGER_WRITE(   "  -----------------");
+        }
+    }
+#endif
+    };
+
+
+#endif /* LOGDATASTOREFORMAT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconasynchandler.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,127 @@
+/*
+* 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:  CSconAsyncHandler header
+*
+*/
+
+
+#ifndef SCONASYNCHANDLER_H_
+#define SCONASYNCHANDLER_H_
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include <syncml/SmlDataSyncDefs.h>
+#include <stringpool.h>
+
+#include "cscontimeout.h"
+
+class CSmlDataStore;
+class CSconSyncRelationship;
+class CSmlDataProvider;
+class CNSmlDataItemUidSet;
+class CSmlDataStoreFormat;
+
+NONSHARABLE_CLASS ( CSconAsyncHandler ): public CActive, MTimeOutObserver
+{
+public:
+    static CSconAsyncHandler* NewL();
+	~CSconAsyncHandler();
+	void HandleServiceL( const RMessage2& aMessage );
+	
+private: // From CActive 
+    void RunL();
+    TInt RunError(TInt aError);
+    void DoCancel();
+    
+private: // From MTimeOutObserver
+    void TimeOut();
+    
+private:
+    
+	CSconAsyncHandler();
+	void ConstructL();
+	
+	void HandleChunkMessage();
+    void ListAllImplementationsL();
+    void OpenStoreL();
+	
+	void OpenItemL();
+	void OpenItemCompletedL( TInt aError );
+	
+	void CreateItemL();
+	void CreateItemCompletedL( TInt aError );
+	void ReplaceItemL();
+	void ReplaceItemCompletedL( TInt aError );
+	void MoveItemL();
+	void DeleteItemL();
+	void SoftDeleteItemL();
+	void DeleteAllItemsL();
+	void ReadParentL();
+	void ReadParentCompletedL( TInt aError );
+	
+    void HasHistoryL();
+    void AddedItemsL();
+    void DeletedItemsL();
+    void SoftDeletedItemsL();
+    void ModifiedItemsL();
+    void MovedItemsL();
+	//void ListChangesL();
+	void ResetChangeInfoL();
+	void CommitChangeInfoL();
+	void CloseStore();
+	
+	void SetSyncTimeStampL();
+	void GetSyncTimeStampL();
+	
+	void ExportStoreFormatL();
+	void SetRemoteStoreFormatL();
+	
+	void LeaveIfNoInstanceL();
+	
+	void DoCloseStore();
+	
+	void CleanOldStoresL();
+	void CompleteRequest( TInt aError );
+private:
+    RChunk  iChunk;
+    
+    RStringPool            iStringPool;
+    CSmlDataStoreFormat*   iStoreFormat;
+    CSmlDataProvider*      iDataProvider;
+    CSmlDataStore*         iDataStore;
+    CSconSyncRelationship* iContext;
+    RFs                    iFs;
+	RMessage2              iMessage;
+	
+	// for committing changes
+	CNSmlDataItemUidSet*   iItems;
+	
+	// for opening item
+	TBool iFieldChange;
+	TInt iSize;
+	TInt iParent;
+	TBuf8<64> iMimeType;
+	TBuf8<64> iMimeVer;
+	
+	// for creating item
+	TSmlDbItemUid  iNewItem;
+	HBufC8*        iWriteData;
+	TBool          iCommitInProgress;
+	
+	CCSconTimeOut*         iTimeOut;
+	TBool                  iForceCancel;
+};
+
+#endif /*SCONASYNCHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncclientserver.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Sync Client-Server header
+*
+*/
+
+
+#ifndef SCONSYNCCLIENTSERVER_H
+#define SCONSYNCCLIENTSERVER_H
+
+#include <e32base.h>
+
+_LIT(KSconSyncServerName, "sconsyncserver");
+_LIT(KSconSyncServerExe, "sconsyncserver.exe");
+
+
+enum TService
+{
+    ESendChunkHandle,
+    ECancelRequest,
+    EListImplementations,
+    
+    EOpenStore,
+    EOpenItem,
+    ECreateItem,
+    EReplaceItem,
+    EMoveItem,
+    EDeleteItem,
+    ESoftDeleteItem,
+    EDeleteAllItems,
+    EReadParent,
+    
+    EHasHistory,
+    EAddedItems,
+    EDeletedItems,
+    ESoftDeletedItems,
+    EModifiedItems,
+    EMovedItems,
+    
+    //EListChanges,
+    EResetChangeInfo,
+    ECommitChangeInfo,
+    
+    ECloseStore,
+    ESetSyncTimeStamp,
+    EGetSyncTimeStamp,
+    EExportStoreFormat,
+    ESetRemoteStoreFormat,
+    
+    EMaxService     // Not an actual service
+};
+
+#endif // SCONSYNCCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncrelationship.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* 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:  CSconSyncRelationship header
+*
+*/
+
+
+#ifndef SCONSYNCRELATIONSHIP_H_
+#define SCONSYNCRELATIONSHIP_H_
+
+#include <e32base.h>
+#include <f32file.h> 
+#include <s32file.h>
+#include <syncml/smldatasyncdefs.h>
+#include <syncmldef.h>
+
+class CDictionaryFileStore;
+
+NONSHARABLE_CLASS ( CSconSyncRelationship ) : public CBase, public MSmlSyncRelationship
+    {
+public:
+    /**
+     * Creates CSconSyncRelationship object.
+     * @param   aFs             reference to open RFs connection
+     * @param   aRelationUid    uniqueID for each server-client pair
+     * @return new CSconSyncRelationship object
+     */
+    static CSconSyncRelationship* NewL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId );
+	~CSconSyncRelationship();
+	
+	static void SetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId );
+	static void GetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId, TDateTime& aTimeStamp );
+	
+public: // From MSmlSyncRelationship
+    
+	/**
+     * Returns the unique identifier for the synchronisation relationship.
+     *
+     * @return             A unique identifier for the sync relationship.
+     */
+    TSmlSyncTaskKey SyncTaskKey() const;
+    
+    /**
+     * Opens a specified stream for reading, and places an item on the cleanup stack to close it.
+     *
+     * @param               aReadStream    On return, an open read stream
+     * @param               aStreamUid     The UID of the stream to open for reading.
+     */
+    void OpenReadStreamLC(RReadStream& aReadStream, TUid aStreamUid);
+    
+    /**
+     * Opens the specified stream, or creates a new one if it does not exist, and places an item on the cleanup stack to close it.
+     *
+     * @param              aWriteStream    On return, an open write stream
+     * @param              aStreamUid      The UID of the stream to open or create
+     */
+    void OpenWriteStreamLC(RWriteStream& aWriteStream, TUid aStreamUid);
+    
+    /**
+     * Tests if the specified stream identified exists in the store.
+     *
+     * @param              aStreamUid The stream UID
+     * @return             Non-zero if the stream exists, otherwise EFalse.
+     */
+    TBool IsStreamPresentL(TUid aStreamUid) const;
+    
+private:
+	CSconSyncRelationship( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId );
+	void ConstructL();
+	
+private:
+    
+	CDictionaryFileStore* iDictionaryStore;
+	RFs&   iFs;
+	TUid   iID;
+	TSmlDataProviderId iProviderId;
+    };
+
+#endif /*SCONSYNCRELATIONSHIP_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncserver.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconSyncServer header
+*
+*/
+
+
+#ifndef __SCONSYNCSERVER_H__
+#define __SCONSYNCSERVER_H__
+
+#include <e32base.h>
+
+class CSconSyncServer : public CPolicyServer
+{
+public:
+    static CSconSyncServer* NewL();
+    static CSconSyncServer* NewLC();      
+    virtual ~CSconSyncServer();
+    
+    void AddSession();
+    void RemoveSession();
+
+private:
+    CSconSyncServer();
+    void ConstructL();
+
+    CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+    TInt RunError(TInt aError);
+
+private:
+    TInt iSessionCount;
+
+};
+
+#endif // __SCONSYNCSERVER_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncsession.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconSyncSession header
+*
+*/
+
+
+#ifndef __SCONSYNCSESSION_H__
+#define __SCONSYNCSESSION_H__
+
+#include <e32base.h>
+
+
+class CSconSyncServer;
+class CSconAsyncHandler;
+
+class CSconSyncSession : public CSession2
+    {
+public:
+    static CSconSyncSession* NewL();
+    
+    void CreateL();
+    
+private:
+    CSconSyncSession();
+    ~CSconSyncSession();
+    void ConstructL();
+    
+    CSconSyncServer& Server();
+    void ServiceL(const RMessage2& aMessage);
+    
+private:
+    CSconAsyncHandler* iAsyncHandler;
+    };
+
+#endif // __SCONSYNCSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/rom/sconsyncserver.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for SconSyncServer
+*
+*/
+
+#ifndef _SCONSYNCSERVER_IBY_
+#define _SCONSYNCSERVER_IBY_
+
+#include <data_caging_paths_for_iby.hrh>
+
+//file content
+file=ABI_DIR\BUILD_DIR\sconsyncserver.exe		PROGRAMS_DIR\sconsyncserver.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CCSconTimeOut implementation
+*
+*/
+
+#include "cscontimeout.h"
+
+CCSconTimeOut::CCSconTimeOut( MTimeOutObserver& aTimeOutObserver ) :
+    CActive(EPriorityStandard), // Standard priority
+    iTimeOutObserver(aTimeOutObserver)
+    {
+    }
+
+
+CCSconTimeOut* CCSconTimeOut::NewL( MTimeOutObserver& aTimeOutObserver )
+    {
+    CCSconTimeOut* self = new (ELeave) CCSconTimeOut( aTimeOutObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CCSconTimeOut::ConstructL()
+    {
+    User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
+    CActiveScheduler::Add(this); // Add to scheduler
+    }
+
+CCSconTimeOut::~CCSconTimeOut()
+    {
+    Cancel(); // Cancel any request, if outstanding
+    iTimer.Close(); // Destroy the RTimer object
+    // Delete instance variables if any
+    }
+
+void CCSconTimeOut::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+void CCSconTimeOut::Start(TTimeIntervalMicroSeconds32 aDelay)
+    {
+    Cancel(); // Cancel any request, just to be sure
+    iState = EUninitialized;
+    iTimer.After(iStatus, aDelay); // Set for later
+    SetActive(); // Tell scheduler a request is active
+    }
+
+void CCSconTimeOut::RunL()
+    {
+    /*if (iState == EUninitialized)
+        {
+        // Do something the first time RunL() is called
+        iState = EInitialized;
+        }
+    else if (iState != EError)
+        {
+        // Do something
+        }
+    iTimer.After(iStatus, 1000000); // Set for 1 sec later
+    SetActive(); // Tell scheduler a request is active*/
+    if ( iState == KErrNone )
+        {
+        iTimeOutObserver.TimeOut();
+        }
+    
+    }
+
+TInt CCSconTimeOut::RunError(TInt aError)
+    {
+    return aError;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/src/sconasynchandler.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1179 @@
+/*
+* 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:  CSconAsyncHandler implementation
+*
+*/
+
+
+#include "sconasynchandler.h"
+
+#include <ecom/ecom.h>
+#include <SmlDataProvider.h>
+#include <s32mem.h>
+#include <nsmlchangefinder.h>
+#include <e32cmn.h>
+#include <ecom/ImplementationInformation.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+
+#include "sconsyncclientserver.h"
+#include "sconsyncrelationship.h"
+#include "scondataproviderinfo.h"
+#include "debug.h"
+#include "logdatastoreformat.h"
+
+// Data Store interface implementation Uid.
+// Load all plugins with this uid.
+const TUid KDSEcomIFUid = {0x101F4D3A};
+
+const TInt KDefaultExpandSize = 1024;
+
+// one store per computer, max store count.
+const TInt KMaxStoresCount = 10;
+
+const TInt KDefaultTimeOutInMicroSeconds = 30 * 1000000; // 30 seconds
+const TInt KDeleteAllTimeOutInMicroSeconds = 300 * 1000000; // 5 minutes
+const TInt KOpenStoreTimeOutInMicroSeconds = 180 * 1000000; // 180 seconds
+
+CSconAsyncHandler::~CSconAsyncHandler()
+    {
+    TRACE_FUNC_ENTRY;
+    Cancel();
+    DoCloseStore();
+    delete iItems;
+    delete iWriteData;
+    delete iDataStore;
+    delete iDataProvider;
+    delete iContext;
+    delete iStoreFormat;
+    iStringPool.Close();
+    iFs.Close();
+    REComSession::FinalClose();
+    iChunk.Close();
+    delete iTimeOut;
+    TRACE_FUNC_EXIT;
+    }
+
+CSconAsyncHandler::CSconAsyncHandler(): CActive( EPriorityStandard )
+    {
+    TRACE_FUNC;
+    CActiveScheduler::Add( this );
+    }
+
+CSconAsyncHandler* CSconAsyncHandler::NewL()
+    {
+    TRACE_FUNC;
+    CSconAsyncHandler* self = new(ELeave) CSconAsyncHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CSconAsyncHandler::ConstructL()
+    {
+    TRACE_FUNC;
+    User::LeaveIfError( iFs.Connect() );
+    TInt err = iFs.CreatePrivatePath( EDriveC );
+    LOGGER_WRITE_1("CreatePrivatePath err: %d", err);
+    iStringPool.OpenL();
+    iTimeOut = CCSconTimeOut::NewL( *this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSconAsyncHandler::HandleServiceL()
+// Handles the client request
+// -----------------------------------------------------------------------------
+//
+void CSconAsyncHandler::HandleServiceL( const RMessage2& aMessage )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aMessage.Function() == ECancelRequest )
+        {
+        LOGGER_WRITE("ECancelRequest");
+        if ( IsActive() )
+            {
+            Cancel();
+            LOGGER_WRITE("iMessage.Complete( KErrCancel )");
+            CompleteRequest( KErrCancel );
+            }
+        
+        LOGGER_WRITE("aMessage.Complete( KErrNone )");
+        aMessage.Complete( KErrNone );
+        TRACE_FUNC_EXIT;
+        return;
+        }
+    
+    iTimeOut->Start( KDefaultTimeOutInMicroSeconds );
+    
+    iMessage = aMessage;
+    switch ( aMessage.Function() )
+        {
+        case ESendChunkHandle:
+            LOGGER_WRITE( "CSconSyncSession::ServiceL() : ESendChunkHandle" );
+            HandleChunkMessage();
+            break;
+            
+        case EListImplementations:
+            LOGGER_WRITE( "CSconSyncSession::ServiceL() : EListImplementations" );
+            ListAllImplementationsL();
+            break;
+            
+        case EOpenStore:
+            LOGGER_WRITE( "CSconSyncSession::ServiceL() : EOpenStore" );
+            iTimeOut->Start( KOpenStoreTimeOutInMicroSeconds );
+            OpenStoreL();
+            break;
+            
+        case EOpenItem:
+            OpenItemL();
+            break;
+        case ECreateItem:
+            CreateItemL();
+            break;
+        case EReplaceItem:
+            ReplaceItemL();
+            break;
+        case EMoveItem:
+            MoveItemL();
+            break;
+        case EDeleteItem:
+            DeleteItemL();
+            break;
+        case ESoftDeleteItem:
+            SoftDeleteItemL();
+            break;
+        case EDeleteAllItems:
+            iTimeOut->Start( KDeleteAllTimeOutInMicroSeconds );
+            DeleteAllItemsL();
+            break;
+        case EReadParent:
+            ReadParentL();
+            break;
+            
+        case EHasHistory:
+            HasHistoryL();
+            break;
+        case EAddedItems:
+            AddedItemsL();
+            break;
+        case EDeletedItems:
+            DeletedItemsL();
+            break;
+        case ESoftDeletedItems:
+            SoftDeletedItemsL();
+            break;
+        case EModifiedItems:
+            ModifiedItemsL();
+            break;
+        case EMovedItems:
+            MovedItemsL();
+            break;
+        case EResetChangeInfo:
+            ResetChangeInfoL();
+            break;
+        case ECommitChangeInfo:
+            CommitChangeInfoL();
+            break;
+        case ECloseStore:
+            CloseStore();
+            break;
+        case ESetSyncTimeStamp:
+            SetSyncTimeStampL();
+            break;
+        case EGetSyncTimeStamp:
+            GetSyncTimeStampL();
+            break;
+        case EExportStoreFormat:
+            ExportStoreFormatL();
+            break;
+        case ESetRemoteStoreFormat:
+            SetRemoteStoreFormatL();
+            break;
+            
+        default:
+            aMessage.Complete(KErrNotSupported);
+            break;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconAsyncHandler::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("iStatus.Int(): %d", iStatus.Int());
+    switch ( iMessage.Function() )
+        {
+        case EOpenStore:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EOpenStore" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case EOpenItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EOpenItem" );
+            OpenItemCompletedL( iStatus.Int() );
+            break;
+            
+        case ECreateItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECreateItem" );
+            if (!iCommitInProgress)
+                {
+                // Write data to item
+                CreateItemCompletedL( iStatus.Int() );
+                }
+            else
+                {
+                // commit is done, all ready
+                LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECreateItem, commit done" );
+                TPckg<TSmlDbItemUid> pckg(iNewItem);
+                iMessage.WriteL( 0, pckg, 0);
+                CompleteRequest( iStatus.Int() );
+                }
+            break;
+            
+        case EReplaceItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReplaceItem" );
+            if (!iCommitInProgress)
+                {
+                // Write data to item
+                ReplaceItemCompletedL( iStatus.Int() );
+                }
+            else
+                {
+                // commit is done, all ready
+                LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReplaceItem, commit done" );
+                CompleteRequest( iStatus.Int() );
+                }
+            break;
+            
+        case EMoveItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EMoveItem" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case EDeleteItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EDeleteItem" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case ESoftDeleteItem:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : ESoftDeleteItem" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case EDeleteAllItems:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EDeleteAllItems" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case EReadParent:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReadParent" );
+            ReadParentCompletedL( iStatus.Int() );
+            break;
+            
+        case EResetChangeInfo:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : EResetChangeInfo" );
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        case ECommitChangeInfo:
+            LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECommitChangeInfo" );
+            delete iItems;
+            iItems = NULL;
+            CompleteRequest( iStatus.Int() );
+            break;
+            
+        default:
+            LOGGER_WRITE("Not asynchronous function")
+            CompleteRequest( KErrNotSupported );
+            break;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+TInt CSconAsyncHandler::RunError(TInt aError)
+    {
+    LOGGER_WRITE_1("CSconAsyncHandler::RunError() aError: %d", aError);
+    delete iItems;
+    iItems = NULL;
+    delete iWriteData;
+    iWriteData = NULL;
+    
+    if ( IsActive() )
+        {
+        LOGGER_WRITE("IsActive");
+        //iDataStore->CancelRequest();
+        Cancel();
+        }
+    
+    if ( iDataStore && iMessage.Function() == EOpenItem )
+        {
+        LOGGER_WRITE( "CSconAsyncHandler::RunError() : EOpenItem" );
+        iDataStore->CloseItem();
+        }
+    
+    CompleteRequest( aError );
+    aError = KErrNone;
+    LOGGER_WRITE_1("CSconAsyncHandler::RunError() : Return %d", aError);
+    return aError;
+    //return KErrNone;//aError;
+    }
+
+void CSconAsyncHandler::DoCancel()
+    {
+    TRACE_FUNC_ENTRY;
+    iDataStore->CancelRequest();
+    iTimeOut->Cancel();
+    
+    if ( iStatus == KRequestPending )
+        {
+        LOGGER_WRITE( "iStatus == KRequestPending" );
+        }
+    
+    if ( iDataStore && iMessage.Function() == EOpenItem )
+        {
+        LOGGER_WRITE( "CSconAsyncHandler::RunError() : EOpenItem" );
+        iDataStore->CloseItem();
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::TimeOut()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( IsActive() )
+        {
+        Cancel();
+        CompleteRequest( KErrCancel );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconAsyncHandler::HandleChunkMessage()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt ret ( KErrNone );
+    
+    ret = iChunk.Open( iMessage, 0, EFalse );
+        
+    LOGGER_WRITE_1( "CSconAsyncHandler::HandleChunkMessageL() : ret %d", ret );
+    CompleteRequest( ret );
+    }
+
+
+
+void CSconAsyncHandler::ListAllImplementationsL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    RImplInfoPtrArray implInfoArray;
+    CleanupResetAndDestroyPushL( implInfoArray );
+    REComSession::ListImplementationsL( KDSEcomIFUid, implInfoArray );
+    
+    const TInt KDataproviderInfoSize = 250; // 250 bytes should be enought
+    TInt requiredSize = implInfoArray.Count() * KDataproviderInfoSize;
+    if ( iChunk.Size() < requiredSize )
+        {
+        User::LeaveIfError( iChunk.Adjust( requiredSize ) );
+        }
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    
+    RSconDataProviderInfoArray dpInfoArray;
+    CleanupResetAndDestroyPushL( dpInfoArray );
+    
+    // Collect information from dataproviders
+    for ( TInt i=0; i < implInfoArray.Count(); i++ )
+        {
+        LOGGER_WRITE_1("implInfoArray: %d",i);
+        CImplementationInformation& implInfo = *implInfoArray[i];
+        
+        CSmlDataProvider* dp(NULL);
+        TRAPD( err, dp = CSmlDataProvider::NewL( implInfo.ImplementationUid().iUid ) );
+        LOGGER_WRITE_2("CSmlDataProvider::NewL, uid(0x%08x) err: %d",implInfo.ImplementationUid().iUid, err );
+        if ( !err )
+            {
+            CleanupStack::PushL( dp );
+            
+            CSconDataproviderInfo *dpInfo = CSconDataproviderInfo::NewL();
+            CleanupStack::PushL( dpInfo );
+            
+            dpInfo->SetImplementationUid( implInfo.ImplementationUid() );
+            LOGGER_WRITE_1("ImplementationUid: 0x%08x", implInfo.ImplementationUid().iUid );
+            dpInfo->SetDisplayNameL( implInfo.DisplayName() );
+            LOGGER_WRITE_1("DisplayName: %S", &implInfo.DisplayName() );
+            
+            dpInfo->SetDefaultStoreL( dp->DefaultStoreL() );
+            LOGGER_WRITE_1("DefaultStoreL: %S", &dp->DefaultStoreL() );
+            CDesCArray* stores = dp->ListStoresLC();
+            dpInfo->SetStoresL( *stores );
+            CleanupStack::PopAndDestroy( stores );
+            
+            dpInfoArray.AppendL( dpInfo );
+            CleanupStack::Pop( dpInfo );
+            
+            CleanupStack::PopAndDestroy( dp );
+            }
+        }
+    
+    // Wrtie to stream
+    stream.WriteUint16L( dpInfoArray.Count() );
+    for ( TInt i = 0; i < dpInfoArray.Count(); i++ )
+        {
+        CSconDataproviderInfo& dpInfo = *dpInfoArray[i];
+        dpInfo.ExternalizeL( stream );
+        }
+    
+    stream.CommitL();
+    
+    CleanupStack::PopAndDestroy( &dpInfoArray );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( &implInfoArray );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::OpenStoreL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iDataStore )
+        {
+        LOGGER_WRITE("Warning: Previous DataStore was not closed properly.");
+        DoCloseStore();
+        }
+    
+    // copy data from the chunk
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    TSmlDataProviderId providerId = readStream.ReadUint32L();
+    LOGGER_WRITE_1("providerId: 0x%08x", providerId);
+    
+    TInt len = readStream.ReadUint32L();
+    HBufC* storeName = HBufC::NewLC(len);
+    TPtr storeNamePtr = storeName->Des();
+    readStream.ReadL(storeNamePtr, len);
+    LOGGER_WRITE_1("storeName: %S", &storeNamePtr);
+    
+    TInt contextUid = readStream.ReadUint32L();
+    
+    LOGGER_WRITE_1("contextIdentifier: 0x%08x", contextUid);
+    
+    LOGGER_WRITE("Open provider");
+    delete iDataProvider;
+    iDataProvider = NULL;
+    iDataProvider = CSmlDataProvider::NewL( providerId );
+    
+    delete iContext;
+    iContext = NULL;
+    
+    delete iStoreFormat;
+    iStoreFormat = NULL;
+
+    LOGGER_WRITE("Create context");
+    iContext = CSconSyncRelationship::NewL( iFs, TUid::Uid(contextUid), providerId );
+    
+    
+    LOGGER_WRITE("Create NewStoreInstanceLC");
+    iDataStore = iDataProvider->NewStoreInstanceLC();
+    CleanupStack::Pop( iDataStore );
+    
+    SetActive();
+    iStatus = KRequestPending;
+    LOGGER_WRITE("OpenL");
+    TRAPD(err, iDataStore->OpenL(storeNamePtr,*iContext, iStatus));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->OpenL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    
+    CleanupStack::PopAndDestroy( storeName );
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconAsyncHandler::OpenItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    if ( IsActive() )
+        {
+        LOGGER_WRITE("Was still in Active");
+        Cancel();
+        }
+    
+    TSmlDbItemUid itemUid = iMessage.Int0();
+    LOGGER_WRITE_1("Open item: %d", itemUid);
+    
+    // set default values
+    iFieldChange = EFalse;
+    iSize = 0;
+    iParent = 0;
+    iMimeType.Copy(KNullDesC);
+    iMimeVer.Copy(KNullDesC);
+    
+    SetActive();
+    LOGGER_WRITE("iDataStore->OpenItemL");
+    iStatus = KRequestPending;
+    TRAPD( err, iDataStore->OpenItemL(itemUid,iFieldChange,iSize,iParent,iMimeType,iMimeVer,iStatus));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->OpenItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::OpenItemCompletedL( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    // item opened, now read it
+    if ( aError )
+        {
+        CompleteRequest( aError );
+        return;
+        }
+    LeaveIfNoInstanceL();
+    
+    LOGGER_WRITE_1("item size: %d", iSize);
+    
+    TInt totalObjectSize( 0 );
+    totalObjectSize+= sizeof(TInt32);   // data length
+    totalObjectSize+= iSize;            // data
+    totalObjectSize+= sizeof(TInt8);    // iFieldChange
+    totalObjectSize+= sizeof(TInt32);   // iParent
+    totalObjectSize+= sizeof(TInt32);   // iMimeType
+    totalObjectSize+= iMimeType.Length();  // iMimeType
+    totalObjectSize+= sizeof(TInt32);   // iMimeVer
+    totalObjectSize+= iMimeVer.Length();  // iMimeType
+    
+    LOGGER_WRITE_1("iChunk.Size(): %d", iChunk.Size());
+    LOGGER_WRITE_1("iChunk.MaxSize(): %d", iChunk.MaxSize());
+    LOGGER_WRITE_1("totalObjectSize: %d", totalObjectSize);
+    
+    if ( iChunk.Size() < totalObjectSize )
+        {
+        LOGGER_WRITE("adjust chunk");
+        TInt err = iChunk.Adjust( totalObjectSize );
+        LOGGER_WRITE_1("Chunk.Adjust err: %d", err);
+        User::LeaveIfError( err );
+        }
+    LOGGER_WRITE_1("new Chunk size: %d", iChunk.Size());
+    LOGGER_WRITE_1("new ChunkMaxSize(): %d", iChunk.MaxSize());
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    
+    LOGGER_WRITE("ReadItemL");
+    HBufC8* tempBuf = HBufC8::NewLC(iSize);
+    TPtr8 tempPtr = tempBuf->Des();
+    
+    TUint8* ptr = (TUint8*) tempPtr.Ptr();
+    
+    TPtr8 tempPtr2( ptr, 0, iSize );
+    LOGGER_WRITE_1( "tempPtr2.Size(): %d", tempPtr2.Size());
+    iDataStore->ReadItemL( tempPtr2 );
+    LOGGER_WRITE("ReadItemL -ok");
+    
+    LOGGER_WRITE_1("readed Length: %d", tempPtr2.Length() );
+    LOGGER_WRITE_1("readed Size: %d", tempPtr2.Size() );
+    
+    LOGGER_WRITE8_1("iMimeType: %S", &iMimeType );
+    LOGGER_WRITE_1("iMimeType.Length(): %d", iMimeType.Length() );
+    LOGGER_WRITE_1("iMimeType Size: %d", iMimeType.Size() );
+    
+    LOGGER_WRITE8_1("iMimeVer: %S", &iMimeVer );
+    LOGGER_WRITE_1("iMimeVer.Length(): %d", iMimeVer.Length() );
+    LOGGER_WRITE_1("iMimeVer Size: %d", iMimeVer.Size() );
+    
+    iDataStore->CloseItem();
+    LOGGER_WRITE("Write to chunk");
+    stream.WriteInt32L( tempPtr2.Length() );
+    stream.WriteL( tempPtr2 );
+    CleanupStack::PopAndDestroy( tempBuf );
+    
+    stream.WriteInt8L( (TInt)iFieldChange );
+    stream.WriteInt32L( iParent );
+    stream.WriteInt32L( iMimeType.Length() );
+    stream.WriteL( iMimeType );
+    stream.WriteInt32L( iMimeVer.Length() );
+    stream.WriteL( iMimeVer );
+    
+    stream.CommitL();
+    LOGGER_WRITE("Writed ok");
+    CleanupStack::PopAndDestroy( &stream );
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CreateItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    iCommitInProgress = EFalse;
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    TSmlDbItemUid parent = readStream.ReadUint32L();
+    TInt len = readStream.ReadUint32L();
+    readStream.ReadL(iMimeType, len);
+    len = readStream.ReadUint32L();
+    readStream.ReadL(iMimeVer, len);
+    len = readStream.ReadUint32L();
+    delete iWriteData;
+    iWriteData = NULL;
+    iWriteData = HBufC8::New(len);
+    TPtr8 dataPtr = iWriteData->Des();
+    readStream.ReadL(dataPtr, len);
+    CleanupStack::PopAndDestroy( &readStream );
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->CreateItemL( iNewItem, dataPtr.Size(), parent, iMimeType, iMimeVer, iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->CreateItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CreateItemCompletedL( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( aError );
+    LeaveIfNoInstanceL();
+    // CreateItem completed, now we must write the data to the created item and commit it.
+    
+    iDataStore->WriteItemL( iWriteData->Des() );
+    delete iWriteData;
+    iWriteData = NULL;
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->CommitItemL( iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    iCommitInProgress = ETrue;
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ReplaceItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    
+    iCommitInProgress = EFalse;
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    TSmlDbItemUid uid = readStream.ReadUint32L();
+    TSmlDbItemUid parent = readStream.ReadUint32L();
+    TBool fieldChange = readStream.ReadUint8L();
+    TInt len = readStream.ReadUint32L();
+    delete iWriteData;
+    iWriteData = NULL;
+    iWriteData = HBufC8::New(len);
+    TPtr8 dataPtr = iWriteData->Des();
+    readStream.ReadL(dataPtr, len);
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err,iDataStore->ReplaceItemL( uid,dataPtr.Size(),parent,fieldChange, iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ReplaceItemCompletedL( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    User::LeaveIfError( aError );
+    LeaveIfNoInstanceL();
+    // CreateItem completed, now we must write the data to the created item and commit it.
+    
+    iDataStore->WriteItemL( iWriteData->Des() );
+    delete iWriteData;
+    iWriteData = NULL;
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->CommitItemL( iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    iCommitInProgress = ETrue;
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::MoveItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    TSmlDbItemUid uid = iMessage.Int0();
+    TSmlDbItemUid newParent = iMessage.Int1();
+    LOGGER_WRITE_1( "uid: %d", uid );
+    LOGGER_WRITE_1( "newParent: %d", newParent );
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->MoveItemL( uid, newParent, iStatus )); 
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->MoveItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::DeleteItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    
+    TSmlDbItemUid uid = iMessage.Int0();
+    LOGGER_WRITE_1( "uid: %d", uid );
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->DeleteItemL( uid, iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->DeleteItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::SoftDeleteItemL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    
+    TSmlDbItemUid uid = iMessage.Int0();
+    LOGGER_WRITE_1( "uid: %d", uid );
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->SoftDeleteItemL( uid, iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->SoftDeleteItemL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::DeleteAllItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->DeleteAllItemsL( iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->DeleteAllItemsL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ReadParentL()
+    {
+    TRACE_FUNC_ENTRY;
+    OpenItemL();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ReadParentCompletedL( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    // item opened, now read it
+    if ( aError )
+        {
+        CompleteRequest( aError );
+        return;
+        }
+    LeaveIfNoInstanceL();
+    
+    iDataStore->CloseItem();
+    
+    TPckg<TSmlDbItemUid> pckg(iParent);
+    iMessage.WriteL( 1, pckg, 0);
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::HasHistoryL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    TBool hasHistory = iDataStore->HasSyncHistory();
+    
+    TPckgC<TBool> pckg(hasHistory);
+    iMessage.WriteL( 0, pckg, 0);
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::AddedItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    const MSmlDataItemUidSet& items = iDataStore->AddedItems();
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    items.ExternalizeL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::DeletedItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    const MSmlDataItemUidSet& items = iDataStore->DeletedItems();
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    items.ExternalizeL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::SoftDeletedItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    const MSmlDataItemUidSet& items = iDataStore->SoftDeletedItems();
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    items.ExternalizeL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ModifiedItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    const MSmlDataItemUidSet& items = iDataStore->ModifiedItems();
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    items.ExternalizeL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::MovedItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    const MSmlDataItemUidSet& items = iDataStore->MovedItems();
+    
+    RMemWriteStream stream ( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( stream );
+    items.ExternalizeL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ResetChangeInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->ResetChangeInfoL( iStatus ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->ResetChangeInfoL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CommitChangeInfoL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    if ( iItems )
+        {
+        delete iItems;
+        iItems = NULL;
+        }
+    iItems = new (ELeave) CNSmlDataItemUidSet();
+    iItems->InternalizeL( readStream );
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    SetActive();
+    iStatus = KRequestPending;
+    TRAPD(err, iDataStore->CommitChangeInfoL( iStatus, *iItems ));
+    if ( err )
+        {
+        // we are on active state, call request completed (RunL)
+        LOGGER_WRITE_1("iDataStore->CommitChangeInfoL leaved with err: %d", err);
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, err );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CloseStore()
+    {
+    TRACE_FUNC_ENTRY;
+    DoCloseStore();
+    REComSession::FinalClose();
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::SetSyncTimeStampL()
+    {
+    TRACE_FUNC_ENTRY;
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    TInt relationId = readStream.ReadInt32L();
+    TInt providerId = readStream.ReadInt32L();
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    CSconSyncRelationship::SetTimeStampL( iFs, TUid::Uid(relationId), providerId);
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::GetSyncTimeStampL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt providerId = iMessage.Int0();
+    TInt relationId = iMessage.Int1();
+        
+    TDateTime time;
+    CSconSyncRelationship::GetTimeStampL( iFs, TUid::Uid(relationId), providerId, time);
+    
+    // write timestamp
+    TPckgC<TDateTime> timeBuf(time);
+    iMessage.WriteL( 2, timeBuf, 0);
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::ExportStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    if ( !iDataProvider )
+        {
+        User::Leave( KErrNotReady );
+        }
+    CBufFlat* buffer = CBufFlat::NewL( KDefaultExpandSize );
+    CleanupStack::PushL( buffer );
+    RBufWriteStream stream( *buffer );
+    CleanupClosePushL( stream );
+    
+    const CSmlDataStoreFormat& storeFormat = iDataProvider->StoreFormatL();
+    TRAP_IGNORE( TLogDataStoreFormat::LogDataStoreFormatL( _L("iDataProvider->StoreFormatL()"), storeFormat ));
+    
+    storeFormat.ExternalizeL( stream );
+    
+    stream.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+    buffer->Compress();
+    
+    RMemWriteStream chunkStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( chunkStream );
+    
+    chunkStream.WriteInt32L( buffer->Size() );
+    chunkStream.WriteL( buffer->Ptr(0), buffer->Size());
+    chunkStream.CommitL();
+    CleanupStack::PopAndDestroy( &chunkStream );
+    
+    CleanupStack::PopAndDestroy( buffer );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::SetRemoteStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+    LeaveIfNoInstanceL();
+    
+    RMemReadStream readStream( iChunk.Base(), iChunk.Size() );
+    CleanupClosePushL( readStream );
+    
+    if ( iStoreFormat )
+        {
+        delete iStoreFormat;
+        iStoreFormat = NULL;
+        }
+    iStoreFormat = CSmlDataStoreFormat::NewLC( iStringPool, readStream);
+    CleanupStack::Pop( iStoreFormat );
+    TRAP_IGNORE( TLogDataStoreFormat::LogDataStoreFormatL( _L("iDataProvider->SetRemoteStoreFormatL()"), *iStoreFormat ));
+    iDataStore->SetRemoteStoreFormatL( *iStoreFormat );
+    
+    CleanupStack::PopAndDestroy( &readStream );
+    
+    CompleteRequest( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::LeaveIfNoInstanceL()
+    {
+    if ( !iDataStore )
+        {
+        LOGGER_WRITE("DataStore instance was not ready, leaving KErrNotReady");
+        User::Leave( KErrNotReady );
+        }
+    }
+
+void CSconAsyncHandler::DoCloseStore()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iItems;
+    iItems = NULL;
+    delete iWriteData;
+    iWriteData = NULL;
+    if ( iDataProvider && iContext )
+        {
+        TInt providerId = iDataProvider->Identifier();
+        TInt contextId = iContext->SyncTaskKey();
+        TRAP_IGNORE( CSconSyncRelationship::SetTimeStampL( iFs, TUid::Uid(contextId), providerId) );
+        }
+    delete iDataStore;
+    iDataStore = NULL;
+    delete iDataProvider;
+    iDataProvider = NULL;
+    delete iContext;
+    iContext = NULL;
+    delete iStoreFormat;
+    iStoreFormat = NULL;
+    
+    CleanOldStoresL();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CleanOldStoresL()
+    {
+    TRACE_FUNC_ENTRY;
+    TFileName path;
+    User::LeaveIfError( iFs.PrivatePath( path ) );
+    CDir* dir;
+    iFs.GetDir( path, KEntryAttNormal, ESortByDate, dir );
+    CleanupStack::PushL( dir );
+    TInt storesCount(0);
+    LOGGER_WRITE_1("count: %d", dir->Count() );
+    for ( TInt i=dir->Count()-1; i >= 0; i-- )
+        {
+        LOGGER_WRITE_1("dir[%d]", i);
+        TEntry entry = (*dir)[i];
+        LOGGER_WRITE_1("file: %S", &entry.iName);
+        _LIT(KContextStoreName, "contextstore");
+        _LIT(KTimeStoreName, "timestore");
+        if ( entry.iName.Find(KContextStoreName) == 0 )
+            {
+            storesCount++;
+            LOGGER_WRITE_1("storeNro: %d", storesCount);
+#ifdef _DEBUG
+            TTime time = entry.iModified;
+            TDateTime dt = time.DateTime();
+            _LIT(KFormat, "%d.%d %02d:%02d");
+            TFileName mod;
+            mod.Format(KFormat, dt.Day()+1, dt.Month()+1, dt.Hour()+1,dt.Minute() );
+            LOGGER_WRITE_1("time: %S", &mod);
+#endif
+            if ( storesCount > KMaxStoresCount )
+                {
+                LOGGER_WRITE_1("delete contextstore: '%S'", &entry.iName );
+                iFs.Delete( entry.iName );
+                TFileName timeStoreFile;
+                timeStoreFile = entry.iName.Right(15);
+                timeStoreFile.Insert(0, KTimeStoreName);
+                LOGGER_WRITE_1("delete timeStoreFile: %S", &timeStoreFile);
+                iFs.Delete( timeStoreFile );
+                }
+            }
+        
+        }
+    CleanupStack::PopAndDestroy( dir );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconAsyncHandler::CompleteRequest( TInt aError )
+    {
+    TRACE_FUNC;
+    iTimeOut->Cancel();
+    LOGGER_WRITE_1("iMessage.Complete( %d )", aError);
+    iMessage.Complete( aError );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncrelationship.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,181 @@
+/*
+* 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:  CSconSyncRelationship implementation
+*
+*/
+
+
+#include "sconsyncrelationship.h"
+#include <s32file.h>
+#include <nsmlchangefinder.h>
+
+#include "debug.h"
+
+_LIT(KContextStore, "contextstore_0x%08x.dat");
+_LIT(KTimeStore, "timestore_0x%08x.dat");
+
+CSconSyncRelationship::~CSconSyncRelationship()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iDictionaryStore )
+        {
+        iDictionaryStore->Commit();
+        delete iDictionaryStore;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+CSconSyncRelationship::CSconSyncRelationship( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId )
+    : iFs(aFs), iID(aRelationUid), iProviderId(aProviderId)
+    {
+    TRACE_FUNC;
+    
+    }
+
+CSconSyncRelationship* CSconSyncRelationship::NewL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId )
+    {
+    TRACE_FUNC_ENTRY;
+    CSconSyncRelationship* self = new (ELeave) CSconSyncRelationship( aFs, aRelationUid, aProviderId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+void CSconSyncRelationship::SetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aRelationUid: 0x%08x", aRelationUid.iUid );
+    LOGGER_WRITE_1("aId: 0x%08x", aId );
+    aFs.SetSessionToPrivate( EDriveC );
+    TFileName file;
+    file.Format(KTimeStore, aRelationUid.iUid);
+    CDictionaryFileStore* dictionaryStore = CDictionaryFileStore::OpenLC(aFs, file, TUid::Uid(0x0001));
+    
+    RDictionaryWriteStream stream;
+    stream.AssignLC( *dictionaryStore, TUid::Uid(aId) );
+    
+    TTime time;
+    time.UniversalTime();
+    
+    TDateTime dateTime = time.DateTime();
+    TPckgBuf<TDateTime> timeBuf(dateTime);
+    
+    stream.WriteL( timeBuf );
+    stream.CommitL();
+    
+    CleanupStack::PopAndDestroy( &stream ); //AssingLC
+    dictionaryStore->Commit();
+    CleanupStack::PopAndDestroy( dictionaryStore );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncRelationship::GetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId, TDateTime& aTimeStamp )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aRelationUid: 0x%08x", aRelationUid.iUid );
+    LOGGER_WRITE_1("aId: 0x%08x", aId );
+    User::LeaveIfError( aFs.SetSessionToPrivate( EDriveC ) );
+    TFileName file;
+    file.Format(KTimeStore, aRelationUid.iUid);
+    CDictionaryFileStore* dictionaryStore = CDictionaryFileStore::OpenLC(aFs, file, TUid::Uid(0x0001));
+    TBool present = dictionaryStore->IsPresentL( TUid::Uid(aId) );
+    if ( !present )
+        {
+        LOGGER_WRITE("Stream was not present");
+        User::Leave(KErrNotFound);
+        }
+    RDictionaryReadStream stream;
+    stream.OpenLC( *dictionaryStore, TUid::Uid(aId) );
+    TPckgBuf<TDateTime> timeBuf;
+    stream.ReadL( timeBuf );
+    aTimeStamp = timeBuf();
+    CleanupStack::PopAndDestroy(); //OpenLC
+    CleanupStack::PopAndDestroy( dictionaryStore );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncRelationship::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iFs.SetSessionToPrivate( EDriveC );
+    TFileName file;
+    file.Format(KContextStore, iID.iUid);
+    iDictionaryStore = CDictionaryFileStore::OpenL(
+            iFs, file, TUid::Uid(0x0001));
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+TSmlSyncTaskKey CSconSyncRelationship::SyncTaskKey() const
+    {
+    TRACE_FUNC;
+    return static_cast<TSmlSyncTaskKey>(iID.iUid);
+    }
+
+void CSconSyncRelationship::OpenReadStreamLC(RReadStream& aReadStream, TUid aStreamUid)
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid);
+    TUid streamUid(aStreamUid);
+    if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID )
+        {
+        LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId);
+        streamUid.iUid = iProviderId;
+        }
+    if ( !IsStreamPresentL( streamUid ) )
+        {
+        LOGGER_WRITE("Stream was not present");
+        User::Leave(KErrNotFound);
+        }
+    
+        
+    static_cast<RDictionaryReadStream&>(aReadStream).OpenLC(
+        *iDictionaryStore, streamUid );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncRelationship::OpenWriteStreamLC(RWriteStream& aWriteStream, TUid aStreamUid)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid);
+    TUid streamUid(aStreamUid);
+    if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID )
+        {
+        LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId);
+        streamUid.iUid = iProviderId;
+        }
+    static_cast<RDictionaryWriteStream&>(aWriteStream).AssignLC(
+                 *iDictionaryStore, streamUid );
+    TRACE_FUNC_EXIT;
+    }
+
+TBool CSconSyncRelationship::IsStreamPresentL(TUid aStreamUid) const
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid.iUid );
+    TUid streamUid(aStreamUid);
+    if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID )
+        {
+        LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId);
+        streamUid.iUid = iProviderId;
+        }
+    TBool present = iDictionaryStore->IsPresentL( streamUid );
+    LOGGER_WRITE_1("CSconSyncRelationship::IsStreamPresentL() return: %d",(TInt)present);
+    return present;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncserver.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,177 @@
+/*
+* 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:  CSconSyncServer implementation
+*
+*/
+
+
+#include "sconsyncserver.h"
+#include "sconsyncclientserver.h"
+
+#include "sconsyncsession.h"
+#include "debug.h"
+
+const TInt KSConPCConnServerUid = 0x101F99F6;
+
+// Security policy
+const TUint KServerPolicyRangeCount = 2;
+
+const TInt KServerPolicyRanges[KServerPolicyRangeCount] =
+    {
+    0,              // range is 0 inclusive
+    EMaxService     // range is 1-KMaxTInt inclusive
+    };
+
+const TUint8 KServerPolicyElementsIndex[KServerPolicyRangeCount] =
+    {
+    0,                              // applies to 0th range
+    CPolicyServer::ENotSupported    // applies to 1st range
+    };
+
+const CPolicyServer::TPolicyElement KServerPolicyElements[] =
+    {
+    { _INIT_SECURITY_POLICY_S0(KSConPCConnServerUid) /*_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData)*/, CPolicyServer::EFailClient }
+    };
+
+const CPolicyServer::TPolicy KServerPolicy =
+    {
+    0 /*CPolicyServer::EAlwaysPass*/, // specifies all connect attempts should pass
+    KServerPolicyRangeCount,                   
+    KServerPolicyRanges,
+    KServerPolicyElementsIndex,
+    KServerPolicyElements
+    };
+
+
+CSconSyncServer* CSconSyncServer::NewL()
+    {
+    CSconSyncServer* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CSconSyncServer* CSconSyncServer::NewLC()
+    {
+    CSconSyncServer* self = new(ELeave) CSconSyncServer();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CSconSyncServer::CSconSyncServer() : 
+    CPolicyServer(EPriorityStandard, KServerPolicy, ESharableSessions)
+    {
+    }
+
+void CSconSyncServer::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt error = Start(KSconSyncServerName);
+
+    if (error != KErrNone)
+        {
+        User::Panic(KSconSyncServerName, error);
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+CSconSyncServer::~CSconSyncServer()
+    {
+    TRACE_FUNC;
+    }
+
+CSession2* CSconSyncServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
+    {
+    TRACE_FUNC;
+    TVersion v(1,0,0);
+    if ( !User::QueryVersionSupported(v,aVersion) )
+        {
+        TVersionName vname = aVersion.Name();
+        LOGGER_WRITE_1("Client has wrong version: %S", &vname);
+        User::Leave( KErrNotSupported );
+        }
+    
+    return CSconSyncSession::NewL();
+    }
+
+TInt CSconSyncServer::RunError(TInt aError)
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError);
+    // Bad descriptor implies bad client
+    if (aError == KErrBadDescriptor)
+        {
+        Message().Panic(KSconSyncServerName, aError);
+        }
+    else
+        {
+        Message().Complete(aError);
+        }
+
+    // Continue handling requests
+    ReStart();
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    }
+
+void CSconSyncServer::AddSession()
+    {
+    ++iSessionCount;
+    LOGGER_WRITE_1("CSconSyncServer::AddSession(), iSessionCount: %d", iSessionCount);
+    }
+
+void CSconSyncServer::RemoveSession()
+    {
+    --iSessionCount;
+    LOGGER_WRITE_1("CSconSyncServer::RemoveSession(), iSessionCount: %d", iSessionCount);
+    if (iSessionCount == 0)
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+
+LOCAL_C void ExeMainL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Install active scheduler
+    CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+    CleanupStack::PushL(scheduler);
+    CActiveScheduler::Install(scheduler);
+
+    CSconSyncServer::NewLC();
+
+    User::LeaveIfError(User::RenameThread(KSconSyncServerName));
+    RProcess::Rendezvous(KErrNone);
+
+    CActiveScheduler::Start();
+
+    CleanupStack::PopAndDestroy();  // CSconSyncServer
+    CleanupStack::PopAndDestroy();  // CActiveScheduler
+    TRACE_FUNC_EXIT;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    TRACE_FUNC_ENTRY;
+    __UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    
+    TRAPD(error, ExeMainL());
+    __ASSERT_ALWAYS(!error, User::Panic(KSconSyncServerName, error));
+
+    delete cleanup;
+    __UHEAP_MARKEND;
+    TRACE_FUNC_EXIT;
+    return 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncsession.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconSyncSession implementation
+*
+*/
+
+
+#include "sconsyncsession.h"
+
+#include "sconsyncserver.h"
+#include "sconsyncclientserver.h"
+#include "sconasynchandler.h"
+#include "debug.h"
+
+
+CSconSyncSession::CSconSyncSession() 
+    {
+    TRACE_FUNC;
+    }
+
+CSconSyncSession* CSconSyncSession::NewL()
+    {
+    TRACE_FUNC;
+    CSconSyncSession* self = new(ELeave) CSconSyncSession();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CSconSyncSession::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iAsyncHandler = CSconAsyncHandler::NewL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncSession::CreateL()
+    {
+    TRACE_FUNC;
+    Server().AddSession();
+    }
+
+CSconSyncSession::~CSconSyncSession()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iAsyncHandler;
+    
+    Server().RemoveSession();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+CSconSyncServer& CSconSyncSession::Server()
+    {
+    return *static_cast<CSconSyncServer*>(const_cast<CServer2*>(CSession2::Server()));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSconSyncSession::ServiceL()
+// Handles the client request
+// -----------------------------------------------------------------------------
+//
+void CSconSyncSession::ServiceL(const RMessage2& aMessage)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TRAPD( err, iAsyncHandler->HandleServiceL( aMessage ));
+    if ( err )
+        {
+        LOGGER_WRITE_1("iAsyncHandler->HandleServiceL leaved: %d", err);
+        if ( iAsyncHandler->IsActive() )
+            {
+            LOGGER_WRITE(" and it was active -> Cancel it");
+            iAsyncHandler->Cancel();
+            }
+        // do server error processing
+        User::Leave( err );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
Binary file connectivitymodules/SeCon/services/csc/bld/101F99F6.xml has changed
--- a/connectivitymodules/SeCon/services/csc/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/csc/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -22,17 +22,12 @@
 DEFAULT
 
 PRJ_EXPORTS
-./101f9698.xml  /epoc32/data/z/private/101f99f6/capability/101f9698.xml
-./fwdcomp.xml   /epoc32/data/z/private/101f99f6/capability/fwdcomp.xml
-./101f99f6.xml  /epoc32/data/z/private/101f99f6/capability/101f99f6.xml
-
-./101f9698.xml  /epoc32/release/winscw/udeb/z/private/101f99f6/capability/101f9698.xml
-./fwdcomp.xml   /epoc32/release/winscw/udeb/z/private/101f99f6/capability/fwdcomp.xml
-./101f99f6.xml  /epoc32/release/winscw/udeb/z/private/101f99f6/capability/101f99f6.xml
+../rom/sconcsc.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(sconcsc.iby)
+./101f9698.xml      Z:/private/101F99F6/capability/101f9698.xml
+./fwdcomp.xml       Z:/private/101F99F6/capability/fwdcomp.xml
+./101f99f6.xml      Z:/private/101F99F6/capability/101f99f6.xml
 
 
 PRJ_MMPFILES
-
 sconcsc.mmp
 
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/csc/rom/sconcsc.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* 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:  Image description file for project SConCSC
+*
+*/
+
+
+#ifndef __SCONCSC_IBY__
+#define __SCONCSC_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconcsc.dll              SHARED_LIB_DIR\sconcsc.dll
+data=ZPRIVATE\101F99F6\capability\101F9698.xml  PRIVATE\101F99F6\capability\101F9698.xml
+data=ZPRIVATE\101F99F6\capability\fwdcomp.xml   PRIVATE\101F99F6\capability\fwdcomp.xml
+data=ZPRIVATE\101F99F6\capability\101F99F6.xml  PRIVATE\101F99F6\capability\101F99F6.xml
+#endif
--- a/connectivitymodules/SeCon/services/csc/src/caplist.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/csc/src/caplist.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -34,12 +34,10 @@
 //
 CCapList* CCapList::NewL()
     {
-    TRACE_FUNC_ENTRY;
     CCapList* self = new(ELeave) CCapList();
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self );
-    TRACE_FUNC_EXIT;
     return self;
     }
 
@@ -50,9 +48,7 @@
 //
 CCapList::~CCapList()
     {
-    TRACE_FUNC_ENTRY;
     delete iList;
-    TRACE_FUNC_EXIT;
     }
 
 // -----------------------------------------------------------------------------
@@ -71,9 +67,7 @@
 //
 void CCapList::ConstructL()
     {
-    TRACE_FUNC_ENTRY;
     iList = CStringList::NewL();
-    TRACE_FUNC_EXIT;
     }
 
 // -----------------------------------------------------------------------------
@@ -94,7 +88,6 @@
 //
 TInt CCapList::FindFromMark(TInt aId, TInt aType)
     {
-    TRACE_FUNC_ENTRY;
     TInt mark = List()->Mark();
     TInt count= List()->Count();
     
@@ -106,7 +99,6 @@
     TInt index=Find(aId, aType, mark);
     if ( index == KErrNotFound )
         {
-        LOGGER_WRITE_1( "CCapList::FindFromMark(TInt aId, TInt aType) returned : %d", KErrNotFound );
         return KErrNotFound;
         }
         
@@ -114,7 +106,6 @@
     __ASSERT_DEBUG(index>=mark, CapUtil::Panic(KErrGeneral));
 
     List()->SetMark(index+1);
-    LOGGER_WRITE_1( "CCapList::FindFromMark(TInt aId, TInt aType) returned : %d", index );
     return index;
     }
 
--- a/connectivitymodules/SeCon/services/csc/src/caputils.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/csc/src/caputils.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -198,12 +198,23 @@
         mobilePhone.GetCurrentNetwork( 
             status, mobilePhoneNetworkInfoPckg, mobilePhoneLocationArea );
         User::WaitForRequest( status );
-        User::LeaveIfError( status.Int() );     
+        User::LeaveIfError( status.Int() );
         }
     
     CleanupStack::PopAndDestroy( &mobilePhone );
     CleanupStack::PopAndDestroy( &server );
-    StrCopy( aLongName, mobilePhoneNetworkInfo.iLongName );
+    if ( mobilePhoneNetworkInfo.iLongName.Length() > 0 )
+        {
+        StrCopy( aLongName, mobilePhoneNetworkInfo.iLongName );
+        }
+    else if ( mobilePhoneNetworkInfo.iShortName.Length() > 0 )
+        {
+        StrCopy( aLongName, mobilePhoneNetworkInfo.iShortName );
+        }
+    else
+        {
+        StrCopy( aLongName, mobilePhoneNetworkInfo.iDisplayTag );
+        }
     StrCopy( aCountryCode, mobilePhoneNetworkInfo.iCountryCode );
     StrCopy( aNetworkID, mobilePhoneNetworkInfo.iNetworkId );
     
--- a/connectivitymodules/SeCon/services/csc/src/stringlist.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/csc/src/stringlist.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -33,10 +33,8 @@
 //
 CStringList* CStringList::NewL()
     {
-    TRACE_FUNC_ENTRY;
     CStringList* self = CStringList::NewLC();
     CleanupStack::Pop( self );
-    TRACE_FUNC_EXIT;
     return self;
     }
 
@@ -47,11 +45,9 @@
 //
 CStringList* CStringList::NewLC()
     {
-    TRACE_FUNC_ENTRY;
     CStringList* self = new ( ELeave ) CStringList();
     CleanupStack::PushL( self );
     self->ConstructL();
-    TRACE_FUNC_EXIT;
     return self;
     }
 
@@ -62,7 +58,6 @@
 //
 CStringList::CStringList()
     {
-    TRACE_FUNC;
     }
 
 // -----------------------------------------------------------------------------
@@ -72,10 +67,8 @@
 //
 CStringList::~CStringList()
     {
-    TRACE_FUNC_ENTRY;
     delete iLines;
     iLines = NULL;
-    TRACE_FUNC_EXIT;
     }
 
 // -----------------------------------------------------------------------------
@@ -85,11 +78,9 @@
 //
 void CStringList::ConstructL()
     {
-    TRACE_FUNC_ENTRY;
     const TInt KDefaultArrayGranularity = 10;
     iLines = new (ELeave) CDesCArrayFlat(KDefaultArrayGranularity);
     SetMark(0);
-    TRACE_FUNC_EXIT;
     }
 
 // -----------------------------------------------------------------------------
--- a/connectivitymodules/SeCon/services/ftp/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/ftp/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -21,7 +21,9 @@
 DEFAULT
 
 PRJ_EXPORTS
-../loc/sconftp.loc  MW_LAYER_LOC_EXPORT_PATH(sconftp.loc)
+../rom/sconftp.iby              CORE_APP_LAYER_IBY_EXPORT_PATH(sconftp.iby)
+../rom/sconftpresources.iby     LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(sconftpresources.iby)
+../loc/sconftp.loc              APP_LAYER_LOC_EXPORT_PATH(sconftp.loc)
 
 PRJ_MMPFILES
 ../bld/sconftp.mmp
--- a/connectivitymodules/SeCon/services/ftp/inc/sconconsts.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconconsts.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -19,7 +19,11 @@
 #ifndef _SCONCONSTS_H_
 #define _SCONCONSTS_H_
 
+// Define this to show C-drive logs folder to user
+#define SCON_SHOW_LOGS_FOLDER
+
 _LIT( K_C_ROOT, "C:\\" );
+_LIT( KSConLogsPath, "logs\\" );     // logs folder
 
 // Following folders on MMC are exluded from folder listing
 _LIT( KSConResource, "resource\\" ); // resource folder on MMC
--- a/connectivitymodules/SeCon/services/ftp/inc/sconftp.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/ftp/inc/sconftp.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -234,6 +234,8 @@
         */
         void UpdateDriveTypeInfoL();
         
+        void CreateObexBufObjectL( CObexBufObject*& aObject, CBufFlat*& aBuffer );
+        
         CSConFTP();
         virtual void ConstructL();
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/rom/sconftp.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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: Image description file for CSConFTP
+*
+*/
+
+
+#ifndef __SCONFTP_IBY__
+#define __SCONFTP_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconftp.dll              SHARED_LIB_DIR\sconftp.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/ftp/rom/sconftpresources.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for SConFTP resources.
+*
+*/
+
+#ifndef __SCONFTP_RESOURCE_IBY__
+#define __SCONFTP_RESOURCE_IBY__
+
+data=DATAZ_\RESOURCE_FILES_DIR\sconftp.rsc	RESOURCE_FILES_DIR\sconftp.rsc
+
+#endif
\ No newline at end of file
--- a/connectivitymodules/SeCon/services/ftp/src/sconfshandler.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/ftp/src/sconfshandler.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1454,6 +1454,13 @@
             // C:\\Data is visible, not exluded
             exluded = EFalse;
             }
+#ifdef SCON_SHOW_LOGS_FOLDER
+        else if ( aFullPath.FindF( KSConLogsPath ) == KDriveLength )
+            {
+            // C:\\Logs is visible, not exluded
+            exluded = EFalse;
+            }
+#endif
         else {
             // other paths on C-drive are exluded
             LOGGER_WRITE_1("CSConFsHandler::IsExludedPath() Path '%S' is not visible to user", &aFullPath);
--- a/connectivitymodules/SeCon/services/ftp/src/sconftp.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/ftp/src/sconftp.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -378,21 +378,7 @@
 
             if( ret == KErrNone )
                 {
-                delete aObject;
-                aObject = CObexBufObject::NewL( NULL );
-                        
-                if( aBuffer )
-                    {
-                    aBuffer->Reset();
-                    delete aBuffer;
-                    }
-                
-                aBuffer = CBufFlat::NewL( KSConBufferSize );
-                aBuffer->ResizeL( KSConBufferSize );
-                
-                TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName, 
-                CObexBufObject::EDoubleBuffering );
-                aObject->SetDataBufL( bufferdetails );
+                CreateObexBufObjectL( aObject, aBuffer );
                 }
             }
         else
@@ -432,21 +418,7 @@
     
     if( ret == KErrNone )
         {
-        delete aObject;
-        aObject = CObexBufObject::NewL( NULL );
-                
-        if( aBuffer )
-            {
-            aBuffer->Reset();
-            delete aBuffer;
-            }
-        
-        aBuffer = CBufFlat::NewL( KSConBufferSize );
-        aBuffer->ResizeL( KSConBufferSize );
-        
-        TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName, 
-        CObexBufObject::EDoubleBuffering );
-        aObject->SetDataBufL( bufferdetails );
+        CreateObexBufObjectL( aObject, aBuffer );
         
         if( lowMemory )
             {
@@ -460,6 +432,31 @@
     return ret;
     }
 
+void CSConFTP::CreateObexBufObjectL( CObexBufObject*& aObject, CBufFlat*& aBuffer )
+    {
+    delete aObject;
+    aObject = NULL;
+    aObject = CObexBufObject::NewL( NULL );
+    
+    delete aBuffer;
+    aBuffer = NULL;
+    
+    aBuffer = CBufFlat::NewL( KSConBufferSize );
+    aBuffer->ResizeL( KSConBufferSize );
+    
+    TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName, 
+                    CObexBufObject::EDoubleBuffering );
+    TRAPD( err, aObject->SetDataBufL( bufferdetails ));
+    if ( err == KErrNoMemory )
+        {
+        LOGGER_WRITE( "KErrNoMemory, Using singe buffer strategy");
+        // If fails, use singe buffer strategy to save RAM
+        TObexFilenameBackedBuffer lowMemBufferdetails( *aBuffer, iTempFileName, 
+                    CObexBufObject::ESingleBuffering );
+        aObject->SetDataBufL( lowMemBufferdetails );
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject )
 // Stores the relayed file object to inbox or file system.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/bwins/sconoviaccounthandleru.def	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateCSconOviAccountHandlerL@@YAPAVCSconOviAccountHandler@@XZ @ 1 NONAME ; class CSconOviAccountHandler * CreateCSconOviAccountHandlerL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/eabi/sconoviaccounthandleru.def	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z29CreateCSconOviAccountHandlerLv @ 1 NONAME
+	_ZTI22CSconOviAccountHandler @ 2 NONAME ; #<TI>#
+	_ZTV22CSconOviAccountHandler @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SconOviAccountHandler bld.inf file
+*
+*/
+
+
+PRJ_PLATFORMS  
+DEFAULT
+
+PRJ_EXPORTS
+../rom/sconoviaccounthandler.iby      CORE_APP_LAYER_IBY_EXPORT_PATH(sconoviaccounthandler.iby)
+
+PRJ_MMPFILES
+sconoviaccounthandler.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/group/sconoviaccounthandler.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  sconoviaccounthandler mmp file
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <non_foundation_paths.hrh>
+#include <data_caging_paths.hrh>
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+TARGETPATH      sys/bin
+
+TARGET          sconoviaccounthandler.dll
+TARGETTYPE      DLL
+DEFFILE         sconoviaccounthandler.def
+UID             0x10009D8D 0x2001A97A
+
+SOURCEPATH      ../src
+SOURCE          sconoviaccounthandler.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// System include paths
+APP_LAYER_SYSTEMINCLUDE
+NON_FOUNDATION_MW_LAYER_SYSTEMINCLUDE
+
+DEBUGLIBRARY	flogger.lib
+LIBRARY         euser.lib
+LIBRARY         wsaccountmanager.lib
+LIBRARY         estor.lib // For RWriteStream
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/inc/sconoviaccounthandler.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* 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:  CSconOviAccountHandler header file
+*
+*/
+
+
+#ifndef _SCONOVIACCOUNTHANDLER_H_
+#define _SCONOVIACCOUNTHANDLER_H_
+
+#include <e32base.h>
+#include <s32strm.h>
+
+_LIT(KSconOviAccountHandlerDllName, "sconoviaccounthandler.dll");
+const TUid KSconOviAccountHandlerDllUid={0x10009D8D};
+
+class CWSOviAccountManager;
+
+/**
+ * CSconOviAccountHandler provides Ovi account information.
+ * Dynamically loadable dll.
+ */
+class CSconOviAccountHandler : public CBase
+{
+    public:
+    static CSconOviAccountHandler* NewL();
+    ~CSconOviAccountHandler();
+    
+    /**
+     * Reads account information from device
+     * @param aAccountInfoStream stream where to export account details.
+     * @leave KErrNotFound if account information does not exist.
+     */
+    virtual void GetOviAccountDetailsL( RWriteStream& aAccountInfoStream );
+    
+    private:
+    void ConstructL();
+    
+    private: // Data
+    CWSOviAccountManager* iOviAccountManager;
+    
+};
+
+IMPORT_C CSconOviAccountHandler* CreateCSconOviAccountHandlerL();
+typedef CSconOviAccountHandler* (*TSConCreateCSconOviAccountHandlerFunc) (); 
+
+#endif // _SCONOVIACCOUNTHANDLER_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/rom/sconoviaccounthandler.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Image description file for SConOviAccountHandler.
+*
+*/
+
+
+#ifndef _SCONOVIACCOUNTHANDLER_IBY_
+#define _SCONOVIACCOUNTHANDLER_IBY_
+
+file=ABI_DIR\BUILD_DIR\sconoviaccounthandler.dll		SHARED_LIB_DIR\sconoviaccounthandler.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/oviaccounthandler/src/sconoviaccounthandler.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconOviAccountHandler implementation
+*
+*/
+
+
+#include "sconoviaccounthandler.h"
+#include <wsoviaccountmanager.h>
+#include "debug.h"
+
+// Constants
+_LIT8( KUserId, "#UserID: " );
+_LIT8( KFirstName, "\n#FirstName: " );
+_LIT8( KLastName, "\n#LastName: " );
+_LIT8( KEmail, "\n#Email: " );
+_LIT8( KEmailVerified, "\n#EmailVerified: " );
+_LIT8( KMobile, "\n#Mobile: " );
+_LIT8( KMobileVerified, "\n#MobileVerified: " );
+
+
+
+// -----------------------------------------------------------------------------
+// CreateCSconOviAccountHandlerL()
+// Entry to CSconOviAccountHandler
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSconOviAccountHandler* CreateCSconOviAccountHandlerL()
+    {
+    TRACE_FUNC;
+    return CSconOviAccountHandler::NewL();
+    }
+
+CSconOviAccountHandler* CSconOviAccountHandler::NewL()
+    {
+    TRACE_FUNC;
+    CSconOviAccountHandler* self = new (ELeave) CSconOviAccountHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+CSconOviAccountHandler::~CSconOviAccountHandler()
+    {
+    TRACE_FUNC;
+    delete iOviAccountManager;
+    }
+
+void CSconOviAccountHandler::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iOviAccountManager = CWSOviAccountManager::NewL();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// GetOviAccountDetailsL()
+// Reads account info and prints details to aAccountInfoStream
+// -----------------------------------------------------------------------------
+//
+void CSconOviAccountHandler::GetOviAccountDetailsL( RWriteStream& aAccountInfoStream )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // not owned
+    CWSAccount* account = iOviAccountManager->Account();
+    if ( !account )
+        {
+        // Account information not found.
+        LOGGER_WRITE("Account information not found, leaving KErrNotFound");
+        User::Leave( KErrNotFound );
+        }
+    
+    // Write userId
+    const TDesC8& userId = account->UserId();
+    aAccountInfoStream.WriteL( KUserId );
+    aAccountInfoStream.WriteL( userId );
+    
+    // Write first name
+    HBufC8* temp = account->AccountItemL( KWSAccAttrAccountFirstName );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KFirstName );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+    
+    // Write last name
+    temp = account->AccountItemL( KWSAccAttrAccountLastName );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KLastName );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+    
+    // Write email
+    temp = account->AccountItemL( KWSAccAttrAccountEmail );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KEmail );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+    
+    // Write email verified (true/false)
+    temp = account->AccountItemL( KWSAccAttrAccountEmailVerified );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KEmailVerified );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+    
+    // Write mobile number
+    temp = account->AccountItemL( KWSAccAttrAccountMobile );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KMobile );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+    
+    // Write mobile verified
+    temp = account->AccountItemL( KWSAccAttrAccountMobileVerified );
+    if ( temp )
+        {
+        aAccountInfoStream.WriteL( KMobileVerified );
+        aAccountInfoStream.WriteL( temp->Des() );
+        delete temp;
+        temp = NULL;
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
--- a/connectivitymodules/SeCon/services/pcd/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -23,7 +23,8 @@
 DEFAULT 
 
 PRJ_EXPORTS
-./sbeconfig.xml /epoc32/data/z/private/10202d56/sbeconfig.xml
+../rom/sconpcd.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(sconpcd.iby)
+./sbeconfig.xml     Z:/private/10202d56/sbeconfig.xml
 
 PRJ_MMPFILES
 sconpcd.mmp
--- a/connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -51,6 +51,7 @@
 SOURCE          sconpcdutility.cpp
 SOURCE          sconmetadata.cpp
 SOURCE          sconvideoparser.cpp
+SOURCE          sconsynchandler.cpp
 SOURCE          cscontimeout.cpp
 
 SOURCEPATH      ../../../common/conmltask/src
@@ -59,6 +60,7 @@
 USERINCLUDE     ../inc
 USERINCLUDE     ../../../inc
 USERINCLUDE     ../../../common/conmltask/inc
+USERINCLUDE     ../../../clients/syncclient/inc
 
 // Default system include paths
 APP_LAYER_SYSTEMINCLUDE
@@ -84,5 +86,12 @@
 LIBRARY         imageconversion.lib         // for CImageEncoder
 LIBRARY         mmfcontrollerframework.lib  // for CMMFMetaDataEntry
 LIBRARY         bafl.lib                    // for BaflUtils
+
+LIBRARY         ecom.lib
+LIBRARY         estor.lib // CDictionaryFileStore
+LIBRARY         sconsyncclient.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY	        centralrepository.lib
+LIBRARY         sif.lib
 DEBUGLIBRARY    flogger.lib
 // End of file
--- a/connectivitymodules/SeCon/services/pcd/inc/sconbackuprestore.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconbackuprestore.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -37,13 +37,12 @@
 		/**
 		 * Two-phase constructor
 		 * @param aQueue The address of CSConBackupRestoreQueue
-		 * @param aMaxObjectSize Max object size
 		 * @param aFs aReference to RFs connection.
     	 * @return CSConBackupRestore instance
 		 */
 		static CSConBackupRestore* NewL( 
 			CSConBackupRestoreQueue* aQueue, 
-			const TInt aMaxObjectSize, RFs& aFs );
+			RFs& aFs );
 		/**
 		 * Destructor
 		 * @return none
@@ -84,10 +83,9 @@
 		CSConBackupRestore( CSConBackupRestoreQueue* aQueue, RFs& aFs );
 		/**
 		 * Initializes member data
-		 * @param aMaxObjectSize Max object size
 		 * @return none
 		 */
-		void ConstructL( const TInt aMaxObjectSize );
+		void ConstructL();
 		/**
 		 * Implementation of CActive::DoCancel()
 		 * @return none
@@ -103,7 +101,6 @@
 		CSConBackupRestoreQueue*		iQueue; 
 		CSConSBEClient*					iSBEClient;
 		TInt							iCurrentTask;
-		TInt							iMaxObjectSize;
 		TBool							iBackupRestoreActive;
 		RFs&                            iFs;
 	};
--- a/connectivitymodules/SeCon/services/pcd/inc/sconbrqueue.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconbrqueue.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* 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"
@@ -31,11 +31,10 @@
 	public:
 		/**
 		 * Two-phase constructor
-		 * @param aMaxObjectSize Max object size
 		 * @param aFs aReference to RFs connection.
 		 * @return CSConBackupRestoreQueue instance
 		 */
-		static CSConBackupRestoreQueue* NewL( const TInt aMaxObjectSize, RFs& aFs );
+		static CSConBackupRestoreQueue* NewL( RFs& aFs );
 		/**
 		 * Destructor
 		 * @return CSConBackupRestoreQueue instance
@@ -82,11 +81,10 @@
 		CSConBackupRestoreQueue();
 		/**
 		 * Initializes member data
-		 * @param aMaxObjectSize Max object size
 		 * @param aFs aReference to RFs connection.
 		 * @return none
 		 */
-		void ConstructL( const TInt aMaxObjectSize, RFs& aFs );
+		void ConstructL( RFs& aFs );
 		/**
 		 * Polls queue
 		 * @return none
--- a/connectivitymodules/SeCon/services/pcd/inc/sconinstaller.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconinstaller.h	Tue Jul 06 14:06:02 2010 +0300
@@ -23,7 +23,7 @@
 
 #include <e32base.h>
 #include <e32cons.h>
-#include <SWInstApi.h>
+#include <usif/sif/sif.h>
 
 #include "sconinstqueue.h"
 
@@ -35,12 +35,12 @@
 NONSHARABLE_CLASS ( CSConAppInstaller ): public CActive
 	{
 	public:
-		/**
-		 * Constructor
-		 * @param aQueue The address of CSConInstallerQueu
-    	 * @return none
-		 */
-		CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs );
+        /**
+         * Constructor
+         * @param aQueue The address of CSConInstallerQueu
+         * @return none
+         */
+        static CSConAppInstaller* NewL( CSConInstallerQueue* aQueue, RFs& aFs );
 		
 		/**
 		 * Destructor
@@ -68,6 +68,14 @@
 		
 	private:
 		/**
+         * Constructor
+         * @param aQueue The address of CSConInstallerQueu
+         * @return none
+         */
+        CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs );
+        
+		void ConstructL();
+		/**
 		 * Implementation of CActive::DoCancel()
 		 * @return none
 		 */
@@ -77,21 +85,33 @@
 		 * @return none
 		 */
 		void RunL();
+		
+		void WriteTaskDataL( CSConTask& aTask );
+		
+		void ExternalizeResultArrayIntValL( const TDesC& aName, RWriteStream& aStream );
+		void ExternalizeResultIntValL( const TDesC& aName, RWriteStream& aStream );
+		void ExternalizeResultStringValL( const TDesC& aName, RWriteStream& aStream );
 		/**
 		 * Executes ListInstalledApps task
 		 * @return none
 		 */
 		void ProcessListInstalledAppsL();
 		/**
-		 * Execures UnInstall task
+         * Executes Install task
+         * @param CSConInstall install params
+         * @return none
+         */
+        void ProcessInstallL( const CSConInstall& aInstallParams );
+		/**
+		 * Executes UnInstall task
 		 * @param CSConUninstall uninstall params
     	 * @return none
 		 */
 		void ProcessUninstallL( const CSConUninstall& aUninstallParams );
 		
-		void UninstallSisL( const CSConUninstall& aUninstallParams );
-		void UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode );
-		void UninstallWidget( const TUid& aUid, const TSConInstallMode aMode );
+		//void UninstallSisL( const CSConUninstall& aUninstallParams );
+		//void UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode );
+		//void UninstallWidget( const TUid& aUid, const TSConInstallMode aMode );
 		void DeleteFile( const TDesC& aPath );
 		
 	private:
@@ -106,11 +126,14 @@
 	        ESilentCustomUnistalling,
 	        EListingInstalledApps
 	        };
-	    TInstallerState                 iInstallerState;
+	    //TInstallerState                 iInstallerState;
 		CSConInstallerQueue*			iQueue; // Not owned
-		SwiUI::RSWInstLauncher			iSWInst;
-		SwiUI::TInstallOptions          iOptions;
-        SwiUI::TInstallOptionsPckg      iOptionsPckg;   
+		//SwiUI::RSWInstLauncher			iSWInst;
+		//SwiUI::TInstallOptions          iOptions;
+        //SwiUI::TInstallOptionsPckg      iOptionsPckg;   
+		Usif::RSoftwareInstall          iSwInstaller;
+		Usif::COpaqueNamedParams*       iSifOptions;
+		Usif::COpaqueNamedParams*       iSifResults;
 		TInt							iCurrentTask;
 		RFs&                            iFs;
 	};
--- a/connectivitymodules/SeCon/services/pcd/inc/sconinstqueue.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconinstqueue.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* 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"
--- a/connectivitymodules/SeCon/services/pcd/inc/sconpcd.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcd.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -23,11 +23,13 @@
 
 #include <e32base.h>
 #include <e32cons.h>
+#include <s32strm.h>
 
 #include "sconconmltask.h"
 
 class CSConInstallerQueue;
 class CSConBackupRestoreQueue;
+class CSconSyncHandler;
 
 enum TSConLastConMLOperation
     {
@@ -68,6 +70,9 @@
          * @return none
          */
         virtual void ResetPCD();
+        
+        virtual void HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize );
+        virtual void HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aResult );
     
     private:        
         /**
@@ -120,12 +125,6 @@
          * @return none
          */
         TInt UpdateDeviceInfoL( TInt aMaxObjectSize );
-        /**
-         * Gets the current max object size
-         * @param aClientObjectSize The object size of the client
-         * @return the max object size
-         */
-        TInt GetMaxObjectSize( TInt aClientObjectSize ) const;
         
         /**
          * Stores a reply
@@ -150,9 +149,9 @@
         CSConBackupRestoreQueue*    iBackupRestoreQueue;
         CSConStatusReply*           iLatestReply;
         TInt                        iTaskNumber;
-        TInt                        iMaxObjectSize;
         TSConLastConMLOperation     iLastOperation;
         RFs                         iFs;
+        CSconSyncHandler*           iSyncHandler;
     }; 
     
     IMPORT_C CSConPCD* CreateCSConPCDL();
--- a/connectivitymodules/SeCon/services/pcd/inc/sconpcdconsts.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcdconsts.h	Tue Jul 06 14:06:02 2010 +0300
@@ -58,6 +58,22 @@
 const TInt KSConCodeInstErrAccessDenied = 608;  // Target location of package is not accessible
 const TInt KSConCodeInstUpgradeError = 609;  // The package is an invalid upgrade
 
+const TInt KSConCodeInstErrSifMissingBasePackage = 610;
+const TInt KSConCodeInstErrSifOverflow = 611;
+const TInt KSConCodeInstErrSifSameVersionAlreadyInstalled = 612;
+const TInt KSConCodeInstErrSifNewerVersionAlreadyInstalled = 613;
+const TInt KSConCodeInstErrSifAlreadyActivated = 614;
+const TInt KSConCodeInstErrSifAlreadyDeactivated = 615;
+const TInt KSConCodeInstErrSifBadComponentId = 616;
+const TInt KSConCodeInstErrSifBadInstallerConfiguration = 617;
+const TInt KSConCodeInstErrSifPackageCannotBeInstalledOnThisDevice = 618;
+const TInt KSConCodeInstErrSifUnsupportedLanguage = 619;
+const TInt KSConCodeInstErrScrWriteOperationInProgress = 620;
+const TInt KSConCodeInstErrScrReadOperationInProgress = 621;
+const TInt KSConCodeInstErrScrNoActiveTransaction = 622;
+const TInt KSConCodeInstErrScrUnsupportedLocale = 623;
+
+
 // ConML Status code: 1001...1050 System wide error code
 const TInt KSConCodeFirstSymbianErr( 1000 );
 
@@ -83,11 +99,11 @@
 	};
 	
 // Supported ConML version
-_LIT8( KCONMLVERSION, "2.0" );
+_LIT8( KConMLVersion, "2.0" );
 // SIS mime type for installer
-_LIT8( KSISMIMEType, "x-epoc/x-sisx-app" );
+_LIT8( KSisMimeType, "x-epoc/x-sisx-app" );
 // Java mime type for installer
-_LIT8( KMidletMIMEType, "application/java-archive" );
+_LIT8( KMidletMimeType, "application/java-archive" );
 
 #endif
 
--- a/connectivitymodules/SeCon/services/pcd/inc/sconqueue.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconqueue.h	Tue Jul 06 14:06:02 2010 +0300
@@ -64,14 +64,14 @@
 		 * @param aError The task error code
     	 * @return none
 		 */
-		virtual void CompleteTask( TInt aTask, TInt aError );
+		virtual TInt CompleteTask( TInt aTask, TInt aError );
 		/**
 		 * Set the task progress value
 		 * @param aTask The task number
 		 * @param aProgressValue The progress value
     	 * @return none
 		 */
-		virtual void SetTaskProgress( TInt aTask, TInt aProgressValue );
+		virtual TInt SetTaskProgress( TInt aTask, TInt aProgressValue );
 		/**
 		 * Receives a specified task
 		 * @param aTaskId The task number
@@ -82,9 +82,9 @@
 		/**
 		 * Removes a task from the queue
 		 * @param aTask The task number
-    	 * @return none
+    	 * @return KErrNone if no errors, else system wide error codes
 		 */
-		virtual void RemoveTask( TInt aTask );	
+		virtual TInt RemoveTask( TInt aTask );	
 		/**
 		 * Cancels a task
 		 * @param aTask The task number
--- a/connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -33,11 +33,10 @@
     public:
         /**
          * Two-phase constructor
-         * @param aMaxObjectSize Max object size
          * @param aFs aReference to RFs connection.
          * @return CSConSBEClient instance
          */
-        static CSConSBEClient* NewL( const TInt aMaxObjectSize, RFs& aFs );
+        static CSConSBEClient* NewL( RFs& aFs );
         /**
          * Destructor
          * @return none
@@ -96,11 +95,10 @@
     private:
         /**
          * Constructor
-         * @paran aMaxObjectSize Max object size
          * @param aFs aReference to RFs connection.
          * @return none
          */
-        CSConSBEClient( const TInt aMaxObjectSize, RFs& aFs );
+        CSConSBEClient( RFs& aFs );
         
         /**
          * Implementation of CActive::DoCancel()
@@ -138,7 +136,12 @@
          * @return KErrNone if no erros. Else system wide error codes.
          */
         TInt ProcessRequestDataL();
-        /**
+		/**
+		 * Request data to iDataBuffer
+		 * @return none
+		 */
+		void RequestDataL( CSBGenericTransferType& aGenericTransferType );
+		/**
          * Executes GetDataOwnerStatus task
          * @return none
          */
@@ -153,7 +156,7 @@
          * @param aDrive Drive number as TInt
          * @return drive number as TDriveNumber
          */
-        TDriveNumber GetDriveNumber( const TInt& aDrive ) const;
+        TDriveNumber GetDriveNumber( TInt aDrive ) const;
         /**
          * Filters the drive list
          * @param aDriveList Drive list to be filtered
@@ -209,25 +212,20 @@
          * @param TDriveList drives to include
          * @return dataowner data size in specified drives
          */
-        TUint JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const;
-        
-    private:
-        CSBEClient*                     iSBEClient;
-        TRequestStatus*                 iCallerStatus;
-        TBool                           iProcessComplete;
-        TInt                            iProcessIndex;
-        TInt                            iMaxObjectSize;
-        
-        CSConTask*                      iCurrentTask;
-        TInt                            iDataPos;
-        TBool                           iDataLeft;
-        TPtrC8                          iDataPtr;
-        TBool                           iLastChunk;
-        TBool                           iBURModeNormal;
-        TBool                           iRestoreMode;
-        RFs&                            iFs;
-        TBool                           iAllSnapshotsSuppliedCalled;
-    };
+         TUint JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const;
+         
+	private:
+		CSBEClient*						iSBEClient;
+		TRequestStatus* 				iCallerStatus;
+		CSConTask*						iCurrentTask;
+		TBool							iBURModeNormal;
+		TBool                           iRestoreMode;
+		RFs&                            iFs;
+		TBool                           iAllSnapshotsSuppliedCalled;
+		TBool                           iLastChunk;
+		CBufFlat*                       iDataBuffer;
+		TInt                            iDataBufferSize;
+	};
 
 #endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/inc/sconsynchandler.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,138 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSconSyncHandler header
+*
+*/
+
+
+#ifndef SCONSYNCHANDLER_H_
+#define SCONSYNCHANDLER_H_
+
+#include <e32base.h>
+#include <s32file.h>
+#include "sconsyncclient.h"
+
+class RFs;
+class RWriteStream;
+class RReadStream;
+class RFileReadStream;
+
+NONSHARABLE_CLASS( TCreatedItem )
+    {
+public:
+    TInt            iTemporaryId;
+    TInt            iErrorCode;
+    TSmlDbItemUid   iNewUid;
+    };
+
+NONSHARABLE_CLASS( TReplacedItem )
+    {
+public:
+    TSmlDbItemUid   iItemUid;
+    TInt            iErrorCode;
+    };
+
+NONSHARABLE_CLASS( CSconSyncHandler ) : public CActive
+{
+public:
+    static CSconSyncHandler* NewL( RFs& aFs );
+	~CSconSyncHandler();
+	
+	void HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize );
+	void HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aData );
+private:
+	CSconSyncHandler( RFs& aFs );
+	void ConstructL();
+	
+	void ListStoresL( RWriteStream& aResult );
+	void OpenStoreL( const TDesC8& aParams, RWriteStream& aResult );
+	void CloseStoreL( RWriteStream& aResult );
+	
+	void ListChangesL( RWriteStream& aResult );
+	void ResetChangeInfoL( RWriteStream& aResult );
+	void CommitChangesL( const TDesC8& aParams, RWriteStream& aResult );
+	void ReadItemsL( const TDesC8& aParams, RWriteStream& aResult );
+	void GetParentsL( const TDesC8& aParams, RWriteStream& aResult );
+	void CreateItemsL( RReadStream& aData );
+	void GetCreateItemsResponseL( const TDesC8& aParams, RWriteStream& aResult );
+	void ReplaceItemsL( RReadStream& aData );
+	void GetReplaceItemsResponseL( const TDesC8& aParams, RWriteStream& aResult );
+	void MoveItemsL( const TDesC8& aParams, RWriteStream& aResult );
+	void DeleteItemsL( const TDesC8& aParams, RWriteStream& aResult );
+	void SoftDeleteItemsL( const TDesC8& aParams, RWriteStream& aResult );
+	void DeleteAllItemsL( RWriteStream& aResult );
+	void GetDeleteAllItemsStatusL( RWriteStream& aResult );
+	void GetStoreFormatL( RWriteStream& aResult );
+	void SetRemoteStoreFormatL( RReadStream& aData );
+	
+	void CreateNextItemOnStreamL();
+	void ReplaceNextItemOnStreamL();
+	
+	void ReadNextDataBlockL( RWriteStream& aResult );
+	void ReadItemL( TSmlDbItemUid aUid, CBufFlat& aItemData );
+	
+	void LoadRemoteStoreFormatL( TInt aContextId, TInt aProviderId );
+	void SaveRemoteStoreFormatL( CSmlDataStoreFormat& aStoreFormat, TInt aContextId, TInt aProviderId );
+	
+	void CancelOperationsL( RWriteStream& aResult );
+	
+	void Reset();
+	
+	void SetCalendarCenrepL( TInt aProfileId, const TDesC& aServerId );
+	void ClearCalendarCenrepL();
+	
+private: // from CActive
+    void DoCancel();
+    void RunL();
+    TInt RunError( TInt aError );
+	
+private:
+    RFs&                    iFs; // Not owned
+    RSconSyncSession        iSyncSession;
+    TBool                   iConnected;
+    
+    TInt                    iCurrentDataProviderUid;
+    TInt                    iCurrentContextUid;
+    
+    CBufFlat*               iResponseData;
+    
+    enum TSyncStatus
+        {
+        EReady,
+        ECreatingItemsFromFile,
+        EItemsCreated,
+        EReplacingItemsFromFile,
+        EItemsReplaced,
+        EDeletingAllItems
+        };
+    TSyncStatus             iSyncStatus;
+    
+    TInt                    iMaxObjectSize;
+    TInt                    iBytesWrited;
+    TBool                   iHasFileStream;
+    RFileReadStream         iFileStream;
+    TSmlDbItemUid           iCreatedItemUid;
+    TPckg<TSmlDbItemUid>    iCreatedItemUidPckg;
+    TSmlDbItemUid           iTemporaryItemUid;
+    TInt                    iItemsLeftInStream;
+    TInt                    iItemInProgress; // =1 if item is in progress
+    RArray<TCreatedItem>    iCreatedItems;
+    RArray<TReplacedItem>   iReplacedItems;
+    RArray<TSmlDbItemUid>   iItemsToRead;
+    TReplacedItem           iReplacedItem;
+    TFileName               iFileInProgress;
+    TBool                   iCalendarCenrepUsed;
+};
+
+#endif /*SCONSYNCHANDLER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/rom/sconpcd.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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: Image description file for SConPCD.
+*
+*/
+#ifndef __SCONPCD_IBY__
+#define __SCONPCD_IBY__
+//file content
+
+file=ABI_DIR\BUILD_DIR\sconpcd.dll		system\libs\sconpcd.dll
+
+data=ZPRIVATE\10202D56\sbeconfig.xml	PRIVATE\10202D56\sbeconfig.xml
+
+#endif
--- a/connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -36,14 +36,12 @@
 // -----------------------------------------------------------------------------
 //
 CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue,
-                                            const TInt aMaxObjectSize, RFs& aFs )
+                                              RFs& aFs )
     {
-    TRACE_FUNC_ENTRY;
     CSConBackupRestore* self = new (ELeave) CSConBackupRestore( aQueue, aFs );
     CleanupStack::PushL( self );
-    self->ConstructL( aMaxObjectSize );
+    self->ConstructL();
     CleanupStack::Pop( self );
-    TRACE_FUNC_EXIT;
     return self;
     }
 
@@ -55,6 +53,7 @@
 CSConBackupRestore::CSConBackupRestore( CSConBackupRestoreQueue* aQueue, RFs& aFs ) : 
             CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
     {
+    CActiveScheduler::Add( this );
     }
     
 // -----------------------------------------------------------------------------
@@ -62,11 +61,9 @@
 // Initializes member data
 // -----------------------------------------------------------------------------
 //
-void CSConBackupRestore::ConstructL( const TInt aMaxObjectSize )
+void CSConBackupRestore::ConstructL()
     {
-    iMaxObjectSize = aMaxObjectSize;
-    iSBEClient = CSConSBEClient::NewL( aMaxObjectSize, iFs );
-    CActiveScheduler::Add( iSBEClient );
+    iSBEClient = CSConSBEClient::NewL( iFs );
     }   
     
 // -----------------------------------------------------------------------------
@@ -76,18 +73,12 @@
 //
 CSConBackupRestore::~CSConBackupRestore()
     {
-    TRACE_FUNC_ENTRY;
     if( iSBEClient )
         {
-        if( iSBEClient->IsActive() )
-            {
-            iSBEClient->Cancel();
-            }
-        
+        iSBEClient->Cancel();
         delete iSBEClient;
         iSBEClient = NULL;
         }
-    TRACE_FUNC_EXIT;
     }
     
 // -----------------------------------------------------------------------------
@@ -166,21 +157,12 @@
     TRACE_FUNC_ENTRY;
     if( iSBEClient )
         {
-        if( iSBEClient->IsActive() )
-            {
-            iSBEClient->Cancel();
-            }
-        
+        iSBEClient->Cancel();
         delete iSBEClient;
         iSBEClient = NULL;
         }
         
-    TRAPD( err, iSBEClient = CSConSBEClient::NewL( iMaxObjectSize, iFs ) );
-    
-    if( err == KErrNone )
-        {
-        CActiveScheduler::Add( iSBEClient );
-        }
+    TRAP_IGNORE( iSBEClient = CSConSBEClient::NewL( iFs ) );
     
     iBackupRestoreActive = EFalse;
     TRACE_FUNC_EXIT;
@@ -212,11 +194,9 @@
 //          
 void CSConBackupRestore::RunL()
     {
-    TRACE_FUNC_ENTRY;
-    
+    TRACE_FUNC;
     iQueue->CompleteTask( iCurrentTask, iStatus.Int() );
     iBackupRestoreActive = EFalse;
-    TRACE_FUNC_EXIT;
     }
     
 // End of file
--- a/connectivitymodules/SeCon/services/pcd/src/sconbrqueue.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconbrqueue.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -24,15 +24,15 @@
 #include "debug.h"
 
 // -----------------------------------------------------------------------------
-// CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize )
+// CSConBackupRestoreQueue::NewL( RFs& aFs )
 // Two-phase constructor
 // -----------------------------------------------------------------------------
 //
-CSConBackupRestoreQueue* CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize, RFs& aFs )
+CSConBackupRestoreQueue* CSConBackupRestoreQueue::NewL( RFs& aFs )
 	{
 	CSConBackupRestoreQueue* self = new (ELeave) CSConBackupRestoreQueue();
 	CleanupStack::PushL( self );
-	self->ConstructL( aMaxObjectSize, aFs );
+	self->ConstructL( aFs );
 	CleanupStack::Pop( self );
     return self;
 	}
@@ -45,17 +45,17 @@
 CSConBackupRestoreQueue::CSConBackupRestoreQueue() : 
 					CActive( EPriorityStandard )
 	{
+    CActiveScheduler::Add( this );
 	}
 	
 // -----------------------------------------------------------------------------
-// CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize )
+// CSConBackupRestoreQueue::ConstructL( RFs& aFs )
 // Initializes member data
 // -----------------------------------------------------------------------------
 //
-void CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize, RFs& aFs )
+void CSConBackupRestoreQueue::ConstructL( RFs& aFs )
 	{
-	iBackupRestore = CSConBackupRestore::NewL( this, aMaxObjectSize, aFs );
-	CActiveScheduler::Add( iBackupRestore );
+	iBackupRestore = CSConBackupRestore::NewL( this, aFs );
 	User::LeaveIfError( iTimer.CreateLocal() );
 	}
 	
@@ -192,7 +192,7 @@
 	{
 	TRACE_FUNC_ENTRY;
 	CSConTask* task = NULL;
-	CSConTaskQueue::GetTask( aTaskId, task );
+	User::LeaveIfError( CSConTaskQueue::GetTask( aTaskId, task ) );
 	LOGGER_WRITE_1( "CSConBackupRestoreQueue::GetTaskMethodL( TInt aTaskId ) : returned %d",
         task->GetServiceId() );
 	return task->GetServiceId();
--- a/connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -17,30 +17,36 @@
 
 
 // INCLUDE FILES
+#include <s32mem.h> // For RBufWriteStream
+#include <utf.h>  // for CnvUtfConverter
+//#include <pathinfo.h>
+#include <usif/sif/sifcommon.h>
 
-#include <pathinfo.h>
-#include <swi/sisregistryentry.h>
-#include <swi/sisregistrypackage.h>
-#include <swi/sisregistrysession.h>
-#include <SWInstDefs.h>
-#include <mmf/common/mmfcontrollerpluginresolver.h>
-#include <javaregistry.h>
-
-using namespace Java;
+using namespace Usif;
 
 #include "debug.h"
 #include "sconinstaller.h"
 #include "sconpcdconsts.h"
 #include "sconpcdutility.h"
 
-_LIT8( KWidgetMimeType, "application/x-nokia-widget");
 
 const TInt KSConSeConUidValue = 0x101f99f6;
 const TUid KSConSeConUid = {KSConSeConUidValue};
 
+_LIT8(KValSep, "=");
+_LIT8(KComma, ",");
+_LIT8(KLineEnd, "\r\n");
+
 // ============================= MEMBER FUNCTIONS ===============================
 
-
+CSConAppInstaller* CSConAppInstaller::NewL( CSConInstallerQueue* aQueue, RFs& aFs )
+    {
+    CSConAppInstaller* self = new (ELeave) CSConAppInstaller( aQueue, aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
 // -----------------------------------------------------------------------------
 // CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue )
 // Constructor
@@ -49,7 +55,13 @@
 CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs ) :
     CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
     {
-    TRACE_FUNC;
+    CActiveScheduler::Add( this );
+    }
+
+void CSConAppInstaller::ConstructL()
+    {
+    iSifOptions = COpaqueNamedParams::NewL();
+    iSifResults = COpaqueNamedParams::NewL();
     }
 
 // -----------------------------------------------------------------------------
@@ -60,7 +72,10 @@
 CSConAppInstaller::~CSConAppInstaller()
     {
     TRACE_FUNC;
-    iSWInst.Close();
+    Cancel();
+    iSwInstaller.Close();
+    delete iSifOptions;
+    delete iSifResults;
     }
 
 // -----------------------------------------------------------------------------
@@ -79,7 +94,7 @@
     
     if( aTaskId > 0 && ret != KErrNotFound )
         {
-        if ( iInstallerState != EIdle || IsActive() )
+        if ( IsActive() )
             {
             LOGGER_WRITE("WARNING! SConAppInstaller was not on idle state!");
             iQueue->CompleteTask( aTaskId, KErrInUse );
@@ -95,32 +110,24 @@
             {
             case EInstall :
                 iQueue->ChangeQueueProcessStatus();
-                err = iSWInst.Connect();
-                
+                err = iSwInstaller.Connect();
                 if( err == KErrNone )
                     {
-                    if ( task->iInstallParams->iMode == ESilentInstall )
-                    	{
-                    	LOGGER_WRITE( "Begin silent installation.. " );
-                    	iOptions.iUntrusted = SwiUI::EPolicyNotAllowed;
-                        iOptions.iOCSP = SwiUI::EPolicyNotAllowed;
-                        iOptionsPckg = iOptions;
-                        iInstallerState = ESilentInstalling;
-                    	iSWInst.SilentInstall( iStatus, task->iInstallParams->iPath, iOptionsPckg );
-                    	}
-                    else
-                    	{
-                    	LOGGER_WRITE( "Begin to install.. " );
-                    	iInstallerState = EInstalling;
-                        iSWInst.Install( iStatus, task->iInstallParams->iPath );
-                    	}
+                    TRAP(err, ProcessInstallL( *task->iInstallParams ));
+                    if( err != KErrNone )
+                        {
+                        LOGGER_WRITE_1( "StartInstaller ProcessInstallL err: %d", err );
+                        iStatus = KRequestPending;
+                        SetActive();
+                        status = &iStatus;
+                        User::RequestComplete( status, err );
+                        }
                     }
                 
                 break;
             case EUninstall :
                 iQueue->ChangeQueueProcessStatus();
-                err = iSWInst.Connect();
-                
+                err = iSwInstaller.Connect();
                 if( err == KErrNone )
                     {
                     LOGGER_WRITE( "Begin to uninstall.. " );
@@ -129,6 +136,8 @@
                     if( err != KErrNone )
                         {
                         LOGGER_WRITE_1( "StartInstaller ProcessUninstallL err: %d", err );
+                        iStatus = KRequestPending;
+                        SetActive();
                         status = &iStatus;
                         User::RequestComplete( status, err );
                         }
@@ -137,7 +146,8 @@
                 break;
             case EListInstalledApps :
                 iQueue->ChangeQueueProcessStatus();
-                iInstallerState = EListingInstalledApps;
+                iStatus = KRequestPending;
+                SetActive();
                 TRAP( err, ProcessListInstalledAppsL() );
                 status = &iStatus;
                 User::RequestComplete( status, err );
@@ -145,8 +155,6 @@
             default :
                 break;
             }
-
-        SetActive();
         }
     TRACE_FUNC_EXIT;
     }
@@ -163,7 +171,7 @@
     if( iCurrentTask == aTaskId )
         {
         Cancel();
-        iSWInst.Close();
+        iSwInstaller.Close();
         }
     TRACE_FUNC_EXIT;
     }
@@ -175,14 +183,7 @@
 //
 TBool CSConAppInstaller::InstallerActive() const
     {
-    if ( iInstallerState == EIdle )
-        {
-        return EFalse;
-        }
-    else
-        {
-        return ETrue;
-        }
+    return IsActive();
     }
 
 // -----------------------------------------------------------------------------
@@ -194,38 +195,9 @@
     {
     TRACE_FUNC_ENTRY;
     
-    switch (iInstallerState)
-        {
-        case EInstalling:
-            LOGGER_WRITE("Cancel normal install");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestInstall );
-            break;
-        case ESilentInstalling:
-            LOGGER_WRITE("Cancel silent install");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentInstall );
-            break;
-        case EUninstalling:
-            LOGGER_WRITE("Cancel normal uninstall");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestUninstall );
-            break;
-        case ESilentUninstalling:
-            LOGGER_WRITE("Cancel silent uninstall");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );
-            break;
-        case ECustomUninstalling: 
-            LOGGER_WRITE("Cancel custom uninstall");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestCustomUninstall );
-            break;
-        case ESilentCustomUnistalling:
-            LOGGER_WRITE("Cancel silent custom uninstall");
-            iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentCustomUninstall );
-            break;
-        default:
-            LOGGER_WRITE("WARNING! Unknown state");
-            break;
-        }
-    iInstallerState = EIdle;
-    
+    LOGGER_WRITE("Cancel iSwInstaller");
+    iSwInstaller.CancelOperation();
+    /*
     // find and complete current task
     CSConTask* task = NULL;
     TInt ret = iQueue->GetTask( iCurrentTask, task );
@@ -245,6 +217,7 @@
                 break;
             }
         }
+        */
     TRACE_FUNC_EXIT;
     }
 
@@ -256,19 +229,24 @@
 void CSConAppInstaller::RunL()
     {
     TRACE_FUNC_ENTRY;
-    iInstallerState = EIdle;
-    iSWInst.Close();
+    iSwInstaller.Close();
     iQueue->ChangeQueueProcessStatus();
     TInt err( iStatus.Int() );
     LOGGER_WRITE_1( "CSConAppInstaller::RunL() iStatus.Int() : returned %d", err );
     
     CSConTask* task = NULL;
     TInt taskErr = iQueue->GetTask( iCurrentTask, task );
-    
-    LOGGER_WRITE_1( "CSConAppInstaller::RunL() GetTask %d", taskErr );
-        
     if( taskErr == KErrNone )
         {
+        if ( task->GetServiceId() == EInstall || task->GetServiceId() == EUninstall )
+            {
+            TRAPD(dataErr, WriteTaskDataL( *task ));
+            if (dataErr)
+                {
+                LOGGER_WRITE_1("WriteTaskDataL err: %d", dataErr);
+                }
+            }
+        
         if( task->GetServiceId() == EInstall && err == KErrNone )
             {
             LOGGER_WRITE( "CSConAppInstaller::RunL() : before DeleteFile" );
@@ -281,10 +259,190 @@
     TRACE_FUNC_EXIT;
     }
 
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::WriteTaskDataL()
+// Writes data to task
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::WriteTaskDataL( CSConTask& aTask )
+    {
+    TRACE_FUNC_ENTRY;
+    CBufFlat* buffer = CBufFlat::NewL(200);
+    CleanupStack::PushL(buffer);
+    RBufWriteStream stream( *buffer );
+    CleanupClosePushL( stream );
+    
+    ExternalizeResultArrayIntValL( KSifOutParam_ComponentId , stream);
+    ExternalizeResultIntValL( KSifOutParam_ErrCategory , stream);
+    ExternalizeResultIntValL( KSifOutParam_ErrCode , stream);
+    ExternalizeResultIntValL( KSifOutParam_ExtendedErrCode , stream);
+    ExternalizeResultStringValL( KSifOutParam_ErrMessage , stream);
+    ExternalizeResultStringValL( KSifOutParam_ErrMessageDetails , stream);
+    
+    stream.CommitL();
+    
+    buffer->Compress();
+    
+    HBufC8* data = HBufC8::NewL( buffer->Size() );
+    TPtr8 dataPtr = data->Des();
+    buffer->Read( 0, dataPtr, buffer->Size() );
+    
+    if ( aTask.GetServiceId() == EInstall )
+        {
+        if ( aTask.iInstallParams->iData )
+            {
+            delete aTask.iInstallParams->iData;
+            aTask.iInstallParams->iData = NULL;
+            }
+        aTask.iInstallParams->iData = data;
+        data = NULL;
+        }
+    else if ( aTask.GetServiceId() == EUninstall )
+        {
+        if ( aTask.iUninstallParams->iData )
+            {
+            delete aTask.iUninstallParams->iData;
+            aTask.iUninstallParams->iData = NULL;
+            }
+        aTask.iUninstallParams->iData = data;
+        data = NULL;
+        }
+    else
+        {
+        delete data;
+        data = NULL;
+        }
+    
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSConAppInstaller::ExternalizeResultArrayIntValL( const TDesC& aName, RWriteStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    RArray<TInt> valueArray;
+    TRAPD(err, valueArray = iSifResults->IntArrayByNameL(aName));
+    if ( !err && valueArray.Count() > 0 )
+        {
+        LOGGER_WRITE_1("count: %d", valueArray.Count());
+        TBuf8<100> nameBuf;
+        err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
+        if (!err)
+            {
+            LOGGER_WRITE("2");
+            aStream.WriteL( nameBuf, nameBuf.Length() );
+            aStream.WriteL( KValSep, 1 );
+            aStream.WriteInt32L( valueArray[0] );
+            for (TInt i=1; i<valueArray.Count(); i++)
+                {
+                aStream.WriteL( KComma, 1 );
+                aStream.WriteInt32L( valueArray[i] );
+                }
+            aStream.WriteL( KLineEnd, 2 );
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::ExternalizeResultIntValL()
+// Read integer value and write it to stream
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::ExternalizeResultIntValL( const TDesC& aName, RWriteStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt value;
+    TBool found(EFalse);
+    found = iSifResults->GetIntByNameL(aName, value);
+
+    if (found)
+        {
+        TBuf8<100> nameBuf;
+        TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
+        if (!err)
+            {
+            aStream.WriteL( nameBuf, nameBuf.Length() );
+            aStream.WriteL( KValSep, 1 );
+            aStream.WriteInt32L( value );
+            aStream.WriteL( KLineEnd, 2 );
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::ExternalizeResultStringValL()
+// Read string value and write it to stream
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::ExternalizeResultStringValL( const TDesC& aName, RWriteStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    const TDesC& strValue = iSifResults->StringByNameL( aName );
+    if (strValue.Length() > 0)
+        {
+        TBuf8<100> nameBuf;
+        TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
+        if (!err)
+            {
+            HBufC8* nameVal = CnvUtfConverter::ConvertFromUnicodeToUtf8L( strValue );
+            CleanupStack::PushL( nameVal );
+            aStream.WriteL( nameBuf, nameBuf.Length() );
+            aStream.WriteL( KValSep, 1 );
+            aStream.WriteL( nameVal->Des(), nameVal->Length() );
+            aStream.WriteL( KLineEnd, 2 );
+            CleanupStack::PopAndDestroy( nameVal );
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConAppInstaller::ProcessInstallL()
+// Executes Install task
+// -----------------------------------------------------------------------------
+//
+void CSConAppInstaller::ProcessInstallL( const CSConInstall& aInstallParams )
+    {
+    TRACE_FUNC_ENTRY;
+    iSifOptions->Cleanup();
+    iSifResults->Cleanup();
+    
+    if ( aInstallParams.iMode == ESilentInstall )
+        {
+        LOGGER_WRITE( "Begin silent installation.. " );
+        
+        iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
+        iSifOptions->AddIntL( Usif::KSifInParam_PerformOCSP, EFalse );   
+        // Note if upgrade is allowed, see NeedsInstallingL function.
+        iSifOptions->AddIntL( Usif::KSifInParam_AllowUpgrade, ETrue );
+        iSifOptions->AddIntL( Usif::KSifInParam_AllowUntrusted, EFalse );
+        iSifOptions->AddIntL( Usif::KSifInParam_GrantCapabilities, EFalse ); 
+        // Defined for the install.
+        iSifOptions->AddIntL( Usif::KSifInParam_InstallOptionalItems, ETrue );          
+        iSifOptions->AddIntL( Usif::KSifInParam_IgnoreOCSPWarnings, ETrue );            
+        iSifOptions->AddIntL( Usif::KSifInParam_AllowAppShutdown, ETrue );
+        iSifOptions->AddIntL( Usif::KSifInParam_AllowDownload, ETrue );
+        iSifOptions->AddIntL( Usif::KSifInParam_AllowOverwrite, ETrue );
+
+        iSwInstaller.Install( aInstallParams.iPath, *iSifOptions,
+                *iSifResults, iStatus, ETrue );
+        }
+    else
+        {
+        LOGGER_WRITE( "Begin to install.. " );
+        
+        iSwInstaller.Install( aInstallParams.iPath, *iSifOptions,
+                *iSifResults, iStatus, ETrue );
+        }
+    SetActive();
+    TRACE_FUNC_EXIT;
+    }
 
 // -----------------------------------------------------------------------------
 // CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
-// Execures UnInstall task
+// Executes UnInstall task
 // -----------------------------------------------------------------------------
 //
 void CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
@@ -295,209 +453,29 @@
     LOGGER_WRITE_1( "aVendor: %S", &aUninstallParams.iVendor );
     LOGGER_WRITE_1( "aType: %d", aUninstallParams.iType );
     LOGGER_WRITE_1( "aMode: %d", aUninstallParams.iMode );
-    switch ( aUninstallParams.iType )
-	    {
-	    case ESisApplication:
-	    case ESisAugmentation:
-	    	UninstallSisL( aUninstallParams );
-	    	break;
-	    case EJavaApplication:
-	    	UninstallJavaL( aUninstallParams.iUid,
-    			aUninstallParams.iMode);
-	    	break;
-	    case EWidgetApplication:
-	    	UninstallWidget( aUninstallParams.iUid,
-	    		aUninstallParams.iMode );
-	    	break;
-	    default:
-	    	User::Leave( KErrNotSupported );
-	    }
     
-    TRACE_FUNC_EXIT;
-    }
-
-// -----------------------------------------------------------------------------
-// CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
-// Uninstall sis package or augmentation
-// -----------------------------------------------------------------------------
-//
-void CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
-	{
-	TRACE_FUNC_ENTRY;
-
-	if ( aUninstallParams.iUid == KSConSeConUid )
+    if ( aUninstallParams.iUid == KSConSeConUid )
 	    {
 	    LOGGER_WRITE("Cannot uninstall itself, leave");
 	    // cannot uninstall itself
-	    User::Leave( SwiUI::KSWInstErrFileInUse );
+	    User::Leave( KErrInUse ); //SwiUI::KSWInstErrFileInUse );
 	    }
-	
-	Swi::RSisRegistrySession sisRegistry;
-    User::LeaveIfError( sisRegistry.Connect() );
-    CleanupClosePushL( sisRegistry );
-    //Check if uid belongs to SIS package
-    if( !sisRegistry.IsInstalledL( aUninstallParams.iUid ) )
-        {
-        CleanupStack::PopAndDestroy( &sisRegistry );
-        User::Leave( KErrNotFound );
-        }
+    TComponentId componentId = aUninstallParams.iUid.iUid;
+    iSifOptions->Cleanup();
+    iSifResults->Cleanup();
     
-    Swi::RSisRegistryEntry entry;
-    CleanupClosePushL(entry);
-    User::LeaveIfError( entry.Open( sisRegistry, aUninstallParams.iUid ) );
-    if ( aUninstallParams.iType == ESisAugmentation )
+    if ( aUninstallParams.iMode == ESilentInstall)
         {
-        // augmentation pkg
-        LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL ESisAugmentation" );
-        
-        TBool augmentationFound(EFalse);
-        // Get possible augmentations
-        RPointerArray<Swi::CSisRegistryPackage> augPackages;
-        CleanupResetAndDestroyPushL( augPackages );
-        entry.AugmentationsL( augPackages );
-        for ( TInt j( 0 ); j < augPackages.Count() && !augmentationFound; j++ )
-            {
-            Swi::RSisRegistryEntry augmentationEntry;
-            CleanupClosePushL( augmentationEntry );
-            augmentationEntry.OpenL( sisRegistry, *augPackages[j] );
-            
-            HBufC* augPackageName = augmentationEntry.PackageNameL();
-            CleanupStack::PushL( augPackageName );
-            HBufC* augUniqueVendorName = augmentationEntry.UniqueVendorNameL();
-            CleanupStack::PushL( augUniqueVendorName );
-            
-            if ( !augmentationEntry.IsInRomL() 
-                && augmentationEntry.IsPresentL()
-                && aUninstallParams.iName.Compare( *augPackageName ) == 0
-                && aUninstallParams.iVendor.Compare( *augUniqueVendorName ) == 0 )
-                {
-                // Correct augmentation found, uninstall it.
-                augmentationFound = ETrue;
-                TInt augmentationIndex = augPackages[j]->Index();
-                LOGGER_WRITE_1( "CSConAppInstaller::ProcessUninstallL augmentationIndex %d", augmentationIndex );
-        
-                SwiUI::TOpUninstallIndexParam params;
-                params.iUid = aUninstallParams.iUid;
-                params.iIndex = augmentationIndex;
-                SwiUI::TOpUninstallIndexParamPckg pckg( params );
-                SwiUI::TOperation operation( SwiUI::EOperationUninstallIndex );
-                if( aUninstallParams.iMode == ESilentInstall )
-                    {
-                    LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent aug-sis-uninstall" );
-                    SwiUI::TUninstallOptionsPckg options;
-                    iInstallerState = ESilentCustomUnistalling;
-                    iSWInst.SilentCustomUninstall( iStatus, operation, options, pckg, KSISMIMEType );
-                    }
-                else
-                    {
-                    LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent aug-sis-uninstall" )
-                    iInstallerState = ECustomUninstalling;
-                    iSWInst.CustomUninstall( iStatus, operation, pckg, KSISMIMEType );
-                    }
-                }
-            CleanupStack::PopAndDestroy( augUniqueVendorName );
-            CleanupStack::PopAndDestroy( augPackageName );
-            CleanupStack::PopAndDestroy( &augmentationEntry );
-            }  
-        CleanupStack::PopAndDestroy( &augPackages );
-        
-        if ( !augmentationFound )
-            {
-            LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL augmentation not found -> Leave" );
-            User::Leave( KErrNotFound );
-            }
+        iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
+        iSwInstaller.Uninstall( componentId, *iSifOptions, *iSifResults, iStatus, ETrue );
         }
     else
         {
-        // Only uninstall if not in rom and is present
-        if ( !entry.IsInRomL() && entry.IsPresentL() )
-            { 
-            if ( aUninstallParams.iMode == ESilentInstall )
-                {
-                LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent sis-uninstall" );
-                SwiUI::TUninstallOptionsPckg options;
-                iInstallerState = ESilentUninstalling;
-                iSWInst.SilentUninstall( iStatus, aUninstallParams.iUid, options, KSISMIMEType );
-                }
-            else
-                {
-                LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent sis-uninstall" )
-                iInstallerState = EUninstalling;
-                iSWInst.Uninstall( iStatus, aUninstallParams.iUid, KSISMIMEType );
-                }
-            }
-        else
-            {
-            LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL sis not present -> Leave" );
-            User::Leave( KErrNotFound );
-            }
+        iSwInstaller.Uninstall( componentId, *iSifOptions, *iSifResults, iStatus, ETrue );
         }
-    
-    CleanupStack::PopAndDestroy( &entry );
-	CleanupStack::PopAndDestroy( &sisRegistry );
-	TRACE_FUNC_EXIT;
-	}
-
-// -----------------------------------------------------------------------------
-// CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
-// Uninstall java package
-// -----------------------------------------------------------------------------
-//
-void CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
-	{
-	TRACE_FUNC_ENTRY;
-	CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
-	TBool entryExist = javaRegistry->RegistryEntryExistsL( aUid );
-	CleanupStack::PopAndDestroy( javaRegistry ); 
-	
-    if( entryExist )
-        {
-        if( aMode == ESilentInstall )
-            {
-            LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : silent midlet-uninstall" )
-            SwiUI::TUninstallOptionsPckg options;
-            iInstallerState = ESilentUninstalling;
-            iSWInst.SilentUninstall( iStatus, aUid, options, KMidletMIMEType );
-            }
-        else
-            {
-            LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : unsilent midlet-uninstall" )
-            iInstallerState = EUninstalling;
-            iSWInst.Uninstall( iStatus, aUid, KMidletMIMEType );
-            }
-        }
-    else
-        {
-        LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL java entry does not exist -> Leave" )
-        User::Leave( KErrNotFound );
-        }
+    SetActive();
     TRACE_FUNC_EXIT;
-	}
-
-// -----------------------------------------------------------------------------
-// CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
-// Uninstall widget
-// -----------------------------------------------------------------------------
-//
-void CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
-	{
-	TRACE_FUNC_ENTRY;
-	if( aMode == ESilentInstall )
-        {
-        LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : silent uninstall" )
-        SwiUI::TUninstallOptionsPckg options;
-        iInstallerState = ESilentUninstalling;
-        iSWInst.SilentUninstall( iStatus, aUid, options, KWidgetMimeType );
-        }
-    else
-        {
-        LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : unsilent uninstall" )
-        iInstallerState = EUninstalling;
-        iSWInst.Uninstall( iStatus, aUid, KWidgetMimeType );
-        }
-	TRACE_FUNC_EXIT;
-	}
-
+    }
     
 //--------------------------------------------------------------------------------
 //void CSConAppInstaller::ProcessListInstalledAppsL()
--- a/connectivitymodules/SeCon/services/pcd/src/sconinstqueue.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconinstqueue.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* 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"
@@ -48,6 +48,7 @@
 //
 CSConInstallerQueue::CSConInstallerQueue( RFs& aFs ) : CActive( EPriorityStandard ), iFs( aFs )
 	{
+    CActiveScheduler::Add( this );
 	}
 	
 // -----------------------------------------------------------------------------
@@ -58,8 +59,7 @@
 void CSConInstallerQueue::ConstructL()
 	{
 	TRACE_FUNC_ENTRY;
-	iInstaller = new (ELeave) CSConAppInstaller( this, iFs );
-	CActiveScheduler::Add( iInstaller );
+	iInstaller = CSConAppInstaller::NewL( this, iFs );
 	User::LeaveIfError( iTimer.CreateLocal() );
 	TRACE_FUNC_EXIT;
 	}
@@ -151,7 +151,7 @@
 //
 void CSConInstallerQueue::PollQueue()
 	{
-	TRACE_FUNC_ENTRY;
+	TRACE_FUNC;
 	// find and start next task if installer and BR is inactive
 	if( !iInstaller->InstallerActive()
 		&& !iBRQueueAddress->QueueProcessActive() )
@@ -168,7 +168,6 @@
 				}
 			}
 		}
-	TRACE_FUNC_EXIT;
 	}
 
 // -----------------------------------------------------------------------------
--- a/connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -23,8 +23,11 @@
 #include "sconinstqueue.h"
 #include "sconbrqueue.h"
 #include "sconmetadata.h"
+#include "sconsynchandler.h"
 #include "debug.h"
 
+const TInt KMaxObjectSize(65536); // informed to PC
+
 // ============================= MEMBER FUNCTIONS ===============================
 
 
@@ -60,11 +63,8 @@
 // Constructor
 // -----------------------------------------------------------------------------
 //
-CSConPCD::CSConPCD() : iInstallerQueue( NULL ), iBackupRestoreQueue( NULL ), 
-    iLatestReply(NULL), iTaskNumber( 0 ), iMaxObjectSize( 65536 ), 
-    iLastOperation( ENoTask )
+CSConPCD::CSConPCD()
     {
-    TRACE_FUNC;
     }
     
 // -----------------------------------------------------------------------------
@@ -76,18 +76,18 @@
     {
     TRACE_FUNC_ENTRY;
     User::LeaveIfError( iFs.Connect() );
-    iInstallerQueue = CSConInstallerQueue::NewL( iFs );
-    iBackupRestoreQueue = CSConBackupRestoreQueue::NewL( iMaxObjectSize, iFs );
-    iInstallerQueue->QueueAddress( iBackupRestoreQueue );
-    iBackupRestoreQueue->QueueAddress( iInstallerQueue );
-    
     if ( !CActiveScheduler::Current() )
         {
         CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
         CActiveScheduler::Install( scheduler );
         }
-    CActiveScheduler::Add( iInstallerQueue );
-    CActiveScheduler::Add( iBackupRestoreQueue );
+    
+    iInstallerQueue = CSConInstallerQueue::NewL( iFs );
+    iBackupRestoreQueue = CSConBackupRestoreQueue::NewL( iFs );
+    iInstallerQueue->QueueAddress( iBackupRestoreQueue );
+    iBackupRestoreQueue->QueueAddress( iInstallerQueue );
+    
+    iSyncHandler = CSconSyncHandler::NewL( iFs );
     TRACE_FUNC_EXIT;
     }
     
@@ -99,26 +99,10 @@
 CSConPCD::~CSConPCD()
     {
     TRACE_FUNC_ENTRY;
-    if ( iInstallerQueue )
-        {
-        iInstallerQueue->Cancel();
-        delete iInstallerQueue;
-        iInstallerQueue = NULL;
-        }
-        
-    if ( iBackupRestoreQueue )
-        {
-        iBackupRestoreQueue->Cancel();
-        delete iBackupRestoreQueue;
-        iBackupRestoreQueue = NULL;
-        }
-    
-    if ( iLatestReply )
-        {
-        delete iLatestReply;
-        iLatestReply = NULL;
-        }
-    
+    delete iInstallerQueue;
+    delete iBackupRestoreQueue;
+    delete iLatestReply;
+    delete iSyncHandler;
     iFs.Close();
     TRACE_FUNC_EXIT;
     }
@@ -260,6 +244,32 @@
     }
 
 // -----------------------------------------------------------------------------
+// CSConPCD::HandleGetSyncRequestL()
+// 
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize )
+    {
+    TRACE_FUNC_ENTRY;
+    iSyncHandler->HandleGetSyncRequestL( aRequest, aResult, aMaxObjectSize );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CSConPCD::HandlePutSyncRequestL()
+// 
+// -----------------------------------------------------------------------------
+//
+void CSConPCD::HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    iSyncHandler->HandlePutSyncRequestL( aRequest, aResult );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
 // CSConPCD::SupportedInstTaskL( CSConTask* aTask )
 // Fills a reply with predefined supported task -information
 // -----------------------------------------------------------------------------
@@ -563,9 +573,8 @@
             }
         }
     
-    taskReply->iDevInfoParams->iVersion.Copy( KCONMLVERSION );
-    taskReply->iDevInfoParams->iMaxObjectSize = 
-        GetMaxObjectSize( aMaxObjectSize );
+    taskReply->iDevInfoParams->iVersion.Copy( KConMLVersion );
+    taskReply->iDevInfoParams->iMaxObjectSize = KMaxObjectSize;
     
     reply->iNoTasks = EFalse;
 
@@ -577,16 +586,5 @@
     LOGGER_WRITE_1( "CSConPCD::UpdateDeviceInfo() : returned %d", ret );
     return ret;
     }
-    
-// -----------------------------------------------------------------------------
-// CSConPCD::GetMaxObjectSize( TInt /*aClientObjectSize*/ ) const
-// Gets the current max object size
-// -----------------------------------------------------------------------------
-//
-TInt CSConPCD::GetMaxObjectSize( TInt /*aClientObjectSize*/ ) const
-    {
-    LOGGER_WRITE_1( "CSConPCD::GetMaxObjectSize() : returned %d", iMaxObjectSize );
-    return iMaxObjectSize;
-    }
 
 // End of file
--- a/connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -214,7 +214,6 @@
 void SConPcdUtility::AppendInstalledJavaL( CSConListInstApps& aListInstApps )
     {
     TRACE_FUNC_ENTRY;
-    // Java related functionality was removed as it was on APP layer.
     CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
     RArray<TUid> packageUids;
     CleanupClosePushL( packageUids );
--- a/connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -22,6 +22,7 @@
 #include "sconpcdconsts.h"
 #include "debug.h"
 #include <SWInstDefs.h> // installer errors
+#include <usif/usiferror.h>
 
 // ============================= MEMBER FUNCTIONS ===============================
 
@@ -165,12 +166,16 @@
 // Set the task to completed -mode
 // -----------------------------------------------------------------------------
 //
-void CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
+TInt CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
     {
     LOGGER_WRITE_1( "CSConTaskQueue::CompleteTask aError: %d", aError );
+    TInt ret(KErrNone);
     TInt index( KErrNotFound );
     
     CSConTask* temp = new CSConTask();
+    if (!temp)
+        return KErrNoMemory;
+    
     temp->iTaskId = aTask;
     index = iQueue.Find( temp, CSConTaskQueue::Match );
     delete temp;
@@ -203,16 +208,19 @@
             	progress = KSConCodeInstErrUserCancel;
             	break;
             case SwiUI::KSWInstErrFileCorrupted:
+            case KErrSifCorruptedPackage:
             	LOGGER_WRITE("File is corrupted");
             	iQueue[index]->SetCompleteValue( complete );
             	progress = KSConCodeInstErrFileCorrupted;
             	break;
             case SwiUI::KSWInstErrInsufficientMemory:
+            case KErrSifNotEnoughSpace:
             	LOGGER_WRITE("Insufficient free memory in the drive to perform the operation");
 	            iQueue[index]->SetCompleteValue( complete );
 	            progress = KSConCodeInstErrInsufficientMemory;	
 	            break;
             case SwiUI::KSWInstErrPackageNotSupported:
+            case KErrSifUnsupportedSoftwareType:
             	LOGGER_WRITE("Installation of the package is not supported");
             	iQueue[index]->SetCompleteValue( complete );
             	progress = KSConCodeInstErrPackageNotSupported;
@@ -223,6 +231,7 @@
             	progress = KSConCodeInstErrSecurityFailure;
             	break;
             case SwiUI::KSWInstErrMissingDependency:
+            case KErrSifMissingDependencies:
             	LOGGER_WRITE("Package cannot be installed due to missing dependency");
             	iQueue[index]->SetCompleteValue( complete );
             	progress = KSConCodeInstErrMissingDependency;
@@ -233,6 +242,7 @@
             	progress = KSConCodeInstErrFileInUse;
             	break;
             case SwiUI::KSWInstErrGeneralError:
+            case KErrSifUnknown:
             	LOGGER_WRITE("Unknown error");
             	iQueue[index]->SetCompleteValue( complete );
             	progress = KSConCodeInstErrGeneralError;
@@ -262,6 +272,77 @@
             	iQueue[index]->SetCompleteValue( complete );
             	progress = KSConCodeInstUpgradeError;
             	break;
+            	
+            case KErrSifMissingBasePackage:
+                LOGGER_WRITE("KErrSifMissingBasePackage");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifMissingBasePackage;
+                break;
+            case KErrSifOverflow:
+                LOGGER_WRITE("KErrSifOverflow");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifOverflow;
+                break;
+            case KErrSifSameVersionAlreadyInstalled:
+                LOGGER_WRITE("KErrSifSameVersionAlreadyInstalled");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifSameVersionAlreadyInstalled;
+                break;
+            case KErrSifNewerVersionAlreadyInstalled:
+                LOGGER_WRITE("KErrSifNewerVersionAlreadyInstalled");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifNewerVersionAlreadyInstalled;
+                break;
+            case KErrSifAlreadyActivated:
+                LOGGER_WRITE("KErrSifAlreadyActivated");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifAlreadyActivated;
+                break;
+            case KErrSifAlreadyDeactivated:
+                LOGGER_WRITE("KErrSifAlreadyDeactivated");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifAlreadyDeactivated;
+                break;
+            case KErrSifBadComponentId:
+                LOGGER_WRITE("KErrSifBadComponentId");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifBadComponentId;
+                break;
+            case KErrSifBadInstallerConfiguration:
+                LOGGER_WRITE("KErrSifBadInstallerConfiguration");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifBadInstallerConfiguration;
+                break;
+            case KErrSifPackageCannotBeInstalledOnThisDevice:
+                LOGGER_WRITE("KErrSifPackageCannotBeInstalledOnThisDevice");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifPackageCannotBeInstalledOnThisDevice;
+                break;
+            case KErrSifUnsupportedLanguage:
+                LOGGER_WRITE("KErrSifUnsupportedLanguage");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrSifUnsupportedLanguage;
+                break;
+            case KErrScrWriteOperationInProgress:
+                LOGGER_WRITE("KErrScrWriteOperationInProgress");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrScrWriteOperationInProgress;
+                break;
+            case KErrScrReadOperationInProgress:
+                LOGGER_WRITE("KErrScrReadOperationInProgress");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrScrReadOperationInProgress;
+                break;
+            case KErrScrNoActiveTransaction:
+                LOGGER_WRITE("KErrScrNoActiveTransaction");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrScrNoActiveTransaction;
+                break;
+            case KErrScrUnsupportedLocale:
+                LOGGER_WRITE("KErrScrUnsupportedLocale");
+                iQueue[index]->SetCompleteValue( complete );
+                progress = KSConCodeInstErrScrUnsupportedLocale;
+                break;
             
             default :
                 iQueue[index]->SetCompleteValue( complete );
@@ -281,7 +362,12 @@
             
         iQueue[index]->SetProgressValue( progress );
         }
+    else
+        {
+        ret = KErrNotFound;
+        }
     StartQueue();
+    return ret;
     }
     
 // -----------------------------------------------------------------------------
@@ -289,19 +375,32 @@
 // Set the task progress value
 // -----------------------------------------------------------------------------
 //
-void CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
+TInt CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
     {
+    TInt ret( KErrNone );
     TInt index( KErrNotFound );
 
     CSConTask* temp = new CSConTask();
-    temp->iTaskId = aTask;
-    index = iQueue.Find( temp, CSConTaskQueue::Match );
-    delete temp;
-    
-    if ( index != KErrNotFound )
+    if (temp)
         {
-        iQueue[index]->SetProgressValue( aProgressValue );
+        temp->iTaskId = aTask;
+        index = iQueue.Find( temp, CSConTaskQueue::Match );
+        delete temp;
+        
+        if ( index != KErrNotFound )
+            {
+            iQueue[index]->SetProgressValue( aProgressValue );
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }
         }
+    else
+        {
+        ret = KErrNoMemory;
+        }
+    return ret;
     }
     
 // -----------------------------------------------------------------------------
@@ -315,17 +414,24 @@
     TInt index;
     
     CSConTask* temp = new CSConTask();
-    temp->iTaskId = aTaskId;
-    index = iQueue.Find( temp, CSConTaskQueue::Match );
-    delete temp;
-
-    if ( index != KErrNotFound )
+    if (temp)
         {
-        aTask = iQueue[index];
+        temp->iTaskId = aTaskId;
+        index = iQueue.Find( temp, CSConTaskQueue::Match );
+        delete temp;
+    
+        if ( index != KErrNotFound )
+            {
+            aTask = iQueue[index];
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }
         }
     else
         {
-        ret = KErrNotFound;
+        ret = KErrNoMemory;
         }
     return ret;
     }
@@ -335,27 +441,40 @@
 // Removes a task from the queue
 // -----------------------------------------------------------------------------
 //
-void CSConTaskQueue::RemoveTask( TInt aTask )
+TInt CSConTaskQueue::RemoveTask( TInt aTask )
     {
+    TInt ret(KErrNone);
     TInt index( KErrNotFound );
     
     CSConTask* temp = new CSConTask();
-    temp->iTaskId = aTask;
-    index = iQueue.Find( temp, CSConTaskQueue::Match );
-    delete temp;
-    
-    if ( index != KErrNotFound ) 
+    if (temp)
         {
-        delete iQueue[index];
-        iQueue.Remove( index );
-        iQueue.Compress();
+        temp->iTaskId = aTask;
+        index = iQueue.Find( temp, CSConTaskQueue::Match );
+        delete temp;
+        
+        if ( index != KErrNotFound ) 
+            {
+            delete iQueue[index];
+            iQueue.Remove( index );
+            iQueue.Compress();
+            }
+        else
+            {
+            ret = KErrNotFound;
+            }
+        
+        if ( iQueue.Count() == 0 )
+            {
+            StopQueue();
+            iQueue.Reset();
+            }
         }
-    
-    if ( iQueue.Count() == 0 )
+    else
         {
-        StopQueue();
-        iQueue.Reset();
+        ret = KErrNoMemory;
         }
+    return ret;
     }
     
 // -----------------------------------------------------------------------------
--- a/connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -24,7 +24,8 @@
 #include "sconsbeclient.h"
 #include "debug.h"
 
-
+const TInt KDataBufExpandSize( 1024 );
+const TInt KMaxObjectSize( 1048576 - 1024 ); // Max chunk size is 1MB, but give some space for ConML wbxml
 _LIT( KSConNoDrive, "\x0" );
 _LIT( KSConDriveExists, "\x1" );
 // ============================= MEMBER FUNCTIONS ==============================
@@ -34,10 +35,10 @@
 // Two-phase constructor
 // -----------------------------------------------------------------------------
 //  
-CSConSBEClient* CSConSBEClient::NewL( const TInt aMaxObjectSize, RFs& aFs )
+CSConSBEClient* CSConSBEClient::NewL( RFs& aFs )
     {
     TRACE_FUNC;
-    CSConSBEClient* self = new (ELeave) CSConSBEClient( aMaxObjectSize, aFs );
+    CSConSBEClient* self = new (ELeave) CSConSBEClient( aFs );
     return self;
     }
     
@@ -46,13 +47,10 @@
 // Constructor
 // -----------------------------------------------------------------------------
 //
-CSConSBEClient::CSConSBEClient( const TInt aMaxObjectSize, RFs& aFs ) : 
-        CActive( EPriorityStandard ), iSBEClient(NULL), 
-        iProcessComplete(EFalse), iProcessIndex( 0 ), iDataPos( 0 ),
-        iDataLeft( EFalse ), iBURModeNormal( ETrue ),
-        iRestoreMode( EFalse ), iFs( aFs )
+CSConSBEClient::CSConSBEClient( RFs& aFs ) : 
+        CActive( EPriorityStandard ), iBURModeNormal( ETrue ), iFs( aFs )
     {
-    iMaxObjectSize = aMaxObjectSize;
+    CActiveScheduler::Add( this );
     }
 
 // -----------------------------------------------------------------------------
@@ -63,6 +61,7 @@
 CSConSBEClient::~CSConSBEClient()
     {
     TRACE_FUNC_ENTRY;
+    Cancel();
     TInt err( KErrNone );
     
     if( !iBURModeNormal && iSBEClient )
@@ -89,6 +88,8 @@
         delete iSBEClient;
         iSBEClient = NULL;
         }
+    
+    delete iDataBuffer;
     TRACE_FUNC_EXIT;
     }
 
@@ -263,67 +264,52 @@
             LOGGER_WRITE( "CSConSBEClient::RunL() : ESetBURMode" );
             TRAP( err, ProcessSetBURModeL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessSetBURModeL() : returned %d", err );
-            HandleSBEErrorL( err );
-            User::RequestComplete( iCallerStatus, err );
             break;
         case EListPublicFiles :
             LOGGER_WRITE( "CSConSBEClient::RunL() : EListPublicFiles" );
             TRAP( err, ProcessListPublicFilesL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListPublicFilesL() : returned %d", err );
-            HandleSBEErrorL( err );
-            User::RequestComplete( iCallerStatus, err );
             break;
         case EListDataOwners :
             LOGGER_WRITE( "CSConSBEClient::RunL() : EListDataOwners" ); 
             TRAP( err, ProcessListDataOwnersL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListDataOwnersL() : returned %d", err );
-            HandleSBEErrorL( err );
-            User::RequestComplete( iCallerStatus, err );
             break;
         case EGetDataSize :
             LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataSize" );    
             TRAP( err, ProcessGetDataSizeL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataSizeL() : returned %d", err );
-            HandleSBEErrorL( err );
-            User::RequestComplete( iCallerStatus, err );
             break;
         case ERequestData :
             LOGGER_WRITE( "CSConSBEClient::RunL() : ERequestData" );
             TRAP( err, ret = ProcessRequestDataL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessRequestDataL() : returned %d", err );
-            HandleSBEErrorL( err );
-            
-            if( err == KErrNone )
-                {
-                err = ret;
-                }
-            
-            User::RequestComplete( iCallerStatus, err );
             break;  
         case EGetDataOwnerStatus :
             LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataOwnerStatus" );
             TRAP( err, ProcessGetDataOwnerStatusL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataOwnerStatusL() : returned %d", err );
-            HandleSBEErrorL( err );
-            User::RequestComplete( iCallerStatus, err );
             break;
         case ESupplyData :
             LOGGER_WRITE( "CSConSBEClient::RunL() : ESupplyData" ); 
             TRAP( err, ret = ProcessSupplyDataL() );
             LOGGER_WRITE_1( "CSConSBEClient::RunL() : SupplyDataL() : returned %d", err );
-            HandleSBEErrorL( err );
-            
-            if( err == KErrNone )
-                {
-                err = ret;
-                }
-            
-            User::RequestComplete( iCallerStatus, err );
             break;
         default :
+            err = KErrNotSupported;
             LOGGER_WRITE( "CSConSBEClient::RunL() : ERROR! Unknown!" ); 
             break;
         }
+    
+    if ( err )
+        {
+        HandleSBEErrorL( err );
+        }
+    else
+        {
+        err = ret;
+        }
+    User::RequestComplete( iCallerStatus, err );
             
     TRACE_FUNC_EXIT;
     }
@@ -338,6 +324,7 @@
     TRACE_FUNC_ENTRY;
     
     iAllSnapshotsSuppliedCalled = EFalse;
+    iLastChunk = EFalse;
     
     TDriveList driveList = iCurrentTask->iBURModeParams->iDriveList;
     
@@ -368,6 +355,21 @@
             break;
         }
     
+    if ( partialType == EBURBackupFull || partialType == ESConBurBackupPartial )
+        {
+        // initialize buffer
+        if ( !iDataBuffer )
+            iDataBuffer = CBufFlat::NewL( KDataBufExpandSize );
+        else
+            iDataBuffer->Reset();
+        iDataBufferSize=0;
+        }
+    else
+        {
+        delete iDataBuffer;
+        iDataBuffer = 0;
+        }
+    
     TBackupIncType incType = ENoBackup;
     
     switch( iCurrentTask->iBURModeParams->iIncType )    
@@ -719,7 +721,7 @@
             //Add sid
             packageDataOwner->iUid.iUid = sid.iId;
             iCurrentTask->iListDataOwnersParams->iDataOwners.AppendL( packageDataOwner );
-            CleanupStack::PopAndDestroy( packageDataOwner );
+            CleanupStack::Pop( packageDataOwner );
             }
         
         if( !includeToList )
@@ -842,11 +844,6 @@
     {
     TRACE_FUNC_ENTRY;
     TInt ret( KErrNone );
-    
-    if( iMaxObjectSize <= 1 )
-        {
-        User::Leave( KErrGeneral );
-        }
         
     TBool packageData = EFalse;
     TTransferDataType transferDataType( ERegistrationData );
@@ -921,95 +918,42 @@
         sid = iCurrentTask->iRequestDataParams->iDataOwner->iUid;
         LOGGER_WRITE_1("CSConSBEClient::ProcessRequestDataL() sid: 0x%08x", sid.iId);
         }
-            
-    CSBPackageTransferType* ptt( NULL );
-    CSBSIDTransferType* stt( NULL );
-    CSBJavaTransferType* jtt( NULL );
     
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    Begin - Data left: %d", iDataLeft );
+
     LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
     Begin - Package data: %d", packageData );
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    Begin - iDataPos: %d", iDataPos );
+
+    LOGGER_WRITE_1("iLastChunk: %d", (TInt) iLastChunk );
+    LOGGER_WRITE_1("iDataBufferSize: %d", iDataBufferSize );
         
-    //Are there old data left to be transfered?
-    if( !iDataLeft ) 
+    // if was't last chunk and there are free space left on our packet
+    if( !iLastChunk && iDataBufferSize < KMaxObjectSize ) 
         {
         //No data left, request more from the server
         if( packageData && !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
             {
-            ptt = CSBPackageTransferType::NewL( uid, driveNumber, 
-                packageDataType );
+            CSBPackageTransferType* ptt = CSBPackageTransferType::NewL(
+                    uid, driveNumber, packageDataType );
             CleanupStack::PushL( ptt );
-            LOGGER_WRITE( "iSBEClient->RequestDataL( ptt ) : start" );
-            TRequestStatus status;
-            iSBEClient->RequestDataL( *ptt, status );
-            User::WaitForRequest( status );
-            LOGGER_WRITE( "iSBEClint->RequestDataL( ptt ) : stop" );
             
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : status.Int() %d", status.Int() );
-            User::LeaveIfError( status.Int() );
-                                    
-            //Get the data and store the handle
-            CSBGenericTransferType* gtt = NULL;
-            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
-            iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
-            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Received data size %d", iDataPtr.Length() );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Received from DO 0x%08x", uid );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Is last chunk %d", iLastChunk );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Transfertype %d", iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
-             
-             if( gtt )
-                {
-                delete gtt;
-                }
-             
+            RequestDataL( *ptt );
+            
             CleanupStack::PopAndDestroy( ptt );
             }
         else if( !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash )
             {
-            stt = CSBSIDTransferType::NewL( sid, driveNumber, transferDataType );
+            CSBSIDTransferType* stt = CSBSIDTransferType::NewL(
+                    sid, driveNumber, transferDataType );
             CleanupStack::PushL( stt );
-            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : start" );
-            TRequestStatus status;
-            iSBEClient->RequestDataL( *stt, status );
-            User::WaitForRequest( status );
-            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : stop" );
             
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             status.Int() %d", status.Int() );
-            User::LeaveIfError( status.Int() );
-                        
-            //Get the data and store the handle
-            CSBGenericTransferType* gtt = NULL;
-            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
-            iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
-            LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Received data size %d", iDataPtr.Length() );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Is last chunk %d", iLastChunk );
-            LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-             Transfertype %d", 
-             iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
-             
-            if( gtt )
-                {
-                delete gtt;
-                }
-             
+            RequestDataL( *stt );
+            
             CleanupStack::PopAndDestroy( stt );
             }
         else
             {
             TPtr javaHashPtr = iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash->Des();
-            
+            CSBJavaTransferType* jtt( NULL );
             //When ESystemData is requested, request EJavaMIDlet
             if( packageDataType == ESystemData )
                 {
@@ -1024,52 +968,25 @@
             if( packageDataType == ESystemData || transferDataType == EPassiveBaseData )
                 {
                 CleanupStack::PushL( jtt );
-                LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : start" );
-                TRequestStatus status;
-                iSBEClient->RequestDataL( *jtt, status );
-                User::WaitForRequest( status );
-                LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : stop" );
                 
-                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-                 status.Int() %d", status.Int() );
-                User::LeaveIfError( status.Int() );
-                            
-                //Get the data and store the handle
-                CSBGenericTransferType* gtt = NULL;
-                LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" );
-                iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) );
-                LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ): stop" );
-                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-                 Received data size %d", iDataPtr.Length() );
-                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-                 Is last chunk %d", iLastChunk );
-                LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\
-                 Transfertype %d", 
-                 iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType );
-                 
-                if( gtt )
-                    {
-                    delete gtt;
-                    }
-                 
+                RequestDataL( *jtt );
+                
                 CleanupStack::PopAndDestroy( jtt );   
                 }
             else
                 {
                 //No data
-                iDataPtr.Set( KNullDesC8 );
+                iDataBuffer->Reset();
+                iDataBufferSize = 0;
                 iLastChunk = ETrue;
                 }
             }
-        }   
+        }
+    
+    LOGGER_WRITE_1("readed iLastChunk: %d", (TInt) iLastChunk );
+    LOGGER_WRITE_1("readed iDataBufferSize: %d", iDataBufferSize );
         
-    TInt dataBufLength = iDataPtr.Length();
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    Data received: %d", dataBufLength );
     
-    TInt maxLength = iMaxObjectSize - 1024;
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    Max length: %d", maxLength );
     
     if( iCurrentTask->iRequestDataParams->iBackupData )
         {
@@ -1077,57 +994,71 @@
         iCurrentTask->iRequestDataParams->iBackupData = NULL;
         }
     
+    TInt dataToRead = KMaxObjectSize;
+    if ( dataToRead > iDataBufferSize )
+        dataToRead = iDataBufferSize;
+    
     //Initialize the task data buffer
-    iCurrentTask->iRequestDataParams->iBackupData = HBufC8::NewL( maxLength );
+    iCurrentTask->iRequestDataParams->iBackupData = HBufC8::NewL( dataToRead );
     //Get descriptor task's buffer
     TPtr8 backupDataPtr = iCurrentTask->iRequestDataParams->iBackupData->Des();
     
-    TInt copyPos = 0;
     
-    //Copy data to task buffer
-    for( ; iDataPos < dataBufLength && copyPos < maxLength;
-     iDataPos++ )
+    iDataBuffer->Read(0, backupDataPtr, dataToRead );
+    iDataBuffer->Delete(0, dataToRead);
+    iDataBufferSize -= dataToRead;
+    
+    if ( !iLastChunk || iDataBufferSize>0 )
         {
-        backupDataPtr.Append( iDataPtr[iDataPos] );
-        copyPos++;
-        }
-        
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    End - copyPos: %d", copyPos );
-    LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \
-    End - iDataPos: %d", iDataPos );
-            
-    //Are there more data left in the buffer
-    if( iDataPos < dataBufLength )
-        {
-        LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There is more data in buffer" );
-        iDataLeft = ETrue;
+        LOGGER_WRITE( "CSConSBEClient::ProcessRequestDataL() : There are more data available" );
         iCurrentTask->iRequestDataParams->iMoreData = ETrue;
         //Another task is needed to transfer the data to the client
         ret = KErrCompletion;
         }
     else
         {
-        //Check if the backup server has more data from the dataowner
-        if( !iLastChunk )
-            {
-            iCurrentTask->iRequestDataParams->iMoreData = ETrue; 
-            //Another task is needed to transfer the data to the client
-            ret = KErrCompletion;
-            LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There are more data available from SBE" );
-            }
-        else
-            {
-            iCurrentTask->iRequestDataParams->iMoreData = EFalse;
-            }
-            
-        iDataPos = 0;   
-        iDataLeft = EFalse; 
+        LOGGER_WRITE( "CSConSBEClient::ProcessRequestDataL() : All data readed" );
+        iDataBuffer->Reset();
+        iDataBufferSize = 0;
+        // task will be completed, initialize iLastChunk value for next operation
+        iLastChunk = EFalse;
         }
+    
         
     LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :  returned %d", ret );
     return ret;
     }
+
+void CSConSBEClient::RequestDataL( CSBGenericTransferType& aGenericTransferType )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iDataBuffer )
+        User::Leave( KErrArgument );
+    
+    do
+        {
+        LOGGER_WRITE( "iSBEClient->RequestDataL() : start" );
+        TRequestStatus status;
+        iSBEClient->RequestDataL( aGenericTransferType, status );
+        User::WaitForRequest( status );
+        LOGGER_WRITE_1( "iSBEClient->RequestDataL() : status.Int() %d", status.Int() );
+        User::LeaveIfError( status.Int() );
+                    
+        //Get the data and store the handle
+        CSBGenericTransferType* gtt = NULL;
+        const TPtrC8& dataPtr = iSBEClient->TransferDataInfoL( gtt, iLastChunk );
+        LOGGER_WRITE_1("data size: %d", dataPtr.Length());
+        delete gtt;
+        iDataBuffer->ExpandL( iDataBufferSize, dataPtr.Length() );
+        iDataBuffer->Write(iDataBufferSize, dataPtr);
+        iDataBufferSize += dataPtr.Length();
+        LOGGER_WRITE_1("total buffer size: %d", iDataBufferSize);
+        }
+    // Continue if there are more data, and our packet is not full
+    while ( !iLastChunk && iDataBufferSize < KMaxObjectSize );
+    
+    TRACE_FUNC_EXIT;
+    }
     
 // -----------------------------------------------------------------------------
 // CSConSBEClient::ProcessGetDataOwnerStatusL()
@@ -1402,11 +1333,11 @@
     }
 
 // -----------------------------------------------------------------------------
-// CSConSBEClient::GetDriveNumber( const TInt& aDrive ) const
+// CSConSBEClient::GetDriveNumber( TInt aDrive ) const
 // Maps TInt drive number to TDriveNumber
 // -----------------------------------------------------------------------------
 //  
-TDriveNumber CSConSBEClient::GetDriveNumber( const TInt& aDrive ) const
+TDriveNumber CSConSBEClient::GetDriveNumber( TInt aDrive ) const
     {
     TDriveNumber driveNumber;
     switch( aDrive )
@@ -1560,6 +1491,15 @@
         iSBEClient = NULL;
         iSBEClient = CSBEClient::NewL();
         }
+    else if ( aErr ) // error
+        {
+        if ( iDataBuffer )
+            {
+            iDataBuffer->Reset();
+            iDataBufferSize = 0;
+            }
+        iLastChunk = EFalse;
+        }
     TRACE_FUNC_EXIT;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/services/pcd/src/sconsynchandler.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1460 @@
+/*
+* 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:  CSconSyncHandler implementation
+*
+*/
+
+
+#include "sconsynchandler.h"
+#include <f32file.h>
+#include <S32MEM.H>
+#include <UTF.H>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <bautils.h>
+#include <nsmlconstants.h>
+#include <centralrepository.h>
+
+#include "debug.h"
+
+// versions up to 5 must be backward compatible
+const TUint16 KFormatVersionNumber ( 1 );
+
+_LIT8(KCommandListStores, "SYNC: ListStores");
+_LIT8(KCommandOpenStore, "SYNC: OpenStore: ");
+_LIT8(KCommandCloseStore, "SYNC: CloseStore");
+_LIT8(KCommandListChanges, "SYNC: ListChanges");
+_LIT8(KCommandResetChangeInfo, "SYNC: ResetChangeInfo");
+_LIT8(KCommandCommitChanges, "SYNC: CommitChanges: ");
+_LIT8(KCommandReadItems, "SYNC: ReadItems: ");
+_LIT8(KCommandGetParents, "SYNC: GetParents: ");
+_LIT8(KCommandCreateItems, "SYNC: CreateItems");
+_LIT8(KCommandGetCreateItemsResponse, "SYNC: GetCreateItemsResponse");
+_LIT8(KCommandGetCreateItems, "SYNC: GetCreateItems: ");
+_LIT8(KCommandReplaceItems, "SYNC: ReplaceItems");
+_LIT8(KCommandGetReplaceItemsResponse, "SYNC: GetReplaceItemsResponse");
+_LIT8(KCommandGetReplaceItems, "SYNC: GetReplaceItems: ");
+_LIT8(KCommandMoveItems, "SYNC: MoveItems");
+_LIT8(KCommandDeleteItems, "SYNC: DeleteItems: ");
+_LIT8(KCommandSoftDeleteItems, "SYNC: SoftDeleteItems: ");
+_LIT8(KCommandDeleteAllItems, "SYNC: DeleteAllItems");
+_LIT8(KCommandDeleteAllItemsStatus, "SYNC: GetDeleteAllItemsStatus");
+_LIT8(KCommandGetStoreFormat, "SYNC: GetStoreFormat");
+_LIT8(KCommandSetRemoteStoreFormat, "SYNC: SetRemoteStoreFormat");
+_LIT8(KCommandGetRestOfData, "SYNC: GetRestOfData");
+_LIT8(KCommandCancel, "SYNC: Cancel");
+
+
+_LIT(KRemoteFormatStore, "remoteformatstore_0x%08x.dat");
+_LIT(KDataFileExtension, ".tmp");
+
+const TInt KTimeStampLength = 16;
+_LIT8(KTimeStampFormat, "%02d%02d%04dT%02d%02d%02dZ");
+
+const TInt KDefaultExpandSize = 1024;
+
+// Calendar sync specific constants
+const TInt KCalendarDsUid = 0x101F6DDE;
+
+CSconSyncHandler::~CSconSyncHandler()
+    {
+    TRACE_FUNC_ENTRY;
+    Cancel();
+    iSyncSession.Close();
+    delete iResponseData;
+    iFileStream.Close();
+    iCreatedItems.Close();
+    iReplacedItems.Close();
+    iItemsToRead.Close();
+    iFs.Delete( iFileInProgress );
+    ClearCalendarCenrepL();
+    TRACE_FUNC_EXIT;
+    }
+
+CSconSyncHandler::CSconSyncHandler( RFs& aFs ) 
+    : CActive( EPriorityStandard ), iFs(aFs), iCreatedItemUidPckg(iCreatedItemUid)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+CSconSyncHandler* CSconSyncHandler::NewL( RFs& aFs)
+    {
+    TRACE_FUNC_ENTRY;
+    CSconSyncHandler* self = new (ELeave) CSconSyncHandler(aFs);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+void CSconSyncHandler::ConstructL()
+    {
+    TInt err = iFs.CreatePrivatePath( EDriveC );
+    LOGGER_WRITE_1("CreatePrivatePath err: %d", err);
+    iFs.SetSessionToPrivate( EDriveC );
+    }
+
+void CSconSyncHandler::HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize )
+    {
+    TRACE_FUNC_ENTRY;
+    iMaxObjectSize = aMaxObjectSize;
+    iBytesWrited = 0;
+    LOGGER_WRITE_1("iMaxObjectSize: %d", iMaxObjectSize);
+    if ( !iConnected )
+        {
+        LOGGER_WRITE("Try to connect")
+        User::LeaveIfError( iSyncSession.Connect() );
+        iConnected = ETrue;
+        }
+    
+    if ( aRequest.Compare( KCommandListStores ) == KErrNone )
+        {
+        ListStoresL( aResult );
+        }
+    else if ( aRequest.Find( KCommandOpenStore ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandOpenStore().Length() );
+        OpenStoreL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandCloseStore ) == 0 )
+        {
+        CloseStoreL( aResult );
+        }
+    else if ( aRequest.Find( KCommandListChanges ) == 0 )
+        {
+        ListChangesL( aResult );
+        }
+    else if ( aRequest.Find( KCommandResetChangeInfo ) == 0 )
+        {
+        ResetChangeInfoL( aResult );
+        }
+    else if ( aRequest.Find( KCommandCommitChanges ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandCommitChanges().Length() );
+        CommitChangesL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandReadItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandReadItems().Length() );
+        ReadItemsL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandGetParents ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandGetParents().Length() );
+        GetParentsL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandGetRestOfData ) == 0 )
+        {
+        // Get rest of data
+        ReadNextDataBlockL( aResult );
+        }
+    else if ( aRequest.Find( KCommandGetCreateItemsResponse ) == 0 )
+        {
+        GetCreateItemsResponseL( KNullDesC8(), aResult );
+        }
+    else if ( aRequest.Find( KCommandGetCreateItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandGetCreateItems().Length() );
+        GetCreateItemsResponseL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandGetReplaceItemsResponse ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandGetReplaceItemsResponse().Length() );
+        GetReplaceItemsResponseL( KNullDesC8(), aResult );
+        }
+    else if ( aRequest.Find( KCommandGetReplaceItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandGetReplaceItems().Length() );
+        GetReplaceItemsResponseL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandMoveItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandMoveItems().Length() );
+        MoveItemsL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandDeleteItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandDeleteItems().Length() );
+        DeleteItemsL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandSoftDeleteItems ) == 0 )
+        {
+        TPtrC8 params = aRequest.Mid( KCommandSoftDeleteItems().Length() );
+        SoftDeleteItemsL( params, aResult );
+        }
+    else if ( aRequest.Find( KCommandDeleteAllItems ) == 0 )
+        {
+        DeleteAllItemsL( aResult );
+        }
+    else if ( aRequest.Find( KCommandDeleteAllItemsStatus ) == 0 )
+        {
+        GetDeleteAllItemsStatusL( aResult );
+        }
+    else if ( aRequest.Find( KCommandGetStoreFormat ) == 0 )
+        {
+        GetStoreFormatL( aResult );
+        }
+    else if ( aRequest.Find( KCommandCancel ) == 0 )
+        {
+        CancelOperationsL( aResult );
+        }
+    else    
+        {
+        LOGGER_WRITE("Unknown command");
+        User::Leave( KErrNotSupported );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconSyncHandler::HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iConnected )
+        {
+        LOGGER_WRITE("Try to connect")
+        User::LeaveIfError( iSyncSession.Connect() );
+        iConnected = ETrue;
+        }
+    if ( aRequest.Find( KCommandCreateItems ) == KErrNone )
+        {
+        CreateItemsL( aData );
+        }
+    else if ( aRequest.Find( KCommandReplaceItems ) == 0 )
+        {
+        ReplaceItemsL( aData );
+        }
+    else if ( aRequest.Find( KCommandSetRemoteStoreFormat ) == 0 )
+        {
+        SetRemoteStoreFormatL( aData );
+        }
+    else
+        {
+        LOGGER_WRITE("Unknown command");
+        User::Leave( KErrNotSupported );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ListStoresL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    RSconDataProviderInfoArray infoArray(5);
+    CleanupResetAndDestroyPushL( infoArray );
+    iSyncSession.ListAllImplementationsL( infoArray );
+    LOGGER_WRITE_1("infoArray.Count(): %d", infoArray.Count());
+    aResult.WriteInt32L( infoArray.Count() );
+    for (TInt i=0; i<infoArray.Count(); i++ )
+        {
+        CSconDataproviderInfo& info = (*infoArray[i]);
+        info.ExternalizeL( aResult );
+        }
+    CleanupStack::PopAndDestroy( &infoArray );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::OpenStoreL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE8_1("Params:'%S'", &aParams);
+    
+    const TUint8* ptr = aParams.Ptr();
+    LOGGER_WRITE_1("Params size: %d", aParams.Size())
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+
+    TInt providerId = stream.ReadInt32L();
+    LOGGER_WRITE_1("Provider Id: 0x%08x", providerId);
+    TInt contextId = stream.ReadInt32L();
+    LOGGER_WRITE_1("Context Id: 0x%08x", contextId);
+    
+    // read utf8 formatted text
+    TInt len = stream.ReadUint16L();
+    
+    LOGGER_WRITE_1("storeName length: %d", len);
+    HBufC8* buf8 = HBufC8::NewLC( len );
+    TPtr8 bufPtr8 = buf8->Des();
+    stream.ReadL( bufPtr8, len );
+    
+    LOGGER_WRITE8_1("storeName8: %S", &bufPtr8);
+    
+    // and convert it to unicode
+    HBufC* storeName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( bufPtr8 ); 
+    CleanupStack::PopAndDestroy( buf8 );
+    CleanupStack::PushL( storeName );
+    
+    TPtr storeNamePtr = storeName->Des();
+    LOGGER_WRITE_1("storeName: %S", &storeNamePtr);
+    
+    if ( providerId == KCalendarDsUid && aParams.Size() >
+            sizeof(TInt32) // providerId
+            + sizeof(TInt32) // contextId
+            + sizeof(TUint16)// storeName len
+            + len )          // storeName
+        {
+        TInt profileId = stream.ReadInt32L();
+        len = stream.ReadUint16L();
+        HBufC8* buffer = HBufC8::NewLC( len );
+        TPtr8 bufferPtr8 = buffer->Des();
+        stream.ReadL( bufferPtr8, len );
+        HBufC* serverId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( bufferPtr8 ); 
+        CleanupStack::PopAndDestroy( buffer );
+        CleanupStack::PushL( serverId );
+        SetCalendarCenrepL( profileId, serverId->Des() );
+        CleanupStack::PopAndDestroy(serverId);
+        }
+    
+    aResult.WriteUint16L( KFormatVersionNumber );
+    TRAPD( err, iSyncSession.OpenDataStoreL( providerId, storeName->Des(), contextId));
+    if ( err == KErrServerTerminated )
+        {
+        // server terminated, try to reconnect
+        iConnected = EFalse;
+        LOGGER_WRITE("Try to re-connect");
+        err = iSyncSession.Connect();
+        LOGGER_WRITE_1("iSyncSession.Connect() err: %d", err);
+        if ( !err )
+            {
+            iConnected = ETrue;
+            TRAP( err, iSyncSession.OpenDataStoreL( providerId, storeName->Des(), contextId));
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( storeName );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    aResult.WriteInt32L( err );
+    
+    if ( err )
+        {
+        LOGGER_WRITE_1("Error: %d", err);
+        LOGGER_WRITE("iSyncSession.CloseDataStore()");
+        iSyncSession.CloseDataStore();
+        ClearCalendarCenrepL();
+        return;
+        }
+    iCurrentDataProviderUid = providerId;
+    iCurrentContextUid = contextId;
+    
+    
+    // Now the store is opened
+    TRAP(err, LoadRemoteStoreFormatL( contextId, providerId ));
+    if ( err )
+        {
+        aResult.WriteUint8L( 1 ); //  Remote store format needed
+        }
+    else
+        {
+        aResult.WriteUint8L( 0 ); //  Remote store format not needed
+        }
+    
+    // return last sync timestamp, if has synced before.
+    TBool hasHistory = iSyncSession.HasSyncHistoryL();
+    TUint8 historyFlag(0);
+    if ( hasHistory )
+        {
+        historyFlag = 1;
+        }
+    aResult.WriteUint8L( historyFlag );
+    
+    if ( hasHistory )
+        {
+        TDateTime timeStamp;
+        TInt err(KErrNone);
+        TRAP(err, iSyncSession.GetSyncTimeStampL( providerId, contextId, timeStamp));
+        LOGGER_WRITE_1("GetSyncTimeStampL err: %d", err);
+        
+        TBuf8<KTimeStampLength> timeStampBuf;
+        
+        timeStampBuf.Format( KTimeStampFormat, 
+                timeStamp.Day()+1,timeStamp.Month()+1, timeStamp.Year(),
+                timeStamp.Hour(), timeStamp.Minute(), timeStamp.Second() );
+        LOGGER_WRITE8_1("timeStamp: %S", &timeStampBuf);
+        aResult.WriteL( timeStampBuf );
+        }
+    
+    
+    //  for testin purposes only
+    /*
+    if (!remoteStoreSetted)
+        {
+        RStringPool pool;
+        pool.OpenL();
+        CleanupClosePushL( pool );
+        CSmlDataStoreFormat* storeFormat(NULL);
+        TRAPD( err, storeFormat = iSyncSession.StoreFormatL( pool ) );
+        CleanupStack::PushL( storeFormat );
+        
+        iSyncSession.SetRemoteStoreFormatL( *storeFormat );
+        SaveRemoteStoreFormatL( *storeFormat, contextId, providerId );
+        
+        CleanupStack::PopAndDestroy( storeFormat );
+        CleanupStack::PopAndDestroy( &pool );
+        }
+    */
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::LoadRemoteStoreFormatL( TInt aContextId, TInt aProviderId )
+    {
+    TRACE_FUNC_ENTRY;
+    TFileName remoteFormatStore;
+    iFs.SetSessionToPrivate( EDriveC );
+    remoteFormatStore.Format( KRemoteFormatStore, aContextId );
+       
+    CDictionaryFileStore* dictionaryStore =
+        CDictionaryFileStore::OpenLC(iFs, remoteFormatStore, TUid::Uid(0x0001));
+    TBool present = dictionaryStore->IsPresentL( TUid::Uid(aProviderId) );
+    if ( !present )
+        {
+        LOGGER_WRITE("Remote store was not saved");
+        User::Leave( KErrNotFound );
+        }
+    else
+        {
+        RDictionaryReadStream stream;
+        stream.OpenLC( *dictionaryStore, TUid::Uid(aProviderId) );
+        RStringPool stringPool;
+        stringPool.OpenL();
+        CleanupClosePushL( stringPool );
+        CSmlDataStoreFormat* storeFormat = CSmlDataStoreFormat::NewLC(stringPool, stream);
+        iSyncSession.SetRemoteStoreFormatL( *storeFormat );
+        CleanupStack::PopAndDestroy( storeFormat );
+        CleanupStack::PopAndDestroy( &stringPool );
+        CleanupStack::PopAndDestroy(); //OpenLC
+        }
+    CleanupStack::PopAndDestroy( dictionaryStore );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::SaveRemoteStoreFormatL( CSmlDataStoreFormat& aStoreFormat, TInt aContextId, TInt aProviderId)
+    {
+    TRACE_FUNC_ENTRY;
+    iFs.SetSessionToPrivate( EDriveC );
+    TFileName remoteFormatStore;
+    remoteFormatStore.Format( KRemoteFormatStore, aContextId );
+    CDictionaryFileStore* dictionaryStore =
+        CDictionaryFileStore::OpenLC(iFs, remoteFormatStore, TUid::Uid(0x0001));
+    
+    RDictionaryWriteStream stream;
+    stream.AssignLC( *dictionaryStore, TUid::Uid(aProviderId) );
+    
+    aStoreFormat.ExternalizeL( stream );
+    stream.CommitL();
+    CleanupStack::PopAndDestroy(); //AssignLC
+    dictionaryStore->CommitL();
+        
+    CleanupStack::PopAndDestroy( dictionaryStore );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::CloseStoreL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    iSyncSession.CloseDataStore();
+    ClearCalendarCenrepL();
+    
+    // Get last used timestamp if provider was open
+    if ( iCurrentDataProviderUid != 0 )
+        {
+        TDateTime timeStamp;
+        iSyncSession.GetSyncTimeStampL(iCurrentDataProviderUid, iCurrentContextUid, timeStamp );
+        
+        iCurrentDataProviderUid = 0;
+        iCurrentContextUid = 0;
+        
+        const TInt KTimeStampLength = 16;
+        TBuf8<KTimeStampLength> timeStampBuf;
+        
+        
+        timeStampBuf.Format( KTimeStampFormat, 
+                timeStamp.Day()+1,timeStamp.Month()+1, timeStamp.Year(),
+                timeStamp.Hour(), timeStamp.Minute(), timeStamp.Second() );
+        aResult.WriteL( timeStampBuf );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ListChangesL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    RArray<TSmlDbItemUid> items;
+    CleanupClosePushL( items );
+    
+    iSyncSession.AddedItemsL( items );
+    LOGGER_WRITE_1("Added items count: %d", items.Count());
+    aResult.WriteInt32L( items.Count() );
+    for (TInt i=0; i<items.Count(); i++ )
+        {
+        aResult.WriteInt32L( items[i] );
+        }
+    
+    items.Reset();
+    iSyncSession.ModifiedItemsL( items );
+    LOGGER_WRITE_1("Modified items count: %d", items.Count());
+    aResult.WriteInt32L( items.Count() );
+    for (TInt i=0; i<items.Count(); i++ )
+        {
+        aResult.WriteInt32L( items[i] );
+        }
+    
+    items.Reset();
+    iSyncSession.MovedItemsL( items );
+    LOGGER_WRITE_1("Moved items count: %d", items.Count());
+    aResult.WriteInt32L( items.Count() );
+    for (TInt i=0; i<items.Count(); i++ )
+        {
+        aResult.WriteInt32L( items[i] );
+        }
+    
+    items.Reset();
+    iSyncSession.DeletedItemsL( items );
+    LOGGER_WRITE_1("Deleted items count: %d", items.Count());
+    aResult.WriteInt32L( items.Count() );
+    for (TInt i=0; i<items.Count(); i++ )
+        {
+        aResult.WriteInt32L( items[i] );
+        }
+    
+    items.Reset();
+    iSyncSession.SoftDeletedItemsL( items );
+    LOGGER_WRITE_1("SoftDeleted items count: %d", items.Count());
+    aResult.WriteInt32L( items.Count() );
+    for (TInt i=0; i<items.Count(); i++ )
+        {
+        aResult.WriteInt32L( items[i] );
+        }
+    CleanupStack::PopAndDestroy( &items );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ResetChangeInfoL( RWriteStream& /*aResult*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    iSyncSession.ResetChangeInfoL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::CommitChangesL( const TDesC8& aParams, RWriteStream& /*aResult*/ )
+    {
+    TRACE_FUNC_ENTRY;
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    TInt itemCount = stream.ReadInt32L();
+    RArray<TSmlDbItemUid> items;
+    CleanupClosePushL( items );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        items.AppendL( stream.ReadInt32L() );
+        }
+    
+    if ( items.Count() > 0 )
+        {
+        iSyncSession.CommitChangeInfoL( items );
+        }
+    
+    CleanupStack::PopAndDestroy( &items );
+    CleanupStack::PopAndDestroy( &stream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ReadItemsL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    iItemsToRead.Reset();
+    LOGGER_WRITE_1("aParams length: %d", aParams.Length());
+    
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    // Read item uids from parameter
+    TInt itemCount = stream.ReadInt32L();
+    LOGGER_WRITE_1("Item count: %d", itemCount);
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        iItemsToRead.AppendL( stream.ReadInt32L() );
+        LOGGER_WRITE_2("Item[%d] = %d", i, iItemsToRead[i] );
+        }
+    CleanupStack::PopAndDestroy( &stream );
+    LOGGER_WRITE( "Items readed ok" );
+    
+    aResult.WriteInt32L( iItemsToRead.Count() );
+    iBytesWrited += sizeof(TInt32);
+    
+    ReadNextDataBlockL( aResult );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::GetParentsL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    // Read item uids from parameter
+    TInt itemCount = stream.ReadInt32L();
+    aResult.WriteInt32L( itemCount );
+    LOGGER_WRITE_1("Item count: %d", itemCount);
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        TSmlDbItemUid itemUid = stream.ReadInt32L();
+        TSmlDbItemUid parent(KErrNotFound);
+        aResult.WriteInt32L( itemUid );
+        TInt err = iSyncSession.GetParent( itemUid, parent);
+        LOGGER_WRITE_1("itemUid: %d", itemUid);
+        LOGGER_WRITE_1("err: %d", err);
+        aResult.WriteInt32L( err );
+        if ( err == KErrNone )
+            {
+            LOGGER_WRITE_1("parent: %d", parent);
+            aResult.WriteInt32L( parent );
+            }
+        }
+    CleanupStack::PopAndDestroy( &stream );
+    aResult.CommitL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ReadNextDataBlockL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( (!iResponseData || iResponseData->Size() == 0 ) && iItemsToRead.Count() == 0 )
+        {
+        // no data
+        LOGGER_WRITE("no more data or items");
+        User::Leave(KErrEof);
+        }
+    
+    if ( iResponseData )
+        {
+        // write data from tempbuffer to response buffer
+        TInt writeLength = iResponseData->Size();
+        if ( writeLength > iMaxObjectSize-iBytesWrited )
+            {
+            writeLength = iMaxObjectSize-iBytesWrited;
+            }
+        aResult.WriteL( iResponseData->Ptr(0), writeLength );
+        iBytesWrited += writeLength;
+        
+        if ( iResponseData->Size()  > writeLength )
+            {
+            iResponseData->Delete(0, writeLength);
+            }
+        else
+            {
+            iResponseData->Reset();
+            }
+        }
+    if ( iBytesWrited == iMaxObjectSize )
+        {
+        // responce buffer is full, return it.
+        LOGGER_WRITE("Stream is full, return it");
+        return;
+        }
+    
+    TBool streamIsFull( EFalse );
+    // Read items from server
+    CBufFlat* dataBuffer = CBufFlat::NewL(KDefaultExpandSize);
+    CleanupStack::PushL( dataBuffer );
+    while ( iItemsToRead.Count() > 0 && !streamIsFull )
+        {
+        if ( iMaxObjectSize-iBytesWrited < sizeof(TUint32) )
+            {
+            streamIsFull = ETrue;
+            LOGGER_WRITE("Stream is full, don't read next item");
+            continue;
+            }
+        ReadItemL( iItemsToRead[0], *dataBuffer );
+        aResult.WriteUint32L( dataBuffer->Size() );
+        iBytesWrited += sizeof( TUint32 );
+        
+        TInt writeLength = dataBuffer->Size();
+        if ( writeLength > iMaxObjectSize-iBytesWrited )
+            {
+            writeLength = iMaxObjectSize-iBytesWrited;
+            LOGGER_WRITE_1("Write only %d bytes", writeLength);
+            }
+        aResult.WriteL( dataBuffer->Ptr(0), writeLength );
+        iBytesWrited += writeLength;
+        
+        if ( dataBuffer->Size()  > writeLength )
+            {
+            // write rest to next data block
+            if ( !iResponseData )
+                {
+                iResponseData = CBufFlat::NewL(KDefaultExpandSize);
+                }
+            iResponseData->Reset();
+            LOGGER_WRITE_1("Save %d bytes for next request", dataBuffer->Size() - writeLength);
+            iResponseData->ResizeL( dataBuffer->Size() - writeLength );
+            iResponseData->Write(0, dataBuffer->Ptr( writeLength ));
+            streamIsFull = ETrue;
+            }
+        
+        iItemsToRead.Remove(0);
+        
+        if ( iBytesWrited == iMaxObjectSize )
+            {
+            // writestream is full
+            LOGGER_WRITE("Stream is full");
+            streamIsFull = ETrue;
+            }
+        
+        }
+    aResult.CommitL();
+    
+    CleanupStack::PopAndDestroy( dataBuffer );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ReadItemL( TSmlDbItemUid aUid, CBufFlat& aItemData )
+    {
+    TRACE_FUNC_ENTRY;
+    aItemData.Reset();
+    CBufFlat* dataBuffer = CBufFlat::NewL(KDefaultExpandSize);
+    CleanupStack::PushL( dataBuffer );
+    TSmlDbItemUid parent(-1);
+    TBool fieldChange(EFalse);
+    
+    TBuf8<256> mimeType;
+    TBuf8<100> mimeVer;
+    TRAPD( err, iSyncSession.OpenItemL( aUid, fieldChange,
+                    parent, mimeType, mimeVer, *dataBuffer ));
+    if ( err )
+        {
+        LOGGER_WRITE_1("Could not read item %d", aUid);
+        // only item uid and errorcode will be writed
+        aItemData.ResizeL( 
+            sizeof(TInt32) +
+            sizeof(TInt32));
+        
+        }
+    else
+        {
+        // reserve memory for all fields
+        aItemData.ResizeL( 
+            sizeof(TInt32) +
+            sizeof(TInt32) +
+            sizeof(TUint8) +
+            sizeof(TInt32) +
+            sizeof(TUint16) +
+            mimeType.Length() +
+            sizeof(TUint16) +
+            mimeVer.Length() +
+            sizeof(TInt32) +
+            dataBuffer->Size()
+            );
+        }
+    
+    RBufWriteStream tempStream( aItemData );
+    CleanupClosePushL( tempStream );
+    tempStream.WriteInt32L( aUid );
+    tempStream.WriteInt32L( err );
+    if ( !err )
+        {
+        tempStream.WriteUint8L( fieldChange );
+        tempStream.WriteInt32L( parent );
+        tempStream.WriteUint16L( mimeType.Length() );
+        tempStream.WriteL( mimeType );
+        tempStream.WriteUint16L( mimeVer.Length() );
+        tempStream.WriteL( mimeVer );
+        tempStream.WriteInt32L( dataBuffer->Size() );
+        tempStream.WriteL( dataBuffer->Ptr(0), dataBuffer->Size() );
+        }
+    tempStream.CommitL();
+    CleanupStack::PopAndDestroy( &tempStream );
+    CleanupStack::PopAndDestroy( dataBuffer );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::CreateItemsL( RReadStream& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    delete iResponseData;
+    iResponseData = NULL;
+    iResponseData = CBufFlat::NewL(KDefaultExpandSize);
+    RBufWriteStream responseStream( *iResponseData );
+    CleanupClosePushL( responseStream );
+    // Read item uids from parameter
+    TInt itemCount = aData.ReadInt32L();
+    LOGGER_WRITE_1("itemCount: %d", itemCount);
+    responseStream.WriteInt32L( itemCount );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        LOGGER_WRITE("read from aData stream");
+        TInt tempUid = aData.ReadInt32L();
+        
+        TSmlDbItemUid parent = aData.ReadInt32L();
+        
+        TInt len = aData.ReadUint16L();
+        HBufC8* mimeTypeBuf = HBufC8::NewLC( len );
+        TPtr8 mimeTypePtr = mimeTypeBuf->Des();
+        aData.ReadL(mimeTypePtr, len);
+        
+        len = aData.ReadUint16L();
+        HBufC8* mimeVerBuf = HBufC8::NewLC( len );
+        TPtr8 mimeVerPtr = mimeVerBuf->Des();
+        aData.ReadL(mimeVerPtr, len);
+        
+        len = aData.ReadInt32L();
+        HBufC8* dataBuf = HBufC8::NewLC( len );
+        TPtr8 dataPtr = dataBuf->Des();
+        aData.ReadL( dataPtr, len );
+        
+        TSmlDbItemUid newUid(-1);
+        LOGGER_WRITE("read from aData stream -readed ok");
+        TRAPD( err, iSyncSession.CreateItemL(newUid,
+                parent, mimeTypePtr,
+                mimeVerPtr, dataPtr));
+        
+        CleanupStack::PopAndDestroy( dataBuf );
+        CleanupStack::PopAndDestroy( mimeVerBuf );
+        CleanupStack::PopAndDestroy( mimeTypeBuf );
+        LOGGER_WRITE("Write to responseStream");
+        responseStream.WriteInt32L( tempUid );
+        responseStream.WriteInt32L( err );
+        if ( !err )
+            {
+            responseStream.WriteInt32L( newUid );
+            }
+        LOGGER_WRITE("Write to responseStream -writed ok");
+        }
+    
+    responseStream.CommitL();
+    CleanupStack::PopAndDestroy( &responseStream );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::GetCreateItemsResponseL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aParams.Length() > 0 )
+        {
+        LOGGER_WRITE_1("params length: %d", aParams.Length());
+        
+        //LOGGER_WRITE8_1("aParams: %S", &aParams);
+        if ( iSyncStatus == EReady )
+            {
+            LOGGER_WRITE("Start creating items from file");
+            iCreatedItems.Reset();
+            const TUint8* ptr = aParams.Ptr();
+            RMemReadStream stream( ptr , aParams.Size() );
+            CleanupClosePushL( stream );
+            TInt filenameLength = stream.ReadInt32L();
+            LOGGER_WRITE_1("filename length: %d", filenameLength );
+            HBufC8* filenameBuf8 = HBufC8::NewLC( /*stream,*/ filenameLength ); // filename
+            TPtr8 filenamePtr = filenameBuf8->Des();
+            stream.ReadL( filenamePtr, filenameLength);
+            LOGGER_WRITE("filename ok");
+            TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileInProgress, filenamePtr );
+            LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 err: %d", err);
+            User::LeaveIfError( err );
+            LOGGER_WRITE_1("iFileInProgress: %S", &iFileInProgress);
+            
+            if ( iFileInProgress.RightTPtr(KDataFileExtension().Length()).CompareF(KDataFileExtension) != 0 )
+                {
+                iFileInProgress = KNullDesC();
+                LOGGER_WRITE("File extendion was not correct");
+                User::Leave( KErrAccessDenied );
+                }
+            
+            CleanupStack::PopAndDestroy( filenameBuf8 );
+			
+            LOGGER_WRITE("open file");
+            err = iFileStream.Open(iFs,iFileInProgress, EFileShareReadersOnly);
+            LOGGER_WRITE_1("iFileStream.Open err: %d", err);
+            User::LeaveIfError( err );
+            
+            CleanupStack::PopAndDestroy( &stream );
+            
+            iSyncStatus = ECreatingItemsFromFile;
+            iItemsLeftInStream = iFileStream.ReadInt32L();
+            LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream);
+            aResult.WriteInt32L( iItemsLeftInStream );
+            aResult.WriteInt32L( 0 ); // completed items since last sync
+            CreateNextItemOnStreamL();
+            iItemsLeftInStream--;
+            }
+        else if ( iSyncStatus == ECreatingItemsFromFile || iSyncStatus == EItemsCreated )
+            {
+            LOGGER_WRITE("Read status");
+            TInt temp = 0;
+            if ( iSyncStatus == ECreatingItemsFromFile )
+                {
+                // one item is on progress, add it to to "left" items.
+                temp = 1;
+                }
+            LOGGER_WRITE_1("left items: %d", iItemsLeftInStream + temp);
+            LOGGER_WRITE_1("completed items: %d", iCreatedItems.Count());
+            aResult.WriteInt32L( iItemsLeftInStream + temp ); // items in progress
+            aResult.WriteInt32L( iCreatedItems.Count() ); // completed items since last get
+            
+            while ( iCreatedItems.Count() > 0 )
+                {
+                aResult.WriteInt32L( iCreatedItems[0].iTemporaryId );
+                aResult.WriteInt32L( iCreatedItems[0].iErrorCode );
+                if ( !iCreatedItems[0].iErrorCode )
+                    {
+                    aResult.WriteInt32L( iCreatedItems[0].iNewUid );
+                    }
+                iCreatedItems.Remove(0);
+                }
+            if ( iSyncStatus == EItemsCreated )
+                {
+                // all done
+                iSyncStatus = EReady;
+                LOGGER_WRITE("iSyncStatus = EReady");
+                }
+            }
+        else
+            {
+            LOGGER_WRITE_1("Wrong sync status: %d", iSyncStatus);
+            User::Leave( KErrInUse );
+            }
+        }
+    else
+        {
+        LOGGER_WRITE("Read response");
+        if ( !iResponseData )
+            {
+            User::Leave( KErrNotReady );
+            }
+        aResult.WriteL( iResponseData->Ptr(0), iResponseData->Size() );
+        delete iResponseData;
+        iResponseData = NULL;
+        }
+    aResult.CommitL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ReplaceItemsL( RReadStream& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    delete iResponseData;
+    iResponseData = NULL;
+    iResponseData = CBufFlat::NewL(KDefaultExpandSize);
+    RBufWriteStream responseStream( *iResponseData );
+    CleanupClosePushL( responseStream );
+    // Read item uids from parameter
+    TInt itemCount = aData.ReadInt32L();
+    
+    responseStream.WriteInt32L( itemCount );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        TSmlDbItemUid uid = aData.ReadInt32L();
+        TSmlDbItemUid parent = aData.ReadInt32L();
+        TBool fieldChange = aData.ReadUint8L();
+        TInt len = aData.ReadInt32L();
+        HBufC8* dataBuf = HBufC8::NewLC( len );
+        TPtr8 dataPtr = dataBuf->Des();
+        aData.ReadL( dataPtr, len );
+        
+        TRAPD( err, iSyncSession.ReplaceItemL(uid, 
+                parent, 
+                fieldChange, dataPtr));
+        CleanupStack::PopAndDestroy( dataBuf );
+        
+        responseStream.WriteInt32L( uid );
+        responseStream.WriteInt32L( err );
+        }
+    responseStream.CommitL();
+    CleanupStack::PopAndDestroy( &responseStream );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::GetReplaceItemsResponseL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aParams.Length() > 0 )
+        {
+        LOGGER_WRITE8_1("aParams: %S", &aParams);
+        if ( iSyncStatus == EReady )
+            {
+            LOGGER_WRITE("Start replacing items from file");
+            iReplacedItems.Reset();
+            
+            // create parameter stream reader
+            const TUint8* ptr = aParams.Ptr();
+            RMemReadStream stream( ptr , aParams.Size() );
+            CleanupClosePushL( stream );
+            
+            // read filename
+            TInt filenameLength = stream.ReadInt32L();
+            LOGGER_WRITE_1("filename length: %d", filenameLength );
+            HBufC8* filenameBuf8 = HBufC8::NewLC( filenameLength ); // filename
+            TPtr8 filenamePtr = filenameBuf8->Des();
+            stream.ReadL( filenamePtr, filenameLength);
+            LOGGER_WRITE("filename ok");
+            
+            TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileInProgress, filenameBuf8->Des() );
+            LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 err: %d", err);
+            User::LeaveIfError( err );
+            if ( iFileInProgress.RightTPtr(KDataFileExtension().Length()).CompareF(KDataFileExtension) != 0 )
+                {
+                iFileInProgress = KNullDesC();
+                LOGGER_WRITE("File extendion was not correct");
+                User::Leave( KErrAccessDenied );
+                }
+            
+            // open file
+            err = iFileStream.Open(iFs, iFileInProgress, EFileShareReadersOnly);
+            LOGGER_WRITE_1("iFileStream.Open err: %d", err);
+            User::LeaveIfError( err );
+            
+            CleanupStack::PopAndDestroy( filenameBuf8 );
+            CleanupStack::PopAndDestroy( &stream );
+            
+            iSyncStatus = EReplacingItemsFromFile;
+            iItemsLeftInStream = iFileStream.ReadInt32L();
+            LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream);
+            // write results to return stream
+            aResult.WriteInt32L( iItemsLeftInStream );
+            aResult.WriteInt32L( 0 ); // completed items since last sync
+            ReplaceNextItemOnStreamL();
+            iItemsLeftInStream--;
+            }
+        else if ( iSyncStatus == EReplacingItemsFromFile || iSyncStatus == EItemsReplaced )
+            {
+            LOGGER_WRITE("Read status");
+            TInt temp = 0;
+            if ( iSyncStatus == EReplacingItemsFromFile )
+                {
+                // one item is on progress, add it to to "left" items.
+                temp = 1;
+                }
+            LOGGER_WRITE_1("left items: %d", iItemsLeftInStream + temp);
+            LOGGER_WRITE_1("completed items: %d", iReplacedItems.Count());
+            aResult.WriteInt32L( iItemsLeftInStream + temp ); // items in progress
+            aResult.WriteInt32L( iReplacedItems.Count() ); // completed items since last get
+            //for (TInt i=0; i<iCreatedItems.Count(); i++)
+            while ( iReplacedItems.Count() > 0 )
+                {
+                aResult.WriteInt32L( iReplacedItems[0].iItemUid );
+                aResult.WriteInt32L( iReplacedItems[0].iErrorCode );
+                iReplacedItems.Remove(0);
+                }
+            if ( iSyncStatus == EItemsReplaced )
+                {
+                // all done
+                iSyncStatus = EReady;
+                LOGGER_WRITE("iSyncStatus = EReady");
+                }
+            }
+        }
+    else
+        {
+        if ( !iResponseData )
+            {
+            LOGGER_WRITE("No response data, leave KErrNotReady");
+            User::Leave( KErrNotReady );
+            }
+        aResult.WriteL( iResponseData->Ptr(0), iResponseData->Size() );
+        aResult.CommitL();
+        delete iResponseData;
+        iResponseData = NULL;
+        }
+    aResult.CommitL();
+    
+    
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::MoveItemsL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;  
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    // Read item uids from parameter
+    TInt itemCount = stream.ReadInt32L();
+    aResult.WriteInt32L( itemCount );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        TSmlDbItemUid uid = stream.ReadInt32L();
+        TSmlDbItemUid newParent = stream.ReadInt32L();
+        TRAPD( err, iSyncSession.MoveItemL( uid,newParent ));
+        
+        aResult.WriteInt32L( uid );
+        aResult.WriteInt32L( err );
+        }
+    aResult.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::DeleteItemsL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    // Read item uids from parameter
+    TInt itemCount = stream.ReadInt32L();
+    aResult.WriteInt32L( itemCount );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        TSmlDbItemUid uid = stream.ReadInt32L();
+        
+        TRAPD( err, iSyncSession.DeleteItemL( uid ));
+        
+        aResult.WriteInt32L( uid );
+        aResult.WriteInt32L( err );
+        }
+    aResult.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::SoftDeleteItemsL( const TDesC8& aParams, RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    const TUint8* ptr = aParams.Ptr();
+    RMemReadStream stream( ptr , aParams.Size() );
+    CleanupClosePushL( stream );
+    
+    // Read item uids from parameter
+    TInt itemCount = stream.ReadInt32L();
+    aResult.WriteInt32L( itemCount );
+    for ( TInt i=0; i<itemCount; i++ )
+        {
+        TSmlDbItemUid uid = stream.ReadInt32L();
+        
+        TRAPD( err, iSyncSession.SoftDeleteItemL( uid ));
+        
+        aResult.WriteInt32L( uid );
+        aResult.WriteInt32L( err );
+        }
+    aResult.CommitL();
+    CleanupStack::PopAndDestroy( &stream );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::DeleteAllItemsL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( IsActive() )
+        {
+        LOGGER_WRITE("Warning: Was on active state!");
+        Cancel();
+        }
+    SetActive();
+    iStatus = KRequestPending;
+    iSyncStatus = EDeletingAllItems;
+    iSyncSession.DeleteAllItems( iStatus );
+    aResult.WriteInt32L( KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::GetDeleteAllItemsStatusL( RWriteStream& aResult )
+    {
+    if ( iSyncStatus == EDeletingAllItems )
+        {
+        LOGGER_WRITE("CSconSyncHandler::GetDeleteAllItemsStatusL - In progress");
+        aResult.WriteInt8L( 1 ); // 1 = in progress
+        }
+    else
+        {
+        LOGGER_WRITE("CSconSyncHandler::GetDeleteAllItemsStatusL - Ready");
+        aResult.WriteInt8L( 0 ); // 0 = ready
+        aResult.WriteInt32L( iStatus.Int() );
+        }
+    }
+
+void CSconSyncHandler::GetStoreFormatL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    RStringPool pool;
+    pool.OpenL();
+    CleanupClosePushL( pool );
+    CSmlDataStoreFormat* storeFormat(NULL);
+    TRAPD( err, storeFormat = iSyncSession.StoreFormatL( pool ) );
+    CleanupStack::PushL( storeFormat );
+    aResult.WriteInt32L( err );
+    if ( !err )
+        {
+        storeFormat->ExternalizeL( aResult );
+        }
+    CleanupStack::PopAndDestroy( storeFormat );
+    CleanupStack::PopAndDestroy( &pool );
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSconSyncHandler::SetRemoteStoreFormatL( RReadStream& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    RStringPool pool;
+    pool.OpenL();
+    CleanupClosePushL( pool );
+    CSmlDataStoreFormat* serverDataStoreFormat = CSmlDataStoreFormat::NewLC( pool, aData );
+    iSyncSession.SetRemoteStoreFormatL( *serverDataStoreFormat );
+    // Save format for later use
+    TRAPD(err, SaveRemoteStoreFormatL( *serverDataStoreFormat, iCurrentContextUid, iCurrentDataProviderUid ));
+    if ( err )
+        {
+        LOGGER_WRITE_1("SaveRemoteStoreFormatL err: %d", err);
+        }
+    CleanupStack::PopAndDestroy( serverDataStoreFormat );
+    CleanupStack::PopAndDestroy( &pool );
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::CreateNextItemOnStreamL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( IsActive() )
+        {
+        LOGGER_WRITE("Warning: Was on active state!");
+        Cancel();
+        }
+    iTemporaryItemUid = iFileStream.ReadInt32L();
+    TSmlDbItemUid parent = iFileStream.ReadInt32L();
+    
+    TInt len = iFileStream.ReadUint16L();
+    HBufC8* mimeTypeBuf = HBufC8::NewLC( len );
+    TPtr8 mimeTypePtr = mimeTypeBuf->Des();
+    iFileStream.ReadL(mimeTypePtr, len);
+    
+    len = iFileStream.ReadUint16L();
+    HBufC8* mimeVerBuf = HBufC8::NewLC( len );
+    TPtr8 mimeVerPtr = mimeVerBuf->Des();
+    iFileStream.ReadL(mimeVerPtr, len);
+    
+    len = iFileStream.ReadInt32L();
+    HBufC8* dataBuf = HBufC8::NewLC( len );
+    TPtr8 dataPtr = dataBuf->Des();
+    iFileStream.ReadL( dataPtr, len );    
+    
+    SetActive();
+    iStatus = KRequestPending;
+    iSyncSession.CreateItemL(iCreatedItemUidPckg,
+            parent, mimeTypePtr,
+            mimeVerPtr, dataPtr, iStatus);
+    
+    CleanupStack::PopAndDestroy( dataBuf );
+    CleanupStack::PopAndDestroy( mimeVerBuf );
+    CleanupStack::PopAndDestroy( mimeTypeBuf );
+    
+   
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::ReplaceNextItemOnStreamL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( IsActive() )
+        {
+        LOGGER_WRITE("Warning: Was on active state!");
+        Cancel();
+        }
+    TSmlDbItemUid uid = iFileStream.ReadInt32L();
+    TSmlDbItemUid parent = iFileStream.ReadInt32L();
+    TBool fieldChange = iFileStream.ReadUint8L();
+    TInt len = iFileStream.ReadInt32L();
+    HBufC8* dataBuf = HBufC8::NewLC( len );
+    TPtr8 dataPtr = dataBuf->Des();
+    iFileStream.ReadL( dataPtr, len );
+    
+    iReplacedItem.iItemUid = uid;
+    
+    SetActive();
+    iStatus = KRequestPending;
+    
+    iSyncSession.ReplaceItemL(uid, 
+                parent, 
+                fieldChange, dataPtr, iStatus);
+    
+    CleanupStack::PopAndDestroy( dataBuf );
+   
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::CancelOperationsL( RWriteStream& aResult )
+    {
+    TRACE_FUNC_ENTRY;
+    Cancel();
+    // all done
+    iFileStream.Close();
+    iTemporaryItemUid = -1;
+    iCreatedItemUid = -1;
+    iSyncStatus = EItemsCreated;
+    iFs.Delete( iFileInProgress );
+    iFileInProgress = KNullDesC();
+    iItemsLeftInStream = 0;
+    _LIT8(KDummyParam, "Cancel");
+    if ( iSyncStatus == EItemsCreated )
+        {
+        GetCreateItemsResponseL( KDummyParam, aResult );
+        }
+    else if ( iSyncStatus == EItemsReplaced )
+        {
+        GetReplaceItemsResponseL( KDummyParam, aResult );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::DoCancel()
+    {
+    TRACE_FUNC_ENTRY;
+    iSyncSession.CancelRequest();
+    Reset();
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("iSyncStatus: %d", iSyncStatus);
+    LOGGER_WRITE_1("iStatus: %d", iStatus.Int());
+    if ( iSyncStatus == ECreatingItemsFromFile )
+        {
+        LOGGER_WRITE_1("iTemporaryItemUid: %d", iTemporaryItemUid);
+        LOGGER_WRITE_1("iCreatedItemUid: %d", iCreatedItemUid);
+        TCreatedItem item;
+        item.iTemporaryId = iTemporaryItemUid;
+        item.iErrorCode = iStatus.Int();
+        item.iNewUid = iCreatedItemUid;
+        iCreatedItems.Append( item );
+        if ( iItemsLeftInStream > 0 )
+            {
+            CreateNextItemOnStreamL();
+            iItemsLeftInStream--;
+            LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream);
+            }
+        else
+            {
+            // all done
+            LOGGER_WRITE("All items added.");
+            iFileStream.Close();
+            iTemporaryItemUid = -1;
+            iCreatedItemUid = -1;
+            iSyncStatus = EItemsCreated;
+            TInt err = iFs.Delete( iFileInProgress );
+            LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err);
+            iFileInProgress = KNullDesC();
+            }
+        }
+    else if ( iSyncStatus == EReplacingItemsFromFile )
+        {
+        iReplacedItem.iErrorCode = iStatus.Int();
+        iReplacedItems.Append( iReplacedItem );
+        if ( iItemsLeftInStream > 0 )
+            {
+            ReplaceNextItemOnStreamL();
+            iItemsLeftInStream--;
+            LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream);
+            }
+        else
+            {
+            // all done
+            LOGGER_WRITE("All items replaced.");
+            iFileStream.Close();
+            iSyncStatus = EItemsReplaced;
+            TInt err = iFs.Delete( iFileInProgress );
+            LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err);
+            iFileInProgress = KNullDesC();
+            }
+        }
+    else if ( iSyncStatus == EDeletingAllItems )
+        {
+        iSyncStatus = EReady;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+TInt CSconSyncHandler::RunError( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError);
+    LOGGER_WRITE_1("iSyncStatus: %d", iSyncStatus);
+    TInt err( aError );
+    if ( iSyncStatus == ECreatingItemsFromFile )
+        {
+        iSyncStatus = EItemsCreated;
+        iItemsLeftInStream = 0;
+        iFileStream.Close();
+        err = iFs.Delete( iFileInProgress );
+        LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err);
+        iFileInProgress = KNullDesC();
+        err = KErrNone;
+        }
+    else if ( iSyncStatus == EReplacingItemsFromFile )
+        {
+        iSyncStatus = EItemsReplaced;
+        iItemsLeftInStream = 0;
+        iFileStream.Close();
+        err = iFs.Delete( iFileInProgress );
+        LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err);
+        iFileInProgress = KNullDesC();
+        err = KErrNone;
+        }
+    else if ( iSyncStatus == EDeletingAllItems )
+        {
+        iSyncStatus = EReady;
+        }
+    
+    TRACE_FUNC_EXIT;
+    return err;
+    }
+
+void CSconSyncHandler::Reset()
+    {
+    TRACE_FUNC_ENTRY;
+    iFileStream.Close();
+    TInt err = iFs.Delete( iFileInProgress );
+    LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err);
+    iFileInProgress = KNullDesC();
+    iSyncStatus = EReady;
+    TRACE_FUNC_EXIT;
+    }
+
+void CSconSyncHandler::SetCalendarCenrepL( TInt aProfileId, const TDesC& aServerId )
+    {
+    LOGGER_WRITE(" Write cenrep values");
+    CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey);
+    User::LeaveIfError( rep->Set(EDSSessionProfileId, aProfileId) );
+    User::LeaveIfError( rep->Set(EDSSessionProfileName, KNullDesC) );
+    User::LeaveIfError( rep->Set(EDSSessionServerId, aServerId) );
+    CleanupStack::PopAndDestroy(rep);
+    iCalendarCenrepUsed = ETrue;
+    }
+
+void CSconSyncHandler::ClearCalendarCenrepL()
+    {
+    if ( iCalendarCenrepUsed )
+        {
+        LOGGER_WRITE("Calendar sync, clear cenrep values");
+                
+        CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey);
+        rep->Set(EDSSessionProfileId, KErrNotFound);
+        rep->Set(EDSSessionProfileName, KNullDesC);
+        rep->Set(EDSSessionServerId, KNullDesC);
+        CleanupStack::PopAndDestroy(rep);
+        iCalendarCenrepUsed = EFalse;
+        }
+    }
+
--- a/connectivitymodules/SeCon/services/pcd/src/sconvideoparser.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/services/pcd/src/sconvideoparser.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -106,6 +106,7 @@
     User::LeaveIfError( iWindow->Construct(iRootWindow, reinterpret_cast<TUint32>(&iRootWindow) + 1) );
     
     TRect temp(0,0,320,240); // dummy parameter
+    
     iVideoUtil = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone, iWsSession, *iScreen, *iWindow, temp, temp);
     
     iTimeOut = CSconTimeOut::NewL( *this );
--- a/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlgenerator.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlgenerator.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -97,9 +97,7 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::SetCallback ( MWBXMLConMLCallback* aCallback )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::SetCallbacks()" );
     iCallback = aCallback;
-    LOGGER_LEAVEFN( "CSConConMLGenerator::SetCallbacks()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -129,7 +127,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::StartElementL( TWBXMLTag aTag )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::StartElementL()" );
     if( iCmdStack->Top() != 0 )
         {
         AddElementL(iCmdStack->Top()->BeginElementL( 
@@ -150,7 +147,6 @@
             User::Leave(KWBXMLParserErrorInvalidTag);
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::StartElementL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -158,7 +154,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AddElementL( CXMLElement* aElement )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AddElement()" );
     if( aElement )
         {
         iCmdStack->PushL(aElement);
@@ -167,7 +162,6 @@
             iCleanupStack->PushL(aElement);
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AddElement()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -175,7 +169,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::CharactersL( const TDesC8& aBuffer )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::CharactersL()" );
     if( iCmdStack->Top() != 0 )
         {
         iCmdStack->Top()->SetDataL(aBuffer);
@@ -185,7 +178,6 @@
         LOGGER_WRITE( "CSConConMLGenerator::CharactersL() : Leave KWBXMLParserErrorInvalidTag" );
         User::Leave(KWBXMLParserErrorInvalidTag);
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::CharactersL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -193,7 +185,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::EndElementL( TWBXMLTag aTag )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::EndElementL()" );
     if( iCmdStack->Top() != 0 )
         {
         CXMLElement::TAction action = iCmdStack->Top()->EndElementL( 
@@ -211,7 +202,6 @@
                 }
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::EndElementL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -219,7 +209,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::WriteMUint32L( TUint32 aValue )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::WriteMUint32L()" );
     TUint8 temp[5];
     TInt i(4);
     
@@ -235,7 +224,6 @@
         {
         iWBXMLWorkspace->WriteL(temp[++i]);
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteMUint32L()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -243,12 +231,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::WriteOpaqueDataL( const TDesC8& aData )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::WriteOpaqueDataL()" );
     iWBXMLWorkspace->WriteL( OPAQUE );
     WriteMUint32L( aData.Size() );
     iWBXMLWorkspace->WriteL( aData );
     iXMLWorkspace->WriteL( aData );
-    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteOpaqueDataL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -256,12 +242,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::WriteInlineStringL( const TDesC8& aData )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::WriteInlineStringL()" );
     iWBXMLWorkspace->WriteL( STR_I );
     iWBXMLWorkspace->WriteL( aData );
     iWBXMLWorkspace->WriteL( 0 );
     iXMLWorkspace->WriteL( aData );
-    LOGGER_LEAVEFN( "CSConConMLGenerator::WriteInlineStringL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -269,12 +253,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::IndentL()
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::IndentL()" );
     for( TInt i = 0; i < iElemStack.Count() + iInitialIndentLevel; i++ )
         {
         iXMLWorkspace->WriteL(KXMLIndent());
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::IndentL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -282,7 +264,6 @@
 // -----------------------------------------------------------------------------    
 TPtrC8 CSConConMLGenerator::TranslateElement( TUint8 aElement )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::TranslateElement()" );
     TPtrC8 buf( KConMLElements );
     while( aElement-- )
         {
@@ -300,7 +281,6 @@
         {
         buf.Set(buf.Left(pos));
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::TranslateElement()" );
     return buf;
     }
     
@@ -335,7 +315,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendConMLL( ConML_ConMLPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendConMLL()" );
     BeginDocumentL(KSConConMLVersion, KSConConMLPublicId, KSConConMLUTF8);
     BeginElementL(EConML, ETrue);
     AppendExecuteL( aContent->execute );
@@ -343,7 +322,6 @@
     AppendCancelL( aContent->cancel );
     AppendStatusL( aContent->status );
     EndElementL(); // EConML
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendConMLL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -351,7 +329,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendExecuteL( ConML_ExecutePtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendExecuteL()" );
     if ( aContent )
         {
         BeginElementL( EConMLExecute, ETrue );
@@ -375,7 +352,6 @@
             }
         EndElementL(); // EConMLExecute
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendExecuteL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -383,7 +359,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendSupplyDataL( ConML_SupplyDataPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSupplyDataL()" );
     if ( aContent )
         {
         BeginElementL( EConMLSupplyData, ETrue );
@@ -391,14 +366,12 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLSupplyData
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSupplyDataL()" );
     }
 // -----------------------------------------------------------------------------
 // AppendInstallL
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendInstallL( ConML_InstallPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendInstallL()" );
     if ( aContent)
         {
         BeginElementL( EConMLInstall, ETrue );
@@ -417,7 +390,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLInstall
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendInstallL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -425,7 +397,6 @@
 // -----------------------------------------------------------------------------    
 void CSConConMLGenerator::AppendCancelL ( ConML_CancelPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendCancelL()" );
     if ( aContent )
         {
         BeginElementL( EConMLCancel, ETrue );
@@ -433,7 +404,6 @@
         AppendPCDataL( EConMLAll, aContent->all);
         EndElementL(); // EConMLCancel
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendCancelL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -441,7 +411,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendStatusL ( ConML_StatusPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendStatusL()" );
     if ( aContent )
         {
         if ( aContent->task )
@@ -455,7 +424,6 @@
             BeginElementL( EConMLStatus );  
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendStatusL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -463,7 +431,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendGetStatusL( ConML_GetStatusPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetStatusL()" );
     if ( aContent )
         {
         BeginElementL( EConMLGetStatus, ETrue );
@@ -474,7 +441,6 @@
             }
         EndElementL(); // EConMLGetStatus
         }
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetStatusL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -495,7 +461,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendTaskL( ConML_TaskPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendTaskL()" );
     if ( aContent )
         {
         BeginElementL( EConMLTask, ETrue );
@@ -515,7 +480,6 @@
         AppendGetMetadataL( aContent->getMetadata );
         EndElementL();
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendTaskL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -523,12 +487,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendTaskListL( ConML_TaskListPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendTaskListL()" );
     for ( ConML_TaskListPtr_t p = aContent; p && p->data; p=p->next )
         {
         AppendTaskL( p->data );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendTaskListL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -537,7 +499,6 @@
 void CSConConMLGenerator::AppendListInstalledAppsL ( 
     ConML_ListInstalledAppsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListInstalledAppsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLListInstalledApps, ETrue );
@@ -549,7 +510,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLListInstalledApps
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListInstalledAppsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -558,7 +518,6 @@
 void CSConConMLGenerator::AppendListDataOwnersL ( 
     ConML_ListDataOwnersPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListDataOwnersL()" );
     if ( aContent )
         {
         if ( aContent->results )
@@ -572,7 +531,6 @@
             BeginElementL( EConMLListDataOwners );          
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListDataOwnersL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -580,7 +538,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendBUROptionsL( ConML_BUROptionsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendBUROptionsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLBUROptions, ETrue );
@@ -602,7 +559,6 @@
             }
         EndElementL(); // EConMLBUROptions
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendBUROptionsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -610,7 +566,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendSetBURModeL( ConML_SetBURModePtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSetBURModeL()" );
     if ( aContent )
         {
         BeginElementL( EConMLSetBURMode, ETrue );
@@ -620,7 +575,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); //EConMLSetBURMode
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSetBURModeL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -628,7 +582,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendUnInstallL( ConML_UnInstallPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendUnInstallL()" );
     if ( aContent )
         {
         BeginElementL( EConMLUnInstall, ETrue );
@@ -637,7 +590,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLUnInstall
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendUnInstallL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -645,7 +597,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendGetDataSizeL( ConML_GetDataSizePtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetDataSizeL()" );
     if ( aContent )
         {
         BeginElementL( EConMLGetDataSize, ETrue );
@@ -653,7 +604,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); //EConMLGetDataSize
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendGetDataSizeL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -661,7 +611,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendRequestDataL( ConML_RequestDataPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendRequestDataL()" );
     if ( aContent )
         {
         BeginElementL( EConMLRequestData, ETrue );
@@ -669,7 +618,6 @@
         AppendResultsL( aContent->results );
         EndElementL();//EConMLRequestData
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendRequestDataL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -678,7 +626,6 @@
 void CSConConMLGenerator::AppendUpdateDeviceInfoL( 
     ConML_UpdateDeviceInfoPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendUpdateDeviceInfoL()" );
     if ( aContent )
         {
         BeginElementL(EConMLUpdateDeviceInfo, ETrue);
@@ -686,7 +633,6 @@
         AppendResultsL( aContent->results );
         EndElementL();// EConMLUpdateDeviceInfo
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendUpdateDeviceInfoL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -695,7 +641,6 @@
 void CSConConMLGenerator::AppendListPublicFilesL( 
     ConML_ListPublicFilesPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendListPublicFilesL()" );
     if ( aContent )
         {
         BeginElementL( EConMLListPublicFiles, ETrue );
@@ -703,7 +648,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLListPublicFiles
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendListPublicFilesL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -711,7 +655,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendApplicationL( ConML_ApplicationPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationL()" );
     if ( aContent )
         {
         BeginElementL(EConMLApplication, ETrue );
@@ -719,7 +662,6 @@
         AppendPCDataL( EConMLUID, aContent->uid );
         EndElementL(); //EConMLApplication
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -728,12 +670,10 @@
 void CSConConMLGenerator::AppendApplicationListL( 
     ConML_ApplicationListPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationListL()" );
     for ( ConML_ApplicationListPtr_t p = aContent; p && p->data; p = p->next )
         {
         AppendApplicationL( p->data );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationListL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -742,14 +682,12 @@
 void CSConConMLGenerator::AppendApplicationsL( 
     ConML_ApplicationsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendApplicationsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLApplications, ETrue );
         AppendApplicationListL( aContent->application );
         EndElementL(); // EConMLApplications
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendApplicationsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -757,7 +695,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendParamL( ConML_ParamPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendParamL()" );
     if ( aContent )
         {
         BeginElementL( EConMLParam, ETrue );
@@ -765,7 +702,6 @@
         AppendPCDataL( EConMLValue, aContent->value );
         EndElementL(); // EConMLParam
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendParamL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -773,12 +709,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendParamListL( ConML_ParamListPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendParamListL()" );
     for ( ConML_ParamListPtr_t p = aContent; p && p->data; p = p->next )
         {
         AppendParamL( p-> data );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendParamListL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -786,14 +720,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendInstParamsL( ConML_InstParamsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendInstParamsLionsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLInstParams, ETrue );
         AppendParamListL( aContent->param );
         EndElementL(); //EConMLInstParams
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendInstParamsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -801,14 +733,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendProgressL( ConML_ProgressPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendProgressL()" );
     if ( aContent )
         {
         BeginElementL( EConMLProgress, ETrue );
         AppendPCDataL( EConMLValue, aContent->value );
         EndElementL(); // EconMLProgress
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendProgressL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -816,7 +746,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendResultsL( ConML_ResultsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendResultsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLResults, ETrue );
@@ -840,7 +769,6 @@
         AppendFilesL( aContent->files );
         EndElementL(); //EConMLResults
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendResultsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -848,14 +776,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendDriveL( ConML_DrivePtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDriveL()" );
     if ( aContent )
         {
         BeginElementL( EConMLDrive, ETrue );
         AppendPCDataL( EConMLName, aContent->name );
         EndElementL(); //EConMLDrive
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDriveL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -863,12 +789,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendDriveListL( ConML_DriveListPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDriveListL()" );
     for ( ConML_DriveListPtr_t p =  aContent; p && p->data; p=p->next )
         {
         AppendDriveL( p->data );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDriveListL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -876,14 +800,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendDrivesL( ConML_DrivesPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDrivesL()" );
     if ( aContent )
         {
         BeginElementL( EConMLDrives, ETrue );
         AppendDriveListL( aContent->drive );
         EndElementL(); // EConMLDrives
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDrivesL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -891,14 +813,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendDataOwnersL( ConML_DataOwnersPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnersL()" );
     if ( aContent )
         {
         BeginElementL( EConMLDataOwners, ETrue );
         AppendSIDListL( aContent->sid );
         EndElementL(); //EConMLDataOwners
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDataOwnersL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -907,7 +827,6 @@
 void CSConConMLGenerator::AppendGetDataOwnerStatusL
     ( ConML_GetDataOwnerStatusPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnerStatusL()" );
     if ( aContent)
         {
         BeginElementL( EConMLGetDataOwnerStatus, ETrue );
@@ -915,7 +834,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EconMLGetDataOwnerStatus
         }
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDataOwnerStatusL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -924,7 +842,6 @@
 void CSConConMLGenerator::AppendGetMetadataL
     ( ConML_GetMetadataPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetMetadataL()" );
     if ( aContent)
         {
         BeginElementL( EConMLGetMetadata, ETrue );
@@ -932,7 +849,6 @@
         AppendResultsL( aContent->results );
         EndElementL(); // EConMLGetMetadata
         }
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendGetMetadataL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -953,7 +869,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendSIDL( ConML_SIDPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSIDL()" );
     if ( aContent )
         {
         BeginElementL( EConMLSID, ETrue );
@@ -975,7 +890,6 @@
             }
         EndElementL(); // EconMLSID
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -983,12 +897,10 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendSIDListL( ConML_SIDListPtr_t aContent )
     {
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDListL()" );
     for ( ConML_SIDListPtr_t p = aContent; p && p->data; p=p->next )
         {
         AppendSIDL( p->data );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSIDListL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -996,7 +908,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendDeviceInfoL( ConML_DeviceInfoPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendDeviceInfoL()" );
     if ( aContent )
         {
         BeginElementL( EConMLDeviceInfo, ETrue );
@@ -1005,7 +916,6 @@
         AppendPCDataL(EConMLMaxObjectSize, aContent->maxObjectSize );
         EndElementL(); // EConMLDeviceInfo
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendDeviceInfoL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1013,14 +923,12 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendFilesL( ConML_FilesPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFilesL()" );
     if ( aContent )
         {
         BeginElementL( EConMLFiles, ETrue );
         AppendFileListL( aContent->file );
         EndElementL(); // EConMLFiles
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFilesL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1029,7 +937,6 @@
 void CSConConMLGenerator::AppendSupportedMethodsL
     ( ConML_SupportedMethodsPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendSupportedMethodsL()" );
     if ( aContent )
         {
         BeginElementL( EConMLSupportedMethods, ETrue );
@@ -1071,7 +978,6 @@
             }
         EndElementL(); // EConMLSupportedMethods
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendSupportedMethodsL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1079,7 +985,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendFileListL( ConML_FileListPtr_t  aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFileListL()" );
     if ( aContent )
         {
         for ( ConML_FileListPtr_t p = aContent; p && p->data; p = p->next )
@@ -1087,7 +992,6 @@
             AppendFileL(p->data );
             }
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFileListL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1095,7 +999,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendFileL( ConML_FilePtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendFileL()" );
     if ( aContent )
         {
         BeginElementL( EConMLFile, ETrue );
@@ -1105,7 +1008,6 @@
         AppendPCDataL( EConMLUserPerm, aContent->userPerm );
         EndElementL(); // EConMLFile
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendFileL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1129,8 +1031,7 @@
             iWBXMLWorkspace->Rollback();
             return KWBXMLGeneratorBufferFull;
         }
-    LOGGER_WRITE_1( "CSConConMLGenerator::HandleResult()\
-     : returned %d", aResult);
+    LOGGER_WRITE_1( "CSConConMLGenerator::HandleResult() : returned %d", aResult);
     return aResult;
     }
 
@@ -1167,7 +1068,6 @@
 void CSConConMLGenerator::BeginElementL( 
     TUint8 aElement, TBool aHasContent, TBool aHasAttributes )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::BeginElementL()" );
     IndentL();
     iXMLWorkspace->WriteL(KXMLTagStart());
     iXMLWorkspace->WriteL(TranslateElement(aElement));
@@ -1195,7 +1095,6 @@
     iDontNewLine = EFalse;
 
     WriteMUint32L(aElement);
-    LOGGER_LEAVEFN( "CSConConMLGenerator::BeginElementL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1203,7 +1102,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::EndElementL()
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::EndElementL()" );
     TUint8 elem = iElemStack[0];
     iElemStack.Remove(0);
     if( !iDontIndent )
@@ -1217,8 +1115,6 @@
     iXMLWorkspace->WriteL(KXMLNewLine());
     
     iWBXMLWorkspace->WriteL(END);
-    
-    LOGGER_LEAVEFN( "CSConConMLGenerator::EndElementL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1227,7 +1123,6 @@
 void CSConConMLGenerator::AddElementL( 
     TUint8 aElement, const TDesC8& aContent, const TWBXMLContentFormat aFormat )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AddElementL()" );
     iDontNewLine = ETrue;
     BeginElementL(aElement, ETrue);
     if( aFormat == EWBXMLContentFormatOpaque )
@@ -1240,7 +1135,6 @@
         }
     iDontIndent = ETrue;
     EndElementL();
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AddElementL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -1248,7 +1142,6 @@
 // -----------------------------------------------------------------------------
 void CSConConMLGenerator::AppendPCDataL( TUint8 aElement, pcdataPtr_t aContent )
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::AppendPCDataL()" );
     if( !aContent )
         {
         return;
@@ -1264,7 +1157,6 @@
         {
         LOGGER_WRITE( "CSConConMLGenerator::AppendPCDataL() : Data type not Opaque - ignoring " );
         }
-    LOGGER_LEAVEFN( "CSConConMLGenerator::AppendPCDataL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -1272,8 +1164,6 @@
 // -----------------------------------------------------------------------------
 TPtrC8 CSConConMLGenerator::WBXMLDocument()
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::WBXMLDocument()" );
-    LOGGER_LEAVEFN( "CSConConMLGenerator::WBXMLDocument()" );
     return iWBXMLWorkspace->Buffer();
     }
     
@@ -1282,7 +1172,5 @@
 // -----------------------------------------------------------------------------
 TPtrC8 CSConConMLGenerator::XMLDocument()
     {
-    LOGGER_ENTERFN( "CSConConMLGenerator::XMLDocument()" );
-    LOGGER_LEAVEFN( "CSConConMLGenerator::XMLDocument()" );
     return iXMLWorkspace->Buffer();
     }
--- a/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlhandler.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/connectivitymodules/SeCon/wbxml/conmlhandler/src/sconconmlhandler.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -169,8 +169,6 @@
 //  
 TPtrC8 CSConConMLHandler::WBXMLDocument()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::WBXMLDocument()" );
-    LOGGER_LEAVEFN( "CSConConMLHandler::WBXMLDocument()" );
     return iGenerator->WBXMLDocument();
     }
     
@@ -181,8 +179,6 @@
 //  
 TPtrC8 CSConConMLHandler::XMLDocument()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::XMLDocument()" );
-    LOGGER_LEAVEFN( "CSConConMLHandler::XMLDocument()" );
     return iGenerator->XMLDocument();
     }
 
@@ -318,7 +314,6 @@
 //  
 TUint8 CSConConMLHandler::ReadUint8L()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::ReadUint8L()" );
     if ( iPos == iParseBuffer->Size()) 
         {
         User::Leave ( KErrEof );
@@ -330,8 +325,6 @@
     iPos+= sizeof(TUint8);
     value = ptr[0];
     CleanupStack::PopAndDestroy(1); //data 
-    LOGGER_WRITE_1( "CSConConMLHandler::ReadUint8L()\
-     : returned %d ", value );
     return value;
     }
     
@@ -342,7 +335,6 @@
 //  
 TUint32 CSConConMLHandler::ReadMUint32L()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::ReadMUint32L()" );
     TUint32 result = 0;
     TUint8 c;
     
@@ -351,8 +343,6 @@
         result = (result << 7) | (c & 0x7f);
         } while ( c & 0x80 );
     
-    LOGGER_WRITE_1( "CSConConMLHandler::ReadMUint32L()\
-     : returned %d ", result );
     return result;
     }
 
@@ -363,7 +353,6 @@
 //  
 TPtrC8 CSConConMLHandler::ReadStrIL()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::ReadStrIL()" );
     iBuffer->Reset();
     RBufWriteStream bws(*iBuffer);
     TUint8 c;
@@ -372,7 +361,6 @@
         bws.WriteUint8L(c);
         }
     bws.CommitL();
-    LOGGER_LEAVEFN( "CSConConMLParser::ReadStrIL()" );
     return iBuffer->Ptr(0);
     }
     
@@ -383,7 +371,6 @@
 //  
 void CSConConMLHandler::ReadStringTableL()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::ReadStringTableL()" );
     delete iStringTable;
     iStringTable = NULL;
     TUint32 strTblLen = ReadMUint32L();
@@ -400,7 +387,6 @@
         iParseBuffer->Read(iPos, ptr, strTblLen);
         iPos+=strTblLen;
         }
-    LOGGER_LEAVEFN( "CSConConMLHandler::ReadStringTableL()" );
     }
     
 // -----------------------------------------------------------------------------
@@ -410,14 +396,12 @@
 //  
 TPtrC8 CSConConMLHandler::StringTableString( TUint32 aIndex )
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::StringTableString()" );
     TPtrC8 temp(iStringTable->Mid(aIndex));
     TInt pos = temp.Find(KWBXMLNull());
     if( pos != KErrNotFound )
         {
         temp.Set(temp.Left(pos));
         }
-    LOGGER_LEAVEFN( "CSConConMLHandler::StringTableString()" );
     return temp;
     }
 
@@ -428,7 +412,6 @@
 //  
 void CSConConMLHandler::HandleElementL( TUint8 aId )
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::HandleElementL()" );
     TUint8 tag(TUint8(aId & 0x3f));
         
     iGenerator->StartElementL( tag );
@@ -441,7 +424,6 @@
         {
         iGenerator->EndElementL(tag);
         }
-    LOGGER_LEAVEFN( "CSConConMLHandler::HandleElementL()" );
     }
 
 // -----------------------------------------------------------------------------
@@ -451,7 +433,6 @@
 //  
 TPtrC8 CSConConMLHandler::ReadOpaqueL()
     {
-    LOGGER_ENTERFN( "CSConConMLHandler::ReadOpaqueL()" );
     iBuffer->Reset();
     RBufWriteStream bws(*iBuffer);
     TUint32 length = ReadMUint32L();
@@ -468,7 +449,6 @@
     bws.CommitL();
     CleanupStack::PopAndDestroy(1); // data
     
-    LOGGER_LEAVEFN( "CSConConMLHandler::ReadOpaqueL()" );
     return iBuffer->Ptr(0);
     }
 
--- a/omads/omadsextensions/adapters/bld/bld.inf	Wed Jun 23 18:02:53 2010 +0300
+++ b/omads/omadsextensions/adapters/bld/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -30,3 +30,12 @@
 #include "../notes/group/bld.inf"
 #endif
 
+#include "../contactsgroup/group/bld.inf"
+
+#include "../mediads/group/bld.inf"
+
+// #include "../bookmark/group/bld.inf"
+
+#include "../mms/group/bld.inf"
+
+#include "../sms/group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/group/102751ba.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,19 @@
+<!-- Capability Object Service -->
+<Service>
+	<Name>Bookmarks</Name>
+	<UUID>SYNCML-SYNC</UUID>
+	<Version>2.0</Version>
+	<Object>	
+		<Type>text/x-vbookmark</Type>
+		<Name-Ext>bookmarks</Name-Ext>
+	</Object>
+	<Ext>
+		<XNam>SyncProfile</XNam>
+		<XVal>HostAddress=PC Suite Data Sync</XVal>
+		<XVal>Database=bookmarks</XVal>
+	</Ext>
+	<Ext>
+		<XNam>Databases</XNam>
+		<XVal>Web Feeds=50000</XVal>
+	</Ext>
+</Service>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* 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              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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,33 @@
+;
+; Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Stub sis file for Bookmark datasync adapter
+;
+
+; Languages
+&EN
+
+; Header
+#{"Bookmark DS Plugin"},(0x102751BA),2,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/group/createstub.bat	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Batch file for creating needed stub files.
+rem
+
+makesis -s bookmarkdsa_stub.pkg
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/inc/bookmarkdataprovider.h	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* 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
+    
+    // Define this to enable file logging
+    #define __FLOGGING__
+    
+    #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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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/sis/backup_registration.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?> 
+<backup_registration>
+    <system_backup />
+    <restore requires_reboot = "no"/>
+</backup_registration> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/sis/bookmarkdsa.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Sis file for Bookmark datasync adapter
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Bookmark DS Plugin"},(0x102751BA),2,0,0, TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\bookmarkdsa.rsc"             -"c:\resource\bookmarkdsa.rsc"
+"\epoc32\data\z\resource\bookmarkdatastore.rsc"             -"c:\resource\bookmarkdatastore.rsc"
+"\epoc32\data\z\resource\plugins\bookmarkdataprovider.rsc"  -"c:\resource\plugins\bookmarkdataprovider.rsc"
+"\epoc32\release\armv5\urel\bookmarkdataprovider.dll"       -"c:\sys\bin\bookmarkdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\102751ba.xml"   -"c:\private\101F99F6\import\102751ba.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FF972\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/sis/bookmarkdsa_debug.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,40 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Contacts Group DS Plugin"},(0x101FF972),1,23,0,TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\contactsgrpdatastore.rsc"             -"c:\resource\contactsgrpdatastore.rsc"
+"\epoc32\data\z\resource\plugins\contactsgrpdataprovider.rsc"  -"c:\resource\plugins\contactsgrpdataprovider.rsc"
+"\epoc32\release\ARMV5\UDEB\contactsgrpdataprovider.dll"       -"c:\sys\bin\contactsgrpdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\101ff972.xml"   -"c:\private\101F99F6\import\101ff972.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FF972\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/bookmark/src/bookmarkdataprovider.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,586 @@
+/*
+* 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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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;
+    }
--- a/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataProvider.cpp	Wed Jun 23 18:02:53 2010 +0300
+++ b/omads/omadsextensions/adapters/contacts/src/NSmlContactsDataProvider.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -38,6 +38,13 @@
 #include "nsmldsimpluids.h"
 #include "nsmlchangefinder.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 ===============================
 
 // -----------------------------------------------------------------------------
Binary file omads/omadsextensions/adapters/contactsgroup/group/101ff972.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  bld file for Contacts Group DS adapter
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./101ff972.xml              Z:/private/101f99f6/capability/101ff972.xml
+./contactsgrpdsa_stub.sis   /epoc32/data/z/system/install/contactsgrpdsa_stub.sis
+../rom/contactsgrpdsa.iby   CORE_APP_LAYER_IBY_EXPORT_PATH(contactsgrpdsa.iby)
+
+PRJ_MMPFILES
+./contactsgrpdataprovider.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdataprovider.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Contacts Group DS adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          contactsgrpdataprovider.dll
+TARGETTYPE      PLUGIN
+UID             0x10009d8d 0x101FF972
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ..\src
+SOURCE          contactsgrpdataprovider.cpp
+SOURCE          contactsgrpdatastore.cpp
+SOURCE          contactsgrpconverter.cpp
+SOURCE          changefinder.cpp
+SOURCE          snapshotitem.cpp
+
+USERINCLUDE     ..\inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ..\src
+
+START RESOURCE  contactsgrpdataprovider.rss
+HEADER
+TARGET          contactsgrpdataprovider.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  contactsgrpdatastore.rss
+HEADER
+TARGET          contactsgrpdatastore.rsc  
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+
+DEBUGLIBRARY    flogger.lib
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         ecom.lib
+LIBRARY         smldataprovider.lib
+LIBRARY         bafl.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         efsrv.lib
+LIBRARY         smlstoreformat.lib
+LIBRARY         SenXml.lib 
+LIBRARY         charconv.lib 
+LIBRARY         sysutil.lib
+LIBRARY         hash.lib
+LIBRARY         cntmodel.lib
+LIBRARY         vcard.lib
+LIBRARY         versit.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdsa_stub.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,31 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+; Languages
+&EN
+
+; Header
+#{"Contacts Group DS Plugin"},(0x101FF972),1,23,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\contactsgrpdatastore.rsc"
+""-"z:\resource\plugins\contactsgrpdataprovider.rsc"
+""-"z:\sys\bin\contactsgrpdataprovider.dll"
Binary file omads/omadsextensions/adapters/contactsgroup/group/contactsgrpdsa_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/group/createstub.bat	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Batch file for creating needed stub files.
+rem
+
+makesis -s contactsgrpdsa_stub.pkg
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/changefinder.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of ContactGroup DS 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 contacts group 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 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);
+	
+    /**
+    * 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 ItemDeleted( const TSnapshotItem& aItem );
+	
+    /**
+    * Update item to snapshot, it is no loger reported.
+    * 
+    * @param aItem   IN: item to update.
+    */
+	void ItemUpdatedL( 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 );
+	
+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;
+	
+    };
+
+#endif // __CHANGEFINDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpconverter.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* 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:  Group vCard object conversion routines
+*
+*/
+
+
+#ifndef __CONTACTSGRPCONVERTER_H__
+#define __CONTACTSGRPCONVERTER_H__
+
+#include <e32base.h>
+
+#include <cntitem.h>
+
+class CContactIdArray;
+
+/* @brief CContactsGrpConverter Class
+ * This class is used to convert Contact Group items to vCard presentation and vice versa.
+ */
+
+NONSHARABLE_CLASS( CContactsGrpConverter ): public CBase
+	{
+public:
+
+	static CContactsGrpConverter* NewL();
+	static CContactsGrpConverter* NewLC();
+	~CContactsGrpConverter();
+
+	// returns group label
+	const TDesC& GroupLabel() const;
+	// returns contact items beloging to group
+	const CContactIdArray& ItemsContained() const;
+	
+	// Import group item
+	void ImportDbItemL( CContactGroup& aItem );
+	
+	// Export / Import vCard info from/to this object
+	void ExportVCardL( CBufBase& aBuffer );
+	void ExportVCardL( RWriteStream& aWriteStream );
+	void ImportVCardL( const TDesC8& aBuffer );
+	
+	// Reset all data
+	void ResetL();
+	
+private:
+    
+    CContactsGrpConverter();	
+	void ConstructL();
+	
+    void SetContactItemsL( const TDesC& aValue );
+        
+    void SplitL( const TDesC& aText, const TChar aSeparator, RArray<TPtrC>& aArray );
+    void TrimAll( TPtrC& aValue );
+private:
+    HBufC*           iGroupLabel;
+    CContactIdArray* iContactsIdArray;
+    
+	};
+
+#endif // __CONTACTSGRPCONVERTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdataprovider.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of ContactGroup DS adapter
+*
+*/
+
+
+#ifndef __CONTACTSGRPDATAPROVIDER_H__
+#define __CONTACTSGRPDATAPROVIDER_H__
+
+#include <SmlDataProvider.h>
+#include <f32file.h>
+
+class CContactsGrpDataProvider : public CSmlDataProvider
+	{
+private:
+	// Default C++ constructor
+	CContactsGrpDataProvider();
+
+	// 2nd phase of constructor
+	void ConstructL();
+
+public:	
+	
+	// Two-phased constructor
+	static CContactsGrpDataProvider* NewL();
+	
+	// Destructor
+	virtual ~CContactsGrpDataProvider();
+
+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	                            iFs;
+	
+	};
+
+#endif // __CONTACTSGRPDATAPROVIDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdataproviderdefs.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* 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:  Part of ContactGroup DS adapter
+*
+*/
+
+
+#ifndef __CONTACTSGRPDATAPROVIDERDEFS_H__
+#define __CONTACTSGRPDATAPROVIDERDEFS_H__
+
+#include <e32def.h> 
+// ------------------------------------------------------------------------------------------------
+// Constants
+// ------------------------------------------------------------------------------------------------
+_LIT8( KContactsGrpItemMimeType, "text/x-vCard" );
+_LIT8( KContactsGrpItemMimeVersion, "2.1" );
+
+_LIT(KContactsGrpStoreName, "Gallery");
+
+#endif // __CONTACTSGRPDATAPROVIDERDEFS_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/contactsgrpdatastore.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of ContactGroup DS adapter
+*
+*/
+
+
+#ifndef __CONTACTSGRPDATASTORE_H__
+#define __CONTACTSGRPDATASTORE_H__
+
+#include <SmlDataProvider.h>
+#include <f32file.h>
+#include <cntdef.h>
+
+class CNSmlDataItemUidSet;
+class CContactsGrpConverter;
+class CChangeFinder;
+class TSnapshotItem;
+class CContactDatabase;
+
+class CContactsGrpDataStore : public CSmlDataStore
+	{
+private:
+
+	CContactsGrpDataStore();
+	~CContactsGrpDataStore();	
+	
+public:
+
+	static CContactsGrpDataStore* NewL();
+	static CContactsGrpDataStore* 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:
+    TContactItemId CreateNewGroupL( const TDesC& aLabel,
+            const CContactIdArray& aContactArray/*, const TDesC& aRingtone*/ );
+    
+    void ReplaceGroupL( TContactItemId aGroupId, const TDesC& aLabel,
+            const CContactIdArray& aContactArray/*, const TDesC& aRingtone*/ );
+    
+    // Create and save snapshot from items on database
+    void RegisterSnapshotL();
+    
+    void AssignString( TDes8& aDestination, const TDesC8& aSource );
+    
+    // Updates contacts last modified time.
+    void UpdateContactLastMod( TContactItemId aContactId, const TTime& aLastModified );
+    
+    // Checks does group name already exists.
+    TBool GroupNameExistsL( const TDesC& aLabel );
+    
+    // Data store states
+    enum TState
+        {
+        EClosed = 0,
+        EOpenAndWaiting,
+        EContactGrpOpening,
+        EContactGrpCreating,
+        EContactGrpUpdating
+        }; 	
+        
+    TState iCurrentState;    
+
+    RFs                 iFs;
+	
+	CContactDatabase*   iContactsDb;
+	
+	TRequestStatus*     iCallerStatus;
+
+    /**
+	* Key that is used in sorting snapshot.
+	*/
+    const TKeyArrayFix  iKey;
+    
+    /**
+	* Change finder, used to determine db modifications.
+	*/
+    CChangeFinder*      iChangeFinder;
+
+    /**
+	* VCard item converter
+	*/
+    CContactsGrpConverter* iConverter;
+	
+    TSmlDbItemUid* iCurrentItem;
+    TSmlDbItemUid  iItemToBeReplaced;
+	
+	CBufFlat*  iDataBuffer;
+	TInt       iWriterPosition;
+	TInt       iReaderPosition;
+	
+	TBool      iHasHistory;
+	
+	CNSmlDataItemUidSet* iNewItems;
+    CNSmlDataItemUidSet* iDeletedItems;
+    CNSmlDataItemUidSet* iUpdatedItems;
+    CNSmlDataItemUidSet* iEmptyList;
+	};
+
+#endif // __CONTACTSGRPDATASTORE_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/logger.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* 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:  Debug utility for Contact Groups
+*
+*/
+
+
+#ifndef _LOGGER_H
+#define _LOGGER_H
+
+#ifdef _DEBUG
+    
+    // Define this to enable file logging
+    #define __FLOGGING__
+    
+    #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, "CNTGRP" );
+    _LIT( KLogFile, "ContactsGroupLog.txt" );
+    
+    _LIT(KTracePrefix16, "[CNTGRP] ");
+    _LIT8(KTracePrefix8, "[CNTGRP] ");
+    _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_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 // SECON_DEBUG_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/inc/snapshotitem.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,95 @@
+/*
+* 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:  Private snapshot item header
+*
+*/
+
+
+#ifndef __SNAPSHOTITEM_H__
+#define __SNAPSHOTITEM_H__
+
+// INCLUDES
+
+#include <s32strm.h>
+#include <nsmlsnapshotitem.h>
+
+
+// CLASS DECLARATION
+class CContactGroup;
+
+// 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 );
+	void CreateHashL( CContactGroup& aGroup );
+	
+	/**
+    * 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/contactsgroup/rom/contactsgrpdsa.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  iby file for Contacts Group DS adapter
+*
+*/
+
+
+#ifndef __CONTACTSGRPDSA_IBY__
+#define __CONTACTSGRPDSA_IBY__
+
+ECOM_PLUGIN(contactsgrpdataprovider.dll,contactsgrpdataprovider.rsc)
+data=DATAZ_\RESOURCE_FILES_DIR\contactsgrpdatastore.rsc     RESOURCE_FILES_DIR\contactsgrpdatastore.rsc
+data=DATAZ_\private\101F99F6\capability\101ff972.xml        private\101F99F6\capability\101ff972.xml
+data=ZSYSTEM\install\contactsgrpdsa_stub.sis             	system\install\contactsgrpdsa_stub.sis
+
+#endif //__CONTACTSGRPDSA_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/sis/backup_registration.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?> 
+<backup_registration>
+    <system_backup />
+    <restore requires_reboot = "no"/>
+</backup_registration> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/sis/contactsgrp.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,40 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: PKG file for Contacts Group DS adapter
+
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Contacts Group DS Plugin"},(0x101FF972),1,23,0,TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\contactsgrpdatastore.rsc"             -"c:\resource\contactsgrpdatastore.rsc"
+"\epoc32\data\z\resource\plugins\contactsgrpdataprovider.rsc"  -"c:\resource\plugins\contactsgrpdataprovider.rsc"
+"\epoc32\release\armv5\urel\contactsgrpdataprovider.dll"       -"c:\sys\bin\contactsgrpdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\101ff972.xml"   -"c:\private\101F99F6\import\101ff972.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FF972\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/sis/contactsgrp_debug.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,40 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Contacts Group DS Plugin"},(0x101FF972),1,23,0,TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\contactsgrpdatastore.rsc"             -"c:\resource\contactsgrpdatastore.rsc"
+"\epoc32\data\z\resource\plugins\contactsgrpdataprovider.rsc"  -"c:\resource\plugins\contactsgrpdataprovider.rsc"
+"\epoc32\release\ARMV5\UDEB\contactsgrpdataprovider.dll"       -"c:\sys\bin\contactsgrpdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\101ff972.xml"   -"c:\private\101F99F6\import\101ff972.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FF972\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/src/changefinder.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,410 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of ContactsGroup 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 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::~CChangeFinder
+// Destructor for the class, closes the ChangeFinder and writes snapshot to stream
+// -----------------------------------------------------------------------------
+CChangeFinder::~CChangeFinder()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iOldSnapshot;
+	delete iCurrentSnapshot;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ConstructL
+// 2nd phase constructor for the class, reads snapshot from stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::ConstructL( TBool& aHasHistory )
+    {
+    TRACE_FUNC_ENTRY;
+    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 );
+            TRACE_FUNC_EXIT;
+            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.");
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CloseL
+// Closes ChangeFinder object and writes snapshot to stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::CloseL()
+    {
+    TRACE_FUNC_ENTRY;
+     
+    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
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ResetL
+// Resets synchronization history, all contetn is considered new after this call
+// -----------------------------------------------------------------------------
+void CChangeFinder::ResetL()
+    {
+    TRACE_FUNC_ENTRY;
+    iOldSnapshot->Reset();
+    
+    // Write 'null' data to file, 
+    // this removes change history from the file
+    CloseL();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindChangedItemsL
+// Compares snapshots, finds changed items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids )
+    {   
+    TRACE_FUNC_ENTRY;
+    aChangedUids.Reset();
+    
+    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() ) );
+                }
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindDeletedItemsL
+// Compares snapshots, finds deleted items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids )
+    {
+    TRACE_FUNC_ENTRY;
+    aDeletedUids.Reset();
+        
+    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() );
+            }       
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindNewItemsL
+// Compares snapshots, finds new items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindNewItemsL( CNSmlDataItemUidSet& aNewUids )
+    {
+    TRACE_FUNC_ENTRY;
+    aNewUids.Reset();
+    
+    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() );
+            }       
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemAddedL
+// Adds item to snapshot, this item is no longer considered new
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemAddedL( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "Adding item %d.", aItem.ItemId() );
+    
+    iOldSnapshot->InsertIsqL( aItem, iKey );
+    iOldSnapshot->Compress();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemDeleted
+// Removes item from snapshot, this item is no longer considered deleted
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemDeleted( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "deleting item %d.", aItem.ItemId() );
+    
+    // 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." );
+        }  
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemUpdatedL
+// Updates item to snapshot, this item is no longer considered changed
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemUpdatedL( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "Updating item %d.", aItem.ItemId() );
+    
+    // Update item in the old snapshot
+    TInt index;
+    if ( iOldSnapshot->FindIsq( aItem, iKey, index ) == KErrNone )
+        {
+        iOldSnapshot->At( index ) = aItem;
+        }
+    else 
+        {
+        // There was no such item. Let's add it
+        ItemAddedL( aItem );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL()
+    {
+    TRACE_FUNC_ENTRY;
+     
+    // 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 );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot, affects only a specified group of items
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL( const MSmlDataItemUidSet& aUids )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // This function commits changes from current snapshot to old snapshot
+    // But commits only the entries in the parameter array
+    
+    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 );
+			    }
+			}
+		}
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetNewSnapshot
+// Sets new snapshot (to be compared against), ChangeFinder takes ownership
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetNewSnapshot( CSnapshotArray* aNewSnapshot )
+    {
+    TRACE_FUNC;
+    
+    // Delete existing snapshot
+    delete iCurrentSnapshot;
+    
+    // Set submitted snapshot as active
+    iCurrentSnapshot = aNewSnapshot;
+    TRACE_FUNC_EXIT;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/src/contactsgrpconverter.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,400 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contacts Group object conversion routines
+*
+*/
+
+
+// INCLUDES
+#include <utf.h>
+#include <cntdef.h>
+#include <cntitem.h>
+#include <cntfldst.h>
+#include <vcard.h>
+#include <vprop.h> 
+#include <vutil.h>
+#include <s32mem.h>
+
+#include "contactsgrpconverter.h"
+#include "logger.h"
+
+// CONSTANTS
+/*
+vCard format example:
+BEGIN:VCARD
+VERSION:2.1
+FN:GroupName
+X-CNTGRP:4;14;54
+END:VCARD
+*/
+
+// Group label property
+_LIT8(KCntGrpFN, "FN");
+// Group contacts propetry
+_LIT8(KCntGrpXCntGrp, "X-CNTGRP");
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CContactsGrpConverter* CContactsGrpConverter::NewL()
+    {
+    CContactsGrpConverter* self = CContactsGrpConverter::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CContactsGrpConverter* CContactsGrpConverter::NewLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CContactsGrpConverter* self = new (ELeave) CContactsGrpConverter();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::CContactsGrpConverter
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CContactsGrpConverter::CContactsGrpConverter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ConstructL()
+    {
+    ResetL();
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::~CContactsGrpConverter
+// Destructor.
+// -----------------------------------------------------------------------------
+CContactsGrpConverter::~CContactsGrpConverter()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iContactsIdArray;
+    delete iGroupLabel;
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::GroupLabel
+// returns group label
+// -----------------------------------------------------------------------------
+const TDesC& CContactsGrpConverter::GroupLabel() const
+    {
+    return *iGroupLabel;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ItemsContained
+// returns contact items belonging to this group
+// -----------------------------------------------------------------------------
+const CContactIdArray& CContactsGrpConverter::ItemsContained() const
+    {
+    return *iContactsIdArray;
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ImportDbItemL
+// Imports group item
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ImportDbItemL( CContactGroup& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( aItem.Type() != KUidContactGroup )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    ResetL();
+    
+    if ( aItem.HasItemLabelField() )
+        {
+        TPtrC label = aItem.GetGroupLabelL();
+        delete iGroupLabel;
+        iGroupLabel = NULL;
+        iGroupLabel = label.AllocL();
+        }
+    else
+        {
+        delete iGroupLabel;
+        iGroupLabel = NULL;
+        iGroupLabel = KNullDesC().AllocL();
+        }
+    
+    // this is NULL, if no items
+    CContactIdArray* tempIdArray = aItem.ItemsContainedLC();
+    if ( tempIdArray )
+        {
+        delete iContactsIdArray;
+        iContactsIdArray = tempIdArray;
+        CleanupStack::Pop( tempIdArray );
+        }
+    
+    LOGGER_WRITE_1("GroupName: %S", iGroupLabel);
+    if ( iContactsIdArray )
+        {
+        LOGGER_WRITE_1("contacts count: %d", iContactsIdArray->Count() );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ExportVCardL
+// Export contact group as vCard
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ExportVCardL( CBufBase& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    RBufWriteStream stream( aBuffer, 0);
+    CleanupClosePushL( stream );
+    ExportVCardL( stream );
+    CleanupStack::PopAndDestroy( &stream );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ExportL
+// Exports contact group as to vCard
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ExportVCardL( RWriteStream& aWriteStream )
+    {
+    TRACE_FUNC_ENTRY;
+    CParserVCard* vCardParser = CParserVCard::NewL();
+    CleanupStack::PushL( vCardParser );
+    
+    // add group name
+    CParserPropertyValue* FNvalue = CParserPropertyValueHBufC::NewL( *iGroupLabel );
+    // Associate the property params and property value with the FN property
+    CParserProperty* FNproperty=CParserProperty::NewL( *FNvalue, KCntGrpFN, NULL );
+    // Finally add the FN property to the vCard using the parser object.
+    vCardParser->AddPropertyL( FNproperty );
+    
+    // add group contacts
+    const TInt KDefaultGranularity = 5;
+    CDesCArrayFlat* flatArray = new (ELeave) CDesCArrayFlat(KDefaultGranularity);
+    CleanupStack::PushL( flatArray );
+    TInt count = iContactsIdArray->Count();
+    const TInt KMaxIdLength = 10;
+    TBuf<KMaxIdLength> idnum;
+    for ( TInt i=0; i<count; i++ )
+        {
+        const TContactItemId id = (*iContactsIdArray)[i];
+        idnum.Zero();
+        idnum.AppendNum( id );
+        flatArray->AppendL( idnum );
+        }
+    CParserPropertyValueCDesCArray* grPropertyValueArray =
+        new (ELeave) CParserPropertyValueCDesCArray( flatArray );
+    CleanupStack::Pop( flatArray );
+    
+    CParserProperty* grProperty = 
+        CParserProperty::NewL( *grPropertyValueArray, KCntGrpXCntGrp, NULL );
+    vCardParser->AddPropertyL( grProperty );
+    
+    // Set default sharacterset
+    vCardParser->SetDefaultCharSet( Versit::EUTF8CharSet );
+    
+    vCardParser->ExternalizeL( aWriteStream );
+    
+    CleanupStack::PopAndDestroy( vCardParser );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ImportVCardL
+// Import vCard item
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ImportVCardL( const TDesC8& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    ResetL();
+    CParserVCard* vCardParser = CParserVCard::NewL();
+    vCardParser->SetDefaultCharSet( Versit::EUTF8CharSet );
+    CleanupStack::PushL( vCardParser );
+    
+    RDesReadStream stream( aBuffer );
+    vCardParser->InternalizeL( stream ); // To import a vCard.
+    stream.Close(); // Close the file stream once the import is done.
+    
+    CArrayPtr<CParserProperty>* properties = vCardParser->ArrayOfProperties( EFalse );
+    LOGGER_WRITE_1("properties count: %d", properties->Count());
+    for (TInt i=0; i<properties->Count(); i++)
+        {
+        const CParserProperty* property = properties->At(i);
+        // FN
+        if ( property->Name() == KCntGrpFN )
+            {
+            LOGGER_WRITE("group name found");
+            delete iGroupLabel;
+            iGroupLabel = NULL;
+            CParserPropertyValue* pvalue = property->Value();
+            TPtrC val = (static_cast<CParserPropertyValueHBufC*> (pvalue))->Value();
+            iGroupLabel = val.AllocL();
+            LOGGER_WRITE_1("iGroupLabel: %S", iGroupLabel);
+            }
+        // X-CNTGRP
+        else if ( property->Name() == KCntGrpXCntGrp )
+            {
+            LOGGER_WRITE("group contacts found");
+            CParserPropertyValue* pvalue = property->Value();
+            TPtrC val = (static_cast<CParserPropertyValueHBufC*> (pvalue))->Value();
+            SetContactItemsL( val );
+            }
+        else
+            {
+            // skip other properties
+            }
+        }
+    CleanupStack::PopAndDestroy( vCardParser );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::ResetL
+// Reset all data
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::ResetL()
+    {
+    delete iGroupLabel;
+    iGroupLabel = NULL;
+    iGroupLabel = KNullDesC().AllocL();
+    if ( iContactsIdArray )
+        {
+        iContactsIdArray->Reset();
+        }
+    else
+        {
+        iContactsIdArray = CContactIdArray::NewL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::SetContactItemsL
+// Parses contact items from aValue
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::SetContactItemsL( const TDesC& aValue )
+    {
+    TRACE_FUNC_ENTRY;
+    const TInt KDefaultGranularity = 5;
+    RArray<TPtrC> arr(KDefaultGranularity);
+    CleanupClosePushL( arr );
+    const TChar separator(';');
+    SplitL( aValue, separator, arr );
+    if ( iContactsIdArray )
+        {
+        iContactsIdArray->Reset();
+        }
+    else
+        {
+        iContactsIdArray = CContactIdArray::NewL();
+        }
+    for (TInt i=0; i<arr.Count(); i++ )
+        {
+        TLex lex( arr[i] );
+        TInt32 id;
+        TInt err = lex.Val( id );
+        if ( err )
+            {
+            LOGGER_WRITE_1("lex.val returned err: %d, leaving with KErrCorrupt", err);
+            iContactsIdArray->Reset();
+            User::Leave( KErrCorrupt );
+            }
+        LOGGER_WRITE_1("add: %d", id);
+        iContactsIdArray->AddL( id );
+        }
+    CleanupStack::PopAndDestroy( &arr );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::SplitL
+// Function splits string (eg "name1, name2, name3") into substrings.
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::SplitL(const TDesC& aText, const TChar aSeparator, 
+                    RArray<TPtrC>& aArray)
+    {
+    TRACE_FUNC_ENTRY;
+    TPtrC ptr;
+    ptr.Set(aText);
+
+    for (;;)
+        {
+        TInt pos=ptr.Locate(aSeparator);
+        if (pos==KErrNotFound)
+            {
+            TrimAll( ptr );
+            if ( ptr.Length() > 0 )
+                {
+                aArray.AppendL(ptr);
+                }
+            break;
+            }
+
+        TPtrC subStr=ptr.Left(pos); // get pos characters starting from position 0
+        TrimAll( subStr );
+        if ( subStr.Length() > 0 )
+            {
+            aArray.AppendL(subStr);
+            }
+
+        if ( !(ptr.Length()>pos+1) )
+            {
+            break;
+            }
+            
+        ptr.Set( ptr.Mid(pos+1) ); // get all characters starting from position pos+1
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpConverter::TrimAll
+// Trims all whitespaces from beginning and end of string
+// -----------------------------------------------------------------------------
+void CContactsGrpConverter::TrimAll( TPtrC& aValue )
+    {
+    TRACE_FUNC_ENTRY;
+    TInt valueStart(0);
+    while ( valueStart < aValue.Length() 
+            && (aValue[valueStart] == ' '
+            || aValue[valueStart] == '\r'
+            || aValue[valueStart] == '\n') )
+        {
+        valueStart++;
+        }
+    TInt valueEnd(aValue.Length()-1);
+    while ( valueEnd > 0 
+            && (aValue[valueEnd] == ' '
+            || aValue[valueEnd] == '\r'
+            || aValue[valueEnd] == '\n') )
+        {
+        valueEnd--;
+        }
+    valueEnd++;
+    aValue.Set( aValue.Mid(valueStart, valueEnd - valueStart));
+    TRACE_FUNC_EXIT;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdataprovider.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,295 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part ContactsGroup Plug In Adapter
+*
+*/
+
+
+#include <ecom/implementationproxy.h>
+#include <data_caging_path_literals.hrh>
+#include <bautils.h>
+#include <barsc.h> 
+#include <contactsgrpdatastore.rsg>
+
+#include "contactsgrpdataprovider.h"
+#include "contactsgrpdatastore.h"
+#include "contactsgrpdataproviderdefs.h"
+#include "logger.h"
+
+const TUint KContactsGrpDataProviderImplUid = 0x101FF972;
+
+// Resource file for CSmlDataStoreFormat
+
+// The following works with DS plugin added into ROM image 
+_LIT(KContactsGrpStoreFormatRscRom,"z:contactsgrpdatastore.rsc");
+
+// The following works with DS plugin installed from SIS
+_LIT(KContactsGrpStoreFormatRsc,"contactsgrpdatastore.rsc");
+
+
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::CContactsGrpDataProvider
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CContactsGrpDataProvider::CContactsGrpDataProvider(): iFilters( 1 )
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataProvider::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    User::LeaveIfError( iFs.Connect() );
+    iStringPool.OpenL();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CContactsGrpDataProvider* CContactsGrpDataProvider::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CContactsGrpDataProvider* self = new ( ELeave ) CContactsGrpDataProvider();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::~CContactsGrpDataProvider
+// Destructor.
+// -----------------------------------------------------------------------------
+CContactsGrpDataProvider::~CContactsGrpDataProvider()
+    {
+    TRACE_FUNC_ENTRY;
+    delete iOwnStoreFormat;
+    iStringPool.Close();
+    iFilters.Close();
+    iFs.Close();
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoOnFrameworkEvent
+// Not used
+// -----------------------------------------------------------------------------
+void CContactsGrpDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/ )
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoSupportsOperation
+// Checks whether data provider supports specific operation
+// -----------------------------------------------------------------------------
+TBool CContactsGrpDataProvider::DoSupportsOperation( TUid /*aOpId*/ ) const
+    {
+    TRACE_FUNC;
+    return EFalse; // optional operations are not supported
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+const CSmlDataStoreFormat& CContactsGrpDataProvider::DoStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+
+    if (!iOwnStoreFormat)
+        {
+        iOwnStoreFormat = DoOwnStoreFormatL();
+        }
+    	
+    TRACE_FUNC_EXIT;
+    	
+    return *iOwnStoreFormat;	
+    }
+	
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoListStoresLC
+// Returns array fo data stores that can be opened
+// -----------------------------------------------------------------------------
+CDesCArray* CContactsGrpDataProvider::DoListStoresLC()
+    {
+    TRACE_FUNC_ENTRY;
+
+    CDesCArrayFlat* stores = new ( ELeave ) CDesCArrayFlat( 1 );
+    CleanupStack::PushL( stores );
+    
+    stores->AppendL( KContactsGrpStoreName );
+
+    TRACE_FUNC_EXIT;
+
+    return stores;	
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoDefaultStoreL
+// Returns the name of the default data store
+// -----------------------------------------------------------------------------
+const TDesC& CContactsGrpDataProvider::DoDefaultStoreL()
+    {
+    TRACE_FUNC;
+    return KContactsGrpStoreName;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoNewStoreInstanceLC
+// Creates a new data store object, which can be used for synchronization
+// ----------------------------------------------------------------------------- 
+CSmlDataStore* CContactsGrpDataProvider::DoNewStoreInstanceLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CContactsGrpDataStore* newStore = CContactsGrpDataStore::NewLC();
+    TRACE_FUNC_EXIT;
+    return newStore;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+const RPointerArray<CSyncMLFilter>& CContactsGrpDataProvider::DoSupportedServerFiltersL()
+    {
+    TRACE_FUNC;
+    return iFilters; // empty array
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoCheckSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CContactsGrpDataProvider::DoCheckSupportedServerFiltersL(
+    const CSmlDataStoreFormat& /*aServerDataStoreFormat*/,
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoCheckServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CContactsGrpDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoGenerateRecordFilterQueryLC
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+HBufC* CContactsGrpDataProvider::DoGenerateRecordFilterQueryLC(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/,
+    TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoGenerateFieldFilterQueryL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CContactsGrpDataProvider::DoGenerateFieldFilterQueryL(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/,
+    RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ )
+    {	
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataProvider::DoOwnStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+CSmlDataStoreFormat* CContactsGrpDataProvider::DoOwnStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+
+    TParse* parse = new ( ELeave ) TParse();
+    CleanupStack::PushL(parse);
+    TFileName fileName;
+    RResourceFile resourceFile;
+    
+    parse->Set( KContactsGrpStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL );
+    fileName = parse->FullName();
+    BaflUtils::NearestLanguageFile( iFs, fileName );
+    LOGGER_WRITE_1( "file: %S", &fileName );
+    
+    TRAPD( error, resourceFile.OpenL( iFs, fileName ) );
+    if ( error )
+        {
+        LOGGER_WRITE_1( "RResourceFile::OpenL leaved with %d - try again", error );
+        parse->Set( KContactsGrpStoreFormatRscRom, &KDC_RESOURCE_FILES_DIR, NULL );
+        fileName = parse->FullName();
+        BaflUtils::NearestLanguageFile( iFs, fileName );
+        LOGGER_WRITE_1( "file: %S", &fileName );
+        resourceFile.OpenL( iFs, fileName );
+        }
+    CleanupClosePushL( resourceFile );
+    HBufC8* buffer = resourceFile.AllocReadLC( CONTACTSGROUP_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 );
+    
+    TRACE_FUNC_EXIT;
+
+    return dsFormat;
+    }
+	
+// -----------------------------------------------------------------------------
+// ImplementationTable
+// Required by ECom plugin interface, tells the entry point of the library
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KContactsGrpDataProviderImplUid, CContactsGrpDataProvider::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/contactsgroup/src/contactsgrpdataprovider.rss	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* 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:  Resource definitions for ContactsGroup DS ECOM plug-in
+*
+*/
+
+
+#include <ecom/registryinfo.rh> 
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101FF972; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x101F4D3A; // Constant for all DS plug ins
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101FF972; // DS interface implementation UID
+                version_no = 1; 
+                display_name = "Contacts Group" ; // shown in UI
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdatastore.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1268 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include <sysutil.h> 
+#include <cntfldst.h>
+
+#include "contactsgrpdatastore.h"
+#include "contactsgrpconverter.h"
+#include "changefinder.h"
+#include "contactsgrpdataproviderdefs.h"
+#include "logger.h"
+
+const TInt KDefaultBufferSize = 1024;
+const TInt KDataBufferNotReady = -1;
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::CContactsGrpDataStore
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+CContactsGrpDataStore::CContactsGrpDataStore() :
+    iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem, ItemId() ), ECmpTInt ) )
+    {
+    TRACE_FUNC;
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::ConstructL
+// Symbian 2nd phase constructor, can leave.
+// -----------------------------------------------------------------------------    
+void CContactsGrpDataStore::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    User::LeaveIfError( iFs.Connect() );
+    
+    iNewItems       = new ( ELeave ) CNSmlDataItemUidSet;
+    iDeletedItems   = new ( ELeave ) CNSmlDataItemUidSet;
+    iUpdatedItems   = new ( ELeave ) CNSmlDataItemUidSet;
+    iEmptyList      = new ( ELeave ) CNSmlDataItemUidSet;
+    
+    iConverter = CContactsGrpConverter::NewL();
+    
+    TRACE_FUNC_EXIT;
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::~CContactsGrpDataStore
+// Destructor
+// -----------------------------------------------------------------------------    
+CContactsGrpDataStore::~CContactsGrpDataStore()
+    {
+    TRACE_FUNC_ENTRY;
+
+    delete iDataBuffer;
+    delete iNewItems;
+    delete iDeletedItems;
+    delete iUpdatedItems;
+    delete iEmptyList;
+    
+    if ( iChangeFinder )
+        {
+        TRAPD( error, iChangeFinder->CloseL() );
+        if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1( "iChangeFinder->CloseL() leaved with %d", error );
+            }
+        }
+    delete iChangeFinder;
+    
+    delete iConverter;
+    
+    delete iContactsDb;
+    
+    iFs.Close();
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CContactsGrpDataStore* CContactsGrpDataStore::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    CContactsGrpDataStore* self = CContactsGrpDataStore::NewLC();
+    CleanupStack::Pop( self );
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CContactsGrpDataStore* CContactsGrpDataStore::NewLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CContactsGrpDataStore* self = new ( ELeave ) CContactsGrpDataStore();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    TRACE_FUNC_EXIT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoOpenL
+// Opens database.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoOpenL( const TDesC& /*aStoreName*/,
+    MSmlSyncRelationship& aContext, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;           
+    *iCallerStatus = KRequestPending;
+    
+    if ( iContactsDb )
+        {
+        // already opened
+        User::RequestComplete( iCallerStatus, KErrInUse );
+        LOGGER_WRITE( "CContactsGrpDataStore::DoOpenL failed with KErrInUse." );
+        return;
+        }
+    
+    // Create ChangeFinder
+    if ( iChangeFinder )
+        {
+        delete iChangeFinder;
+        iChangeFinder = NULL;
+        }
+    iChangeFinder = CChangeFinder::NewL( aContext, iKey, iHasHistory );
+    
+    iContactsDb = CContactDatabase::OpenL();
+    
+    RegisterSnapshotL();
+    
+    User::RequestComplete( iCallerStatus, KErrNone );
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCancelRequest
+// Not supported, does nothing.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCancelRequest()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoStoreName
+// Returns the name of the DataStore
+// -----------------------------------------------------------------------------
+const TDesC& CContactsGrpDataStore::DoStoreName() const
+    {
+    TRACE_FUNC;
+    
+    if ( iContactsDb )
+        {
+        return KContactsGrpStoreName;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoBeginTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------    
+void CContactsGrpDataStore::DoBeginTransactionL()
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCommitTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCommitTransactionL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC;
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoRevertTransaction
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoRevertTransaction( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC;
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoBeginBatchL
+// Batching is not supported.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoBeginBatchL()
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCommitBatchL
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCommitBatchL( RArray<TInt>& /*aResultArray*/, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC;
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCancelBatch
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCancelBatch()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoSetRemoteStoreFormatL
+// Not supported
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/ )
+    {
+    TRACE_FUNC;
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoSetRemoteMaxObjectSize
+// Not supported
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoSetRemoteMaxObjectSize( TInt /*aServerMaxObjectSize*/ )
+    {
+    TRACE_FUNC;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoMaxObjectSize
+// Reads the maximum object size from the central repository
+// -----------------------------------------------------------------------------
+TInt CContactsGrpDataStore::DoMaxObjectSize() const
+    {
+    TRACE_FUNC;
+    return 0; // no limit
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::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 CContactsGrpDataStore::DoOpenItemL(
+    TSmlDbItemUid aUid, 
+    TBool& aFieldChange, 
+    TInt& aSize, 
+    TSmlDbItemUid& aParent, 
+    TDes8& aMimeType, 
+    TDes8& aMimeVer, 
+    TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aUid: %d", aUid );
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    aFieldChange = EFalse;
+    aParent = KErrNotFound;
+    
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    
+    if ( !iContactsDb )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize ); 
+    iReaderPosition = 0;
+    
+    CContactItem* item = iContactsDb->ReadContactLC( aUid );
+    if ( item->Type() != KUidContactGroup )
+        {
+        CleanupStack::PopAndDestroy( item );
+        User::Leave( KErrNotFound );
+        }
+
+    iConverter->ImportDbItemL( *static_cast<CContactGroup*>(item) );
+    
+    CleanupStack::PopAndDestroy( item );
+    
+    iConverter->ExportVCardL( *iDataBuffer );
+    iConverter->ResetL();
+    aSize = iDataBuffer->Size();
+    
+    // Set mime type to correct one
+    AssignString( aMimeType, KContactsGrpItemMimeType );
+    AssignString( aMimeVer, KContactsGrpItemMimeVersion );
+    
+    User::RequestComplete( iCallerStatus, KErrNone );   
+    iCurrentState = EContactGrpOpening;
+    
+    TRACE_FUNC_EXIT;   
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCreateItemL
+// Create new item to the message store.
+// Return the id number of the newly created item
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCreateItemL(
+    TSmlDbItemUid& aUid, 
+    TInt aSize, 
+    TSmlDbItemUid /*aParent*/, 
+    const TDesC8& /*aMimeType*/, 
+    const TDesC8& /*aMimeVer*/, 
+    TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "Warning: Unexpected current state: %d", iCurrentState );
+        }
+        
+    if ( !iContactsDb )
+        {
+        LOGGER_WRITE( "iContactsDb not ready" );
+        User::Leave( KErrNotReady );
+        }
+    
+    // Ensure that we've got enough disk space for the item
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aSize, EDriveC ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE( "SysUtil::DiskSpaceBelowCriticalLevelL failed with KErrDiskFull." );
+        return;
+        }
+    
+    // item uid is updated when groups is saved to db.
+    iCurrentItem = &aUid; 
+    // Save current operation-state so we know what operation
+    // is needed to do on DoCommitItemL
+    iCurrentState = EContactGrpCreating;
+                
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize );
+    iWriterPosition = 0;
+    
+    User::RequestComplete( iCallerStatus, KErrNone );  
+    TRACE_FUNC_EXIT;    
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoReplaceItemL
+// Begin the replace operation, ensure that the item really exists
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoReplaceItemL(
+    TSmlDbItemUid aUid, 
+    TInt aSize, 
+    TSmlDbItemUid /*aParent*/,
+    TBool /*aFieldChange*/, 
+    TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aUid: %d", aUid);
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    if ( !iContactsDb )
+        {
+        LOGGER_WRITE( "iContactsDb not ready" );
+        User::Leave( KErrNotReady );
+        }
+        
+    // Ensure that we've got enough disk space for the item
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aSize, EDriveC ) )
+        {
+        User::RequestComplete( iCallerStatus, KErrDiskFull );
+        LOGGER_WRITE( "SysUtil::DiskSpaceBelowCriticalLevelL failed with KErrDiskFull." );
+        return;
+        }
+    
+    // check that item exist and is Group-type
+    CContactItem* item = iContactsDb->ReadContactLC( aUid );
+    if ( item->Type() != KUidContactGroup )
+        {
+        CleanupStack::PopAndDestroy( item );
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy( item );
+    
+    // init databuffer
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    iDataBuffer = CBufFlat::NewL( KDefaultBufferSize );
+    iWriterPosition = 0;
+    
+    // Save current item, so we know what item needs to be replaced
+    iItemToBeReplaced = aUid;
+    // Save current operation-state so we know what operation
+    // is needed to do on DoCommitItemL
+    iCurrentState = EContactGrpUpdating;
+    
+    User::RequestComplete( iCallerStatus, KErrNone );   
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoReadItemL
+// Read specified amount of data from the temporary buffer
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoReadItemL( TDes8& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( iCurrentState != EContactGrpOpening || !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 );
+        }   
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoWriteItemL
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoWriteItemL( const TDesC8& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( iCurrentState != EContactGrpCreating && iCurrentState != EContactGrpUpdating )
+        {
+        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( &iFs, 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();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCommitItemL
+// Commits item from temporary buffer to the message store
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCommitItemL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EContactGrpCreating && iCurrentState != EContactGrpUpdating )
+        {
+        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 ( !iContactsDb )
+        {
+        LOGGER_WRITE( "iContactsDb not ready" );
+        User::Leave( KErrNotReady );
+        }
+
+    iDataBuffer->Compress();
+    iConverter->ImportVCardL( iDataBuffer->Ptr(0) );
+    
+    const CContactIdArray& contactArr = iConverter->ItemsContained();
+    
+    if ( iCurrentState == EContactGrpCreating )
+        {
+        *iCurrentItem = CreateNewGroupL( iConverter->GroupLabel(), contactArr );
+        }
+    else
+        {
+        ReplaceGroupL( iItemToBeReplaced, iConverter->GroupLabel(), contactArr);
+        }
+    iConverter->ResetL();
+    
+    // Destroy buffer
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    iWriterPosition = 0;
+    
+    // Restore state and signal we're done
+    iCurrentState = EOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::CreateNewGroupL
+// Creates new groupd to db.
+// -----------------------------------------------------------------------------
+TContactItemId CContactsGrpDataStore::CreateNewGroupL( const TDesC& aLabel,
+        const CContactIdArray& aContactArray )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aLabel: %S", &aLabel );
+    
+    // Check for duplicates
+    if ( GroupNameExistsL( aLabel ) )
+        {
+        LOGGER_WRITE("Duplicate group name found, leave KErrAlreadyExists");
+        User::Leave( KErrAlreadyExists );
+        }
+    
+    CContactGroup* group =
+        static_cast<CContactGroup*>
+        (iContactsDb->CreateContactGroupLC( aLabel ));
+    
+    // Create new contact group
+    
+    TContactItemId groupId = group->Id();
+    LOGGER_WRITE_1("new group id: %d", groupId);
+    
+    TBool partiallyUpdated(EFalse);
+    TTime lastMod;
+    lastMod.UniversalTime();
+    TInt err(KErrNone);
+    for ( TInt i=0; i<aContactArray.Count(); i++ )
+        {
+        LOGGER_WRITE_1("Add contact: %d", aContactArray[i] );
+        TRAP( err, iContactsDb->AddContactToGroupL( aContactArray[i], groupId ));
+        if ( err )
+            {
+            LOGGER_WRITE_2("Warning: AddContactToGroupL, contact: %d, err: %d", aContactArray[i], err);
+            partiallyUpdated = ETrue;
+            }
+        else
+            {
+            // If succesfully added, update contact timestamp so contact sync sees those
+            // contacts as changed ones.
+            UpdateContactLastMod( aContactArray[i], lastMod );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( group );
+    group = NULL;
+    
+    // if item was only partially updated, do not register to snapshot
+    //   --> on next sync item is marked as updated
+    if ( !partiallyUpdated )
+        {
+        // reload group
+        group = static_cast<CContactGroup*>
+            (iContactsDb->ReadContactLC( groupId ));
+        // Inform ChangeFinder of new item
+        TSnapshotItem snapshotItem( groupId );
+        snapshotItem.CreateHashL( *group );
+        iChangeFinder->ItemAddedL( snapshotItem );
+        
+        CleanupStack::PopAndDestroy( group );
+        }
+    
+    
+    
+    TRACE_FUNC_EXIT;
+    return groupId;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::ReplaceGroupL
+// Replaces existing group on db
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::ReplaceGroupL( TContactItemId aGroupId, const TDesC& aLabel,
+            const CContactIdArray& aContactArray )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aGroupId: %d", aGroupId);
+    LOGGER_WRITE_1("aLabel: %S", &aLabel);
+    TBool partiallyUpdated(EFalse);
+    // check that item exist and is Group-type
+    // The LX suffix means that the lock record of the contact item is left on the cleanup stack.
+    CContactItem* item = iContactsDb->OpenContactLX( aGroupId );
+    CleanupStack::PushL( item );
+    if ( item->Type() != KUidContactGroup )
+        {
+        LOGGER_WRITE("Type was not KUidContactGroup, leaving KErrNotFound");
+        User::Leave( KErrNotFound );
+        }
+    
+    // cast item to CContactGroup type
+    CContactGroup* groupItem = static_cast<CContactGroup*>(item);
+    TContactItemId groupId = groupItem->Id();
+    
+    TBool labelUpdated(EFalse);
+    // Check is group label changed
+    if ( groupItem->HasItemLabelField() )
+        {
+        TPtrC dbLabel = groupItem->GetGroupLabelL();
+        if ( aLabel.Compare( dbLabel ) != 0 )
+            {
+            // didn't match, update label.
+            // Check that new name does not already exist
+            if ( GroupNameExistsL( aLabel ) )
+                {
+                LOGGER_WRITE("Name already exists, leave KErrAlreadyExists");
+                User::Leave( KErrAlreadyExists );
+                }
+            LOGGER_WRITE("Update label" );
+            groupItem->SetGroupLabelL( aLabel );
+            iContactsDb->CommitContactL( *item );
+            labelUpdated = ETrue;
+            }
+        }
+    TTime lastMod;
+    lastMod.UniversalTime();
+    // Update joined contacts
+    TInt err(KErrNone);
+    // add new items to current group
+    for ( TInt i=0; i<aContactArray.Count(); i++ )
+        {
+        TContactItemId newItem = aContactArray[i];
+        TBool founded = groupItem->ContainsItem( newItem );
+        if ( !founded )
+            {
+            // item does not exist on current group, add it.
+            LOGGER_WRITE_1("Add contact: %d", newItem)
+            TRAP( err, iContactsDb->AddContactToGroupL( newItem, groupId ));
+            if ( err )
+                {
+                LOGGER_WRITE_2("Warning: Could not add contact: %d, err: %d", newItem, err);
+                partiallyUpdated = ETrue;
+                }
+            else
+                {
+                // Update contact timestamp
+                UpdateContactLastMod( newItem, lastMod );
+                }
+            }
+        else
+            {
+            LOGGER_WRITE_1("contact( %d ) already exist on group, no need to update", newItem)
+            }
+        }
+    
+    // remove all missing items from group
+    CContactIdArray* oldIdArr = groupItem->ItemsContainedLC();
+    if ( oldIdArr )
+        {
+        for ( TInt i=0; i<oldIdArr->Count(); i++ )
+            {
+            TContactItemId oldItem = (*oldIdArr)[i];
+            TInt err = aContactArray.Find( oldItem );
+            if ( err == KErrNotFound )
+                {
+                LOGGER_WRITE_1("Remove contact: %d", oldItem );
+                // old item was not found from new item list, remove it.
+                TRAP( err, iContactsDb->RemoveContactFromGroupL(oldItem, groupId));
+                if ( err )
+                    {
+                    LOGGER_WRITE_2("Warning: Could not remove contact: %d, err: ",oldItem, err );
+                    partiallyUpdated = ETrue;
+                    }
+                else
+                    {
+                    UpdateContactLastMod( oldItem, lastMod );
+                    }
+                }
+            // Update all contacts in group if label is changed
+            else if ( labelUpdated )
+                {
+                UpdateContactLastMod( oldItem, lastMod );
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( oldIdArr );
+    CleanupStack::PopAndDestroy( 2 ); // item, lock object 
+    
+    // if item was only partially updated, do not register to snapshot
+    //   --> on next sync item is marked as updated
+    if ( !partiallyUpdated )
+        {
+        // reload group
+        groupItem = NULL;
+        groupItem = static_cast<CContactGroup*>
+            (iContactsDb->ReadContactLC( groupId ));
+        // Inform ChangeFinder of updated item
+        TSnapshotItem snapshotItem( groupId );
+        snapshotItem.CreateHashL( *groupItem );
+        iChangeFinder->ItemUpdatedL( snapshotItem );
+        
+        CleanupStack::PopAndDestroy( groupItem );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCloseItem
+// Closes open item in the data store
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCloseItem()
+    {
+    TRACE_FUNC_ENTRY;
+    // Reset read buffer 
+    iReaderPosition = KDataBufferNotReady;
+    delete iDataBuffer;
+    iDataBuffer = NULL;
+    
+    // Make sure that we're opened an item
+    if ( iCurrentState != EContactGrpOpening )
+        {
+        LOGGER_WRITE_1( "WARNING: Invalid state %d.", iCurrentState );
+        }
+    // Start to wait for the next operation     
+   iCurrentState = EOpenAndWaiting;
+    
+    TRACE_FUNC_EXIT;   
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoMoveItemL
+// Not supported.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoMoveItemL( TSmlDbItemUid /*aUid*/,
+    TSmlDbItemUid /*aNewParent*/, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Restore state and signal we're done
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoDeleteItemL
+// Removes item from the message store
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aUid: %d", aUid );
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CContactsGrpDataStore::DoDeleteItemL, Incorrect state: %d", iCurrentState);
+        }
+    
+    if ( !iContactsDb )
+        {
+        LOGGER_WRITE( "iContactsDb not ready" );
+        User::Leave( KErrNotReady );
+        }
+    
+    // check that item type is ContactGroup
+    CContactItem* item = iContactsDb->ReadContactLC( aUid );
+    if ( item->Type() != KUidContactGroup )
+        {
+        LOGGER_WRITE("Item was not ContactGroup");
+        CleanupStack::PopAndDestroy( item );
+        User::Leave( KErrNotFound );
+        }
+    
+    // Update all contacts in group
+    CContactGroup* groupItem = static_cast<CContactGroup*>(item);
+    CContactIdArray* contactArr = groupItem->ItemsContainedLC();
+    if ( contactArr )
+        {
+        TTime lastMod;
+        lastMod.UniversalTime();
+        for ( TInt i=0; i<contactArr->Count(); i++ )
+            {
+            TContactItemId contactId = (*contactArr)[i];
+            UpdateContactLastMod( contactId, lastMod );
+            }
+        }
+    CleanupStack::PopAndDestroy( contactArr );
+    CleanupStack::PopAndDestroy( item );
+    
+    // delete group
+    iContactsDb->DeleteContactL( aUid );
+    
+    TSnapshotItem snapshotItem( aUid );     
+    iChangeFinder->ItemDeleted( snapshotItem );
+    
+    User::RequestComplete( iCallerStatus, KErrNone );
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoSoftDeleteItemL
+// Soft delete isn't supported.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoSoftDeleteItemL(TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus)
+    {
+    TRACE_FUNC_ENTRY;
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    User::RequestComplete(iCallerStatus, KErrNotSupported); 
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoDeleteAllItemsL
+// Deletes all items in the standard folders of bookmark store
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    if ( !iContactsDb )
+        {
+        LOGGER_WRITE( "iContactsDb is not opened, Leaving KErrNotReady");
+        User::Leave( KErrNotReady );
+        }
+    
+    CContactIdArray* groups = iContactsDb->GetGroupIdListL();
+    if ( groups )
+        {
+        CleanupStack::PushL( groups );
+        TTime lastMod;
+        lastMod.UniversalTime();
+        
+        // update all contacts in all groups
+        for ( TInt i=0; i<groups->Count(); i++ )
+            {
+            // check that item type is ContactGroup
+            CContactItem* item = iContactsDb->ReadContactLC( (*groups)[i] );
+            
+            // Update all contacts in group
+            CContactGroup* groupItem = static_cast<CContactGroup*>(item);
+            CContactIdArray* contactArr = groupItem->ItemsContainedLC();
+            if ( contactArr )
+                {
+                for ( TInt i=0; i<contactArr->Count(); i++ )
+                    {
+                    TContactItemId contactId = (*contactArr)[i];
+                    UpdateContactLastMod( contactId, lastMod );
+                    }
+                }
+            CleanupStack::PopAndDestroy( contactArr );
+            CleanupStack::PopAndDestroy( item );
+            }
+        
+        // delete all groups
+        iContactsDb->DeleteContactsL( *groups );
+        CleanupStack::PopAndDestroy( groups );
+        }
+    
+    // Reset the whole change finder
+    iChangeFinder->ResetL();
+    
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::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 CContactsGrpDataStore::DoHasSyncHistory() const
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "iHasHistory: %d", iHasHistory );
+    TRACE_FUNC_EXIT;  
+    return iHasHistory;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoAddedItems
+// This method returns UIDs of added items. Those items are added after previous
+// synchronization with current synchronization relationship. 
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CContactsGrpDataStore::DoAddedItems() const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Clear new-items array
+    iNewItems->Reset();
+    if ( !iChangeFinder )
+        {
+        LOGGER_WRITE( "WARNING: Not ready, returns empty item list" );
+        return *iNewItems;      
+        }
+    
+    // Search for new items
+    TRAPD( error, iChangeFinder->FindNewItemsL( *iNewItems ) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error );
+        } 
+    
+    LOGGER_WRITE_1( "New item count: %d.", iNewItems->ItemCount() );    
+    TRACE_FUNC_EXIT;
+    
+    return *iNewItems;  
+    }
+    
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoDeletedItems
+// Returns ids of items, which are deleted after previous synchronization
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CContactsGrpDataStore::DoDeletedItems() const
+    {
+    TRACE_FUNC_ENTRY;    
+    
+    // Clear deleted-items array
+    iDeletedItems->Reset();
+    if ( !iChangeFinder )
+        {
+        LOGGER_WRITE( "WARNING: Not ready, returns empty item list" );
+        return *iDeletedItems;      
+        }
+    
+    // Search for deleted items
+    TRAPD( error, iChangeFinder->FindDeletedItemsL( *iDeletedItems ) );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error );
+        }
+    
+    LOGGER_WRITE_1( "Deleted item count: %d.", iDeletedItems->ItemCount() );
+    TRACE_FUNC_EXIT;
+    return *iDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoSoftDeletedItems
+// Not directly supported, empty list returned
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CContactsGrpDataStore::DoSoftDeletedItems() const
+    {
+    TRACE_FUNC;
+    // Return empty array as a result
+    return *iEmptyList;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoModifiedItems
+// Finds all modified items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CContactsGrpDataStore::DoModifiedItems() const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Clear updated-items array
+    iUpdatedItems->Reset();
+    if ( !iChangeFinder )
+        {
+        LOGGER_WRITE( "WARNING: Not ready, returns empty item list" );
+        return *iUpdatedItems;      
+        }
+    
+    // Search for updated items
+    TRAPD( error, iChangeFinder->FindChangedItemsL( *iUpdatedItems ) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error );
+        }
+    
+    LOGGER_WRITE_1( "Modified item count: %d.", iUpdatedItems->ItemCount() );
+    TRACE_FUNC_EXIT;     
+    return *iUpdatedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoMovedItems
+// Finds all moved items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CContactsGrpDataStore::DoMovedItems() const
+    {
+    TRACE_FUNC;
+    // Moved items are not supported
+    // Return empty array as a result
+    return *iEmptyList;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoResetChangeInfoL
+// Resets change history in the data store. All content is considered
+// new in the data store point of view.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoResetChangeInfoL, invalid state %d.", iCurrentState );
+        }   
+            
+    // Reset change info in ChangeFinder
+    iChangeFinder->ResetL();
+    iHasHistory = EFalse;
+    
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );   
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCommitChangeInfoL
+// Commits change info. These items are no longer reported, when change
+// information is being queried.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus,
+    const MSmlDataItemUidSet& aItems )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState );
+        }
+
+    // Notify ChangeFinder
+    LOGGER_WRITE_1( "CContactsGrpDataStore::DoCommitChangeInfoL, item count %d.", aItems.ItemCount() );
+    iChangeFinder->CommitChangesL( aItems );
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::DoCommitChangeInfoL
+// Commits change info. There is no more nothing to report when change
+// information is being queried. 
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1( "CContactsGrpDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState );
+        }
+    
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL();
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::RegisterSnapshotL
+// Sets Changefinder to compare against current message store content
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::RegisterSnapshotL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CArrayFixSeg<TSnapshotItem>* snapshot = 
+        new ( ELeave ) CArrayFixSeg<TSnapshotItem>( KSnapshotGranularity );
+    CleanupStack::PushL( snapshot );
+    
+    // Add everything to snapshot
+    
+    // GetGroupIdListL returns NULL if there are no groups in the database.
+    CContactIdArray* groups = iContactsDb->GetGroupIdListL();
+    if ( groups )
+        {
+        TKeyArrayFix key( iKey );
+        CleanupStack::PushL( groups );
+        for ( TInt i=0; i<groups->Count(); i++ )
+            {
+            CContactItem* item = iContactsDb->ReadContactLC((*groups)[i]);
+            CContactGroup* groupItem = static_cast<CContactGroup*>(item);
+            
+            LOGGER_WRITE_1( "Add group to snatshot, group id: %d",groupItem->Id() );
+            
+            TSnapshotItem snapshotItem( groupItem->Id() );
+            snapshotItem.CreateHashL( *groupItem );
+            
+            snapshot->InsertIsqL( snapshotItem, key );
+            
+            CleanupStack::PopAndDestroy( item );
+            }
+        CleanupStack::PopAndDestroy( groups );
+        }
+    
+    // Set new snapshot to compare against
+    iChangeFinder->SetNewSnapshot( snapshot );
+    
+    // Changefinder takes ownership of the snapshot
+    CleanupStack::Pop( snapshot );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::AssignString
+// Assigns data from one descriptor into another, truncates if too long 
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::AssignString( TDes8& aDestination, const TDesC8& aSource )
+    {
+    TInt targetLength = aSource.Length();
+    if ( aDestination.MaxLength() < targetLength )
+        {
+        targetLength = aDestination.MaxLength();
+        }
+        
+    aDestination.Copy( aSource.Ptr(), targetLength );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::UpdateContactLastMod
+// Updates contact item last modified time. Contact sync will see item as changed one.
+// -----------------------------------------------------------------------------
+void CContactsGrpDataStore::UpdateContactLastMod( TContactItemId aContactId,
+        const TTime& aLastModified )
+    {
+    // Ignore errors.
+    // Cannot update timestamp if contact is already open. However modified time
+    // is most likely still updated by UI.
+    TRAP_IGNORE(
+        // OpenContactLX() places the edit lock on the cleanup stack
+        CContactItem* contact = iContactsDb->OpenContactLX( aContactId );
+        CleanupStack::PushL( contact );
+        contact->SetLastModified( aLastModified );
+        iContactsDb->CommitContactL( *contact );
+        CleanupStack::PopAndDestroy( contact );
+        CleanupStack::PopAndDestroy( 1 ); // lock object
+        );
+    }
+
+// -----------------------------------------------------------------------------
+// CContactsGrpDataStore::GroupNameExistsL
+// Checks does group name already exists.
+// -----------------------------------------------------------------------------
+TBool CContactsGrpDataStore::GroupNameExistsL( const TDesC& aLabel )
+    {
+    TBool duplicateFound( EFalse );
+    // GetGroupIdListL returns NULL if there are no groups in the database.
+    CContactIdArray* groups = iContactsDb->GetGroupIdListL();
+    if ( groups )
+        {
+        CleanupStack::PushL( groups );
+        for ( TInt i=0; i<groups->Count() && !duplicateFound; i++ )
+            {
+            CContactItem* item = iContactsDb->ReadContactLC((*groups)[i]);
+            CContactGroup* groupItem = static_cast<CContactGroup*>(item);
+            
+            if ( groupItem->HasItemLabelField() )
+                {
+                TPtrC label = groupItem->GetGroupLabelL();
+                if ( aLabel.Compare( label ) == 0 )
+                    {
+                    duplicateFound = ETrue;
+                    }
+                }
+            CleanupStack::PopAndDestroy( item );
+            }
+        CleanupStack::PopAndDestroy( groups );
+        }
+    
+    return duplicateFound;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/contactsgroup/src/contactsgrpdatastore.rss	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource data for ContactsGroup DS Plug In Adapter
+*
+*/
+
+
+#include <SmlDataFormat.rh>
+#include <SmlDataFormat.hrh>
+
+RESOURCE SML_DATA_STORE_FORMAT CONTACTSGROUP_DATA_STORE
+    {
+    version = 1;
+    display_name = "Gallery";
+    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 = "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/contactsgroup/src/snapshotitem.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+#include <hash.h>
+#include <utf.h>
+#include <cntitem.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 group content
+// -----------------------------------------------------------------------------
+void TSnapshotItem::CreateHashL( CContactGroup& aGroup )
+    {
+    CMessageDigest* hash = CMessageDigestFactory::NewDigestLC( CMessageDigest::EMD5 );
+    
+    if ( aGroup.HasItemLabelField() )
+        {
+        TPtrC label = aGroup.GetGroupLabelL();
+        HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( label );
+        CleanupStack::PushL( tempBuf );
+        hash->Update( tempBuf->Des() );
+        CleanupStack::PopAndDestroy( tempBuf );
+        }
+    
+    // Create text field from items on group
+    CContactIdArray* contactsIdArray = aGroup.ItemsContainedLC();
+    const TInt idBufferMaxSize( 400 );
+    HBufC8* tempIdBuf = HBufC8::NewLC( idBufferMaxSize );
+    TPtr8 tempId = tempIdBuf->Des();
+    const TInt KMaxNumLength(5);
+    if ( contactsIdArray ) // this is NULL if there are no objects
+        {
+        tempId.AppendNum( contactsIdArray->Count(), EHex );
+        for (TInt i=0; i< contactsIdArray->Count(); i++ )
+            {
+            if ( tempId.Length()+KMaxNumLength > tempId.MaxLength() )
+                {
+                // buffer is almost full, don't add any new items
+                LOGGER_WRITE("buffer full");
+                break;
+                }
+            // add item id
+            tempId.AppendNum( (*contactsIdArray)[i] , EHex );
+            }
+        }
+    else
+        {
+        tempId.AppendNum( 0 );
+        }
+    // update hash
+    hash->Update( tempId );
+    
+    iHash.Copy( hash->Final() );
+    
+    CleanupStack::PopAndDestroy( tempIdBuf );
+    CleanupStack::PopAndDestroy( contactsIdArray );
+    CleanupStack::PopAndDestroy( hash );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::Hash
+// Gets Hash
+// -----------------------------------------------------------------------------
+const TDesC8& TSnapshotItem::Hash() const
+    {
+    return iHash;
+    }
Binary file omads/omadsextensions/adapters/mediads/group/2001a9a1.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/group/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  bld file for Media DS adapter
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./2001a9a1.xml          Z:/private/101f99f6/capability/2001a9a1.xml
+./mediads_stub.sis      /epoc32/data/z/system/install/mediads_stub.sis
+../rom/mediads.iby     CORE_APP_LAYER_IBY_EXPORT_PATH(mediads.iby)
+
+PRJ_MMPFILES
+./mediads.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/group/createstub.bat	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Batch file for creating needed stub files.
+rem
+
+makesis -s mediads_stub.pkg
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/group/mediads.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Media DS adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          mediadsprovider.dll
+TARGETTYPE      PLUGIN
+UID             0x10009d8d 0x2001A9A1
+
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          snapshotitem.cpp
+SOURCE          changefinder.cpp
+SOURCE          mediadsprovider.cpp
+SOURCE          mediadsstore.cpp
+SOURCE          mediamanager.cpp
+SOURCE          playlistitem.cpp
+SOURCE          songitem.cpp
+SOURCE          omadsfolderobject.cpp
+SOURCE          cmdemanager.cpp
+
+USERINCLUDE     ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+
+START RESOURCE  mediadsprovider.rss
+HEADER
+TARGET          mediadsprovider.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  mediadsstore.rss
+HEADER
+TARGET          mediadsstore.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         bafl.lib
+LIBRARY         nsmlchangefinder.lib
+LIBRARY         mpxcollectionhelper.lib
+LIBRARY         mpxcommon.lib
+LIBRARY         charconv.lib
+LIBRARY         hash.lib
+LIBRARY         mpxharvesterutility.lib
+LIBRARY         mpxcollectionutility.lib
+LIBRARY         mpxcollectionmediator.lib
+LIBRARY         fbscli.lib
+LIBRARY         metadatautility.lib
+LIBRARY         platformenv.lib
+LIBRARY         mdccommon.lib
+LIBRARY         mdeclient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/group/mediads_stub.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,32 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+; Languages
+&EN
+
+; Header
+#{"Media DS Plugin"},(0x2001A9A1),1,20,0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Files to install
+""-"z:\resource\mediadsstore.rsc"
+""-"z:\resource\plugins\mediadsprovider.rsc"
+""-"z:\sys\bin\mediadsprovider.dll"
Binary file omads/omadsextensions/adapters/mediads/group/mediads_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/changefinder.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,202 @@
+/*
+* 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:  CChangeFinder class 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 media 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 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);
+	
+    /**
+    * 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 );
+
+    /**
+    * 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 );
+	
+private:
+	
+    /**
+    * 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/mediads/inc/cmdemanager.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,159 @@
+/*
+* 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:  CMdEManager declaration
+*
+*/
+
+
+#ifndef CMDEMANAGER_H
+#define CMDEMANAGER_H
+
+#include <e32base.h>
+#include <mdesession.h>
+#include <mdequery.h>
+
+#include "playlistitem.h"
+
+class MMdEManagerObserver
+    {
+public:
+    virtual void AlbumsReaded( TInt aError ) = 0;
+    virtual void AlbumReplaced( TInt aError ) = 0;
+    };
+
+class CMdEManager : public CBase,
+                        MMdESessionObserver,
+                        MMdEQueryObserver
+    {
+public:
+    // Cancel and destroy
+    ~CMdEManager();
+
+    // Two-phased constructor.
+    static CMdEManager* NewL( MMdEManagerObserver& aObserver );
+
+public:
+    
+    /**
+	 * Start enumerating albums. Calls MMdEManagerObserver::AlbumsReaded when ready.
+	 * This needs to be called before any other operations.
+	 */ 
+    void GetAlbumsL();
+    
+
+    RPointerArray<CPlaylistItem>& AlbumsArray(){ return iAlbums; };
+    const CPlaylistItem& AlbumL( TInt aAlbumId ) const;
+    
+    void CreateAlbumL( CPlaylistItem& aAlbum );
+    void ReplaceAlbumL( TInt aAlbumId, CPlaylistItem& aAlbum );
+    void DeleteAlbumL( TInt aAlbumId );
+    
+	/**
+	 * Cancels any outstanding request if any.
+	 */
+    void Cancel();
+    
+private:
+    void StartProcessingAlbumsL();
+    void ProcessNextAlbumL();
+    void FindItemsOnAlbumL( TItemId aAlbumObjectId );
+    
+private: // from MMdESessionObserver
+    /**
+     * Called to notify the observer that opening the session has been 
+     * completed and, if the opening succeeded, the session is ready for use.
+     *
+     * @param aSession session
+     * @param aError   <code>KErrNone</code>, if opening the session succeeded;
+     *                 or one of the system-wide error codes, if opening the 
+     *                 session failed
+     */
+    void HandleSessionOpened(CMdESession& aSession, TInt aError);
+
+    /**
+     * Called to notify the observer about errors, which are not a direct 
+     * consequence of the operations initiated by the client but caused by 
+     * some external source (e.g., other clients). The error cannot be 
+     * recovered and all on-going operations initiated by the client have been 
+     * aborted. Any attempts to continue using the session will cause a panic. 
+     * The client should close the session immediately and try to open a new 
+     * session, if it needs to continue using the metadata engine.
+     *
+     * @param aSession session
+     * @param aError one of the system-wide error codes
+     */
+    void HandleSessionError(CMdESession& aSession, TInt aError);
+
+private: // from MMdEQueryObserver
+    /**
+     * Called to notify the observer that new results have been received 
+     * in the query.
+     *
+     * @param aQuery              Query instance that received new results.
+     * @param aFirstNewItemIndex  Index of the first new item that was added
+     *                            to the result item array.
+     * @param aNewItemCount       Number of items added to the result item 
+     *                            array.
+     */
+    void HandleQueryNewResults(CMdEQuery& aQuery,
+                                       TInt aFirstNewItemIndex,
+                                       TInt aNewItemCount);
+
+
+            
+    /**
+     * Called to notify the observer that the query has been completed,
+     * or that an error has occured.
+     *
+     * @param aQuery  Query instance.
+     * @param aError  <code>KErrNone</code>, if the query was completed
+     *                successfully. Otherwise one of the system-wide error 
+     *                codes.
+     */
+    void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
+private:
+    
+    CMdEManager( MMdEManagerObserver& aObserver );
+    
+    void ConstructL();
+    
+    void HandleAlbumQueryCompletedL( CMdEObjectQuery& aQuery );
+    void HandleObjectQueryCompletedL( CMdEObjectQuery& aQuery );
+    void HandleRelationQueryCompletedL( CMdERelationQuery& aQuery );
+    
+private:
+    enum TCMdEManagerState
+        {
+        EUninitialized,             // Uninitialized / initialization is ongoing
+        EWaitingToEnumerateAlbums,  // Initializing and starting collecting albums info
+        EEnumeratingAlbums,         // Album enumeration is ongoing
+        EReplacingAlbum,            // Replacing album (searching removed relation id:s)
+        EIdle                       // Ready for next operation
+        };
+
+private:
+    MMdEManagerObserver& iObserver;
+    TCMdEManagerState   iState;
+    
+    CMdESession*        iMde;
+    CMdEObjectQuery*    iAlbumQuery;
+    CMdEObjectQuery*    iObjectQuery;
+    CMdERelationQuery*  iContainmentQuery;
+    
+    RPointerArray<CPlaylistItem> iAlbumsInProgress;
+    RPointerArray<CPlaylistItem> iAlbums;
+    
+    };
+
+#endif // CMDEMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/logger.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging macros used by Media DS Plugin
+*
+*/
+
+
+#ifndef __LOGGER_H__
+#define __LOGGER_H__
+
+#ifdef _DEBUG
+    #ifdef __WINS__
+        // File logging for WINS
+        #define __FLOGGING__
+    #else
+        #define __FLOGGING__ // enable to log file on target HW
+    #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, "MediaDS" );
+    _LIT( KLogFile, "MediaDS.txt" );
+    
+    _LIT(KTracePrefix16, "[MediaDs] ");
+    _LIT8(KTracePrefix8, "[MediaDs] ");
+    _LIT8(KFuncEntryFormat8, "%S : Begin");
+    _LIT8(KFuncExitFormat8, "%S : End");
+    _LIT8(KFuncReturnFormat8, "%S : End, return: %d");
+    _LIT8(KFuncFormat8, "><%S");
+    
+    const TInt KMaxLogLineLength = 512;
+    
+    /**
+    * logging macros, for public use
+    */
+
+    #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 );}
+    
+    // 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);}
+    
+    #define TRACE_FUNC_RET( number )  {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncReturnFormat8, &ptr8, number);}
+    // 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 _DEBUG defined
+    
+    // No loggings --> reduced code size
+    #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
+    #define TRACE_FUNC_RET( number )
+
+#endif // _DEBUG
+
+#endif // __LOGGER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/mediadsprovider.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef __MEDIADSPROVIDER_H__
+#define __MEDIADSPROVIDER_H__
+
+// INCLUDES
+#include <smldataprovider.h>
+
+// FORWARD DECLARATIONS
+class CMediaDsDataStore;
+class CSmlDataStoreFormat;
+
+/**
+ * This class is derived from ECom Data Provider plugin-interface (CSmlDataProvider).
+ * 
+ */
+class CMediaDataProvider : public CSmlDataProvider
+    {
+
+public:
+    
+    /**
+    * Constructor.
+	*
+	* @return CMediaDataProvider*, a new CMediaDataProvider instance.
+    */
+    static CMediaDataProvider* NewL();
+    
+	/**
+    * Destructor.
+    */
+    virtual ~CMediaDataProvider();
+
+    
+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.
+    */
+    CMediaDataProvider();
+    
+	/**
+    * 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 iFs;
+    
+    };
+
+#endif // __MEDIADSPROVIDER_H__  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/mediadsproviderdefs.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef __MEDIADSPROVIDERDEFS_H__ 
+#define __MEDIADSPROVIDERDEFS_H__ 
+
+#include <e32def.h>
+#include <e32cmn.h>
+
+// Database name
+
+_LIT( KMediaDsDbName, "mediads" ); // Default db
+_LIT( KMediaDsRefreshDbName, "mediadsrefresh" ); // Used to refresh db, before opening
+
+// Resource file for CSmlDataStoreFormat in SIS installation
+_LIT(KMediaDsStoreFormatRsc,"mediadsstore.rsc");
+
+// max foldername
+const TInt KMaxFolderNameLength = 50;
+
+// Implementation uid
+const TUint KMediaDataProviderImplUid = 0x2001A9A1;
+
+// Folders
+_LIT( KAllSongs, "All songs" );
+_LIT( KPlaylists, "Playlists" );
+_LIT( KAlbums, "Albums" );
+const TInt KAllSongsFolderId( 1 );
+const TInt KPlaylistsFolderId( 2 );
+const TInt KAlbumsFolderId( 3 );
+
+const TInt KLastFolderId( KAlbumsFolderId );
+
+#endif // __MEDIADSPROVIDERDEFS_H__ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/mediadsstore.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,258 @@
+/*
+* 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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef __MEDIADATASTORE_H__
+#define __MEDIADATASTORE_H__
+
+// INCLUDES
+#include <smldataprovider.h>
+#include <mpxcollectionobserver.h>
+
+#include "mediadsproviderdefs.h" 
+#include "changefinder.h"
+#include "mediamanager.h"
+#include "cmdemanager.h"
+
+// FORWARD DECLARATIONS
+class CNSmlDataItemUidSet;
+class MMPXHarvesterUtility;
+class MMPXCollectionUtility;  
+class CMPXCollectionMediator;
+
+
+/**
+* @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 CMediaDsDataStore : public CSmlDataStore,
+                          public MMediaManagerObserver,
+                          public MMdEManagerObserver
+    {
+public:  
+    
+    /**
+    * Constructor
+	*
+	* @return CMediaDsDataStore* instance.
+    */
+    static CMediaDsDataStore* NewLC( RFs& aFs );
+    
+	/**
+    * Destructor
+    */
+    virtual ~CMediaDsDataStore();
+
+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);
+
+protected: // from MMPXCollectionObserver
+    void HandleCollectionMessage(CMPXMessage* aMsg, TInt /*aErr*/) ;
+    void HandleOpenL(const CMPXMedia& aEntries,
+          TInt aIndex,TBool aComplete,TInt aError);
+    void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError);
+    void HandleCommandComplete(CMPXCommand* /*aCommandResult*/, 
+                                           TInt /*aError*/);
+    void HandleCollectionMediaL(const CMPXMedia& aMedia, 
+                                            TInt aError);
+    // from MMediaManagerObserver
+    void RegisterAllPlayListsCompleted( TInt aError );
+    void RegisterAllSongsCompleted( TInt aError );
+    
+protected: // from MMdEManagerObserver
+    void AlbumsReaded( TInt aError );
+    void AlbumReplaced( TInt aError );
+
+private: 
+
+	/**
+    * C++ Constructor.
+    */
+    CMediaDsDataStore( RFs& aFs );
+    
+	/**
+    * 2nd-phase Constructor.
+    *
+    * @param aMsvSession	IN: a session handle to message store
+    */    
+    void ConstructL();
+	
+	/**
+    * Registers snapshot to ChangeFinder.
+    */
+	void RegisterSnapshotL();
+
+	void RegisterFoldersL( CSnapshotArray& aItemArray );
+	
+	void FinalizeOpenStore();
+	
+	inline TInt MapSyncIdToAlbumId( TSmlDbItemUid aSyncId );
+	inline TSmlDbItemUid MapAlbumIdToSyncId( TInt aAlbumId );
+	
+private: // Data members
+
+	
+    enum TState
+        {
+        EClosed = 0,
+        EOpening,
+        EOpenAndWaiting,
+        EReplace,
+        ECreatePlaylist
+        };
+    
+    /**
+    * The state of the plugin.
+    */
+    TState iCurrentState;   
+    
+    /**
+	* A flag indicating the existence of synchronization history.
+	*/
+    TBool iHasHistory;
+    
+    /**
+	* Key that is used in sorting snapshot.
+	*/
+    const TKeyArrayFix iKey;
+
+    /**
+	* Change finder, used to determine db modifications.
+	*/
+    CChangeFinder* iChangeFinder;
+    
+    /**
+	* The location for temporary data
+	*/
+    CBufFlat* iDataBuffer;
+    
+    /**
+	* Current read position at the data chunk from MMS engine
+	*/      
+    TInt iReadPosition;
+    
+    /**
+	* Indicates wheter this was only status update
+	*/      
+    TInt iWrittenDataLength;
+
+    /**
+	* Stores the currently active message id.
+	*/
+    TSmlDbItemUid iCurrentId;
+    
+    /**
+	* Pointer to the variable, receiving the created Uid.
+	*/
+	TSmlDbItemUid* iCreatedUid;  
+
+    /**
+	* 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 manage playlists and songs.
+     */
+    CMediaManager*  iMediaManager;
+    TBool           iMediaManagerReady;
+    
+    /**
+     * Used to manage photo albums.
+     */
+    CMdEManager*    iMdEManager;
+    TBool           iMdEManagerReady;
+    
+    TInt            iError;
+    
+    CMD5* iHasher;
+    
+    RFs&    iFs;
+    
+    CSnapshotArray* iSnapshot;
+    TSnapshotItem   iItemInReplacement;
+    };
+
+#endif // __MEDIADATASTORE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/mediamanager.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef _CMEDIAMANAGER_H
+#define _CMEDIAMANAGER_H
+
+#include <e32base.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxcollectionutility.h>
+#include <mpxcollectionmediator.h>
+#include <mpxcollectionobserver.h>
+#include <mpxharvesterutilityobserver.h>
+#include <mpxharvesterutility.h>
+#include <mpxcollectionhelperobserver.h>
+ 
+#include "changefinder.h"
+#include "songitem.h"
+
+class CMPXMedia;
+class MMPXCollectionHelper;
+
+class MMediaManagerObserver : public MMPXCollectionObserver
+    {
+public:
+    virtual void RegisterAllPlayListsCompleted( TInt aError ) = 0;
+    virtual void RegisterAllSongsCompleted( TInt aError ) = 0;
+    };
+
+/**
+ * @brief This class manages playlist's on media library. Also songs metadata can be queried.
+ * 
+ */
+class CMediaManager : public CActive, private MMPXCollectionHelperObserver
+    {
+public:
+
+    static CMediaManager* NewL( RFs& aFs, MMediaManagerObserver* aObserver, TKeyArrayFix aKey, CMD5& aHasher );
+    
+    ~CMediaManager();
+    
+    /**
+     * Starts scanning music library.
+     * Calls MMPXCollectionObserver::HandleCollectionMessage when completed.
+     */
+    void ScanL();
+    
+    /**
+     * Cancel scan
+     */
+    void CancelScanL();
+    
+    /**
+     * Set current snapshot.
+     * @param aSnapshot
+     */
+    void SetSnapshot( CSnapshotArray* aSnapshot ){iSnapshotArray=aSnapshot;};
+    
+    /**
+     * Starts registering all playlists.
+     * Snapshot must be set before calling this.
+     * Calls MMediaManagerObserver::RegisterAllPlayListsCompleted when ready
+     * @return KErrNone if operation succesfully started.
+     */
+    TInt RegisterAllPlayLists();
+    
+    /**
+     * Starts registering all songs.
+     * Snapshot must be set before calling this.
+     * Calls MMediaManagerObserver::RegisterAllSongsCompleted when ready
+     * @return KErrNone if operation succesfully started.
+     */
+    TInt RegisterAllSongs();
+    
+    /**
+     * Gets CPlaylistItem
+     * @param aPlaylistId playlist id to get.
+     * @param aPlaylist returned playlist.
+     */
+    void GetPlayListL( TInt aPlaylistId, CPlaylistItem& aPlaylist );
+    
+    /**
+     * Gets CSongItem
+     * @param aSongId song id to get.
+     * @param aSongItem returned song.
+     */
+    void GetSongL( TInt aSongId, CSongItem& aSongItem );
+    
+    /**
+     * Creates new playlist to music library
+     * @param aNewUid returns new playlist id, if succesfully added.
+     * @param aPlaylist playlist to be added. Uri is updated to aPlaylist.
+     */
+    void CreateNewPlaylistL( TInt& aNewUid, CPlaylistItem& aPlaylist );
+    
+    /**
+     * Replaces existing playlist in music library
+     * @param aPlaylistId playlist id to be replaced. Uri is read to aPlaylist.
+     * @param aPlaylist new content.
+     */
+    void ReplacePlaylistL( TInt aPlaylistId, CPlaylistItem& aPlaylist );
+    
+    /**
+     * Deletes playlist from music library
+     * @param aPlaylistId playlist id to be deleted.
+     */
+    void DeletePlaylistL( TInt aPlaylistId );
+    
+private: // From MMPXCollectionHelperObserver
+    void HandleAddFileCompleteL( TInt aErr );
+    
+private:
+    CMediaManager( RFs& aFs, MMediaManagerObserver* aObserver, TKeyArrayFix aKey, CMD5& aHasher );
+    
+    void ConstructL();
+    
+    void RegisterPlaylistL( const CMPXMedia& aMedia );
+    
+    void RegisterSongL( const CMPXMedia& aMedia );
+    
+    CMPXMedia* FetchPlaylistContentL( TInt aId );
+    
+    CMPXMedia* FindPlaylistL( TInt aUid );
+    
+    void AddPlaylistL( CMPXMedia* aMedia );
+    
+    void ReadSongAttributesL( const CMPXMedia& aMedia, CSongItem& aSongItem, TBool aReadFileDetails );
+    
+    CMPXMedia* CreatePlaylistMediaL( const CPlaylistItem& aPlaylist );
+    
+    CMPXMediaArray* CreateMediaArrayLC( const CPlaylistItem& aPlaylist );
+    
+    void ReadPlaylistCountL();
+    void ReadPlaylistItemsL();
+    
+    void ReadSongCountL();
+    void ReadSongItemsL();
+private: // from CActive
+    
+    void DoCancel();
+    void RunL();
+    TInt RunError( TInt aError );
+    
+private:
+    
+    enum TState
+        {
+        EIdle = 0,
+        EReadingPlaylistCount,
+        EEnumeratingPlaylists,
+        EReadingSongCount,
+        EEnumeratingSongs
+        };
+    TState iCurrentState;
+    
+    CMPXMedia*              iFoundedMedia;
+    TInt                    iReadedItems;
+    TInt                    iItemsFound;
+    CSnapshotArray*         iSnapshotArray; // not owned
+    
+    MMediaManagerObserver*  iObserver;
+    const TKeyArrayFix      iKey;
+    MMPXCollectionHelper*   iCollectionHelper;
+    
+    CMD5&                   iHasher;
+    
+    MMPXHarvesterUtility*   iHarvester;
+    CMPXCollectionMediator* iMediator;
+    MMPXCollectionUtility*  iCollection;
+    RFs&                    iFs;
+    
+    bool                    iWaitOngoing;
+    CActiveSchedulerWait    iWait;
+    };
+
+
+#endif // _CMEDIAMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/omadsfolderobject.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  COMADSFolderObject class implementation
+*
+*/
+
+
+
+#ifndef __OMADSFOLDEROBJECT_H__
+#define __OMADSFOLDEROBJECT_H__
+
+#include <e32base.h>
+
+const TInt KMaxElementLength = 255;
+const TInt KMaxXmlLineLength = 1024;
+
+class COMADSFolderObject : public CBase
+    {
+public:
+
+    static COMADSFolderObject* NewLC();
+    ~COMADSFolderObject();
+
+    // 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;};
+    
+    void ExportFolderXmlL( CBufBase& aBuffer );
+    
+private:
+    void ExportL(); 
+    void WriteL( const TDesC &aData );
+    
+private:
+    
+    TBuf8<KMaxXmlLineLength>    iTemp;
+    TPath                       iName;
+    TDateTime                   iCreatedDate;
+    TDateTime                   iModifiedDate;
+    CBufBase*                   iBuffer; // Not owned
+    TInt                        iWriteBufPosition;
+    TInt                        iWriteBufSize;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/playlistitem.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef PLAYLISTITEM_H_
+#define PLAYLISTITEM_H_
+
+#include <e32base.h>
+#include <s32mem.h>
+#include <BADESCA.H>
+
+class CPlaylistItem : public CBase
+    {
+public:
+    static CPlaylistItem* NewLC();
+    ~CPlaylistItem();
+    
+    void SetId( TInt aId );
+    TInt Id() const;
+    
+    void SetTitleL( const TDesC& aTitle );
+    const TDesC& Title() const;
+    
+    void SetUrlL( const TDesC& aUrl );
+    const TDesC& Url() const;
+    
+    void AddItemL( const TDesC& aSongUri );
+    TInt ItemCount() const;
+    TPtrC16 ItemAt( TInt aIndex ) const;
+    TInt FindItem( const TDesC16& aPtr, TInt& aPos, TKeyCmpText aTextComparisonType=ECmpFolded ) const;
+    
+    void ExportL( RBufWriteStream& aStream ) const;
+    void ImportL( const TDesC& aBuffer );
+    
+private:
+    CPlaylistItem();
+    void ConstructL();
+    
+private:
+    
+    TInt ReadNextLine( const TDesC& aBuffer, TPtrC& aLine );
+    
+private:
+    TInt iId;
+    HBufC* iTitle;
+    HBufC* iUrl;
+
+    CDesCArrayFlat* iDescArray;
+    };
+
+#endif /* PLAYLISTITEM_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/sconmetadatafielddefs.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,131 @@
+/*
+* 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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#ifndef _SCONMETADATAFIELDDEFS_H_
+#define _SCONMETADATAFIELDDEFS_H_
+
+// Content type header
+const TUint8 KSconMetadataHeaderAudio( 0x01 );
+const TUint8 KSconMetadataHeaderExif ( 0x02 );
+const TUint8 KSconMetadataHeaderVideo( 0x03 );
+
+const TUint8 KSconMetadataHeaderVersion ( 0x03 ); // format version = 3
+
+// fields for audio
+const TUint8 KSconAudioID3Version   ( 0x01 );
+const TUint8 KSconAudioTitle        ( 0x02 );
+const TUint8 KSconAudioArtist       ( 0x03 );
+const TUint8 KSconAudioAlbum        ( 0x04 );
+const TUint8 KSconAudioYear         ( 0x05 );
+const TUint8 KSconAudioComment      ( 0x06 );
+const TUint8 KSconAudioAlbumTrack   ( 0x07 );
+const TUint8 KSconAudioGenre        ( 0x08 );
+const TUint8 KSconAudioComposer     ( 0x09 );
+const TUint8 KSconAudioCopyright    ( 0x0a );
+const TUint8 KSconAudioOriginalArtist( 0x0b );
+const TUint8 KSconAudioUrl          ( 0x0c );
+const TUint8 KSconAudioUserUrl      ( 0x0d );
+const TUint8 KSconAudioJpeg         ( 0x0e );
+const TUint8 KSconAudioVendor       ( 0x0f );
+const TUint8 KSconAudioRating       ( 0x10 );
+const TUint8 KSconAudioUniqueFileIdentifier( 0x11 );
+const TUint8 KSconAudioDuration     ( 0x12 );
+const TUint8 KSconAudioDate         ( 0x13 );
+const TUint8 KSconAudioMimeType     ( 0x14 );
+const TUint8 KSconAudioFilename     ( 0x15 );
+const TUint8 KSconAudioFileSize     ( 0x16 );
+
+// fields for exif
+const TUint8 KSconExifThumbnail         ( 0x01 );
+const TUint8 KSconExifDescription       ( 0x02 );
+const TUint8 KSconExifMake              ( 0x03 );
+const TUint8 KSconExifModel             ( 0x04 );
+const TUint8 KSconExifDateTime          ( 0x05 );
+const TUint8 KSconExifSoftware          ( 0x06 );
+const TUint8 KSconExifCopyright         ( 0x07 );
+const TUint8 KSconExifOrientation       ( 0x08 );
+const TUint8 KSconExifXResolution1      ( 0x09 );
+const TUint8 KSconExifXResolution2      ( 0x0a );
+const TUint8 KSconExifYResolution1      ( 0x0b );
+const TUint8 KSconExifYResolution2      ( 0x0c );
+const TUint8 KSconExifResolutionUnit    ( 0x0d );
+const TUint8 KSconExifYCbCrPositioning  ( 0x0e );
+const TUint8 KSconExifIsoSpeedRatings   ( 0x0f );
+const TUint8 KSconExifDateTimeOriginal  ( 0x10 );
+const TUint8 KSconExifDateTimeDigitized ( 0x11 );
+const TUint8 KSconExifMakerNote         ( 0x12 );
+const TUint8 KSconExifUserComment       ( 0x13 );
+const TUint8 KSconExifRelatedSoundFile  ( 0x14 );
+const TUint8 KSconExifExposureTime1     ( 0x15 );
+const TUint8 KSconExifExposureTime2     ( 0x16 );
+const TUint8 KSconExifComponentsConfiguration ( 0x17 );
+const TUint8 KSconExifFlash             ( 0x18 );
+const TUint8 KSconExifColorSpace        ( 0x19 );
+const TUint8 KSconExifPixelXDimension   ( 0x1a );
+const TUint8 KSconExifPixelYDimension   ( 0x1b );
+const TUint8 KSconExifExposureMode      ( 0x1c );
+const TUint8 KSconExifWhiteBalance      ( 0x1d );
+const TUint8 KSconExifSceneCaptureType  ( 0x1e );
+const TUint8 KSconExifExposureProgram   ( 0x1f );
+const TUint8 KSconExifApertureValue1    ( 0x20 );
+const TUint8 KSconExifApertureValue2    ( 0x21 );
+const TUint8 KSconExifExposureBiasValue1 ( 0x22 );
+const TUint8 KSconExifExposureBiasValue2 ( 0x23 );
+const TUint8 KSconExifMeteringMode      ( 0x24 );
+const TUint8 KSconExifLightSource       ( 0x25 );
+const TUint8 KSconExifFileSource        ( 0x26 );
+const TUint8 KSconExifDigitalZoomRatio1 ( 0x27 );
+const TUint8 KSconExifDigitalZoomRatio2 ( 0x28 );
+const TUint8 KSconExifContrast          ( 0x29 );
+const TUint8 KSconExifSaturation        ( 0x2a );
+const TUint8 KSconExifSharpness         ( 0x2b );
+const TUint8 KSconExifExifVersion       ( 0x2c );
+const TUint8 KSconExifFlashPixVersion   ( 0x2d );
+const TUint8 KSconExifThumbXResolution1 ( 0x2e );
+const TUint8 KSconExifThumbXResolution2 ( 0x2f );
+const TUint8 KSconExifThumbYResolution1 ( 0x30 );
+const TUint8 KSconExifThumbYResolution2 ( 0x31 );
+const TUint8 KSconExifThumbResolutionUnit   ( 0x32 );
+const TUint8 KSconExifThumbCompression      ( 0x33 );
+const TUint8 KSconExifThumbJpegInterchangeFormat        ( 0x34 );
+const TUint8 KSconExifThumbJpegInterchangeFormatLength  ( 0x35 );
+const TUint8 KSconExifShutterSpeedValue1 ( 0x36 );
+const TUint8 KSconExifShutterSpeedValue2 ( 0x37 );
+const TUint8 KSconExifBrightnessValue1  ( 0x38 );
+const TUint8 KSconExifBrightnessValue2  ( 0x39 );
+const TUint8 KSconExifCustomRendered    ( 0x3a );
+const TUint8 KSconExifGainControl       ( 0x3b );
+const TUint8 KSconExifGpsVersion        ( 0x3c );
+const TUint8 KSconExifGPSLatitude    	( 0x3d );
+const TUint8 KSconExifGPSLongitude      ( 0x3e );
+const TUint8 KSconExifGPSAltitude       ( 0x3f );
+const TUint8 KSconExifBitDepth	        ( 0x40 );
+
+// fields for video
+const TUint8 KSconVideoFormat			( 0x01 );
+const TUint8 KSconVideoFrameRate		( 0x02 );
+const TUint8 KSconVideoFrameSizeWidth	( 0x03 );
+const TUint8 KSconVideoFrameSizeHeight	( 0x04 );
+const TUint8 KSconVideoVideoBitRate		( 0x05 );
+const TUint8 KSconVideoAudioBitRate		( 0x06 );
+const TUint8 KSconVideoDuration			( 0x07 );
+const TUint8 KSconVideoThumbnail		( 0x08 );
+const TUint8 KSconVideoAudioStreamMimetype	( 0x09 );
+const TUint8 KSconVideoVideoStreamMimetype	( 0x0a );
+
+#endif // _SCONMETADATAFIELDDEFS_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/snapshotitem.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,133 @@
+/*
+* 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:  Private snapshot item header
+*
+*/
+
+
+#ifndef __SNAPSHOTITEM_H__
+#define __SNAPSHOTITEM_H__
+
+// INCLUDES
+#include <syncml/SmlDataSyncDefs.h>
+#include <hash.h>
+#include "mediadsproviderdefs.h"
+#include "songitem.h"
+#include "playlistitem.h"
+
+typedef TBuf<KMaxFolderNameLength> TFolderName;
+
+// CLASS DECLARATION
+
+/**
+ * @brief TSnapshotItem
+ * This class represents a single item in the ChangeFinder snapshot.
+ * 
+ */
+
+// Defines the maximum length of a hash.
+const TInt KMaxHashLength = 16;
+typedef TBuf8<KMaxHashLength> THashValue;
+
+class TSnapshotItem
+	{ 
+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 );
+	
+	/**
+    * 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 );	
+	
+	/**
+    * Getter for item UID value.
+    * @return const TSmlDbItemUid& item UID.
+    */
+    const TSmlDbItemUid& ItemId() const;
+
+    /**
+    * Setter for item UID value.
+    * @param aItemId item UID.
+    */
+    void SetItemId( const TSmlDbItemUid& aItemId );
+
+    /**
+    * Getter for parent UID value.
+    * @return const TSmlDbItemUid& parent UID.
+    */
+    const TSmlDbItemUid& ParentId() const;
+
+    /**
+    * Setter for parent UID value.
+    * @param aParentId parent UID.
+    */
+    void SetParentId( const TSmlDbItemUid& aParentId );
+	
+    /**
+     * Generate hash value from foldername
+     * @param aFolderName foldername
+     * @param CMD5& aHasher MD5 hasher
+     */
+	void SetItemHash( const TDesC& aFolderName, CMD5& aHasher );
+	
+	/**
+     * Generate hash value from aSongItem content
+     * @param aSongItem song item
+     * @param CMD5& aHasher MD5 hasher
+     */
+	void SetItemHash( const CSongItem& aSongItem, CMD5& aHasher );
+	
+	/**
+     * Generate hash value from aPlaylist content
+     * @param aPlaylist aPlaylist
+     * @param CMD5& aHasher MD5 hasher
+     */
+	void SetItemHash( const CPlaylistItem& aPlaylist, CMD5& aHasher );
+	
+	/**
+	 * Getter for generated hash value.
+	 * @return const TDesC8& hash value
+	 */
+	const TDesC8& Hash() const;
+	
+private:
+	TSmlDbItemUid iItemId;
+	TSmlDbItemUid iParentId;
+    THashValue    iHash;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/inc/songitem.h	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef TSONGITEM_H_
+#define TSONGITEM_H_
+
+#include <e32base.h>
+#include <s32strm.H>
+
+
+class CSongItem : public CBase
+    {
+public:
+    
+    static CSongItem* NewLC();
+    ~CSongItem();
+    
+    void SetId( TInt aId );
+    TInt Id() const;
+    
+    void SetUriL( const TDesC& aUri );
+    const TDesC& Uri() const;
+    
+    void SetTitleL( const TDesC& aTitle );
+    const TDesC& Title() const;
+    
+    void SetMimeTypeL( const TDesC& aMimeType );
+    const TDesC& MimeType() const;
+    
+    void SetDuration( TInt aDuration );
+    TInt Duration() const;
+    
+    void SetArtistL( const TDesC& aArtist );
+    const TDesC& Artist() const;
+    
+    void SetAlbumL( const TDesC& aAlbum );
+    const TDesC& Album() const;
+    
+    void SetYear( TInt aYear );
+    TInt Year() const;
+    
+    void SetAlbumTrack( TInt aId );
+    TInt AlbumTrack() const;
+    
+    void SetGenreL( const TDesC& aGenre );
+    const TDesC& Genre() const;
+    
+    void SetCommentL( const TDesC& aComment );
+    const TDesC& Comment() const;
+    
+    void SetComposerL( const TDesC& aComposer );
+    const TDesC& Composer() const;
+    
+    void SetRating( TInt aRating );
+    TInt Rating() const;
+    
+    void SetModifiedTime( TTime& aTime );
+    const TTime& ModifiedTime() const;
+    
+    void SetFileSize( TInt32 aSize );
+    TInt32 FileSize() const;
+    
+    /**
+     * Export item.
+     * @param aStream stream where to export.
+     */
+    void ExportL( RWriteStream& aStream );
+    
+private:
+    CSongItem();
+    void ConstructL();
+    
+    inline void WriteUnicodeL( RWriteStream& aStream, const TDesC& aData, const TUint8 aFieldId );
+    
+    inline void WriteDataFieldL( RWriteStream& aStream, const TDesC8& aData, const TUint8 aFieldId );
+    
+    inline void WriteUInt16FieldL( RWriteStream& aStream, TUint16 aData, const TUint8 aFieldId );
+    
+    inline void WriteUInt32FieldL( RWriteStream& aStream, TUint32 aData, const TUint8 aFieldId );
+    
+private:
+    TInt      iId;
+    HBufC*    iUri;
+    HBufC*    iTitle;
+    HBufC*    iMimeType;
+    TInt      iDuration;
+    HBufC*    iArtist;
+    HBufC*    iAlbum;
+    TInt      iYear;
+    TInt      iAlbumTrack;
+    HBufC*    iGenre;
+    HBufC*    iComment;
+    HBufC*    iComposer;
+    TInt      iRating;
+    TTime     iModifiedTime;
+    TInt      iSize;
+    };
+
+#endif /* TSONGITEM_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/rom/mediads.iby	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for Media DS plugin
+*
+*/
+
+
+#ifndef __MEDIADS_IBY__
+#define __MEDIADS_IBY__
+
+ECOM_PLUGIN(mediadsprovider.dll,mediadsprovider.rsc)
+data=DATAZ_\RESOURCE_FILES_DIR\mediadsstore.rsc         RESOURCE_FILES_DIR\mediadsstore.rsc
+data=DATAZ_\private\101F99F6\capability\2001A9A1.XML    private\101F99F6\capability\2001A9A1.XML
+
+data=ZSYSTEM\install\mediads_stub.sis             	    system\install\mediads_stub.sis
+
+#endif //__MEDIADS_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/sis/backup_registration.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?> 
+<backup_registration>
+    <system_backup />
+    <restore requires_reboot = "no"/>
+</backup_registration> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/sis/mediads.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,42 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: PKG file for Media DS adapter
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Media DS Plugin"},(0x2001A9A1),1,20,0,TYPE=SA, RU
+;
+
+; S60 v5.2
+[0x20022E6D ], 0, 0, 0, {"Series60ProductID"}
+
+
+"\epoc32\data\z\resource\mediadsstore.rsc"                  -"c:\resource\mediadsstore.rsc"
+"\epoc32\data\z\resource\plugins\mediadsprovider.rsc"       -"c:\resource\plugins\mediadsprovider.rsc"
+"\epoc32\release\ARMV5\UREL\mediadsprovider.dll"            -"c:\sys\bin\mediadsprovider.dll"
+"\epoc32\data\Z\private\101F99F6\capability\2001a9a1.xml"   -"c:\private\101F99F6\import\2001a9a1.xml"
+
+"backup_registration.xml"   -"c:\private\10202D56\import\packages\2001A9A1\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/sis/mediads_debug.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,42 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: PKG file for Media DS adapter (debug)
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"Media DS Plugin"},(0x2001A9A1),1,20,0,TYPE=SA, RU
+;
+
+; S60 v5.2
+[0x20022E6D ], 0, 0, 0, {"Series60ProductID"}
+
+
+"\epoc32\data\z\resource\mediadsstore.rsc"                  -"c:\resource\mediadsstore.rsc"
+"\epoc32\data\z\resource\plugins\mediadsprovider.rsc"       -"c:\resource\plugins\mediadsprovider.rsc"
+"\epoc32\release\ARMV5\UDEB\mediadsprovider.dll"            -"c:\sys\bin\mediadsprovider.dll"
+"\epoc32\data\Z\private\101F99F6\capability\2001a9a1.xml"   -"c:\private\101F99F6\import\2001a9a1.xml"
+
+"backup_registration.xml"   -"c:\private\10202D56\import\packages\2001A9A1\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/changefinder.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,537 @@
+/*
+* 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:  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()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt error;
+    TRAP( error, CloseL() );
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE( "CChangeFinder::~CChangeFinder, CloseL failed." );
+        }
+    
+    delete iCurrentSnapshot;
+    iCurrentSnapshot = NULL;
+    delete iOldSnapshot;
+    iOldSnapshot = NULL;
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ConstructL
+// 2nd phase constructor for the class, reads snapshot from stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::ConstructL( TBool& aHasHistory )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TUid streamId;
+    streamId.iUid = iStreamUid;
+    
+    aHasHistory = iSyncRelationship.IsStreamPresentL(streamId);
+    
+    if ( aHasHistory )
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, history exists.");
+        RReadStream readStream;
+        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 );
+            TRACE_FUNC_EXIT;
+            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 );
+            }
+
+        CleanupStack::PopAndDestroy( &readStream );
+        }
+    else
+        {
+        LOGGER_WRITE("CChangeFinder::ConstructL, no sync history.");
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CloseL
+// Closes ChangeFinder object and writes snapshot to stream
+// -----------------------------------------------------------------------------
+void CChangeFinder::CloseL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // 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();
+    CleanupStack::PopAndDestroy( &writeStream );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ResetL
+// Resets synchronization history, all contetn is considered new after this call
+// -----------------------------------------------------------------------------
+void CChangeFinder::ResetL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // 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();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindChangedItemsL
+// Compares snapshots, finds changed items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids )
+    {   
+    TRACE_FUNC_ENTRY;
+    
+    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 count: %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 );
+            // Compare hash to see whether this was changed
+            if ( oldItem.Hash().Compare( currentItem.Hash() ) != 0
+                    || oldItem.ParentId() != currentItem.ParentId() )
+                {
+                aChangedUids.AddItem( currentItem.ItemId() );
+                //LOGGER_WRITE_1( "Item %d was changed.", currentItem.ItemId() );  
+                }
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindDeletedItemsL
+// Compares snapshots, finds deleted items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( !iOldSnapshot )
+        {
+        LOGGER_WRITE( "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() );
+            }       
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::FindNewItemsL
+// Compares snapshots, finds new items
+// -----------------------------------------------------------------------------
+void CChangeFinder::FindNewItemsL( CNSmlDataItemUidSet& aNewUids )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    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() );
+            }       
+        }
+        
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemAddedL
+// Adds item to snapshot, this item is no longer considered new
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemAddedL( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // 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 );
+        }
+    iOldSnapshot->Compress();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemDeletedL
+// Removes item to snapshot, this item is no longer considered deleted
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemDeletedL( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    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." );
+        }
+    iOldSnapshot->Compress();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::ItemUpdatedL
+// Updates item to snapshot, this item is no longer considered changed
+// -----------------------------------------------------------------------------
+void CChangeFinder::ItemUpdatedL( const TSnapshotItem& aItem )
+    {
+    TRACE_FUNC_ENTRY;
+
+    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 );
+            }
+        
+        }
+    iOldSnapshot->Compress();
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    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 );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::CommitChangesL
+// Commits current changes to snapshot, affects only a specified group of items
+// -----------------------------------------------------------------------------
+void CChangeFinder::CommitChangesL( const MSmlDataItemUidSet& aUids )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    
+    // 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 );
+        TInt err = iOldSnapshot->FindIsq( temp, iKey, indexOld);
+        if ( !err )
+            {
+            // founded from old snapshot
+            if ( !iCurrentSnapshot->FindIsq(temp, iKey, indexNew) )
+                {
+                // Replace
+                iOldSnapshot->At( indexOld ) = iCurrentSnapshot->At( indexNew );
+                }
+            else
+                {
+                // not found from current snapshot, delete from old also.
+                iOldSnapshot->Delete( indexOld );
+                }
+            }
+        else
+            {
+            // not found from old snapshot, add it.
+            if ( !iCurrentSnapshot->FindIsq( temp, iKey, indexNew ) )
+                {
+                iOldSnapshot->InsertIsqL( iCurrentSnapshot->At( indexNew ), iKey );
+                }
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetNewSnapshot
+// Sets new snapshot (to be compared against), ChangeFinder takes ownership
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetNewSnapshot( CSnapshotArray* aNewSnapshot )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Delete existing snapshot
+    delete iCurrentSnapshot;
+    
+    // Set submitted snapshot as active
+    iCurrentSnapshot = aNewSnapshot;
+    iCurrentSnapshot->Compress();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::DataStoreUid
+// returns stored data store id number
+// -----------------------------------------------------------------------------
+TInt64 CChangeFinder::DataStoreUid() const
+    {
+    TRACE_FUNC;
+    return iDataStoreUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CChangeFinder::SetDataStoreUid
+// Sets data store id number
+// -----------------------------------------------------------------------------
+void CChangeFinder::SetDataStoreUid( TInt64 aUid )
+    {
+    TRACE_FUNC;
+    iDataStoreUid = aUid;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/cmdemanager.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,741 @@
+/*
+* 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:  CMdEManager implementation
+*
+*/
+
+
+#include "cmdemanager.h"
+#include <mdeconstants.h>
+
+#include <mmf\common\mmfcontrollerpluginresolver.h>
+
+#include "logger.h"
+
+// Warning:  #940-D: missing return statement at end of non-void function
+#pragma  diag_remark 940
+
+CMdEManager::CMdEManager( MMdEManagerObserver& aObserver ) :
+    iObserver(aObserver)
+    {
+    }
+
+
+CMdEManager* CMdEManager::NewL( MMdEManagerObserver& aObserver )
+    {
+    CMdEManager* self = new (ELeave) CMdEManager( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CMdEManager::ConstructL()
+    {
+    TRACE_FUNC;
+    iMde = CMdESession::NewL( *this );
+    }
+
+
+CMdEManager::~CMdEManager()
+    {
+    TRACE_FUNC;
+    Cancel(); // Cancel any request, if outstanding
+    delete iAlbumQuery;
+    delete iObjectQuery;
+    delete iContainmentQuery;
+    delete iMde;
+    
+    iAlbumsInProgress.ResetAndDestroy();
+    iAlbums.ResetAndDestroy();
+    }
+
+void CMdEManager::GetAlbumsL()
+    {
+    TRACE_FUNC_ENTRY;
+    iAlbumsInProgress.ResetAndDestroy();
+    iAlbums.ResetAndDestroy();
+    if ( !iMde )
+        {
+        LOGGER_WRITE("Session was not ready!");
+        iState = EUninitialized;
+        iMde = CMdESession::NewL( *this );
+        }
+    
+    if ( iState == EUninitialized)
+        {
+        LOGGER_WRITE("Starting processing albums after session is ready");
+        iState = EWaitingToEnumerateAlbums;
+        }
+    else if ( iState == EIdle )
+        {
+        StartProcessingAlbumsL();
+        }
+    else
+        {
+        LOGGER_WRITE_1("Wrong state: %d", iState);
+        User::Leave( KErrGeneral );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+const CPlaylistItem& CMdEManager::AlbumL( TInt aAlbumId ) const
+    {
+    for ( TInt i=0; i<iAlbums.Count(); i++ )
+        {
+        if ( iAlbums[i]->Id() == aAlbumId )
+            {
+            LOGGER_WRITE("Album found");
+            return *iAlbums[i];
+            }
+        }
+    LOGGER_WRITE_1("CMdEManager::AlbumL - aAlbumId %d does not exist - Leaving KErrNotFound", aAlbumId);
+    User::Leave( KErrNotFound );
+    }
+
+void CMdEManager::CreateAlbumL( CPlaylistItem& aAlbum )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iMde || iState != EIdle )
+        {
+        LOGGER_WRITE("Not ready!");
+        User::Leave( KErrNotReady );
+        }
+    CMdENamespaceDef& defaultNamespaceDef = iMde->GetDefaultNamespaceDefL();
+    CMdEObjectDef& albumObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Album::KAlbumObject );
+    
+    CMdEPropertyDef& titlePropDef = albumObjDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );   
+    
+    // Validate album name
+    TInt albumLength = aAlbum.Title().Length();
+    if ( albumLength < titlePropDef.MinTextLengthL() || 
+         albumLength > titlePropDef.MaxTextLengthL() )
+        {
+        LOGGER_WRITE("Album length is not on valid range!");
+        User::Leave( KErrBadName );
+        }
+    
+    CMdEObject* albumObject = iMde->NewObjectLC( albumObjDef, KNullDesC );
+    
+    CMdEPropertyDef& sizePropDef = albumObjDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
+    albumObject->AddUint32PropertyL(sizePropDef, 0);
+    CMdEPropertyDef& creationDatePropDef = albumObjDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
+    CMdEPropertyDef& lastModifiedDatePropDef = albumObjDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
+    
+    TTime timeDate;
+    timeDate.UniversalTime();
+    
+    albumObject->AddTimePropertyL( creationDatePropDef, timeDate );
+    albumObject->AddTimePropertyL( lastModifiedDatePropDef, timeDate );
+    
+    CMdEPropertyDef& typePropDef = albumObjDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
+    albumObject->AddTextPropertyL( typePropDef,MdeConstants::Album::KAlbumItemType );
+    
+    albumObject->AddTextPropertyL( titlePropDef, aAlbum.Title() );
+    TItemId newAlbumId = iMde->AddObjectL( *albumObject );
+    
+    CleanupStack::PopAndDestroy( albumObject );
+    
+    if ( newAlbumId == KNoId )
+        {
+        LOGGER_WRITE("Adding album failed!");
+        User::Leave( KErrGeneral );
+        }
+    LOGGER_WRITE_1("New almbum created, id: %d", newAlbumId);
+    
+    CMdERelationDef& relationDef = defaultNamespaceDef.GetRelationDefL( MdeConstants::Relations::KContains );
+    TMdEObject mediaObject;
+    RPointerArray<CMdEInstanceItem> relations;
+    CleanupResetAndDestroyPushL( relations);
+    for ( TInt i=0; i<aAlbum.ItemCount(); i++ )
+        {
+        TRAPD(err, iMde->CheckObjectL( mediaObject, aAlbum.ItemAt(i) ));
+        LOGGER_WRITE_1("url: %S", &aAlbum.ItemAt(i));
+        LOGGER_WRITE_1("CheckObjectL err: %d", err);
+        if ( !err )
+            {
+            LOGGER_WRITE_1("object def: %S", &mediaObject.DefL().Name());
+            if ( mediaObject.DefL().Name().Compare( MdeConstants::Image::KImageObject ) == 0 
+                    || mediaObject.DefL().Name().Compare( MdeConstants::Video::KVideoObject ) == 0 )
+                {
+                CMdERelation* relation = iMde->NewRelationL( relationDef, newAlbumId, mediaObject.Id() );
+                relations.AppendL( relation );
+                }
+            else
+                {
+                LOGGER_WRITE("type not supported");
+                }
+            }
+        }
+    
+    if ( relations.Count() > 0 )
+        {
+        TInt err = iMde->AddItemsL( relations );
+        LOGGER_WRITE_1("AddItemsL first err: %d", err);
+        }
+    
+    CleanupStack::PopAndDestroy( &relations );
+    
+    aAlbum.SetId( newAlbumId );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMdEManager::ReplaceAlbumL( TInt aAlbumId, CPlaylistItem& aAlbum )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iMde || iState != EIdle )
+        {
+        LOGGER_WRITE("Not ready!");
+        User::Leave( KErrNotReady );
+        }
+    // get old album from local cache and check do we need to change album title
+    const CPlaylistItem& oldAlbum = AlbumL( aAlbumId );
+    CMdENamespaceDef& defaultNamespaceDef = iMde->GetDefaultNamespaceDefL();
+    if ( oldAlbum.Title().Compare( aAlbum.Title() ) != 0 )
+        {
+        // Title changed, open item from MdE and update it
+        
+        CMdEObjectDef& albumObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Album::KAlbumObject );
+        
+        CMdEPropertyDef& titlePropDef = albumObjDef.GetPropertyDefL( 
+                MdeConstants::Object::KTitleProperty );
+        
+        // Validate album name
+        TInt albumLength = aAlbum.Title().Length();
+        if ( albumLength < titlePropDef.MinTextLengthL() || 
+             albumLength > titlePropDef.MaxTextLengthL() )
+            {
+            LOGGER_WRITE("Album length is not on valid range!");
+            User::Leave( KErrBadName );
+            }
+        
+        CMdEObject* albumObject = iMde->OpenObjectL( aAlbumId, albumObjDef );
+        
+        CMdEProperty* titleProp = NULL;
+        TInt index = albumObject->Property( titlePropDef, titleProp );
+        if ( index == KErrNotFound )
+            {
+            LOGGER_WRITE("Cannot find title property");
+            User::Leave( KErrCorrupt );
+            }
+        
+        LOGGER_WRITE("Change title property");
+        titleProp->SetTextValueL( aAlbum.Title() );
+        
+        CMdEPropertyDef& lastModDatePropDef = albumObjDef.GetPropertyDefL(
+                MdeConstants::Object::KLastModifiedDateProperty );
+        CMdEProperty* lastModDateProp = NULL;
+        index = albumObject->Property( lastModDatePropDef, lastModDateProp );
+        
+        if ( index == KErrNotFound )
+            {
+            LOGGER_WRITE("Cannot find lastModDateProp property");
+            User::Leave( KErrCorrupt );
+            }
+        
+        TTime now;
+        now.UniversalTime();
+        lastModDateProp->SetTimeValueL( now );
+        
+        iMde->CommitObjectL( *albumObject );
+        }
+    
+    // Update album and content relations
+    // Search added relations
+    CMdERelationDef& containsRelationDef = defaultNamespaceDef.GetRelationDefL( MdeConstants::Relations::KContains );
+    TMdEObject mediaObject;
+    RPointerArray<CMdEInstanceItem> addedRelations;
+    CleanupResetAndDestroyPushL( addedRelations);
+    for ( TInt i=0; i< aAlbum.ItemCount(); i++)
+        {
+        TInt index(KErrNotFound);
+        TInt foundRes = oldAlbum.FindItem( aAlbum.ItemAt(i) ,index );
+        if ( foundRes != 0 )
+            {
+            // Item not found for old album -> Added relation
+            // Find object by uri
+            TRAPD( err, iMde->CheckObjectL( mediaObject, aAlbum.ItemAt(i) ));
+            LOGGER_WRITE_1("url: %S", &aAlbum.ItemAt(i));
+            LOGGER_WRITE_1("CheckObjectL err: %d", err);
+            if ( !err )
+                {
+                LOGGER_WRITE_1("object def: %S", &mediaObject.DefL().Name());
+                if ( mediaObject.DefL().Name().Compare( MdeConstants::Image::KImageObject ) == 0 
+                        || mediaObject.DefL().Name().Compare( MdeConstants::Video::KVideoObject ) == 0 )
+                    {
+                    CMdERelation* relation = iMde->NewRelationL( containsRelationDef, aAlbumId, mediaObject.Id() );
+                    addedRelations.AppendL( relation );
+                    }
+                else
+                    {
+                    LOGGER_WRITE("type not supported");
+                    }
+                }
+            
+            }
+        }
+    if ( addedRelations.Count() > 0 )
+        {
+        TInt err = iMde->AddItemsL( addedRelations );
+        LOGGER_WRITE_1("AddItemsL first err: %d", err);
+        }
+    
+    CleanupStack::PopAndDestroy( &addedRelations );
+    
+    // search removed relations
+    if ( iContainmentQuery )
+        {
+        delete iContainmentQuery;
+        iContainmentQuery = NULL;
+        }
+    iContainmentQuery = iMde->NewRelationQueryL( defaultNamespaceDef, this );
+    
+    CMdELogicCondition& rootCondition = iContainmentQuery->Conditions();
+    CMdERelationCondition& relationCondition =
+        rootCondition.AddRelationConditionL(containsRelationDef,
+                                            ERelationConditionSideLeft); // "AND"
+    
+    CMdELogicCondition& leftCondition = relationCondition.LeftL();
+    CMdELogicCondition& rightCondition = relationCondition.RightL();
+    
+    leftCondition.AddObjectConditionL( aAlbumId );
+    
+    CMdELogicCondition& objectDefLogicCond = 
+            rightCondition.AddLogicConditionL( ELogicConditionOperatorOr);
+    
+    TBool removingRelationsNeeded( EFalse );
+    for ( TInt i=0; i< oldAlbum.ItemCount(); i++)
+        {
+        TInt index(KErrNotFound);
+        TInt foundRes = aAlbum.FindItem( oldAlbum.ItemAt(i) ,index );
+        if ( foundRes != 0 )
+            {
+            removingRelationsNeeded = ETrue;
+            // Item not found from new album -> Removed relation (add uri to search condition)
+            LOGGER_WRITE_1("relation to be removed, uri: %S", &oldAlbum.ItemAt(i) );
+            objectDefLogicCond.AddObjectConditionL( EObjectConditionCompareUri, oldAlbum.ItemAt(i) );
+            }
+        }
+    
+    if ( removingRelationsNeeded )
+        {
+        // find all removed relation ID:s. HandleRelationQueryCompleted will be called when ready.
+        iContainmentQuery->SetResultMode( EQueryResultModeId );
+        iContainmentQuery->FindL();
+        iState = EReplacingAlbum;
+        }
+    else
+        {
+        // All done
+        iState = EIdle;
+        iObserver.AlbumReplaced( KErrNone );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMdEManager::DeleteAlbumL( TInt aAlbumId )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iMde || iState != EIdle )
+        {
+        LOGGER_WRITE("Not ready!");
+        User::Leave( KErrNotReady );
+        }
+    
+    CMdENamespaceDef& defaultNamespaceDef = iMde->GetDefaultNamespaceDefL();
+    CMdEObjectDef& albumObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Album::KAlbumObject );
+    
+    CMdEObject* albumObject = iMde->GetObjectL( aAlbumId, albumObjDef );
+    
+    CMdEPropertyDef& typePropDef = albumObjDef.GetPropertyDefL( 
+           MdeConstants::Album::KTypeProperty );
+    
+    CMdEProperty* typeProp = NULL;
+    TInt index = albumObject->Property( typePropDef, typeProp );
+    if ( index != KErrNotFound )
+        {
+        TUint16 typeVal = typeProp->Uint16ValueL();
+        if ( typeVal == MdeConstants::Album::EAlbumSystemFavourite )
+            {
+            LOGGER_WRITE("Item type is EAlbumSystemFavourite, deletion not allowed!");
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+    
+    TItemId removedId(KNoId);
+    removedId = iMde->RemoveObjectL( aAlbumId );
+    if ( removedId == KNoId )
+        {
+        LOGGER_WRITE("Deletion failed!");
+        User::Leave( KErrNotFound );
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMdEManager::StartProcessingAlbumsL()
+    {
+    TRACE_FUNC_ENTRY;
+    CMdENamespaceDef& defaultNamespaceDef = iMde->GetDefaultNamespaceDefL();
+    CMdEObjectDef& albumObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Album::KAlbumObject );
+    if ( iAlbumQuery )
+        {
+        delete iAlbumQuery;
+        iAlbumQuery = NULL;
+        }
+    // query objects with object definition "Album"
+    iAlbumQuery = iMde->NewObjectQueryL( defaultNamespaceDef, albumObjDef, this );
+    
+    // Add order
+    CMdEObjectDef& objdef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
+    CMdEPropertyDef& propDef = objdef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
+    TMdEOrderRule rule( propDef, ETrue );
+    iAlbumQuery->AppendOrderRuleL( rule );
+    
+    iAlbumQuery->FindL();
+    
+    iState = EEnumeratingAlbums;
+
+    TRACE_FUNC_EXIT;
+    }
+    
+
+void CMdEManager::FindItemsOnAlbumL( TItemId aAlbumObjectId )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iMde )
+        {
+        LOGGER_WRITE("Session was not ready!");
+        User::Leave( KErrNotReady );
+        }
+    CMdENamespaceDef& defaultNamespaceDef = iMde->GetDefaultNamespaceDefL();
+    CMdEObjectDef& objDef = defaultNamespaceDef.GetObjectDefL(  MdeConstants::Object::KBaseObject );
+    
+    CMdEPropertyDef& titlePropDef = objDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
+    
+    if ( iObjectQuery )
+        {
+        delete iObjectQuery;
+        iObjectQuery = NULL;
+        }
+    iObjectQuery = iMde->NewObjectQueryL( defaultNamespaceDef, objDef, this );
+    
+    // get only "Title" property
+    iObjectQuery->AddPropertyFilterL( &titlePropDef );
+    
+    CMdEObjectDef& objdef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
+    CMdEPropertyDef& propDef = objdef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
+
+    CMdELogicCondition& rootCond = iObjectQuery->Conditions();
+
+    CMdERelationDef& containsRelDef = defaultNamespaceDef.GetRelationDefL( 
+        MdeConstants::Relations::KContains );
+
+    // query right side objects from relations
+    CMdERelationCondition& relCond = rootCond.AddRelationConditionL( 
+        containsRelDef, ERelationConditionSideRight );
+
+    // left side object of relation must be defined album object
+    CMdELogicCondition& leftRelCond = relCond.LeftL();
+    leftRelCond.AddObjectConditionL( aAlbumObjectId );
+    
+    iObjectQuery->FindL();
+
+    TRACE_FUNC_EXIT;
+    }
+
+/**
+ * Called to notify the observer that opening the session has been 
+ * completed and, if the opening succeeded, the session is ready for use.
+ *
+ * @param aSession session
+ * @param aError   <code>KErrNone</code>, if opening the session succeeded;
+ *                 or one of the system-wide error codes, if opening the 
+ *                 session failed
+ */
+void CMdEManager::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !aError )
+        {
+        LOGGER_WRITE("Session opened");
+        if ( iState == EWaitingToEnumerateAlbums )
+            {
+            iState = EIdle;
+            TRAPD(err, StartProcessingAlbumsL());
+            if ( err )
+                {
+                iObserver.AlbumsReaded( err );
+                }
+            }
+        else
+            {
+            iState = EIdle;
+            }
+        }
+    else
+        {
+        LOGGER_WRITE_1("Error happened on opening session, aError: %d", aError);
+        if ( iState == EWaitingToEnumerateAlbums )
+            {
+            iObserver.AlbumsReaded( aError );
+            }
+        iState = EUninitialized;
+        delete iMde;
+        iMde = NULL;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+/**
+ * Called to notify the observer about errors, which are not a direct 
+ * consequence of the operations initiated by the client but caused by 
+ * some external source (e.g., other clients). The error cannot be 
+ * recovered and all on-going operations initiated by the client have been 
+ * aborted. Any attempts to continue using the session will cause a panic. 
+ * The client should close the session immediately and try to open a new 
+ * session, if it needs to continue using the metadata engine.
+ *
+ * @param aSession session
+ * @param aError one of the system-wide error codes
+ */
+void CMdEManager::HandleSessionError(CMdESession& /*aSession*/, TInt aError)
+    {
+    // Something went wrong. Handle the error and delete the old session.
+    LOGGER_WRITE_1("CMdEManager::HandleSessionError - aError: %d", aError)
+    iState = EUninitialized;
+    delete iMde;
+    iMde = NULL;
+    }
+
+/**
+ * Called to notify the observer that new results have been received 
+ * in the query.
+ *
+ * @param aQuery              Query instance that received new results.
+ * @param aFirstNewItemIndex  Index of the first new item that was added
+ *                            to the result item array.
+ * @param aNewItemCount       Number of items added to the result item 
+ *                            array.
+ */
+void CMdEManager::HandleQueryNewResults(CMdEQuery& /*aQuery*/,
+                                   TInt /*aFirstNewItemIndex*/,
+                                   TInt /*aNewItemCount*/)
+    {
+    }
+
+void CMdEManager::ProcessNextAlbumL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iAlbumsInProgress.Count() == 0 )
+        {
+        LOGGER_WRITE("All ready");
+        // all ready
+        return;
+        }
+    
+    FindItemsOnAlbumL( iAlbumsInProgress[0]->Id() );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+        
+/**
+ * Called to notify the observer that the query has been completed,
+ * or that an error has occured.
+ *
+ * @param aQuery  Query instance.
+ * @param aError  <code>KErrNone</code>, if the query was completed
+ *                successfully. Otherwise one of the system-wide error 
+ *                codes.
+ */
+void CMdEManager::HandleQueryCompleted(CMdEQuery& aQuery, TInt aError)
+    {
+    TRACE_FUNC_ENTRY;
+    TInt err( aError );
+    
+    if ( iState == EEnumeratingAlbums )
+        {
+        CMdEObjectQuery& query = (CMdEObjectQuery&)aQuery;
+        if ( !err && &aQuery == iAlbumQuery )
+            {
+            LOGGER_WRITE("Album query");
+            TRAP( err, HandleAlbumQueryCompletedL( query ));
+            }
+        else if ( !err && &aQuery == iObjectQuery )
+            {
+            LOGGER_WRITE("Object query");
+            TRAP( err, HandleObjectQueryCompletedL( query ));
+            }
+        else
+            {
+            LOGGER_WRITE("unknown query or error happened");
+            }
+        
+        if ( err )
+            {
+            LOGGER_WRITE_1("Error happened: %d", err);
+            iState = EIdle;
+            iAlbumsInProgress.ResetAndDestroy();
+            iAlbums.ResetAndDestroy();
+            iObserver.AlbumsReaded( err );
+            }
+        }
+    else if ( iState == EReplacingAlbum )
+        {
+        if ( !err && &aQuery == iContainmentQuery )
+            {
+            LOGGER_WRITE("relation query");
+            CMdERelationQuery& query = (CMdERelationQuery&)aQuery;
+            TRAP( err, HandleRelationQueryCompletedL( query ));
+            }
+        
+        iState = EIdle;
+        iObserver.AlbumReplaced( err );
+        
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMdEManager::HandleAlbumQueryCompletedL
+// Callback function for find all albums. Save albums to iAlbumsInProgress array 
+// and start collecting objects on each album.
+// -----------------------------------------------------------------------------
+void CMdEManager::HandleAlbumQueryCompletedL( CMdEObjectQuery& aQuery )
+    {
+    TRACE_FUNC_ENTRY;
+    // clear old items
+    iAlbumsInProgress.ResetAndDestroy();
+    iAlbums.ResetAndDestroy();
+    
+    for ( TInt i = 0; i < aQuery.Count(); i++ )
+        {
+        CPlaylistItem* albumItem = CPlaylistItem::NewLC();
+        CMdEObject& object = aQuery.Result(i);
+        LOGGER_WRITE_1("Id: %d", object.Id());
+        albumItem->SetId( object.Id() );
+        
+        CMdEPropertyDef& titlePropDef = object.Def().GetPropertyDefL( MdeConstants::Object::KTitleProperty );
+              
+        CMdEProperty* titleProp = NULL;
+        TInt index = object.Property( titlePropDef, titleProp );
+        if ( index != KErrNotFound )
+            {
+            const TDesC& title = titleProp->TextValueL();
+            LOGGER_WRITE_1("Title: %S", &title);
+            albumItem->SetTitleL( title );
+            }
+        else
+            {
+            // not found, might be default album
+            albumItem->SetTitleL( object.Uri() );
+            }
+        
+        LOGGER_WRITE("");
+        iAlbumsInProgress.AppendL( albumItem );
+        CleanupStack::Pop( albumItem );
+        }
+    
+    if ( aQuery.Count() > 0 )
+        {
+        // Start processing albums
+        ProcessNextAlbumL();
+        }
+    else
+        {
+        // no albums
+        iObserver.AlbumsReaded( KErrNone );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CMdEManager::HandleObjectQueryCompletedL( CMdEObjectQuery& aQuery )
+    {
+    if ( !iAlbumsInProgress.Count() )
+        {
+        LOGGER_WRITE("Error! No items on iAlbumsInProgress");
+        User::Leave( KErrGeneral );
+        }
+    for ( TInt i = 0; i < aQuery.Count(); i++ )
+        {
+        CMdEObject& object = aQuery.Result(i);
+        iAlbumsInProgress[0]->AddItemL( object.Uri() );
+        }
+    iAlbums.AppendL( iAlbumsInProgress[0] );
+    iAlbumsInProgress.Remove( 0 );
+    if ( iAlbumsInProgress.Count() > 0)
+        {
+        ProcessNextAlbumL();
+        }
+    else
+        {
+        // all albums processed
+        iState = EIdle;
+        iObserver.AlbumsReaded( KErrNone );
+        }
+    }
+
+void CMdEManager::HandleRelationQueryCompletedL( CMdERelationQuery& aQuery )
+    {
+    TRACE_FUNC_ENTRY;
+    const RArray<TItemId>& res = aQuery.ResultIds();
+    LOGGER_WRITE_1("founded relations count: %d", res.Count())
+    for (TInt i=0; i<res.Count(); i++ )
+        {
+        LOGGER_WRITE_1(" %d", res[i]);
+        }
+    LOGGER_WRITE_1("q count: %d", aQuery.Count() );
+    RArray<TItemId> removed;
+    CMdENamespaceDef& defaultNameSpace = iMde->GetDefaultNamespaceDefL();
+    iMde->RemoveRelationsL( aQuery.ResultIds(),removed, &defaultNameSpace);
+    LOGGER_WRITE_1("Removed relations count: %d", removed.Count())
+    for (TInt i=0; i<removed.Count(); i++)
+        {
+        LOGGER_WRITE_1(" %d", removed[i]);
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CMdEManager::Cancel()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iState == EWaitingToEnumerateAlbums )
+        {
+        // Cancel enumeration before it even begins
+        iState = EUninitialized;
+        iObserver.AlbumsReaded( KErrCancel );
+        }
+    
+    if ( iAlbumQuery )
+        {
+        LOGGER_WRITE("iAlbumQuery->Cancel()");
+        iAlbumQuery->Cancel();
+        }
+    if ( iObjectQuery )
+        {
+        LOGGER_WRITE("iObjectQuery->Cancel()");
+        iObjectQuery->Cancel();
+        }
+    if ( iContainmentQuery )
+        {
+        LOGGER_WRITE("iContainmentQuery->Cancel()");
+        iContainmentQuery->Cancel();
+        }
+    TRACE_FUNC_EXIT;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/mediadsprovider.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,305 @@
+/*
+* 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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+  
+#include <f32file.h>
+#include <bautils.h>
+#include <barsc.h> 
+#include <stringpool.h> 
+#include <data_caging_path_literals.hrh>
+
+#include <smldataformat.h>
+#include <ecom/implementationproxy.h>
+#include "mediadsprovider.h"
+#include "mediadsproviderdefs.h"
+#include "mediadsstore.h"
+#include <mediadsstore.rsg>
+#include "logger.h"
+
+
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::CMediaDataProvider
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+CMediaDataProvider::CMediaDataProvider() :
+    iOwnStoreFormat(NULL),
+    iFilters(1)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CMediaDataProvider::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iStringPool.OpenL();
+    User::LeaveIfError( iFs.Connect() );
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CMediaDataProvider* CMediaDataProvider::NewL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CMediaDataProvider* self = new (ELeave) CMediaDataProvider;
+   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    TRACE_FUNC_EXIT;
+    return self;  
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::~CMediaDataProvider
+// Destructor.
+// -----------------------------------------------------------------------------
+CMediaDataProvider::~CMediaDataProvider()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    delete iOwnStoreFormat; 
+    iStringPool.Close();
+    
+    iFilters.ResetAndDestroy();
+    iFilters.Close();
+    
+    iFs.Close();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoOnFrameworkEvent
+// Not used
+// -----------------------------------------------------------------------------
+void CMediaDataProvider::DoOnFrameworkEvent(TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/)
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoSupportsOperation
+// Checks whether data provider supports specific operation
+// -----------------------------------------------------------------------------
+TBool CMediaDataProvider::DoSupportsOperation(TUid /*aOpId*/) const 
+    {
+    TRACE_FUNC;
+    
+    // Optional operations are not supported
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+const CSmlDataStoreFormat& CMediaDataProvider::DoStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    if ( !iOwnStoreFormat )
+        {
+        iOwnStoreFormat = DoOwnStoreFormatL();
+        }
+    
+    TRACE_FUNC_EXIT;
+    
+    return *iOwnStoreFormat;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoListStoresLC
+// Returns array fo data stores, not implemented because only single data store
+// is supported
+// -----------------------------------------------------------------------------
+CDesCArray* CMediaDataProvider::DoListStoresLC()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(1);
+    CleanupStack::PushL( stores );
+    stores->AppendL( KMediaDsDbName );
+    stores->AppendL( KMediaDsRefreshDbName );
+    
+    TRACE_FUNC_EXIT;
+    
+    return stores;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoDefaultStoreL
+// Returns the name of the default data store
+// -----------------------------------------------------------------------------
+const TDesC& CMediaDataProvider::DoDefaultStoreL()
+    {
+    TRACE_FUNC;
+    return KMediaDsDbName;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoNewStoreInstanceLC
+// Creates a new data store object, which can be used for synchronization
+// ----------------------------------------------------------------------------- 
+CSmlDataStore* CMediaDataProvider::DoNewStoreInstanceLC()
+    {
+    TRACE_FUNC_ENTRY;
+    CMediaDsDataStore* newStore = CMediaDsDataStore::NewLC( iFs );
+    TRACE_FUNC_EXIT;
+    return newStore;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoCheckSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMediaDataProvider::DoCheckSupportedServerFiltersL(
+    const CSmlDataStoreFormat& /*aServerDataStoreFormat*/,
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoCheckServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMediaDataProvider::DoCheckServerFiltersL(
+    RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterChangeInfo& /*aChangeInfo*/)
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoSupportedServerFiltersL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+const RPointerArray<CSyncMLFilter>& CMediaDataProvider::DoSupportedServerFiltersL()
+    {
+    TRACE_FUNC;
+    return iFilters; // empty array
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoSupportsUserSelectableMatchType
+// Not supported
+// -----------------------------------------------------------------------------        
+TBool CMediaDataProvider::DoSupportsUserSelectableMatchType() const
+    {
+    TRACE_FUNC;
+    return EFalse;
+    }           
+    
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoGenerateRecordFilterQueryLC
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+HBufC* CMediaDataProvider::DoGenerateRecordFilterQueryLC(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/,
+    TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/,
+    TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoGenerateFieldFilterQueryL
+// Filters are not supported
+// ----------------------------------------------------------------------------- 
+void CMediaDataProvider::DoGenerateFieldFilterQueryL(
+    const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/,
+    RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/)
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDataProvider::DoOwnStoreFormatL
+// Creates data store format
+// -----------------------------------------------------------------------------
+CSmlDataStoreFormat* CMediaDataProvider::DoOwnStoreFormatL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TParse* parse = new ( ELeave ) TParse();
+    CleanupStack::PushL(parse);
+    TFileName fileName;
+    RResourceFile resourceFile;
+    
+    parse->Set( KMediaDsStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL );
+    fileName = parse->FullName();
+    LOGGER_WRITE_1("filename: %S", &fileName);
+    BaflUtils::NearestLanguageFile( iFs, fileName );
+    
+    resourceFile.OpenL( iFs, fileName );
+    CleanupClosePushL( resourceFile );
+    
+    HBufC8* buffer = resourceFile.AllocReadLC( MEDIADS_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 );
+    
+    TRACE_FUNC_EXIT;
+    
+    return dsFormat;
+    }
+
+
+// -----------------------------------------------------------------------------
+// ImplementationTable
+// Required by ECom plugin interface, tells the entry point of the library
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KMediaDataProviderImplUid, CMediaDataProvider::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/mediads/src/mediadsprovider.rss	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for Media DS ECOM plug-in
+*
+*/
+
+
+#include <ecom/registryinfo.rh> 
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x2001A9A1; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x101F4D3A; // Constant for all DS plug ins
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x2001A9A1; // DS interface implementation UID
+                version_no = 1; 
+                display_name = "Media"; // shown in UI
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/mediadsstore.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1210 @@
+/*
+* 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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+#include "mediadsstore.h"
+#include <mpxmessagegeneraldefs.h>
+#include <mpxcollectionmessage.h>
+
+#include "mediadsproviderdefs.h"
+#include "mediamanager.h"
+#include "cmdemanager.h"
+#include "playlistitem.h"
+#include "omadsfolderobject.h"
+#include "snapshotitem.h"
+#include "logger.h"
+
+_LIT8( KFolderMimeType, "application/vnd.omads-folder+xml" );
+_LIT8( KFolderMimeVersion, "1.2" );
+
+_LIT8( KPlaylistMimeType, "audio/x-mpegurl");
+_LIT8( KPlaylistMimeVersion, "1.0");
+
+_LIT8( KSongMimeType, "application/x-song");
+_LIT8( KSongMimeVersion, "1.0");
+
+
+const TInt KDataBufferSize = 1024;
+
+const TInt KAlbumsOffSet = 0x0000f000;
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::CMediaDsDataStore
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+CMediaDsDataStore::CMediaDsDataStore( RFs& aFs):
+    iKey(TKeyArrayFix(_FOFF(TSnapshotItem, ItemId()), ECmpTInt)),
+    iFs( aFs )
+    { 
+    TRACE_FUNC;
+    }
+  
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::ConstructL
+// Symbian 2nd phase constructor, can leave.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // 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;
+    
+    iHasher = CMD5::NewL();
+    
+    iMediaManager = CMediaManager::NewL( iFs, this, iKey, *iHasher );
+    
+    iMdEManager = CMdEManager::NewL( *this );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CMediaDsDataStore* CMediaDsDataStore::NewLC( RFs& aFs)
+    {
+    TRACE_FUNC_ENTRY;
+    CMediaDsDataStore* self = new (ELeave) CMediaDsDataStore( aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    TRACE_FUNC_EXIT;
+    return self;    
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::~CMediaDsDataStore
+// Destructor
+// -----------------------------------------------------------------------------
+CMediaDsDataStore::~CMediaDsDataStore()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    delete iDataBuffer;
+    
+    delete iChangeFinder;
+    
+    delete iNewItems;
+    delete iDeletedItems;
+    delete iUpdatedItems;
+    delete iMovedItems;
+    delete iSoftDeletedItems;
+    
+    delete iMediaManager;
+    LOGGER_WRITE("iMediaManager deleted");
+    
+    delete iMdEManager;
+    LOGGER_WRITE("iMdEManager deleted");
+    
+    delete iHasher;
+    LOGGER_WRITE("iHasher deleted");
+    // normally iSnapshot is NULL, but if error has occured we need to delete it.
+    delete iSnapshot;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoOpenL
+// Opens database. This operation is performed SYNCHRONOUSLY
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoOpenL( const TDesC& aStoreName,
+    MSmlSyncRelationship& aContext, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    if ( iCurrentState != EClosed )
+        {
+        User::RequestComplete( iCallerStatus, KErrInUse );
+        LOGGER_WRITE("CMmsDataStore::DoOpenL failed with KErrInUse.");
+        return;
+        }
+    
+    // Create ChangeFinder object
+    if ( iChangeFinder )
+        {
+        delete iChangeFinder;
+        iChangeFinder = NULL;
+        }
+    iChangeFinder = CChangeFinder::NewL( aContext, iKey, iHasHistory, KMediaDataProviderImplUid );
+    
+    if ( aStoreName.CompareF( KMediaDsRefreshDbName ) == 0 )
+        {
+        LOGGER_WRITE("Refresh library and open database");
+        // just kick off scanner, don't wait ready status
+        // Async. func. HandleCollectionMessage is called when ready
+        iMediaManager->ScanL();
+        
+        }
+    else if ( aStoreName.CompareF( KMediaDsDbName ) == 0 )
+        {
+        LOGGER_WRITE("Open database");
+        
+        if ( !iHasHistory )
+            {
+            LOGGER_WRITE("No history, scan library");
+            // just kick off scanner, don't wait ready status
+            // Async. func. HandleCollectionMessage is called when ready
+            iMediaManager->ScanL();
+            }
+        
+        }
+    else
+        {
+        LOGGER_WRITE("Unknown database");
+        User::Leave( KErrNotSupported );
+        }
+    
+    // Set current snapshot, this will be compared against the old one   
+    RegisterSnapshotL();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCancelRequest
+// Not supported, does nothing.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCancelRequest()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iCurrentState == EOpening )
+        {
+        LOGGER_WRITE("Cancel Open command");
+        iMediaManager->Cancel();
+        iMdEManager->Cancel();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoStoreName
+// Returns the name of the DataStore
+// -----------------------------------------------------------------------------
+const TDesC& CMediaDsDataStore::DoStoreName() const
+    {
+    TRACE_FUNC;
+    return KNullDesC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoBeginTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoBeginTransactionL()
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCommitTransactionL
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCommitTransactionL( TRequestStatus& /*aStatus*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoRevertTransaction
+// Transactions are not supported.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoRevertTransaction( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC;
+    iCallerStatus = &aStatus;
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoBeginBatchL
+// Batching is not supported.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoBeginBatchL()
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCommitBatchL
+// Batching is not supported
+// -----------------------------------------------------------------------------
+//
+void CMediaDsDataStore::DoCommitBatchL( RArray<TInt>& /*aResultArray*/, TRequestStatus& /*aStatus*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCancelBatch
+// Batching is not supported
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCancelBatch()
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoSetRemoteStoreFormatL
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CMediaDsDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/ )
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoSetRemoteMaxObjectSize
+// Not supported
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoSetRemoteMaxObjectSize( TInt /*aServerMaxObjectSize*/ )
+    {
+    TRACE_FUNC;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoMaxObjectSize
+// Reads the maximum MMS Message size from the central repository
+// -----------------------------------------------------------------------------
+TInt CMediaDsDataStore::DoMaxObjectSize() const
+    {
+    TRACE_FUNC;
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::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 CMediaDsDataStore::DoOpenItemL( TSmlDbItemUid aUid, TBool& /*aFieldChange*/, 
+    TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, 
+    TDes8& aMimeVer, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+
+    LOGGER_WRITE_1( "Opening item %d.", aUid );
+    
+    // Store these for later use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iReadPosition=0;
+    
+    // Check that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "CMediaDsDataStore::DoOpenItemL, invalid state %d.", iCurrentState );
+        User::RequestComplete( iCallerStatus, KErrNotReady );
+        return;
+        }
+    
+    if ( !iDataBuffer )
+        {
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        }
+    iDataBuffer->Reset();
+
+    
+    if ( aUid <= KLastFolderId )
+        {
+        COMADSFolderObject* folderObject = COMADSFolderObject::NewLC();
+        
+        switch ( aUid )
+            {
+            case KAllSongsFolderId:
+                folderObject->SetName( KAllSongs );
+                break;
+            case KPlaylistsFolderId:
+                folderObject->SetName( KPlaylists );
+                break;
+            case KAlbumsFolderId:
+                folderObject->SetName( KAlbums );
+                break;
+            default:
+                User::Leave( KErrNotFound );
+                break;
+            }
+        folderObject->ExportFolderXmlL( *iDataBuffer );
+        CleanupStack::PopAndDestroy( folderObject );
+        aMimeType.Copy( KFolderMimeType );
+        aMimeVer.Copy( KFolderMimeVersion );
+        aParent = KErrNotFound;
+        }
+    else
+        {
+        CSongItem* song = CSongItem::NewLC();
+        LOGGER_WRITE("Try to read song");
+        TRAPD( err, iMediaManager->GetSongL( aUid, *song ));
+        if ( !err )
+            {
+            RBufWriteStream stream( *iDataBuffer );
+            CleanupClosePushL( stream );
+            song->ExportL( stream );
+            CleanupStack::PopAndDestroy( &stream );
+            CleanupStack::PopAndDestroy( song );
+            
+            aMimeType.Copy( KSongMimeType );
+            aMimeVer.Copy( KSongMimeVersion );
+            aParent = KAllSongsFolderId;
+            }
+        else // could not read song, maybe it is playlist
+            {
+            CleanupStack::PopAndDestroy( song );
+            CPlaylistItem* playList = CPlaylistItem::NewLC();
+            LOGGER_WRITE("Try to read playlist");
+            TRAP(err, iMediaManager->GetPlayListL( aUid, *playList ));
+            if ( !err )
+                {
+                RBufWriteStream stream( *iDataBuffer );
+                CleanupClosePushL( stream );
+                
+                playList->ExportL( stream );
+                CleanupStack::PopAndDestroy( &stream );
+                CleanupStack::PopAndDestroy( playList );
+                
+                aMimeType.Copy( KPlaylistMimeType );
+                aMimeVer.Copy( KPlaylistMimeVersion );
+                aParent = KPlaylistsFolderId;
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy( playList );
+                LOGGER_WRITE("Try to read album");
+                // Could not read song, maybe it's a Album
+                const CPlaylistItem& album = iMdEManager->AlbumL( MapSyncIdToAlbumId(aUid) );
+                RBufWriteStream stream( *iDataBuffer );
+                CleanupClosePushL( stream );
+                
+                album.ExportL( stream );
+                CleanupStack::PopAndDestroy( &stream );
+                
+                aMimeType.Copy( KPlaylistMimeType );
+                aMimeVer.Copy( KPlaylistMimeVersion );
+                aParent = KAlbumsFolderId;
+                }
+            }
+        
+        }
+    
+    aSize = iDataBuffer->Size();
+    
+    LOGGER_WRITE_1("aSize: %d", aSize);
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone ); 
+
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCreateItemL
+// Create new item to the message store.
+// Return the id number of the newly created item
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, 
+    const TDesC8& aMimeType, const TDesC8& /*aMimeVer*/, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "Parent folder: %d.", aParent );
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "Invalid state %d.", iCurrentState );
+        }
+    
+    iWrittenDataLength = 0;
+    iCreatedUid = &aUid;
+    LOGGER_WRITE8_1( "aMimeType: %S", &aMimeType );
+    
+    if ( aMimeType.Compare( KPlaylistMimeType() ) == 0 )
+        {
+        LOGGER_WRITE("Add Playlist");
+        iCurrentState = ECreatePlaylist;
+        }
+    else if ( aMimeType.Compare( KSongMimeType() ) == 0 )
+        {
+        LOGGER_WRITE("Add Song not supported");
+        User::Leave( KErrNotSupported );
+        }
+    else
+        {
+        User::RequestComplete( iCallerStatus, KErrNotSupported );
+        LOGGER_WRITE("Bad MIME type");
+        return;
+        }
+    
+    if ( iDataBuffer )
+        {
+        iDataBuffer->ResizeL( aSize );
+        }
+    else
+        {
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        iDataBuffer->ResizeL( aSize );
+        }
+    LOGGER_WRITE_1("iDataBuffer->Size: %d", iDataBuffer->Size());
+    
+    LOGGER_WRITE_1("aSize: %d", aSize);
+    iParentId = aParent;
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoReplaceItemL
+// Begin the replace operation, ensure that the item really exists
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, 
+    TBool /*aFieldChange*/, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    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 != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1("Invalid state %d.", iCurrentState);
+        }
+    
+    iCurrentState = EReplace;
+    
+    iParentId = aParent;
+    iCurrentId = aUid;
+    
+    if ( iDataBuffer )
+        {
+        iDataBuffer->ResizeL( aSize );
+        }
+    else
+        {
+        iDataBuffer = CBufFlat::NewL( KDataBufferSize );
+        iDataBuffer->ResizeL( aSize );
+        }
+    
+    // Signal we're complete
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoReadItemL
+// Read specified amount of data from the temporary buffer
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoReadItemL( TDes8& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    // Thiw is how much data there is left in the buffer    
+    TInt left = iDataBuffer->Size() - iReadPosition;
+    
+    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( "No data to read" );
+        User::Leave( KErrEof );
+        }   
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoWriteItemL
+// Write specified amount of data to the temporary buffer
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoWriteItemL( const TDesC8& aData )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iDataBuffer->Write( iWrittenDataLength, aData );
+    iWrittenDataLength += aData.Size();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCommitItemL
+// Commits item from temporary buffer to the message store
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCommitItemL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Store some variables
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    iDataBuffer->Compress();
+    
+    // Read the playlist item
+    CPlaylistItem* newItem = CPlaylistItem::NewLC();
+    
+    const TUint8* ptr8 = iDataBuffer->Ptr(0).Ptr();
+    const TUint16* ptr16 = reinterpret_cast<const TUint16*>( ptr8 );
+    TPtrC dataPtr;
+    dataPtr.Set( ptr16, iDataBuffer->Size()/2 );
+    newItem->ImportL( dataPtr );
+    
+    iDataBuffer->Reset();
+    
+#ifdef _DEBUG
+    LOGGER_WRITE_1("Name: %S", &newItem->Title());
+    LOGGER_WRITE_1("Items count: %d", newItem->ItemCount());
+    for ( TInt i=0; i<newItem->ItemCount(); i++ )
+        {
+        TPtrC16 ptr = newItem->ItemAt(i);
+        LOGGER_WRITE_1("item: %S", &ptr);
+        }
+#endif
+    
+    
+    TInt error(KErrNone);
+    if ( iCurrentState == ECreatePlaylist )
+        {
+        if ( iParentId == KPlaylistsFolderId )
+            {
+            iMediaManager->CreateNewPlaylistL( *iCreatedUid, *newItem );
+            }
+        else if ( iParentId == KAlbumsFolderId )
+            {
+            iMdEManager->CreateAlbumL( *newItem );
+            *iCreatedUid = MapAlbumIdToSyncId( newItem->Id() );
+            }
+        else
+            {
+            LOGGER_WRITE("Not supported");
+            User::Leave( KErrNotSupported);
+            }
+        
+        // Inform ChangeFinder of the added item
+        TSnapshotItem snapshotItem( *iCreatedUid );
+        snapshotItem.SetParentId( iParentId );
+        snapshotItem.SetItemHash( *newItem, *iHasher );
+        iChangeFinder->ItemAddedL( snapshotItem );
+        
+        }
+    else if ( iCurrentState == EReplace )
+        {
+        if ( iParentId == KPlaylistsFolderId )
+            {
+            iMediaManager->ReplacePlaylistL( iCurrentId, *newItem );
+            }
+        else if ( iParentId == KAlbumsFolderId )
+            {
+            iItemInReplacement.SetItemId( iCurrentId );
+            iItemInReplacement.SetParentId( iParentId );
+            iItemInReplacement.SetItemHash( *newItem, *iHasher );
+            // Async function, calls AlbumReplaced when completed
+            iMdEManager->ReplaceAlbumL( MapSyncIdToAlbumId(iCurrentId), *newItem );
+            
+            CleanupStack::PopAndDestroy( newItem );
+            return;
+            }
+        else
+            {
+            LOGGER_WRITE("Not supported");
+            User::Leave( KErrNotSupported);
+            }
+        
+        // Inform ChangeFinder of the replaced item
+        TSnapshotItem snapshotItem( iCurrentId );
+        snapshotItem.SetParentId( iParentId );
+        snapshotItem.SetItemHash( *newItem, *iHasher );
+        iChangeFinder->ItemUpdatedL( snapshotItem );
+        }
+    else
+        {
+        LOGGER_WRITE_1("Wrong state: %d", iCurrentState);
+        User::Leave( KErrNotSupported );
+        }
+    CleanupStack::PopAndDestroy( newItem );
+    
+    
+    
+    LOGGER_WRITE_1("error: %d", error);
+    // We'll be waiting for next event, signal we're done
+    iCurrentState = EOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, error );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCloseItem
+// Closes open item in the data store
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCloseItem()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iDataBuffer )
+        {
+        iDataBuffer->Reset();
+        }
+    iCurrentState = EOpenAndWaiting;
+    iReadPosition = 0;
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoMoveItemL
+// Moves item from one folder to another in the message store
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoMoveItemL( TSmlDbItemUid /*aUid*/,
+    TSmlDbItemUid /*aNewParent*/, TRequestStatus& /*aStatus*/ )
+    {
+    TRACE_FUNC;
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoDeleteItemL
+// Removes item from the message store
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus  )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("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 != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoDeleteItemL, invalid state %d.", iCurrentState);        
+        }
+    
+    TRAP( error,  iMediaManager->DeletePlaylistL( aUid ) );
+    if ( error )
+        {
+        error = KErrNone;
+        iMdEManager->DeleteAlbumL( MapSyncIdToAlbumId( aUid ) );
+        }
+    
+    if ( !error )
+        {
+        // Inform ChangeFinder of the deleted item
+        TSnapshotItem snapshotItem( aUid );
+        iChangeFinder->ItemDeletedL( snapshotItem );
+        }
+    
+    LOGGER_WRITE_1("complete error: %d", error);
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, error );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoSoftDeleteItemL
+// Soft delete isn't supported.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Store some variables for further use
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoDeleteAllItemsL
+// Deletes all items in the standard folders of message store
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // Store some variables for further use 
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    User::RequestComplete( iCallerStatus, KErrNotSupported );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::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 CMediaDsDataStore::DoHasSyncHistory() const
+    {
+    TRACE_FUNC_RET( (TInt)iHasHistory );      
+    
+    // iHasHistory is initialized in DoOpenL method
+    return iHasHistory;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoAddedItems
+// This method returns UIDs of added items. Those items are added after previous
+// synchronization with current synchronization relationship. 
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMediaDsDataStore::DoAddedItems() const
+    {
+    TRACE_FUNC;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoAddedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+
+    // Clear new-items array
+    iNewItems->Reset();
+
+    // Set current snapshot, this will be compared against the old one      
+    // Search for new items
+    TRAP( error, iChangeFinder->FindNewItemsL(*iNewItems) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_WRITE_1("New item count: %d.", iNewItems->ItemCount());
+    
+    return *iNewItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoDeletedItems
+//
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMediaDsDataStore::DoDeletedItems() const
+    {
+    TRACE_FUNC;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1("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_WRITE_1("CMmsDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error);
+        }           
+    
+    LOGGER_WRITE_1("Deleted item count: %d.", iDeletedItems->ItemCount());
+    return *iDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoSoftDeletedItems
+// Not directly supported, equals to "hard" delete
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMediaDsDataStore::DoSoftDeletedItems() const
+    {
+    TRACE_FUNC;
+
+    iSoftDeletedItems->Reset();
+    return *iSoftDeletedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoModifiedItems
+// Finds all modified items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMediaDsDataStore::DoModifiedItems() const
+    {
+    TRACE_FUNC;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting )
+        {
+        LOGGER_WRITE_1("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_WRITE_1("CMmsDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_WRITE_1("Modified item count: %d.", iUpdatedItems->ItemCount()); 
+    return *iUpdatedItems;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoMovedItems
+// Finds all moved items in the data store
+// -----------------------------------------------------------------------------
+const MSmlDataItemUidSet& CMediaDsDataStore::DoMovedItems() const
+    {
+    TRACE_FUNC;
+    // return empty array
+    return *iMovedItems;    
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoResetChangeInfoL
+// Resets change history in the data store. All content is considered
+// new in the data store point of view.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Check that we're in proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoResetChangeInfoL, invalid state %d.", iCurrentState);
+        }   
+            
+    // Reset change info in ChangeFinder
+    iChangeFinder->ResetL();
+    iHasHistory = EFalse;
+    
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone ); 
+    
+    TRACE_FUNC_EXIT;
+    }
+        
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCommitChangeInfoL
+// Commits change info. These items are no longer reported, when change
+// information is being queried.
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+        }
+
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL(aItems);
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete(iCallerStatus, KErrNone);
+        
+    TRACE_FUNC_EXIT;
+    }
+        
+    
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::DoCommitChangeInfoL
+// Commits change info. There is no more nothing to report when change
+// information is being queried. 
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::DoCommitChangeInfoL(TRequestStatus& aStatus)
+    {
+    TRACE_FUNC_ENTRY;
+    
+    iCallerStatus = &aStatus;
+    *iCallerStatus = KRequestPending;
+    
+    // Ensure that we're in a proper state
+    if ( iCurrentState != EOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoCommitChangeInfoL, invalid state %d.", iCurrentState);
+        }
+    
+    // Notify ChangeFinder
+    iChangeFinder->CommitChangesL();
+    iHasHistory = ETrue;
+        
+    // Signal we're done
+    User::RequestComplete( iCallerStatus, KErrNone );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CMediaDsDataStore::HandleCollectionMessage(CMPXMessage* /*aMsg*/, TInt /*aErr*/) 
+    {
+    TRACE_FUNC;
+    }
+
+void CMediaDsDataStore::HandleOpenL(const CMPXMedia& /*aEntries*/,
+        TInt /*aIndex*/,TBool /*aComplete*/,TInt /*aError*/)
+    {
+    TRACE_FUNC;
+    }
+
+void CMediaDsDataStore::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/,
+        TInt /*aError*/)
+    {
+    TRACE_FUNC;
+    }
+    
+void CMediaDsDataStore::HandleCommandComplete(CMPXCommand* /*aCommandResult*/, 
+         TInt /*aError*/)
+    {
+    TRACE_FUNC;
+    }
+
+void CMediaDsDataStore::HandleCollectionMediaL(const CMPXMedia& /*aMedia*/, 
+        TInt /*aError*/)
+    {
+    TRACE_FUNC;
+    }
+
+void CMediaDsDataStore::AlbumsReaded( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    iMdEManagerReady = ETrue;
+    LOGGER_WRITE_1("aError: %d", aError );
+    
+    if ( aError )
+        {
+        iError = aError;
+        }
+    
+    FinalizeOpenStore();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaDsDataStore::AlbumReplaced( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError);
+    if ( !aError )
+        {
+        // Inform ChangeFinder of the replaced item
+        iChangeFinder->ItemUpdatedL( iItemInReplacement );
+        }
+    
+    iCurrentState = EOpenAndWaiting;
+    User::RequestComplete( iCallerStatus, aError );
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::RegisterSnapshotL
+// Sets Changefinder to compare against current message store content
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::RegisterSnapshotL()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iSnapshot )
+        {
+        delete iSnapshot;
+        iSnapshot = NULL;
+        }
+    iSnapshot = new (ELeave) CSnapshotArray( KSnapshotGranularity );
+    RegisterFoldersL( *iSnapshot );
+    iMediaManager->SetSnapshot( iSnapshot );
+    
+    iCurrentState = EOpening;
+    TInt err = iMediaManager->RegisterAllPlayLists();
+    if ( err )
+        {
+        LOGGER_WRITE_1("Could not start, err: %d", err);
+        iCurrentState = EClosed;
+        User::RequestComplete( iCallerStatus, err );
+        }
+    else
+        {
+        iMdEManager->GetAlbumsL();
+        }
+
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaDsDataStore::RegisterAllPlayListsCompleted( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !aError )
+        {
+        TInt err = iMediaManager->RegisterAllSongs();
+        if ( err )
+            {
+            LOGGER_WRITE_1("Could not start, err: %d", err);
+            iMediaManagerReady = ETrue;
+            iError = err;
+            }
+        }
+    else
+        {
+        // Error happened or cancelled.
+        iMediaManagerReady = ETrue;
+        iError = aError;
+        }
+    
+    FinalizeOpenStore();
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaDsDataStore::RegisterAllSongsCompleted( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    iMediaManagerReady = ETrue;
+    if ( aError )
+        {
+        // Error happened or cancelled, save error code
+        iError = aError;
+        }
+    
+    FinalizeOpenStore();
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// -----------------------------------------------------------------------------
+// CMediaDsDataStore::RegisterFoldersL
+// 
+// -----------------------------------------------------------------------------
+void CMediaDsDataStore::RegisterFoldersL( CSnapshotArray& aItemArray )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TKeyArrayFix key( iKey );
+    TSnapshotItem folder;
+    folder.SetItemId( KAllSongsFolderId );
+    folder.SetItemHash( KAllSongs, *iHasher );
+    aItemArray.InsertIsqL( folder, key );
+    
+    folder.SetItemId( KPlaylistsFolderId );
+    folder.SetItemHash( KPlaylists, *iHasher );
+    aItemArray.InsertIsqL( folder, key );
+    
+    folder.SetItemId( KAlbumsFolderId );
+    folder.SetItemHash( KAlbums, *iHasher );
+    aItemArray.InsertIsqL( folder, key );
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaDsDataStore::FinalizeOpenStore()
+    {
+    TRACE_FUNC_ENTRY;
+    // Signal client if all ready
+    if ( iMediaManagerReady && iMdEManagerReady )
+        {
+        if ( !iError )
+            {
+            RPointerArray<CPlaylistItem> albums = iMdEManager->AlbumsArray();
+            TKeyArrayFix key( iKey );
+            LOGGER_WRITE("Album snapshots:")
+            for (TInt i=0; i<albums.Count(); i++)
+                {
+                TSnapshotItem playlistItem( MapAlbumIdToSyncId( albums[i]->Id() ) );
+                playlistItem.SetItemHash( *albums[i], *iHasher );
+                playlistItem.SetParentId( KAlbumsFolderId );
+                TRAP(iError, iSnapshot->InsertIsqL( playlistItem, key ));
+                if ( iError )
+                    {
+                    LOGGER_WRITE_1("iSnapshot->InsertIsqL err: %d", iError);
+                    iError = KErrGeneral;
+                    }
+                }
+            
+            if ( !iError )
+                {
+                // Set new snapshot to compare against
+                iChangeFinder->SetNewSnapshot(iSnapshot);
+                
+                // Changefinder takes ownership of the snapshot
+                iSnapshot = NULL;
+                iCurrentState = EOpenAndWaiting;
+                }
+            }
+        
+        if ( iError )
+            {
+            iCurrentState = EClosed;
+            }
+        
+        LOGGER_WRITE_1("Signal client with %d", iError);
+        User::RequestComplete( iCallerStatus, iError );
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+inline TInt CMediaDsDataStore::MapSyncIdToAlbumId( TSmlDbItemUid aSyncId )
+    {
+    return aSyncId - KAlbumsOffSet;
+    }
+
+inline TSmlDbItemUid CMediaDsDataStore::MapAlbumIdToSyncId( TInt aAlbumId )
+    {
+    return KAlbumsOffSet + aAlbumId;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/mediadsstore.rss	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* 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 data for Media DS adapter
+*
+*/
+
+
+#include <smldataformat.rh>
+#include <smldataformat.hrh>
+
+RESOURCE SML_DATA_STORE_FORMAT MEDIADS_DATA_STORE
+	{
+	version = 1;
+	display_name = "Media";
+	sync_types = KSmlSyncType_TwoWay + KSmlSyncType_OneWayFromSvr + KSmlSyncType_OneWayFromClnt
+        + KSmlSyncType_SlowSync + KSmlSyncType_RefreshFromSvr + KSmlSyncType_RefreshFromClnt;
+	
+	mime_format=
+		{
+		SML_MIME_FORMAT
+			{
+			version = 1;
+			mime_type = "application/vnd.omads-folder+xml";
+			mime_ver = "1.2";
+			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 = "audio/x-mpegurl";
+			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/x-song";
+			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/mediads/src/mediamanager.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1254 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CMediaManager class implementation
+*
+*/
+
+
+
+#include "mediamanager.h"
+
+#include <mpxmedia.h>
+#include <mpxmediageneraldefs.h>
+#include <mpxcollectionhelper.h>
+#include <mpxmediacontainerdefs.h>
+#include <mpxmediaarray.h>
+#include <mpxcollectionhelperfactory.h>
+#include <mpxcollectionhelper.h>
+#include <utf.h>
+#include <mpxplaylistenginedefs.h> // for EMPXPlaylistTypeM3U
+#include <mpxcollectiontype.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxcollectionplugin.hrh>
+#include <PathInfo.h>
+#include <mpxmediaaudiodefs.h>
+#include <mpxmediamtpdefs.h>
+#include <driveinfo.h>
+
+#include "mediadsproviderdefs.h"
+#include "playlistitem.h"
+#include "logger.h"
+
+
+const TUid KMpxLocalCollectionUid = { 0x101FFC3A };
+
+_LIT( KPlaylistPath, "playlists\\" );
+_LIT( KMPXVirtualPlaylistExt, ".vir" );
+
+// Maximum amount of song items to be enumerated on one RunL.
+const TInt iMaxSongItemsToEnumerate(100);
+// Maximum amount of playlist items to be enumerated on one RunL.
+const TInt iMaxPlaylistItemsToEnumerate(15);
+
+
+CMediaManager::CMediaManager( RFs& aFs, MMediaManagerObserver* aObserver,
+        TKeyArrayFix aKey, CMD5& aHasher  )
+: CActive( EPriorityStandard ),
+iObserver( aObserver ),
+iKey( aKey ),
+iHasher( aHasher ),
+iFs( aFs )
+    {
+    TRACE_FUNC;
+    CActiveScheduler::Add(this);
+    }
+
+
+void CMediaManager::ConstructL()
+    {
+    TRACE_FUNC_ENTRY;
+    iHarvester = CMPXHarvesterFactory::NewL();
+    LOGGER_WRITE("1");
+    iCollection = MMPXCollectionUtility::NewL( iObserver );
+    LOGGER_WRITE("2");
+    iMediator = CMPXCollectionMediator::NewL( iCollection->Collection() );
+    LOGGER_WRITE("3");
+    iCollectionHelper = CMPXCollectionHelperFactory::NewCollectionCachedHelperL();   
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+CMediaManager* CMediaManager::NewL( RFs& aFs, MMediaManagerObserver* aObserver, TKeyArrayFix aKey, CMD5& aHasher )
+    {
+    CMediaManager* self = new( ELeave ) CMediaManager( aFs, aObserver, aKey, aHasher );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CMediaManager::~CMediaManager()
+    {
+    TRACE_FUNC_ENTRY;
+    Cancel();
+    delete iFoundedMedia;
+    if ( iCollectionHelper )
+        {
+        iCollectionHelper->Close();
+        iCollectionHelper = NULL;
+        }
+    
+    delete iMediator;
+    
+    if ( iCollection )
+        {
+        iCollection->Close();
+        iCollection = NULL;
+        }
+    
+    if ( iHarvester )
+        {
+        // For some unknown reason this may sometimes leave with error code -38
+        TRAP_IGNORE( iHarvester->Close() );
+        iHarvester = NULL;
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::ScanL()
+    {
+    TRACE_FUNC_ENTRY;
+    iHarvester->ScanL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::CancelScanL()
+    {
+    TRACE_FUNC_ENTRY;
+    iHarvester->CancelScanL();
+    TRACE_FUNC_EXIT;
+    }
+
+// --------------------------------------------------------------------------
+// Starts registering all playlists. Calls RegisterAllPlayListsCompleted when ready
+// --------------------------------------------------------------------------
+// 
+TInt CMediaManager::RegisterAllPlayLists()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iCurrentState != EIdle || !iSnapshotArray)
+        {
+        LOGGER_WRITE("Not Idle or iSnapshotArray is NULL");
+        return KErrNotReady;
+        }
+    iCurrentState = EReadingPlaylistCount;
+    SetActive();
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Starts registering all song items. Calls RegisterAllSongsCompleted when ready
+// --------------------------------------------------------------------------
+// 
+TInt CMediaManager::RegisterAllSongs()
+    {
+    TRACE_FUNC_ENTRY;
+    if ( iCurrentState != EIdle || !iSnapshotArray)
+        {
+        LOGGER_WRITE("Not Idle or iSnapshotArray is NULL");
+        return KErrNotReady;
+        }
+    iCurrentState = EReadingSongCount;
+    SetActive();
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// Registers playlist.
+// --------------------------------------------------------------------------
+// 
+void CMediaManager::RegisterPlaylistL( const CMPXMedia& aMedia )
+    {
+    TRACE_FUNC_ENTRY;
+    if ( !iSnapshotArray )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    if ( !aMedia.IsSupported(KMPXMediaGeneralId) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralId not supported");
+        User::Leave(KErrNotSupported);
+        }
+     
+     // Extract the playlist id from the found object
+     TUint32 playlistId = *aMedia.Value<TMPXItemId>(KMPXMediaGeneralId);
+     LOGGER_WRITE_1("KMPXMediaGeneralId: %d", playlistId);
+     
+     if ( !aMedia.IsSupported( KMPXMediaGeneralTitle ) )
+          {
+          LOGGER_WRITE("KMPXMediaGeneralTitle not supported");
+          User::Leave(KErrNotSupported);
+          }
+     
+     CPlaylistItem* playlist = CPlaylistItem::NewLC();
+     // find the media object that contains a list of songs in the playlist
+     
+     RArray<TInt> contentIDs;
+     CleanupClosePushL( contentIDs );
+     contentIDs.AppendL(KMPXMediaIdGeneral);
+     
+     CMPXMedia* searchMedia = CMPXMedia::NewL(contentIDs.Array());
+     CleanupStack::PopAndDestroy( &contentIDs );
+     CleanupStack::PushL(searchMedia);
+     
+     searchMedia->SetTObjectValueL(KMPXMediaGeneralType, EMPXGroup);    
+     searchMedia->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong);
+     searchMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId);
+     
+     RArray<TMPXAttribute> songAttributes;
+     CleanupClosePushL(songAttributes);
+     songAttributes.AppendL(KMPXMediaGeneralId);
+     songAttributes.AppendL(KMPXMediaGeneralUri);
+     
+     CMPXMedia* foundMedia = iCollectionHelper->FindAllL(*searchMedia, 
+                                                         songAttributes.Array());
+     CleanupStack::PopAndDestroy(&songAttributes);
+     CleanupStack::PopAndDestroy(searchMedia);
+     
+     CleanupStack::PushL(foundMedia);
+     
+     
+     if ( !foundMedia->IsSupported(KMPXMediaArrayCount) )
+         {
+         User::Leave(KErrNotSupported);
+         }
+     
+     // Number of references
+     TInt numOfRefs = *foundMedia->Value<TInt>(KMPXMediaArrayCount);
+     if ( numOfRefs )
+         {
+         if (!foundMedia->IsSupported(KMPXMediaArrayContents))
+             {
+             User::Leave(KErrNotSupported);
+             }
+         
+         const CMPXMediaArray* refArray =
+             foundMedia->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+         
+         // Import the references
+         for (TInt i=0;i<numOfRefs;i++)
+             {
+             const CMPXMedia* refMedia = (*refArray)[i];
+             
+             if ( refMedia->IsSupported(KMPXMediaGeneralUri) )
+                 {
+                 const TDesC& uri = refMedia->ValueText(KMPXMediaGeneralUri);
+                 playlist->AddItemL( uri );
+                 }
+             
+             }
+         }
+    
+    TSnapshotItem playlistItem(playlistId);
+    
+    const TDesC& title = aMedia.ValueText( KMPXMediaGeneralTitle );
+    playlist->SetTitleL( title );
+    
+    const TDesC& uri = aMedia.ValueText( KMPXMediaGeneralUri );
+    playlist->SetUrlL( uri );
+    
+    playlistItem.SetItemHash( *playlist, iHasher );
+    
+    playlistItem.SetParentId( KPlaylistsFolderId );
+    TKeyArrayFix key( iKey );
+    iSnapshotArray->InsertIsqL( playlistItem, key );
+    
+    CleanupStack::PopAndDestroy( foundMedia );
+    CleanupStack::PopAndDestroy( playlist );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// --------------------------------------------------------------------------
+// Populates CPlaylistItem
+// --------------------------------------------------------------------------
+// 
+void CMediaManager::GetPlayListL( TInt aPlaylistId, CPlaylistItem& aList )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    LOGGER_WRITE_1("aPlaylistId: %d", aPlaylistId);
+    
+    CMPXMedia* playlistItem = FindPlaylistL( aPlaylistId );
+    CleanupStack::PushL( playlistItem );
+    if ( !playlistItem->IsSupported(KMPXMediaGeneralId) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralId not supported");
+        User::Leave(KErrNotSupported);
+        }
+    
+    // Extract the playlist id from the found object
+    TUint32 playlistId = *playlistItem->Value<TMPXItemId>(KMPXMediaGeneralId);
+    LOGGER_WRITE_1("KMPXMediaGeneralId: %d", playlistId);
+    aList.SetId( playlistId );
+    
+    if ( !playlistItem->IsSupported(KMPXMediaGeneralTitle) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralTitle not supported");
+        User::Leave( KErrNotSupported );
+        }
+    else
+        {
+        const TDesC& title = playlistItem->ValueText(KMPXMediaGeneralTitle);
+        LOGGER_WRITE_1("KMPXMediaGeneralTitle: %S", &title);
+        aList.SetTitleL( title );
+        }
+    
+    if ( playlistItem->IsSupported( KMPXMediaGeneralUri ) )
+        {
+        const TDesC& uri = playlistItem->ValueText( KMPXMediaGeneralUri );
+        aList.SetUrlL( uri );
+        }
+    
+    CleanupStack::PopAndDestroy( playlistItem );
+    
+    CMPXMedia* playlist = FetchPlaylistContentL( aPlaylistId );
+    CleanupStack::PushL( playlist );
+    
+    if ( !playlist->IsSupported(KMPXMediaArrayCount) )
+         {
+         User::Leave(KErrNotSupported);
+         }
+     
+    // Number of references
+    TInt numOfRefs = *playlist->Value<TInt>(KMPXMediaArrayCount);
+    LOGGER_WRITE_1("numOfRefs: %d", numOfRefs);
+    if ( numOfRefs )
+        {
+        if (!playlist->IsSupported(KMPXMediaArrayContents))
+            {
+            User::Leave(KErrNotSupported);
+            }
+        
+        const CMPXMediaArray* refArray =
+        playlist->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+        
+        // Import the references
+        for (TInt i=0;i<numOfRefs;i++)
+            {
+            const CMPXMedia* refMedia = (*refArray)[i];
+            
+            if ( refMedia->IsSupported(KMPXMediaGeneralUri) )
+                {
+                aList.AddItemL( refMedia->ValueText(KMPXMediaGeneralUri) );
+                }
+            }
+        }
+ 
+    CleanupStack::PopAndDestroy( playlist );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+// --------------------------------------------------------------------------
+// Fetch a playlist content
+// --------------------------------------------------------------------------
+// 
+CMPXMedia* CMediaManager::FetchPlaylistContentL( TInt aId )
+    {
+    TRACE_FUNC_ENTRY;
+    TMPXItemId id(aId);
+
+    CMPXMedia* criteria = CMPXMedia::NewL();
+    CleanupStack::PushL( criteria );
+    criteria->SetTObjectValueL<TUid>(
+            KMPXMediaGeneralCollectionId, KMpxLocalCollectionUid );
+    criteria->SetTObjectValueL<TMPXGeneralType>(
+            KMPXMediaGeneralType, EMPXGroup );
+    
+    // set search keys
+    criteria->SetTObjectValueL<TMPXGeneralCategory>(
+            KMPXMediaGeneralCategory, EMPXSong );    
+    criteria->SetTObjectValueL<TMPXItemId>(
+            KMPXMediaGeneralId, id );
+    
+    // define attributes fetched
+    RArray<TMPXAttribute> songAttributes;
+    CleanupClosePushL(songAttributes);
+    songAttributes.AppendL(KMPXMediaGeneralId);
+    songAttributes.AppendL(KMPXMediaGeneralUri);
+    
+    // now find
+    CMPXMedia* result = iCollectionHelper->FindAllL( *criteria , songAttributes.Array() );
+    CleanupStack::PopAndDestroy( &songAttributes );
+    CleanupStack::PopAndDestroy( criteria );
+    
+    TRACE_FUNC_EXIT;
+    return result;
+    }
+
+
+ // --------------------------------------------------------------------------
+ // Find a playlist
+ // --------------------------------------------------------------------------
+ //
+ CMPXMedia* CMediaManager::FindPlaylistL( TInt aUid )
+     {
+     TRACE_FUNC_ENTRY;
+     CMPXMedia* criteria = CMPXMedia::NewL();
+     CleanupStack::PushL( criteria );
+     
+     criteria->SetTObjectValueL<TMPXGeneralType>(
+                 KMPXMediaGeneralType, EMPXItem );
+     criteria->SetTObjectValueL<TMPXGeneralCategory>(
+                 KMPXMediaGeneralCategory, EMPXPlaylist );
+     criteria->SetTObjectValueL<TMPXItemId>(
+                 KMPXMediaGeneralId, aUid );
+         
+     // define attributes fetched
+     RArray<TMPXAttribute> playlistAttributes;
+     CleanupClosePushL(playlistAttributes);
+     playlistAttributes.AppendL(KMPXMediaGeneralId);
+     playlistAttributes.AppendL(KMPXMediaGeneralCollectionId); //test
+     playlistAttributes.AppendL(KMPXMediaGeneralTitle);
+     playlistAttributes.AppendL(KMPXMediaGeneralUri);
+     
+     // now find
+     CMPXMedia* foundList = 0;
+     foundList = iCollectionHelper->FindAllL( *criteria , playlistAttributes.Array() );
+     CleanupStack::PopAndDestroy( &playlistAttributes );
+     CleanupStack::PopAndDestroy( criteria );
+     
+     CleanupStack::PushL( foundList );
+     
+     if ( !foundList->IsSupported(KMPXMediaArrayCount) )
+         {
+         LOGGER_WRITE("KMPXMediaArrayCount not supported");
+         User::Leave( KErrNotSupported );
+         }
+     
+     TInt foundItemCount = *foundList->Value<TInt>(KMPXMediaArrayCount);
+     
+     CMPXMedia* playlist(NULL);
+     if ( foundItemCount )
+         {
+         if ( !foundList->IsSupported(KMPXMediaArrayContents) )
+             {
+             LOGGER_WRITE("KMPXMediaArrayContents not supported");
+             User::Leave(KErrNotSupported);
+             }
+             
+         const CMPXMediaArray* foundArray = foundList->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+         
+         // get the first founded item
+         playlist = CMPXMedia::NewL(*(*foundArray)[0]);
+         }
+     else
+         {
+         User::Leave( KErrGeneral );
+         }
+     
+     CleanupStack::PopAndDestroy( foundList );
+     
+     TRACE_FUNC_EXIT;
+     return playlist;
+     }
+
+void CMediaManager::GetSongL( TInt aSongId, CSongItem& aSongItem )
+    {
+    TRACE_FUNC_ENTRY;
+    TMPXItemId id(aSongId);
+
+    RArray<TInt> contentIDs;
+    CleanupClosePushL( contentIDs );
+    contentIDs.AppendL( KMPXMediaIdMusic );
+    contentIDs.AppendL( KMPXMediaIdGeneral );
+    
+    CMPXMedia* criteria = CMPXMedia::NewL(contentIDs.Array());
+    CleanupStack::PopAndDestroy( &contentIDs );
+    CleanupStack::PushL(criteria);
+    
+    // set search keys
+    criteria->SetTObjectValueL<TMPXGeneralType>(
+            KMPXMediaGeneralType, EMPXItem );
+    criteria->SetTObjectValueL<TMPXGeneralCategory>(
+            KMPXMediaGeneralCategory, EMPXSong );   
+    criteria->SetTObjectValueL<TMPXItemId>(
+            KMPXMediaGeneralId, id );
+    
+    // define attributes fetched
+    RArray<TMPXAttribute> songAttributes;
+    CleanupClosePushL(songAttributes);
+    
+    songAttributes.AppendL( KMPXMediaGeneralType );
+    songAttributes.AppendL( KMPXMediaGeneralCategory );
+    songAttributes.AppendL( KMPXMediaGeneralUri );
+    songAttributes.AppendL( KMPXMediaGeneralId );
+    songAttributes.AppendL( KMPXMediaGeneralTitle );
+    songAttributes.AppendL( KMPXMediaGeneralMimeType );
+    songAttributes.AppendL( KMPXMediaGeneralDuration );
+    songAttributes.AppendL( KMPXMediaGeneralComment );
+    
+    songAttributes.AppendL( KMPXMediaMusicArtist );
+    songAttributes.AppendL( KMPXMediaMusicAlbum );
+    songAttributes.AppendL( KMPXMediaMusicYear );
+    songAttributes.AppendL( KMPXMediaMusicAlbumTrack );
+    songAttributes.AppendL( KMPXMediaMusicGenre );
+    songAttributes.AppendL( KMPXMediaMusicComposer );
+    
+    // now find
+    CMPXMedia* result = 0;
+    TRAPD(err, result = iCollectionHelper->FindAllL( *criteria , songAttributes.Array() ));
+    CleanupStack::PopAndDestroy( &songAttributes );
+    CleanupStack::PopAndDestroy( criteria );
+    
+    if ( err )
+        {
+        LOGGER_WRITE_1("FindAllL err: %d", err);
+        User::Leave( err );
+        }
+    
+    CleanupStack::PushL( result );
+
+    if ( !result->IsSupported(KMPXMediaArrayCount) )
+         {
+         LOGGER_WRITE("KMPXMediaArrayCount not supported");
+         User::Leave(KErrNotSupported);
+         }
+    
+    if ( !result->IsSupported( KMPXMediaArrayContents ) )
+        {
+        User::Leave(KErrNotSupported);
+        }
+    
+    const CMPXMediaArray* songsArray =
+    result->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+    if ( songsArray->Count() == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    const CMPXMedia* songMedia = (*songsArray)[0];
+    
+    ReadSongAttributesL( *songMedia, aSongItem, ETrue );
+    
+    CleanupStack::PopAndDestroy( result );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+CMPXMedia* CMediaManager::CreatePlaylistMediaL( const CPlaylistItem& aPlaylist )
+    {
+    TRACE_FUNC_ENTRY;
+    RArray<TInt> contentIDs;
+    contentIDs.AppendL(KMPXMediaIdGeneral);
+    
+    CMPXMedia* playlist = CMPXMedia::NewL( contentIDs.Array() );
+    CleanupStack::PushL( playlist );
+    contentIDs.Close();
+    // add playlist info into the playlist media
+    playlist->SetTObjectValueL<TUid>(
+        KMPXMediaGeneralCollectionId, KMpxLocalCollectionUid );
+    
+    // set playlist title
+    playlist->SetTextValueL( KMPXMediaGeneralTitle, aPlaylist.Title() );
+    
+    // set type
+    playlist->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
+     
+    // set category
+    playlist->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist ); 
+    
+    
+    TFileName playlistfile;
+    
+    TInt drive;
+    User::LeaveIfError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive) );
+    TUint driveStatus( 0 );
+    TInt err = DriveInfo::GetDriveStatus( iFs, drive, driveStatus );
+    if ( !err && (driveStatus & DriveInfo::EDrivePresent) )
+        {
+        User::LeaveIfError( PathInfo::GetRootPath( playlistfile, drive ) );
+        LOGGER_WRITE_1("mmc playlistfile: %S", &playlistfile);
+        }
+    else
+        {
+        playlistfile = PathInfo::PhoneMemoryRootPath();
+        LOGGER_WRITE_1("phone playlistfile: %S", &playlistfile);
+        }
+    
+    playlistfile.Append( KPlaylistPath );
+    
+    // set location drive
+    TDriveUnit driveUnit( playlistfile );
+    TPtrC driveName = driveUnit.Name();
+    playlist->SetTextValueL( KMPXMediaGeneralDrive, driveName );
+    
+    
+    TTime time;
+    time.HomeTime();
+    playlistfile.AppendNum(time.Int64());
+    playlistfile.Append(KMPXVirtualPlaylistExt);
+    
+    LOGGER_WRITE_1("playlistfile: %S", &playlistfile);
+    playlist->SetTextValueL(
+             KMPXMediaGeneralUri, playlistfile );
+    
+    // set DbFlags to indicate that this is a virtual playlist
+    playlist->SetTObjectValueL<TUint>(KMPXMediaGeneralFlags,
+       KMPXMediaGeneralFlagsSetOrUnsetBit | KMPXMediaGeneralFlagsIsVirtual);
+
+    // create songs
+    CMPXMediaArray* medias = CreateMediaArrayLC( aPlaylist );
+    // set medias
+    playlist->SetCObjectValueL( KMPXMediaArrayContents, medias );
+    /// set media count        
+    playlist->SetTObjectValueL( KMPXMediaArrayCount, medias->Count() );
+    
+    CleanupStack::PopAndDestroy(medias);
+    CleanupStack::Pop(playlist);
+    
+    
+    TRACE_FUNC_EXIT;
+    return playlist;
+    }
+
+CMPXMediaArray* CMediaManager::CreateMediaArrayLC( const CPlaylistItem& aList )
+    {
+    CMPXMediaArray* medias = CMPXMediaArray::NewL();
+    CleanupStack::PushL( medias );
+    //
+    // create entries
+    //
+    TInt itemCount = aList.ItemCount();
+    for ( TInt i=0; i<itemCount; i++)
+        {
+        TPtrC16 ptrUri = aList.ItemAt(i);
+        LOGGER_WRITE_1("add uri: %S", &ptrUri);
+        iCollectionHelper->AddL( ptrUri, this );
+        iWaitOngoing = ETrue;
+        LOGGER_WRITE("iWait.Start");
+        iWait.Start();
+        LOGGER_WRITE("continue..");
+    
+        RArray<TInt> contentIDs;
+        contentIDs.AppendL(KMPXMediaIdGeneral);
+        contentIDs.AppendL(KMPXMediaIdAudio);
+        contentIDs.AppendL(KMPXMediaIdMusic);
+        contentIDs.AppendL(KMPXMediaIdMTP); 
+        
+        CMPXMedia* entry = CMPXMedia::NewL( contentIDs.Array() );
+        CleanupStack::PushL( entry );
+        contentIDs.Close();
+        
+        entry->SetTObjectValueL<TUid>(
+                KMPXMediaGeneralCollectionId, KMpxLocalCollectionUid );
+        
+        entry->SetTObjectValueL<TMPXGeneralType>(
+                     KMPXMediaGeneralType, EMPXItem );
+        
+        entry->SetTObjectValueL<TMPXGeneralCategory>(
+                     KMPXMediaGeneralCategory, EMPXSong );
+        
+        
+        entry->SetTextValueL( KMPXMediaGeneralUri, ptrUri );
+        
+        // set location drive
+        TDriveUnit driveUnit( ptrUri );
+        TPtrC driveName = driveUnit.Name();
+        entry->SetTextValueL( KMPXMediaGeneralDrive, driveName );
+        
+        medias->AppendL(entry);
+        CleanupStack::Pop(entry);
+        }
+    return medias;
+    }
+
+void CMediaManager::CreateNewPlaylistL( TInt& aNewUid, CPlaylistItem& aList )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CMPXMedia* playlist = CreatePlaylistMediaL( aList );
+    CleanupStack::PushL( playlist );
+    iMediator->AddItemL( playlist );
+    
+    if ( !playlist->IsSupported(KMPXMediaGeneralId) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralId not supported");
+        User::Leave( KErrNotSupported );
+        }
+    else
+        {
+        // Extract the playlist id from the found object
+        TUint32 playlistId = *playlist->Value<TMPXItemId>(KMPXMediaGeneralId);
+        LOGGER_WRITE_1("KMPXMediaGeneralId: %d", playlistId);
+        aNewUid = playlistId;
+        
+        if ( !playlist->IsSupported( KMPXMediaGeneralUri ) )
+            {
+            // get url
+            const TDesC& uri = playlist->ValueText( KMPXMediaGeneralUri );
+            aList.SetUrlL( uri );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy(playlist);
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::ReplacePlaylistL( TInt aPlaylistId, CPlaylistItem& aPlaylist )
+    {
+    TRACE_FUNC_ENTRY;
+    CMPXMedia* playlist = CMPXMedia::NewL();
+    CleanupStack::PushL( playlist );
+    
+    // add playlist info into the playlist media
+    playlist->SetTObjectValueL<TUid>(
+        KMPXMediaGeneralCollectionId, KMpxLocalCollectionUid );
+    
+    // set type
+    playlist->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
+     
+    // set category
+    playlist->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist ); 
+    
+    
+    
+    // find playlist uri
+    CMPXMedia* oldPlaylist = FindPlaylistL( aPlaylistId );
+    CleanupStack::PushL( oldPlaylist );
+    if ( !oldPlaylist->IsSupported(KMPXMediaGeneralUri) )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    const TDesC& uri = oldPlaylist->ValueText( KMPXMediaGeneralUri );
+    LOGGER_WRITE_1("uri: %S", &uri);
+    
+    playlist->SetTextValueL(
+            KMPXMediaGeneralUri, uri );
+    
+	aPlaylist.SetUrlL( uri );
+    
+    const TDesC& title = oldPlaylist->ValueText( KMPXMediaGeneralTitle );
+    if ( title.Compare( aPlaylist.Title() ) != 0 )
+        {
+        LOGGER_WRITE_1("title changed old: %S", &title);
+        LOGGER_WRITE_1("new title: %S", &aPlaylist.Title());
+        // set playlist title
+        playlist->SetTextValueL( KMPXMediaGeneralTitle, aPlaylist.Title() );
+        
+        // update title first
+        iMediator->SetItemL( playlist );
+        }
+    
+    
+    CleanupStack::PopAndDestroy( oldPlaylist );
+    
+    // update songs
+    CMPXMediaArray* songArray = CreateMediaArrayLC( aPlaylist );
+    // set medias
+    playlist->SetCObjectValueL( KMPXMediaArrayContents, songArray );
+    /// set media count        
+    playlist->SetTObjectValueL( KMPXMediaArrayCount, songArray->Count() );
+    
+    iMediator->SetItemL( playlist );
+    
+    CleanupStack::PopAndDestroy( songArray );
+    CleanupStack::PopAndDestroy( playlist );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CMediaManager::DeletePlaylistL( TInt aPlaylistId )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    CMPXMedia* playlist = FindPlaylistL( aPlaylistId );
+    CleanupStack::PushL( playlist );
+    iCollection->Collection().RemoveL( *playlist );
+    CleanupStack::PopAndDestroy( playlist );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::HandleAddFileCompleteL( TInt aErr )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aErr: %d", aErr);
+    if ( iWaitOngoing )
+        {
+        LOGGER_WRITE("AsyncStop");
+        iWaitOngoing = EFalse;
+        iWait.AsyncStop();
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::ReadSongAttributesL( const CMPXMedia& aMedia, CSongItem& aSongItem,
+        TBool aReadFileDetails )
+    {
+    if ( !aMedia.IsSupported(KMPXMediaGeneralUri) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralUri not supported");
+        User::Leave(KErrNotSupported);
+        }    
+    
+    if ( !aMedia.IsSupported(KMPXMediaGeneralId) )
+        {
+        LOGGER_WRITE("KMPXMediaGeneralId not supported");
+        User::Leave(KErrNotSupported);
+        }
+    
+    aSongItem.SetId( *aMedia.Value<TMPXItemId>(KMPXMediaGeneralId) );
+    
+    const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
+    aSongItem.SetUriL( uri );
+    
+    if ( aMedia.IsSupported(KMPXMediaGeneralTitle) )
+        {
+        aSongItem.SetTitleL( aMedia.ValueText(KMPXMediaGeneralTitle) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaGeneralMimeType) )
+        {
+        aSongItem.SetMimeTypeL( aMedia.ValueText(KMPXMediaGeneralMimeType) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaGeneralDuration) )
+        {
+        aSongItem.SetDuration( aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralDuration) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicArtist) )
+        {
+        aSongItem.SetArtistL( aMedia.ValueText(KMPXMediaMusicArtist) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicAlbum) )
+        {
+        aSongItem.SetAlbumL( aMedia.ValueText(KMPXMediaMusicAlbum) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicYear) )
+        {
+        TInt64 year = aMedia.ValueTObjectL<TInt64>( KMPXMediaMusicYear );
+        TTime yearTime( year);
+        aSongItem.SetYear( yearTime.DateTime().Year() );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicAlbumTrack) )
+        {
+        aSongItem.SetAlbumTrack( *aMedia.Value<TInt>(KMPXMediaMusicAlbumTrack) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicGenre) )
+        {
+        const TDesC& genre = aMedia.ValueText(KMPXMediaMusicGenre);
+        aSongItem.SetGenreL( genre );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaMusicComposer) )
+        {
+        aSongItem.SetComposerL( aMedia.ValueText(KMPXMediaMusicComposer) );
+        }
+    
+    if ( aMedia.IsSupported(KMPXMediaGeneralComment) )
+        {
+        aSongItem.SetCommentL( aMedia.ValueText(KMPXMediaGeneralComment) );
+        }
+    
+    // Reading file timestamp and size is slow, read only if needed
+    if ( aReadFileDetails )
+        {
+        TEntry fileEntry;
+        TInt err = iFs.Entry(uri,fileEntry);
+        if ( !err )
+            {
+            aSongItem.SetModifiedTime( fileEntry.iModified );
+            aSongItem.SetFileSize( fileEntry.iSize );
+            }
+        }
+    
+    }
+
+
+void CMediaManager::DoCancel()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    delete iFoundedMedia;
+    iFoundedMedia = NULL;
+    iReadedItems = 0;
+    iItemsFound = 0;      
+    TState state = iCurrentState;
+    iCurrentState = EIdle;
+    
+    switch (state)
+        {
+        case EReadingPlaylistCount:
+        case EEnumeratingPlaylists:
+            iObserver->RegisterAllPlayListsCompleted( KErrCancel );
+            break;
+            
+        case EReadingSongCount:
+        case EEnumeratingSongs:
+            iObserver->RegisterAllSongsCompleted( KErrCancel );
+            break;
+        default:
+            break;
+        }
+    
+    LOGGER_WRITE("signal cancel");
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrCancel );
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::RunL()
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("iStatus.Int(): %d", iStatus.Int())
+    TRequestStatus* status = &iStatus;
+    switch (iCurrentState)
+        {
+        case EReadingPlaylistCount:
+            //if ( !iCancel )
+            //    {
+                ReadPlaylistCountL();
+                iReadedItems=0;
+                // next state
+                iCurrentState = EEnumeratingPlaylists;
+                SetActive();
+                User::RequestComplete( status, KErrNone );
+            /*    }
+            else
+                {
+                LOGGER_WRITE("cancel");
+                iCancel = EFalse;
+                delete iFoundedMedia; iFoundedMedia = NULL;
+                iReadedItems = 0;
+                iItemsFound = 0;
+                iCurrentState = EIdle;
+                iObserver->RegisterAllPlayListsCompleted( KErrCancel );
+                }*/
+            break;
+            
+        case EEnumeratingPlaylists:
+            //if ( !iCancel )
+            //    {
+                ReadPlaylistItemsL();
+                if ( iReadedItems == iItemsFound )
+                    {
+                    // all items readed
+                    delete iFoundedMedia;
+                    iFoundedMedia = NULL;
+                    // next state
+                    iCurrentState = EIdle;
+                    iObserver->RegisterAllPlayListsCompleted( KErrNone );
+                    }
+                else
+                    {
+                    // not ready yet, continue same operation
+                    SetActive();
+                    User::RequestComplete( status, KErrNone );
+                    }
+             /*   }
+            else
+                {
+                // cancel
+                LOGGER_WRITE("cancel");
+                iCancel = EFalse;
+                delete iFoundedMedia; iFoundedMedia = NULL;
+                iReadedItems = 0;
+                iItemsFound = 0;
+                iCurrentState = EIdle;
+                iObserver->RegisterAllPlayListsCompleted( KErrCancel );
+                }*/
+            break;
+            
+        case EReadingSongCount:
+            //if ( !iCancel )
+            //    {
+                ReadSongCountL();
+                iReadedItems=0;
+                // next state
+                iCurrentState = EEnumeratingSongs;
+                SetActive();
+                User::RequestComplete( status, KErrNone );
+            /*    }
+            else
+                {
+                LOGGER_WRITE("cancel");
+                iCancel = EFalse;
+                delete iFoundedMedia; iFoundedMedia = NULL;
+                iReadedItems = 0;
+                iItemsFound = 0;
+                iCurrentState = EIdle;
+                iObserver->RegisterAllSongsCompleted( KErrCancel );
+                }*/
+            break;
+            
+        case EEnumeratingSongs:
+//            if ( !iCancel )
+              //  {
+                ReadSongItemsL();
+                if ( iReadedItems == iItemsFound )
+                    {
+                    // all items readed
+                    delete iFoundedMedia;
+                    iFoundedMedia = NULL;
+                    // next state
+                    iCurrentState = EIdle;
+                    iObserver->RegisterAllSongsCompleted( KErrNone );
+                    }
+                else
+                    {
+                    // not ready yet, continue same operation
+                    SetActive();
+                    User::RequestComplete( status, KErrNone );
+                    }
+              /*  }
+            else
+                {
+                LOGGER_WRITE("cancel");
+                iCancel = EFalse;
+                delete iFoundedMedia; iFoundedMedia = NULL;
+                iReadedItems = 0;
+                iItemsFound = 0;
+                iCurrentState = EIdle;
+                iObserver->RegisterAllSongsCompleted( KErrCancel );
+                }*/
+            break;
+        default:
+            break;
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+
+TInt CMediaManager::RunError( TInt aError )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1("aError: %d", aError)
+    switch (iCurrentState)
+        {
+        case EReadingPlaylistCount:
+        case EEnumeratingPlaylists:
+            iObserver->RegisterAllPlayListsCompleted( aError );
+            break;
+        case EReadingSongCount:
+        case EEnumeratingSongs:
+            iObserver->RegisterAllSongsCompleted( aError );
+            break;
+        default:
+            LOGGER_WRITE("Unknown state!");
+            break;
+        }
+    
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    }
+
+void CMediaManager::ReadPlaylistCountL()
+    {
+    TRACE_FUNC_ENTRY;
+    // Find all playlist files in the playlist DB
+    RArray<TInt> contentIDs;
+    CleanupClosePushL( contentIDs );
+    contentIDs.AppendL(KMPXMediaIdGeneral);
+    
+    CMPXMedia* searchMedia = CMPXMedia::NewL(contentIDs.Array());
+    CleanupStack::PopAndDestroy( &contentIDs );
+    CleanupStack::PushL(searchMedia);
+    
+    searchMedia->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);    
+    searchMedia->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXPlaylist);
+    
+    RArray<TMPXAttribute> playlistAttributes;
+    CleanupClosePushL(playlistAttributes);
+    playlistAttributes.AppendL( KMPXMediaGeneralId );
+    playlistAttributes.AppendL( KMPXMediaGeneralTitle );
+    playlistAttributes.AppendL( KMPXMediaGeneralUri );
+    
+    LOGGER_WRITE("find all");
+    delete iFoundedMedia; iFoundedMedia=NULL;
+    iFoundedMedia = iCollectionHelper->FindAllL(*searchMedia, playlistAttributes.Array());
+    CleanupStack::PopAndDestroy(&playlistAttributes);
+    CleanupStack::PopAndDestroy(searchMedia);
+
+    if ( !iFoundedMedia->IsSupported(KMPXMediaArrayCount) )
+        {
+        delete iFoundedMedia; iFoundedMedia=NULL;
+        User::Leave( KErrNotSupported );
+        }
+    
+    iItemsFound = *iFoundedMedia->Value<TInt>(KMPXMediaArrayCount);
+    
+    LOGGER_WRITE_1("playlists: %d", iItemsFound);
+
+    if ( iItemsFound )
+        {
+        if ( !iFoundedMedia->IsSupported(KMPXMediaArrayContents) )
+            {
+            delete iFoundedMedia; iFoundedMedia=NULL;
+            iItemsFound = 0;
+            User::Leave(KErrNotSupported);
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::ReadPlaylistItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    TInt start = iReadedItems;
+    TInt end = start+iMaxPlaylistItemsToEnumerate;
+    if ( end >iItemsFound )
+        {
+        end = iItemsFound;
+        }
+    
+    const CMPXMediaArray* foundArray = iFoundedMedia->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+            
+    for (TInt i = start; i < end; i++)
+        {
+        LOGGER_WRITE_1("read playlistItem: %d", i);
+        CMPXMedia* playlistMedia = CMPXMedia::NewL(*(*foundArray)[i]);
+        CleanupStack::PushL( playlistMedia );
+        
+        // Append playlist to item array
+        RegisterPlaylistL( *playlistMedia );
+               
+        CleanupStack::PopAndDestroy( playlistMedia );
+        iReadedItems++;
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+    
+
+void CMediaManager::ReadSongCountL()
+    {
+    TRACE_FUNC_ENTRY;
+
+    RArray<TInt> contentIDs;
+    CleanupClosePushL( contentIDs );
+    contentIDs.AppendL( KMPXMediaIdGeneral );
+    contentIDs.AppendL( KMPXMediaIdMusic );
+    
+    CMPXMedia* criteria = CMPXMedia::NewL(contentIDs.Array());
+    CleanupStack::PopAndDestroy( &contentIDs );
+    CleanupStack::PushL(criteria);
+    
+    criteria->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem );
+    criteria->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong );
+    
+    // define attributes fetched
+    RArray<TMPXAttribute> songAttributes;
+    CleanupClosePushL(songAttributes);
+    
+    songAttributes.AppendL( KMPXMediaGeneralType );
+    songAttributes.AppendL( KMPXMediaGeneralCategory );
+    songAttributes.AppendL( KMPXMediaGeneralUri );
+    songAttributes.AppendL( KMPXMediaGeneralId );
+    songAttributes.AppendL( KMPXMediaGeneralTitle );
+    songAttributes.AppendL( KMPXMediaGeneralMimeType );
+    songAttributes.AppendL( KMPXMediaGeneralDuration );
+    songAttributes.AppendL( KMPXMediaGeneralComment );
+    
+    songAttributes.AppendL( KMPXMediaMusicArtist );
+    songAttributes.AppendL( KMPXMediaMusicAlbum );
+    songAttributes.AppendL( KMPXMediaMusicYear );
+    songAttributes.AppendL( KMPXMediaMusicAlbumTrack );
+    songAttributes.AppendL( KMPXMediaMusicGenre );
+    songAttributes.AppendL( KMPXMediaMusicComposer );
+    
+    delete iFoundedMedia;
+    iFoundedMedia = NULL;
+    // now find
+    LOGGER_WRITE("FindAllL");
+    iFoundedMedia = iCollectionHelper->FindAllL( *criteria , songAttributes.Array() );
+        
+    LOGGER_WRITE("FindAllL ok");
+    CleanupStack::PopAndDestroy( &songAttributes );
+    CleanupStack::PopAndDestroy( criteria );
+    
+
+    if ( !iFoundedMedia->IsSupported(KMPXMediaArrayCount) )
+         {
+         LOGGER_WRITE("KMPXMediaArrayCount not supported");
+         delete iFoundedMedia;
+         iFoundedMedia = NULL;
+         iItemsFound = 0;
+         User::Leave(KErrNotSupported);
+         }
+     
+    // Number of references
+    iItemsFound = *iFoundedMedia->Value<TInt>(KMPXMediaArrayCount);
+    LOGGER_WRITE_1("songs: %d", iItemsFound);
+    if ( iItemsFound )
+        {
+        if (!iFoundedMedia->IsSupported(KMPXMediaArrayContents))
+            {
+            delete iFoundedMedia;
+            iFoundedMedia = NULL;
+            iItemsFound = 0;
+            User::Leave(KErrNotSupported);
+            }
+        }
+    
+    TRACE_FUNC_EXIT;
+    }
+
+void CMediaManager::ReadSongItemsL()
+    {
+    TRACE_FUNC_ENTRY;
+    
+    TInt start = iReadedItems;
+    TInt end = start+iMaxSongItemsToEnumerate;
+    if ( end >iItemsFound )
+        {
+        end = iItemsFound;
+        }
+    
+    const CMPXMediaArray* foundArray = iFoundedMedia->Value<CMPXMediaArray>(KMPXMediaArrayContents);
+    
+    TKeyArrayFix key( iKey );
+    // Import the references
+    for (TInt i = start; i < end; i++)
+        {
+        //LOGGER_WRITE_1("read songitem: %d",i);
+        const CMPXMedia* refMedia = (*foundArray)[i];
+        
+        CSongItem* song = CSongItem::NewLC();
+        
+        ReadSongAttributesL( *refMedia, *song, EFalse );
+        TSnapshotItem snapshotItem( song->Id(), KAllSongsFolderId );
+        snapshotItem.SetItemHash( *song, iHasher );
+        
+        iSnapshotArray->InsertIsqL( snapshotItem, key );
+        
+        CleanupStack::PopAndDestroy( song );
+        iReadedItems++;
+        }
+    TRACE_FUNC_EXIT;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/omadsfolderobject.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,101 @@
+/*
+* 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:  COMADSFolderObject class implementation.
+*
+*/
+
+
+#include <utf.h>
+#include "omadsfolderobject.h"
+#include "logger.h"
+
+_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");
+const TInt KDateFormatLength( 15 );
+
+
+COMADSFolderObject* COMADSFolderObject::NewLC()
+    {
+    COMADSFolderObject* self = new (ELeave) COMADSFolderObject;
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+COMADSFolderObject::~COMADSFolderObject()
+    {
+    }
+
+void COMADSFolderObject::ExportFolderXmlL( CBufBase& aBuffer )
+    {
+    iBuffer = &aBuffer;
+    iWriteBufPosition = 0;
+    iWriteBufSize = aBuffer.Size();     
+
+    ExportL();
+    }
+    
+void COMADSFolderObject::ExportL()
+    {
+    // Folder
+    WriteL( KFolderBeginTag );
+    
+    // Name
+    WriteL( KNameBeginTag );
+    WriteL( 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 )
+    {   
+    User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( iTemp, aData ) );
+    
+    TInt newPosition = iWriteBufPosition + iTemp.Length();
+
+    if ( newPosition > iWriteBufSize )
+        {
+        TInt expand = newPosition - iWriteBufSize;
+        iBuffer->ExpandL( iWriteBufSize, expand );
+        iWriteBufSize += expand;
+        }
+
+    iBuffer->Write( iWriteBufPosition, iTemp );
+    iWriteBufPosition = newPosition;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/playlistitem.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,204 @@
+/*
+* 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:  CPlaylistItem class implementation
+*
+*/
+
+
+
+#include "playlistitem.h"
+
+#include "logger.h"
+
+_LIT( KLineFeed, "\r\n" );
+_LIT( KUrl, "#EXTURL:" );
+_LIT( KTitle, "#EXTTITLE:" );
+
+_LIT( KCommentChar, "#" );
+
+const TInt KDefaultGranularity( 5 );
+
+CPlaylistItem* CPlaylistItem::NewLC()
+    {
+    CPlaylistItem* self = new (ELeave) CPlaylistItem();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CPlaylistItem::~CPlaylistItem()
+    {
+    TRACE_FUNC;
+    delete iTitle;
+    delete iUrl;
+    delete iDescArray;
+    }
+
+CPlaylistItem::CPlaylistItem()
+    {
+    }
+
+void CPlaylistItem::ConstructL()
+    {
+    TRACE_FUNC;
+    iTitle = KNullDesC().AllocL();
+    iUrl = KNullDesC().AllocL();
+    iDescArray = new (ELeave) CDesCArrayFlat(KDefaultGranularity);
+    }
+
+void CPlaylistItem::SetId( TInt aId )
+    {
+    iId = aId;
+    }
+
+TInt CPlaylistItem::Id() const
+    {
+    return iId;
+    }
+
+void CPlaylistItem::SetTitleL( const TDesC& aTitle )
+    {
+    delete iTitle;
+    iTitle = NULL;
+    iTitle = aTitle.AllocL();
+    }
+
+const TDesC& CPlaylistItem::Title() const
+    {
+    return *iTitle;
+    }
+
+void CPlaylistItem::SetUrlL( const TDesC& aUrl )
+    {
+    delete iUrl;
+    iUrl = NULL;
+    iUrl = aUrl.AllocL();
+    }
+
+const TDesC& CPlaylistItem::Url() const
+    {
+    return *iUrl;
+    }
+
+TInt CPlaylistItem::ItemCount() const
+    {
+    return iDescArray->MdcaCount();
+    }
+
+TPtrC16 CPlaylistItem::ItemAt( TInt aIndex ) const
+    {
+    return iDescArray->MdcaPoint( aIndex );
+    }
+
+TInt CPlaylistItem::FindItem( const TDesC16& aPtr, TInt& aPos, TKeyCmpText aTextComparisonType ) const
+    {
+    return iDescArray->Find( aPtr, aPos, aTextComparisonType );
+    }
+
+void CPlaylistItem::ExportL( RBufWriteStream& aStream ) const
+    {
+    TRACE_FUNC_ENTRY;
+    
+    aStream.WriteL( KUrl );
+    aStream.WriteL( *iUrl, iUrl->Length() );
+    aStream.WriteL( KLineFeed );
+    
+    aStream.WriteL( KTitle );
+    aStream.WriteL( *iTitle, iTitle->Length() );
+    aStream.WriteL( KLineFeed );
+    
+    TInt count = iDescArray->MdcaCount();
+    for ( TInt i=0; i<count; i++ )
+        {
+        TPtrC16 ptr16 = iDescArray->MdcaPoint( i );
+        aStream.WriteL( ptr16, ptr16.Length() );
+        aStream.WriteL( KLineFeed );
+        }
+    
+    aStream.CommitL();
+    TRACE_FUNC_EXIT;
+    }
+
+void CPlaylistItem::ImportL( const TDesC& aBuffer )
+    {
+    TRACE_FUNC_ENTRY;
+    iDescArray->Reset();
+    TPtrC tag;
+    TPtrC data;
+    TInt currentPos(0);
+    TInt lineLen(0);
+    TBool eof(EFalse);
+    while( !eof )
+        {
+        lineLen = ReadNextLine( aBuffer.Mid(currentPos), data );
+        if ( lineLen >= 0)
+            {
+            if ( data.FindF( KTitle ) == 0 )
+                {
+                TPtrC title = data.Mid( KTitle().Length() );
+                SetTitleL( title );
+                }
+            else if ( data.FindF( KCommentChar ) == 0 )
+                {
+                // ignore comment
+                }
+            else if ( data.Length() > 0 )
+                {
+                // must be song url
+                AddItemL( data );
+                }
+            }
+        else
+            {
+            eof = ETrue;
+            }
+        currentPos += lineLen;
+        if ( currentPos >= aBuffer.Length() )
+            {
+            eof = ETrue;
+            }
+        }
+    TRACE_FUNC_EXIT;
+    }
+
+void CPlaylistItem::AddItemL( const TDesC& aSongUri )
+    {
+    //LOGGER_WRITE_1("AddItem: %S", &aSongUri);
+    TFileName uri(aSongUri);
+    uri.LowerCase();
+    uri.TrimAll();
+    iDescArray->InsertIsqAllowDuplicatesL( uri );
+    }
+
+TInt CPlaylistItem::ReadNextLine( const TDesC& aBuffer, TPtrC& aLine )
+    {
+    //TRACE_FUNC_ENTRY;
+    TInt lineLen = aBuffer.FindF( KLineFeed );
+    
+    if ( lineLen == KErrNotFound )
+        {
+        lineLen = aBuffer.Length();
+        if ( lineLen == 0 )
+            {
+            //TRACE_FUNC_RET( lineLen );
+            return KErrNotFound;
+            }
+        }
+    
+    aLine.Set( aBuffer.Mid( 0, lineLen ));
+    //LOGGER_WRITE_1("aLine: %S", &aLine);
+    lineLen += 2;
+    //TRACE_FUNC_RET( lineLen );
+    return lineLen;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/snapshotitem.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,200 @@
+/*
+* 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:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#include <S32STRM.h>
+
+#include "snapshotitem.h"
+
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// C++ default constructor can NOT contain any code, that might leave
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem()
+    {
+    SetItemId( 0 );
+    SetParentId( 0 );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::TSnapshotItem
+// Constructor, takes item id as a parameter
+// -----------------------------------------------------------------------------
+TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
+    const TSmlDbItemUid& aParent )
+    {
+    SetItemId( aItemId );
+    SetParentId( aParent );
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::ExternalizeL
+// Writes the contents of this class to stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::ExternalizeL( RWriteStream& aStream ) const
+    {
+    aStream.WriteInt32L( iItemId );
+    aStream.WriteInt32L( iParentId );
+    
+    TPckgBuf<THashValue> nameBuf(iHash);
+    
+    aStream << nameBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// TSnapshotItem::InternalizeL
+// Reads the contents of this class from stream
+// -----------------------------------------------------------------------------
+void TSnapshotItem::InternalizeL( RReadStream& aStream )
+    {
+    iItemId = aStream.ReadInt32L();
+    iParentId = aStream.ReadInt32L();
+    
+    TPckgBuf<THashValue> nameBuf;
+	aStream >> nameBuf;
+	iHash = nameBuf();
+    }
+
+const TSmlDbItemUid& TSnapshotItem::ItemId() const
+    {
+    return iItemId;
+    }
+
+void TSnapshotItem::SetItemId( const TSmlDbItemUid& aItemId )
+    {
+    iItemId = aItemId;
+    }
+
+
+const TSmlDbItemUid& TSnapshotItem::ParentId() const
+    {
+    return iParentId;
+    }
+
+void TSnapshotItem::SetParentId( const TSmlDbItemUid& aParentId )
+    {
+    iParentId = aParentId;
+    }
+
+
+void TSnapshotItem::SetItemHash( const TDesC& aFolderName, CMD5& aHasher )
+    {
+    TPtrC8 narrowFolder;
+    TInt narrowFolderLen = 0;
+
+    narrowFolderLen = aFolderName.Length()*2;
+    narrowFolder.Set((TUint8*)aFolderName.Ptr(), narrowFolderLen);
+    
+    aHasher.Reset();
+    aHasher.Update( narrowFolder );
+    
+    iHash = aHasher.Final();
+    
+    }
+
+void TSnapshotItem::SetItemHash( const CSongItem& aSongItem, CMD5& aHasher )
+    {
+    TPtrC8 narrowData;
+    TInt narrowDataLen = 0;
+
+    
+    aHasher.Reset();
+    
+    narrowDataLen = aSongItem.Uri().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Uri().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Title().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Title().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.MimeType().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.MimeType().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Artist().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Artist().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Album().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Album().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Genre().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Genre().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Comment().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Comment().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.Composer().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.Composer().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aSongItem.MimeType().Length()*2;
+    narrowData.Set((TUint8*)aSongItem.MimeType().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    const TInt KNumberMaxLength(11);
+    TBuf8<KNumberMaxLength> temp;
+    temp.Num( aSongItem.Year() );
+    aHasher.Update( temp );
+    
+    temp.Num( aSongItem.AlbumTrack() );
+    aHasher.Update( temp );
+    
+    temp.Num( aSongItem.Rating() );
+    aHasher.Update( temp );   
+    
+    temp.Num( aSongItem.Duration() );
+    aHasher.Update( temp );
+    
+    iHash.Copy( aHasher.Final() );
+    
+    }
+
+void TSnapshotItem::SetItemHash( const CPlaylistItem& aPlaylist, CMD5& aHasher )
+    {
+    TPtrC8 narrowData;
+    TInt narrowDataLen = 0;
+    
+    aHasher.Reset();
+    narrowDataLen = aPlaylist.Title().Length()*2;
+    narrowData.Set((TUint8*)aPlaylist.Title().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    narrowDataLen = aPlaylist.Url().Length()*2;
+    narrowData.Set((TUint8*)aPlaylist.Url().Ptr(), narrowDataLen);
+    aHasher.Update( narrowData );
+    
+    for (TInt i=0; i<aPlaylist.ItemCount(); i++ )
+        {
+        TPtrC16 song = aPlaylist.ItemAt(i);
+        narrowDataLen = song.Length()*2;
+        narrowData.Set((TUint8*)song.Ptr(), narrowDataLen);
+        aHasher.Update( narrowData );
+        }
+    iHash.Copy( aHasher.Final() );
+    }
+
+const TDesC8& TSnapshotItem::Hash() const
+    {
+    return iHash;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mediads/src/songitem.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,351 @@
+/*
+* 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:  CSongItem class implementation
+*
+*/
+
+
+
+#include "songitem.h"
+
+#include <metadatautility.h>
+#include <metadatafieldcontainer.h>
+#include <metadatafield.hrh>
+
+#include "logger.h"
+#include "sconmetadatafielddefs.h"
+
+
+CSongItem::CSongItem()
+    {
+    }
+
+CSongItem* CSongItem::NewLC()
+    {
+    CSongItem* self = new (ELeave) CSongItem();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+void CSongItem::ConstructL()
+    {
+    iUri = KNullDesC().AllocL();
+    iTitle = KNullDesC().AllocL();
+    iMimeType = KNullDesC().AllocL();
+    iArtist = KNullDesC().AllocL();
+    iAlbum = KNullDesC().AllocL();
+    iGenre = KNullDesC().AllocL();
+    iComment = KNullDesC().AllocL();
+    iComposer = KNullDesC().AllocL();
+    
+    iDuration = -1;
+    iYear = -1;
+    iAlbumTrack = -1;
+    iRating = -1;
+    iSize = 0;
+    }
+
+CSongItem::~CSongItem()
+    {
+    delete iUri;
+    delete iTitle;
+    delete iMimeType;
+    delete iArtist;
+    delete iAlbum;
+    delete iGenre;
+    delete iComment;
+    delete iComposer;
+    }
+
+void CSongItem::SetId( TInt aId )
+    {
+    iId = aId;
+    }
+
+TInt CSongItem::Id() const
+    {
+    return iId;
+    }
+
+void CSongItem::SetUriL( const TDesC& aUri )
+    {
+    delete iUri;
+    iUri = NULL;
+    iUri = aUri.AllocL();
+    }
+
+const TDesC& CSongItem::Uri() const
+    {
+    return *iUri;
+    }
+
+void CSongItem::SetTitleL( const TDesC& aTitle )
+    {
+    delete iTitle;
+    iTitle = NULL;
+    iTitle = aTitle.AllocL();
+    }
+
+const TDesC& CSongItem::Title() const
+    {
+    return *iTitle;
+    }
+
+void CSongItem::SetMimeTypeL( const TDesC& aMimeType )
+    {
+    delete iMimeType;
+    iMimeType = NULL;
+    iMimeType = aMimeType.AllocL();
+    }
+
+const TDesC& CSongItem::MimeType() const
+    {
+    return *iMimeType;
+    }
+
+void CSongItem::SetDuration( TInt aDuration )
+    {
+    iDuration = aDuration;
+    }
+
+TInt CSongItem::Duration() const
+    {
+    return iDuration;
+    }
+
+void CSongItem::SetArtistL( const TDesC& aArtist )
+    {
+    delete iArtist;
+    iArtist = NULL;
+    iArtist = aArtist.AllocL();
+    }
+
+const TDesC& CSongItem::Artist() const
+    {
+    return *iArtist;
+    }
+
+void CSongItem::SetAlbumL( const TDesC& aAlbum )
+    {
+    delete iAlbum;
+    iAlbum = NULL;
+    iAlbum = aAlbum.AllocL();
+    }
+
+const TDesC& CSongItem::Album() const
+    {
+    return *iAlbum;
+    }
+
+void CSongItem::SetYear( TInt aYear )
+    {
+    iYear = aYear;
+    }
+
+TInt CSongItem::Year() const
+    {
+    return iYear;
+    }
+
+void CSongItem::SetAlbumTrack( TInt aAlbumTrack )
+    {
+    iAlbumTrack = aAlbumTrack;
+    }
+
+TInt CSongItem::AlbumTrack() const
+    {
+    return iAlbumTrack;
+    }
+
+void CSongItem::SetGenreL( const TDesC& aGenre )
+    {
+    delete iGenre;
+    iGenre = NULL;
+    iGenre = aGenre.AllocL();
+    }
+
+const TDesC& CSongItem::Genre() const
+    {
+    return *iGenre;
+    }
+
+void CSongItem::SetCommentL( const TDesC& aComment )
+    {
+    delete iComment;
+    iComment = NULL;
+    iComment = aComment.AllocL();
+    }
+
+const TDesC& CSongItem::Comment() const
+    {
+    return *iComment;
+    }
+    
+void CSongItem::SetComposerL( const TDesC& aComposer )
+    {
+    delete iComposer;
+    iComposer = NULL;
+    iComposer = aComposer.AllocL();
+    }
+
+const TDesC& CSongItem::Composer() const
+    {
+    return *iComposer;
+    }
+
+void CSongItem::SetRating( TInt aRating )
+    {
+    iRating = aRating;
+    }
+
+TInt CSongItem::Rating() const
+    {
+    return iRating;
+    }
+
+void CSongItem::SetModifiedTime( TTime& aTime )
+    {
+    iModifiedTime = aTime;
+    }
+
+const TTime& CSongItem::ModifiedTime() const
+    {
+    return iModifiedTime;
+    }
+
+void CSongItem::SetFileSize( TInt32 aSize )
+    {
+    iSize = aSize;
+    }
+
+TInt32 CSongItem::FileSize() const
+    {
+    return iSize;
+    }
+
+// -----------------------------------------------------------------------------
+// CSongItem::ExportL
+// Exports item as specified in "Metadata format description v3.doc" document.
+// -----------------------------------------------------------------------------
+void CSongItem::ExportL( RWriteStream& aStream )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    // write object header
+
+    // header id
+    aStream.WriteUint8L( KSconMetadataHeaderAudio );
+    
+    // header version
+    aStream.WriteUint8L( KSconMetadataHeaderVersion );
+    
+    WriteUnicodeL( aStream, iTitle->Des(), KSconAudioTitle );
+    WriteUnicodeL( aStream, iUri->Des(), KSconAudioFilename );
+    
+    if ( iDuration > -1 )
+        {
+        WriteUInt32FieldL( aStream, iDuration, KSconAudioDuration );
+        }
+    
+    WriteUnicodeL( aStream, iArtist->Des(), KSconAudioArtist );
+    if ( iYear > -1 )
+        {
+        WriteUInt16FieldL( aStream, iYear, KSconAudioYear);
+        }
+    if ( iAlbumTrack > -1 )
+        {
+        WriteUInt16FieldL( aStream, iAlbumTrack, KSconAudioAlbumTrack );
+        }
+    WriteUnicodeL( aStream, iAlbum->Des(), KSconAudioAlbum );
+    WriteUnicodeL( aStream, iGenre->Des(), KSconAudioGenre );
+    WriteUnicodeL( aStream, iComposer->Des(), KSconAudioComposer );
+    WriteUnicodeL( aStream, iComment->Des(), KSconAudioComment );
+
+    if ( iRating > -1 )
+        {
+        WriteUInt16FieldL( aStream, iRating, KSconAudioRating );
+        }
+    WriteUnicodeL( aStream, iMimeType->Des(), KSconAudioMimeType );
+    
+    aStream.WriteUint8L( KSconAudioDate );
+    const TUint KDateTimeSize = 7; // Int16 + 5*Int8 = 2 + 5*1 = 7 bytes
+    aStream.WriteUint32L( KDateTimeSize ); //size
+    
+    TDateTime time = iModifiedTime.DateTime();
+    aStream.WriteInt16L( time.Year() );
+    aStream.WriteInt8L( time.Month()+1 ); // range 1...12
+    aStream.WriteInt8L( time.Day()+1 );
+    aStream.WriteInt8L( time.Hour() );
+    aStream.WriteInt8L( time.Minute() );
+    aStream.WriteInt8L( time.Second() );
+    
+    // filesize
+    WriteUInt32FieldL( aStream, iSize, KSconAudioFileSize );
+    
+    // read album art
+    CMetaDataUtility* metaDataUtil = CMetaDataUtility::NewL();
+    CleanupStack::PushL( metaDataUtil );
+    
+    RArray<TMetaDataFieldId> wantedFields;
+    CleanupClosePushL(wantedFields);
+    wantedFields.AppendL(EMetaDataJpeg);
+    
+    metaDataUtil->OpenFileL(iUri->Des(), wantedFields);
+    
+    const CMetaDataFieldContainer& metaCont = 
+                                    metaDataUtil->MetaDataFieldsL();
+    TPtrC8 data = metaCont.Field8( EMetaDataJpeg );
+    if ( data.Length() > 0 )
+        {
+        WriteDataFieldL( aStream, data, KSconAudioJpeg );
+        }
+    
+    CleanupStack::PopAndDestroy(&wantedFields);
+    CleanupStack::PopAndDestroy(metaDataUtil);
+    
+    aStream.CommitL();
+    TRACE_FUNC_EXIT;
+    }
+
+
+void CSongItem::WriteUnicodeL( RWriteStream& aStream, const TDesC& aData, const TUint8 aFieldId )
+    {
+    aStream.WriteUint8L( aFieldId );
+    aStream.WriteUint32L( aData.Size() );
+    aStream.WriteL( aData, aData.Length() );
+    }
+
+void CSongItem::WriteDataFieldL( RWriteStream& aStream, const TDesC8& aData, const TUint8 aFieldId )
+    {
+    aStream.WriteUint8L( aFieldId );
+    aStream.WriteUint32L( aData.Size() );
+    aStream.WriteL( aData, aData.Length() );
+    }
+
+void CSongItem::WriteUInt16FieldL( RWriteStream& aStream, TUint16 aData, const TUint8 aFieldId )
+    {
+    aStream.WriteUint8L( aFieldId );
+    const TUint KSizeOfUint16 = 2; // =sizeof(TUint16), hardcoded for performance reasons.
+    aStream.WriteUint32L( KSizeOfUint16 );
+    aStream.WriteUint16L( aData );
+    }
+
+void CSongItem::WriteUInt32FieldL( RWriteStream& aStream, TUint32 aData, const TUint8 aFieldId )
+    {
+    aStream.WriteUint8L( aFieldId );
+    const TUint KSizeOfUint32 = 4; // =sizeof(TUint32), hardcoded for performance reasons.
+    aStream.WriteUint32L( KSizeOfUint32 );
+    aStream.WriteUint32L( aData );
+    }
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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for MMS DS adapter
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+./101fb0e9.xml      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/createstub.bat	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Batch file for creating needed stub files.
+rem
+
+makesis -s mmsdsa_stub.pkg
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/group/mmsdataprovider.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  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	Tue Jul 06 14:06:02 2010 +0300
@@ -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,35,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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,130 @@
+/*
+* 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
+    
+    // Define this to enable file logging
+    #define __FLOGGING__
+    
+    #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,"MMS");
+    _LIT(KLogFile,"MMSDataproviderLog.txt");
+    _LIT( KLogFormat, "[MMSDS] %S");
+    
+    _LIT(KTracePrefix16, "[MMSDS] ");
+    _LIT8(KTracePrefix8, "[MMSDS] ");
+    _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
+    
+    
+    // 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 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/mms/inc/mmsadaptermsvapi.h	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,358 @@
+/*
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Part of SyncML Data Synchronization Plug In Adapter
+*
+*/
+
+
+
+#ifndef __MMSDATASTORE_H__
+#define __MMSDATASTORE_H__
+
+// INCLUDES
+#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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  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/sis/backup_registration.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?> 
+<backup_registration>
+    <system_backup />
+    <restore requires_reboot = "no"/>
+</backup_registration> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/sis/mms.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,43 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: PKG file for MMS DS adapter
+
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"MMS DS Plugin"},(0x101FB0E9),1,35,0,TYPE=SA, RU
+;
+
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+
+"\epoc32\data\z\resource\mmsdatastore.rsc"             -"c:\resource\mmsdatastore.rsc"
+"\epoc32\data\z\resource\plugins\mmsdataprovider.rsc"  -"c:\resource\plugins\mmsdataprovider.rsc"
+"\epoc32\release\ARMV5\UREL\mmsdataprovider.dll"       -"c:\sys\bin\mmsdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\101fb0e9.xml"   -"c:\private\101F99F6\import\101fb0e9.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FB0E9\backup_registration.xml"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/sis/mms_debug.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: PKG file for MMS DS adapter
+
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"MMS DS Plugin"},(0x101FB0E9),1,35,0,TYPE=SA, RU
+;
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\mmsdatastore.rsc"             -"c:\resource\mmsdatastore.rsc"
+"\epoc32\data\z\resource\plugins\mmsdataprovider.rsc"  -"c:\resource\plugins\mmsdataprovider.rsc"
+"\epoc32\release\armv5\udeb\mmsdataprovider.dll"       -"c:\sys\bin\mmsdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\101fb0e9.xml"   -"c:\private\101F99F6\import\101fb0e9.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\101FB0E9\backup_registration.xml"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/changefinder.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,313 @@
+/*
+* 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()
+    {
+    TRACE_FUNC;
+    }
+       
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::CMmsAdapterMsvApi
+// -----------------------------------------------------------------------------
+//
+CMmsAdapterMsvApi::CMmsAdapterMsvApi( CMsvSession& aMsvSession ):
+    iSession( aMsvSession )
+    { 
+    }
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CMmsAdapterMsvApi::ConstructL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::DeleteUserFolderL
+// -----------------------------------------------------------------------------
+//
+ TInt CMmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
+    {
+    TRACE_FUNC_ENTRY;
+    
+    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 );
+    TRACE_FUNC_EXIT;
+    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 )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aName: %S", &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();
+    
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMmsAdapterMsvApi::UpdateUserFolderL
+// Updates user folder (changes name)
+// -----------------------------------------------------------------------------    
+TInt CMmsAdapterMsvApi::UpdateUserFolderL( TMsvId aFolder, const TDesC& aName )
+    {
+    TRACE_FUNC_ENTRY;
+    LOGGER_WRITE_1( "aName: %S", &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" );
+        TRACE_FUNC_EXIT;
+        return KErrNotSupported;
+        }
+       
+    tEntry.iDetails.Set( aName );   
+    tEntry.iDescription.Set( aName );
+    
+    entry->ChangeL( tEntry );
+    
+    CleanupStack::PopAndDestroy( entry );
+    
+    TRACE_FUNC_EXIT;
+    return KErrNone;
+    } 
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/mms/src/mmsdataprovider.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -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_WRITE_1( "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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,1787 @@
+/*
+* 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_WRITE_1( "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_WRITE_1( "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_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 != EMmsOpenAndWaiting )
+        {
+        LOGGER_WRITE_1( "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_WRITE_1("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_WRITE_1("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_WRITE_1( "iCodecClient->InitializeChunkedRetrievingL failed with %d",
+                    iMsvWait->iStatus.Int() ); 
+                return;
+                }
+            LOGGER_WRITE_1("iUnread: %d", (TInt)iUnread);
+            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_WRITE_1( "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_WRITE_1( "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_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 != EMmsOpenAndWaiting )
+        {
+        LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("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 );
+            LOGGER_WRITE_1("WriteStatusBits: %d", status);
+            aBuffer.Append( &status, 1 );
+            }
+        else
+            {
+            LOGGER_WRITE("Field update done");
+            User::Leave( KErrEof );             
+            }   
+        }
+        
+    else if ( iCurrentState == EMmsItemOpen )
+        {
+        if ( iReadCounter++ == 0 )
+            {
+            TUint8 status = ResolveStatusBits( iUnread );
+            LOGGER_WRITE_1("WriteStatusBits: %d", status);
+            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_WRITE_1("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_WRITE_1("%d",iWriteCounter);
+    
+    TInt dataLength = aData.Length();
+    LOGGER_WRITE_1("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_WRITE_1("Message status updated, iUnread: %d", iUnread);
+                }    
+            }
+        else
+            {
+            TPtrC8 data = aData.Mid(0);    
+            iDataBuffer->Write( iWrittenDataLength, data );
+            iWrittenDataLength += dataLength;
+            }    
+        }
+        
+    else
+        {
+        LOGGER_WRITE_1("Wrong state %d", iCurrentState);
+        User::Leave( KErrNotReady );
+        }
+        
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("iMsvApi->AddFolderL failed with %d", error);
+                }    
+            }
+         else
+            {
+            error = iMsvApi->UpdateUserFolderL( iCurrentId, name );
+            if ( error != KErrNone )
+                {
+                LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1( "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_WRITE_1("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_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 != EMmsOpenAndWaiting ) 
+        {
+        LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("CMmsCodecClient::DeleteMM failed with %d", error);   
+            return;
+            }
+        // Inform ChangeFinder of the removed item
+        iChangeFinder->ItemDeletedL( aUid );
+        }
+    else
+        {
+        User::RequestComplete( iCallerStatus, KErrNotFound ); 
+        LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("Message item %d:", id);
+        
+        error = iMsvSession->GetEntry( id, service, msg );
+        if ( error != KErrNone )
+            {
+            LOGGER_WRITE_1("GetEntry failed with %d", error);
+            break;
+            }
+        
+        if ( msg.iMtm == KUidMsgTypeMultimedia )
+            {
+            error = iCodecClient->DeleteMM( id );
+            if ( error != KErrNone )
+                {
+                LOGGER_WRITE_1("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_WRITE_1("CMmsDataStore::DoAddedItems, invalid state %d.", iCurrentState);
+        }
+    
+    TInt error(KErrNone);
+
+    // Clear new-items array
+    iNewItems->Reset();
+
+    // Set current snapshot, this will be compared against the old one      
+    // Search for new items
+    TRAP( error, iChangeFinder->FindNewItemsL(*iNewItems) )
+    if ( error != KErrNone )
+        {
+        LOGGER_WRITE_1("CMmsDataStore::DoAddedItems, iChangeFinder->FindNewItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("CMmsDataStore::DoDeletedItems, iChangeFinder->FindDeletedItemsL leaved with %d.", error);
+        }           
+    
+    LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("CMmsDataStore::DoModifiedItems, iChangeFinder->FindChangedItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("CMmsDataStore::DoMovedItems, iChangeFinder->FindMovedItemsL leaved with %d.", error);
+        }
+    
+    LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("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_WRITE_1("iCodecClient->GetNextDataPart failed with %d", error);
+                return error;
+                }
+            else
+                {
+                LOGGER_WRITE_1("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_WRITE_1("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_WRITE_1("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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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_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/mms/src/snapshotitem.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -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/bld.inf	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* 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      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/createstub.bat	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Batch file for creating needed stub files.
+rem
+
+makesis -s smsdsa_stub.pkg
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/group/smsdataprovider.mmp	Tue Jul 06 14:06:02 2010 +0300
@@ -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/smsdsa_stub.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,31 @@
+;
+; Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  SMS plugin pkg-stub file
+;
+; Languages
+&EN
+
+; Header
+#{"SMS DS Plugin"},(0x10206B5C),1,14,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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,133 @@
+/*
+* 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
+    
+    // Define this to enable file logging
+    #define __FLOGGING__
+    
+    #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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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/sis/backup_registration.xml	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?> 
+<backup_registration>
+    <system_backup />
+    <restore requires_reboot = "no"/>
+</backup_registration> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/sis/sms.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: SMS plugin pkg file
+;
+
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"SMS DS Plugin"},(0x10206B5C),1,14,0,TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\smsdatastore.rsc"             -"c:\resource\smsdatastore.rsc"
+"\epoc32\data\z\resource\plugins\smsdataprovider.rsc"  -"c:\resource\plugins\smsdataprovider.rsc"
+"\epoc32\release\armv5\urel\smsdataprovider.dll"       -"c:\sys\bin\smsdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\10206b5c.xml"   -"c:\private\101F99F6\import\10206b5c.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\10206B5C\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/sis/sms_debug.pkg	Tue Jul 06 14:06:02 2010 +0300
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: SMS debug plugin pkg file
+;
+
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia"}
+
+;Language - standard language definitions
+&EN
+
+;package-header
+#{"SMS DS Plugin"},(0x10206B5C),1,14,0,TYPE=SA, RU
+
+; S60 v5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+"\epoc32\data\z\resource\smsdatastore.rsc"             -"c:\resource\smsdatastore.rsc"
+"\epoc32\data\z\resource\plugins\smsdataprovider.rsc"  -"c:\resource\plugins\smsdataprovider.rsc"
+"\epoc32\release\armv5\udeb\smsdataprovider.dll"       -"c:\sys\bin\smsdataprovider.dll"
+
+"\epoc32\data\Z\private\101F99F6\capability\10206b5c.xml"   -"c:\private\101F99F6\import\10206b5c.xml"
+"backup_registration.xml"                                   -"c:\private\10202D56\import\packages\10206B5C\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omads/omadsextensions/adapters/sms/src/changefinder.cpp	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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	Tue Jul 06 14:06:02 2010 +0300
@@ -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