Revision: 201033 RCL_3 PDK_3.0.3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 21:17:03 +0300
branchRCL_3
changeset 31 97232defd20e
parent 30 bd7edf625bdd
Revision: 201033 Kit: 201035
calendarengines/caldav/bwins/CalDavClientu.def
calendarengines/caldav/eabi/CalDavClientu.def
calendarengines/caldav/group/CalDavClient.mmp
calendarengines/caldav/group/CalDavServer.mmp
calendarengines/caldav/group/CalDavTest.mmp
calendarengines/caldav/group/bld.inf
calendarengines/caldav/inc/CalDavTest.h
calendarengines/caldav/inc/caldavclient.h
calendarengines/caldav/inc/caldavengine.h
calendarengines/caldav/inc/caldavenginemgr.h
calendarengines/caldav/inc/caldavserver.h
calendarengines/caldav/inc/caldavserversession.h
calendarengines/caldav/inc/caldavsession.h
calendarengines/caldav/inc/caldavsessionimpl.h
calendarengines/caldav/inc/caldavutils.h
calendarengines/caldav/inc/httpclient.h
calendarengines/caldav/src/caldavclient.cpp
calendarengines/caldav/src/caldavengine.cpp
calendarengines/caldav/src/caldavenginemgr.cpp
calendarengines/caldav/src/caldavserver.cpp
calendarengines/caldav/src/caldavserversession.cpp
calendarengines/caldav/src/caldavsession.cpp
calendarengines/caldav/src/caldavsessionimpl.cpp
calendarengines/caldav/src/caldavutils.cpp
calendarengines/caldav/src/httpclient.cpp
calendarengines/caldav/tsrc/CalDavTest.cpp
calendarengines/group/bld.inf
calendarui/caldav/data/2002B503.rss
calendarui/caldav/data/caldav.loc
calendarui/caldav/data/calencaldavpluginData.rss
calendarui/caldav/group/bld.inf
calendarui/caldav/group/calencaldavplugin.mmp
calendarui/caldav/inc/CalDavUids.h
calendarui/caldav/inc/caldavsettingitems.h
calendarui/caldav/inc/calencaldavplugin.h
calendarui/caldav/sis/caldavplugin.pkg
calendarui/caldav/src/caldavsettingitems.cpp
calendarui/caldav/src/calencaldavplugin.cpp
calendarui/caldav/src/calencaldavpluginProxy.cpp
calendarui/commonutils/bwins/calencommonutilsu.def
calendarui/commonutils/eabi/calencommonutilsu.def
calendarui/commonutils/group/bld.inf
calendarui/commonutils/group/commonutils.mmp
calendarui/commonutils/inc/KoreanCalConv.h
calendarui/commonutils/inc/calenentryutil.h
calendarui/commonutils/inc/calenlocationutil.h
calendarui/commonutils/src/KoreanCalConv.cpp
calendarui/commonutils/src/calenentryutil.cpp
calendarui/commonutils/src/calenlocationutil.cpp
calendarui/controller/src/calenbackgroundstate.cpp
calendarui/controller/src/calencmdlinelauncher.cpp
calendarui/controller/src/calencontroller.cpp
calendarui/controller/src/calenlocationui.cpp
calendarui/controller/src/calennotifier.cpp
calendarui/controller/src/calenviewmanager.cpp
calendarui/customisationmanager/src/calencustomisationmanager.cpp
calendarui/editors/data/CalenDefaultEditorsData.rss
calendarui/editors/group/CalenDefaultEditors.mmp
calendarui/editors/inc/CalenDefaultEditors.h
calendarui/editors/inc/CalenDefaultEditors.hrh
calendarui/editors/inc/CalenEditorDataHandler.h
calendarui/editors/inc/KoreanLunarDateEditor.h
calendarui/editors/inc/KoreanLunarDateEditor.rh
calendarui/editors/inc/KoreanLunarDateUtil.h
calendarui/editors/inc/KoreanLunarTypeField.h
calendarui/editors/inc/calenunifiededitor.h
calendarui/editors/inc/calenunifiededitorcontrol.h
calendarui/editors/src/CalenDefaultEditors.cpp
calendarui/editors/src/CalenEditorDataHandler.cpp
calendarui/editors/src/KoreanLunarDateEditor.cpp
calendarui/editors/src/KoreanLunarDateUtil.cpp
calendarui/editors/src/KoreanLunarTypeField.cpp
calendarui/editors/src/calendbfield.cpp
calendarui/editors/src/calenunifiededitor.cpp
calendarui/editors/src/calenunifiededitorcontrol.cpp
calendarui/globaldata/inc/calencontextimpl.h
calendarui/globaldata/src/calencontextimpl.cpp
calendarui/group/bld.inf
calendarui/inc/CalenUid.h
calendarui/regionalplugins/KoreanLunar/conf/KoreanLunar.confml
calendarui/regionalplugins/KoreanLunar/conf/KoreanLunar_2001843E.crml
calendarui/regionalplugins/KoreanLunar/data/CalenKoreanLunarPlugin.rss
calendarui/regionalplugins/KoreanLunar/data/CalenKoreanLunarPluginData.rss
calendarui/regionalplugins/KoreanLunar/data/KoreanSolarItems
calendarui/regionalplugins/KoreanLunar/group/CalenKoreanLunarPlugin.mmp
calendarui/regionalplugins/KoreanLunar/group/bld.inf
calendarui/regionalplugins/KoreanLunar/inc/CalenExtraRowFormatter.h
calendarui/regionalplugins/KoreanLunar/inc/CalenKoreanLunarPlugin.h
calendarui/regionalplugins/KoreanLunar/inc/CalenKoreanLunarPrivateCRKeys.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarInfo.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarInfoProvider.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarLocalizedInfo.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarLocalizer.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPanic.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPaths.h
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPluginUids.hrh
calendarui/regionalplugins/KoreanLunar/inc/CalenLunarSettingItem.h
calendarui/regionalplugins/KoreanLunar/inc/CalenSolarTerms.h
calendarui/regionalplugins/KoreanLunar/loc/calenkoreanlunar.loc
calendarui/regionalplugins/KoreanLunar/rom/KoreanCalPlugin.iby
calendarui/regionalplugins/KoreanLunar/src/CalenExtraRowFormatter.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenKoreanLunarPlugin.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarInfo.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarInfoProvider.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarLocalizedInfo.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarLocalizer.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarPluginProxy.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenLunarSettingItem.cpp
calendarui/regionalplugins/KoreanLunar/src/CalenSolarTerms.cpp
calendarui/rom/caldav.iby
calendarui/server/CalenSvr/src/CalenServer.cpp
calendarui/settings/settingsui/src/calensettingsuicontainer.cpp
calendarui/views/inc/caleneventviewcontainer.h
calendarui/views/inc/calennativeview.h
calendarui/views/src/calendaycontainer.cpp
calendarui/views/src/calendayview.cpp
calendarui/views/src/caleneventview.cpp
calendarui/views/src/caleneventviewcontainer.cpp
calendarui/views/src/calenmissedalarmscontainer.cpp
calendarui/views/src/calenmissedalarmsview.cpp
calendarui/views/src/calenmissedeventcontainer.cpp
calendarui/views/src/calenmissedeventview.cpp
calendarui/views/src/calenmonthcontainer.cpp
calendarui/views/src/calennativeview.cpp
calendarui/views/src/calentodocontainer.cpp
calendarui/views/src/calentodoview.cpp
calendarui/views/src/calenweekcontainer.cpp
clock2/clockengines/clocktimesourceinterface/group/clocktimesourceinterface.mmp
clock2/clockengines/clocktimezoneresolver/group/clocktimezoneresolver.mmp
clock2/clockui/adtupdater/group/adtupdater.mmp
clock2/clockui/uilayer/clockworldview/src/clockworldview.cpp
clock2/clockui/utilities/data/mcc.rss
organizer_plat/calendar_common_utils_api/group/bld.inf
organizer_plat/calendar_common_utils_api/inc/calenlocationutil.h
organizer_plat/calendar_custamization_api/inc/calencontext.h
organizer_plat/calendar_custamization_api/inc/calennotificationhandler.h
pimappservices/calendar/bwins/agnmodelv3u.def
pimappservices/calendar/bwins/calinterimapiv3u.def
pimappservices/calendar/client/inc/calentryimpl.h
pimappservices/calendar/client/src/calentry.cpp
pimappservices/calendar/client/src/calentryimpl.cpp
pimappservices/calendar/eabi/agnmodelv3u.def
pimappservices/calendar/eabi/calinterimapiv3u.def
pimappservices/calendar/inc/calentry.h
pimappservices/calendar/server/inc/agsbackuprestoreagent.h
pimappservices/calendar/server/inc/agsmain.h
pimappservices/calendar/server/src/agsattachmentindex.cpp
pimappservices/calendar/server/src/agsbackuprestoreagent.cpp
pimappservices/calendar/server/src/agsmain.cpp
pimappservices/calendar/server/src/agssess.cpp
pimappservices/calendar/shared/inc/agmentry.h
pimappservices/calendar/shared/src/agmentry.cpp
pimappservices/calendar/tsrc/T_VCAL2.CPP
pimappservices/calendarvcalplugin/src/agmvcali.cpp
pimappservices/calendarvcalplugin/src/agmvcalx.cpp
pimappsupport/vcardandvcal/inc/VTOKEN.H
pimappsupport/vcardandvcal/src/VCAL.CPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/bwins/CalDavClientu.def	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,45 @@
+EXPORTS
+	?SetPastDays@RCalDavServer@@QAEHABVTDesC16@@VTTimeIntervalDays@@@Z @ 1 NONAME ; int RCalDavServer::SetPastDays(class TDesC16 const &, class TTimeIntervalDays)
+	??1CCalDavSession@@UAE@XZ @ 2 NONAME ; CCalDavSession::~CCalDavSession(void)
+	?EnabledSync@RCalDavServer@@QAEHABVTDesC16@@AAH@Z @ 3 NONAME ; int RCalDavServer::EnabledSync(class TDesC16 const &, int &)
+	?SyncInterval@RCalDavServer@@QAEHABVTDesC16@@AAVTTimeIntervalMinutes@@@Z @ 4 NONAME ; int RCalDavServer::SyncInterval(class TDesC16 const &, class TTimeIntervalMinutes &)
+	?Disable@RCalDavServer@@QAEHABVTDesC16@@@Z @ 5 NONAME ; int RCalDavServer::Disable(class TDesC16 const &)
+	?SyncAllL@CCalDavSession@@QAEHXZ @ 6 NONAME ; int CCalDavSession::SyncAllL(void)
+	?SetUsername@CCalDavSession@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 7 NONAME ; int CCalDavSession::SetUsername(class TDesC16 const &, class TDesC8 const &)
+	?PastDays@RCalDavServer@@QAEHABVTDesC16@@AAVTTimeIntervalDays@@@Z @ 8 NONAME ; int RCalDavServer::PastDays(class TDesC16 const &, class TTimeIntervalDays &)
+	?SetUrl@RCalDavServer@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 9 NONAME ; int RCalDavServer::SetUrl(class TDesC16 const &, class TDesC8 const &)
+	?Url@RCalDavServer@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 10 NONAME ; int RCalDavServer::Url(class TDesC16 const &, class TDes8 &)
+	?Sync@RCalDavServer@@QAEHABVTDesC16@@@Z @ 11 NONAME ; int RCalDavServer::Sync(class TDesC16 const &)
+	?EnabledSync@CCalDavSession@@QAEHABVTDesC16@@AAH@Z @ 12 NONAME ; int CCalDavSession::EnabledSync(class TDesC16 const &, int &)
+	?ImmediateSync@RCalDavServer@@QAEHABVTDesC16@@AAH@Z @ 13 NONAME ; int RCalDavServer::ImmediateSync(class TDesC16 const &, int &)
+	?Connect@RCalDavServer@@QAEHXZ @ 14 NONAME ; int RCalDavServer::Connect(void)
+	?Password@RCalDavServer@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 15 NONAME ; int RCalDavServer::Password(class TDesC16 const &, class TDes8 &)
+	?SyncAll@RCalDavServer@@QAEHXZ @ 16 NONAME ; int RCalDavServer::SyncAll(void)
+	?SetPastDays@CCalDavSession@@QAEHABVTDesC16@@VTTimeIntervalDays@@@Z @ 17 NONAME ; int CCalDavSession::SetPastDays(class TDesC16 const &, class TTimeIntervalDays)
+	?NewLC@CCalDavSession@@SAPAV1@XZ @ 18 NONAME ; class CCalDavSession * CCalDavSession::NewLC(void)
+	?SetUrl@CCalDavSession@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 19 NONAME ; int CCalDavSession::SetUrl(class TDesC16 const &, class TDesC8 const &)
+	?SetImmediateSync@CCalDavSession@@QAEHABVTDesC16@@H@Z @ 20 NONAME ; int CCalDavSession::SetImmediateSync(class TDesC16 const &, int)
+	?SetSyncInterval@CCalDavSession@@QAEHABVTDesC16@@VTTimeIntervalMinutes@@@Z @ 21 NONAME ; int CCalDavSession::SetSyncInterval(class TDesC16 const &, class TTimeIntervalMinutes)
+	?Disable@CCalDavSession@@QAEHABVTDesC16@@@Z @ 22 NONAME ; int CCalDavSession::Disable(class TDesC16 const &)
+	??0RCalDavServer@@QAE@XZ @ 23 NONAME ; RCalDavServer::RCalDavServer(void)
+	?SyncL@CCalDavSession@@QAEHABVTDesC16@@@Z @ 24 NONAME ; int CCalDavSession::SyncL(class TDesC16 const &)
+	?Username@RCalDavServer@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 25 NONAME ; int RCalDavServer::Username(class TDesC16 const &, class TDes8 &)
+	?Enable@CCalDavSession@@QAEHABVTDesC16@@@Z @ 26 NONAME ; int CCalDavSession::Enable(class TDesC16 const &)
+	?SetUsername@RCalDavServer@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 27 NONAME ; int RCalDavServer::SetUsername(class TDesC16 const &, class TDesC8 const &)
+	?KeepServerEntry@RCalDavServer@@QAEHABVTDesC16@@AAH@Z @ 28 NONAME ; int RCalDavServer::KeepServerEntry(class TDesC16 const &, int &)
+	?SetPassword@RCalDavServer@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 29 NONAME ; int RCalDavServer::SetPassword(class TDesC16 const &, class TDesC8 const &)
+	?PastDays@CCalDavSession@@QAEHABVTDesC16@@AAVTTimeIntervalDays@@@Z @ 30 NONAME ; int CCalDavSession::PastDays(class TDesC16 const &, class TTimeIntervalDays &)
+	?SetKeepServerEntry@CCalDavSession@@QAEHABVTDesC16@@H@Z @ 31 NONAME ; int CCalDavSession::SetKeepServerEntry(class TDesC16 const &, int)
+	?SetKeepServerEntry@RCalDavServer@@QAEHABVTDesC16@@H@Z @ 32 NONAME ; int RCalDavServer::SetKeepServerEntry(class TDesC16 const &, int)
+	?NewL@CCalDavSession@@SAPAV1@XZ @ 33 NONAME ; class CCalDavSession * CCalDavSession::NewL(void)
+	?Url@CCalDavSession@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 34 NONAME ; int CCalDavSession::Url(class TDesC16 const &, class TDes8 &)
+	?SetSyncInterval@RCalDavServer@@QAEHABVTDesC16@@VTTimeIntervalMinutes@@@Z @ 35 NONAME ; int RCalDavServer::SetSyncInterval(class TDesC16 const &, class TTimeIntervalMinutes)
+	?Username@CCalDavSession@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 36 NONAME ; int CCalDavSession::Username(class TDesC16 const &, class TDes8 &)
+	?Password@CCalDavSession@@QAEHABVTDesC16@@AAVTDes8@@@Z @ 37 NONAME ; int CCalDavSession::Password(class TDesC16 const &, class TDes8 &)
+	?Enable@RCalDavServer@@QAEHABVTDesC16@@@Z @ 38 NONAME ; int RCalDavServer::Enable(class TDesC16 const &)
+	?SyncInterval@CCalDavSession@@QAEHABVTDesC16@@AAVTTimeIntervalMinutes@@@Z @ 39 NONAME ; int CCalDavSession::SyncInterval(class TDesC16 const &, class TTimeIntervalMinutes &)
+	?KeepServerEntry@CCalDavSession@@QAEHABVTDesC16@@AAH@Z @ 40 NONAME ; int CCalDavSession::KeepServerEntry(class TDesC16 const &, int &)
+	?SetImmediateSync@RCalDavServer@@QAEHABVTDesC16@@H@Z @ 41 NONAME ; int RCalDavServer::SetImmediateSync(class TDesC16 const &, int)
+	?ImmediateSync@CCalDavSession@@QAEHABVTDesC16@@AAH@Z @ 42 NONAME ; int CCalDavSession::ImmediateSync(class TDesC16 const &, int &)
+	?SetPassword@CCalDavSession@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 43 NONAME ; int CCalDavSession::SetPassword(class TDesC16 const &, class TDesC8 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/eabi/CalDavClientu.def	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,52 @@
+EXPORTS
+	_ZN13RCalDavServer11EnabledSyncERK7TDesC16Ri @ 1 NONAME
+	_ZN13RCalDavServer11SetPasswordERK7TDesC16RK6TDesC8 @ 2 NONAME
+	_ZN13RCalDavServer11SetPastDaysERK7TDesC1617TTimeIntervalDays @ 3 NONAME
+	_ZN13RCalDavServer11SetUsernameERK7TDesC16RK6TDesC8 @ 4 NONAME
+	_ZN13RCalDavServer12SyncIntervalERK7TDesC16R20TTimeIntervalMinutes @ 5 NONAME
+	_ZN13RCalDavServer13ImmediateSyncERK7TDesC16Ri @ 6 NONAME
+	_ZN13RCalDavServer15KeepServerEntryERK7TDesC16Ri @ 7 NONAME
+	_ZN13RCalDavServer15SetSyncIntervalERK7TDesC1620TTimeIntervalMinutes @ 8 NONAME
+	_ZN13RCalDavServer16SetImmediateSyncERK7TDesC16i @ 9 NONAME
+	_ZN13RCalDavServer18SetKeepServerEntryERK7TDesC16i @ 10 NONAME
+	_ZN13RCalDavServer3UrlERK7TDesC16R5TDes8 @ 11 NONAME
+	_ZN13RCalDavServer4SyncERK7TDesC16 @ 12 NONAME
+	_ZN13RCalDavServer6EnableERK7TDesC16 @ 13 NONAME
+	_ZN13RCalDavServer6SetUrlERK7TDesC16RK6TDesC8 @ 14 NONAME
+	_ZN13RCalDavServer7ConnectEv @ 15 NONAME
+	_ZN13RCalDavServer7DisableERK7TDesC16 @ 16 NONAME
+	_ZN13RCalDavServer7SyncAllEv @ 17 NONAME
+	_ZN13RCalDavServer8PasswordERK7TDesC16R5TDes8 @ 18 NONAME
+	_ZN13RCalDavServer8PastDaysERK7TDesC16R17TTimeIntervalDays @ 19 NONAME
+	_ZN13RCalDavServer8UsernameERK7TDesC16R5TDes8 @ 20 NONAME
+	_ZN13RCalDavServerC1Ev @ 21 NONAME
+	_ZN13RCalDavServerC2Ev @ 22 NONAME
+	_ZN14CCalDavSession11EnabledSyncERK7TDesC16Ri @ 23 NONAME
+	_ZN14CCalDavSession11SetPasswordERK7TDesC16RK6TDesC8 @ 24 NONAME
+	_ZN14CCalDavSession11SetPastDaysERK7TDesC1617TTimeIntervalDays @ 25 NONAME
+	_ZN14CCalDavSession11SetUsernameERK7TDesC16RK6TDesC8 @ 26 NONAME
+	_ZN14CCalDavSession12SyncIntervalERK7TDesC16R20TTimeIntervalMinutes @ 27 NONAME
+	_ZN14CCalDavSession13ImmediateSyncERK7TDesC16Ri @ 28 NONAME
+	_ZN14CCalDavSession15KeepServerEntryERK7TDesC16Ri @ 29 NONAME
+	_ZN14CCalDavSession15SetSyncIntervalERK7TDesC1620TTimeIntervalMinutes @ 30 NONAME
+	_ZN14CCalDavSession16SetImmediateSyncERK7TDesC16i @ 31 NONAME
+	_ZN14CCalDavSession18SetKeepServerEntryERK7TDesC16i @ 32 NONAME
+	_ZN14CCalDavSession3UrlERK7TDesC16R5TDes8 @ 33 NONAME
+	_ZN14CCalDavSession4NewLEv @ 34 NONAME
+	_ZN14CCalDavSession5NewLCEv @ 35 NONAME
+	_ZN14CCalDavSession5SyncLERK7TDesC16 @ 36 NONAME
+	_ZN14CCalDavSession6EnableERK7TDesC16 @ 37 NONAME
+	_ZN14CCalDavSession6SetUrlERK7TDesC16RK6TDesC8 @ 38 NONAME
+	_ZN14CCalDavSession7DisableERK7TDesC16 @ 39 NONAME
+	_ZN14CCalDavSession8PasswordERK7TDesC16R5TDes8 @ 40 NONAME
+	_ZN14CCalDavSession8PastDaysERK7TDesC16R17TTimeIntervalDays @ 41 NONAME
+	_ZN14CCalDavSession8SyncAllLEv @ 42 NONAME
+	_ZN14CCalDavSession8UsernameERK7TDesC16R5TDes8 @ 43 NONAME
+	_ZN14CCalDavSessionD0Ev @ 44 NONAME
+	_ZN14CCalDavSessionD1Ev @ 45 NONAME
+	_ZN14CCalDavSessionD2Ev @ 46 NONAME
+	_ZTI11CalDavUtils @ 47 NONAME
+	_ZTI18CCalDavSessionImpl @ 48 NONAME
+	_ZTV11CalDavUtils @ 49 NONAME
+	_ZTV18CCalDavSessionImpl @ 50 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/group/CalDavClient.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: This is the project specification file for the
+*				Caldav client library
+*/
+
+TARGET        CalDavClient.dll
+TARGETTYPE    dll
+UID 0 0x2002B71F
+
+SOURCEPATH    ..\src
+SOURCE        CalDavClient.cpp caldavsession.cpp caldavsessionimpl.cpp caldavutils.cpp
+
+USERINCLUDE   ..\inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY       euser.lib
+LIBRARY       bafl.lib
+LIBRARY http.lib	
+
+//EXPORTUNFROZEN
+
+CAPABILITY	CAP_APPLICATION NetworkControl
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/group/CalDavServer.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: This is the project specification file for the
+*				Caldav server
+*/ 
+
+TARGET        !CalDavServer.exe
+TARGETTYPE    exe
+UID           0	0x2002B71E
+
+SOURCEPATH    ../src
+SOURCE        CalDavServer.cpp caldavutils.cpp httpclient.cpp CalDavServerSession.cpp caldavengine.cpp caldavenginemgr.cpp
+
+USERINCLUDE   ../inc
+USERINCLUDE   ../../../calendarui/globaldata/inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY			euser.lib apparc.lib cone.lib eikcore.lib avkon.lib charconv.lib
+LIBRARY			commonengine.lib efsrv.lib estor.lib eikcoctl.lib eikdlg.lib 
+LIBRARY			eikctl.lib bafl.lib fbscli.lib aknnotify.lib aknicon.lib
+LIBRARY			etext.lib gdi.lib egul.lib insock.lib
+LIBRARY			ecom.lib InetProtUtil.lib http.lib esock.lib xmlengineDOM.lib calinterimapi.lib calenimp.lib CalenInterimUtils2.lib commdb.lib calenglobaldata.lib
+LIBRARY			extendedconnpref.lib netmeta.lib
+
+EPOCHEAPSIZE        0x5000 0x400000
+EPOCSTACKSIZE        0x5000
+
+CAPABILITY ReadDeviceData ReadUserData WriteDeviceData WriteUserData ProtServ NetworkServices
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/group/CalDavTest.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: This is the project specification file for the
+*				Caldav test application
+*/
+
+TARGET		  CalDavTest.exe
+TARGETTYPE	  exe
+UID			 0 0x2002B81C
+
+USERINCLUDE	 ..\inc
+USERINCLUDE   ..\..\..\calendarui\globaldata\inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH	  	..\src
+SOURCE			caldavengine.cpp httpclient.cpp caldavutils.cpp
+
+SOURCEPATH	  	..\tsrc
+SOURCE			CalDavTest.cpp
+
+LIBRARY			euser.lib apparc.lib cone.lib eikcore.lib avkon.lib charconv.lib
+LIBRARY			commonengine.lib efsrv.lib estor.lib eikcoctl.lib eikdlg.lib 
+LIBRARY			eikctl.lib bafl.lib fbscli.lib aknnotify.lib aknicon.lib
+LIBRARY			etext.lib gdi.lib egul.lib insock.lib
+LIBRARY			ecom.lib InetProtUtil.lib http.lib esock.lib xmlengineDOM.lib calinterimapi.lib calenimp.lib CalenInterimUtils2.lib commdb.lib flogger.lib 
+LIBRARY			caldavclient.lib
+LIBRARY			calenglobaldata.lib
+LIBRARY			extendedconnpref.lib netmeta.lib
+
+EPOCHEAPSIZE        0x5000 0x400000
+EPOCSTACKSIZE        0x5000
+
+CAPABILITY NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides the information required for building
+*				caldav engine
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+CalDavClient.mmp
+CalDavServer.mmp
+
+PRJ_TESTMMPFILES
+CalDavTest.mmp
+
+PRJ_EXPORTS
+../inc/caldavsession.h  |../../../inc/caldavsession.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/CalDavTest.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav Test Suite
+*
+*/
+
+#ifndef __CALDAVTEST_H__
+#define __CALDAVTEST_H__
+
+//  Include Files
+
+#include <e32base.h>
+#include <e32cons.h>			// Console
+#include <flogger.h>	
+
+class CCalDavEngine;
+class CCalDavSession;
+
+class CalDavTest
+	{
+public:
+	CalDavTest(CConsoleBase* console);
+	~CalDavTest();
+
+	void TestGeneralEngineL();
+	void TestEngineL(TInt aSucces, const TDesC8 &aUrl, const TDesC8 &aUser,
+			const TDesC8 &aPassword, TBool aWebdavsync, TBool aCtag,
+			TBool aEvent, TBool aTodo, TBool aFreeBusy, TBool aJournal);
+	void TestClientServerL(TInt aSucces, const TDesC8 &aUrl,
+			const TDesC8 &aUser, const TDesC8 &aPassword);
+private:
+	// test client server
+
+	TInt ConfigureSessionL(TInt aSucces, const TDesC8 &aUrl,
+			const TDesC8 &aUser, const TDesC8 &aPassword);
+	void OptionSession();
+
+	void Enabled(TBool aEnabled);
+
+	// test engine
+	TInt EnableL(TInt aSucces, const TDesC8 &aUrl, const TDesC8 &aUser,
+			const TDesC8 &aPassword);
+	// use caldav engine
+	void SendL(const unsigned long localuid);
+	// use http call
+	void SendL(TBool aVEvent);
+
+	void DownloadLGetL(const unsigned long localuid);
+	void DownloadLMultiGetL(const unsigned long localuid);
+
+	// use http call
+	void DeleteServerL();
+	// use caldav engine
+	void DeleteServerL(const unsigned long localuid);
+	void DeleteClientL(const TDesC8 &aUid);
+
+	void HeadL(TBool aExists, const TDesC8 &aUid);
+	void OptionsL();
+	void SyncL();
+	void DoesExistL(TBool aExists, const unsigned long localuid);
+	void DoesExistL(TBool aExists, const TDesC8 &aUID);
+	void CTagL(TBool aEqual);
+	void SynctokenL(TBool aEqual);
+
+	void MkCalendarL(TBool aSuccess, const TDesC8 &aName);
+	void DeleteCalendarL(const TDesC8 &aName);
+
+	void CalendarInfoL();
+	void GetUIDByUrl();
+	void GetBaseUrl();
+
+	void Write(const TDesC &aMessage);
+	void Write(TBool aSuccess, const char* aMessage);
+	void Write(TBool aSuccess, const TDesC &aMessage);
+
+	TBool iWebdavSync;
+	TBool iCtag;
+
+	TBool iVEVENT;
+	TBool iVTODO;
+	TBool iVJOURNAL;
+	TBool iVFREEBUSY;
+
+	CCalDavEngine* iEngine;
+	CCalDavSession* iSession;
+	CConsoleBase* iConsole;
+	RFileLogger iFileLogger;
+	};
+
+GLDEF_C TInt E32Main();
+
+#endif  // __CALDAVTEST_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavclient.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides a client API for Caldav server
+*
+*/
+
+#ifndef _CALDAVCLIENT_H
+#define _CALDAVCLIENT_H
+
+#include <e32base.h>
+
+//**********************************
+//RCalDavServer
+//**********************************
+
+static TInt StartServer();
+
+class RCalDavServer : public RSessionBase
+	{
+public:
+    IMPORT_C RCalDavServer();
+    IMPORT_C TInt Connect();
+
+    IMPORT_C TInt Enable(const TDesC &aCalendar);
+    IMPORT_C TInt Disable(const TDesC &aCalendar);
+
+    IMPORT_C TInt EnabledSync(const TDesC &aCalendar, TBool &aEnabled);
+
+    IMPORT_C TInt Sync(const TDesC &aCalendar);
+    IMPORT_C TInt SyncAll();
+
+    IMPORT_C TInt Url(const TDesC &aCalendar, TDes8 &aUrl);
+    IMPORT_C TInt SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl);
+
+    IMPORT_C TInt Username(const TDesC &aCalendar, TDes8 &aUsername);
+    IMPORT_C TInt SetUsername(const TDesC &aCalendar, const TDesC8 &aUsername);
+
+    IMPORT_C TInt Password(const TDesC &aCalendar, TDes8 &aPassword);
+    IMPORT_C TInt SetPassword(const TDesC &aCalendar, const TDesC8 &aPassword);
+
+    IMPORT_C TInt SyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes& aSyncInterval);
+    IMPORT_C TInt SetSyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes aSyncInterval);
+
+    IMPORT_C TInt PastDays(const TDesC &aCalendar, TTimeIntervalDays &aDays);
+    IMPORT_C TInt SetPastDays(const TDesC &aCalendar, TTimeIntervalDays aDays);
+
+    IMPORT_C TInt ImmediateSync(const TDesC &aCalendar, TBool &aImmediateSyc);
+    IMPORT_C TInt SetImmediateSync(const TDesC &aCalendar, TBool aImmediateSyc);
+
+    IMPORT_C TInt KeepServerEntry(const TDesC &aCalendar, TBool &aKeepServerEntry);
+    IMPORT_C TInt SetKeepServerEntry(const TDesC &aCalendar, TBool aKeepServerEntry);
+
+	TVersion Version() const;
+	TInt UnsupportedRequest();
+	void BadRequest();
+
+private:
+	};
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavengine.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: main Caldav class, all magic happens here
+*
+*/
+
+#ifndef _CALSTORE_H
+#define _CALSTORE_H
+
+#include <e32base.h>
+#include <BADESCA.H>
+
+#include <calchangecallback.h>
+#include <calprogresscallback.h>
+#include <calfilechangenotification.h>
+
+#include <xmlengdomimplementation.h>
+#include <xmlengdomparser.h>
+
+#include "caldavutils.h"
+
+class CCalSession;
+class CCalEntry;
+class CCalIter;
+class CCalEntryView;
+class CCalenExporter;
+class CCalenImporter;
+class CCalenInterimUtils2;
+
+class RXmlEngDOMImplementation;
+class RXmlEngDOMParser;
+class RXmlEngDocument;
+
+class CHttpClient;
+class CalDavTest;
+
+// sync interval of 0 correspons to one minute
+// 0 actually means to enable push connectivity once supported
+#define DEFAULT_SYNC_MINUTES 		0
+#define DEFAULT_PAST_DAYS			14
+#define DEFAULT_IMMEDIATE_SYNC		ETrue
+#define DEFAULT_KEEP_SERVER_ENTRY	EFalse
+
+
+enum TLocalLoopAction
+	{
+		ELoopActionUpload, ELoopActionFillArray, ELoopActionDeleteLocal
+	};
+
+/**
+ *  CCalDavEngine
+ * 
+ */
+class CCalDavEngine : public CBase, MCalProgressCallBack, MCalChangeCallBack2, MCalFileChangeObserver
+	{
+public:
+
+	friend class CalDavTest;
+
+	~CCalDavEngine();
+
+	static CCalDavEngine* NewL(const TDesC& aCalendar);
+	static CCalDavEngine* NewLC(const TDesC& aCalendar);
+
+	TInt EnableL();
+	void DisableL();
+	TBool EnabledSync();
+
+	TInt SyncL();
+
+	TInt MkcalendarL(const TDesC8 &aName);
+	TInt DeleteCalendarL(const TDesC8 &aName);
+
+	TPtrC CalendarName() const;
+	TPtrC8 Home() const;
+
+	TPtrC8 Url() const;
+	void SetUrlL(const TDesC8 &aUrl);
+
+	TPtrC8 User() const;
+	void SetUserL(const TDesC8 &aUser);
+
+	TPtrC8 Password() const;
+	void SetPasswordL(const TDesC8 &aPassword);
+
+	TTimeIntervalMinutes SyncInterval() const;
+	void SetSyncIntervalL(TTimeIntervalMinutes aSyncInterval);
+
+	TTimeIntervalDays PastDays() const;
+	void SetPastDaysL(TTimeIntervalDays aDays);
+
+	TBool ImmediateSync() const;
+	void SetImmediateSyncL(TBool aImmediateSyc);
+
+	TBool KeepServerEntry() const;
+	void SetKeepServerEntryL(TBool aKeepServerEntry);
+
+	CPeriodic* Timer();
+
+	TPtrC8 SyncToken();
+	TPtrC8 CTag();
+
+private:
+
+	CCalDavEngine();
+	void ConstructL(const TDesC& aCalendar);
+
+	void RegisterL();
+	HBufC8* GetCTagL();
+	HBufC8* GetSyncTokenL();
+
+	TInt InitL();
+
+	// Called during calendar entry view creation
+	void Progress(TInt aPercentageCompleted);
+	void Completed(TInt aError);
+	TBool NotifyProgress();
+	void CalChangeNotification(RArray<TCalChangeEntry> &aChangeItems);
+	void CalendarInfoChangeNotificationL(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries);
+
+	void CalendarInfoL();
+	void SetCalendarInfoL(const TDesC8 &aKey, const TDesC8 &aValue);
+
+	void HandleCalendarInfoChangeL();
+	void HandleChangeL(MCalChangeCallBack2::TChangeType &aChangeType,
+			MCalChangeCallBack2::TChangeEntryType &aEntryType,
+			TCalLocalUid &aUid);
+
+	TBool ManualSyncL();
+	TBool WebDavSyncL();
+	TInt WebDavSyncReportL(TBool aSynctoken);
+	TBool UploadModifiedSinceDateL();
+	TBool ClientChangesL();
+	TBool ServerChangesL();
+	TInt DeleteRemovedEntriesOnServerL();
+	TInt LocalLoopL(TLocalLoopAction aAction);
+	
+	TInt ListL();
+	TInt TimeReportL(TBool VEVENT, const TDesC8 &aStart, TBool aDelete = EFalse);
+
+	// server actions
+	TInt UploadEntryL(const TCalLocalUid &aUid,
+			MCalChangeCallBack2::TChangeType aChangeType,
+			MCalChangeCallBack2::TChangeEntryType aEntryType);
+	TInt UploadEntryL(CCalEntry* aEntry,
+			MCalChangeCallBack2::TChangeType aChangeType,
+			MCalChangeCallBack2::TChangeEntryType aEntryType);
+	TInt DownloadEntryL(const TDesC8 &aUrl);
+	TInt DownloadEntryL(CDesC8Array* aArray);
+	TInt DeleteEntryL(const TCalLocalUid &aUid);
+	TInt DeleteEntryL(const TDesC8 &aUid);
+	TInt HeadL(const TDesC8 &aUID);
+
+	// local actions
+	TInt AddModifyLocalEntryL(const TDesC8 &aUrl, const TDesC8 &aETag,
+			CDesC8ArrayFlat* aArray);
+	TInt DeleteLocalEntryL(const TDesC8 &aUID);
+
+	TInt ParseResponsesDeleteL(const TDesC8 &aDocument);
+	TInt ParseResponsesL(RXmlEngDocument &aDocument, TBool aMultiget = EFalse);
+	TInt ParseResponsesL(const TDesC8 &aDocument, TBool aMultiget = EFalse);
+	
+	unsigned long DoesEntryExistL(const TDesC8 &aUrl);
+	TPtrC8 GetUIDByUrl(const TDesC8 &aUrl);
+	TBool ETagMatchL(const TDesC8& aUrl, const TDesC8& aETag);
+	TInt StoreEntryL(const TDesC8 &aBuf, const TDesC8 &aEtag);
+
+	void SyncFailedL();
+	void SetLastSyncTimeL();
+	void SetSyncTokenL(HBufC8* aToken);
+	void SetCTagL(HBufC8* aToken);
+
+	void CheckCalendarInfoL(RXmlEngDocument &aDocument);
+	
+	TBool GetOptionsL();
+	TInt GetCalendarUrlsL(CDesC8ArrayFlat *aArray);
+	void FindUrlsL(const TDesC8 &aDes, HBufC8 *&home, HBufC8 *&inbox,
+			HBufC8 *&outbox);
+	void GetBaseUrl(const TDesC8 &aUrl);
+	HBufC8 * FindCalendarCollectionL(const TDesC8 &aUrl,
+			CDesC8ArrayFlat *aArray);
+	
+	void DeleteCalObjects();
+	TInt CreateCalObjectsL();
+	
+	CCalSession* iCalSession;
+	CCalIter* iCalIter;
+	CCalEntryView* iCalEntryView;
+	CCalenExporter* iCalExporter;
+	CCalenImporter* iCalImporter;
+	CCalenInterimUtils2* iCalIntermimUtils2;
+	HBufC *iCalendar;
+	HBufC8 *iUrl;
+	HBufC8 *iBaseUrl;
+	HBufC8 *iHome;
+
+	TCalDAVOptions iOptions;
+	CHttpClient* iHttp;
+
+	RXmlEngDOMImplementation iDomImpl;
+	RXmlEngDOMParser iDomParser;
+
+	// when we get a callback with a localuid, the corresponding entry is already deleted
+	// we therefore need a different way to map from localuid to global uid/filename
+	// this can be completly removed when introducing a new callback,
+	// which includes the to be deleted localuid
+	RArray<TCalLocalUid> iLocalUidArray;
+	RArray<TBuf8<100> > iGlobalUidArray;
+	//
+	RArray<TCalLocalUid> iDeletedEntries;
+
+	HBufC8 *iSynctoken;
+	HBufC8 *iCTag;
+	TBool iManualSync;
+	TCalTime iLastSyncTime;
+	TBool iFirstInit;
+
+	// Options
+	TTimeIntervalMinutes iSyncInterval;
+	TTimeIntervalDays iPastDays;
+	TBool iImmediateSync;
+	TBool iKeepServerEntry;
+	TBool iEnabled;
+
+	CPeriodic* iTimer;
+	};
+
+#endif // CALSTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavenginemgr.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides a manager to keep track of all available engines
+*
+*/
+
+#ifndef CCALDAVENGINEMGR_H
+#define CCALDAVENGINEMGR_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include <calprogresscallback.h>
+
+class CCalDavEngine;
+/**
+ *  CCalDavEngineMgr
+ * 
+ */
+class CCalDavEngineMgr : public CBase, MCalProgressCallBack
+	{
+public:
+
+	~CCalDavEngineMgr();
+
+	static CCalDavEngineMgr* NewL();
+	static CCalDavEngineMgr* NewLC();
+	
+	void Progress(TInt aPercentageCompleted);
+	void Completed(TInt aError);
+	TBool NotifyProgress();
+
+	TInt SyncL(const TDesC &aCalendar);
+	TInt SyncAllL();
+
+	TInt EnableL(const TDesC &aCalendar);
+	TInt DisableL(const TDesC &aCalendar);
+
+	TBool EnabledSyncL(const TDesC &aCalendar);
+
+	TPtrC8 UrlL(const TDesC &aCalendar);
+	void SetUrlL(const TDesC &aCalendar, const TDesC8 &aUrl);
+
+	TPtrC8 UsernameL(const TDesC &aCalendar);
+	void SetUsernameL(const TDesC &aCalendar, const TDesC8 &aUsername);
+
+	TPtrC8 PasswordL(const TDesC &aCalendar);
+	void SetPasswordL(const TDesC &aCalendar, const TDesC8 &aPassword);
+
+	// TODO do also if enable was not called yet? if yes, create CalDavEngine and store settings
+	TTimeIntervalMinutes SyncIntervalL(const TDesC &aCalendar);
+	void SetSyncIntervalL(const TDesC &aCalendar,
+			TTimeIntervalMinutes aSyncInterval);
+
+	TTimeIntervalDays PastDaysL(const TDesC &aCalendar);
+	void SetPastDaysL(const TDesC &aCalendar, TTimeIntervalDays aDays);
+
+	TBool ImmediateSyncL(const TDesC &aCalendar);
+	void SetImmediateSyncL(const TDesC &aCalendar, TBool aImmediateSyc);
+
+	TBool KeepServerEntryL(const TDesC &aCalendar);
+	void SetKeepServerEntryL(const TDesC &aCalendar, TBool aKeepServerEntry);
+
+private:
+
+	CCalDavEngineMgr();
+	void ConstructL();
+
+	TInt FindEngineL(const TDesC &aName, TBool aCreate = EFalse);
+	RPointerArray<CCalDavEngine> iEngines;
+
+	};
+
+#endif // CCALDAVENGINEMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavserver.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav server, follows Symbian client/server 
+*				architecture
+*/
+
+#ifndef CCALDAVSERVER_H
+#define CCALDAVSERVER_H
+
+#include <e32base.h>
+
+#include "caldavutils.h"
+
+class CCalDavEngineMgr;
+
+// needed for creating server thread.
+const TUint KDefaultHeapSize = 0x10000;
+
+//**********************************
+//CCalDavServer
+//**********************************
+class CCalDavServer : public CPolicyServer
+	{
+public:
+	static CCalDavServer* NewLC();
+	static TInt ThreadFunction(TAny* aStarted);
+	static void PanicServer(TCalDavServPanic aPanic);
+	CSession2
+			* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+public:
+
+	TInt EnableL(const TDesC &aCalendar);
+	TInt DisableL(const TDesC &aCalendar);
+
+	TBool EnabledSyncL(const TDesC &aCalendar) const;
+
+	// TODO: make these asynchronous
+	TInt SyncL(const TDesC &aCalendar);
+	TInt SyncAllL();
+
+	TPtrC8 UrlL(const TDesC &aCalendar);
+	void SetUrlL(const TDesC &aCalendar, const TDesC8 &aUrl);
+
+	TPtrC8 UsernameL(const TDesC &aCalendar);
+	void SetUsernameL(const TDesC &aCalendar, const TDesC8 &aUsername);
+
+	TPtrC8 PasswordL(const TDesC &aCalendar);
+	void SetPasswordL(const TDesC &aCalendar, const TDesC8 &aPassword);
+
+	TTimeIntervalMinutes SyncIntervalL(const TDesC &aCalendar) const;
+	void SetSyncIntervalL(const TDesC &aCalendar,
+			TTimeIntervalMinutes aSyncInterval);
+
+	TTimeIntervalDays PastDaysL(const TDesC &aCalendar) const;
+	void SetPastDaysL(const TDesC &aCalendar, TTimeIntervalDays aDays);
+
+	TBool ImmediateSyncL(const TDesC &aCalendar) const;
+	void SetImmediateSyncL(const TDesC &aCalendar, TBool aImmediateSyc);
+
+	TBool KeepServerEntryL(const TDesC &aCalendar) const;
+	void SetKeepServerEntryL(const TDesC &aCalendar, TBool aKeepServerEntry);
+
+private:
+
+private:
+	static void ThreadFunctionL();
+	~CCalDavServer();
+	CCalDavServer();
+
+	CCalDavEngineMgr* iMgr;
+
+protected:
+	void ConstructL();
+	CCalDavServer(CActive::TPriority aActiveObjectPriority);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavserversession.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav server session, follows Symbian 
+* 				client/server architecture
+*
+*/
+
+#ifndef CCALDAVSERVERSESSION_H
+#define CCALDAVSERVERSESSION_H
+
+#include <e32base.h>
+
+class CCalDavServer;
+
+//**********************************
+//CCalDavServerSession
+//**********************************
+/**
+ This class represents a session with the  server.
+ Functions are provided to respond appropriately to client messages.
+ */
+class CCalDavServerSession : public CSession2
+	{
+public:
+	CCalDavServerSession(CCalDavServer &aServer);
+	void ServiceL(const RMessage2& aMessage);
+
+	void EnableL(const RMessage2& aMessage);
+	void DisableL(const RMessage2& aMessage);
+
+	void SyncL(const RMessage2& aMessage);
+	void SyncAllL(const RMessage2& aMessage);
+
+	void UrlL(const RMessage2& aMessage);
+	void SetUrlL(const RMessage2& aMessage);
+
+	void UsernameL(const RMessage2& aMessage);
+	void SetUsernameL(const RMessage2& aMessage);
+
+	void PasswordL(const RMessage2& aMessage);
+	void SetPasswordL(const RMessage2& aMessage);
+
+	void SyncIntervalL(const RMessage2& aMessage);
+	void SetSyncIntervalL(const RMessage2& aMessage);
+
+	void PastDaysL(const RMessage2& aMessage);
+	void SetPastDaysL(const RMessage2& aMessage);
+
+	void ImmediateSyncL(const RMessage2& aMessage);
+	void SetImmediateSyncL(const RMessage2& aMessage);
+
+	void KeepServerEntryL(const RMessage2& aMessage);
+	void SetKeepServerEntryL(const RMessage2& aMessage);
+
+	void EnabledSyncL(const RMessage2& aMessage);
+
+	// still there from symbian count example, not part of caldav 
+	void SetFromStringL(const RMessage2& aMessage);
+	void Increase();
+	void Decrease();
+	void IncreaseBy(const RMessage2& aMessage);
+	void DecreaseBy(const RMessage2& aMessage);
+	void CounterValueL(const RMessage2& aMessage);
+	void Reset();
+	/********************************************************/
+
+protected:
+	// panic the client
+	void PanicClient(const RMessage2& aMessage, TInt aPanic) const;
+
+private:
+	void DispatchMessageL(const RMessage2& aMessage);
+
+	CCalDavServer& rServer;
+	TInt iCount;
+
+	};
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavsession.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	Client API to connect to Caldav server
+*				Wrapper around RCalDavServer
+*/
+
+#ifndef CCALDAVSESSION_H
+#define CCALDAVSESSION_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+class CCalDavSessionImpl;
+
+/**
+ * @class CCalenCustomisation 
+ * @brief Client API to connect to the CalDAV server.
+ */
+NONSHARABLE_CLASS( CCalDavSession ) : public CBase
+	{
+public:
+	/** Allocates and constructs a session to the Calendar server.
+	 * @return Pointer to the newly created session.
+	 */
+	IMPORT_C static CCalDavSession* NewL();
+	/** 	Allocates and constructs a session to the Calendar server.
+	 @return Pointer to the newly created session.
+	 */
+	IMPORT_C static CCalDavSession* NewLC();
+	
+	/**
+	 * 	standard destructor, close session with CalDavServer
+	 */
+	IMPORT_C ~CCalDavSession();
+
+	/**
+	 Enable access to a remote CalDAV server. At least url, 
+	 username and password need to be set first.
+	 
+	 @param aCalendar calendar to enable, must be internal filename in the form c:calendar
+	 */
+	IMPORT_C TInt Enable(const TDesC &aCalendar);
+	/**
+	 Disable access to a remote CalDAV server.
+	 
+	 @param aCalendar calendar to disable, must be internal filename in the form c:calendar
+	 */
+	IMPORT_C TInt Disable(const TDesC &aCalendar);
+
+	/**
+	 On demand syncing of an enabled connection of one calendar file
+	 
+	 @param aCalendar calendar to enable, must be internal filename in the form c:calendar
+	 */
+	IMPORT_C TInt SyncL(const TDesC &aCalendar);
+	/**
+	 On demand syncing of all enabled connections 
+	 */
+	IMPORT_C TInt SyncAllL();
+
+	/**
+	 Retrieve connection url
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aUrl url for the connection
+	 */
+	IMPORT_C TInt Url(const TDesC &aCalendar, TDes8 &aUrl);
+	/**
+	 Set connection url
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aUrl url for the url
+	 */
+	IMPORT_C TInt SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl);
+
+	/**
+	 Retrieve connection username
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aUsername username for the connection
+	 */
+
+	IMPORT_C TInt Username(const TDesC &aCalendar, TDes8 &aUsername);
+	/**
+	 Set connection username
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aUsername username for the connection
+	 */
+	IMPORT_C TInt SetUsername(const TDesC &aCalendar, const TDesC8 &aUsername);
+
+	/**
+	 Retrieve connection password
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aPassword password for the connection
+	 */
+
+	IMPORT_C TInt Password(const TDesC &aCalendar, TDes8 &aPassword);
+	/**
+	 Set connection password
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aPassword password for the connection
+	 */
+	IMPORT_C TInt SetPassword(const TDesC &aCalendar, const TDesC8 &aPassword);
+	/**
+	 Retrieve synchonization interval
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aSyncInterval sync interval for the connection
+	 */
+
+	IMPORT_C TInt SyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes& aSyncInterval);
+	/**
+	 Set synchonization interval
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aSyncInterval sync interval for the connection, value of zero minutes meaning 
+	 continuous connection
+	 */
+	IMPORT_C TInt SetSyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes aSyncInterval);
+
+	/**
+	 Retrieve time range into past for synchronization
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aDays number of days into the past for the connection
+	 */
+	IMPORT_C TInt PastDays(const TDesC &aCalendar, TTimeIntervalDays &aDays);
+	/**
+	 Set time range into past for synchronization
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aDays number of days into the past for the connection
+	 */
+	IMPORT_C TInt SetPastDays(const TDesC &aCalendar, TTimeIntervalDays aDays);
+
+	/**
+	 Retrieve immediate push of client changes
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aImmediateSync push client changes immediatly
+	 */
+	IMPORT_C TInt ImmediateSync(const TDesC &aCalendar, TBool &aImmediateSyc);
+	/**
+	 Set immediate push of client changes
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aImmediateSync push client changes immediatly
+	 */
+	IMPORT_C TInt SetImmediateSync(const TDesC &aCalendar, TBool aImmediateSyc);
+
+	/**
+	 During a synchronisation conflict, either the server or client needs to win, default is the server
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aKeepServerEntry server or client wins during synchronisation
+	 */
+	IMPORT_C TInt KeepServerEntry(const TDesC &aCalendar,
+			TBool &aKeepServerEntry);
+	/**
+	 During a synchronisation conflict, either the server or client needs to win, which can be set here
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aKeepServerEntry server or client wins during synchronisation
+	 */
+	IMPORT_C TInt SetKeepServerEntry(const TDesC &aCalendar,
+			TBool aKeepServerEntry);
+
+	/**
+	 Retrieve connection status
+	 
+	 @param aCalendar calendar for sync, must be internal filename in the form c:calendar
+	 @param aEnabledSync connection status
+	 */
+	IMPORT_C TInt EnabledSync(const TDesC &aCalendar, TBool &aEnabledSync);
+
+private:
+
+	CCalDavSession();
+	void ConstructL();
+
+	CCalDavSessionImpl* iImpl;
+
+	};
+
+#endif // CCALDAVSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavsessionimpl.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	Client API implementation
+*				Wrapper around RCalDavServer
+*/
+
+#ifndef CCALDAVSESSIONIMPL_H
+#define CCALDAVSESSIONIMPL_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+class RCalDavServer;
+
+// CLASS DECLARATION
+
+/**
+ *  CCalDavSessionImpl
+ * 
+ */
+class CCalDavSessionImpl : public CBase
+	{
+public:
+
+	~CCalDavSessionImpl();
+
+	static CCalDavSessionImpl* NewL();
+	static CCalDavSessionImpl* NewLC();
+
+	TInt Enable(const TDesC &aCalendar);
+	TInt Disable(const TDesC &aCalendar);
+
+	TInt SyncL(const TDesC &aCalendar);
+	TInt SyncAllL();
+
+	TInt Url(const TDesC &aCalendar, TDes8 &aUrl);
+	TInt SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl);
+
+	TInt Username(const TDesC &aCalendar, TDes8 &aUsername);
+	TInt SetUsername(const TDesC &aCalendar, const TDesC8 &aUsername);
+
+	TInt Password(const TDesC &aCalendar, TDes8 &aPassword);
+	TInt SetPassword(const TDesC &aCalendar, const TDesC8 &aPassword);
+
+	TInt SyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes& aSyncInterval);
+	TInt SetSyncInterval(const TDesC &aCalendar,
+			TTimeIntervalMinutes aSyncInterval);
+
+	TInt PastDays(const TDesC &aCalendar, TTimeIntervalDays &aDays);
+	TInt SetPastDays(const TDesC &aCalendar, TTimeIntervalDays aDays);
+
+	TInt ImmediateSync(const TDesC &aCalendar, TBool &aImmediateSyc);
+	TInt SetImmediateSync(const TDesC &aCalendar, TBool aImmediateSyc);
+
+	TInt KeepServerEntry(const TDesC &aCalendar, TBool &aKeepServerEntry);
+	TInt SetKeepServerEntry(const TDesC &aCalendar, TBool aKeepServerEntry);
+
+	TInt EnabledSync(const TDesC &aCalendar, TBool &aEnabledSync);
+
+private:
+
+	CCalDavSessionImpl();
+	void ConstructL();
+
+	RCalDavServer* iServer;
+
+	};
+
+#endif // CCALDAVSESSIONIMPL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/caldavutils.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,251 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	various utility classes and functions
+*				used in Caldav client and server code
+*/
+
+#ifndef CALDAVUTILS_H
+#define CALDAVUTILS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+// CLASS DECLARATION
+class RHTTPTransaction;
+
+_LIT(KCalDavServerName,"!CalDavServer");
+_LIT(KCalDavServerFilename,"!CalDavServer.exe");
+_LIT8(KUserAgent, "Symbian 1.0");
+
+const TUint KCalDavServerMajorVersionNumber = 1;
+const TUint KCalDavServerMinorVersionNumber = 0;
+const TUint KCalDavServerBuildVersionNumber = 0;
+
+enum TCalDavServReq
+	{
+	ECalDavCreate = 1,
+	ECalDavClose,
+	ECalDavUnsupportedRequest,
+	ECalDavEnable,
+	ECalDavDisable,
+	ECalDavMkCalendar,
+	ECalDavDeleteCalendar,
+	ECalDavSyncAll,
+	ECalDavSync,
+	ECalDavUrl,
+	ECalDavSetUrl,
+	ECalDavUsername,
+	ECalDavSetUsername,
+	ECalDavPassword,
+	ECalDavSetPassword,
+	ECalDavSyncInterval,
+	ECalDavSetSyncInterval,
+	ECalDavPastDays,
+	ECalDavSetPastDays,
+	ECalDavImmediateSync,
+	ECalDavSetImmediateSync,
+	ECalDavKeepServer,
+	ECalDavSetKeepServer,
+	ECalDavEnabled
+	};
+
+enum TCalDavServLeave
+	{
+	ENonNumericString = 99
+	};
+
+// reasons for server panic
+enum TCalDavServPanic
+	{
+	EBadRequest = 1,
+	EBadDescriptor,
+	EMainSchedulerError,
+	ESvrCreateServer,
+	ESvrStartServer,
+	ECreateTrapCleanup,
+	ENotImplementedYet,
+	};
+
+struct TCalDAVOptions
+	{
+	// ALLOW header
+	TBool DELETE;
+	TBool GET;
+	TBool HEAD;
+	TBool MKCALENDAR;
+	TBool MKCOL;
+	TBool OPTIONS;
+	TBool PROPFIND;
+	TBool PROPPATCH;
+	TBool PUT;
+	TBool REPORT;
+	TBool COPY;
+	TBool POST;
+	TBool MOVE;
+	TBool ACL;
+	TBool LOCK;
+	TBool UNLOCK;
+	TBool MULTIGET;
+	TBool QUERY;
+
+	TBool VEVENT;
+	TBool VTODO;
+	TBool VFREEBUSY;
+	TBool VJOURNAL;
+
+	//DAV header
+	TBool ONE;
+	TBool TWO;
+	TBool THREE;
+	TBool access_control;
+	TBool calendar_access;
+	TBool calendar_schedule;
+	TBool calendar_auto_schedule;
+	TBool extended_mkcol;
+	TBool sync_collection;
+	TBool sync_ctag;
+	};
+_LIT8(colon,",");
+_LIT8(DAV,"DAV");
+_LIT8(ALLOW,"Allow");
+_LIT8(DELETE,"DELETE");
+_LIT8(GET,"GET");
+_LIT8(HEAD,"HEAD");
+_LIT8(MKCALENDAR,"MKCALENDAR");
+_LIT8(MKCOL,"MKCOL");
+_LIT8(OPTIONS,"OPTIONS");
+_LIT8(PROPFIND,"PROPFIND");
+_LIT8(PROPPATCH,"PROPPATCH");
+_LIT8(PUT,"PUT");
+_LIT8(REPORT,"REPORT");
+_LIT8(COPY,"COPY");
+_LIT8(POST,"POST");
+_LIT8(MOVE,"MOVE");
+_LIT8(ACL,"ACL");
+_LIT8(LOCK,"LOCK");
+_LIT8(UNLOCK,"UNLOCK");
+_LIT8(MULTIGET,"MULTIGET");
+//DAV header
+_LIT8(ZERO,"0");
+_LIT8(ONE,"1");
+_LIT8(TWO,"2");
+_LIT8(THREE,"3");
+_LIT8(access_control,"access-control");
+_LIT8(calendar_access,"calendar-access");
+_LIT8(calendar_schedule,"calendar-schedule");
+_LIT8(calendar_auto_schedule,"calendar-auto-schedule");
+_LIT8(sync_collection,"sync-collection");
+_LIT8(extended_mkcol,"extended-mkcol");
+_LIT8(KVEVENT,"VEVENT");
+_LIT8(KVTODO,"VTODO");
+_LIT8(KVJOURNAL,"VJOURNAL");
+_LIT8(KVFREBUSY,"VFREEBUSY");
+_LIT8(KDav,"DAV:");
+_LIT8(KMultistatus,"multistatus");
+_LIT8(LProp,"prop");
+_LIT8(KHref,"href");
+_LIT8(KResponse,"response");
+_LIT8(KStatus,"status");
+_LIT8(KOwner,"owner");
+_LIT8(KEtag,"getetag");
+_LIT8(KResourcetype,"resourcetype");
+_LIT8(KCalDav,"urn:ietf:params:xml:ns:caldav");
+_LIT8(KGetctag,"getctag");
+_LIT8(KSynctoken,"sync-token");
+_LIT8(KCalendarData,"calendar-data");
+_LIT8(KCalendar,"calendar");
+_LIT8(KCalendarHomeSet,"calendar-home-set");
+_LIT8(KOutbox,"schedule-outbox-URL");
+_LIT8(KInbox,"schedule-inbox-URL");
+_LIT8(KCalendarMultiget,"calendar-multiget");
+_LIT8(KCalendarQuery,"calendar-query");
+_LIT8(KDisplayname,"displayname");
+_LIT8(KSupportedCalendarComponentSet,"supported-calendar-component-set");
+_LIT8(KCalendar_Color,"calendar-color");
+
+// groupdav
+_LIT8(KVTodoCollection,"vtodo-collection");
+_LIT8(KVEventCollection,"vevent-collection");
+_LIT8(KIcs, ".ics");
+_LIT8(KUID,"UID:");
+_LIT8(KSlash,"/");
+_LIT8(KName,"name");
+_LIT8(KHrefstart,"<D:href xmlns:D=\"DAV:\">");
+_LIT8(KHrefend,"</D:href>");
+_LIT8(KMultistart,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><C:calendar-multiget xmlns:C=\"urn:ietf:params:xml:ns:caldav\"><D:prop xmlns:D=\"DAV:\"><D:getetag/><C:calendar-data/></D:prop>");
+_LIT8(KMultiend,"</C:calendar-multiget>");
+_LIT8(KSync,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:sync-collection xmlns:D=\"DAV:\"><D:sync-token>%S</D:sync-token><D:prop><D:getetag/></D:prop></D:sync-collection>");
+_LIT8(KCtag,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><T:getctag xmlns:T=\"http://calendarserver.org/ns/\"/></D:prop></D:propfind>");
+_LIT8(KSupportedSet,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><C:supported-calendar-component-set/><D:supported-report-set/><D:displayname/><A:calendar-color xmlns:A=\"http://apple.com/ns/ical/\"/></D:prop></D:propfind>");
+_LIT8(KCalendarurl,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><D:owner/><D:resourcetype/></D:prop></D:propfind>");
+_LIT8(KPrincipalurl,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><C:calendar-home-set/><C:schedule-inbox-URL/><C:schedule-outbox-URL/></D:prop></D:propfind>");
+_LIT8(KPropList,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><D:getetag/></D:prop></D:propfind>");
+_LIT8(KTimeStartEVENT,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VEVENT\"><time-range start=");
+_LIT8(KTimeStartTODO,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VTODO\"><time-range start=");
+_LIT8(KTimeEnd," end=\"20200101T000000Z\"/></comp-filter></comp-filter></filter></calendar-query>");
+_LIT8(KTimeTest,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VEVENT\"><time-range start=\"20090509T220000Z\" end=\"20090509T220000Z\"/></comp-filter></comp-filter></filter></calendar-query>");
+
+_LIT8(KColorDisplayStart,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propertyupdate xmlns:D=\"DAV:\"><D:set><D:prop><A:calendar-color xmlns:A=\"http://apple.com/ns/ical/\">");
+_LIT8(KColorDisplayMiddle,"</A:calendar-color><D:displayname>");
+_LIT8(KColorDisplayEnd,"</D:displayname></D:prop></D:set></D:propertyupdate>");
+
+// strings for CCalCalendarInfo Properties
+_LIT8(KCaldavEnabled,"caldavenabled");
+_LIT8(KCaldavFirstInit,"caldavfirstinit");
+_LIT8(KCaldavCtag,"caldavctag");
+_LIT8(KCaldavSynctoken,"caldavsynctoken");
+_LIT8(KCaldavManualSync,"caldavmanualsync");
+_LIT8(KCaldavTime,"caldavtime");
+_LIT8(KCaldavUser,"caldavuser");
+_LIT8(KCaldavPassword,"caldavpassword");
+_LIT8(KCaldavUrl,"caldavurl");
+_LIT8(KCaldavKeepServer,"caldavkeepserver");
+_LIT8(KCaldavImmediateSync,"caldavimmediatesync");
+_LIT8(KCaldavPastDays,"caldavpastdays");
+_LIT8(KCaldavSyncInterval,"caldavsyncinterval");
+
+class CalDavUtils : public CBase
+	{
+public:
+
+	~CalDavUtils();
+
+	static CalDavUtils* NewL();
+	static CalDavUtils* NewLC();
+
+	static void ScanDAVHeaderL(RHTTPTransaction &aTransaction,
+			TCalDAVOptions &aOptions);
+	static void ScanAllowHeaderL(RHTTPTransaction &aTransaction,
+			TCalDAVOptions &aOptions);
+	static void FixExportIssues(TDes8 &aDes);
+	static void FixImportIssues(TDes8 &aDes);
+	static void GetFileName(const TDesC8 &aIcs, TDes8 &aUrl);
+
+	static HBufC8* EnsureSlashL(HBufC8* aIn);
+	static HBufC8* CalDavUtils::EnsureSlashL(const TDesC8 &aIn);
+
+private:
+
+	CalDavUtils();
+	void ConstructL();
+
+	static void FindAndRemoveMethod(TDes8 &aDes);
+	static void FixBYMONTHDAY(TDes8 &aDes);
+	static void FixSameTime(TDes8 &aDes);
+	static void FixLineFeed(TDes8 &aDes);
+
+	};
+
+#endif // CALDAVUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/inc/httpclient.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 
+*
+*/
+
+#ifndef HTTPCLIENT_H
+#define HTTPCLIENT_H
+
+#include <http\MHTTPAuthenticationCallback.h>
+#include <http\mhttptransactioncallback.h>
+#include <http\mhttpdatasupplier.h>
+
+#include <es_sock.h>
+#include <extendedconnpref.h>
+
+struct TCalDAVOptions;
+
+_LIT8(KHTTP200,"http/1.1 200 ok");
+_LIT8(KHTTP201,"http/1.1 201 created");
+_LIT8(KHTTP404,"http/1.1 404 not found");
+
+#define ERROR 			0
+#define OK				200
+#define CREATED 		201
+#define NOCONTENT		204
+#define MULTISTATUS		207
+#define MUTIPLECHOICES	300
+#define BADREQUEST		400
+#define FORBIDDEN		403
+#define NOTFOUND		404
+#define NOTALLOWED		405
+#define CONFLICT		409
+#define PRECONDFAILED 	412
+
+enum THttpAction
+	{
+	EActionUpload, EActionDelete, EActionOption, EActionNone
+	};
+
+class CHttpClient : public CBase,
+		public MHTTPDataSupplier,
+		public MHTTPAuthenticationCallback,
+		public MHTTPTransactionCallback
+	{
+public:
+	virtual ~CHttpClient();
+	static CHttpClient* NewLC();
+	static CHttpClient* NewL();
+
+	TInt PutL(const TDesC8 &aUrl, const TDesC8 &aICS, CBufFlat *aResponse,
+			const TDesC8 &aEtag = KNullDesC8);
+	TInt MkCalendarL(const TDesC8 &aUrl, const TDesC8 &aBody,
+			CBufFlat *aResponse);
+	TInt DeleteL(const TDesC8 &aUrl, const TDesC8 &aETag = KNullDesC8);
+	TInt HeadL(const TDesC8 &aUrl);
+	TInt GetL(const TDesC8 &aUrl, CBufFlat *aResponse);
+	TInt PropfindL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest,
+			CBufFlat *aResponse, TBool depth0 = ETrue);
+	TInt ReportL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest,
+			CBufFlat *aResponse);
+	TInt ProppatchL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest,
+			CBufFlat *aResponse);
+
+	TInt GetServerOptionsL(const TDesC8 &aUrl, TCalDAVOptions &aOptions);
+
+	// methods inherited from MHTTPDataSupplier
+	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
+	virtual void ReleaseData();
+	virtual TInt OverallDataSize();
+	virtual TInt Reset();
+
+	TInt ReturnCode();
+	TPtrC8 ETag();
+
+	//
+	// methods from MHTTPTransactionCallback
+	//
+	virtual void MHFRunL(RHTTPTransaction aTransaction,
+			const THTTPEvent& aEvent);
+	virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction,
+			const THTTPEvent& aEvent);
+	
+	// methods inherited from MHTTPAuthenticationCallback
+	virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm,
+			RStringF aAuthenticationType, RString& aUsername,
+			RString& aPassword);
+
+	TPtrC8 User();
+	void SetUserL(const TDesC8 &aUser);
+
+	void SetPasswordL(const TDesC8 &aPassword);
+	TPtrC8 Password();
+
+protected:
+	CHttpClient();
+	void ConstructL();
+private:
+
+	void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
+	void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField,
+			const TDesC8& aHdrValue);
+	void SetHeaderL(RHTTPHeaders aHeaders, const TDesC8 &aField,
+			const TDesC8 &aValue);
+	void GetEtagHeaderL(RHTTPTransaction& aTransaction);
+
+	void GetPostBodyManuallyL();
+
+	void OpenSessionL();
+
+private:
+	RHTTPSession iSess;
+	RHTTPTransaction iTrans;
+	TParse iParsedFileName;
+	CBufFlat* iBodyResponse;
+	HBufC8* iBodyRequest;
+
+	RSocketServ iSocketServ;
+	RConnection iRConnection;
+	TConnPrefList iPrefList;
+	TExtendedConnPref iExtPrefs;
+
+	HBufC8 *iUser;
+	HBufC8 *iPassword;
+
+	TCalDAVOptions *iOptions;
+	THttpAction iAction;
+
+	TInt iReturnCode;
+	HBufC8* iEtag;
+	TInt iCredentialCount;
+
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavclient.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,329 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides a client API for Caldav server
+*
+*/
+
+#include "caldavclient.h"
+#include "caldavserver.h"
+#include "caldavutils.h"
+
+const TUint KDefaultMessageSlots = 4;
+
+// testing ************
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32cmn.h>
+
+/**
+ * RCalDavServer::RCalDavServer
+ * default constructor
+ */
+EXPORT_C RCalDavServer::RCalDavServer()
+	{
+	}
+
+/**
+ * RCalDavServer::Connect
+ * connect to server
+ */
+EXPORT_C TInt RCalDavServer::Connect()
+	{
+	TInt retry = 2;
+	for (;;)
+		{
+		TInt r = CreateSession(KCalDavServerName, Version(),
+				KDefaultMessageSlots);
+
+		if ((KErrNotFound != r) && (KErrServerTerminated != r))
+			return (r);
+
+		if (--retry == 0)
+			return (r);
+
+		r = StartServer();
+		if ((KErrNone != r) && (KErrAlreadyExists != r))
+			return (r);
+		}
+	}
+
+/**
+ * RCalDavServer::Enable
+ * enable Caldav sync
+ */
+EXPORT_C TInt RCalDavServer::Enable(const TDesC &aCalendar)
+	{
+	TIpcArgs args(&aCalendar);
+	return SendReceive(ECalDavEnable, args);
+	}
+
+/**
+ * RCalDavServer::Disable
+ * disable Caldav sync
+ */
+EXPORT_C TInt RCalDavServer::Disable(const TDesC &aCalendar)
+	{
+	TIpcArgs args(&aCalendar);
+	return SendReceive(ECalDavDisable, args);
+	}
+
+/**
+ * RCalDavServer::EnabledSync
+ * check for enabled sync
+ */
+EXPORT_C TInt RCalDavServer::EnabledSync(const TDesC &aCalendar,
+		TBool &aEnabled)
+	{
+	TPckg<TBool> enabled(aEnabled);
+	TIpcArgs args(&aCalendar, &enabled);
+	return (SendReceive(ECalDavEnabled, args));
+	}
+
+/**
+ * RCalDavServer::Sync
+ * sync now a specific calendar
+ */
+EXPORT_C TInt RCalDavServer::Sync(const TDesC &aCalendar)
+	{
+	TIpcArgs args(&aCalendar);
+	return SendReceive(ECalDavSync, args);
+	}
+
+/**
+ * RCalDavServer::SyncAll
+ * sync now all calendars
+ */
+EXPORT_C TInt RCalDavServer::SyncAll()
+	{
+	return SendReceive(ECalDavSyncAll);
+	}
+
+/**
+ * RCalDavServer::Url
+ * get caldav sync url
+ */
+EXPORT_C TInt RCalDavServer::Url(const TDesC &aCalendar, TDes8 &aUrl)
+	{
+	TIpcArgs args(&aCalendar, &aUrl);
+	return SendReceive(ECalDavUrl, args);
+	}
+
+/**
+ * RCalDavServer::SetUrl
+ * set url
+ */
+EXPORT_C TInt RCalDavServer::SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl)
+	{
+	TIpcArgs args(&aCalendar, &aUrl);
+	return SendReceive(ECalDavSetUrl, args);
+	}
+
+/**
+ * RCalDavServer::Username
+ * get username
+ */
+EXPORT_C TInt RCalDavServer::Username(const TDesC &aCalendar, TDes8 &aUsername)
+	{
+	TIpcArgs args(&aCalendar, &aUsername);
+	return SendReceive(ECalDavUsername, args);
+	}
+
+/**
+ * RCalDavServer::SetUsername
+ * set username
+ */
+EXPORT_C TInt RCalDavServer::SetUsername(const TDesC &aCalendar,
+		const TDesC8 &aUsername)
+	{
+	TIpcArgs args(&aCalendar, &aUsername);
+	return SendReceive(ECalDavSetUsername, args);
+	}
+
+/**
+ * RCalDavServer::Password
+ * get password
+ */
+EXPORT_C TInt RCalDavServer::Password(const TDesC &aCalendar, TDes8 &aPassword)
+	{
+	TIpcArgs args(&aCalendar, &aPassword);
+	return SendReceive(ECalDavPassword, args);
+	}
+
+/**
+ * RCalDavServer::SetPassword
+ * set password
+ */
+EXPORT_C TInt RCalDavServer::SetPassword(const TDesC &aCalendar,
+		const TDesC8 &aPassword)
+	{
+	TIpcArgs args(&aCalendar, &aPassword);
+	return SendReceive(ECalDavSetPassword, args);
+	}
+
+/**
+ * RCalDavServer::SyncInterval
+ * get SyncInterval
+ */
+EXPORT_C TInt RCalDavServer::SyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes& aSyncInterval)
+	{
+	TPckg<TTimeIntervalMinutes> syncinterval(aSyncInterval);
+	TIpcArgs args(&aCalendar, &syncinterval);
+	return (SendReceive(ECalDavSyncInterval, args));
+	}
+
+/**
+ * RCalDavServer::SetSyncInterval
+ * set SyncInterval
+ */
+EXPORT_C TInt RCalDavServer::SetSyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes aSyncInterval)
+	{
+	TPckg<TTimeIntervalMinutes> syncinterval(aSyncInterval);
+	TIpcArgs args(&aCalendar, &syncinterval);
+	return (SendReceive(ECalDavSetSyncInterval, args));
+	}
+
+/**
+ * RCalDavServer::PastDays
+ * get past days
+ */
+EXPORT_C TInt RCalDavServer::PastDays(const TDesC &aCalendar,
+		TTimeIntervalDays &aDays)
+	{
+	TPckg<TTimeIntervalDays> pastdays(aDays);
+	TIpcArgs args(&aCalendar, &pastdays);
+	return (SendReceive(ECalDavPastDays, args));
+	}
+
+/**
+ * RCalDavServer::SetPastDays
+ * set past days
+ */
+EXPORT_C TInt RCalDavServer::SetPastDays(const TDesC &aCalendar,
+		TTimeIntervalDays aDays)
+	{
+	TPckg<TTimeIntervalDays> pastdays(aDays);
+	TIpcArgs args(&aCalendar, &pastdays);
+	return (SendReceive(ECalDavSetPastDays, args));
+	}
+
+/**
+ * RCalDavServer::ImmediateSync
+ * get Immediate Sync
+ */
+EXPORT_C TInt RCalDavServer::ImmediateSync(const TDesC &aCalendar,
+		TBool &aImmediateSyc)
+	{
+	TPckg<TBool> syncimmediate(aImmediateSyc);
+	TIpcArgs args(&aCalendar, &syncimmediate);
+	return (SendReceive(ECalDavImmediateSync, args));
+	}
+
+/**
+ * RCalDavServer::SetImmediateSync
+ * set immediate Sync
+ */
+EXPORT_C TInt RCalDavServer::SetImmediateSync(const TDesC &aCalendar,
+		TBool aImmediateSyc)
+	{
+	TPckg<TBool> syncimmediate(aImmediateSyc);
+	TIpcArgs args(&aCalendar, &syncimmediate);
+	return SendReceive(ECalDavSetImmediateSync, args);
+	}
+
+/**
+ * RCalDavServer::KeepServerEntry
+ * get KeepServerEntry
+ */
+EXPORT_C TInt RCalDavServer::KeepServerEntry(const TDesC &aCalendar,
+		TBool &aKeepServerEntry)
+	{
+	TPckg<TBool> keepserverentry(aKeepServerEntry);
+	TIpcArgs args(&aCalendar, &keepserverentry);
+	return SendReceive(ECalDavKeepServer, args);
+	}
+
+/**
+ * RCalDavServer::SetKeepServerEntry
+ * set KeepServerEntry
+ */
+EXPORT_C TInt RCalDavServer::SetKeepServerEntry(const TDesC &aCalendar,
+		TBool aKeepServerEntry)
+	{
+	TPckg<TBool> keepserverentry(aKeepServerEntry);
+	TIpcArgs args(&aCalendar, &keepserverentry);
+	return SendReceive(ECalDavSetKeepServer, args);
+	}
+
+/**
+ * RCalDavServer::Version
+ * get version
+ */
+TVersion RCalDavServer::Version(void) const
+	{
+	return (TVersion(KCalDavServerMajorVersionNumber,
+			KCalDavServerMinorVersionNumber, KCalDavServerBuildVersionNumber));
+	}
+
+/**
+ * RCalDavServer::UnsupportedRequest()
+ *  A server request to stop the server.
+ *  This is a request that is NOT implemented by the server; it is here to show
+ *  the handling of non-implemented requests.
+ */
+TInt RCalDavServer::UnsupportedRequest()
+	{
+	return SendReceive(ECalDavUnsupportedRequest);
+	}
+
+/**
+ * RCalDavServer::BadRequest()
+ * A request that the server knows nothing about.
+ */
+void RCalDavServer::BadRequest()
+	{
+	SendReceive(9999);
+	}
+
+static TInt StartServer()
+	{
+	RProcess server;
+	TInt r = server.Create(KCalDavServerFilename, KNullDesC);
+	if (r != KErrNone)
+		return r;
+
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+
+	if (stat != KRequestPending)
+		server.Kill(0); // abort startup
+	else
+		server.Resume(); // logon OK - start the server
+
+	User::WaitForRequest(stat); // wait for start or death
+
+	// Check the exit type.
+	// We can't use the 'exit reason' because if the server panicked this
+	// is set to the panic 'reason' (which may be '0' and cannot thus be distinguished
+	// from KErrNone)
+	r = server.ExitType();
+	if (EExitPanic == r)
+		r = KErrGeneral;
+	else
+		r = stat.Int();
+
+	server.Close(); // This is no longer needed
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavengine.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,2617 @@
+/*
+ * Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributor:
+ * Maximilian Odendahl
+ *
+ * Contributors:
+ * 
+ * Description:  main Caldav class, all magic happens here 
+ *				one engine for each configured Caldav calendar
+ */
+#include "caldavengine.h"
+#include <f32file.h> 
+#include <S32FILE.H>
+#include <S32MEM.H> 
+#include <avkon.rsg>
+#include <UTF.H>
+#include <agnexportobserver.h>
+#include <calsession.h>
+#include <caliterator.h>
+#include <calentry.h>
+#include <calentryview.h>
+#include <caltime.h>
+#include <calalarm.h>
+#include <calcategory.h>
+#include <caluser.h>
+#include <calrrule.h>
+#include <calinstance.h>
+#include <calinstanceview.h>
+#include <caleninterimutils2.h> 
+#include <calenexporter.h>
+#include <calenimporter.h>
+#include <calcalendarinfo.h>
+#include "calenglobaldata.h"
+#include <xmlengdocument.h>
+#include <xmlengnode.h>
+#include <xmlengelement.h>
+#include <xmlengnodelist.h>
+#include <xmlengtext.h>
+#include "httpclient.h"
+#include <e32math.h>	// divmod
+#define MULTIGETSPLIT 			100
+#define ARRAYEXPAND				4
+#define	URLMAX					500
+#define EXPANDSIZE_SMALL		512
+#define EXPANDSIZE_BIG			1024
+_LIT(KFormatString,"\"%F%Y%M%DT000000Z\"");
+
+/**
+ * SyncTickL
+ * timer for basic sync interval
+ */
+TInt SyncTickL(TAny *aObject)
+	{
+	CCalDavEngine* engine = ((CCalDavEngine*) aObject);
+	CPeriodic* timer = engine->Timer();
+	if (engine && timer)
+		{
+		timer->Cancel();
+		TRAP_IGNORE(engine->SyncL());
+		TInt ticktime = engine->SyncInterval().Int() == 0 ? 1
+				: engine->SyncInterval().Int();
+		const TUint64 tickInterval = 1000000 * 60 * ticktime;
+		timer->Start(tickInterval, tickInterval, TCallBack(SyncTickL, engine));
+		}
+	return 0;
+	}
+
+#ifdef _DEBUG
+void ExportToFileNameL(const TDesC8& aDes, const TDesC &aFilename)
+	{
+	RFs fsSession;
+	User::LeaveIfError(fsSession.Connect());
+	CleanupClosePushL(fsSession);
+
+	TInt err = fsSession.MkDirAll(aFilename);
+
+	RFile file;
+	User::LeaveIfError(file.Replace(fsSession, aFilename, EFileWrite));
+	CleanupClosePushL(file);
+
+	RFileWriteStream writeStream2;
+	writeStream2.Attach(file);
+	CleanupClosePushL(writeStream2);
+
+	writeStream2 << aDes;
+	writeStream2.CommitL();
+	CleanupStack::PopAndDestroy(&writeStream2);
+	CleanupStack::PopAndDestroy(&file);
+	CleanupStack::PopAndDestroy(&fsSession);
+	}
+
+void ExportToFileL(CCalEntry* aEntry, CCalenExporter *iCalExporter)
+	{
+	if (aEntry)
+		{
+		_LIT(KFileName, "C:\\logs\\caldav\\testing_export.txt");
+
+		RFs fsSession;
+		User::LeaveIfError(fsSession.Connect());
+		CleanupClosePushL(fsSession);
+
+		TInt err = fsSession.MkDirAll(KFileName);
+
+		RFile file;
+		User::LeaveIfError(file.Replace(fsSession, KFileName, EFileWrite));
+		CleanupClosePushL(file);
+
+		RFileWriteStream writeStream2;
+		writeStream2.Attach(file);
+		CleanupClosePushL(writeStream2);
+
+		iCalExporter->ExportICalL(*aEntry, writeStream2);
+		writeStream2.CommitL();
+		CleanupStack::PopAndDestroy(&writeStream2);
+		CleanupStack::PopAndDestroy(&file);
+		CleanupStack::PopAndDestroy(&fsSession);
+		}
+	}
+#endif
+
+/**
+ * SearchL
+ * search inside xml tree for a specific node
+ */
+void SearchL(TXmlEngNode &aTopNode, const TDesC8 &aName,
+		const TDesC8 &aNamespace, TXmlEngNode & aReturnNode)
+	{
+	RXmlEngNodeList<TXmlEngNode> List;
+	aTopNode.GetChildNodes(List);
+	while (List.HasNext() && aReturnNode.IsNull())
+		{
+		TXmlEngNode Node = List.Next();
+		TXmlEngNode::TXmlEngDOMNodeType Type = Node.NodeType();
+		if (Type == TXmlEngNode::EElement)
+			{
+			//todo: compare namespace ?
+			if (Node.Name() == aName)
+				{
+				aReturnNode = Node.CopyL();
+				return;
+				}
+			else
+				{
+				SearchL(Node, aName, aNamespace, aReturnNode);
+				if (!aReturnNode.IsNull())
+					return;
+				}
+			}
+		}
+	}
+
+/**
+ * SearchL
+ * search inside xml tree for a specific node
+ */
+void SearchL(TXmlEngNode &aTopNode, const TDesC8 &aName,
+		const TDesC8 &aNamespace, RBuf8 &aBuf)
+	{
+	RXmlEngNodeList<TXmlEngNode> List;
+	aTopNode.GetChildNodes(List);
+	while (List.HasNext())
+		{
+		TXmlEngNode Node = List.Next();
+		TXmlEngNode::TXmlEngDOMNodeType Type = Node.NodeType();
+		if (Type == TXmlEngNode::EElement)
+			{
+			//todo: compare namespace ?
+			if (Node.Name() == aName)
+				{
+				if (Node.IsSimpleTextContents())
+					aBuf.Create(Node.Value());
+				else
+					Node.WholeTextContentsCopyL(aBuf);
+				return;
+				}
+			else
+				{
+				SearchL(Node, aName, aNamespace, aBuf);
+				if (aBuf.Length())
+					return;
+				}
+			}
+		}
+	}
+
+/**
+ * SearchL
+ * search inside xml tree for a specific node
+ */
+TPtrC8 SearchL(TXmlEngNode &aTopNode, const TDesC8 &aName,
+		const TDesC8 &aNamespace)
+	{
+	RXmlEngNodeList<TXmlEngNode> List;
+	aTopNode.GetChildNodes(List);
+	while (List.HasNext())
+		{
+		TXmlEngNode Node = List.Next();
+		TXmlEngNode::TXmlEngDOMNodeType Type = Node.NodeType();
+		if (Type == TXmlEngNode::EElement)
+			{
+			//todo: compare namespace ?
+			if (Node.Name() == aName)
+				return Node.Value();
+			else
+				{
+				TPtrC8 Return = SearchL(Node, aName, aNamespace);
+				if (Return != KNullDesC8)
+					return Return;
+				}
+			}
+		}
+	return KNullDesC8();
+	}
+
+/**
+ * GetBoolFromPropertiesL
+ * get a boolean value from CCalCalendarInfo
+ */
+TBool GetBoolFromPropertiesL(CCalCalendarInfo* info, const TDesC8 &aKey)
+	{
+	TBool boolean;
+	TPckgC<TBool> pckgboolean(boolean);
+	pckgboolean.Set(info->PropertyValueL(aKey));
+	return pckgboolean();
+	}
+
+/**
+ * GetTimeFromPropertiesL
+ * get a time value from CCalCalendarInfo
+ */
+TCalTime GetTimeFromPropertiesL(CCalCalendarInfo* info, const TDesC8 &aKey)
+	{
+	TCalTime time;
+	TPckgC<TCalTime> pckgtime(time);
+	pckgtime.Set(info->PropertyValueL(aKey));
+	return pckgtime();
+	}
+
+/**
+ * PropertyExists
+ * finds a property from an array
+ */
+TBool PropertyExists(CDesC8Array* aArray, const TDesC8 &aKey)
+	{
+	TInt pos = 0;
+	return aArray->Find(aKey, pos, ECmpNormal) == KErrNone;
+	}
+
+/**
+ * CCalDavEngine::SetCalendarInfoL
+ * set key and value pair at calendar session info
+ */
+void CCalDavEngine::SetCalendarInfoL(const TDesC8 &aKey, const TDesC8 &aValue)
+	{
+	TBool createdelete = !iCalSession;
+	if (createdelete)
+		{
+		iCalSession = CCalSession::NewL();
+		TRAP_IGNORE(iCalSession->OpenL(*iCalendar));
+		}
+	CCalCalendarInfo* calendarInfo = iCalSession->CalendarInfoL();
+	CleanupStack::PushL(calendarInfo);
+	TPckgC<TBool> enabled(iEnabled);
+	calendarInfo->SetPropertyL(KCaldavEnabled, enabled);
+	if (aValue != KNullDesC8)
+		calendarInfo->SetPropertyL(aKey, aValue);
+	iCalSession->SetCalendarInfoL(*calendarInfo);
+	CleanupStack::PopAndDestroy(calendarInfo);
+
+	if (createdelete)
+		{
+		delete iCalSession;
+		iCalSession = NULL;
+		}
+	}
+
+/**
+ * CCalDavEngine::CCalDavEngine
+ * default constructor
+ */
+CCalDavEngine::CCalDavEngine() :
+	iCalSession(0), iCalIter(0), iCalEntryView(0), iCalExporter(0),
+			iCalImporter(0), iCalIntermimUtils2(0), iCalendar(0), iUrl(0),
+			iBaseUrl(0), iHome(0), iHttp(0), iSynctoken(0), iCTag(0),
+			iSyncInterval(DEFAULT_SYNC_MINUTES), iPastDays(DEFAULT_PAST_DAYS),
+			iImmediateSync(DEFAULT_IMMEDIATE_SYNC), iKeepServerEntry(
+					DEFAULT_KEEP_SERVER_ENTRY), iEnabled(EFalse), iTimer(0)
+	{
+	}
+
+/**
+ * CCalDavEngine::~CCalDavEngine
+ * default destructor
+ */
+CCalDavEngine::~CCalDavEngine()
+	{
+	iLocalUidArray.Close();
+	iGlobalUidArray.Close();
+	iDeletedEntries.Close();
+
+	iDomParser.Close();
+	iDomImpl.Close();
+
+	if (iCalendar)
+		delete iCalendar;
+
+	if (iUrl)
+		delete iUrl;
+
+	if (iBaseUrl)
+		delete iBaseUrl;
+
+	if (iHttp)
+		delete iHttp;
+
+	DeleteCalObjects();
+
+	if (iCalIntermimUtils2)
+		delete iCalIntermimUtils2;
+
+	if (iSynctoken)
+		delete iSynctoken;
+
+	if (iCTag)
+		delete iCTag;
+
+	if (iHome)
+		delete iHome;
+
+	if (iTimer)
+		delete iTimer;
+	}
+
+/**
+ * CCalDavEngine::NewLC
+ * first phase construction
+ */
+CCalDavEngine* CCalDavEngine::NewLC(const TDesC& aCalendar)
+	{
+	CCalDavEngine* self = new (ELeave) CCalDavEngine();
+	CleanupStack::PushL(self);
+	self->ConstructL(aCalendar);
+	return self;
+	}
+
+/**
+ * CCalDavEngine::NewL
+ * first phase construction
+ */
+CCalDavEngine* CCalDavEngine::NewL(const TDesC& aCalendar)
+	{
+	CCalDavEngine* self = CCalDavEngine::NewLC(aCalendar);
+	CleanupStack::Pop(self); // self;
+	return self;
+	}
+
+/**
+ * CCalDavEngine::
+ * second phase construction
+ */
+void CCalDavEngine::ConstructL(const TDesC& aCalendar)
+	{
+	iManualSync = EFalse;
+	iFirstInit = ETrue;
+	iCalendar = aCalendar.AllocL();
+
+	iHttp = CHttpClient::NewL();
+
+	iDomImpl.OpenL();
+	TInt err = iDomParser.Open(iDomImpl);
+	if (KErrNone != err)
+		User::Leave(err);
+
+	iTimer = CPeriodic::NewL(EPriorityNormal);
+	iCalIntermimUtils2 = CCalenInterimUtils2::NewL();
+	iCalSession = CCalSession::NewL();
+	TRAP_IGNORE(iCalSession->OpenL(aCalendar));
+	CalendarInfoL();
+	// we can't close the file, so delete it completly
+	delete iCalSession;
+	iCalSession = NULL;
+	}
+
+/**
+ * CCalDavEngine::Progress
+ * Progress callback
+ */
+void CCalDavEngine::Progress(TInt /*aPercentageCompleted*/)
+	{
+	}
+
+/**
+ * CCalDavEngine::RegisterL
+ * register all neccessary notification callback
+ */
+void CCalDavEngine::RegisterL()
+	{
+	TDateTime Start;
+	TDateTime End;
+	End.SetYear(2200);
+
+	TCalTime StartCal;
+	TCalTime EndCal;
+	StartCal.SetTimeLocalL(Start);
+	EndCal.SetTimeLocalL(End);
+	CalCommon::TCalTimeRange Range(StartCal, EndCal);
+	CCalChangeNotificationFilter *Filter = CCalChangeNotificationFilter::NewL(
+			MCalChangeCallBack2::EChangeEntryAll, true, Range);
+	iCalSession->StartChangeNotification(*this, *Filter);
+	iCalSession->StartFileChangeNotificationL(*this);
+	delete Filter;
+	}
+
+/**
+ * CCalDavEngine::CalendarInfoL
+ * load all properties from CalendarInfo
+ */
+void CCalDavEngine::CalendarInfoL()
+	{
+	CCalCalendarInfo* calendarInfo = iCalSession->CalendarInfoL();
+	if (calendarInfo->IsValid())
+		{
+		CleanupStack::PushL(calendarInfo);
+		CDesC8Array* propertyKeys = calendarInfo->PropertyKeysL();
+		CleanupStack::PushL(propertyKeys);
+		TInt pos = 0;
+		if (propertyKeys->Find(KCaldavEnabled, pos, ECmpNormal) == KErrNone)
+			{
+			iEnabled = GetBoolFromPropertiesL(calendarInfo, KCaldavEnabled);
+			if (PropertyExists(propertyKeys, KCaldavFirstInit))
+				iFirstInit = GetBoolFromPropertiesL(calendarInfo,
+						KCaldavFirstInit);
+			if (PropertyExists(propertyKeys, KCaldavSynctoken))
+				iSynctoken
+						= calendarInfo->PropertyValueL(KCaldavSynctoken).AllocL();
+			if (PropertyExists(propertyKeys, KCaldavCtag))
+				iCTag = calendarInfo->PropertyValueL(KCaldavCtag).AllocL();
+			if (PropertyExists(propertyKeys, KCaldavManualSync))
+				iManualSync = GetBoolFromPropertiesL(calendarInfo,
+						KCaldavManualSync);
+			if (PropertyExists(propertyKeys, KCaldavTime))
+				iLastSyncTime = GetTimeFromPropertiesL(calendarInfo,
+						KCaldavTime);
+			if (PropertyExists(propertyKeys, KCaldavUrl))
+				iUrl = calendarInfo->PropertyValueL(KCaldavUrl).AllocL();
+			if (PropertyExists(propertyKeys, KCaldavUser))
+				iHttp->SetUserL(calendarInfo->PropertyValueL(KCaldavUser));
+			if (PropertyExists(propertyKeys, KCaldavPassword))
+				iHttp->SetPasswordL(calendarInfo->PropertyValueL(
+						KCaldavPassword));
+			if (PropertyExists(propertyKeys, KCaldavKeepServer))
+				iKeepServerEntry = GetBoolFromPropertiesL(calendarInfo,
+						KCaldavKeepServer);
+			if (PropertyExists(propertyKeys, KCaldavImmediateSync))
+				iImmediateSync = GetBoolFromPropertiesL(calendarInfo,
+						KCaldavImmediateSync);
+			if (PropertyExists(propertyKeys, KCaldavPastDays))
+				{
+				TPckgC<TTimeIntervalDays> pastdays(iPastDays);
+				pastdays.Set(calendarInfo->PropertyValueL(KCaldavPastDays));
+				iPastDays = pastdays();
+				}
+			if (PropertyExists(propertyKeys, KCaldavSyncInterval))
+				{
+				TPckgC<TTimeIntervalMinutes> syncinterval(iSyncInterval);
+				syncinterval.Set(calendarInfo->PropertyValueL(
+						KCaldavSyncInterval));
+				iSyncInterval = syncinterval();
+				}
+			// access point	    
+			}
+
+		CleanupStack::PopAndDestroy(propertyKeys);
+		CleanupStack::Pop(calendarInfo);
+		}
+	delete calendarInfo;
+	}
+
+/**
+ * CCalDavEngine::InitL
+ * check for correct url
+ * load most Caldav url properties
+ * do inital sync
+ */
+TInt CCalDavEngine::InitL()
+	{
+	// this is only needed to find a GlobalUID from a LocalUID, used after an event was deleted
+	// also used now for uploading of local events when only GlobalUID is know 
+	LocalLoopL(ELoopActionFillArray);
+
+	if (iFirstInit)
+		{
+		TInt err = GetCalendarUrlsL(NULL);
+		if (err == KErrArgument)
+			return KErrArgument;
+		GetOptionsL();
+		SetLastSyncTimeL();
+
+		TBool success;
+		// get all server items
+		if (iOptions.sync_collection)
+			success = WebDavSyncL();
+		else
+			success = ListL() == KErrNone;
+
+		if (!success)
+			return KErrGeneral;
+
+		// upload all local entries of this calendar to server
+		LocalLoopL(ELoopActionUpload);
+
+		if (iOptions.sync_collection)
+			SetSyncTokenL(GetSyncTokenL());
+		else
+			SetCTagL(GetCTagL());
+
+		iFirstInit = EFalse;
+		iEnabled = ETrue;
+		TPckgC<TBool> firstInit(iFirstInit);
+		SetCalendarInfoL(KCaldavFirstInit, firstInit); // this will set iEnabled as well
+		}
+	else
+		{
+		TInt err = GetCalendarUrlsL(NULL);
+		if (err == KErrArgument)
+			return KErrArgument;
+		GetOptionsL();
+		SetLastSyncTimeL();
+		iEnabled = ETrue;
+		SetCalendarInfoL(KCaldavEnabled, KNullDesC8);
+		SyncL();
+		}
+
+	return KErrNone;
+	}
+
+/**
+ * CCalDavEngine::Completed
+ * Completed callback
+ */
+void CCalDavEngine::Completed(TInt aError)
+	{
+	if (aError == KErrNone)
+		{
+		CActiveScheduler::Stop();
+		}
+	else
+		iManualSync = true;
+	}
+
+/**
+ * CCalDavEngine::NotifyProgress
+ * NotifyProgress callback
+ */
+TBool CCalDavEngine::NotifyProgress()
+	{
+	return EFalse;
+	}
+
+/**
+ * CCalDavEngine::CalChangeNotification
+ * change item callback, sync to server
+ */
+void CCalDavEngine::CalChangeNotification(RArray<TCalChangeEntry> &aChangeItems)
+	{
+	for (TInt i = 0; i < aChangeItems.Count(); i++)
+		{
+		TRAP_IGNORE(HandleChangeL(aChangeItems[i].iChangeType, aChangeItems[i].iEntryType, aChangeItems[i].iEntryId));
+		}
+	}
+
+/**
+ * CCalDavEngine::CalendarInfoChangeNotificationL
+ * change callback, sync changed color or name to server
+ */
+void CCalDavEngine::CalendarInfoChangeNotificationL(RPointerArray<
+		CCalFileChangeInfo>& aCalendarInfoChangeEntries)
+	{
+	for (TInt i = 0; i < aCalendarInfoChangeEntries.Count(); i++)
+		{
+		if ((aCalendarInfoChangeEntries[i]->FileNameL() == *iCalendar)
+				&& (aCalendarInfoChangeEntries[i]->ChangeType()
+						== MCalFileChangeObserver::ECalendarInfoUpdated))
+			{
+			TRAP_IGNORE(HandleCalendarInfoChangeL());
+			}
+		}
+	}
+
+/**
+ * CCalDavEngine::HandleCalendarInfoChangeL
+ * sync changed color or name to server
+ */
+void CCalDavEngine::HandleCalendarInfoChangeL()
+	{
+	if (iHttp)
+		{
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		CCalCalendarInfo* info = iCalSession->CalendarInfoL();
+		CleanupStack::PushL(info);
+
+		HBufC8* name =
+				CnvUtfConverter::ConvertFromUnicodeToUtf8L(info->NameL());
+		CleanupStack::PushL(name);
+
+		TRgb color = info->Color();
+		_LIT8(KColorformat,"#%02x%02x%02xFF");
+		TBuf8<9> colorbuf;
+		colorbuf.Format(KColorformat, color.Red(), color.Green(), color.Blue());
+
+		HBufC8* patch = HBufC8::NewLC(KColorDisplayStart().Length()
+				+ colorbuf.Length() + KColorDisplayMiddle().Length()
+				+ name->Length() + KColorDisplayEnd().Length());
+		patch->Des().Append(KColorDisplayStart);
+		patch->Des().Append(colorbuf);
+		patch->Des().Append(KColorDisplayMiddle);
+		patch->Des().Append(*name);
+		patch->Des().Append(KColorDisplayEnd);
+		iHttp->ProppatchL(*iUrl, *patch, response);
+		CleanupStack::PopAndDestroy(4); // response, info, name, patch
+		}
+	}
+
+/**
+ * CCalDavEngine::HandleChangeL
+ * change item callback, sync to server
+ */
+void CCalDavEngine::HandleChangeL(
+		MCalChangeCallBack2::TChangeType &aChangeType,
+		MCalChangeCallBack2::TChangeEntryType &aEntryType, TCalLocalUid &aUid)
+	{
+	switch (aChangeType)
+		{
+		case MCalChangeCallBack2::EChangeAdd:
+		case MCalChangeCallBack2::EChangeModify:
+			{
+			if (iImmediateSync)
+				UploadEntryL(aUid, aChangeType, aEntryType);
+			else
+				// enable manual sync for the next sync interval
+				SyncFailedL();
+			break;
+			}
+		case MCalChangeCallBack2::EChangeDelete:
+			{
+			if (iImmediateSync)
+				DeleteEntryL(aUid);
+			else
+				{
+				iDeletedEntries.Append(aUid);
+				SyncFailedL();
+				}
+			break;
+			}
+		case MCalChangeCallBack2::EChangeUndefined:
+			{
+			// upload new and modified entries to server
+			UploadModifiedSinceDateL();
+
+			// Find locally deleted ones and delete on server
+			DeleteRemovedEntriesOnServerL();
+
+			break;
+			}
+		}
+	}
+
+/**
+ * CCalDavEngine::EnableL
+ * enable Caldav sync
+ */
+TInt CCalDavEngine::EnableL()
+	{
+	if (!iCalEntryView) //do not use iEnabled here,might be set already in ConstructL()
+		{
+		TInt aErr = CreateCalObjectsL();
+		if ((aErr == KErrNone) && (InitL() == KErrNone))
+			{
+			iTimer->Cancel();
+			TInt ticktime = iSyncInterval.Int() == 0 ? 1 : iSyncInterval.Int();
+			const TUint64 tickInterval = 1000000 * 60 * ticktime;
+			iTimer->Start(tickInterval, tickInterval,
+					TCallBack(SyncTickL, this));
+			// register change notification
+			RegisterL();
+			return KErrNone;
+			}
+		else
+			{
+			iEnabled = EFalse;
+			SetCalendarInfoL(KCaldavEnabled, KNullDesC8);
+			DeleteCalObjects();
+			return KErrArgument;
+			}
+		}
+	return KErrNone;
+	}
+
+/**
+ * CCalDavEngine::DeleteCalObjects
+ * delete all calendar objects
+ */
+void CCalDavEngine::DeleteCalObjects()
+	{
+	delete iCalIter;
+	iCalIter = NULL;
+	delete iCalEntryView;
+	iCalEntryView = NULL;
+	delete iCalImporter;
+	iCalImporter = NULL;
+	delete iCalExporter;
+	iCalExporter = NULL;
+	if (iCalSession)
+		{
+		iCalSession->StopChangeNotification();
+		iCalSession->StopFileChangeNotification();
+		delete iCalSession;
+		}
+	iCalSession = NULL;
+	}
+
+/**
+ * CCalDavEngine::CreateCalObjectsL
+ * create all calendar objects
+ */
+TInt CCalDavEngine::CreateCalObjectsL()
+	{
+	iCalSession = CCalSession::NewL();
+	TRAPD(aErr,iCalSession->OpenL(*iCalendar));
+	iCalExporter = CCalenExporter::NewL(*iCalSession);
+	iCalImporter = CCalenImporter::NewL(*iCalSession);
+	iCalEntryView = CCalEntryView::NewL(*iCalSession);
+	iCalIter = CCalIter::NewL(*iCalSession);
+	return aErr;
+	}
+
+/**
+ * CCalDavEngine::DisableL
+ * disable sync
+ */
+void CCalDavEngine::DisableL()
+	{
+	if (iEnabled)
+		{
+		iTimer->Cancel();
+		iEnabled = EFalse;
+		SetCalendarInfoL(KCaldavEnabled, KNullDesC8);
+		DeleteCalObjects();
+		}
+	}
+
+/**
+ * CCalDavEngine::EnabledSync
+ * check for enabled sync
+ */
+TBool CCalDavEngine::EnabledSync()
+	{
+	return iEnabled;
+	}
+
+/**
+ * CCalDavEngine::TimeReportL
+ * do a CalDav time report
+ */
+TInt CCalDavEngine::TimeReportL(TBool VEVENT, const TDesC8 &aStart,
+		TBool aDelete)
+	{
+	CBufFlat* body = CBufFlat::NewL(EXPANDSIZE_BIG);
+	CleanupStack::PushL(body);
+
+	body->InsertL(body->Size(), VEVENT ? KTimeStartEVENT() : KTimeStartTODO());
+	body->InsertL(body->Size(), aStart); // "20090509T220000Z"/>
+	body->InsertL(body->Size(), KTimeEnd);
+
+	CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_BIG);
+	CleanupStack::PushL(response);
+	TInt ret = iHttp->ReportL(*iUrl, body->Ptr(0), response);
+
+	if (ret == MULTISTATUS)
+		ret = aDelete ? ParseResponsesDeleteL(response->Ptr(0))
+				: ParseResponsesL(response->Ptr(0));
+	else
+		ret = KErrGeneral;
+
+	CleanupStack::PopAndDestroy(response);
+	CleanupStack::PopAndDestroy(body);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::ListL
+ * get events either using time report or basic propfind
+ */
+TInt CCalDavEngine::ListL()
+	{
+	if (iOptions.calendar_access)
+		{
+		TTime syncstart;
+		syncstart.HomeTime();
+		syncstart = syncstart - iPastDays;
+		TBuf<100> nowStr;
+		syncstart.FormatL(nowStr, KFormatString);
+		TBuf8<100> nowStrAdd;
+		nowStrAdd.Append(nowStr);
+
+		TInt eventreturn = KErrNone;
+		if (iOptions.VEVENT)
+			eventreturn = TimeReportL(ETrue, nowStrAdd);
+
+		TInt todoreturn = KErrNone;
+		if (iOptions.VTODO)
+			todoreturn = TimeReportL(EFalse, nowStrAdd);
+
+		return (eventreturn == KErrNone) && (todoreturn == KErrNone) ? KErrNone
+				: KErrGeneral;
+		}
+	else
+		{
+		// use PROPFIND report
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt ret = iHttp->PropfindL(*iUrl, KPropList, response, EFalse);
+		if (ret == MULTISTATUS)
+			ret = ParseResponsesL(response->Ptr(0));
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(response);
+		return ret;
+		}
+	}
+
+/**
+ * CCalDavEngine::SyncL
+ * sync a calendar
+ */
+TInt CCalDavEngine::SyncL()
+	{
+	if (iUrl)
+		{
+		if (iOptions.sync_collection)
+			return WebDavSyncL();
+		else
+			return ManualSyncL();
+		}
+	return KErrGeneral;
+	}
+
+/**
+ * CCalDavEngine::ManualSyncL
+ * if sync failed previously, try again manually
+ */
+TBool CCalDavEngine::ManualSyncL()
+	{
+	TBool client = ClientChangesL();
+	if (iOptions.sync_ctag)
+		{
+		HBufC8 *newCTag = GetCTagL();
+		TBool server = ETrue;
+		if ((CTag() != *newCTag) && (*newCTag != KNullDesC8))
+			{
+			server = ServerChangesL();
+			if (server)
+				SetCTagL(newCTag);
+			else
+				delete newCTag;
+			}
+		else
+			delete newCTag;
+
+		return client || server;
+		}
+	else
+		{
+		TBool server = ServerChangesL();
+		return client || server;
+		}
+	}
+
+/**
+ * CCalDavEngine::ServerChangesL
+ * sync server changes
+ */
+TBool CCalDavEngine::ServerChangesL()
+	{
+	// loop over all server items to find new and modified entries
+	// uses either propfind or calendar-query
+	TInt ret = ListL();
+
+	// loop over all local items to find deleted ones on the server
+	LocalLoopL(ELoopActionDeleteLocal);
+
+	return ret == KErrNone;
+	}
+
+/**
+ * CCalDavEngine::LocalLoopL
+ * loop over local calendar store
+ */
+TInt CCalDavEngine::LocalLoopL(TLocalLoopAction aAction)
+	{
+	TBuf8<URLMAX> iter = iCalIter->FirstL();
+	TBuf8<URLMAX> url;
+	while (iter != KNullDesC8)
+		{
+		url.Append(*iUrl);
+		url.Append(iter);
+		url.Append(KIcs);
+		switch (aAction)
+			{
+			case ELoopActionDeleteLocal:
+				{
+				if (HeadL(iter) == NOTFOUND)
+					DeleteLocalEntryL(url);
+				break;
+				}
+			case ELoopActionFillArray:
+				{
+				RPointerArray<CCalEntry> entryArray;
+				CleanupClosePushL(entryArray);
+				iCalEntryView->FetchL(iter, entryArray);
+				if (entryArray.Count())
+					{
+					iLocalUidArray.Append(entryArray[0]->LocalUidL());
+					iGlobalUidArray.Append(entryArray[0]->UidL());
+					}
+				entryArray.ResetAndDestroy();
+				CleanupStack::PopAndDestroy(&entryArray);
+
+				break;
+				}
+			case ELoopActionUpload:
+				{
+				TInt pos = iGlobalUidArray.Find(iter);
+				if ((pos != KErrNotFound) && (iLocalUidArray.Count() > pos))
+					UploadEntryL(iLocalUidArray[pos],
+							MCalChangeCallBack2::EChangeAdd,
+							MCalChangeCallBack2::EChangeEntryAll);
+				break;
+				}
+			}
+		url.Delete(0, url.Length());
+		iter = iCalIter->NextL();
+		}
+	return KErrNone;
+	}
+
+/**
+ * CCalDavEngine::ParseResponsesDeleteL
+ * process a recieved multistatus response
+ */
+TInt CCalDavEngine::ParseResponsesDeleteL(const TDesC8 &aDocument)
+	{
+	TInt ret = KErrNone;
+	RXmlEngDocument document = iDomParser.ParseL(aDocument);
+	CleanupClosePushL(document);
+	if (document.NotNull())
+		{
+		// this method works for response as well as sync-response
+		// do not use GetElementsByTagNameL for one specific responses directly	
+		TXmlEngElement ResponseListTop;
+		SearchL(document, KMultistatus, KNullDesC8, ResponseListTop);
+
+		RXmlEngNodeList<TXmlEngNode> ResponseList;
+		CleanupClosePushL(ResponseList);
+		ResponseListTop.GetChildNodes(ResponseList);
+
+		while (ResponseList.HasNext())
+			{
+			TXmlEngNode node = ResponseList.Next();
+			if (node.NodeType() == TXmlEngNode::EElement)
+				{
+				TPtrC8 href = SearchL(node, KHref, KNullDesC8);
+				// don't do anything with home itself
+				if ((href.Right(KIcs().Length()) == KIcs))
+					{
+					if (!DoesEntryExistL(href))
+						DeleteEntryL(href);
+					}
+				}
+			}
+		CleanupStack::PopAndDestroy(&ResponseList);
+
+		}
+	else
+		ret = KErrArgument;
+	CleanupStack::PopAndDestroy(&document);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::ParseResponsesL
+ * process a recieved multistatus response
+ */
+TInt CCalDavEngine::ParseResponsesL(RXmlEngDocument &aDocument, TBool aMultiget)
+	{
+	TInt ret = KErrNone;
+	if (aDocument.NotNull())
+		{
+		CDesC8ArrayFlat *multiget = NULL;
+		if (iOptions.MULTIGET)
+			{
+			multiget = new (ELeave) CDesC8ArrayFlat(ARRAYEXPAND);
+			CleanupStack::PushL(multiget);
+			}
+
+		// this method works for response as well as sync-response
+		// do not use GetElementsByTagNameL for one specific responses directly	
+		TXmlEngElement ResponseListTop;
+		SearchL(aDocument, KMultistatus, KNullDesC8, ResponseListTop);
+
+		RXmlEngNodeList<TXmlEngNode> ResponseList;
+		CleanupClosePushL(ResponseList);
+		ResponseListTop.GetChildNodes(ResponseList);
+
+		while (ResponseList.HasNext())
+			{
+			TXmlEngNode node = ResponseList.Next();
+			if (node.NodeType() == TXmlEngNode::EElement)
+				{
+				TPtrC8 href = SearchL(node, KHref, KNullDesC8);
+				//do not use Search, only looking for first childs,
+				//as D:propstat has D:status as well
+				RXmlEngNodeList<TXmlEngElement> statuslist;
+				CleanupClosePushL(statuslist);
+				node.AsElement().GetElementsByTagNameL(statuslist, KStatus,
+						KDav);
+				//only one or zero item
+				HBufC8* status =
+						statuslist.Count() ? statuslist.Next().Value().AllocL()
+								: KNullDesC8().AllocL();
+				CleanupStack::PopAndDestroy(&statuslist);
+				CleanupStack::PushL(status);
+				status->Des().LowerCase();
+				TPtrC8 etag = SearchL(node, KEtag, KNullDesC8);
+				RBuf8 calendardata;
+				SearchL(node, KCalendarData, KNullDesC8, calendardata);
+				calendardata.CleanupClosePushL();
+
+				// don't do anything with home itself
+				if (href.Right(KIcs().Length()) == KIcs)
+					{
+					if ((*status == KHTTP200) || (*status == KHTTP201) || (*status == KNullDesC8))
+						{
+						if ((calendardata == KNullDesC8))
+							{
+							if (aMultiget)
+								{
+								// ATTENTION: an empty response to a multiget should never happen
+								// data wrapped inside CDATA, e.g. bedework ??
+								}
+							else
+								//TOOD: if this is a webdav sync response, we should skip the etag check
+								AddModifyLocalEntryL(href, etag, multiget);
+							}
+						else
+							{
+							// response to a multiget or time-range report, we now already have everything we need
+							StoreEntryL(calendardata, etag);
+							}
+						}
+					else if (*status == KHTTP404)
+						{
+						if (iOptions.sync_collection)
+							{
+							// if this is an initial sync without token, 
+							// this should be ignored, Sun Server bug!!!
+							if (SyncToken() != KNullDesC8)
+								DeleteLocalEntryL(href);
+							}
+						else
+							{
+							//multiget answer, but deleted in the meantime, should delete locally as well
+							DeleteLocalEntryL(href);
+							}
+						}
+					}
+				CleanupStack::PopAndDestroy(&calendardata);
+				CleanupStack::PopAndDestroy(status);
+				}
+			}
+		CleanupStack::PopAndDestroy(&ResponseList);
+
+		if (iOptions.MULTIGET)
+			{
+			if (multiget->Count())
+				{
+				DownloadEntryL(multiget);
+				multiget->Reset();
+				}
+			CleanupStack::PopAndDestroy(multiget);
+			}
+		}
+	else
+		ret = KErrArgument;
+
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::ParseResponsesL
+ * process a recieved multistatus response
+ */
+TInt CCalDavEngine::ParseResponsesL(const TDesC8 &aDocument, TBool aMultiget)
+	{
+#ifdef _DEBUG
+	_LIT(KFilename,"c:\\logs\\caldav\\parseresonseslatest.txt");
+	ExportToFileNameL(aDocument, KFilename);
+#endif
+
+	RXmlEngDocument document = iDomParser.ParseL(aDocument);
+	CleanupClosePushL(document);
+	TInt ret = ParseResponsesL(document, aMultiget);
+	CleanupStack::PopAndDestroy(&document);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::StoreEntryL
+ * store event in local store
+ */
+#ifdef ETAG
+TInt CCalDavEngine::StoreEntryL(const TDesC8 &aBuf, const TDesC8 &aEtag)
+#else
+TInt CCalDavEngine::StoreEntryL(const TDesC8 &aBuf, const TDesC8 &/*aEtag*/)
+#endif
+	{
+#ifdef _DEBUG
+	_LIT(KFileName2, "C:\\logs\\caldav\\testing_import.txt");
+	ExportToFileNameL(aBuf, KFileName2);
+#endif
+
+	HBufC8* buffer = HBufC8::NewL(aBuf.Length() + 500);
+	buffer->Des().Append(aBuf);
+	TPtr8 ptr = buffer->Des();
+	CalDavUtils::FixImportIssues(ptr);
+
+	RPointerArray<CCalEntry> Array;
+	CleanupClosePushL(Array);
+	RDesReadStream ReadStream;
+	ReadStream.Open(ptr);
+	CleanupClosePushL(ReadStream);
+#ifdef _DEBUG
+	_LIT(KFileName, "C:\\logs\\caldav\\testing_import_fixed.txt");
+	ExportToFileNameL(ptr, KFileName);
+#endif
+	TRAPD(error, iCalImporter->ImportICalendarL(ReadStream,Array));
+	CleanupStack::PopAndDestroy(&ReadStream); // calls close on rSteam												
+	if ((error == KErrNone) && (Array.Count()))
+		{
+		iCalIntermimUtils2->StoreL(*iCalEntryView, *Array[0], ETrue); // or should last one be EFalse??
+		TInt pos = iLocalUidArray.Find(Array[0]->LocalUidL());
+		if (pos == KErrNotFound)
+			{
+			iLocalUidArray.Append(Array[0]->LocalUidL());
+			iGlobalUidArray.Append(Array[0]->UidL());
+			}
+#ifdef ETAG
+		Array[0]->SetETag(aEtag);
+#endif
+		}
+	Array.ResetAndDestroy();
+	CleanupStack::PopAndDestroy(&Array);
+
+	delete buffer;
+	return error;
+	}
+
+/**
+ * CCalDavEngine::WebDavSyncReportL
+ * webdav sync report
+ * http://tools.ietf.org/html/draft-daboo-webdav-sync-02
+ */
+TInt CCalDavEngine::WebDavSyncReportL(TBool aSynctoken)
+	{
+	HBufC8 *Buf = HBufC8::NewL(KSync().Length() + SyncToken().Length());
+	TPtrC8 token = SyncToken();
+	if (aSynctoken)
+		Buf->Des().Format(KSync, &token);
+	else
+		Buf->Des().Format(KSync, &KNullDesC8());
+	CleanupStack::PushL(Buf);
+
+	CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_BIG);
+	CleanupStack::PushL(response);
+	TInt ret = iHttp->ReportL(*iUrl, *Buf, response);
+
+	if (ret == MULTISTATUS)
+		{
+		RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+		CleanupClosePushL(document);
+		if (document.NotNull())
+			{
+			TPtrC8 Token = SearchL(document, KSynctoken, KNullDesC8);
+			if ((Token != KNullDesC8) && (Token != SyncToken()))
+				{
+				ret = ParseResponsesL(document);
+				//store newest token
+				if (ret == KErrNone)
+					SetSyncTokenL(Token.AllocL());
+				}
+			else
+				ret = KErrNone;
+			}
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(&document);
+		}
+	CleanupStack::PopAndDestroy(response);
+	CleanupStack::PopAndDestroy(Buf);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::WebDavSyncL
+ * sync using webdav sync
+ * http://tools.ietf.org/html/draft-daboo-webdav-sync-02
+ */
+TBool CCalDavEngine::WebDavSyncL()
+	{
+	if (iHttp)
+		{
+		// commit any left over client changes
+		TBool RetClient = ClientChangesL();
+		// get all changes from server
+		TInt ret = WebDavSyncReportL(ETrue);
+		if (ret == CONFLICT)
+			ret = WebDavSyncReportL(EFalse);
+		return (ret == KErrNone) && RetClient;
+		}
+	return EFalse;
+	}
+
+/**
+ * CCalDavEngine::GetUIDByUrl
+ * parse url to find UID
+ */
+TPtrC8 CCalDavEngine::GetUIDByUrl(const TDesC8 &aUrl)
+	{
+	TPtrC8 UID;
+	TInt Pos = aUrl.LocateReverse('/');
+	TInt Pos2 = aUrl.Find(KIcs);
+
+	if ((Pos != KErrNotFound) && (Pos2 != KErrNotFound))
+		UID.Set(aUrl.Mid(Pos + 1, Pos2 - Pos - 1));
+	else
+		{
+		if (Pos != KErrNotFound)
+			UID.Set(aUrl.Mid(Pos + 1, aUrl.Length() - Pos - 1));
+		else if (Pos2 != KErrNotFound)
+			UID.Set(aUrl.Left(aUrl.Length() - KIcs().Length()));
+		else
+			UID.Set(aUrl);
+		}
+
+	return UID;
+	}
+
+/**
+ * CCalDavEngine::DoesEntryExistL
+ * check if entry exists in local store
+ */
+unsigned long CCalDavEngine::DoesEntryExistL(const TDesC8 &aUrl)
+	{
+	// check if we already have it locally by uid
+	RPointerArray<CCalEntry> entryArray;
+	CleanupClosePushL(entryArray);
+	iCalEntryView->FetchL(GetUIDByUrl(aUrl), entryArray);
+	// get parent 
+	CCalEntry *entry = entryArray.Count() ? entryArray[0] : NULL;
+	TInt ret = entry ? entry->LocalUidL() : 0;
+	entryArray.ResetAndDestroy();
+	CleanupStack::PopAndDestroy(&entryArray);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::ETagMatchL
+ * checks for equal ETag
+ */
+TBool CCalDavEngine::ETagMatchL(const TDesC8& /*aUrl*/, const TDesC8& /*aETag*/)
+	{
+#ifdef ETAG
+	// check if we already have it locally by uid
+	RPointerArray<CCalEntry> entryArray;
+	CleanupClosePushL(entryArray);
+	iCalEntryView->FetchL(GetUIDByUrl(aUrl), entryArray);
+	// get parent 
+	CCalEntry *entry = entryArray.Count() ? entryArray[0] : NULL;
+	TBool ret = entry ? entry->ETag() == aETag : EFalse;
+	entryArray.ResetAndDestroy();
+	CleanupStack::PopAndDestroy(&entryArray);
+	return ret;
+#else
+	return EFalse;
+#endif
+	}
+
+/**
+ * CCalDavEngine::AddModifyLocalEntryL
+ * add or modify existing event
+ */
+TInt CCalDavEngine::AddModifyLocalEntryL(const TDesC8 &aUrl,
+		const TDesC8 &aETag, CDesC8ArrayFlat* aArray)
+	{
+	// check if we have the entry locally
+	// check for etag if we have the latest version, if not, download and import or add to multiget request
+	if (!ETagMatchL(aUrl, aETag))
+		{
+		if (aArray)
+			aArray->AppendL(aUrl);
+		else
+			DownloadEntryL(aUrl);
+		}
+	return KErrNone;
+	}
+
+/**
+ * CCalDavEngine::DownloadEntryL
+ * download entries using multiget from server
+ */
+TInt CCalDavEngine::DownloadEntryL(CDesC8Array* aArray)
+	{
+	TInt ret = KErrNone;
+	TInt64 remainder;
+	TInt64 result = Math::DivMod64(aArray->Count(), MULTIGETSPLIT, remainder);
+
+	// split large multigets request into several smaller ones
+	for (TInt64 l = 0; l <= result; l++)
+		{
+		// do the multiget request and pass it to parserepsonses again to read in the data
+		CBufFlat* body = CBufFlat::NewL(EXPANDSIZE_BIG);
+		CleanupStack::PushL(body);
+
+		body->InsertL(body->Size(), KMultistart);
+		for (TInt64 i = 0; i <= ((l == result) ? remainder - 1 : MULTIGETSPLIT
+				- 1); i++)
+			{
+			body->InsertL(body->Size(), KHrefstart);
+			body->InsertL(body->Size(), (*aArray)[MULTIGETSPLIT * l + i]);
+			body->InsertL(body->Size(), KHrefend);
+			}
+		body->InsertL(body->Size(), KMultiend);
+
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_BIG);
+		CleanupStack::PushL(response);
+		TInt Return = iHttp->ReportL(*iUrl, body->Ptr(0), response);
+
+		if (Return == MULTISTATUS)
+			{
+			TInt parsereturn = ParseResponsesL(response->Ptr(0), ETrue);
+			// if it failed before, we do not want to override this error
+			ret = (ret == KErrNone) ? parsereturn : ret;
+			}
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(response);
+		CleanupStack::PopAndDestroy(body);
+
+		}
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::DownloadEntryL
+ * download entry from server
+ */
+TInt CCalDavEngine::DownloadEntryL(const TDesC8 &aUrl)
+	{
+	TBuf8<URLMAX> url;
+	url.Append(*iUrl);
+	url.Append(GetUIDByUrl(aUrl));
+	url.Append(KIcs);
+
+	CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+	CleanupStack::PushL(response);
+	TInt ret = iHttp->GetL(url, response);
+	if (ret == OK)
+		ret = StoreEntryL(response->Ptr(0), iHttp->ETag());
+	else
+		ret = KErrGeneral;
+	CleanupStack::PopAndDestroy(response);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::DeleteLocalEntryL
+ * delete an event from local store
+ */
+TInt CCalDavEngine::DeleteLocalEntryL(const TDesC8 &aUID)
+	{
+	CDesC8ArrayFlat * Array = new (ELeave) CDesC8ArrayFlat(ARRAYEXPAND);
+	CleanupStack::PushL(Array);
+	Array->AppendL(GetUIDByUrl(aUID));
+	// we could have delete it ourselves, so it is already gone
+	TRAPD(error, iCalEntryView->DeleteL(*Array));
+	Array->Reset();
+	CleanupStack::PopAndDestroy(Array);
+	return error;
+	}
+
+/**
+ * CCalDavEngine::DeleteRemovedEntriesOnServerL
+ * check for removed entries on server
+ */
+TInt CCalDavEngine::DeleteRemovedEntriesOnServerL()
+	{
+	if (iOptions.calendar_access)
+		{
+		TTime syncstart;
+		syncstart.HomeTime();
+		syncstart = syncstart - iPastDays;
+		TBuf<100> nowStr;
+		syncstart.FormatL(nowStr, KFormatString);
+		TBuf8<100> nowStrAdd;
+		nowStrAdd.Append(nowStr);
+
+		TInt eventreturn = KErrNone;
+		if (iOptions.VEVENT)
+			eventreturn = TimeReportL(ETrue, nowStrAdd, ETrue);
+
+		TInt todoreturn = KErrNone;
+		if (iOptions.VTODO)
+			todoreturn = TimeReportL(EFalse, nowStrAdd, ETrue);
+
+		return (eventreturn == KErrNone) && (todoreturn == KErrNone) ? KErrNone
+				: KErrGeneral;
+		}
+	else
+		{
+		// use PROPFIND report
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt ret = iHttp->PropfindL(*iUrl, KPropList, response, EFalse);
+		if (ret == MULTISTATUS)
+			ret = ParseResponsesDeleteL(response->Ptr(0));
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(response);
+		return ret;
+		}
+
+	}
+
+/**
+ * CCalDavEngine::UploadModifiedSinceDateL
+ * check for any modified data after last sync time
+ */
+TBool CCalDavEngine::UploadModifiedSinceDateL()
+	{
+	TBool manualsync = EFalse;
+	// upload modified and newly create ones 
+	RArray<TCalLocalUid> *Ids = new (ELeave) RArray<TCalLocalUid> (ARRAYEXPAND);
+	iCalEntryView->GetIdsModifiedSinceDateL(iLastSyncTime, *Ids);
+	for (TInt i = 0; i < Ids->Count(); i++)
+		{
+		TCalLocalUid id = (*Ids)[i];
+		TInt ret = UploadEntryL(id, MCalChangeCallBack2::EChangeUndefined,
+				MCalChangeCallBack2::EChangeEntryAll);
+		// TOOD: if it fails during upload, ignore
+		// if it fails due to internet connection, try again
+		if (ret != KErrNone)
+			manualsync = ETrue;
+		}
+	Ids->Reset();
+	delete Ids;
+	return manualsync;
+	}
+
+/**
+ * CCalDavEngine::ClientChangesL
+ * check for left over local client changes
+ */
+TBool CCalDavEngine::ClientChangesL()
+	{
+	if (iCalEntryView && iManualSync)
+		{
+		iManualSync = EFalse;
+
+		// upload modified and newly create ones 
+		iManualSync = UploadModifiedSinceDateL();
+
+		// delete locally deleted entries on server 
+		for (TInt i = iDeletedEntries.Count() - 1; i >= 0; --i)
+			{
+			TInt ret = DeleteEntryL(iDeletedEntries[i]);
+			if (ret == KErrNone)
+				iDeletedEntries.Remove(i);
+
+			}
+
+		iManualSync = iDeletedEntries.Count() ? ETrue : EFalse;
+
+		TPckgC<TBool> manualSync(iManualSync);
+		SetCalendarInfoL(KCaldavManualSync, manualSync);
+		}
+
+	return ETrue;
+	}
+
+/**
+ * CCalDavEngine::MkcalendarL
+ * create a new calendar on the server
+ */
+TInt CCalDavEngine::MkcalendarL(const TDesC8 &aName)
+	{
+	if (iOptions.MKCALENDAR)
+		{
+		TBuf8<URLMAX> url;
+		url.Append(*iHome);
+		url.Append(aName);
+		url.Append(KSlash);
+
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+
+		// TOOD: initialize with name, body etc.
+		TInt ret = iHttp->MkCalendarL(url, KNullDesC8, response);
+
+		if ((ret == CREATED) || (ret == OK))
+			ret = KErrNone;
+		else if ((ret == NOTALLOWED) || (ret == FORBIDDEN))
+			ret = KErrArgument;
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(response);
+		return ret;
+		}
+	else
+		return KErrNotSupported;
+	}
+
+/**
+ * CCalDavEngine::DeleteCalendarL
+ * delete a calendar on the server
+ */
+TInt CCalDavEngine::DeleteCalendarL(const TDesC8 &aName)
+	{
+	if (iOptions.MKCALENDAR)
+		{
+		TBuf8<URLMAX> url;
+		url.Append(*iHome);
+		url.Append(aName);
+		url.Append(KSlash);
+
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt ret = iHttp->DeleteL(url);
+		if ((ret == NOCONTENT) || (ret == OK))
+			ret = KErrNone;
+		else
+			ret = KErrGeneral;
+		CleanupStack::PopAndDestroy(response);
+		return ret;
+		}
+	else
+		return KErrNotSupported;
+	}
+
+/**
+ * CCalDavEngine::HeadL
+ * check for existence of an entry on server
+ */
+TInt CCalDavEngine::HeadL(const TDesC8 &aUID)
+	{
+	// special handing for yahoo neccessary
+	// after deleting an event, it is still there and findable with HEAD
+	_LIT8(KYahoo,"yahoo");
+	_LIT8(KTrash,"trash");
+
+	TBuf8<URLMAX> url;
+	url.Append(*iUrl);
+	url.Append(aUID);
+	url.Append(KIcs);
+	if (iUrl->Find(KYahoo) == KErrNotFound)
+		{
+		TInt head = iHttp->HeadL(url);
+		return (head == NOCONTENT) || (head == OK) ? OK : head;
+		}
+	else
+		{
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt ret = iHttp->PropfindL(url, KNullDesC8, response);
+
+		if (ret == MULTISTATUS)
+			{
+			RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+			CleanupClosePushL(document);
+			if (document.NotNull())
+				{
+				HBufC8* href = SearchL(document, KHref, KNullDesC8).AllocL();
+				href->Des().LowerCase();
+				ret = href->Find(KTrash) == KErrNotFound ? OK : NOTFOUND;
+				delete href;
+				}
+			CleanupStack::PopAndDestroy(&document);
+			CleanupStack::PopAndDestroy(response);
+			return ret;
+			}
+		else
+			{
+			CleanupStack::PopAndDestroy(response);
+			return NOTFOUND;
+			}
+		}
+	}
+
+/**
+ * CCalDavEngine::DeleteEntryL
+ * delete entry on server
+ */
+TInt CCalDavEngine::DeleteEntryL(const TDesC8 &aUid)
+	{
+	TBuf8<URLMAX> url;
+	url.Append(*iBaseUrl);
+	url.Append(aUid);
+	return iHttp->DeleteL(url);
+	}
+
+/**
+ * CCalDavEngine::DeleteEntryL
+ * delete entry on server
+ */
+TInt CCalDavEngine::DeleteEntryL(const TCalLocalUid &aUid)
+	{
+	TInt Ret = KErrNone;
+	// find the filename for a given local UID
+	TInt aPos = iLocalUidArray.Find(aUid);
+	if (aPos != KErrNotFound)
+		{
+		TBuf8<URLMAX> url;
+		url.Append(*iUrl);
+		url.Append(iGlobalUidArray[aPos]);
+		url.Append(KIcs);
+
+#ifdef ETAG
+		CCalEntry* entry = iCalEntryView->FetchL(aUid);
+		CleanupStack::PushL(entry);
+		TInt Return = entry ? iHttp->DeleteL(url, entry->ETag())
+		: iHttp->DeleteL(url);
+		CleanupStack::PopAndDestroy(entry);
+#else
+		TInt Return = iHttp->DeleteL(url);
+#endif
+
+		if ((Return == NOCONTENT) || (Return == OK))
+			{
+			SetLastSyncTimeL();
+			}
+		else if (Return == PRECONDFAILED)
+			{
+			// someone modified this in the meantime
+			// ask user if he wants the new event or still delete it
+			TBool modify = EFalse;
+			if (modify)
+				DownloadEntryL(url);
+			else
+				iHttp->DeleteL(url);
+			}
+		else if (Return == NOTFOUND)
+			{
+			// someone deleted this already
+			Ret = KErrGeneral;
+			}
+		else if (Return == FORBIDDEN)
+			{
+			// event read-only
+			Ret = KErrGeneral;
+			}
+		else
+			{
+			Ret = KErrGeneral;
+			SyncFailedL();
+			TInt pos = iDeletedEntries.Find(aUid);
+			if (pos == KErrNotFound)
+				iDeletedEntries.Append(aUid);
+			}
+		}
+	else
+		Ret = KErrGeneral;
+	return Ret;
+	}
+
+/**
+ * CCalDavEngine::UploadEntryL
+ * upload entry to server
+ */
+TInt CCalDavEngine::UploadEntryL(CCalEntry* aEntry,
+		MCalChangeCallBack2::TChangeType aChangeType,
+		MCalChangeCallBack2::TChangeEntryType aEntryType)
+	{
+	if (aEntry)
+		{
+		TInt ret = KErrNone;
+		TBool upload = EFalse;
+		switch (aEntryType)
+			{
+			case MCalChangeCallBack2::EChangeEntryEvent:
+			case MCalChangeCallBack2::EChangeEntryTodo:
+				{
+				upload = aEntry && ((MCalChangeCallBack2::EChangeEntryEvent
+						&& iOptions.VEVENT)
+						|| (MCalChangeCallBack2::EChangeEntryTodo
+								&& iOptions.VTODO));
+				break;
+				}
+			case MCalChangeCallBack2::EChangeEntryAll:
+				{
+				if (aEntry)
+					{
+					switch (aEntry->EntryTypeL())
+						{
+						case CCalEntry::EAppt:
+						case CCalEntry::EAnniv:
+						case CCalEntry::EEvent:
+						case CCalEntry::EReminder:
+							{
+							upload = iOptions.VEVENT;
+							break;
+							}
+						case CCalEntry::ETodo:
+							{
+							upload = iOptions.VTODO;
+							break;
+							}
+						}
+					}
+
+				}
+			}
+		if (upload)
+			{
+			CBufFlat* BufFlat = CBufFlat::NewL(EXPANDSIZE_SMALL);
+			CleanupStack::PushL(BufFlat);
+			RBufWriteStream writeStream(*BufFlat);
+			CleanupClosePushL(writeStream);
+			iCalExporter->ExportICalL(*aEntry, writeStream);
+			writeStream.CommitL();
+			CleanupStack::PopAndDestroy(&writeStream);
+
+			HBufC8* buffer = BufFlat->Ptr(0).AllocL();
+			CleanupStack::PopAndDestroy(BufFlat);
+			CleanupStack::PushL(buffer);
+			TPtr8 ptr = buffer->Des();
+			CalDavUtils::FixExportIssues(ptr);
+
+#ifdef _DEBUG
+			ExportToFileL(aEntry, iCalExporter);
+			_LIT(KFileName, "C:\\logs\\caldav\\testing_export_fixed.txt");
+			ExportToFileNameL(ptr, KFileName);
+#endif
+
+			TBuf8<URLMAX> url;
+			url.Append(*iUrl);
+			url.Append(aEntry->UidL());
+			url.Append(KIcs);
+
+			CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+			CleanupStack::PushL(response);
+
+#ifdef ETAG
+			TPtrC8 etag = aEntry->GetETag();
+			TBool newentry = (aChangeType == MCalChangeCallBack2::EChangeAdd)
+			|| ((aChangeType == MCalChangeCallBack2::EChangeUndefined)
+					&& (etag == KNullDesC8));
+			TInt Ret = newentry ? iHttp->PutL(url, *buffer, response)
+			: iHttp->PutL(url, *buffer, response, etag);
+#else
+			TBool newentry = (aChangeType == MCalChangeCallBack2::EChangeAdd)
+					|| (aChangeType == MCalChangeCallBack2::EChangeUndefined);
+			TInt Ret = newentry ? iHttp->PutL(url, *buffer, response)
+					: iHttp->PutL(url, *buffer, response, _L8("ETAG"));
+#endif
+			if ((Ret == CREATED) || (Ret == NOCONTENT) || (Ret == OK))
+				{
+				if (newentry)
+					{
+					iLocalUidArray.Append(aEntry->LocalUidL());
+					iGlobalUidArray.Append(aEntry->UidL());
+					}
+#ifdef ETAG
+				aEntry->SetETag(iHttp->ETag());
+#endif
+				SetLastSyncTimeL();
+				}
+			else if (Ret == PRECONDFAILED)
+				{
+				if (newentry)// same filename already exists, use a different one and upload again
+					{
+					TBuf8<URLMAX> nextUrl;
+					nextUrl.Append(*iUrl);
+					nextUrl.Append(aEntry->UidL());
+					TTime time;
+					time.HomeTime();
+					_LIT(KTimeFormat,"%H%T%S");
+					TBuf<20> StringTime;
+					time.FormatL(StringTime, KTimeFormat);
+					nextUrl.Append(StringTime);
+					nextUrl.Append(_L8(".ics"));
+					response->Reset();
+					TInt Ret = iHttp->PutL(nextUrl, *buffer, response);
+					if ((Ret == CREATED) || (Ret == OK))
+						{
+						iLocalUidArray.Append(aEntry->LocalUidL());
+						iGlobalUidArray.Append(aEntry->UidL());
+#ifdef ETAG
+						aEntry->SetETag(iHttp->ETag());
+#endif
+						SetLastSyncTimeL();
+						}
+					else
+						{
+						SyncFailedL();
+						ret = KErrAbort;
+						}
+					}
+				else
+					{
+					if (!iKeepServerEntry)
+						{
+						response->Reset();
+						// upload again without ETAG to overwrite server entry
+						TInt Ret = iHttp->PutL(url, *buffer, response);
+						if ((Ret == CREATED) || (Ret == OK))
+							{
+#ifdef ETAG
+							aEntry->SetETag(iHttp->ETag());
+#endif
+							SetLastSyncTimeL();
+							}
+						else
+							{
+							SyncFailedL();
+							ret = KErrAbort;
+							}
+						}
+					else
+						{
+						// download the server event and update local store
+						ret = DownloadEntryL(url);
+						if (ret == KErrNone)
+							SetLastSyncTimeL();
+						else
+							{
+							SyncFailedL();
+							ret = KErrAbort;
+							}
+						}
+					}
+				}
+			else
+				{
+				SyncFailedL();
+				ret = KErrAbort;
+				}
+			CleanupStack::PopAndDestroy(response);
+			CleanupStack::PopAndDestroy(buffer);
+			}
+		return ret;
+		}
+	return KErrArgument;
+	}
+
+/**
+ * CCalDavEngine::UploadEntryL
+ * upload entry to server
+ */
+TInt CCalDavEngine::UploadEntryL(const TCalLocalUid &aUid,
+		MCalChangeCallBack2::TChangeType aChangeType,
+		MCalChangeCallBack2::TChangeEntryType aEntryType)
+	{
+	CCalEntry * aEntry = iCalEntryView->FetchL(aUid);
+	CleanupStack::PushL(aEntry);
+	TInt ret = UploadEntryL(aEntry, aChangeType, aEntryType);
+	CleanupStack::PopAndDestroy(aEntry);
+	return ret;
+	}
+
+/**
+ * CCalDavEngine::GetSyncTokenL
+ * get latest Webdav Sync token
+ */
+HBufC8* CCalDavEngine::GetSyncTokenL()
+	{
+	HBufC8 *aBuf = HBufC8::NewL(KSync().Length());
+	aBuf->Des().Format(KSync, &KNullDesC8());
+	CleanupStack::PushL(aBuf);
+
+	CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+	CleanupStack::PushL(response);
+	TInt RetServer = iHttp->ReportL(*iUrl, *aBuf, response);
+
+	if (RetServer)
+		{
+		RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+		CleanupClosePushL(document);
+		if (document.NotNull())
+			{
+			HBufC8* ret = SearchL(document, KSynctoken, KNullDesC8).AllocL();
+			CleanupStack::PopAndDestroy(&document);
+			CleanupStack::PopAndDestroy(response);
+			CleanupStack::PopAndDestroy(aBuf);
+			return ret;
+			}
+		CleanupStack::PopAndDestroy(&document);
+		}
+	CleanupStack::PopAndDestroy(response);
+	CleanupStack::PopAndDestroy(aBuf);
+	return KNullDesC8().AllocL();
+	}
+
+/**
+ * CCalDavEngine::CheckCalendarInfoL
+ * check for new calendar displayname and color
+ */
+void CCalDavEngine::CheckCalendarInfoL(RXmlEngDocument &aDocument)
+	{
+	TBool change = EFalse;
+	CCalCalendarInfo* info = iCalSession->CalendarInfoL();
+	CleanupStack::PushL(info);
+
+	HBufC8* color = SearchL(aDocument, KCalendar_Color, KNullDesC8).AllocLC();
+	if ((*color != KNullDesC8) && (color->Length() > 6))
+		{
+		TLex8 lexred(color->Des().Mid(1, 2));
+		TInt red;
+		lexred.Val(red);
+		TLex8 lexgreen(color->Des().Mid(3, 2));
+		TInt green;
+		lexgreen.Val(green);
+		TLex8 lexblue(color->Des().Mid(5, 2));
+		TInt blue;
+		lexblue.Val(blue);
+		TRgb newcolor(red, green, blue);
+		if (info->Color() != newcolor)
+			{
+			info->SetColor(newcolor);
+			change = ETrue;
+			}
+		}
+	CleanupStack::PopAndDestroy(color);
+
+	HBufC8* displayname =
+			SearchL(aDocument, KDisplayname, KNullDesC8).AllocLC();
+	if (*displayname != KNullDesC8)
+		{
+		HBufC16* name =
+				CnvUtfConverter::ConvertToUnicodeFromUtf8L(*displayname);
+		CleanupStack::PushL(name);
+		if (info->NameL() != *name)
+			{
+			info->SetNameL(*name);
+			change = ETrue;
+			}
+		CleanupStack::PopAndDestroy(name);
+		change = ETrue;
+		}
+	CleanupStack::PopAndDestroy(displayname);
+
+	if (change)
+		iCalSession->SetCalendarInfoL(*info);
+	CleanupStack::PopAndDestroy(info);
+
+	}
+
+/**
+ * CCalDavEngine::GetCTagL
+ * get latest CTag
+ * https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-ctag.txt
+ */
+HBufC8* CCalDavEngine::GetCTagL()
+	{
+	if (iHttp)
+		{
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt ret = iHttp->PropfindL(*iUrl, KCtag, response);
+
+		if (ret == MULTISTATUS)
+			{
+			RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+			CleanupClosePushL(document);
+			if (document.NotNull())
+				{
+				HBufC8* status =
+						SearchL(document, KStatus, KNullDesC8).AllocLC();
+				HBufC8* ctag =
+						SearchL(document, KGetctag, KNullDesC8).AllocLC();
+				status->Des().LowerCase();
+				if ((*ctag != KNullDesC8) && (*status == KHTTP200))
+					{
+					CleanupStack::Pop(ctag);
+					CleanupStack::PopAndDestroy(status);
+					CleanupStack::PopAndDestroy(&document);
+					CleanupStack::PopAndDestroy(response);
+					return ctag;
+					}
+				else
+					CleanupStack::PopAndDestroy(ctag);
+				CleanupStack::PopAndDestroy(status);
+				}
+			CleanupStack::PopAndDestroy(&document);
+
+			}
+		CleanupStack::PopAndDestroy(response);
+		}
+	return KNullDesC8().AllocL();
+	}
+
+/**
+ * CCalDavEngine::GetOptionsL
+ * get OPTIONS from server
+ */
+TBool CCalDavEngine::GetOptionsL()
+	{
+	if (iHttp)
+		{
+		// check DAV and allow headers
+		iHttp->GetServerOptionsL(*iUrl, iOptions);
+
+		// check ctag extension
+		HBufC8* ctag = GetCTagL();
+		if (*ctag != KNullDesC8)
+			iOptions.sync_ctag = true;
+		delete ctag;
+
+		// check supported elements
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt Ret = iHttp->PropfindL(*iUrl, KSupportedSet, response);
+
+		if (Ret == MULTISTATUS)
+			{
+			RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+			CleanupClosePushL(document);
+			if (document.NotNull())
+				{
+				CheckCalendarInfoL(document);
+
+				//<C:supported-calendar-component-set/>
+				TXmlEngElement supportedelement;
+				SearchL(document, KSupportedCalendarComponentSet, KNullDesC8,
+						supportedelement);
+				if (supportedelement.NotNull())
+					{
+					RXmlEngNodeList<TXmlEngElement> supportedelements;
+					CleanupClosePushL(supportedelements);
+					supportedelement.GetChildElements(supportedelements);
+					while (supportedelements.HasNext())
+						{
+						TXmlEngElement element = supportedelements.Next();
+						TPtrC8 value = element.AttributeValueL(KName);
+						if (value == KNullDesC8)
+							value.Set(element.AttributeValueL(KName, KCalDav));
+						if (value == KVEVENT)
+							iOptions.VEVENT = ETrue;
+						else if (value == KVTODO)
+							iOptions.VTODO = ETrue;
+						else if (value == KVFREBUSY)
+							iOptions.VFREEBUSY = ETrue;
+						else if (value == KVJOURNAL)
+							iOptions.VJOURNAL = ETrue;
+						}
+					CleanupStack::PopAndDestroy(&supportedelements);
+					}
+				}
+			CleanupStack::PopAndDestroy(&document);
+			}
+		CleanupStack::PopAndDestroy(response);
+		}
+	return ETrue;
+	}
+
+/**
+ * CCalDavEngine::SetSyncTokenL
+ * set sync token
+ */
+void CCalDavEngine::SetSyncTokenL(HBufC8* aToken)
+	{
+	if (iSynctoken)
+		{
+		delete iSynctoken;
+		iSynctoken = NULL;
+		}
+	iSynctoken = aToken;
+	SetCalendarInfoL(KCaldavSynctoken, *iSynctoken);
+	}
+
+/**
+ * CCalDavEngine::SyncToken
+ * get synctoken
+ */
+TPtrC8 CCalDavEngine::SyncToken()
+	{
+	return iSynctoken ? *iSynctoken : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngine::SetCTagL
+ * set ctag
+ */
+void CCalDavEngine::SetCTagL(HBufC8* aToken)
+	{
+	if (iCTag)
+		{
+		delete iCTag;
+		iCTag = NULL;
+		}
+	iCTag = aToken;
+	SetCalendarInfoL(KCaldavCtag, *iCTag);
+	}
+
+/**
+ * CCalDavEngine::CTag
+ * get ctag
+ */
+TPtrC8 CCalDavEngine::CTag()
+	{
+	return iCTag ? *iCTag : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngine::SetLastSyncTimeL
+ * set last sync time
+ */
+void CCalDavEngine::SetLastSyncTimeL()
+	{
+	// only set a new last sync time, if we did not have a failed one before
+	// otherwise, the old one would be lost
+	if (!iManualSync)
+		{
+		TTime time;
+		time.UniversalTime();
+		iLastSyncTime.SetTimeUtcL(time);
+		TPckgC<TCalTime> lasttime(iLastSyncTime);
+		SetCalendarInfoL(KCaldavTime, lasttime);
+		}
+	}
+
+/**
+ * CCalDavEngine::SyncFailedL
+ * sync failed, enable manual sync
+ */
+void CCalDavEngine::SyncFailedL()
+	{
+	if (!iManualSync)
+		{
+		iManualSync = ETrue;
+		TPckgC<TBool> manualSync(iManualSync);
+		SetCalendarInfoL(KCaldavManualSync, manualSync);
+		}
+	}
+
+/**
+ * CCalDavEngine::GetBaseUrl
+ * get base domain url
+ */
+void CCalDavEngine::GetBaseUrl(const TDesC8 &aUrl)
+	{
+	_LIT8(http,"http://");
+	_LIT8(https,"https://");
+
+	if (iBaseUrl)
+		{
+		delete iBaseUrl;
+		iBaseUrl = NULL;
+		}
+
+	if (aUrl.Length() > http().Length())
+		{
+		TInt length = aUrl.Find(https) != KErrNotFound ? https().Length()
+				: http().Length();
+		TInt pos = aUrl.Mid(length).Locate('/');
+		iBaseUrl = aUrl.Left(pos + length).Alloc();
+		}
+	}
+
+/**
+ * CCalDavEngine::FindUrlsL
+ * find home, inbox and outbox property
+ */
+void CCalDavEngine::FindUrlsL(const TDesC8 &aDes, HBufC8 *&home,
+		HBufC8 *&inbox, HBufC8 *&outbox)
+	{
+	RXmlEngDocument document = iDomParser.ParseL(aDes);
+	CleanupClosePushL(document);
+	if (document.NotNull())
+		{
+		HBufC8* status = SearchL(document, KStatus, KNullDesC8).AllocLC();
+		status->Des().LowerCase();
+		if (*status == KHTTP200)
+			{
+			TXmlEngElement calendarhome, inboxhome, outboxhome;
+
+			SearchL(document, KCalendarHomeSet, KNullDesC8, calendarhome);
+			if (calendarhome.NotNull())
+				{
+				TPtrC8 homeend = SearchL(calendarhome, KHref, KNullDesC8);
+				home = HBufC8::NewL(iBaseUrl->Length() + homeend.Length());
+				home->Des().Append(*iBaseUrl);
+				home->Des().Append(homeend);
+				}
+
+			SearchL(document, KInbox, KNullDesC8, inboxhome);
+			if (inboxhome.NotNull())
+				{
+				TPtrC8 inboxend = SearchL(inboxhome, KHref, KNullDesC8);
+				inbox = HBufC8::NewL(iBaseUrl->Length() + inboxend.Length());
+				inbox->Des().Append(*iBaseUrl);
+				inbox->Des().Append(inboxend);
+				}
+
+			SearchL(document, KOutbox, KNullDesC8, outboxhome);
+			if (outboxhome.NotNull())
+				{
+				TPtrC8 outboxend = SearchL(outboxhome, KHref, KNullDesC8);
+				outbox = HBufC8::NewL(iBaseUrl->Length() + outboxend.Length());
+				outbox->Des().Append(*iBaseUrl);
+				outbox->Des().Append(outboxend);
+				}
+			}
+		CleanupStack::PopAndDestroy(status);
+		}
+	CleanupStack::PopAndDestroy(&document);
+	}
+
+/**
+ * CCalDavEngine::FindCalendarCollectionL
+ * find all calendar collections under home url
+ */
+HBufC8* CCalDavEngine::FindCalendarCollectionL(const TDesC8 &aUrl,
+		CDesC8ArrayFlat *aArray)
+	{
+	HBufC8* homecalendar = 0;
+
+	// do propfind depth:1 and find all calendar collections
+	// right now, take the first one as default
+	CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+	CleanupStack::PushL(response);
+	TInt retcode = iHttp->PropfindL(aUrl, KCalendarurl, response, EFalse);
+	if (retcode == MULTISTATUS)
+		{
+		RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+		CleanupClosePushL(document);
+		if (document.NotNull() && document.DocumentElement().NotNull())
+			{
+			RXmlEngNodeList<TXmlEngElement> ResponseList;
+			CleanupClosePushL(ResponseList);
+			document.DocumentElement().GetElementsByTagNameL(ResponseList,
+					KResponse, KDav);
+			TBool FirstOneDone = EFalse;
+			while (ResponseList.HasNext())
+				{
+				TXmlEngElement node = ResponseList.Next();
+				TPtrC8 href = SearchL(node, KHref, KNullDesC8);
+				TPtrC8 status = SearchL(node, KStatus, KNullDesC8);
+
+				TXmlEngElement calendar;
+				TXmlEngElement vevent_collection;
+				TXmlEngElement vtodo_collection;
+				SearchL(node, KCalendar, KNullDesC8, calendar);
+				SearchL(node, KVEventCollection, KNullDesC8, vevent_collection);
+				SearchL(node, KVTodoCollection, KNullDesC8, vtodo_collection);
+
+				if (calendar.NotNull() || vevent_collection.NotNull()
+						|| vtodo_collection.NotNull())
+					{
+					if (!FirstOneDone)
+						{
+						homecalendar = HBufC8::NewL(iBaseUrl->Length()
+								+ href.Length());
+						homecalendar->Des().Append(*iBaseUrl);
+						homecalendar->Des().Append(href);
+
+						iOptions.VEVENT = vevent_collection.NotNull();
+						iOptions.VTODO = vtodo_collection.NotNull();
+
+						FirstOneDone = ETrue;
+						}
+
+					if (aArray)
+						{
+						TBuf8<URLMAX> url;
+						url.Append(*iBaseUrl);
+						url.Append(href);
+						aArray->AppendL(url);
+						}
+					}
+				}
+			CleanupStack::PopAndDestroy(&ResponseList);
+			}
+		CleanupStack::PopAndDestroy(&document);
+		}
+	CleanupStack::PopAndDestroy(response);
+	return homecalendar;
+	}
+
+/**
+ * CCalDavEngine::GetCalendarUrlsL
+ * find calendar url based on any url
+ * could be principal url, home or direct calendar url
+ */
+TInt CCalDavEngine::GetCalendarUrlsL(CDesC8ArrayFlat *aArray)
+	{
+	if (iHttp && iUrl)
+		{
+		HBufC8 *principal = 0;
+		HBufC8 *home = 0;
+		HBufC8 *homecalendar = 0;
+		HBufC8 *inbox = 0;
+		HBufC8 *outbox = 0;
+
+		GetBaseUrl(*iUrl);
+
+		// TODO: does this really find groupdav collection?
+
+		// find out if this is a caldav or groupdav calendar collection
+		CBufFlat* response = CBufFlat::NewL(EXPANDSIZE_SMALL);
+		CleanupStack::PushL(response);
+		TInt retcode = iHttp->PropfindL(*iUrl, KCalendarurl, response);
+		if (retcode == MULTISTATUS)
+			{
+			RXmlEngDocument document = iDomParser.ParseL(response->Ptr(0));
+			CleanupClosePushL(document);
+			if (document.NotNull())
+				{
+				HBufC8* status =
+						SearchL(document, KStatus, KNullDesC8).AllocLC();
+				status->Des().LowerCase();
+				TXmlEngElement calendar;
+				SearchL(document, KCalendar, KNullDesC8, calendar);
+				// it should be <owner><href>value</href></owner>
+				// but oracle beehive server does <owner>value</owner>
+				TXmlEngElement owner;
+				SearchL(document, KOwner, KNullDesC8, owner);
+				TPtrC8 ownerref1 = SearchL(owner, KHref, KNullDesC8);
+				TPtrC8 ownerref2 = owner.Value();
+				TPtrC8 ownerref;
+				ownerref.Set(ownerref1 != KNullDesC8 ? ownerref1 : ownerref2);
+
+				if (calendar.NotNull() && (ownerref != KNullDesC8) && (*status
+						== KHTTP200))
+					{
+					// this is a calendar collection and we know the principal as well now
+					homecalendar = iUrl->AllocL();
+					_LIT8(KHTTP,"http");
+					HBufC8* http = ownerref.Left(KHTTP().Length()).AllocLC();
+					if (*http == KHTTP)
+						{
+						// sogo server does not return relative, but principal url
+						principal = ownerref.AllocL();
+						}
+					else
+						{
+						principal = HBufC8::NewL(iBaseUrl->Length()
+								+ ownerref.Length());
+						principal->Des().Append(*iBaseUrl);
+						principal->Des().Append(ownerref);
+						}
+					CleanupStack::PopAndDestroy(http);
+					}
+				CleanupStack::PopAndDestroy(status);
+				}
+			CleanupStack::PopAndDestroy(&document);
+			}
+
+		// if we have principal, ask for home, otherwise see if principal was given in the first place
+		if (principal)
+			{
+			response->Reset();
+			TInt retcode =
+					iHttp->PropfindL(*principal, KPrincipalurl, response);
+			if (retcode == MULTISTATUS)
+				{
+				FindUrlsL(response->Ptr(0), home, inbox, outbox);
+				}
+			}
+		else
+			{
+			response->Reset();
+			TInt retcode = iHttp->PropfindL(*iUrl, KPrincipalurl, response);
+			if (retcode == MULTISTATUS)
+				{
+				FindUrlsL(response->Ptr(0), home, inbox, outbox);
+				}
+			}
+
+		home = CalDavUtils::EnsureSlashL(home);
+		inbox = CalDavUtils::EnsureSlashL(inbox);
+		outbox = CalDavUtils::EnsureSlashL(outbox);
+
+		// find out all calendar collections under home
+		if (home)
+			{
+			// TODO: temporary? we already have homecalendar...
+			if (!homecalendar)
+				{
+				homecalendar = FindCalendarCollectionL(*home, aArray);
+				}
+			}
+		else
+			{
+			// have not found out home nor a groupdav collection, maybe we are home ourselves
+			homecalendar = FindCalendarCollectionL(*iUrl, aArray);
+			if (homecalendar)
+				home = iUrl->AllocL();
+			}
+
+		CleanupStack::PopAndDestroy(response);
+		delete principal;
+		delete inbox;
+		delete outbox;
+
+		if (home)
+			iHome = CalDavUtils::EnsureSlashL(home);
+		if (homecalendar)
+			{
+			delete iUrl;
+			iUrl = NULL;
+			iUrl = CalDavUtils::EnsureSlashL(homecalendar);
+			return KErrNone;
+			}
+		else
+			return KErrArgument;
+		}
+	return KErrArgument;
+	}
+
+/**
+ * CCalDavEngine::CalendarName
+ * get calendar name
+ */
+TPtrC CCalDavEngine::CalendarName() const
+	{
+	return iCalendar ? *iCalendar : KNullDesC();
+	}
+
+/**
+ * CCalDavEngine::Home
+ * get home
+ */
+TPtrC8 CCalDavEngine::Home() const
+	{
+	return iHome ? *iHome : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngine::Url
+ * get url
+ */
+TPtrC8 CCalDavEngine::Url() const
+	{
+	return iUrl ? *iUrl : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngine::SetUrlL
+ * set url
+ */
+void CCalDavEngine::SetUrlL(const TDesC8 &aUrl)
+	{
+	if (iUrl ? *iUrl != aUrl : ETrue)
+		{
+		DisableL();
+
+		if (iUrl)
+			{
+			delete iUrl;
+			iUrl = NULL;
+			}
+
+		iUrl = CalDavUtils::EnsureSlashL(aUrl);
+		SetCalendarInfoL(KCaldavUrl, *iUrl);
+		}
+	}
+
+/**
+ * CCalDavEngine::User
+ * get user
+ */
+TPtrC8 CCalDavEngine::User() const
+	{
+	return iHttp->User();
+	}
+
+/**
+ * CCalDavEngine::SetUserL
+ * set user
+ */
+void CCalDavEngine::SetUserL(const TDesC8 &aUser)
+	{
+	if (iHttp->User() != aUser)
+		{
+		DisableL();
+		SetCalendarInfoL(KCaldavUser, aUser);
+		iHttp->SetUserL(aUser);
+		}
+	}
+
+/**
+ * CCalDavEngine::Password
+ * get password
+ */
+TPtrC8 CCalDavEngine::Password() const
+	{
+	return iHttp->Password();
+	}
+
+/**
+ * CCalDavEngine::SetPasswordL
+ * set password
+ */
+void CCalDavEngine::SetPasswordL(const TDesC8 &aPassword)
+	{
+	if (iHttp->Password() != aPassword)
+		{
+		DisableL();
+		iHttp->SetPasswordL(aPassword);
+		SetCalendarInfoL(KCaldavPassword, aPassword);
+		}
+	}
+
+/**
+ * CCalDavEngine::SyncInterval
+ * get SyncInterval
+ */
+TTimeIntervalMinutes CCalDavEngine::SyncInterval() const
+	{
+	return iSyncInterval;
+	}
+
+/**
+ * CCalDavEngine::SetSyncIntervalL
+ * set SetSyncIntervalL
+ */
+void CCalDavEngine::SetSyncIntervalL(TTimeIntervalMinutes aSyncInterval)
+	{
+	iSyncInterval = aSyncInterval;
+	TPckgC<TTimeIntervalMinutes> minutes(iSyncInterval);
+	SetCalendarInfoL(KCaldavSyncInterval, minutes);
+	}
+
+/**
+ * CCalDavEngine::PastDays
+ * get past days
+ */
+TTimeIntervalDays CCalDavEngine::PastDays() const
+	{
+	return iPastDays;
+	}
+
+/**
+ * CCalDavEngine::SetPastDaysL
+ * Set PastDaysL
+ */
+void CCalDavEngine::SetPastDaysL(TTimeIntervalDays aDays)
+	{
+	iPastDays = aDays;
+	TPckgC<TTimeIntervalDays> days(iPastDays);
+	SetCalendarInfoL(KCaldavPastDays, days);
+	}
+
+/**
+ * CCalDavEngine::ImmediateSync
+ * get ImmediateSyncL
+ */
+TBool CCalDavEngine::ImmediateSync() const
+	{
+	return iImmediateSync;
+	}
+
+/**
+ * CCalDavEngine::SetImmediateSyncL
+ * Set ImmediateSyncL
+ */
+void CCalDavEngine::SetImmediateSyncL(TBool aImmediateSyc)
+	{
+	iImmediateSync = aImmediateSyc;
+	TPckgC<TBool> immediatesync(iImmediateSync);
+	SetCalendarInfoL(KCaldavImmediateSync, immediatesync);
+	}
+
+/**
+ * CCalDavEngine::KeepServerEntry
+ * get KeepServerEntryL
+ */
+TBool CCalDavEngine::KeepServerEntry() const
+	{
+	return iKeepServerEntry;
+	}
+
+/**
+ * CCalDavEngine::SetKeepServerEntryL
+ * Set KeepServerEntryL
+ */
+void CCalDavEngine::SetKeepServerEntryL(TBool aKeepServerEntry)
+	{
+	iKeepServerEntry = aKeepServerEntry;
+	TPckgC<TBool> keepserver(iKeepServerEntry);
+	SetCalendarInfoL(KCaldavKeepServer, keepserver);
+	}
+
+/**
+ * CCalDavEngine::Timer
+ * get timer
+ */
+CPeriodic* CCalDavEngine::Timer()
+	{
+	return iTimer;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavenginemgr.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides a manager to keep track of all available engines
+*
+*/
+
+#include "caldavenginemgr.h"
+#include "caldavengine.h"
+
+#include <calsession.h>
+#include <calcalendarinfo.h>
+#include "calenglobaldata.h"
+
+/**
+ * CCalDavEngineMgr::CCalDavEngineMgr()
+ * default constructor
+ */
+CCalDavEngineMgr::CCalDavEngineMgr()
+	{
+	}
+
+/**
+ * CCalDavEngineMgr::~CCalDavEngineMgr()
+ * default destructor
+ */
+CCalDavEngineMgr::~CCalDavEngineMgr()
+	{
+	for (TInt i = iEngines.Count() - 1; i >= 0; --i)
+		delete iEngines[i];
+	iEngines.Close();
+	}
+
+/**
+ * CCalDavEngineMgr::NewLC()
+ * first phase construction
+ */
+CCalDavEngineMgr* CCalDavEngineMgr::NewLC()
+	{
+	CCalDavEngineMgr* self = new (ELeave) CCalDavEngineMgr();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/**
+ * CCalDavEngineMgr::NewL()
+ * first phase construction
+ */
+CCalDavEngineMgr* CCalDavEngineMgr::NewL()
+	{
+	CCalDavEngineMgr* self = CCalDavEngineMgr::NewLC();
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+/**
+ * CCalDavEngineMgr::Progress()
+ * progress callback
+ */
+void CCalDavEngineMgr::Progress(TInt /*aPercentageCompleted*/)
+	{
+	}
+
+/**
+ * CCalDavEngineMgr::Completed()
+ * completed callback
+ */
+void CCalDavEngineMgr::Completed(TInt /*aError*/)
+	{
+	}
+
+/**
+ * CCalDavEngineMgr::NotifyProgress()
+ * NotifyProgress callback
+ */
+TBool CCalDavEngineMgr::NotifyProgress()
+	{
+	return EFalse;
+	}
+
+/**
+ * CCalDavEngineMgr::ConstructL()
+ * second phase construction
+ * check all calendar files, for each one which has caldav sync enabled, 
+ * create a CCalDavengine and enable sync
+ */
+void CCalDavEngineMgr::ConstructL()
+	{
+	RPointerArray<CCalCalendarInfo> calendarInfoList;
+	CCalenGlobalData* data = CCalenGlobalData::NewL(*this);
+	data->InitializeGlobalDataL();
+	CleanupStack::PushL(data);
+	data->GetAllCalendarInfoL(calendarInfoList);
+	CleanupClosePushL(calendarInfoList);
+
+	for (TInt i = 0; i < calendarInfoList.Count(); i++)
+		{
+		CDesC8Array* propertyKeys = calendarInfoList[i]->PropertyKeysL();
+		CleanupStack::PushL(propertyKeys);
+		TInt pos = 0;
+		if (propertyKeys->Find(KCaldavEnabled, pos, ECmpNormal) == KErrNone)
+			{
+			CCalDavEngine* engine = CCalDavEngine::NewL(
+					calendarInfoList[i]->FileNameL());
+			iEngines.Append(engine);
+			if (engine->EnabledSync())
+				engine->EnableL();
+			}
+		CleanupStack::PopAndDestroy(propertyKeys);
+		}
+	CleanupStack::PopAndDestroy(&calendarInfoList);
+	CleanupStack::PopAndDestroy(data);
+	}
+
+/**
+ * CCalDavEngineMgr::FindEngineL()
+ * find engines inside engine array, create if neccessary
+ */
+TInt CCalDavEngineMgr::FindEngineL(const TDesC &aName, TBool aCreate)
+	{
+	CCalSession* session = CCalSession::NewL();
+	TRAPD(error,session->OpenL(aName));
+	delete session;
+	if (error != KErrNone)
+		return KErrNotFound;
+		
+	for (TInt i = 0; i <= iEngines.Count() - 1; i++)
+		{
+		if (iEngines[i]->CalendarName() == aName)
+			return i;
+		}
+
+	if (aCreate)
+		{
+		iEngines.Append(CCalDavEngine::NewL(aName));
+		return iEngines.Count() - 1;
+		}
+	else
+		return KErrNotFound;
+	}
+
+/**
+ * CCalDavEngineMgr::SyncL()
+ * sync specific calendar
+ */
+TInt CCalDavEngineMgr::SyncL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	if (pos != KErrNotFound)
+		return iEngines[pos]->SyncL();
+	else
+		return KErrNotFound;
+	}
+
+/**
+ * CCalDavEngineMgr::SyncAllL()
+ * sync all calendars
+ */
+TInt CCalDavEngineMgr::SyncAllL()
+	{
+	// sync all caldav enabled calendars
+	for (TInt i = 0; i <= iEngines.Count() - 1; i++)
+		iEngines[i]->SyncL();
+	return KErrNone;
+	}
+
+/**
+ * CCalDavEngineMgr::DisableL()
+ * 
+ */
+TInt CCalDavEngineMgr::DisableL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+
+	if (pos != KErrNotFound)
+		iEngines[pos]->DisableL();
+
+	return pos == KErrNotFound ? KErrNotFound : KErrNone;
+	}
+
+/**
+ * CCalDavEngineMgr::EnableL()
+ * 
+ */
+TInt CCalDavEngineMgr::EnableL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	if (pos != KErrNotFound)
+		{
+		return iEngines[pos]->EnableL();
+		}
+
+	return KErrArgument;
+	}
+
+/**
+ * CCalDavEngineMgr::UrlL()
+ * 
+ */
+TPtrC8 CCalDavEngineMgr::UrlL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->Url() : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngineMgr::SetUrlL()
+ * 
+ */
+void CCalDavEngineMgr::SetUrlL(const TDesC &aCalendar, const TDesC8 &aUrl)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetUrlL(aUrl);
+	}
+
+/**
+ * CCalDavEngineMgr::UsernameL()
+ * 
+ */
+TPtrC8 CCalDavEngineMgr::UsernameL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->User() : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngineMgr::SetUsernameL()
+ * 
+ */
+void CCalDavEngineMgr::SetUsernameL(const TDesC &aCalendar,
+		const TDesC8 &aUsername)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetUserL(aUsername);
+	}
+
+/**
+ * CCalDavEngineMgr::PasswordL()
+ * 
+ */
+TPtrC8 CCalDavEngineMgr::PasswordL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->Password() : KNullDesC8();
+	}
+
+/**
+ * CCalDavEngineMgr::SetPasswordL()
+ * 
+ */
+void CCalDavEngineMgr::SetPasswordL(const TDesC &aCalendar,
+		const TDesC8 &aPassword)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetPasswordL(aPassword);
+	}
+
+/**
+ * CCalDavEngineMgr::SyncIntervalL()
+ * 
+ */
+TTimeIntervalMinutes CCalDavEngineMgr::SyncIntervalL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->SyncInterval()
+			: TTimeIntervalMinutes(DEFAULT_SYNC_MINUTES);
+	}
+
+/**
+ * CCalDavEngineMgr::SetSyncIntervalL()
+ * 
+ */
+void CCalDavEngineMgr::SetSyncIntervalL(const TDesC &aCalendar,
+		TTimeIntervalMinutes aSyncInterval)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetSyncIntervalL(aSyncInterval);
+	}
+
+/**
+ * CCalDavEngineMgr::PastDaysL()
+ * 
+ */
+TTimeIntervalDays CCalDavEngineMgr::PastDaysL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->PastDays()
+			: TTimeIntervalDays(DEFAULT_PAST_DAYS);
+	}
+
+/**
+ * CCalDavEngineMgr::SetPastDaysL()
+ * 
+ */
+void CCalDavEngineMgr::SetPastDaysL(const TDesC &aCalendar,
+		TTimeIntervalDays aDays)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetPastDaysL(aDays);
+	}
+
+/**
+ * CCalDavEngineMgr::ImmediateSyncL()
+ * 
+ */
+TBool CCalDavEngineMgr::ImmediateSyncL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return pos != KErrNotFound ? iEngines[pos]->ImmediateSync()
+			: DEFAULT_IMMEDIATE_SYNC;
+	}
+
+/**
+ * CCalDavEngineMgr::SetImmediateSyncL()
+ * 
+ */
+void CCalDavEngineMgr::SetImmediateSyncL(const TDesC &aCalendar,
+		TBool aImmediateSyc)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetImmediateSyncL(aImmediateSyc);
+	}
+
+/**
+ * CCalDavEngineMgr::KeepServerEntryL()
+ * 
+ */
+TBool CCalDavEngineMgr::KeepServerEntryL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return pos != KErrNotFound ? iEngines[pos]->KeepServerEntry()
+			: DEFAULT_KEEP_SERVER_ENTRY;
+	}
+
+/**
+ * CCalDavEngineMgr::SetKeepServerEntryL()
+ * 
+ */
+void CCalDavEngineMgr::SetKeepServerEntryL(const TDesC &aCalendar,
+		TBool aKeepServerEntry)
+	{
+	TInt pos = FindEngineL(aCalendar, ETrue);
+	if (pos != KErrNotFound)
+		iEngines[pos]->SetKeepServerEntryL(aKeepServerEntry);
+	}
+
+/**
+ * CCalDavEngineMgr::EnabledSyncL()
+ * 
+ */
+TBool CCalDavEngineMgr::EnabledSyncL(const TDesC &aCalendar)
+	{
+	TInt pos = FindEngineL(aCalendar);
+	return (pos != KErrNotFound) ? iEngines[pos]->EnabledSync() : EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavserver.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,373 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav server, follows Symbian client/server 
+*				architecture
+*/
+
+#include <e32svr.h>
+#include <e32uid.h>
+#include <S32MEM.H> 
+
+#include <xmlengdocument.h>
+#include <xmlengtext.h>
+
+#include "caldavserver.h"
+#include "caldavenginemgr.h"
+#include "caldavserverSession.h"
+#include "httpclient.h"
+
+const TUint KServerPolicyRangeCount = 2;
+
+const TInt KServerPolicyRanges[KServerPolicyRangeCount] =
+	{
+	0, // range is 0 inclusive
+			200
+	// range is 1-KMaxTInt inclusive
+		};
+
+const TUint8 KServerPolicyElementsIndex[KServerPolicyRangeCount] =
+	{
+	0, // applies to 0th range
+			CPolicyServer::ENotSupported
+	// applies to 1st range
+		};
+
+/**
+ * CPolicyServer::TPolicyElement()
+ * 
+ */
+const CPolicyServer::TPolicyElement
+		KServerPolicyElements[] =
+			{
+						{
+								_INIT_SECURITY_POLICY_C5(ECapabilityWriteDeviceData,ECapabilityWriteUserData, ECapabilityReadDeviceData,ECapabilityReadUserData,ECapabilityNetworkServices), CPolicyServer::EFailClient
+						}
+			};
+
+const CPolicyServer::TPolicy KServerPolicy =
+	{
+	CPolicyServer::EAlwaysPass, // specifies all connect attempts should pass
+			KServerPolicyRangeCount,
+			KServerPolicyRanges,
+			KServerPolicyElementsIndex,
+			KServerPolicyElements
+	};
+
+/**
+ * CCalDavServer::CCalDavServer
+ * default constructor
+ */
+CCalDavServer::CCalDavServer(CActive::TPriority aActiveObjectPriority) :
+	CPolicyServer(aActiveObjectPriority, KServerPolicy)
+	{
+	}
+
+/**
+ * CCalDavServer::NewSessionL
+ * Creates a new session with the server.
+ */
+CSession2* CCalDavServer::NewSessionL(const TVersion& aVersion,
+		const RMessage2& /*aMessage*/) const
+	{
+	// Check that the version is OK
+	TVersion v(KCalDavServerMajorVersionNumber,
+			KCalDavServerMinorVersionNumber, KCalDavServerBuildVersionNumber);
+	if (!User::QueryVersionSupported(v, aVersion))
+		User::Leave(KErrNotSupported);
+
+	// CAN USE THE aMessage argument to check client's security and identity
+	// can make use of this later but for now ignore. AH 4/5/05
+	// the connect message is delivered via the RMessage2 object passed. 
+
+	// do something with this later (and move it to the start of the function?)
+
+	// Create the session.
+	return new (ELeave) CCalDavServerSession(*const_cast<CCalDavServer*> (this));
+	}
+
+/**
+* CCalDavServer::PanicServer
+ A utility function to panic the server.
+ */
+void CCalDavServer::PanicServer(TCalDavServPanic aPanic)
+	{
+	_LIT(KTxtServerPanic,"CalDav server panic");
+	User::Panic(KTxtServerPanic, aPanic);
+	}
+
+/**
+ * CCalDavServer::ThreadFunction
+ * The count server thread function that initialises the server.
+ */
+TInt CCalDavServer::ThreadFunction(TAny* /**aStarted*/)
+	{
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (!(cleanupStack))
+		{
+		PanicServer(ECreateTrapCleanup);
+		}
+	TRAPD( err, ThreadFunctionL() );
+	if (err != KErrNone)
+		{
+		PanicServer(ESvrCreateServer);
+		}
+
+	delete cleanupStack;
+	cleanupStack = NULL;
+
+	return KErrNone;
+
+	}
+
+/**
+ * CCalDavServer::NewLC
+ * first phase construction
+ */
+CCalDavServer* CCalDavServer::NewLC()
+	{
+	CCalDavServer* self =
+			new (ELeave) CCalDavServer(CActive::EPriorityStandard);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/**
+ * CCalDavServer::ConstructL
+ * second phase construction
+ */
+void CCalDavServer::ConstructL()
+	{
+	StartL(KCalDavServerName);
+
+	iMgr = CCalDavEngineMgr::NewL();
+	}
+
+/**
+ * CCalDavServer::ThreadFunctionL
+ * start scheduler and construct function
+ */
+void CCalDavServer::ThreadFunctionL()
+	{
+	// Construct active scheduler
+	CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
+	CleanupStack::PushL(activeScheduler);
+
+	// Install active scheduler
+	// We don't need to check whether an active scheduler is already installed
+	// as this is a new thread, so there won't be one
+	CActiveScheduler::Install(activeScheduler);
+
+	// Construct our server, leave it on clean-up stack
+	CCalDavServer::NewLC();
+
+	// Naming the server thread after the server helps to debug panics
+	User::LeaveIfError(User::RenameThread(KCalDavServerName));
+
+	RProcess::Rendezvous(KErrNone);
+
+	// Start handling requests
+	CActiveScheduler::Start();
+
+	CleanupStack::PopAndDestroy(2, activeScheduler); //Anonymous CCalDavServer
+	}
+
+/**
+ * CCalDavServer::~CCalDavServer
+ * default destructor
+ */
+CCalDavServer::~CCalDavServer()
+	{
+	if (iMgr)
+		delete iMgr;
+	}
+
+/**
+ * CCalDavServer::SyncL
+ * 
+ */
+TInt CCalDavServer::SyncL(const TDesC &aCalendar)
+	{
+	return iMgr->SyncL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SyncAllL
+ * 
+ */
+TInt CCalDavServer::SyncAllL()
+	{
+	return iMgr->SyncAllL();
+	}
+
+/**
+ * CCalDavServer::EnableL
+ * 
+ */
+TInt CCalDavServer::EnableL(const TDesC &aCalendar)
+	{
+	return iMgr->EnableL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::DisableL
+ * 
+ */
+TInt CCalDavServer::DisableL(const TDesC &aCalendar)
+	{
+	return iMgr->DisableL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::UrlL
+ * 
+ */
+TPtrC8 CCalDavServer::UrlL(const TDesC &aCalendar)
+	{
+	return iMgr->UrlL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetUrlL
+ * 
+ */
+void CCalDavServer::SetUrlL(const TDesC &aCalendar, const TDesC8 &aUrl)
+	{
+	return iMgr->SetUrlL(aCalendar, aUrl);
+	}
+
+/**
+ * CCalDavServer::UsernameL
+ * 
+ */
+TPtrC8 CCalDavServer::UsernameL(const TDesC &aCalendar)
+	{
+	return iMgr->UsernameL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetUsernameL
+ * 
+ */
+void CCalDavServer::SetUsernameL(const TDesC &aCalendar, const TDesC8 &aUsername)
+	{
+	return iMgr->SetUsernameL(aCalendar, aUsername);
+	}
+
+/**
+ * CCalDavServer::PasswordL
+ * 
+ */
+TPtrC8 CCalDavServer::PasswordL(const TDesC &aCalendar)
+	{
+	return iMgr->PasswordL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetPasswordL
+ * 
+ */
+void CCalDavServer::SetPasswordL(const TDesC &aCalendar, const TDesC8 &aPassword)
+	{
+	return iMgr->SetPasswordL(aCalendar, aPassword);
+	}
+
+/**
+ * CCalDavServer::SyncIntervalL
+ * 
+ */
+TTimeIntervalMinutes CCalDavServer::SyncIntervalL(const TDesC &aCalendar) const
+	{
+	return iMgr->SyncIntervalL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetSyncIntervalL
+ * 
+ */
+void CCalDavServer::SetSyncIntervalL(const TDesC &aCalendar,
+		TTimeIntervalMinutes aSyncInterval)
+	{
+	iMgr->SetSyncIntervalL(aCalendar, aSyncInterval);
+	}
+
+/**
+ * CCalDavServer::EnabledSyncL
+ * 
+ */
+TBool CCalDavServer::EnabledSyncL(const TDesC &aCalendar) const
+	{
+	return iMgr->EnabledSyncL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::PastDaysL
+ * 
+ */
+TTimeIntervalDays CCalDavServer::PastDaysL(const TDesC &aCalendar) const
+	{
+	return iMgr->PastDaysL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetPastDaysL
+ * 
+ */
+void CCalDavServer::SetPastDaysL(const TDesC &aCalendar, TTimeIntervalDays aDays)
+	{
+	iMgr->SetPastDaysL(aCalendar, aDays);
+	}
+
+/**
+ * CCalDavServer::ImmediateSyncL
+ * 
+ */
+TBool CCalDavServer::ImmediateSyncL(const TDesC &aCalendar) const
+	{
+	return iMgr->ImmediateSyncL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetImmediateSyncL
+ * 
+ */
+void CCalDavServer::SetImmediateSyncL(const TDesC &aCalendar,
+		TBool aImmediateSyc)
+	{
+	iMgr->SetImmediateSyncL(aCalendar, aImmediateSyc);
+	}
+
+/**
+ * CCalDavServer::KeepServerEntryL
+ * 
+ */
+TBool CCalDavServer::KeepServerEntryL(const TDesC &aCalendar) const
+	{
+	return iMgr->KeepServerEntryL(aCalendar);
+	}
+
+/**
+ * CCalDavServer::SetKeepServerEntryL
+ * 
+ */
+void CCalDavServer::SetKeepServerEntryL(const TDesC &aCalendar,
+		TBool aKeepServerEntry)
+	{
+	iMgr->SetKeepServerEntryL(aCalendar, aKeepServerEntry);
+	}
+
+TInt E32Main()
+	{
+	return CCalDavServer::ThreadFunction(NULL);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavserversession.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,400 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav server session, follows Symbian 
+* 				client/server architecture
+*/
+
+#include <e32cmn.h>
+
+#include "caldavserversession.h"
+#include "caldavserver.h"
+#include "caldavutils.h"
+
+#define MAXLENGTH	500
+
+CCalDavServerSession::CCalDavServerSession(CCalDavServer &aServer) :
+	rServer(aServer)
+	{
+	}
+
+/**
+ Services a client request.
+ */
+void CCalDavServerSession::ServiceL(const RMessage2& aMessage)
+	{
+	TRAP_IGNORE(DispatchMessageL(aMessage));
+	}
+
+/**
+ Called by ServiceL()
+
+ It tests the function code and then delegates to
+ the appropriate function.
+ */
+void CCalDavServerSession::DispatchMessageL(const RMessage2& aMessage)
+	{
+	switch (aMessage.Function())
+		{
+		case ECalDavEnable:
+			EnableL(aMessage);
+			return;
+		case ECalDavDisable:
+			DisableL(aMessage);
+			return;
+		case ECalDavSyncAll:
+			SyncAllL(aMessage);
+			return;
+		case ECalDavSync:
+			SyncL(aMessage);
+			return;
+		case ECalDavUrl:
+			UrlL(aMessage);
+			return;
+		case ECalDavSetUrl:
+			SetUrlL(aMessage);
+			return;
+		case ECalDavUsername:
+			UsernameL(aMessage);
+			return;
+		case ECalDavSetUsername:
+			SetUsernameL(aMessage);
+			return;
+		case ECalDavPassword:
+			PasswordL(aMessage);
+			return;
+		case ECalDavSetPassword:
+			SetPasswordL(aMessage);
+			return;
+		case ECalDavSyncInterval:
+			SyncIntervalL(aMessage);
+			return;
+		case ECalDavSetSyncInterval:
+			SetSyncIntervalL(aMessage);
+			return;
+		case ECalDavPastDays:
+			PastDaysL(aMessage);
+			return;
+		case ECalDavSetPastDays:
+			SetPastDaysL(aMessage);
+			return;
+		case ECalDavImmediateSync:
+			ImmediateSyncL(aMessage);
+			return;
+		case ECalDavSetImmediateSync:
+			SetImmediateSyncL(aMessage);
+			return;
+		case ECalDavKeepServer:
+			KeepServerEntryL(aMessage);
+			return;
+		case ECalDavSetKeepServer:
+			SetKeepServerEntryL(aMessage);
+			return;
+		case ECalDavEnabled:
+			EnabledSyncL(aMessage);
+			return;
+		case ECalDavUnsupportedRequest:
+			User::Leave(KErrNotSupported);
+			//  Requests that we don't understand at all are a different matter.
+			//  This is considered a client programming error, so we panic the 
+			//  client - this also completes the message.
+		default:
+			PanicClient(aMessage, EBadRequest);
+			return;
+		}
+	}
+
+/**
+ Panics the client
+ */
+void CCalDavServerSession::PanicClient(const RMessage2& aMessage, TInt aPanic) const
+	{
+	_LIT(KTxtServer,"CalDav server");
+	aMessage.Panic(KTxtServer, aPanic);
+	}
+
+void CCalDavServerSession::EnableL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TInt result = rServer.EnableL(*calendar);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(result);
+	}
+
+void CCalDavServerSession::DisableL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TInt result = rServer.DisableL(*calendar);
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(result);
+	}
+
+void CCalDavServerSession::SyncL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TInt result = rServer.SyncL(*calendar);
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(result);
+	}
+
+void CCalDavServerSession::SyncAllL(const RMessage2& aMessage)
+	{
+	TInt result = rServer.SyncAllL();
+	aMessage.Complete(result);
+	}
+
+void CCalDavServerSession::UrlL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	aMessage.WriteL(1, rServer.UrlL(*calendar));
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetUrlL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	length = aMessage.GetDesLength(1);
+	HBufC8* url = HBufC8::NewLC(length);
+	TPtr8 urlPtr(url->Des());
+	aMessage.ReadL(1, urlPtr);
+
+	rServer.SetUrlL(*calendar, *url);
+	CleanupStack::PopAndDestroy(url);
+	CleanupStack::PopAndDestroy(calendar);
+
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::UsernameL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	aMessage.WriteL(1, rServer.UsernameL(*calendar));
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetUsernameL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	length = aMessage.GetDesLength(1);
+	HBufC8* username = HBufC8::NewLC(length);
+	TPtr8 usernamePtr(username->Des());
+	aMessage.ReadL(1, usernamePtr);
+
+	rServer.SetUsernameL(*calendar, *username);
+	CleanupStack::PopAndDestroy(username);
+	CleanupStack::PopAndDestroy(calendar);
+
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::PasswordL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	aMessage.WriteL(1, rServer.PasswordL(*calendar));
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetPasswordL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	length = aMessage.GetDesLength(1);
+	HBufC8* password = HBufC8::NewLC(length);
+	TPtr8 passwordPtr(password->Des());
+	aMessage.ReadL(1, passwordPtr);
+
+	rServer.SetPasswordL(*calendar, *password);
+	CleanupStack::PopAndDestroy(password);
+	CleanupStack::PopAndDestroy(calendar);
+
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SyncIntervalL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TTimeIntervalMinutes interval = rServer.SyncIntervalL(*calendar);
+	TPckg<TTimeIntervalMinutes> intervalDes(interval);
+	aMessage.WriteL(1, intervalDes);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetSyncIntervalL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TTimeIntervalMinutes interval;
+	;
+	TPckg<TTimeIntervalMinutes> intervalDes(interval);
+	aMessage.ReadL(1, intervalDes);
+
+	rServer.SetSyncIntervalL(*calendar, interval);
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::PastDaysL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TTimeIntervalDays days = rServer.PastDaysL(*calendar);
+	TPckg<TTimeIntervalDays> daysDes(days);
+	aMessage.WriteL(1, daysDes);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetPastDaysL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TTimeIntervalDays days;
+	TPckg<TTimeIntervalDays> daysDes(days);
+	aMessage.ReadL(1, daysDes);
+
+	rServer.SetPastDaysL(*calendar, days);
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::ImmediateSyncL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TBool immediate = rServer.ImmediateSyncL(*calendar);
+	TPckg<TBool> immediateDes(immediate);
+	aMessage.WriteL(1, immediateDes);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetImmediateSyncL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TBool immediate;
+	TPckg<TBool> immediateDes(immediate);
+	aMessage.ReadL(1, immediateDes);
+	rServer.SetImmediateSyncL(*calendar, immediate);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::KeepServerEntryL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TBool keepserver = rServer.ImmediateSyncL(*calendar);
+	TPckg<TBool> keepserverDes(keepserver);
+	aMessage.WriteL(1, keepserverDes);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::EnabledSyncL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TBool enabledsync = rServer.EnabledSyncL(*calendar);
+	TPckg<TBool> enabledsyncDes(enabledsync);
+	aMessage.WriteL(1, enabledsyncDes);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
+
+void CCalDavServerSession::SetKeepServerEntryL(const RMessage2& aMessage)
+	{
+	TUint length = aMessage.GetDesLength(0);
+	HBufC* calendar = HBufC::NewLC(length);
+	TPtr calendarPtr(calendar->Des());
+	aMessage.ReadL(0, calendarPtr);
+
+	TBool keepserver;
+	TPckg<TBool> keepserverDes(keepserver);
+	aMessage.ReadL(1, keepserverDes);
+	rServer.SetImmediateSyncL(*calendar, keepserver);
+
+	CleanupStack::PopAndDestroy(calendar);
+	aMessage.Complete(KErrNone);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavsession.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	Client API to connect to Caldav server
+*				Wrapper around RCalDavServer
+*/
+
+#include "caldavsession.h"
+#include "caldavsessionimpl.h"
+
+CCalDavSession::CCalDavSession()
+	{
+	}
+
+EXPORT_C CCalDavSession::~CCalDavSession()
+	{
+	delete iImpl;
+	}
+
+EXPORT_C CCalDavSession* CCalDavSession::NewLC()
+	{
+	CCalDavSession* self = new (ELeave) CCalDavSession();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+EXPORT_C CCalDavSession* CCalDavSession::NewL()
+	{
+	CCalDavSession* self = CCalDavSession::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CCalDavSession::ConstructL()
+	{
+	iImpl = CCalDavSessionImpl::NewL();
+	}
+
+EXPORT_C TInt CCalDavSession::Enable(const TDesC &aCalendar)
+	{
+	return iImpl->Enable(aCalendar);
+	}
+
+EXPORT_C TInt CCalDavSession::Disable(const TDesC &aCalendar)
+	{
+	return iImpl->Disable(aCalendar);
+	}
+
+EXPORT_C TInt CCalDavSession::SyncL(const TDesC &aCalendar)
+	{
+	return iImpl->SyncL(aCalendar);
+	}
+
+EXPORT_C TInt CCalDavSession::SyncAllL()
+	{
+	return iImpl->SyncAllL();
+	}
+
+EXPORT_C TInt CCalDavSession::Url(const TDesC &aCalendar, TDes8 &aUrl)
+	{
+	return iImpl->Url(aCalendar, aUrl);
+	}
+
+EXPORT_C TInt CCalDavSession::SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl)
+	{
+	return iImpl->SetUrl(aCalendar, aUrl);
+	}
+
+EXPORT_C TInt CCalDavSession::Username(const TDesC &aCalendar, TDes8 &aUsername)
+	{
+	return iImpl->Username(aCalendar, aUsername);
+	}
+
+EXPORT_C TInt CCalDavSession::SetUsername(const TDesC &aCalendar,
+		const TDesC8 &aUsername)
+	{
+	return iImpl->SetUsername(aCalendar, aUsername);
+	}
+
+EXPORT_C TInt CCalDavSession::Password(const TDesC &aCalendar, TDes8 &aPassword)
+	{
+	return iImpl->Password(aCalendar, aPassword);
+	}
+
+EXPORT_C TInt CCalDavSession::SetPassword(const TDesC &aCalendar,
+		const TDesC8 &aPassword)
+	{
+	return iImpl->SetPassword(aCalendar, aPassword);
+	}
+
+EXPORT_C TInt CCalDavSession::SyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes& aSyncInterval)
+	{
+	return iImpl->SyncInterval(aCalendar, aSyncInterval);
+	}
+
+EXPORT_C TInt CCalDavSession::SetSyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes aSyncInterval)
+	{
+	return iImpl->SetSyncInterval(aCalendar, aSyncInterval);
+	}
+
+EXPORT_C TInt CCalDavSession::PastDays(const TDesC &aCalendar,
+		TTimeIntervalDays &aDays)
+	{
+	return iImpl->PastDays(aCalendar, aDays);
+	}
+
+EXPORT_C TInt CCalDavSession::SetPastDays(const TDesC &aCalendar,
+		TTimeIntervalDays aDays)
+	{
+	return iImpl->SetPastDays(aCalendar, aDays);
+	}
+
+EXPORT_C TInt CCalDavSession::ImmediateSync(const TDesC &aCalendar,
+		TBool &aImmediateSyc)
+	{
+	return iImpl->ImmediateSync(aCalendar, aImmediateSyc);
+	}
+
+EXPORT_C TInt CCalDavSession::SetImmediateSync(const TDesC &aCalendar,
+		TBool aImmediateSyc)
+	{
+	return iImpl->SetImmediateSync(aCalendar, aImmediateSyc);
+	}
+
+EXPORT_C TInt CCalDavSession::KeepServerEntry(const TDesC &aCalendar,
+		TBool &aKeepServerEntry)
+	{
+	return iImpl->KeepServerEntry(aCalendar, aKeepServerEntry);
+	}
+
+EXPORT_C TInt CCalDavSession::SetKeepServerEntry(const TDesC &aCalendar,
+		TBool aKeepServerEntry)
+	{
+	return iImpl->SetKeepServerEntry(aCalendar, aKeepServerEntry);
+	}
+
+EXPORT_C TInt CCalDavSession::EnabledSync(const TDesC &aCalendar,
+		TBool &aEnabledSync)
+	{
+	return iImpl->EnabledSync(aCalendar, aEnabledSync);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavsessionimpl.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	Client API implementation
+*				Wrapper around RCalDavServer
+*/
+
+#include "caldavsessionimpl.h"
+#include "caldavclient.h"
+
+CCalDavSessionImpl::CCalDavSessionImpl()
+	{
+	// No implementation required
+	}
+
+CCalDavSessionImpl::~CCalDavSessionImpl()
+	{
+	if (iServer)
+		{
+		iServer->Close();
+		delete iServer;
+		}
+	}
+
+CCalDavSessionImpl* CCalDavSessionImpl::NewLC()
+	{
+	CCalDavSessionImpl* self = new (ELeave) CCalDavSessionImpl();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCalDavSessionImpl* CCalDavSessionImpl::NewL()
+	{
+	CCalDavSessionImpl* self = CCalDavSessionImpl::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CCalDavSessionImpl::ConstructL()
+	{
+	iServer = new (ELeave) RCalDavServer();
+	User::LeaveIfError(iServer->Connect());
+	}
+
+TInt CCalDavSessionImpl::Enable(const TDesC &aCalendar)
+	{
+	return iServer->Enable(aCalendar);
+	}
+
+TInt CCalDavSessionImpl::Disable(const TDesC &aCalendar)
+	{
+	return iServer->Disable(aCalendar);
+	}
+
+TInt CCalDavSessionImpl::SyncL(const TDesC &aCalendar)
+	{
+	return iServer->Sync(aCalendar);
+	}
+
+TInt CCalDavSessionImpl::SyncAllL()
+	{
+	return iServer->SyncAll();
+	}
+
+TInt CCalDavSessionImpl::Url(const TDesC &aCalendar, TDes8 &aUrl)
+	{
+	return iServer->Url(aCalendar, aUrl);
+	}
+
+TInt CCalDavSessionImpl::SetUrl(const TDesC &aCalendar, const TDesC8 &aUrl)
+	{
+	return iServer->SetUrl(aCalendar, aUrl);
+	}
+
+TInt CCalDavSessionImpl::Username(const TDesC &aCalendar, TDes8 &aUsername)
+	{
+	return iServer->Username(aCalendar, aUsername);
+	}
+
+TInt CCalDavSessionImpl::SetUsername(const TDesC &aCalendar,
+		const TDesC8 &aUsername)
+	{
+	return iServer->SetUsername(aCalendar, aUsername);
+	}
+
+TInt CCalDavSessionImpl::Password(const TDesC &aCalendar, TDes8 &aPassword)
+	{
+	return iServer->Password(aCalendar, aPassword);
+	}
+
+TInt CCalDavSessionImpl::SetPassword(const TDesC &aCalendar,
+		const TDesC8 &aPassword)
+	{
+	return iServer->SetPassword(aCalendar, aPassword);
+	}
+
+TInt CCalDavSessionImpl::SyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes& aSyncInterval)
+	{
+	return iServer->SyncInterval(aCalendar, aSyncInterval);
+	}
+
+TInt CCalDavSessionImpl::SetSyncInterval(const TDesC &aCalendar,
+		TTimeIntervalMinutes aSyncInterval)
+	{
+	return iServer->SetSyncInterval(aCalendar, aSyncInterval);
+	}
+
+TInt CCalDavSessionImpl::PastDays(const TDesC &aCalendar,
+		TTimeIntervalDays &aDays)
+	{
+	return iServer->PastDays(aCalendar, aDays);
+	}
+
+TInt CCalDavSessionImpl::SetPastDays(const TDesC &aCalendar,
+		TTimeIntervalDays aDays)
+	{
+	return iServer->SetPastDays(aCalendar, aDays);
+	}
+
+TInt CCalDavSessionImpl::ImmediateSync(const TDesC &aCalendar,
+		TBool &aImmediateSyc)
+	{
+	return iServer->ImmediateSync(aCalendar, aImmediateSyc);
+	}
+
+TInt CCalDavSessionImpl::SetImmediateSync(const TDesC &aCalendar,
+		TBool aImmediateSyc)
+	{
+	return iServer->SetImmediateSync(aCalendar, aImmediateSyc);
+	}
+
+TInt CCalDavSessionImpl::KeepServerEntry(const TDesC &aCalendar,
+		TBool &aKeepServerEntry)
+	{
+	return iServer->KeepServerEntry(aCalendar, aKeepServerEntry);
+	}
+
+TInt CCalDavSessionImpl::SetKeepServerEntry(const TDesC &aCalendar,
+		TBool aKeepServerEntry)
+	{
+	return iServer->SetKeepServerEntry(aCalendar, aKeepServerEntry);
+	}
+
+TInt CCalDavSessionImpl::EnabledSync(const TDesC &aCalendar,
+		TBool &aEnabledSync)
+	{
+	return iServer->EnabledSync(aCalendar, aEnabledSync);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/caldavutils.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,375 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	various utility classes and functions
+*				used in Caldav client and server code
+*/
+
+#include "caldavutils.h"
+
+#include <http\MHTTPAuthenticationCallback.h>
+#include <http\mhttptransactioncallback.h>
+#include <http\mhttpdatasupplier.h>
+#include <http\rhttpheaders.h> 
+
+/**
+ * CalDavUtils::CalDavUtils
+ * default constructor
+ */
+CalDavUtils::CalDavUtils()
+	{
+	// No implementation required
+	}
+
+/**
+ * CalDavUtils::~CalDavUtils
+ * default destructor
+ */
+CalDavUtils::~CalDavUtils()
+	{
+	}
+
+/**
+ * CalDavUtils::NewLC
+ * first phase construction
+ */
+CalDavUtils* CalDavUtils::NewLC()
+	{
+	CalDavUtils* self = new (ELeave) CalDavUtils();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/**
+ * CalDavUtils::NewL
+ * first phase construction
+ */
+CalDavUtils* CalDavUtils::NewL()
+	{
+	CalDavUtils* self = CalDavUtils::NewLC();
+	CleanupStack::Pop(self); // self;
+	return self;
+	}
+
+/**
+ * CalDavUtils::ConstructL
+ * second phase construction
+ */
+void CalDavUtils::ConstructL()
+	{
+	}
+
+/**
+ * CalDavUtils::FixImportIssues
+ * fix import issues
+ */
+void CalDavUtils::FixImportIssues(TDes8 &aDes)
+	{
+	const TUint KICalCarriageReturnChar('\r');
+	_LIT8(KICalNewlineChar,"\n");
+	_LIT8(KICalCarriageReturnLineFeed,"\r\n");
+
+	TInt ret = aDes.Find(KICalNewlineChar);
+
+	while ((ret != KErrNotFound) && (ret == 0 ? ETrue : (aDes[ret - 1]
+			!= KICalCarriageReturnChar)))
+		{
+		aDes.Replace(ret, 1, KICalCarriageReturnLineFeed);
+		TInt mid = aDes.Mid(ret + 2).Find(KICalNewlineChar);
+		ret = mid != KErrNone ? mid + ret + 2 : KErrNotFound;
+		}
+	}
+
+/**
+ * CalDavUtils::FixExportIssues
+ * fix export issues, hopefully can be removed in the future
+ */
+void CalDavUtils::FixExportIssues(TDes8 &aDes)
+	{
+	FixSameTime(aDes);
+	FindAndRemoveMethod(aDes);
+	FixBYMONTHDAY(aDes);
+	FixLineFeed(aDes);
+	//TODO: using public, nothing is exported
+	}
+
+/**
+ * CalDavUtils::FixLineFeed
+ * fix lidne feed
+ */
+void CalDavUtils::FixLineFeed(TDes8 &aDes)
+	{
+	_LIT8(lf1,"
");
+	_LIT8(KBackSlashN,"\\n");
+	TInt ret = aDes.Find(lf1);
+	while (ret != KErrNotFound)
+		{
+		aDes.Replace(ret, lf1().Length(), KBackSlashN);
+		ret = aDes.Find(lf1);
+		}
+	}
+
+/**
+ * CalDavUtils::FixSameTime
+ * fix same time
+ */
+void CalDavUtils::FixSameTime(TDes8 &aDes)
+	{
+#define DATELENGTH	15
+	_LIT8(DTSTART,"DTSTART:");
+	_LIT8(DTEND,"DTEND:");
+	_LIT8(DUE,"DUE:");
+	_LIT8(nine,"9");
+	_LIT8(five,"5");
+	_LIT8(VEVENT,"VEVENT");
+	_LIT8(VTODO,"VTODO");
+
+	// add one second if DTSTART and DTEND is the same
+	// ATTENTION: works only for very simple cases right now
+	// DTSTART:20090630T000000
+	// DTEND:20090630T000000
+	if (aDes.Find(VEVENT) != KErrNone)
+		{
+		TInt PosStart = aDes.Find(DTSTART);
+		TInt PosDue = aDes.Find(DTEND);
+
+		if ((PosStart != KErrNone) && (PosDue != KErrNone))
+			{
+			TPtrC8 PtrStart = aDes.Mid(PosStart + DTSTART().Length(),
+					DATELENGTH);
+			TPtrC8 PtrStop = aDes.Mid(PosDue + DTEND().Length(), DATELENGTH);
+
+			if (PtrStart == PtrStop)
+				{
+				aDes.Replace(PosDue + DTEND().Length() + DATELENGTH - 1, 1,
+						nine);
+				aDes.Replace(PosDue + DTEND().Length() + DATELENGTH - 2, 1,
+						five);
+				aDes.Replace(PosDue + DTEND().Length() + DATELENGTH - 3, 1,
+						nine);
+				}
+			}
+		}
+
+	// add one second if DTSTART and DUE is the same
+	// ATTENTION: works only for very simple cases right now
+	// DTSTART:20090630T000000
+	// DUE:20090630T000000
+
+	if (aDes.Find(VTODO) != KErrNone)
+		{
+		TInt PosStart = aDes.Find(DTSTART);
+		TInt PosDue = aDes.Find(DUE);
+
+		if ((PosStart != KErrNone) && (PosDue != KErrNone))
+			{
+			TPtrC8 PtrStart = aDes.Mid(PosStart + DTSTART().Length(),
+					DATELENGTH);
+			TPtrC8 PtrStop = aDes.Mid(PosDue + DUE().Length(), DATELENGTH);
+
+			if (PtrStart == PtrStop)
+				{
+				aDes.Replace(PosDue + DUE().Length() + DATELENGTH - 1, 1, nine);
+				aDes.Replace(PosDue + DUE().Length() + DATELENGTH - 2, 1, five);
+				aDes.Replace(PosDue + DUE().Length() + DATELENGTH - 3, 1, nine);
+				}
+			}
+		}
+	}
+
+/**
+ * CalDavUtils::FindAndRemoveMethod
+ * fix wrong method export
+ */
+void CalDavUtils::FindAndRemoveMethod(TDes8 &aDes)
+	{
+	_LIT8(method,"METHOD:PUBLISH\r\n");
+	TInt Ret = aDes.Find(method);
+	while (Ret != KErrNotFound)
+		{
+		aDes.Delete(Ret, method().Length());
+		Ret = aDes.Find(method);
+		}
+	}
+
+/**
+ * CalDavUtils::FixBYMONTHDAY
+ * fix wrong BYMONTHDAY export
+ */
+void CalDavUtils::FixBYMONTHDAY(TDes8 &aDes)
+	{
+	_LIT8(method0,"BYMONTHDAY=0");
+	_LIT8(method1,"BYMONTHDAY=1");
+	TInt ret = aDes.Find(method0);
+	while (ret != KErrNotFound)
+		{
+		aDes.Replace(ret, method1().Length(), method1);
+		ret = aDes.Find(method0);
+		}
+	}
+
+/**
+ * CalDavUtils::ScanAllowHeaderL
+ * fix scan allow header
+ */
+void CalDavUtils::ScanAllowHeaderL(RHTTPTransaction &aTransaction,
+		TCalDAVOptions &aOptions)
+	{
+	RStringF Header = aTransaction.Session().StringPool().OpenFStringL(ALLOW);
+	THTTPHdrVal HeaderVal;
+	if (aTransaction.Response().GetHeaderCollection().GetField(Header, 0,
+			HeaderVal) == KErrNone)
+		{
+		RStringF FieldValStr = aTransaction.Session().StringPool().StringF(
+				HeaderVal.StrF());
+		const TDesC8 &FieldValDesC = FieldValStr.DesC();
+		HBufC8 *FieldVal = FieldValDesC.AllocLC();
+		// delete all colons
+		TInt Pos = FieldVal->Find(colon);
+		while (Pos != KErrNotFound)
+			{
+			FieldVal->Des().Delete(Pos, 1);
+			Pos = FieldVal->Find(colon);
+			}
+		TLex8 Lex(FieldVal->Des());
+		TBool stop = EFalse;
+		while (!stop)
+			{
+			TPtrC8 Ptr = Lex.NextToken();
+			stop = Ptr.Length() == 0;
+			if (Ptr == DELETE)
+				aOptions.DELETE = ETrue;
+			else if (Ptr == GET)
+				aOptions.GET = ETrue;
+			else if (Ptr == HEAD)
+				aOptions.HEAD = ETrue;
+			else if (Ptr == MKCALENDAR)
+				aOptions.MKCALENDAR = ETrue;
+			else if (Ptr == MKCOL)
+				aOptions.MKCOL = ETrue;
+			else if (Ptr == OPTIONS)
+				aOptions.OPTIONS = ETrue;
+			else if (Ptr == PROPFIND)
+				aOptions.PROPFIND = ETrue;
+			else if (Ptr == PROPPATCH)
+				aOptions.PROPPATCH = ETrue;
+			else if (Ptr == PUT)
+				aOptions.PUT = ETrue;
+			else if (Ptr == REPORT)
+				aOptions.REPORT = ETrue;
+			else if (Ptr == COPY)
+				aOptions.COPY = ETrue;
+			else if (Ptr == POST)
+				aOptions.POST = ETrue;
+			else if (Ptr == MOVE)
+				aOptions.MOVE = ETrue;
+			else if (Ptr == ACL)
+				aOptions.ACL = ETrue;
+			else if (Ptr == LOCK)
+				aOptions.LOCK = ETrue;
+			else if (Ptr == UNLOCK)
+				aOptions.UNLOCK = ETrue;
+			}
+		CleanupStack::PopAndDestroy(FieldVal);
+		}
+	Header.Close();
+	}
+
+/**
+ * CalDavUtils::ScanDAVHeaderL
+ * scan DAV header
+ */
+void CalDavUtils::ScanDAVHeaderL(RHTTPTransaction &aTransaction,
+		TCalDAVOptions &aOptions)
+	{
+	RStringF Header = aTransaction.Session().StringPool().OpenFStringL(DAV);
+	THTTPHdrVal aHeaderVal;
+	if (aTransaction.Response().GetHeaderCollection().GetField(Header, 0,
+			aHeaderVal) == KErrNone)
+		{
+		RStringF FieldValStr = aTransaction.Session().StringPool().StringF(
+				aHeaderVal.StrF());
+		const TDesC8 &FieldValDesC = FieldValStr.DesC();
+		HBufC8 *FieldVal = FieldValDesC.AllocLC();
+		// delete all colons
+		TInt Pos = FieldVal->Find(colon);
+		while (Pos != KErrNotFound)
+			{
+			FieldVal->Des().Delete(Pos, 1);
+			Pos = FieldVal->Find(colon);
+			}
+		TLex8 Lex(FieldVal->Des());
+		TBool stop = EFalse;
+		while (!stop)
+			{
+			TPtrC8 Ptr = Lex.NextToken();
+			stop = Ptr.Length() == 0;
+			if (Ptr == ONE)
+				aOptions.ONE = ETrue;
+			else if (Ptr == TWO)
+				aOptions.TWO = ETrue;
+			else if (Ptr == THREE)
+				aOptions.THREE = ETrue;
+			else if (Ptr == access_control)
+				aOptions.access_control = ETrue;
+			else if (Ptr == calendar_access)
+				{
+				aOptions.calendar_access = ETrue;
+				// this is a CalDAV server for sure, MULTIGET and calendar-query is required
+				// we do not check for this anymore in CCaldavEngine::GetOptions()
+				aOptions.MULTIGET = ETrue;
+				aOptions.QUERY = ETrue;
+				}
+			else if (Ptr == calendar_schedule)
+				aOptions.calendar_schedule = ETrue;
+			else if (Ptr == calendar_auto_schedule)
+				aOptions.calendar_auto_schedule = ETrue;
+			else if (Ptr == sync_collection)
+				aOptions.sync_collection = ETrue;
+			else if (Ptr == extended_mkcol)
+				aOptions.extended_mkcol = ETrue;
+			}
+		CleanupStack::PopAndDestroy(FieldVal);
+		}
+	Header.Close();
+	}
+
+/**
+ * CalDavUtils::EnsureSlashL
+ * ensure trailing slash
+ */
+HBufC8* CalDavUtils::EnsureSlashL(HBufC8* aIn)
+	{
+	if ((aIn == NULL) || (aIn->Right(KSlash().Length()) == KSlash))
+		return aIn;
+	else
+		{
+		HBufC8 *out = HBufC8::NewL(aIn->Length() + KSlash().Length());
+		out->Des().Append(*aIn);
+		out->Des().Append(KSlash);
+		delete aIn;
+		aIn = NULL;
+		return out;
+		}
+	}
+
+/**
+ * CalDavUtils::EnsureSlashL
+ * ensure trailing slash
+ */
+HBufC8* CalDavUtils::EnsureSlashL(const TDesC8 &aIn)
+	{
+	HBufC8 *out = aIn.AllocL();
+	return CalDavUtils::EnsureSlashL(out);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/src/httpclient.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,687 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: 	basic http/webdav functionality
+*				handles all needed internet access for Caldav
+*/
+
+#include "httpclient.h"
+#include "caldavutils.h"
+#include <uri8.h>
+#include <http.h>
+#include <EIKENV.H>
+
+_LIT8(KTextXml,"text/xml");
+_LIT8(KTextCalendar,"text/calendar");
+_LIT8(KDepth,"depth");
+
+/**
+ * CHttpClient::CHttpClient
+ * default constructor
+ */
+CHttpClient::CHttpClient() :
+	iUser(0), iPassword(0), iEtag(0), iCredentialCount(0)
+	{
+	}
+
+/**
+ * CHttpClient::~CHttpClient
+ * default destructor
+ */
+CHttpClient::~CHttpClient()
+	{
+	delete iUser;
+	delete iPassword;
+	delete iEtag;
+
+	iSess.Close();
+	iRConnection.Close();
+	iSocketServ.Close();
+
+	}
+
+/**
+ * CHttpClient::NewLC
+ * first phase constructor
+ */
+CHttpClient* CHttpClient::NewLC()
+	{
+	CHttpClient* me = new (ELeave) CHttpClient;
+	CleanupStack::PushL(me);
+	me->ConstructL();
+	return me;
+	}
+
+/**
+ * CHttpClient::NewL
+ * first phase construction
+ */
+CHttpClient* CHttpClient::NewL()
+	{
+	CHttpClient* me = NewLC();
+	CleanupStack::Pop(me);
+	return me;
+	}
+
+/**
+ * CHttpClient::OpenSessionL
+ * open session and instal authentification
+ */
+void CHttpClient::OpenSessionL()
+	{
+	TRAPD(err, iSess.OpenL());
+
+	if (err != KErrNone)
+		{
+		_LIT(KErrMsg, "Cannot create session. Is internet access point configured?");
+		_LIT(KExitingApp, "Exiting app.");
+		CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
+		User::Leave(err);
+		}
+
+	// Install this class as the callback for authentication requests
+	InstallAuthenticationL(iSess);
+
+	// Set the session's connection info...
+	RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
+	// ...to use the socket server
+	connInfo.SetPropertyL(iSess.StringPool().StringF(HTTP::EHttpSocketServ,
+			RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));
+	// ...to use the connection
+	connInfo.SetPropertyL(
+			iSess.StringPool().StringF(HTTP::EHttpSocketConnection,
+					RHTTPSession::GetTable()),
+			THTTPHdrVal(REINTERPRET_CAST(TInt, &(iRConnection))));
+
+	}
+
+/**
+ * CHttpClient::ConstructL
+ * second phase construction
+ */
+void CHttpClient::ConstructL()
+	{
+	User::LeaveIfError(iSocketServ.Connect());
+	User::LeaveIfError(iRConnection.Open(iSocketServ));
+	
+	iExtPrefs.SetSnapPurpose( CMManager::ESnapPurposeInternet );
+	iExtPrefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnDisableNotes);
+	iPrefList.AppendL(&iExtPrefs);
+	iRConnection.Start(iPrefList);
+
+	OpenSessionL();
+	}
+
+/**
+ * CHttpClient::DeleteL
+ * HTTP DELETE
+ */
+TInt CHttpClient::DeleteL(const TDesC8 &aUrl, const TDesC8 &aETag)
+	{
+	iReturnCode = ERROR;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF(
+			HTTP::EDELETE, RHTTPSession::GetTable()));
+	if (aETag != KNullDesC8)
+		SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EIfMatch,
+				aETag);
+	SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent,
+			KUserAgent);
+	iTrans.SubmitL();
+
+	CActiveScheduler::Start();
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::HeadL
+ * HTTP HEAD
+ */
+TInt CHttpClient::HeadL(const TDesC8 &aUrl)
+	{
+	iReturnCode = ERROR;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF(
+			HTTP::EHEAD, RHTTPSession::GetTable()));
+	SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent,
+			KUserAgent);
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::GetL
+ * HTTP Get
+ */
+TInt CHttpClient::GetL(const TDesC8 &aUrl, CBufFlat *aResponse)
+	{
+	iReturnCode = ERROR;
+
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF(
+			HTTP::EGET, RHTTPSession::GetTable()));
+	SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent,
+			KUserAgent);
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+	iBodyResponse = NULL;
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::MkCalendarL
+ * Caldav MKCALENDAR
+ */
+TInt CHttpClient::MkCalendarL(const TDesC8 &aUrl, const TDesC8 &aBody,
+		CBufFlat *aResponse)
+	{
+	iReturnCode = ERROR;
+
+	if (aBody != KNullDesC8)
+		{
+		iBodyRequest = aBody.Alloc();
+		iTrans.Request().SetBody(*this);
+		}
+
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	RStringF mkcalendar = iSess.StringPool().OpenFStringL(MKCALENDAR);
+	iTrans = iSess.OpenTransactionL(uri, *this, mkcalendar);
+	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+
+	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+	SetHeaderL(hdr, HTTP::EContentType, KTextXml);
+
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+
+	mkcalendar.Close();
+	if (iBodyRequest)
+		{
+		delete iBodyRequest;
+		iBodyRequest = NULL;
+		}
+	iBodyResponse = NULL;
+
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::PutL
+ * HTTP PUT
+ */
+TInt CHttpClient::PutL(const TDesC8 &aUrl, const TDesC8 &aIcs,
+		CBufFlat *aResponse, const TDesC8 &aEtag)
+	{
+	iReturnCode = ERROR;
+
+	iBodyRequest = aIcs.Alloc();
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	iTrans = iSess.OpenTransactionL(uri, *this, iSess.StringPool().StringF(
+			HTTP::EPUT, RHTTPSession::GetTable()));
+	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+
+	iTrans.Request().SetBody(*this);
+
+	if (aEtag == KNullDesC8)
+		{
+		_LIT8(KStar, "*");
+		SetHeaderL(hdr, HTTP::EIfNoneMatch, KStar);
+		}
+	else
+		{
+#ifdef ETAG
+		 SetHeaderL(hdr,HTTP::EIfMatch,aEtag);
+#endif
+		}
+
+	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+	SetHeaderL(hdr, HTTP::EContentType, KTextCalendar);
+
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+
+	delete iBodyRequest;
+	iBodyRequest = NULL;
+	iBodyResponse = NULL;
+
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::ReportL
+ * Caldav REPORT 
+ */
+TInt CHttpClient::ReportL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest,
+		CBufFlat *aResponse)
+	{
+	iReturnCode = ERROR;
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	RStringF report = iSess.StringPool().OpenFStringL(REPORT);
+	iTrans = iSess.OpenTransactionL(uri, *this, report);
+	if (aBodyRequest.Length())
+		{
+		iBodyRequest = aBodyRequest.Alloc();
+		iTrans.Request().SetBody(*this);
+		}
+
+	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+	SetHeaderL(hdr, HTTP::EContentType, KTextXml);
+	SetHeaderL(hdr, KDepth, ONE);
+	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+
+	report.Close();
+
+	delete iBodyRequest;
+	iBodyRequest = NULL;
+	iBodyResponse = NULL;
+
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::PropfindL
+ * WebDAV PROPFIND
+ */
+TInt CHttpClient::PropfindL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest,
+		CBufFlat *aResponse, TBool depth)
+	{
+	iReturnCode = ERROR;
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	RStringF propfind = iSess.StringPool().OpenFStringL(PROPFIND);
+	iTrans = iSess.OpenTransactionL(uri, *this, propfind);
+	if (aBodyRequest.Length())
+		{
+		iBodyRequest = aBodyRequest.Alloc();
+		iTrans.Request().SetBody(*this);
+		}
+
+	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+	SetHeaderL(hdr, HTTP::EContentType, KTextXml);
+	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+	if (depth)
+		SetHeaderL(hdr, KDepth, ZERO);
+	else
+		SetHeaderL(hdr, KDepth, ONE);
+
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+
+	propfind.Close();
+
+	delete iBodyRequest;
+	iBodyRequest = NULL;
+	iBodyResponse = NULL;
+
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::ProppatchL
+ * Webdav PROPPATCH
+ */
+TInt CHttpClient::ProppatchL(const TDesC8 &aUrl, const TDesC8 &aBodyRequest, CBufFlat *aResponse)
+	{
+	iReturnCode = ERROR;
+	iBodyResponse = aResponse;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	RStringF proppatch = iSess.StringPool().OpenFStringL(PROPPATCH);
+	iTrans = iSess.OpenTransactionL(uri, *this, proppatch);
+	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+	SetHeaderL(hdr, HTTP::EContentType, KTextXml);
+	
+	iBodyRequest = aBodyRequest.Alloc();
+	iTrans.Request().SetBody(*this);
+	
+	iTrans.SubmitL();
+	CActiveScheduler::Start();
+
+	proppatch.Close();
+
+	delete iBodyRequest;
+	iBodyRequest = NULL;
+	iBodyResponse = NULL;
+
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::GetServerOptionsL
+ * HTTP OPTIONS
+ */
+TInt CHttpClient::GetServerOptionsL(const TDesC8 &aUrl,
+		TCalDAVOptions &aOptions)
+	{
+	iReturnCode = ERROR;
+	iAction = EActionOption;
+	iOptions = &aOptions;
+
+	TUriParser8 uri;
+	uri.Parse(aUrl);
+
+	RStringF options = iSess.StringPool().OpenFStringL(OPTIONS);
+	iTrans = iSess.OpenTransactionL(uri, *this, options);
+	SetHeaderL(iTrans.Request().GetHeaderCollection(), HTTP::EUserAgent,
+			KUserAgent);
+	iTrans.SubmitL();
+
+	CActiveScheduler::Start();
+
+	options.Close();
+
+	iAction = EActionNone;
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::GetNextDataPart
+ * GetNextDataPart callback
+ */
+TBool CHttpClient::GetNextDataPart(TPtrC8& aDataPart)
+	{
+	aDataPart.Set(iBodyRequest->Des());
+	return ETrue;
+	}
+
+/**
+ * CHttpClient::ReleaseData
+ * ReleaseData callback
+ */
+void CHttpClient::ReleaseData()
+	{
+	}
+
+/**
+ * CHttpClient::OverallDataSize
+ * OverallDataSize callback
+ */
+TInt CHttpClient::OverallDataSize()
+	{
+	if (iBodyRequest)
+		return iBodyRequest->Length();
+	else
+		return 0;
+	}
+
+/**
+ * CHttpClient::Reset
+ * Reset callback
+ */
+TInt CHttpClient::Reset()
+	{
+	return KErrNone;
+	}
+
+/**
+ * CHttpClient::SetHeaderL
+ * sets int header at session headers 
+ */
+void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField,
+		const TDesC8& aHdrValue)
+	{
+	RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue);
+	CleanupClosePushL(valStr);
+	THTTPHdrVal val(valStr);
+	aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,
+			RHTTPSession::GetTable()), val);
+	CleanupStack::PopAndDestroy(&valStr);
+	}
+
+/**
+ * CHttpClient::SetHeaderL
+ * set string header at session headers
+ */
+void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, const TDesC8 &aField,
+		const TDesC8 &aValue)
+	{
+	RStringF FieldVal = iSess.StringPool().OpenFStringL(aField);
+	CleanupClosePushL(FieldVal);
+	RStringF valStr = iSess.StringPool().OpenFStringL(aValue);
+	CleanupClosePushL(valStr);
+	THTTPHdrVal val(valStr);
+	aHeaders.SetFieldL(FieldVal, val);
+	CleanupStack::PopAndDestroy(&valStr);
+	CleanupStack::PopAndDestroy(&FieldVal);
+	}
+
+/**
+ * CHttpClient::GetCredentialsL
+ * ask for username and password for authentification
+ */
+TBool CHttpClient::GetCredentialsL(const TUriC8& /*aURI*/, RString aRealm,
+		RStringF /*aAuthenticationType*/, RString& aUsername,
+		RString& aPassword)
+	{
+	if (iCredentialCount)
+		{
+		iCredentialCount = 0;
+		User::Leave(KErrAccessDenied);
+		}
+	iCredentialCount++;
+	aUsername = aRealm.Pool().OpenStringL(*iUser);
+	aPassword = aRealm.Pool().OpenStringL(*iPassword);
+	return ETrue;
+	}
+
+/**
+ * CHttpClient::GetEtagHeaderL
+ * check for ETag and save it
+ */
+void CHttpClient::GetEtagHeaderL(RHTTPTransaction &aTransaction)
+	{
+	RStringF Header = aTransaction.Session().StringPool().StringF(HTTP::EETag,
+			RHTTPSession::GetTable());
+	THTTPHdrVal HeaderVal;
+	if (aTransaction.Response().GetHeaderCollection().GetField(Header, 0,
+			HeaderVal) == KErrNone)
+		{
+		RStringF FieldValStr = aTransaction.Session().StringPool().StringF(
+				HeaderVal.StrF());
+		const TDesC8 &FieldValDesC = FieldValStr.DesC();
+		delete iEtag;
+		iEtag = NULL;
+		iEtag = FieldValDesC.AllocL();
+		}
+	}
+
+/**
+ * CHttpClient::MHFRunL
+ * http state machine callback
+ */
+void CHttpClient::MHFRunL(RHTTPTransaction aTransaction,
+		const THTTPEvent& aEvent)
+	{
+	switch (aEvent.iStatus)
+		{
+		case THTTPEvent::EGotResponseHeaders:
+			{
+			// HTTP response headers have been received. We can determine now if there is
+			// going to be a response body to save.
+			RHTTPResponse resp = aTransaction.Response();
+			iReturnCode = resp.StatusCode();
+
+			if (iAction == EActionOption)
+				{
+				CalDavUtils::ScanAllowHeaderL(aTransaction, *iOptions);
+				CalDavUtils::ScanDAVHeaderL(aTransaction, *iOptions);
+				}
+
+			GetEtagHeaderL(aTransaction);
+			
+			TBool cancelling = ETrue;
+			if (resp.HasBody() && (iReturnCode >= OK) && (iReturnCode
+					< MUTIPLECHOICES))
+				cancelling = EFalse;
+
+			if (cancelling)
+				{
+				aTransaction.Close();
+				CActiveScheduler::Stop();
+				}
+			}
+			break;
+		case THTTPEvent::EGotResponseBodyData:
+			{
+			// Get the body data supplier
+			MHTTPDataSupplier* body = aTransaction.Response().Body();
+			TPtrC8 dataChunk;
+			TBool isLast = body->GetNextDataPart(dataChunk);
+			if (iBodyResponse)
+				iBodyResponse->InsertL(iBodyResponse->Size(), dataChunk);
+			// Done with that bit of body data
+			body->ReleaseData();
+			}
+			break;
+		case THTTPEvent::EResponseComplete:
+			{
+			// The transaction's response is complete
+			}
+			break;
+		case THTTPEvent::ESucceeded:
+			{
+			aTransaction.Close();
+			CActiveScheduler::Stop();
+			}
+			break;
+		case THTTPEvent::EFailed:
+			{
+			aTransaction.Close();
+			CActiveScheduler::Stop();
+			}
+			break;
+		case THTTPEvent::ERedirectedPermanently:
+			{
+			}
+			break;
+		case THTTPEvent::ERedirectedTemporarily:
+			{
+			}
+			break;
+		default:
+			{
+			// close off the transaction if it's an error
+			if (aEvent.iStatus < 0)
+				{
+				iReturnCode = aEvent.iStatus;
+				aTransaction.Close();
+				CActiveScheduler::Stop();
+				}
+			}
+			break;
+		}
+	}
+
+/**
+ * CHttpClient::MHFRunError
+ * http stack erros
+ */
+TInt CHttpClient::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/,
+		const THTTPEvent& /*aEvent*/)
+	{
+	iReturnCode = aError;
+	return KErrNone;
+	}
+
+/**
+ * CHttpClient::SetUserL
+ * set username for authentification
+ */
+void CHttpClient::SetUserL(const TDesC8 &aUser)
+	{
+	if (iUser)
+		delete iUser;
+	iUser = aUser.Alloc();
+	iSess.Close();
+	OpenSessionL();
+	}
+
+/**
+ * CHttpClient::SetPasswordL
+ * Set Password for authentification
+ */
+void CHttpClient::SetPasswordL(const TDesC8 &aPassword)
+	{
+	if (iPassword)
+		delete iPassword;
+	iPassword = aPassword.Alloc();
+	iSess.Close();
+	OpenSessionL();
+	}
+
+/**
+ * CHttpClient::User
+ * get username
+ */
+TPtrC8 CHttpClient::User()
+	{
+	return iUser ? *iUser : KNullDesC8();
+	}
+
+/**
+ * CHttpClient::Password
+ * get password
+ */
+TPtrC8 CHttpClient::Password()
+	{
+	return iPassword ? *iPassword : KNullDesC8();
+	}
+
+/**
+ * CHttpClient::ReturnCode
+ * get returned HTTP code
+ */
+TInt CHttpClient::ReturnCode()
+	{
+	return iReturnCode;
+	}
+
+/**
+ * CHttpClient::ETag
+ * get ETag
+ */
+TPtrC8 CHttpClient::ETag()
+	{
+	return iEtag ? *iEtag : KNullDesC8();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarengines/caldav/tsrc/CalDavTest.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,936 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav Test Suite 
+*
+*/
+
+#include "CalDavTest.h"
+#include <e32base.h>
+#include <e32std.h>
+#include <e32base.h>
+#include <calentry.h>
+#include <calentryview.h>
+#include <caleninterimutils2.h>
+#include <calcalendarinfo.h>
+#include <calsession.h>
+#include "caldavengine.h"
+#include "httpclient.h"
+#include <caldavsession.h>
+_LIT(KTextConsoleTitle, "Console");
+_LIT(KTextFailed, " failed, leave code = %d");
+_LIT(KTextPressAnyKey, " [press any key]\n");
+//  Global Variables
+LOCAL_D CConsoleBase* console; // write all messages to this
+
+_LIT8(urlAries,"http://aries.demo.sun.com:3080/davserver/dav/home/modendahl@demo.sun.com/calendar/");
+_LIT8(urlAriesPrincipal,"http://aries.demo.sun.com:3080/davserver/dav/principals/modendahl/");
+_LIT8(urlAriesHome,"http://aries.demo.sun.com:3080/davserver/dav/home/modendahl@demo.sun.com/");
+_LIT8(urlWN,"http://whatsnew.demo.iplanet.com:3080/dav/home/modendahl/calendar/");
+_LIT8(userSUN,"modendahl");
+_LIT8(passwordSUN,"secret");
+_LIT8(urlGoogle,"https://www.google.com/calendar/dav/maximilian.odendahl@sun.com/events/");
+_LIT8(urlGooglePrincipal,"https://www.google.com/calendar/dav/maximilian.odendahl@sun.com/user/");
+_LIT8(userGoogle,"maximilian.odendahl@sun.com");
+_LIT8(passwordGoogle,"iplanetiplanet");
+_LIT8(urlChandler,"https://hub.chandlerproject.org/dav/mod/f16c9eb0-6373-11de-979e-cdd32d46e10a11111/");
+_LIT8(urlChandlerPrincipal,"https://hub.chandlerproject.org/dav/users/mod/");
+_LIT8(userChandler,"mod");
+_LIT8(passwordChandler,"modmod");
+_LIT8(urlBedework,"http://bedework.org:8585/ucaldav/user/testuser29/calendar/");
+_LIT8(urlBedeWorkPrincipal,"http://bedework.org:8585/ucaldav/principals/users/testuser29");
+_LIT8(userBedework,"testuser29");
+_LIT8(passwordbedework,"bedework");
+_LIT8(urlYahoo,"https://caldav.calendar.yahoo.com/dav/lkz633/Calendar/lkz633/");
+_LIT8(urlYahooPrincipal,"https://caldav.calendar.yahoo.com/principals/users/lkz633/");
+_LIT8(userYahoo,"lkz633");
+_LIT8(passwordYahoo,"iplanetiplanet");
+_LIT8(urlOracle,"http://kingsknight.sfbay.sun.com:7777/caldav/Sun/home/7B7B.65E6.user.6FCA54EE73AD4821811999F4D7679F6E000000000070%40email.invalid/calendars/MyCalendar");
+_LIT8(urlOraclePrincipal,"http://kingsknight.sfbay.sun.com:7777/caldav/Sun/principals/individuals/7B7B.65E6.user.6FCA54EE73AD4821811999F4D7679F6E000000000070%40email.invalid");
+_LIT8(userOracle,"symbian");
+_LIT8(passwordOracle,"Secret12");
+_LIT8(urlSogo,"http://sogo-demo.inverse.ca/SOGo/dav/sogo3/Calendar/personal/");
+_LIT8(userSogo,"sogo3");
+_LIT8(passwordSogo,"sogo3");
+_LIT8(urlDAV,"http://dhcp-usca15-127-168.red.iplanet.com/dav/calendar/");
+_LIT8(userDAV,"max");
+_LIT8(passwordDAV,"max");
+_LIT8(urlApple,"http://zeta.macosforge.org:8008/calendars/__uids__/1E872019-0078-412D-8EE0-85A5680365C2/calendar/");
+_LIT8(principalAplle,"http://zeta.macosforge.org:8008/calendars/__uids__/1E872019-0078-412D-8EE0-85A5680365C2/calendar/");
+_LIT8(userApple,"trial1");
+_LIT8(passwordApple,"lompywickets");
+_LIT8(urlKerio,"http://iop.test.kerio.com/calendars/iop.test.kerio.com/user1/Calendar");
+_LIT8(principalKerio,"http://iop.test.kerio.com/caldav/iop.test.kerio.com/user1/");
+_LIT8(userKerio,"user1");
+_LIT8(passwordkerio,"x");
+_LIT8(urlDaviCal,"http://dev.davical.org:8008/caldav.php/user1/home/");
+_LIT8(principalDaviCal,"http://dev.davical.org:8008/caldav.php/user1/");
+_LIT8(userDaviCal,"user1");
+_LIT8(passwordDaviCal,"user1");
+_LIT8(urlblabla,"http://www.blablabalbalabal.com/calendar/");
+_LIT8(passwordblabla,"bla");
+_LIT8(userblabla,"blabla");
+_LIT(calendar, "c:calendar12345");
+_LIT8(KFixedUIDics,"123456.ics");
+
+#define TWOSECONDS TTimeIntervalMicroSeconds32(2000000)
+
+void CreateCalFileL()
+	{
+	CCalSession* session = CCalSession::NewL();
+	CleanupStack::PushL(session);
+	TRAPD(err, session->CreateCalFileL(calendar));
+	if (err == KErrAlreadyExists)
+		{
+		session->DeleteCalFileL(calendar);
+		session->CreateCalFileL(calendar);
+		}
+	CleanupStack::PopAndDestroy(session);
+	}
+
+void DeleteCalFileL()
+	{
+	CCalSession* session = CCalSession::NewL();
+	CleanupStack::PushL(session);
+	session->DeleteCalFileL(calendar);
+	CleanupStack::PopAndDestroy(session);
+	}
+
+TBool GetBoolFromProperties2(CCalCalendarInfo* info, const TDesC8 &aKey)
+	{
+	TBool boolean;
+	TPckgC<TBool> pckgboolean(boolean);
+	pckgboolean.Set(info->PropertyValueL(aKey));
+	return pckgboolean();
+	}
+
+TCalTime GetTimeFromProperties2(CCalCalendarInfo* info, const TDesC8 &aKey)
+	{
+	TCalTime time;
+	TPckgC<TCalTime> pckgtime(time);
+	pckgtime.Set(info->PropertyValueL(aKey));
+	return pckgtime();
+	}
+
+void NewApptL(HBufC8* aUid, TBool aEvent, CCalEntryView* iCalEntryView)
+	{
+	CCalEntry* appt = CCalEntry::NewL(aEvent ? CCalEntry::EEvent
+			: CCalEntry::ETodo, aUid, CCalEntry::EMethodNone, 0);
+	CleanupStack::PushL(appt);
+
+	//Some data
+	TBuf16<100> summary;
+	summary.Copy(*aUid);
+	appt->SetSummaryL(summary);
+	appt->SetLocationL(_L("Location2"));
+	appt->SetDescriptionL(_L("Description3"));
+
+	//Start / end date
+	TTime start;
+	start.UniversalTime();
+	TTime end;
+	end.UniversalTime();
+	TCalTime startCalTime;
+	startCalTime.SetTimeUtcL(start);
+	TCalTime endCalTime;
+	endCalTime.SetTimeUtcL(end);
+
+	//Set it
+	appt->SetStartAndEndTimeL(startCalTime, endCalTime);
+
+	//Store this new Entry
+
+	RPointerArray<CCalEntry> entryArray;
+	CleanupClosePushL(entryArray);
+	entryArray.AppendL(appt);
+	TInt success(0);
+	iCalEntryView->StoreL(entryArray, success);
+	entryArray.Reset();
+	CleanupStack::PopAndDestroy(&entryArray);
+	CleanupStack::PopAndDestroy(appt);
+	}
+
+CalDavTest::CalDavTest(CConsoleBase* console)
+	{
+	iConsole = console;
+	TInt connect = iFileLogger.Connect();
+	TTime home;
+	home.UniversalTime();
+	_LIT(KDateFormat,"%H%T%S");
+	TBuf<20> StringTime;
+	home.FormatL(StringTime, KDateFormat);
+	StringTime.Append(_L(".txt"));
+	iFileLogger.CreateLog(_L("CalDav"),StringTime, EFileLoggingModeOverwrite);
+	}
+
+CalDavTest::~CalDavTest()
+	{
+	iFileLogger.CloseLog();
+	iFileLogger.Close();
+	}
+
+void CalDavTest::Write(TBool aSuccess, const char* aMessage)
+	{
+	TBuf<500> buffer;
+	TPtrC8 ptr(reinterpret_cast<const TUint8*> (aMessage));
+	buffer.Copy(ptr);
+
+	Write(aSuccess, buffer);
+	}
+
+void CalDavTest::Write(TBool aSuccess, const TDesC &aMessage)
+	{
+	// convert char* into tbug
+	TBuf<500> buffer;
+	buffer.Append(aMessage);
+
+	if (aSuccess)
+		buffer.Append(_L("....PASSED\n"));
+	else
+		buffer.Append(_L("....FAILED\n"));
+
+	// write to console and file
+	Write(buffer);
+	}
+
+void CalDavTest::TestClientServerL(TInt aSucces, const TDesC8 &aUrl,
+		const TDesC8 &aUser, const TDesC8 &aPassword)
+	{
+	TBuf16<500> url;
+	url.Copy(aUrl);
+	Write(_L("\n\nStarting CalDav client-server test..."));
+	Write(url);
+
+	CreateCalFileL();
+
+	CCalDavSession *server = CCalDavSession::NewLC();
+	iSession = server;
+
+	if (ConfigureSessionL(aSucces, aUrl, aUser, aPassword) == KErrNone)
+		{
+		OptionSession();
+		}
+
+	CleanupStack::PopAndDestroy(server);
+	iSession = NULL;
+	DeleteCalFileL();
+
+	Write(_L("\nFinished CalDav client-server test..."));
+	Write(_L("\n\n"));
+	}
+
+void CalDavTest::TestGeneralEngineL()
+	{
+	CreateCalFileL();
+	CCalDavEngine* store = CCalDavEngine::NewLC(calendar);
+	iEngine = store;
+
+	CalendarInfoL();
+	GetUIDByUrl();
+	GetBaseUrl();
+
+	CleanupStack::PopAndDestroy(store);
+	iEngine = NULL;
+	DeleteCalFileL();
+	}
+
+void CalDavTest::TestEngineL(TInt aSucces, const TDesC8 &aUrl,
+		const TDesC8 &aUser, const TDesC8 &aPassword, TBool aWebdavsync,
+		TBool aCtag, TBool aEvent, TBool aTodo, TBool aFreeBusy, TBool aJournal)
+	{
+	Write(_L("\n\nStarting CalDav Engine test..."));
+	TBuf16<500> url;
+	url.Copy(aUrl);
+	Write(url);
+	Write(_L("\n"));
+
+	CreateCalFileL();
+
+	CCalDavEngine* store = CCalDavEngine::NewLC(calendar);
+
+	iEngine = store;
+	iWebdavSync = aWebdavsync;
+	iCtag = aCtag;
+
+	iVEVENT = aEvent;
+	iVTODO = aTodo;
+	iVFREEBUSY = aFreeBusy;
+	iVJOURNAL = aJournal;
+
+	Write(_L("\n\nStarting init and option tests...\n"));
+
+	Enabled(EFalse);
+	if (EnableL(aSucces, aUrl, aUser, aPassword) == KErrNone)
+		{
+		Enabled(ETrue);
+		OptionsL();
+		CTagL(ETrue);
+		SynctokenL(ETrue);
+
+		/******* Test events ******/
+		Write(_L("\nStarting VEvent engine tests...\n\n"));
+
+		HBufC8* newuid = iEngine->iCalIntermimUtils2->GlobalUidL();
+		// need to save it, as it will be destroyed by CCalEntry::NewL
+		TBuf8<100> uid;
+		uid.Append(*newuid);
+		// does entry exists locally
+		DoesExistL(EFalse, uid);
+		// add new local event with UID
+		NewApptL(newuid, ETrue, iEngine->iCalEntryView);
+		// does entry exists locally
+		DoesExistL(ETrue, uid);
+
+		// send to server using handle	 
+		unsigned long local = iEngine->DoesEntryExistL(uid);
+		// send existing event to server
+		SendL(local);
+		// available on server
+		if (iEngine->iOptions.VEVENT)
+			{
+			HeadL(ETrue, uid);
+			//download from server
+			DownloadLGetL(local);
+			DownloadLMultiGetL(local);
+			// delete on server 
+			DeleteServerL(local);
+			// available on server
+			HeadL(EFalse, uid);
+			}
+		else
+			HeadL(EFalse, uid);
+
+		// delete locally 
+		DeleteClientL(uid);
+		// should be gone now
+		DoesExistL(EFalse, uid);
+		/**************************/
+
+		CTagL(!iEngine->iOptions.VEVENT);
+		SynctokenL(!iEngine->iOptions.VEVENT);
+
+		User::After(TWOSECONDS);
+		SyncL();
+
+		CTagL(ETrue);
+		SynctokenL(ETrue);
+
+		// test synchronization method, put/delete on server using http calls		
+		if (iEngine->iOptions.VEVENT)
+			{
+			Write(_L("\nStarting VEvent http and sync tests...\n\n"));
+			// create directly on server using only http calls
+			SendL(ETrue);
+			// we should not have this yet
+			DoesExistL(EFalse, KFixedUIDics);
+			User::After(TWOSECONDS);
+			SyncL();
+			// now we should
+			DoesExistL(ETrue, KFixedUIDics);
+			// delete directly on server
+			DeleteServerL();
+			// we should still have it
+			DoesExistL(ETrue, KFixedUIDics);
+			User::After(TWOSECONDS);
+			SyncL();
+			// now it should be gone locally
+			DoesExistL(EFalse, KFixedUIDics);
+			}
+
+		/******* Test VTodo ******/
+
+		Write(_L("\n\nStarting VTodo tests...\n\n"));
+
+		HBufC8* newuid2 = iEngine->iCalIntermimUtils2->GlobalUidL();
+		// need to save it, as it will be destroyed by CCalEntry::NewL
+		TBuf8<100> uid2;
+		uid2.Append(*newuid2);
+		// does entry exists locally
+		DoesExistL(EFalse, uid2);
+		// add new local event with UID
+		NewApptL(newuid2, EFalse, iEngine->iCalEntryView);
+		// does entry exists locally
+		DoesExistL(ETrue, uid2);
+
+		// send to server using handle	 
+		unsigned long local2 = iEngine->DoesEntryExistL(uid2);
+		// send existing event to server
+		SendL(local2);
+
+		if (iEngine->iOptions.VTODO)
+			{
+			// available on server
+			HeadL(ETrue, uid2);
+			//download from server
+			DownloadLGetL(local2);
+			DownloadLMultiGetL(local2);
+			// delete on server 
+			DeleteServerL(local2);
+			// available on server
+			HeadL(EFalse, uid2);
+			}
+		else
+			HeadL(EFalse, uid2);
+		// delete locally 
+		DeleteClientL(uid2);
+		// should be gone now
+		DoesExistL(EFalse, uid2);
+		/**************************/
+
+		CTagL(!iEngine->iOptions.VTODO);
+		SynctokenL(!iEngine->iOptions.VTODO);
+
+		// test synchronization method, put/delete on server using http calls		
+		if (iEngine->iOptions.VTODO)
+			{
+			Write(_L("\nStarting VTodo http and sync tests...\n\n"));
+			// create directly on server using only http calls
+			SendL(EFalse);
+			// we should not have this yet
+			DoesExistL(EFalse, KFixedUIDics);
+			User::After(TWOSECONDS);
+			SyncL();
+			// now we should
+			DoesExistL(ETrue, KFixedUIDics);
+			// delete directly on server
+			DeleteServerL();
+			// we should still have it
+			DoesExistL(ETrue, KFixedUIDics);
+			User::After(TWOSECONDS);
+			SyncL();
+			// now it should be gone locally as well
+			DoesExistL(EFalse, KFixedUIDics);
+			}
+
+		/**** Test Calendar ******/
+		/*
+		 // creating calendars under home calendar should not be allowed
+		 if (iEngine->iOptions.MKCALENDAR)
+		 {
+		 Write(_L("\n\nStarting Calendar tests...\n\n"));
+		 _LIT8(howareyou, "howareyoudoingtoday");
+		 MkCalendarL(KErrNone, howareyou);
+		 MkCalendarL(KErrArgument, howareyou);
+		 DeleteCalendarL(howareyou);
+		 }
+		 */
+		/**************************/
+		iEngine->DisableL();
+		}
+
+	CleanupStack::PopAndDestroy(store);
+	iEngine = NULL;
+	DeleteCalFileL();
+	
+	Write(_L("\n\nFinished CalDav Engine test..."));
+	Write(_L("\n\n"));
+	}
+
+void CalDavTest::Write(const TDesC &aMessage)
+	{
+	iConsole->Write(aMessage);
+	iFileLogger.Write(aMessage);
+	}
+
+void CalDavTest::Enabled(TBool aEnabled)
+	{
+	Write(iEngine->EnabledSync() == aEnabled, __FUNCTION__);
+	}
+
+void CalDavTest::DoesExistL(TBool aExists, const unsigned long localuid)
+	{
+	CCalEntry* entry = iEngine->iCalEntryView->FetchL(localuid);
+	CleanupStack::PushL(entry);
+	unsigned long uid = iEngine->DoesEntryExistL(entry->UidL());
+	Write(aExists ? uid > 0 : uid == 0, __FUNCTION__);
+
+	CleanupStack::PopAndDestroy(entry);
+	}
+
+void CalDavTest::DoesExistL(TBool aExists, const TDesC8 &aUID)
+	{
+	unsigned long uid = iEngine->DoesEntryExistL(aUID);
+	Write(aExists ? uid > 0 : uid == 0, __FUNCTION__);
+	}
+
+void CalDavTest::HeadL(TBool aExists, const TDesC8 &aUid)
+	{
+	TBool del = iEngine->HeadL(aUid) == OK;
+	Write(aExists == del, __FUNCTION__);
+	}
+
+void CalDavTest::MkCalendarL(TInt aSuccess, const TDesC8 &aName)
+	{
+	TInt ret = iEngine->MkcalendarL(aName);
+	Write(ret == aSuccess, __FUNCTION__);
+	}
+
+void CalDavTest::DeleteCalendarL(const TDesC8 &aName)
+	{
+	Write(iEngine->DeleteCalendarL(aName) == KErrNone, __FUNCTION__);
+	}
+
+void CalDavTest::OptionsL()
+	{
+	TBuf<500> message;
+	message.Append(_L("Options Displayname "));
+	CCalCalendarInfo* info = iEngine->iCalSession->CalendarInfoL();
+	TBuf<500> display;
+	display.Copy(info->NameL());
+	message.Append(display);
+	delete info;
+	Write(display != KNullDesC, message);
+	Write(iEngine->iOptions.sync_collection == iWebdavSync, _L("Options Webdav Sync"));
+	Write(iEngine->iOptions.sync_ctag == iCtag, _L("Options Ctag"));
+	Write(iEngine->iOptions.VEVENT == iVEVENT, _L("Options VEVENT"));
+	Write(iEngine->iOptions.VTODO == iVTODO, _L("Options VTODO"));
+	Write(iEngine->iOptions.VFREEBUSY == iVFREEBUSY, _L("FREEBUSY"));
+	Write(iEngine->iOptions.VJOURNAL == iVJOURNAL, _L("VJOURNAL"));
+	}
+
+void CalDavTest::CalendarInfoL()
+	{
+	_LIT8(user,"user");
+	_LIT8(password,"pass");
+	_LIT8(url,"http://neindanke/");
+	iEngine->SetUserL(user);
+	iEngine->SetUrlL(url);
+	iEngine->SetPasswordL(password);
+	iEngine->SetSyncIntervalL(TTimeIntervalMinutes(5));
+	iEngine->SetPastDaysL(TTimeIntervalDays(10));
+	iEngine->SetKeepServerEntryL(EFalse);
+	iEngine->SetImmediateSyncL(ETrue);
+	iEngine->EnableL();
+
+	iEngine->iCalSession = CCalSession::NewL();
+	iEngine->iCalSession->OpenL(calendar);
+
+	CCalCalendarInfo* calendarInfo = iEngine->iCalSession->CalendarInfoL();
+	CleanupStack::PushL(calendarInfo);
+
+	Write(!GetBoolFromProperties2(calendarInfo, KCaldavEnabled), _L("CalendarInfo: enabled"));
+	Write(!GetBoolFromProperties2(calendarInfo, KCaldavKeepServer), _L("CalendarInfo: Keepserver"));
+	Write(GetBoolFromProperties2(calendarInfo, KCaldavImmediateSync), _L("CalendarInfo: ImmediateSync"));
+	Write(calendarInfo->PropertyValueL(KCaldavUrl) == url, _L("CalendarInfo: url"));
+	Write(calendarInfo->PropertyValueL(KCaldavUser) == user, _L("CalendarInfo: user"));
+	Write(calendarInfo->PropertyValueL(KCaldavPassword) == password, _L("CalendarInfo: password"));
+
+	TTimeIntervalDays pastday;
+	TPckgC<TTimeIntervalDays> pastdays(pastday);
+	pastdays.Set(calendarInfo->PropertyValueL(KCaldavPastDays));
+	Write(TTimeIntervalDays(10) == pastdays(), _L("CalendarInfo: pastdays"));
+
+	TTimeIntervalMinutes syncintervals;
+	TPckgC<TTimeIntervalMinutes> syncinterval(syncintervals);
+	syncinterval.Set(calendarInfo->PropertyValueL(KCaldavSyncInterval));
+	Write(TTimeIntervalMinutes(5) == syncinterval(), _L("CalendarInfo: syncinterval"));
+
+	/*
+	 Write(calendarInfo->PropertyValueL(KCaldavSynctoken) ==KNullDesC8, _L("CalendarInfo: SyncToken"));
+	 Write(calendarInfo->PropertyValueL(KCaldavCtag) == KNullDesC8, _L("CalendarInfo: CTag"));
+	 Write(GetTimeFromProperties2(calendarInfo,KCaldavTime).TimeUtcL()==  TCalTime().TimeUtcL(), _L("CalendarInfo: LastTime"));		
+	 */
+
+	// access point	    
+	CleanupStack::PopAndDestroy(calendarInfo);
+
+	delete iEngine->iCalSession;
+	iEngine->iCalSession = NULL;
+	}
+
+void CalDavTest::GetUIDByUrl()
+	{
+	_LIT8(url,"1234");
+	_LIT8(url1,"/hi/1234.ics");
+	_LIT8(url2,"/1234.ics");
+	_LIT8(url3,"1234.ics");
+	_LIT8(url4,"1234");
+
+	Write(iEngine->GetUIDByUrl(url1) == url, __FUNCTION__);
+	Write(iEngine->GetUIDByUrl(url2) == url, __FUNCTION__);
+	Write(iEngine->GetUIDByUrl(url3) == url, __FUNCTION__);
+	Write(iEngine->GetUIDByUrl(url4) == url, __FUNCTION__);
+	}
+
+void CalDavTest::GetBaseUrl()
+	{
+	_LIT8(url1,"http://www.ok.de/1234.ics");
+	_LIT8(url,"http://www.ok.de");
+	_LIT8(url2,"https://www.ok.de:80/123444444.ics");
+	_LIT8(urlport,"https://www.ok.de:80");
+
+	iEngine->GetBaseUrl(url1);
+	Write(*iEngine->iBaseUrl == url, __FUNCTION__);
+
+	iEngine->GetBaseUrl(url2);
+	Write(*iEngine->iBaseUrl == urlport, __FUNCTION__);
+	}
+
+void CalDavTest::CTagL(TBool aEqual)
+	{
+	if (iEngine->iOptions.sync_ctag && !iEngine->iOptions.sync_collection)
+		{
+		HBufC8* tag = iEngine->GetCTagL();
+		Write(aEqual ? *tag == *iEngine->iCTag : *tag != *iEngine->iCTag, _L("CTag"));
+		if (aEqual && (*tag != *iEngine->iCTag))
+			{
+			TBuf<500> name;
+			name.Append(_L("saved cTag: "));
+			TBuf<100> one;
+			one.Copy(*iEngine->iCTag);
+			name.Append(one);
+			name.Append(_L(" current server cTag: "));
+			TBuf<100> two;
+			two.Copy(*tag);
+			name.Append(two);
+			Write(ETrue, name);
+			}
+		delete tag;
+		}
+	}
+
+void CalDavTest::SynctokenL(TBool aEqual)
+	{
+	if (iEngine->iOptions.sync_collection)
+		{
+		HBufC8* tag = iEngine->GetSyncTokenL();
+		Write(aEqual ? *tag == *iEngine->iSynctoken : *tag
+				!= *iEngine->iSynctoken, _L("SyncToken"));
+		if (aEqual && (*tag != *iEngine->iSynctoken))
+			{
+			TBuf<500> name;
+			name.Append(_L("saved Syntoken: "));
+			TBuf<100> one;
+			one.Copy(*iEngine->iSynctoken);
+			name.Append(one);
+			name.Append(_L(" current server Synctoken: "));
+			TBuf<100> two;
+			two.Copy(*tag);
+			name.Append(two);
+			Write(ETrue, name);
+			}
+		delete tag;
+		}
+	}
+
+void CalDavTest::SendL(const unsigned long localuid)
+	{
+	Write(iEngine->UploadEntryL(localuid, MCalChangeCallBack2::EChangeAdd,
+			MCalChangeCallBack2::EChangeEntryAll) == KErrNone, __FUNCTION__);
+	}
+
+void CalDavTest::SendL(TBool aVEvent)
+	{
+	TBuf8<500> url;
+	url.Append(*iEngine->iUrl);
+	url.Append(KFixedUIDics);
+	_LIT8(KEntry1, "BEGIN:VCALENDAR\r\n"
+			"PRODID:Symbian\r\n"
+			"VERSION:2.0\r\n"
+			"BEGIN:VEVENT\r\n"
+			"UID:123456\r\n"
+			"SUMMARY:first entry\r\n"
+			"DESCRIPTION:a description\r\n"
+			"DTSTAMP:20100411T100000Z\r\n"
+			"DTSTART:20100411T100000Z\r\n"
+			"DTEND:20100412T120000Z\r\n"
+			"END:VEVENT\r\n"
+			"END:VCALENDAR\r\n");
+	_LIT8(KEntry2, "BEGIN:VCALENDAR\r\n"
+			"PRODID:Symbian\r\n"
+			"VERSION:2.0\r\n"
+			"BEGIN:VTODO\r\n"
+			"DTSTAMP:20100205T235335Z\r\n"
+			"DUE;VALUE=DATE:20110104\r\n"
+			"SUMMARY:Task #1\r\n"
+			"UID:123456\r\n"
+			"END:VTODO\r\n"
+			"END:VCALENDAR\r\n");
+
+	CBufFlat* response = CBufFlat::NewL(500);
+	CleanupStack::PushL(response);
+	TInt Ret = iEngine->iHttp->PutL(url, aVEvent ? KEntry1() : KEntry2(),
+			response);
+	CleanupStack::PopAndDestroy(response);
+	
+	if (Ret==PRECONDFAILED)
+	{	
+		//might be still there from an older run
+		TBuf8<500> url;
+		url.Append(*iEngine->iUrl);
+		url.Append(KFixedUIDics);
+		iEngine->iHttp->DeleteL(url);
+		
+		CBufFlat* response = CBufFlat::NewL(500);
+		CleanupStack::PushL(response);
+		Ret = iEngine->iHttp->PutL(url, aVEvent ? KEntry1() : KEntry2(),
+				response);
+		CleanupStack::PopAndDestroy(response);
+		
+		// locally as well maybe:
+		iEngine->DeleteLocalEntryL(KFixedUIDics);
+	}
+	Write((Ret == CREATED) || (Ret == NOCONTENT) || (Ret == OK), __FUNCTION__);
+	}
+
+void CalDavTest::SyncL()
+	{
+	Write(iEngine->SyncL(), __FUNCTION__);
+	}
+
+void CalDavTest::DownloadLGetL(const unsigned long localuid)
+	{
+	TInt aPos = iEngine->iLocalUidArray.Find(localuid);
+	if (aPos != KErrNotFound)
+		Write(iEngine->DownloadEntryL(iEngine->iGlobalUidArray[aPos])
+				== KErrNone, __FUNCTION__);
+	else
+		Write(EFalse, __FUNCTION__);
+	}
+void CalDavTest::DownloadLMultiGetL(const unsigned long localuid)
+	{
+	if (iEngine->iOptions.MULTIGET)
+		{
+		TInt aPos = iEngine->iLocalUidArray.Find(localuid);
+		if (aPos != KErrNotFound)
+			{
+			TBuf8<500> url;
+			url.Append(iEngine->iUrl->Mid(iEngine->iBaseUrl->Length()));
+			url.Append(iEngine->iGlobalUidArray[aPos]);
+			url.Append(KIcs);
+			CDesC8ArrayFlat *multiget = new (ELeave) CDesC8ArrayFlat(4);
+			CleanupStack::PushL(multiget);
+			multiget->AppendL(url);
+			multiget->AppendL(url);
+			Write(iEngine->DownloadEntryL(multiget) == KErrNone, __FUNCTION__);
+			multiget->Reset();
+			CleanupStack::PopAndDestroy(multiget);
+			}
+		else
+			Write(EFalse, __FUNCTION__);
+		}
+	}
+
+TInt CalDavTest::ConfigureSessionL(TInt aSucces, const TDesC8 &aUrl,
+		const TDesC8 &aUser, const TDesC8 &aPassword)
+	{
+	iSession->SetUrl(calendar, aUrl);
+	iSession->SetUsername(calendar, aUser);
+	iSession->SetPassword(calendar, aPassword);
+	TInt ret = iSession->Enable(calendar);
+	Write(ret == aSucces, __FUNCTION__);
+	return ret;
+	}
+
+void CalDavTest::OptionSession()
+	{
+	TTimeIntervalDays pastdays = 0;
+	TTimeIntervalMinutes syncinterval = 0;
+	TBool immediatesync = EFalse;
+	TBool keepserverentry = EFalse;
+	TBuf8<500> url, username, password;
+
+	// retreive standard values
+	iSession->PastDays(calendar, pastdays);
+	iSession->SyncInterval(calendar, syncinterval);
+	iSession->ImmediateSync(calendar, immediatesync);
+	iSession->KeepServerEntry(calendar, keepserverentry);
+	iSession->Url(calendar, url);
+	iSession->Username(calendar, username);
+	iSession->Password(calendar, password);
+
+	Write(pastdays.Int() == DEFAULT_PAST_DAYS, __FUNCTION__);
+	Write(syncinterval.Int() == DEFAULT_SYNC_MINUTES, __FUNCTION__);
+	Write(immediatesync, __FUNCTION__);
+	Write(keepserverentry, __FUNCTION__);
+	Write(url == urlAries, __FUNCTION__);
+	Write(password == passwordSUN, __FUNCTION__);
+	Write(username == userSUN, __FUNCTION__);
+
+	// set new values
+	pastdays = TTimeIntervalDays(100);
+	syncinterval = TTimeIntervalMinutes(4);
+	immediatesync = EFalse;
+	keepserverentry = EFalse;
+	iSession->SetPastDays(calendar, pastdays);
+	iSession->SetSyncInterval(calendar, syncinterval);
+	iSession->SetImmediateSync(calendar, immediatesync);
+	iSession->SetKeepServerEntry(calendar, keepserverentry);
+	iSession->SetUrl(calendar, urlGooglePrincipal);
+	iSession->SetUsername(calendar, userGoogle);
+	iSession->SetPassword(calendar, passwordGoogle);
+
+	// check if new values are set correctly
+	TTimeIntervalDays pastdays1(10000);
+	TTimeIntervalMinutes syncinterval1(4000);
+	TBool immediatesync1 = ETrue;
+	TBool keepserverentry1 = ETrue;
+	TBuf8<500> url1, username1, password1;
+
+	iSession->PastDays(calendar, pastdays1);
+	iSession->SyncInterval(calendar, syncinterval1);
+	iSession->ImmediateSync(calendar, immediatesync1);
+	iSession->KeepServerEntry(calendar, keepserverentry1);
+	iSession->Url(calendar, url1);
+	iSession->Username(calendar, username1);
+	iSession->Password(calendar, password1);
+
+	Write(pastdays1.Int() == 100, __FUNCTION__);
+	Write(syncinterval1.Int() == 4, __FUNCTION__);
+	Write(!immediatesync1, __FUNCTION__);
+	Write(!keepserverentry1, __FUNCTION__);
+	Write(url1 == urlGooglePrincipal, __FUNCTION__);
+	Write(username1 == userGoogle, __FUNCTION__);
+	Write(password1 == passwordGoogle, __FUNCTION__);
+	}
+
+TInt CalDavTest::EnableL(TInt aSucces, const TDesC8 &aUrl, const TDesC8 &aUser,
+		const TDesC8 &aPassword)
+	{
+	iEngine->SetUrlL(aUrl);
+	iEngine->SetUserL(aUser);
+	iEngine->SetPasswordL(aPassword);
+	TInt ret = iEngine->EnableL();
+	Write(ret == aSucces, __FUNCTION__);
+	return ret;
+	}
+
+void CalDavTest::DeleteServerL(const unsigned long localuid)
+	{
+	Write(iEngine->DeleteEntryL(localuid) == KErrNone, __FUNCTION__);
+	}
+
+void CalDavTest::DeleteServerL()
+	{
+	TBuf8<500> url;
+	url.Append(*iEngine->iUrl);
+	url.Append(KFixedUIDics);
+	TInt Return = iEngine->iHttp->DeleteL(url);
+	Write((Return == NOCONTENT) || (Return == OK), __FUNCTION__);
+	}
+
+void CalDavTest::DeleteClientL(const TDesC8 &aUid)
+	{
+	Write(iEngine->DeleteLocalEntryL(aUid) == KErrNone, __FUNCTION__);
+	}
+
+LOCAL_C void DoStartL()
+	{
+
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	for (TInt i = 0; i <= 10; i++)
+		{
+		CalDavTest* aTest = new (ELeave) CalDavTest(console);
+		 
+		aTest->TestClientServerL(KErrNone, urlAries, userSUN, passwordSUN);
+		aTest->TestClientServerL(KErrArgument, urlblabla, userblabla,
+				passwordblabla);
+		
+		aTest->TestGeneralEngineL();
+		
+		//Test syntax: (url, username,password,webdav sync,ctag,  aEvent, aTodo, aFreeBusy, aJournal)
+
+		aTest->TestEngineL(KErrNone, urlWN, userSUN, passwordSUN, ETrue, ETrue,
+				ETrue, ETrue, ETrue, EFalse);
+
+		aTest->TestEngineL(KErrNone, urlAriesHome, userSUN, passwordSUN, ETrue,
+				ETrue, ETrue, ETrue, ETrue, EFalse);
+		aTest->TestEngineL(KErrNone, urlAries, userSUN, passwordSUN, ETrue,
+				ETrue, ETrue, ETrue, ETrue, EFalse);
+		aTest->TestEngineL(KErrNone, urlAriesPrincipal, userSUN, passwordSUN,
+				ETrue, ETrue, ETrue, ETrue, ETrue, EFalse);
+
+		aTest->TestEngineL(KErrNone, urlApple, userApple, passwordApple,
+				EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+		aTest->TestEngineL(KErrNone, principalAplle, userApple, passwordApple,
+				EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+
+		aTest->TestEngineL(KErrNone, urlGoogle, userGoogle, passwordGoogle,
+				EFalse, ETrue, ETrue, EFalse, EFalse, EFalse);
+		aTest->TestEngineL(KErrNone, urlGooglePrincipal, userGoogle,
+				passwordGoogle, EFalse, ETrue, ETrue, EFalse, EFalse, EFalse);
+
+		aTest->TestEngineL(KErrNone, urlChandler, userChandler,
+				passwordChandler, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+		aTest->TestEngineL(KErrNone, urlChandlerPrincipal, userChandler,
+				passwordChandler, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+
+		aTest->TestEngineL(KErrNone, urlOracle, userOracle, passwordOracle,
+				EFalse, ETrue, ETrue, ETrue, EFalse, EFalse);
+		aTest->TestEngineL(KErrNone, urlOraclePrincipal, userOracle,
+				passwordOracle, EFalse, ETrue, ETrue, ETrue, EFalse, EFalse);
+
+		aTest->TestEngineL(KErrNone, urlSogo, userSogo, passwordSogo, EFalse,
+				ETrue, ETrue, ETrue, EFalse, EFalse);
+		aTest->TestEngineL(KErrNone, urlDAV, userDAV, passwordDAV, EFalse,
+				EFalse, ETrue, ETrue, EFalse, EFalse);
+		
+		aTest->TestEngineL(KErrNone, urlYahoo, userYahoo, passwordYahoo,
+				EFalse, ETrue, ETrue, EFalse, ETrue, EFalse);
+		aTest->TestEngineL(KErrNone, urlYahooPrincipal, userYahoo,
+				passwordYahoo, EFalse, ETrue, ETrue, EFalse, ETrue, EFalse);
+		
+		aTest->TestEngineL(KErrNone, urlDaviCal, userDaviCal, passwordDaviCal,
+				EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+		aTest->TestEngineL(KErrNone, principalDaviCal, userDaviCal,
+				passwordDaviCal, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue);
+
+		aTest->TestEngineL(KErrNone, urlKerio, userKerio, passwordkerio,
+				EFalse, ETrue, ETrue, ETrue, ETrue, EFalse);
+		aTest->TestEngineL(KErrNone, principalKerio, userKerio, passwordkerio,
+				EFalse, ETrue, ETrue, ETrue, ETrue, EFalse);
+
+		aTest->TestEngineL(KErrNone, urlBedework, userBedework,
+				passwordbedework, EFalse, ETrue, ETrue, ETrue,
+				EFalse, EFalse);
+		aTest->TestEngineL(KErrNone, urlBedeWorkPrincipal, userBedework,
+				passwordbedework, EFalse, ETrue, ETrue, ETrue,
+				EFalse, EFalse);
+
+		aTest->TestEngineL(KErrArgument, urlAries, userSUN, passwordblabla,
+				ETrue, ETrue, ETrue, ETrue, ETrue, EFalse);
+
+		aTest->TestEngineL(KErrArgument, urlblabla, userblabla, passwordblabla,
+				EFalse, EFalse, ETrue, ETrue, EFalse, EFalse);
+
+		delete aTest;
+		}
+
+	// Delete active scheduler
+	CleanupStack::PopAndDestroy(scheduler);
+	}
+
+//  Global Functions
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
+							KConsFullScreen, KConsFullScreen)));
+	if (createError)
+		return createError;
+	TRAPD(mainError, DoStartL());
+	if (mainError)
+		console->Printf(KTextFailed, mainError);
+	console->Printf(KTextPressAnyKey);
+	console->Getch();
+
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
--- a/calendarengines/group/bld.inf	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarengines/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -28,6 +28,9 @@
 #include "../calenimp/group/bld.inf"
 #include "../calenlauncher/group/bld.inf"
 
+#ifdef FF_CALDAV_SUPPORT
+#include "../caldav/group/bld.inf"
+#endif //FF_CALDAV_SUPPORT
 
 
 PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/data/2002B503.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: registration file for Caldav ECOM plugin
+*
+*/
+
+#ifndef CALENCALDAVPLUGINREG_H
+#define CALENCALDAVPLUGINREG_H
+
+
+#include "CalDavUids.h"
+#include "caldav.loc"
+
+#include <ecom/registryinfo.rh>
+#include <calendar.loc>
+
+RESOURCE REGISTRY_INFO registry_info
+    {
+    dll_uid = CALENCALDAVPLUGIN_DLL_UID;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = CALENUIPLUGININTERFACE_ECOM_INTERFACE_UID;
+            implementations =
+                {
+                IMPLEMENTATION_INFO 
+                    {
+                    implementation_uid = CALEN_CALDAV_IMPLEMENTATION_UID;
+                    version_no = 1;
+                    display_name = qtn_caldav;
+                    default_data = "language(*)";
+                    opaque_data  = "";
+                    }
+                };
+            }
+        };
+    }
+
+#endif
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/data/caldav.loc	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: caldav user interface strings
+*
+*/
+
+#define qtn_caldav						"CalDAV Synchronisation"
+
+#define qtn_caldav_query_disconnect		"This change will disable synchronisation. Do you want to continue?"
+#define qtn_caldav_query_fail			"Synchronization could not be enabled. Please check url, username and password"
+#define qtn_caldav_query_success		"Synchronization was enabled successfully."
+
+#define qtn_caldav_access_point			"Access Point"
+
+#define qtn_caldav_username				"Username"
+#define qtn_caldav_url					"Url"
+#define qtn_caldav_password				"Password"
+#define qtn_caldav_syncinterval 		"Sync Interval"
+
+#define qtn_caldav_conflictaction 		"Conflict resolution"
+#define qtn_caldav_keep_server 			"Keep server"
+#define qtn_caldav_keep_device 			"Keep device"
+
+#define qtn_caldav_immediatesync 		"New entries"
+#define qtn_caldav_immediatesync_yes 	"Sync immediatly"
+#define qtn_caldav_immediatesync_no 	"Wait until next sync"
+
+#define qtn_caldav_enable 				"Enabled synchronization"
+#define qtn_caldav_yes					"Yes"
+#define qtn_caldav_no					"No"
+
+#define qtn_caldav_range				"Time range"
+#define qtn_caldav_range_two			"2 weeks back"
+#define qtn_caldav_range_three			"3 month back"
+#define qtn_caldav_range_six			"6 month back"
+#define qtn_caldav_range_all			"all events"
+
+#define qtn_caldav_time					"Sync interval"
+
+#define qtn_caldav_time_always			"Always on"
+#define qtn_caldav_time_one				"One minute"
+#define qtn_caldav_time_five			"Five minutes"
+#define qtn_caldav_time_fifteen			"Fifteen minutes"
+#define qtn_caldav_time_thirty 			"Thirty minutes"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/data/calencaldavpluginData.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,351 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav ECOM plugin resource file
+*
+*/
+
+#include <eikon.rh>
+#include <avkon.hrh>
+#include <avkon.rh>
+#include <avkon.rsg>
+
+#include <Calendar.loc>
+#include "caldav.loc"
+
+NAME CLU2
+
+RESOURCE RSS_SIGNATURE { }
+
+
+
+RESOURCE TBUF r_caldav
+    {
+    buf = qtn_caldav;
+    }
+
+RESOURCE TBUF r_caldav_query_disconnect
+    {
+    buf = qtn_caldav_query_disconnect;
+    }
+
+RESOURCE TBUF r_caldav_query_fail
+    {
+    buf = qtn_caldav_query_fail;
+    }
+
+RESOURCE TBUF r_caldav_query_success
+    {
+    buf = qtn_caldav_query_success;
+    }
+
+RESOURCE DIALOG r_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO;
+    title = qtn_caldav;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_INFO_ANIM;   
+                };
+            }
+        };
+    }
+
+RESOURCE TBUF r_caldav_access_point
+    {
+    buf = qtn_caldav_access_point;
+    }
+
+RESOURCE TBUF r_caldav_username
+    {
+    buf = qtn_caldav_username;
+    }
+
+RESOURCE TBUF r_caldav_url
+    {
+    buf = qtn_caldav_url;
+    }
+
+RESOURCE TBUF r_caldav_password
+    {
+    buf = qtn_caldav_password;
+    }
+
+RESOURCE TBUF r_caldav_syncinterval
+    {
+    buf = qtn_caldav_syncinterval;
+    }
+
+RESOURCE AVKON_SETTING_PAGE r_url_setting_page
+{
+	type = EEikCtEdwin;
+	editor_resource_id = r_url_editor_resource;
+}
+
+RESOURCE EDWIN r_url_editor_resource
+	{
+	maxlength = 255;
+	default_case = EAknEditorTextCase;
+	allowed_case_modes = EAknEditorAllCaseModes;
+	numeric_keymap = EAknEditorStandardNumberModeKeymap;
+	default_input_mode = EAknEditorTextInputMode;
+	allowed_input_modes = EAknEditorTextInputMode 
+	| EAknEditorNumericInputMode 
+	| EAknEditorSecretAlphaInputMode 
+	| EAknEditorKatakanaInputMode 
+	| EAknEditorFullWidthTextInputMode 
+	| EAknEditorFullWidthNumericInputMode 
+	| EAknEditorFullWidthKatakanaInputMode 
+	| EAknEditorHiraganaKanjiInputMode 
+	| EAknEditorHalfWidthTextInputMode;
+	special_character_table = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
+	lines = 0;
+	}
+
+RESOURCE AVKON_SETTING_PAGE r_username_setting_page
+{
+	type = EEikCtEdwin;
+	editor_resource_id = r_username_editor_resource;
+}
+
+RESOURCE EDWIN r_username_editor_resource
+{
+	maxlength = 255;
+	default_case = EAknEditorTextCase;
+	allowed_case_modes = EAknEditorAllCaseModes;
+	numeric_keymap = EAknEditorStandardNumberModeKeymap;
+	default_input_mode = EAknEditorTextInputMode;
+	allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode | EAknEditorSecretAlphaInputMode | EAknEditorKatakanaInputMode | EAknEditorFullWidthTextInputMode | EAknEditorFullWidthNumericInputMode | EAknEditorFullWidthKatakanaInputMode | EAknEditorHiraganaKanjiInputMode | EAknEditorHalfWidthTextInputMode;
+	lines = 0;
+}
+
+RESOURCE AVKON_SETTING_PAGE r_password_setting_page
+{
+	//type = EEikCtEdwin;
+	//editor_resource_id = r_password_editor_resource;
+	type = EEikCtSecretEd;
+	editor_resource_id = r_settinglist_alpha_password;
+}
+
+RESOURCE EDWIN r_password_editor_resource
+	{
+	maxlength = 255;
+	default_case = EAknEditorTextCase;
+	allowed_case_modes = EAknEditorAllCaseModes;
+	numeric_keymap = EAknEditorStandardNumberModeKeymap;
+	default_input_mode = EAknEditorTextInputMode;
+	allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode | EAknEditorSecretAlphaInputMode | EAknEditorKatakanaInputMode | EAknEditorFullWidthTextInputMode | EAknEditorFullWidthNumericInputMode | EAknEditorFullWidthKatakanaInputMode | EAknEditorHiraganaKanjiInputMode | EAknEditorHalfWidthTextInputMode;
+	lines = 0;
+	}
+
+RESOURCE SECRETED r_settinglist_alpha_password
+    {
+    num_letters = 100;
+    }
+
+
+RESOURCE TBUF r_caldav_time
+    {
+    buf = qtn_caldav_time;
+   }
+
+RESOURCE AVKON_SETTING_PAGE r_caldav_time_page
+
+    {
+    number = 1;
+    type = EEikCtTimeOffsetEditor;
+    editor_resource_id = r_caldav_time_editor;
+    }
+
+RESOURCE TIME_OFFSET_EDITOR r_caldav_time_editor
+    {
+    minTimeOffset = TIME_OFFSET { seconds = 0; };
+    maxTimeOffset = TIME_OFFSET { seconds = 43200; };
+    flags = EEikTimeWithoutSecondsField | EEikTimeZoneOffsetFormat;
+    }
+
+RESOURCE AVKON_SETTING_PAGE r_caldav_binary_page
+{
+	label = "";
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_cl_setting_list_ed;
+}
+
+RESOURCE POPUP_SETTING_LIST r_cl_setting_list_ed
+{
+	flags = 0;
+}
+
+RESOURCE TBUF r_caldav_conflictaction
+    {
+    buf = qtn_caldav_conflictaction;
+   }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_caldav_conflictaction_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_caldav_conflictaction_setting_array;
+    popped_up_texts_resource = r_caldav_conflictaction_popup_array;
+    }
+
+RESOURCE ARRAY r_caldav_conflictaction_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT { value = 1; text = qtn_caldav_keep_server; },
+        AVKON_ENUMERATED_TEXT { value = 0; text = qtn_caldav_keep_device; }
+        };
+    }
+
+RESOURCE ARRAY r_caldav_conflictaction_popup_array
+    {
+    items =
+        {
+        LBUF { txt = qtn_caldav_keep_server; },
+        LBUF { txt = qtn_caldav_keep_device; }
+        };
+    }
+
+RESOURCE TBUF r_caldav_immediatesync
+    {
+    buf = qtn_caldav_immediatesync;
+   }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_caldav_immediatesync_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_caldav_immediatesync_setting_array;
+    popped_up_texts_resource = r_caldav_immediatesync_popup_array;
+    }
+
+RESOURCE ARRAY r_caldav_immediatesync_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT { value = 1; text = qtn_caldav_immediatesync_yes; },
+        AVKON_ENUMERATED_TEXT { value = 0; text = qtn_caldav_immediatesync_no; }
+        };
+    }
+
+RESOURCE ARRAY r_caldav_immediatesync_popup_array
+    {
+    items =
+        {
+        LBUF { txt = qtn_caldav_immediatesync_yes; },
+        LBUF { txt = qtn_caldav_immediatesync_no; }
+        };
+    }
+
+RESOURCE TBUF r_caldav_enable
+    {
+    buf = qtn_caldav_enable;
+   }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_caldav_enable_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_caldav_enable_setting_array;
+    popped_up_texts_resource = r_caldav_enable_popup_array;
+    }
+
+RESOURCE ARRAY r_caldav_enable_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT { value = 1; text = qtn_caldav_yes; },
+        AVKON_ENUMERATED_TEXT { value = 0; text = qtn_caldav_no; }
+        };
+    }
+
+RESOURCE ARRAY r_caldav_enable_popup_array
+    {
+    items =
+        {
+        LBUF { txt = qtn_caldav_yes; },
+        LBUF { txt = qtn_caldav_no; }
+        };
+    }
+
+RESOURCE TBUF r_caldav_range
+   {
+    buf = qtn_caldav_range;
+  }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_caldav_range_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_caldav_range_setting_array;
+    popped_up_texts_resource = r_caldav_range_popup_array;
+    }
+
+RESOURCE ARRAY r_caldav_range_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT { value = 0; text = qtn_caldav_range_two; },
+        AVKON_ENUMERATED_TEXT { value = 1; text = qtn_caldav_range_three; },
+        AVKON_ENUMERATED_TEXT { value = 2; text = qtn_caldav_range_six; },
+        AVKON_ENUMERATED_TEXT { value = 3; text = qtn_caldav_range_all; }
+        };
+    }
+
+RESOURCE ARRAY r_caldav_range_popup_array
+    {
+    items =
+        {
+        LBUF { txt = qtn_caldav_range_two; },
+        LBUF { txt = qtn_caldav_range_three; },
+        LBUF { txt = qtn_caldav_range_six; },
+        LBUF { txt = qtn_caldav_range_all; }
+
+        };
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_caldav_time_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_caldav_time_setting_array;
+    popped_up_texts_resource = r_caldav_time_popup_array;
+    }
+
+RESOURCE ARRAY r_caldav_time_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT { value = 0; text = qtn_caldav_time_always; },
+        AVKON_ENUMERATED_TEXT { value = 1; text = qtn_caldav_time_one; },
+        AVKON_ENUMERATED_TEXT { value = 2; text = qtn_caldav_time_five; },
+        AVKON_ENUMERATED_TEXT { value = 3; text = qtn_caldav_time_fifteen; },
+        AVKON_ENUMERATED_TEXT { value = 4; text = qtn_caldav_time_thirty; }
+        };
+    }
+
+RESOURCE ARRAY r_caldav_time_popup_array
+    {
+    items =
+        {
+        LBUF { txt = qtn_caldav_time_always; },
+        LBUF { txt = qtn_caldav_time_one; },
+        LBUF { txt = qtn_caldav_time_five; },
+        LBUF { txt = qtn_caldav_time_fifteen; },
+        LBUF { txt = qtn_caldav_time_thirty; }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: provides the information required for building
+*				caldav ecom plugin, integrates into calendar
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_MMPFILES
+calencaldavplugin.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/group/calencaldavplugin.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: This is the project specification file for the
+*				Caldav ECOM plugin, integrates into calendar app
+*/
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+#include "../inc/CalDavUids.h"
+				
+TARGET          calencaldavplugin.dll
+TARGETTYPE      PLUGIN
+UID             SYMBIAN_ECOM_PLUGIN_UID CALENCALDAVPLUGIN_DLL_UID
+
+CAPABILITY      CAP_APPLICATION NetworkControl
+
+//Includes
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   ../../../inc
+SYSTEMINCLUDE   /epoc32/include/
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH      ../src
+SOURCE          calencaldavplugin.cpp
+SOURCE 			calencaldavpluginProxy.cpp
+SOURCE 			caldavsettingitems.cpp
+
+USERINCLUDE     ../../settings/settingsui/inc
+SOURCEPATH ../../settings/settingsui/src
+SOURCE calennestedsettingitem.cpp
+SOURCE calennestedsettingdialog.cpp
+
+// Resources
+SOURCEPATH      ../data
+START RESOURCE 2002B503.rss
+	TARGET calencaldavplugin.rsc
+END
+
+START RESOURCE  ../data/calencaldavplugindata.rss
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+LIBRARY			avkon.lib
+LIBRARY         calinterimapi.lib
+LIBRARY         cone.lib
+LIBRARY         ecom.lib
+LIBRARY         eikcoctl.lib
+LIBRARY         eikcore.lib
+LIBRARY         euser.lib
+LIBRARY         bafl.lib
+LIBRARY         CommonEngine.lib
+LIBRARY			eikdlg.lib 
+LIBRARY			hlplch.lib 
+LIBRARY			FeatMgr.lib
+LIBRARY         aknskins.lib
+LIBRARY         aknicon.lib
+LIBRARY         flogger.lib 
+LIBRARY         caldavclient.lib 
+LIBRARY         commdb.lib
+LIBRARY         cmmanager.lib
+LIBRARY			charconv.lib
+LIBRARY			esock.lib calenglobaldata.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/inc/CalDavUids.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav UIDs
+*
+*/
+
+#ifndef CALDAVUIDS_H_
+#define CALDAVUIDS_H_
+
+#define SYMBIAN_ECOM_PLUGIN_UID               			0x10009D8D
+#define CALENUIPLUGININTERFACE_ECOM_INTERFACE_UID       0x1028336F
+
+#define CALENCALDAVPLUGIN_DLL_UID              	0x2002B503
+#define CALEN_CALDAV_IMPLEMENTATION_UID			0x2002B81E
+
+#endif /* CALDAVUIDS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/inc/caldavsettingitems.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav setting items
+*
+*/
+
+#ifndef SETTINGITEMS_H
+#define SETTINGITEMS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+ 
+#include <aknsettingitemlist.h>
+
+class CCalDavSession;
+
+class CCalDavTextSettingItem : public CAknTextSettingItem
+    {
+    public:
+        
+        static CCalDavTextSettingItem* NewL(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        static CCalDavTextSettingItem* NewLC(TInt aId,CCalDavSession* aSession, const TDesC &aCalendar);
+        ~CCalDavTextSettingItem();
+        
+        void SetEnableSettingItem(CAknSettingItem* aItem);
+        
+    private:
+    	CCalDavTextSettingItem(TInt aId, CCalDavSession* aSession);
+        
+        void ConstructL(const TDesC &aCalendar);
+   
+    protected:// From base classes
+        void EditItemL( TBool aCalledFromMenu );
+        virtual void StoreL();
+        virtual void LoadL();
+           
+    private:
+    	TBuf<500> iInternalValue;
+    	CCalDavSession* iSession;
+    	HBufC* 	iCalendar;
+    	CAknSettingItem* iEnableSettingItem;	// not owned
+    };
+
+class CCalDavPasswordSettingItem : public CAknPasswordSettingItem
+    {
+    public:
+        
+        static CCalDavPasswordSettingItem* NewL(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        static CCalDavPasswordSettingItem* NewLC(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        ~CCalDavPasswordSettingItem();
+        
+        void SetEnableSettingItem(CAknSettingItem* aItem);
+        
+    private:
+    	CCalDavPasswordSettingItem(TInt aId, CCalDavSession* aSession);
+        
+        void ConstructL(const TDesC &aCalendar);
+   
+    protected:// From base classes
+        void EditItemL( TBool aCalledFromMenu );
+        virtual void StoreL();
+        virtual void LoadL();
+           
+    private:
+    	TBuf<500> iInternalValue;
+    	CCalDavSession* iSession;
+    	HBufC* 	iCalendar;
+    	CAknSettingItem* iEnableSettingItem;	// not owned
+    };
+
+class CCalDavBooleanSettingItem : public CAknBinaryPopupSettingItem
+    {
+    public:
+			
+        static CCalDavBooleanSettingItem* NewL(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        static CCalDavBooleanSettingItem* NewLC(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        ~CCalDavBooleanSettingItem();
+        
+    private:
+    	CCalDavBooleanSettingItem(TInt aId, CCalDavSession* aSession);
+        
+        void ConstructL(const TDesC &aCalendar);
+   
+    protected:// From base classes
+        void EditItemL( TBool aCalledFromMenu );
+        virtual void StoreL();
+        virtual void LoadL();
+           
+    private:
+    	TBool iInternalValue;
+    	CCalDavSession* iSession;
+    	HBufC* 	iCalendar;
+    };
+
+class CCalDavEnumeratedTextSettingItem : public CAknEnumeratedTextPopupSettingItem
+    {
+    public:
+			
+        static CCalDavEnumeratedTextSettingItem* NewL(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        static CCalDavEnumeratedTextSettingItem* NewLC(TInt aId, CCalDavSession* aSession, const TDesC &aCalendar);
+        ~CCalDavEnumeratedTextSettingItem();
+        
+    private:
+    	CCalDavEnumeratedTextSettingItem(TInt aId, CCalDavSession* aSession);
+        
+        void ConstructL(const TDesC &aCalendar);
+   
+    protected:// From base classes
+        void EditItemL( TBool aCalledFromMenu );
+        virtual void StoreL();
+        virtual void LoadL();
+           
+    private:
+    	TInt iInternalValue;
+    	CCalDavSession* iSession;
+    	HBufC* 	iCalendar;
+    };
+
+class CCalDavAccessPointSettingItem : public CAknSettingItem
+    	{
+    	public:
+            static CCalDavAccessPointSettingItem*
+             CCalDavAccessPointSettingItem::NewL( TInt aSettingId, CCalDavSession* aSession, const TDesC &aCalendar);
+     	    ~CCalDavAccessPointSettingItem();
+     	private:
+     	    CCalDavAccessPointSettingItem ( TInt aSettingId, CCalDavSession* aSession);
+     	    void ConstructL(const TDesC &aCalendar);
+     
+     
+     	protected:	// from CAknSettingItem
+     		void EditItemL( TBool aCalledFromMenu );
+     		virtual void StoreL();
+            virtual void LoadL();
+            
+     		const TDesC& SettingTextL();
+     
+     	private:
+     	    TBool EditAccessPointItemL();
+     
+         private:
+             HBufC* iSettingText;
+         	CCalDavSession* iSession;
+     	};
+
+
+#endif // SETTINGITEMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/inc/calencaldavplugin.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: CalDav ECOM plugin
+*
+*/
+ 
+#ifndef __CALENLUNARPLUGIN_H__
+#define __CALENLUNARPLUGIN_H__
+
+//SYSTEM INCLUDES
+#include <e32base.h>
+#include <ecom.h> 
+
+//CALENDAR INCLUDES
+#include <calencommandhandler.h>
+#include <calennotificationhandler.h>
+#include "calencustomisation.h"
+#include "CalendarVariant.hrh"
+
+//FORWARD DECLARE
+class CEikonEnv;
+class CCalenLunarInfoProvider;
+class CEikLabel;
+class CCoeControl;
+class TRect;
+class CEikMenuPane;
+class CCalDavSession;
+
+enum TCalDavSettingItem
+{
+	ECalDavSettingUrl = 0,
+	ECalDavSettingUser,
+	ECalDavSettingPassword,
+	ECalDavSettingEnable,	
+	ECalDavSettingKeepServer, 
+	ECalDavSettingSyncImmediate, 
+	ECalDavSettingSyncInterval,
+	ECalDavSettingSyncRange,
+	ECalDavSettingAccess
+};
+	
+//CLASS DECLARATION
+NONSHARABLE_CLASS(CCalenCalDavPlugin) : 	public CCalenCustomisation,
+												public MCalenCommandHandler,
+												public MCalenNotificationHandler
+									
+	{
+	public:
+	    
+	    static CCalenCalDavPlugin* NewL( MCalenServices* aServices );
+	    virtual ~CCalenCalDavPlugin();
+    
+	private:
+		CCalenCalDavPlugin( MCalenServices* aServices);
+		void ConstructL();
+		
+	public: //From CCalenCustomisation
+		void GetCustomViewsL(  RPointerArray<CCalenView>& aCustomViewArray );
+		void GetCustomSettingsL( RPointerArray<CAknSettingItem>& aCustomSettingArray );
+        CCoeControl* InfobarL( const TRect& aRect );
+        const TDesC& InfobarL();
+	  MCalenPreview* CustomPreviewPaneL( TRect& aRect );
+        CCoeControl* PreviewPaneL(  TRect& aRect );
+        MCalenCommandHandler* CommandHandlerL( TInt aCommand );
+        void RemoveViewsFromCycle( RArray<TInt>& aViews );
+        TBool CustomiseMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+        TBool CanBeEnabledDisabled();
+        TAny* CalenCustomisationExtensionL( TUid aExtensionUid );        
+        
+    public:// From MCalenCommandHandler
+        TBool HandleCommandL( const TCalenCommand& aCommand );
+        TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid );
+    
+    public://From MCalenNotificationHandler 
+        void HandleNotification( const TCalenNotification aNotification );
+        
+    private:
+        
+		MCalenServices* iServices;
+	
+		TInt iStart;
+	    TInt iEnd;
+	    TRect iRect;
+	    TInt  iResourceFileOffset;
+	    
+    	CCalDavSession* iSession;
+	    
+	};
+	
+#endif //__CALENLUNARPLUGIN_H__
+
+
+
+ 									
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/sis/caldavplugin.pkg	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,28 @@
+
+ 
+; Languages
+&EN
+
+; Header
+#{"CalDAV plugin"}, (0x2002B775), 1, 0, 0
+
+; Localised Vendor name
+%{"Sun Microsystems"}
+
+; Unique Vendor name
+:"Sun Microsystems"
+
+;Platform Dependency
+[0x1028315f],0 ,0 ,0,{"S60ProductID"}
+
+; ------ files -----
+
+; caldav client-server
+"\epoc32\release\armv5\urel\!CalDavServer.exe "-"!:\sys\bin\!CalDavServer.exe"
+"\epoc32\release\armv5\urel\CalDavClient.dll "-"!:\sys\bin\CalDavClient.dll"
+
+;caldav calendarui ecom plugin
+"\epoc32\release\armv5\urel\calencaldavplugin.dll"-"!:\sys\Bin\calencaldavplugin.dll"
+"\epoc32\data\z\resource\calencaldavplugindata.rsc"-"!:\resource\plugins\calencaldavplugindata.rsc"
+"\epoc32\data\z\resource\calencaldavplugindata.r01" - "!:\resource\calencaldavplugindata.r01"
+"\epoc32\data\z\resource\plugins\calencaldavplugin.rsc"-"!:\resource\plugins\calencaldavplugin.rsc" 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/src/caldavsettingitems.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,887 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: Caldav setting items
+*
+*/
+
+#include "caldavsettingitems.h"
+
+#include <StringLoader.h>
+#include <aknnotewrappers.h>
+#include <cmapplicationsettingsui.h>
+#include <CommDbConnPref.h>
+#include <UTF.H>
+
+#include <caldavsession.h>
+#include "calencaldavplugin.h"
+#include <calencaldavplugindata.rsg>
+
+#define KMAXSETTINGLENGTH	500
+
+#define KTIMETWOWEEKS 	14
+#define KTIMETHREEMONTH	30*3
+#define KTIMESIXMONTH	30*6
+#define KTIMEALL		1000
+
+#define KTIMEALWAYSON		0
+#define	KTIMEONEMINUTE		1
+#define	KTIMEFIVEMINUTES	5
+#define	KTIMEFIFTEENMINUTES	15
+#define KTIMETHIRTYMINUTES	30
+
+/**
+ * show a global info note
+ */
+void ShowNoteL(TInt aResource)
+	{
+	HBufC* text = StringLoader::LoadLC(aResource);
+	CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote();
+	note->ExecuteLD(*text);
+	CleanupStack::PopAndDestroy(text);
+	}
+
+/**
+ * CCalDavTextSettingItem::CCalDavTextSettingItem 
+ * default constructor
+ */
+CCalDavTextSettingItem::CCalDavTextSettingItem(TInt aId,
+		CCalDavSession* aSession) :
+	CAknTextSettingItem(aId, iInternalValue), iSession(aSession)
+	{
+
+	}
+
+/**
+ * CCalDavTextSettingItem::~CCalDavTextSettingItem 
+ * destructor
+ */
+CCalDavTextSettingItem::~CCalDavTextSettingItem()
+	{
+	delete iCalendar;
+	}
+
+/**
+ * CCalDavTextSettingItem::NewLC 
+ * 1st-phase construction
+ */
+CCalDavTextSettingItem* CCalDavTextSettingItem::NewLC(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavTextSettingItem* self = new (ELeave) CCalDavTextSettingItem(aId,
+			aSession);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCalendar);
+	return self;
+	}
+
+/**
+ * CCalDavTextSettingItem::NewL
+ *  1st-phase construction
+ */
+CCalDavTextSettingItem* CCalDavTextSettingItem::NewL(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavTextSettingItem* self = CCalDavTextSettingItem::NewLC(aId, aSession,
+			aCalendar);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+/**
+ * CCalDavTextSettingItem::ConstructL
+ * 2nd-phase construction
+ */
+void CCalDavTextSettingItem::ConstructL(const TDesC &aCalendar)
+	{
+	iCalendar = aCalendar.AllocL();
+	HBufC* title = NULL;
+	TInt page = 0;
+	switch (Identifier())
+		{
+		case ECalDavSettingUrl:
+			title = StringLoader::LoadLC(R_CALDAV_URL);
+			page = R_URL_SETTING_PAGE;
+			break;
+		case ECalDavSettingUser:
+			title = StringLoader::LoadLC(R_CALDAV_USERNAME);
+			page = R_USERNAME_SETTING_PAGE;
+			break;
+		case ECalDavSettingPassword:
+			title = StringLoader::LoadLC(R_CALDAV_PASSWORD);
+			page = R_PASSWORD_SETTING_PAGE;
+			break;
+		}
+	SetEmptyItemTextL(KNullDesC);
+	CAknTextSettingItem::ConstructL(EFalse, 0, *title, NULL,page, -1);
+	CleanupStack::PopAndDestroy(title);
+	}
+
+/**
+ * CCalDavTextSettingItem::EditItemL
+ * Edits the item
+ */
+void CCalDavTextSettingItem::EditItemL(TBool aCalledFromMenu)
+	{
+	TBool enabled;
+	iSession->EnabledSync(*iCalendar, enabled);
+	if (enabled)
+		{
+		HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT);
+		CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+		if (dlg->ExecuteLD(R_QUERY, *text))
+			{
+			CAknTextSettingItem::EditItemL(aCalledFromMenu);
+			// TODO: disable Enabled-Setting-Item	
+			}
+		CleanupStack::PopAndDestroy(text);
+		}
+	else
+		CAknTextSettingItem::EditItemL(aCalledFromMenu);
+	}
+
+/**
+ * CCalDavTextSettingItem::StoreL
+ * Stores the item
+ */
+void CCalDavTextSettingItem::StoreL()
+	{
+	CAknTextSettingItem::StoreL();
+
+	HBufC8* text = CnvUtfConverter::ConvertFromUnicodeToUtf8L(iInternalValue);
+	CleanupStack::PushL(text);
+	
+	switch (Identifier())
+		{
+		case ECalDavSettingUrl:
+			iSession->SetUrl(*iCalendar, *text);
+			break;
+		case ECalDavSettingUser:
+			iSession->SetUsername(*iCalendar, *text);
+			break;
+		case ECalDavSettingPassword:
+			iSession->SetPassword(*iCalendar, *text);
+			break;
+		}
+	CleanupStack::PopAndDestroy(text);
+	
+	if (iEnableSettingItem)
+		{
+		iEnableSettingItem->LoadL();
+		iEnableSettingItem->UpdateListBoxTextL();
+		}
+	}
+
+/**
+ * CCalDavTextSettingItem::LoadL
+ * loades the item
+ */
+void CCalDavTextSettingItem::LoadL()
+	{
+	HBufC8* buf = HBufC8::NewL(KMAXSETTINGLENGTH);
+	TPtr8 ptr(buf->Des());
+	switch (Identifier())
+		{
+		case ECalDavSettingUrl:
+			iSession->Url(*iCalendar, ptr);
+			break;
+		case ECalDavSettingUser:
+			iSession->Username(*iCalendar, ptr);
+			break;
+		case ECalDavSettingPassword:
+			iSession->Password(*iCalendar, ptr);
+			break;
+		}
+	CnvUtfConverter::ConvertToUnicodeFromUtf8(iInternalValue, ptr);
+	delete buf;
+	CAknTextSettingItem::LoadL();
+	}
+
+/**
+ * CCalDavTextSettingItem::StoreL
+ * Save a pointer to the Enable Item, this is used to set current
+ * enable/disable state
+ */
+void CCalDavTextSettingItem::SetEnableSettingItem(CAknSettingItem* aItem)
+	{
+	iEnableSettingItem = aItem;
+	}
+
+/**
+ * CCalDavPasswordSettingItem::CCalDavPasswordSettingItem
+ * default constructor
+ */
+CCalDavPasswordSettingItem::CCalDavPasswordSettingItem(TInt aId,
+		CCalDavSession* aSession) :
+	CAknPasswordSettingItem(aId, CAknPasswordSettingItem::EAlpha,
+			iInternalValue), iSession(aSession)
+	{
+
+	}
+
+/**
+ * CCalDavPasswordSettingItem::~CCalDavPasswordSettingItem
+ * default destructor
+ */
+CCalDavPasswordSettingItem::~CCalDavPasswordSettingItem()
+	{
+	delete iCalendar;
+	}
+
+/**
+ * CCalDavPasswordSettingItem::NewLC
+ * first phase construction
+ */
+CCalDavPasswordSettingItem* CCalDavPasswordSettingItem::NewLC(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavPasswordSettingItem* self = new (ELeave) CCalDavPasswordSettingItem(
+			aId, aSession);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCalendar);
+	return self;
+	}
+
+/**
+ * CCalDavPasswordSettingItem::NewL
+ * first phase construction
+ */
+CCalDavPasswordSettingItem* CCalDavPasswordSettingItem::NewL(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavPasswordSettingItem* self = CCalDavPasswordSettingItem::NewLC(aId,
+			aSession, aCalendar);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+/**
+ * CCalDavPasswordSettingItem::SetEnableSettingItem
+ * Save a pointer to the Enable Item, this is used to set current
+ * enable/disable state
+ */
+void CCalDavPasswordSettingItem::SetEnableSettingItem(CAknSettingItem* aItem)
+	{
+	iEnableSettingItem = aItem;
+	}
+
+/**
+ * CCalDavPasswordSettingItem::ConstructL
+ * second phase construction
+ */
+void CCalDavPasswordSettingItem::ConstructL(const TDesC &aCalendar)
+	{
+	iCalendar = aCalendar.AllocL();
+	HBufC* title = NULL;
+	TInt page = 0;
+	switch (Identifier())
+		{
+		case ECalDavSettingPassword:
+			title = StringLoader::LoadLC(R_CALDAV_PASSWORD);
+			page = R_PASSWORD_SETTING_PAGE;
+			break;
+		}
+	SetEmptyItemTextL(KNullDesC);
+	CAknPasswordSettingItem::ConstructL(EFalse, 0, *title, NULL,page, -1);
+	CleanupStack::PopAndDestroy(title);
+	}
+
+/**
+ * CCalDavPasswordSettingItem::EditItemL
+ * edits the item
+ */
+void CCalDavPasswordSettingItem::EditItemL(TBool aCalledFromMenu)
+	{
+	TBool enabled;
+	iSession->EnabledSync(*iCalendar, enabled);
+	if (enabled)
+		{
+		HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT);
+		CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+		if (dlg->ExecuteLD(R_QUERY, *text))
+			CAknPasswordSettingItem::EditItemL(aCalledFromMenu);
+		CleanupStack::PopAndDestroy(text);
+		}
+	else
+		CAknPasswordSettingItem::EditItemL(aCalledFromMenu);
+	CAknSettingItem::UpdateListBoxTextL();
+	}
+
+/**
+ * CCalDavPasswordSettingItem::StoreL
+ * stores the item
+ */
+void CCalDavPasswordSettingItem::StoreL()
+	{
+	CAknPasswordSettingItem::StoreL();
+	
+	HBufC8* text = CnvUtfConverter::ConvertFromUnicodeToUtf8L(iInternalValue);
+	CleanupStack::PushL(text);
+
+	switch (Identifier())
+		{
+		case ECalDavSettingPassword:
+			iSession->SetPassword(*iCalendar, *text);
+			break;
+		}
+	CleanupStack::PopAndDestroy(text);
+	}
+
+/**
+ * CCalDavPasswordSettingItem::LoadL
+ * loads the item
+ */
+void CCalDavPasswordSettingItem::LoadL()
+	{
+	HBufC8* buf = HBufC8::NewL(KMAXSETTINGLENGTH);
+	TPtr8 ptr(buf->Des());
+	switch (Identifier())
+		{
+		case ECalDavSettingPassword:
+			iSession->Password(*iCalendar, ptr);
+			break;
+		}
+	CnvUtfConverter::ConvertToUnicodeFromUtf8(iInternalValue, ptr);
+	delete buf;
+	CAknPasswordSettingItem::LoadL();
+	}
+
+/**
+ * CCalDavBooleanSettingItem::CCalDavBooleanSettingItem
+ * default constructor
+ */
+CCalDavBooleanSettingItem::CCalDavBooleanSettingItem(TInt aId,
+		CCalDavSession* aSession) :
+	CAknBinaryPopupSettingItem(aId, iInternalValue), iSession(aSession)
+	{
+
+	}
+
+/**
+ * CCalDavBooleanSettingItem::~CCalDavBooleanSettingItem
+ * default destructor
+ */
+CCalDavBooleanSettingItem::~CCalDavBooleanSettingItem()
+	{
+	delete iCalendar;
+	}
+
+/**
+ * CCalDavBooleanSettingItem::NewLC
+ * first phase construction
+ */
+CCalDavBooleanSettingItem* CCalDavBooleanSettingItem::NewLC(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavBooleanSettingItem* self = new (ELeave) CCalDavBooleanSettingItem(
+			aId, aSession);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCalendar);
+	return self;
+	}
+
+/**
+ * CCalDavBooleanSettingItem::NewLC
+ * first phase construction
+ */
+CCalDavBooleanSettingItem* CCalDavBooleanSettingItem::NewL(TInt aId,
+		CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavBooleanSettingItem* self = CCalDavBooleanSettingItem::NewLC(aId,
+			aSession, aCalendar);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+/**
+ * CCalDavBooleanSettingItem::ConstructL
+ * second phase construction
+ */
+void CCalDavBooleanSettingItem::ConstructL(const TDesC &aCalendar)
+	{
+	iCalendar = aCalendar.AllocL();
+	HBufC* title = NULL;
+	TInt text = 0;
+	TInt page = R_CALDAV_BINARY_PAGE;
+	switch (Identifier())
+		{
+		case ECalDavSettingKeepServer:
+			title = StringLoader::LoadLC(R_CALDAV_CONFLICTACTION);
+			text = R_CALDAV_CONFLICTACTION_TEXTS;
+			break;
+		case ECalDavSettingSyncImmediate:
+			title = StringLoader::LoadLC(R_CALDAV_IMMEDIATESYNC);
+			text = R_CALDAV_IMMEDIATESYNC_TEXTS;
+			break;
+		case ECalDavSettingEnable:
+			title = StringLoader::LoadLC(R_CALDAV_ENABLE);
+			text = R_CALDAV_ENABLE_TEXTS;
+			break;
+		}
+	SetEmptyItemTextL(KNullDesC);
+	CAknBinaryPopupSettingItem::ConstructL(EFalse, 0, *title, NULL,page,
+			EAknCtPopupSettingList, NULL, text);
+	CleanupStack::PopAndDestroy(title);
+	}
+
+/**
+ * CCalDavBooleanSettingItem::EditItemL
+ * edits the item
+ */
+void CCalDavBooleanSettingItem::EditItemL(TBool aCalledFromMenu)
+	{
+	if (Identifier() == ECalDavSettingEnable)
+		{
+		TBool enabled_old;
+		iSession->EnabledSync(*iCalendar, enabled_old);
+		if (enabled_old)
+			{
+			HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT);
+			CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+			if (dlg->ExecuteLD(R_QUERY, *text))
+				{
+				iSession->Disable(*iCalendar);
+				CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu);
+				}
+			CleanupStack::PopAndDestroy(text);
+			}
+		else
+			{
+			iSession->Enable(*iCalendar);
+			// TODO: progressbar
+			TBool enabled_new;
+			iSession->EnabledSync(*iCalendar, enabled_new);
+			if (!enabled_new)
+				{
+				ShowNoteL(R_CALDAV_QUERY_FAIL);
+				}
+			else
+				{
+				ShowNoteL(R_CALDAV_QUERY_SUCCESS);
+				CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu);
+				}
+			}
+		}
+	else
+		CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu);
+	}
+
+/**
+ * CCalDavBooleanSettingItem::StoreL
+ * stores the item
+ */
+void CCalDavBooleanSettingItem::StoreL()
+	{
+	CAknBinaryPopupSettingItem::StoreL();
+
+	switch (Identifier())
+		{
+		case ECalDavSettingKeepServer:
+			iSession->SetKeepServerEntry(*iCalendar, iInternalValue);
+			break;
+		case ECalDavSettingSyncImmediate:
+			iSession->SetImmediateSync(*iCalendar, iInternalValue);
+			break;
+		}
+	}
+
+/**
+ * CCalDavBooleanSettingItem::LoadL
+ * loads the item
+ */
+void CCalDavBooleanSettingItem::LoadL()
+	{
+	switch (Identifier())
+		{
+		case ECalDavSettingKeepServer:
+			iSession->KeepServerEntry(*iCalendar, iInternalValue);
+			break;
+		case ECalDavSettingSyncImmediate:
+			iSession->ImmediateSync(*iCalendar, iInternalValue);
+			break;
+		case ECalDavSettingEnable:
+			iSession->EnabledSync(*iCalendar, iInternalValue);
+			break;
+		}
+	CAknBinaryPopupSettingItem::LoadL();
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::CCalDavEnumeratedTextSettingItem
+ * default constructor
+ */
+CCalDavEnumeratedTextSettingItem::CCalDavEnumeratedTextSettingItem(TInt aId,
+		CCalDavSession* aSession) :
+	CAknEnumeratedTextPopupSettingItem(aId, iInternalValue), iSession(aSession)
+	{
+
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::~CCalDavEnumeratedTextSettingItem
+ * default destructor
+ */
+CCalDavEnumeratedTextSettingItem::~CCalDavEnumeratedTextSettingItem()
+	{
+	delete iCalendar;
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::NewLC
+ * first phase construction
+ */
+CCalDavEnumeratedTextSettingItem* CCalDavEnumeratedTextSettingItem::NewLC(
+		TInt aId, CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavEnumeratedTextSettingItem* self =
+			new (ELeave) CCalDavEnumeratedTextSettingItem(aId, aSession);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCalendar);
+	return self;
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::NewL
+ * first phase construction
+ */
+CCalDavEnumeratedTextSettingItem* CCalDavEnumeratedTextSettingItem::NewL(
+		TInt aId, CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavEnumeratedTextSettingItem* self =
+			CCalDavEnumeratedTextSettingItem::NewLC(aId, aSession, aCalendar);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::ConstructL
+ * second phase construction
+ */
+void CCalDavEnumeratedTextSettingItem::ConstructL(const TDesC &aCalendar)
+	{
+	iCalendar = aCalendar.AllocL();
+	HBufC* title = NULL;
+	TInt text = 0;
+	TInt page = R_CALDAV_BINARY_PAGE;
+	switch (Identifier())
+		{
+		case ECalDavSettingSyncRange:
+			title = StringLoader::LoadLC(R_CALDAV_RANGE);
+			text = R_CALDAV_RANGE_TEXTS;
+			break;
+		case ECalDavSettingSyncInterval:
+			title = StringLoader::LoadLC(R_CALDAV_TIME);
+			text = R_CALDAV_TIME_TEXTS;
+			break;
+
+		}
+	SetEmptyItemTextL(KNullDesC);
+	CAknEnumeratedTextSettingItem::ConstructL(EFalse, 0, *title, NULL,page,
+			EAknCtPopupSettingList, NULL, text);
+	CleanupStack::PopAndDestroy(title);
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::EditItemL
+ * edits the item
+ */
+void CCalDavEnumeratedTextSettingItem::EditItemL(TBool aCalledFromMenu)
+	{
+	CAknEnumeratedTextPopupSettingItem::EditItemL(aCalledFromMenu);
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::StoreL
+ * stores the item
+ */
+void CCalDavEnumeratedTextSettingItem::StoreL()
+	{
+	CAknEnumeratedTextPopupSettingItem::StoreL();
+
+	switch (iInternalValue)
+		{
+		case 0:
+			{
+			if (Identifier() == ECalDavSettingSyncRange)
+				iSession->SetPastDays(*iCalendar, TTimeIntervalDays(
+						KTIMETWOWEEKS));
+			else
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMEALWAYSON));
+			break;
+			}
+		case 1:
+			{
+			if (Identifier() == ECalDavSettingSyncRange)
+				iSession->SetPastDays(*iCalendar, TTimeIntervalDays(
+						KTIMETHREEMONTH));
+			else
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMEONEMINUTE));
+			break;
+			}
+		case 2:
+			{
+			if (Identifier() == ECalDavSettingSyncRange)
+				iSession->SetPastDays(*iCalendar, TTimeIntervalDays(
+						KTIMESIXMONTH));
+			else
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMEFIVEMINUTES));
+			break;
+			}
+		case 3:
+			{
+			if (Identifier() == ECalDavSettingSyncRange)
+				iSession->SetPastDays(*iCalendar, TTimeIntervalDays(KTIMEALL));
+			else
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMEFIFTEENMINUTES));
+			break;
+			}
+		case 4:
+			{
+			if (Identifier() == ECalDavSettingSyncInterval)
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMETHIRTYMINUTES));
+			break;
+			}
+		default:
+			if (Identifier() == ECalDavSettingSyncRange)
+				iSession->SetPastDays(*iCalendar, TTimeIntervalDays(
+						KTIMETWOWEEKS));
+			else
+				iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes(
+						KTIMEALWAYSON));
+
+			break;
+		}
+	}
+
+/**
+ * CCalDavEnumeratedTextSettingItem::LoadL
+ * loads the item
+ */
+void CCalDavEnumeratedTextSettingItem::LoadL()
+	{
+	switch (Identifier())
+		{
+		case ECalDavSettingSyncRange:
+			{
+			TTimeIntervalDays days;
+			iSession->PastDays(*iCalendar, days);
+			switch (days.Int())
+				{
+				case KTIMETWOWEEKS:
+					{
+					iInternalValue = 0;
+					break;
+					}
+				case KTIMETHREEMONTH:
+					{
+					iInternalValue = 1;
+					break;
+					}
+				case KTIMESIXMONTH:
+					{
+					iInternalValue = 2;
+					break;
+					}
+				case KTIMEALL:
+					{
+					iInternalValue = 3;
+					break;
+					}
+				default:
+					iInternalValue = 0;
+					break;
+				}
+			break;
+			}
+		case ECalDavSettingSyncInterval:
+			{
+			TTimeIntervalMinutes minutes;
+			iSession->SyncInterval(*iCalendar, minutes);
+			switch (minutes.Int())
+				{
+				case KTIMEALWAYSON:
+					{
+					iInternalValue = 0;
+					break;
+					}
+				case KTIMEONEMINUTE:
+					{
+					iInternalValue = 1;
+					break;
+					}
+				case KTIMEFIVEMINUTES:
+					{
+					iInternalValue = 2;
+					break;
+					}
+				case KTIMEFIFTEENMINUTES:
+					{
+					iInternalValue = 3;
+					break;
+					}
+				case KTIMETHIRTYMINUTES:
+					{
+					iInternalValue = 4;
+					break;
+					}
+				default:
+					iInternalValue = 0;
+					break;
+				}
+			break;
+			}
+		}
+	CAknEnumeratedTextPopupSettingItem::LoadL();
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::NewL
+ * first phase construction
+ */
+CCalDavAccessPointSettingItem* CCalDavAccessPointSettingItem::NewL(
+		TInt aSettingId, CCalDavSession* aSession, const TDesC &aCalendar)
+	{
+	CCalDavAccessPointSettingItem * item =
+			new (ELeave) CCalDavAccessPointSettingItem(aSettingId, aSession);
+	CleanupStack::PushL(item);
+	item->ConstructL(aCalendar);
+	CleanupStack::Pop(item);
+	return item;
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::CCalDavAccessPointSettingItem
+ * default constructor
+ */
+CCalDavAccessPointSettingItem::CCalDavAccessPointSettingItem(TInt aSettingId,
+		CCalDavSession* aSession) :
+	CAknSettingItem(aSettingId), iSession(aSession)
+	{
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::~CCalDavAccessPointSettingItem
+ * default destructor
+ */
+CCalDavAccessPointSettingItem::~CCalDavAccessPointSettingItem()
+	{
+	delete iSettingText;
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::ConstructL
+ * second phase construction
+ */
+void CCalDavAccessPointSettingItem::ConstructL(const TDesC &/*aCalendar*/)
+	{
+	SetEmptyItemTextL(KNullDesC);
+	HBufC* title = StringLoader::LoadLC(R_CALDAV_ACCESS_POINT);
+	CAknSettingItem::ConstructL(EFalse, 0, *title, NULL,0, 0);
+	CleanupStack::PopAndDestroy(title);
+
+	_LIT(hi,"Default Connection");
+	iSettingText = hi().Alloc();
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::EditItemL
+ * edits the item
+ */
+void CCalDavAccessPointSettingItem::EditItemL(TBool /*aCalledFromMenu*/)
+	{
+	delete iSettingText;
+	iSettingText = NULL;
+
+	TCmSettingSelection userSelection;
+	userSelection.iId = 0;
+	userSelection.iResult = CMManager::EDefaultConnection;
+
+	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
+	CleanupStack::PushL(settings);
+	TUint listedItems = CMManager::EShowDefaultConnection
+			| CMManager::EShowDestinations | CMManager::EShowConnectionMethods;
+	TBearerFilterArray filter;
+	settings->RunApplicationSettingsL(userSelection, listedItems, filter);
+	CleanupStack::PopAndDestroy(settings);
+
+	switch (userSelection.iResult)
+		{
+		case CMManager::EDestination:
+			{
+			TConnSnapPref prefs;
+			prefs.SetSnap(userSelection.iId);
+			// iSettingText =
+			// iConnection.Start( prefs, iStatus );
+			break;
+			}
+		case CMManager::EConnectionMethod:
+			{
+			TCommDbConnPref prefs;
+			prefs.SetIapId(userSelection.iId);
+			prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+
+			// iConnection.Start( prefs, iStatus );
+			// iSettingText =
+			break;
+			}
+		case CMManager::EDefaultConnection:
+			{
+			// iConnection.Start( iStatus );
+			// iSettingText = 
+			break;
+			}
+		}
+	UpdateListBoxTextL();
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::SettingTextL
+ * returns the setting text
+ */
+const TDesC& CCalDavAccessPointSettingItem::SettingTextL()
+	{
+	if (!iSettingText)
+		{
+		return CAknSettingItem::SettingTextL();
+		}
+	else if (iSettingText->Length() == 0)
+		{
+		return CAknSettingItem::SettingTextL();
+		}
+
+	return *iSettingText;
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::StoreL
+ * stores the item
+ */
+void CCalDavAccessPointSettingItem::StoreL()
+	{
+	CAknSettingItem::StoreL();
+	}
+
+/**
+ * CCalDavAccessPointSettingItem::LoadL
+ * loads the item
+ */
+void CCalDavAccessPointSettingItem::LoadL()
+	{
+	//CAknSettingItem::Load();
+	}
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/src/calencaldavplugin.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,343 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: CalDav ECOM plugin
+*
+*/
+
+#include <eikenv.h>
+#include <aknutils.h>
+#include <eiklabel.h>
+#include <avkon.hrh>
+#include <StringLoader.h>
+#include <AknMessageQueryDialog.h>
+#include <data_caging_path_literals.hrh>
+#include <bautils.h>
+#include <aknbiditextutils.h>
+#include <aknsettingitemlist.h>
+
+#include <caldavsession.h>
+#include <calcalendarinfo.h>
+#include <calenservices.h>
+#include <calendar.rsg>
+
+#include <CalenCaldavPluginData.rsg>
+#include <calencommands.hrh>
+#include "caldavsettingitems.h"
+#include "calennestedsettingitem.h"
+#include "calendarui_debug.h" 
+#include "CalenCaldavPlugin.h"
+
+_LIT( KResourceCCalDavPluginFile, "calencaldavplugindata.rsc" );
+
+#define KResourcePath KDC_RESOURCE_FILES_DIR
+
+/**
+ * CCalenCalDavPlugin::CCalenCalDavPlugin
+ * default constructor
+ */
+CCalenCalDavPlugin::CCalenCalDavPlugin(MCalenServices* aServices) :
+	iServices(aServices), iResourceFileOffset(NULL)
+
+	{
+	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::NewL
+ * first phase construction
+ */
+CCalenCalDavPlugin* CCalenCalDavPlugin::NewL(MCalenServices* aServices)
+	{
+	TRACE_ENTRY_POINT;
+	CCalenCalDavPlugin* self = new (ELeave) CCalenCalDavPlugin(aServices);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);TRACE_EXIT_POINT;
+	return self;
+	}
+
+/**
+ * CCalenCalDavPlugin::~CCalenCalDavPlugin
+ * default destructor
+ */
+CCalenCalDavPlugin::~CCalenCalDavPlugin()
+	{
+	TRACE_ENTRY_POINT;
+
+	delete iSession;
+
+	if (iServices)
+		{
+		iServices->CancelNotifications(this);
+		iServices->Release();
+		}
+
+	if (iResourceFileOffset)
+		{
+		CCoeEnv::Static()->DeleteResourceFile(iResourceFileOffset);
+		}TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::ConstructL
+ * second phase construction
+ */
+void CCalenCalDavPlugin::ConstructL()
+	{
+	TRACE_ENTRY_POINT;
+
+	TFileName dllName;
+	// Get the complate path of the DLL from where it is currently loaded
+	Dll::FileName(dllName);
+
+	TFileName resourceFilename;
+	resourceFilename.Append(dllName.Mid(0, 2));
+	resourceFilename.Append(KResourcePath);
+	resourceFilename.Append(KResourceCCalDavPluginFile);
+	BaflUtils::NearestLanguageFile(CEikonEnv::Static()->FsSession(),
+			resourceFilename);
+	// Add the resource file.
+	iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL(
+			resourceFilename);
+
+	iServices->GetCommandRange(iStart, iEnd);
+
+	iSession = CCalDavSession::NewL();
+
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::InfobarL
+ * show an additional infobar
+ */
+CCoeControl* CCalenCalDavPlugin::InfobarL(const TRect& /*aRect*/)
+	{
+	TRACE_ENTRY_POINT;
+	return NULL;TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::InfobarL
+ * show an additional infobar
+ */
+const TDesC& CCalenCalDavPlugin::InfobarL()
+	{
+	TRACE_ENTRY_POINT;
+	return KNullDesC;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::PreviewPaneL
+ * show an additional preview pabe
+ */
+CCoeControl* CCalenCalDavPlugin::PreviewPaneL(TRect& /* aRect */)
+	{
+	TRACE_ENTRY_POINT;
+	return NULL;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::CustomPreviewPaneL
+ * show an additional custom preview pane
+ */
+MCalenPreview* CCalenCalDavPlugin::CustomPreviewPaneL(TRect& /* aRect */)
+	{
+	TRACE_ENTRY_POINT;
+	return NULL;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::CustomiseMenuPaneL
+ * customize menu pane
+ */
+TBool CCalenCalDavPlugin::CustomiseMenuPaneL(TInt /*aResourceId*/,
+		CEikMenuPane* /*aMenuPane*/)
+	{
+	TRACE_ENTRY_POINT;
+	return EFalse;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::HandleCommandL
+ * let this plugin handle its own commands
+ */
+TBool CCalenCalDavPlugin::HandleCommandL(const TCalenCommand& /*aCommand*/)
+	{
+	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
+	return EFalse;
+	}
+
+/**
+ * CCalenCalDavPlugin::CommandHandlerL
+ * let this plugin handle its own commands
+ */
+MCalenCommandHandler* CCalenCalDavPlugin::CommandHandlerL(TInt /*aCommand*/)
+	{
+	TRACE_ENTRY_POINT;
+	MCalenCommandHandler* commandHandler = NULL;
+	return commandHandler;TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::RemoveViewsFromCycle
+ * remove added views from cycle
+ */
+void CCalenCalDavPlugin::RemoveViewsFromCycle(RArray<TInt>& /*aViews*/)
+	{
+	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::GetCustomSettingsL
+ * add custom settings to calendar setting pane
+ * all CalDav settings are added here into UI
+ */
+void CCalenCalDavPlugin::GetCustomSettingsL(
+		RPointerArray<CAknSettingItem>& aCustomSettingArray)
+	{
+	TRACE_ENTRY_POINT
+
+	RPointerArray<CCalCalendarInfo> calendarInfoList;
+	iServices->GetAllCalendarInfoL(calendarInfoList);
+	CleanupClosePushL(calendarInfoList);
+
+	TInt count = calendarInfoList.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		TPtrC calendar = calendarInfoList[i]->FileNameL();
+
+		RPointerArray<CAknSettingItem> settings;
+
+		CCalDavBooleanSettingItem * enable = CCalDavBooleanSettingItem::NewL(
+				ECalDavSettingEnable, iSession, calendar);
+
+		CCalDavTextSettingItem* url = CCalDavTextSettingItem::NewL(
+				ECalDavSettingUrl, iSession, calendar);
+		url->SetEnableSettingItem(enable);
+		settings.Append(url);
+
+		CCalDavTextSettingItem* user = CCalDavTextSettingItem::NewL(
+				ECalDavSettingUser, iSession, calendar);
+		user->SetEnableSettingItem(enable);
+		settings.Append(user);
+
+		CCalDavPasswordSettingItem* password = CCalDavPasswordSettingItem::NewL(
+				ECalDavSettingPassword, iSession, calendar);
+		password->SetEnableSettingItem(enable);
+		settings.Append(password);
+
+		CCalDavBooleanSettingItem * keepserver =
+				CCalDavBooleanSettingItem::NewL(ECalDavSettingKeepServer,
+						iSession, calendar);
+		settings.Append(keepserver);
+
+		//    CCalDavBooleanSettingItem * immediatesync = CCalDavBooleanSettingItem::NewL(ECalDavSettingSyncImmediate,iSession, calendar);
+		//    settings.Append(immediatesync);
+
+		CCalDavEnumeratedTextSettingItem* range =
+				CCalDavEnumeratedTextSettingItem::NewL(ECalDavSettingSyncRange,
+						iSession, calendar);
+		settings.Append(range);
+
+		CCalDavEnumeratedTextSettingItem* time =
+				CCalDavEnumeratedTextSettingItem::NewL(
+						ECalDavSettingSyncInterval, iSession, calendar);
+		settings.Append(time);
+		settings.Append(enable);
+
+		CCalenNestedSettingItem* item = new (ELeave) CCalenNestedSettingItem(0,
+				settings, calendarInfoList[i]->NameL());
+		CleanupStack::PushL(item);
+
+		item->SetEmptyItemTextL(KNullDesC);
+
+		if (count == 1)
+			{
+			HBufC16* name = StringLoader::LoadLC(R_CALDAV);
+			item->ConstructL(EFalse, 0, *name, NULL,
+			R_CALEN_EMPTY_SETTING_PAGE, EAknSetListBox, NULL,
+			R_CALEN_EMPTY_POPUP_SETTING_TEXTS );
+			CleanupStack::PopAndDestroy(name);
+			}
+		else
+			{
+			item->ConstructL(EFalse, 0, calendarInfoList[i]->NameL(), NULL,
+			R_CALEN_EMPTY_SETTING_PAGE, EAknSetListBox, NULL,
+			R_CALEN_EMPTY_POPUP_SETTING_TEXTS );
+			}
+		aCustomSettingArray.Append(item);
+		CleanupStack::Pop(item);
+		}
+	CleanupStack::PopAndDestroy(&calendarInfoList);
+
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::GetCustomViewsL
+ * add custom views
+ */
+void CCalenCalDavPlugin::GetCustomViewsL(RPointerArray<CCalenView>&
+/*aCustomViewArray*/)
+	{
+	TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::HandleNotification
+ * handle received notifications in this plugin
+ */
+void CCalenCalDavPlugin::HandleNotification(const TCalenNotification /*aNotification*/)
+	{
+	TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * CCalenCalDavPlugin::CanBeEnabledDisabled
+ * can the plugin be disabled or enabled, called by customization manager
+ */
+TBool CCalenCalDavPlugin::CanBeEnabledDisabled()
+	{
+	return EFalse;
+	}
+
+/**
+ * CCalenCalDavPlugin::CalenCustomisationExtensionL
+ * add custom extensions
+ */
+TAny* CCalenCalDavPlugin::CalenCustomisationExtensionL(TUid /*aExtensionUid*/)
+	{
+	TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+	return NULL;
+	}
+
+/**
+ * CCalenCalDavPlugin::CalenCommandHandlerExtensionL
+ * CalenCommandHandlerExtensionL
+ */
+TAny* CCalenCalDavPlugin::CalenCommandHandlerExtensionL(TUid /*aExtensionUid*/)
+	{
+	TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+	return NULL;
+	}
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/caldav/src/calencaldavpluginProxy.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributor:
+* Maximilian Odendahl
+*
+* Contributors:
+* 
+* Description: calav ecom plugin proxy implementation
+*
+*/ 
+
+#include <implementationproxy.h>
+
+#include "CalDavUids.h"
+#include "calencaldavplugin.h"
+
+
+// ----------------------------------------------------------------------------
+// ImplementationTable
+// ----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( CALEN_CALDAV_IMPLEMENTATION_UID,
+                                CCalenCalDavPlugin::NewL )
+    
+    };
+
+
+// ----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// ----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof (TImplementationProxy);
+    return ImplementationTable;
+    }
+
+// ----------------------------------------------------------------------------
+// End of file
+// ----------------------------------------------------------------------------
+
--- a/calendarui/commonutils/bwins/calencommonutilsu.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/bwins/calencommonutilsu.def	Tue Sep 14 21:17:03 2010 +0300
@@ -138,3 +138,12 @@
 	?AttachmentOpen@CCalenAttachmentModel@@QAEXAAH@Z @ 137 NONAME ; void CCalenAttachmentModel::AttachmentOpen(int &)
 	?IsAttachmentOpen@CCalenAttachmentModel@@QAEHXZ @ 138 NONAME ; int CCalenAttachmentModel::IsAttachmentOpen(void)
 	?ShowNaviPaneL@CCalenStatusPaneUtils@@QAEPAVCAknNavigationDecorator@@ABVTDesC16@@VTRgb@@@Z @ 139 NONAME ; class CAknNavigationDecorator * CCalenStatusPaneUtils::ShowNaviPaneL(class TDesC16 const &, class TRgb)
+	?DateTimeToKoreanL@CKoreanCalConv@@QAEXABVTDateTime@@AAVTChineseDate@@@Z @ 140 NONAME ; void CKoreanCalConv::DateTimeToKoreanL(class TDateTime const &, class TChineseDate &)
+	?DateRange@CKoreanCalConv@@QAEXAAVTDateTime@@0@Z @ 141 NONAME ; void CKoreanCalConv::DateRange(class TDateTime &, class TDateTime &)
+	?CalendarType@CCalenEntryUtil@@QBE?AW4TLunarCalendarType@@XZ @ 142 NONAME ; enum TLunarCalendarType CCalenEntryUtil::CalendarType(void) const
+	?SetCalendarTypeL@CCalenEntryUtil@@QAEXW4TLunarCalendarType@@@Z @ 143 NONAME ; void CCalenEntryUtil::SetCalendarTypeL(enum TLunarCalendarType)
+	?DateRange@CKoreanCalConv@@QAEXAAVTChineseDate@@0@Z @ 144 NONAME ; void CKoreanCalConv::DateRange(class TChineseDate &, class TChineseDate &)
+	?KoreanToDateTimeL@CKoreanCalConv@@QAEXAAVTChineseDate@@AAVTDateTime@@@Z @ 145 NONAME ; void CKoreanCalConv::KoreanToDateTimeL(class TChineseDate &, class TDateTime &)
+	?NewL@CKoreanCalConv@@SAPAV1@XZ @ 146 NONAME ; class CKoreanCalConv * CKoreanCalConv::NewL(void)
+	?NewLC@CKoreanCalConv@@SAPAV1@XZ @ 147 NONAME ; class CKoreanCalConv * CKoreanCalConv::NewLC(void)
+
--- a/calendarui/commonutils/eabi/calencommonutilsu.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/eabi/calencommonutilsu.def	Tue Sep 14 21:17:03 2010 +0300
@@ -151,4 +151,14 @@
 	_ZN21CCalenAttachmentModel14AttachmentOpenERi @ 150 NONAME
 	_ZN21CCalenAttachmentModel16IsAttachmentOpenEv @ 151 NONAME
 	_ZN21CCalenStatusPaneUtils13ShowNaviPaneLERK7TDesC164TRgb @ 152 NONAME
+	_ZN14CKoreanCalConv17DateTimeToKoreanLERK9TDateTimeR12TChineseDate @ 153 NONAME
+	_ZN14CKoreanCalConv17KoreanToDateTimeLER12TChineseDateR9TDateTime @ 154 NONAME
+	_ZN14CKoreanCalConv4NewLEv @ 155 NONAME
+	_ZN14CKoreanCalConv5NewLCEv @ 156 NONAME
+	_ZN14CKoreanCalConv9DateRangeER12TChineseDateS1_ @ 157 NONAME
+	_ZN14CKoreanCalConv9DateRangeER9TDateTimeS1_ @ 158 NONAME
+	_ZN15CCalenEntryUtil16SetCalendarTypeLE18TLunarCalendarType @ 159 NONAME
+	_ZNK15CCalenEntryUtil12CalendarTypeEv @ 160 NONAME
+	_ZTI14CKoreanCalConv @ 161 NONAME
+	_ZTV14CKoreanCalConv @ 162 NONAME
 
--- a/calendarui/commonutils/group/bld.inf	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -22,11 +22,11 @@
 PRJ_EXPORTS
 ../inc/calenentryutil.h				|../../inc/calenentryutil.h
 ../inc/calennotedatautil.h			|../../inc/calennotedatautil.h
-../inc/calenlocationutil.h          |../../inc/calenlocationutil.h
 ../inc/calenattachmentutils.h       |../../inc/calenattachmentutils.h
 ../inc/calenattachmentinfo.h    	|../../inc/calenattachmentinfo.h
 ../inc/calenattachmentmodel.h   	|../../inc/calenattachmentmodel.h
 ../inc/calentitlepane.h				|../../inc/calentitlepane.h
+../inc/KoreanCalConv.h				|../../inc/KoreanCalConv.h
 PRJ_MMPFILES
 commonutils.mmp
 
--- a/calendarui/commonutils/group/commonutils.mmp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/group/commonutils.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -57,6 +57,8 @@
 
 SOURCE          calenmulticalutil.cpp
 SOURCE          calencustomnavilabel.cpp
+SOURCE 	        KoreanCalConv.cpp
+
 
 LIBRARY         caleninterimutils2.lib
 LIBRARY         avkon.lib
@@ -99,6 +101,9 @@
 LIBRARY		ws32.lib
 LIBRARY		aknlayout2scalable.lib
 LIBRARY		gdi.lib
+LIBRARY ccon.lib
+
+deffile			calencommonutils.def
 
 CAPABILITY      CAP_GENERAL_DLL
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/commonutils/inc/KoreanCalConv.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __KOREANCALCONV_H__
+#define __KOREANCALCONV_H__
+
+#include <e32base.h>
+#include <CalendarConverter.h>
+
+typedef class TChineseDate TKoreanDate;
+ 
+
+ enum TLunarCalendarType
+     {
+     ESolar = 0,
+     ELunar,
+     ELunarLeap
+     };
+	 
+class CKoreanCalConv : public CBase
+{
+    public: /* exported public methods */
+        /* Construction methods */
+    	IMPORT_C static CKoreanCalConv* NewL();
+    	IMPORT_C static CKoreanCalConv* NewLC();
+
+        /* Method converting gregorian date to korean lunar date,
+           supported range is 1.1.1900 - 31.12.2099
+           Leaves with KErrArgument if date is uncovertible.
+        */
+        IMPORT_C void DateTimeToKoreanL( const TDateTime& aDateTime, TKoreanDate& aKoreanDate );
+
+        /* Method converting korean lunar date to gregorian date,
+           supported range is 1.1.1900 - 31.12.2099
+           Leaves with KErrArgument if date is uncovertible.
+        */
+        IMPORT_C void KoreanToDateTimeL( TKoreanDate& aKoreanDate, TDateTime& aDateTime );
+
+        /* Method getting supported gregorian date range
+        */
+        IMPORT_C void DateRange( TDateTime& aLower, TDateTime& aUpper );
+
+        /* Method getting supported korean lunar date range
+        */
+        IMPORT_C void DateRange( TKoreanDate& aLower, TKoreanDate& aUpper );
+
+    public: /* public methods */
+        /* Desctructor */
+    	virtual ~CKoreanCalConv();
+
+    private: /* private methods */
+        /* C++ constructor */
+        CKoreanCalConv();
+
+        /* Second phase constructor */
+        void ConstructL();
+
+    private: /* Own private data */
+        CChineseCalendarConverter* chineseConv;
+
+};
+
+#endif /* __KOREANCALCONV_H__ */
--- a/calendarui/commonutils/inc/calenentryutil.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/inc/calenentryutil.h	Tue Sep 14 21:17:03 2010 +0300
@@ -25,6 +25,7 @@
 
 #include <caltime.h>
 #include "calennotedatautil.h"
+#include "KoreanCalConv.h"
 #include <calentry.h>
 
 
@@ -147,6 +148,19 @@
      * @return RArray<TCalTime> 
      */
     IMPORT_C const RArray<TCalTime> GetRdatesL();
+
+    /**
+     * Return Lunar Calendar Type
+     * 
+     * @return TLunarCalendarType
+     */
+    IMPORT_C TLunarCalendarType CalendarType() const;
+
+	/**
+	 * @brief set Lunar Calendar Type
+	 * @param TLunarCalendarType
+	 */
+    IMPORT_C void SetCalendarTypeL(TLunarCalendarType aCalendarType);
     
 private:
     CCalenEntryUtil( CCalEntry& aEntry );
@@ -256,6 +270,14 @@
     CCalEntry& iEntry;
     
     TInt iAttachmentCount;
+
+    TLunarCalendarType iCalendarType;
+
+    /**
+    * True if FeatureManager is initialized.
+    */
+    TBool iFeatMgrInitialized;
+    
     };
 
 #endif // CALENEDITORDATA_H
--- a/calendarui/commonutils/inc/calenlocationutil.h	Wed Sep 01 12:32:31 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description: Utility class to inform calendar components if any Nokia map 
- * 			providers are available. Its a static API.
- *
- */
-
-
-#ifndef CALENLOCATIONUTIL_H
-#define CALENLOCATIONUTIL_H
-
-// System includes
-#include <e32base.h>
-#include <mnprovider.h>
-
-class CCalenLocationUtil : public CBase
-	{
-	
-public:
-	
-	/**
-	 * API to tell claendar modules if Nokia maps provider is available 
-	 * in the device or not.
-	 * 
-	 * @return ETrue if Nokia maps is installed on the device else EFalse.
-	 */
-	static TBool IsMapProviderAvailableL();
-
-	/**
-	 * Utility function to display list query with three strings.
-	 * This function will be used when user selects a map location 
-	 * when there is already some invalidated location for the event.
-	 * First string will be a combination of lod text and newly 
-	 * selected map locaiton. Second string will be newly selected map location.
-	 * Third strign will be old invalidated text.
-	 * 
-	 * @params aStrings Array of three strings.
-	 * @return 0 for first string, 1 for second and 2 for third string when user 
-	 * 			selects his choice. If cancelled, returns -1. 
-	 */
-	static TInt ShowLocationAppendOrReplaceL( 
-	                                          RPointerArray< HBufC >& aStrings );
-	
-	};
-
-#endif // CALENLOCATIONUTIL_H
-
-// End of file	--Don't remove this.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/commonutils/src/KoreanCalConv.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,528 @@
+/*
+* 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:  Implementation of View Utils
+*
+*/
+
+#include "KoreanCalConv.h"
+
+//debug
+#include "calendarui_debug.h"
+
+/* Leap month exceptions for fixing conversion result
+   to match Korean lunar calendar:
+
+  year cycle, year, Chinese leap month, Korean leap month
+*/
+typedef struct
+{
+    TInt cycle;
+    TInt year;
+    TInt chineseLeapMonth;
+    TInt koreanLeapMonth;
+} TLeapExceptions;
+
+//CONSTANTS
+const TLeapExceptions KLeapExceptions[] = { {78, 29,  4,  3},
+                                            {78, 34,  6,  5},
+                                            {79, 56,  2,  3} };
+
+const TInt KLeapExceptionCnt = (sizeof( KLeapExceptions ) / sizeof( TLeapExceptions ));
+
+/* Month length exceptions for fixing conversion result
+   to match Korean lunar calendar. Corresponding months
+   have 30 days in Korean lunar calendar and 29 days
+   in Chinese lunar calendar. The next month always contains
+   30 days in Chinese lunar calendar and 29 days in Korean
+   lunar calendar:
+
+  year cycle, year, korean month, flag indicating leap month, flag indicating next month is leap
+*/
+typedef struct
+{
+    TInt cycle;
+    TInt year;
+    TInt koreanMonth;
+    TBool isLeapMonth;
+    TBool nextIsLeapMonth;
+} TMonthExceptions;
+
+const TMonthExceptions KMonthExceptions[] = { {76, 43,  3, EFalse, EFalse },
+                                              {76, 51,  5, EFalse, ETrue },
+                                              {76, 51,  9, EFalse, EFalse },
+                                              {76, 52, 12, EFalse, EFalse },
+                                              {76, 55, 10, EFalse, EFalse },
+                                              {76, 56,  7, EFalse, ETrue },
+                                              {76, 56,  9, EFalse, EFalse },
+                                              {76, 57,  9, EFalse, EFalse },
+                                              {76, 60,  9, EFalse, EFalse },
+                                              {77,  1,  1, EFalse, EFalse },
+                                              {77,  2,  4, EFalse, ETrue },
+                                              {77,  4,  9, EFalse, EFalse },
+                                              {77,  5,  8, EFalse, EFalse },
+                                              {77,  8,  3, EFalse, EFalse },
+                                              {77, 11,  8, EFalse, EFalse },
+                                              {77, 13,  5, EFalse, EFalse },
+                                              {77, 19,  7, EFalse, EFalse },
+                                              {77, 19,  9, EFalse, EFalse },
+                                              {77, 20, 10, EFalse, EFalse },
+                                              {77, 20, 12, EFalse, EFalse },
+                                              {77, 26,  2, EFalse, EFalse },
+                                              {77, 27,  1, EFalse, EFalse },
+                                              {77, 27,  4, EFalse, EFalse },
+                                              {77, 29,  6, EFalse, EFalse },
+                                              {77, 30, 12, EFalse, EFalse },
+                                              {77, 32,  1, EFalse, EFalse },
+                                              {77, 34, 12, EFalse, EFalse },
+                                              {77, 45,  3, EFalse, EFalse },
+                                              {77, 47,  5, EFalse, EFalse },
+                                              {77, 49, 11, EFalse, EFalse },
+                                              {77, 50, 11, EFalse, EFalse },
+                                              {77, 53,  9, EFalse, EFalse },
+                                              {77, 55,  2, EFalse, EFalse },
+                                              {77, 59,  9, EFalse, EFalse },
+                                              {78,  4,  4, EFalse, EFalse },
+                                              {78,  4, 12, EFalse, EFalse },
+                                              {78,  6,  9, EFalse, EFalse },
+                                              {78, 12,  6, EFalse, EFalse },
+                                              {78, 12,  9, EFalse, EFalse },
+                                              {78, 13, 12, EFalse, EFalse },
+                                              {78, 15, 11, EFalse, EFalse },
+                                              {78, 18,  3, EFalse, EFalse },
+                                              {78, 22, 10, EFalse, EFalse },
+                                              {78, 29,  4, EFalse, EFalse },
+                                              {78, 29,  6, EFalse, EFalse },
+                                              {78, 30,  4, EFalse, EFalse },
+                                              {78, 36, 10, EFalse, EFalse },
+                                              {78, 37,  1, EFalse, EFalse },
+                                              {78, 40,  3, EFalse, EFalse },
+                                              {78, 43,  8, EFalse, EFalse },
+                                              {78, 43, 12, EFalse, EFalse },
+                                              {78, 44, 12, EFalse, EFalse },
+                                              {78, 46,  5, EFalse, EFalse },
+                                              {78, 48,  1, EFalse, EFalse },
+                                              {78, 52, 11, EFalse, EFalse },
+                                              {78, 53, 10, EFalse, EFalse },
+                                              {78, 57,  7, EFalse, EFalse },
+                                              {78, 58,  1, EFalse, EFalse },
+                                              {78, 59, 10, EFalse, EFalse },
+                                              {79,  3,  4, EFalse, EFalse },
+                                              {79,  5, 10, EFalse, EFalse },
+                                              {79,  7,  1, EFalse, EFalse },
+                                              {79,  8,  6, EFalse, EFalse },
+                                              {79,  8,  9, EFalse, EFalse },
+                                              {79,  9,  8, ETrue, EFalse },
+                                              {79, 15,  5, EFalse, EFalse },
+                                              {79, 16,  8, EFalse, EFalse },
+                                              {79, 17,  8, EFalse, EFalse },
+                                              {79, 17, 12, EFalse, EFalse },
+                                              {79, 20,  3, EFalse, EFalse },
+                                              {79, 25,  5, EFalse, EFalse },
+                                              {79, 26,  1, EFalse, EFalse },
+                                              {79, 27,  1, EFalse, EFalse },
+                                              {79, 28,  2, EFalse, EFalse },
+                                              {79, 31,  6, ETrue, EFalse },
+                                              {79, 37,  9, EFalse, EFalse },
+                                              {79, 38,  1, EFalse, EFalse },
+                                              {79, 39,  6, EFalse, EFalse },
+                                              {79, 45, 12, EFalse, EFalse },
+                                              {79, 46,  7, EFalse, EFalse },
+                                              {79, 51,  1, EFalse, EFalse },
+                                              {79, 53,  7, EFalse, EFalse },
+                                              {79, 54,  6, EFalse, EFalse },
+                                              {79, 55,  7, EFalse, EFalse },
+                                              {79, 55, 11, EFalse, EFalse },
+                                              {79, 56,  3, EFalse, ETrue } };
+
+const TInt KMonthExceptionCnt = (sizeof( KMonthExceptions ) / sizeof( TMonthExceptions ));
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::NewL
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CKoreanCalConv* CKoreanCalConv::NewL()
+    {
+    TRACE_ENTRY_POINT;
+    CKoreanCalConv* self = CKoreanCalConv::NewLC();
+    CleanupStack::Pop( self );
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::NewLC
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CKoreanCalConv* CKoreanCalConv::NewLC()
+    {
+    TRACE_ENTRY_POINT;
+    CKoreanCalConv* self = new (ELeave) CKoreanCalConv();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::CKoreanCalConv
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CKoreanCalConv::CKoreanCalConv()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::ConstructL
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CKoreanCalConv::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+    chineseConv = CChineseCalendarConverter::NewL();
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::~CKoreanCalConv
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CKoreanCalConv::~CKoreanCalConv()
+    {
+    TRACE_ENTRY_POINT;
+    delete chineseConv;
+    TRACE_EXIT_POINT;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::DateTimeToKoreanL
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CKoreanCalConv::DateTimeToKoreanL( const TDateTime& aDateTime, TKoreanDate& aKoreanDate )
+    {
+    TRACE_ENTRY_POINT;
+    TInt i;
+    
+    /* Use the chinese converter for initial result */
+    chineseConv->DateTimeToChineseL( aDateTime, aKoreanDate );
+    
+    /* Check if leap month fix is needed */
+    for( i = 0 ; i < KLeapExceptionCnt ; i++ )
+        {
+        if( KLeapExceptions[i].cycle == aKoreanDate.iCycle &&
+        KLeapExceptions[i].year == aKoreanDate.iYear )
+            { /* Year contains an exception */
+            if( KLeapExceptions[i].koreanLeapMonth < KLeapExceptions[i].chineseLeapMonth )
+                {
+                if( aKoreanDate.iLeapMonth )
+                    { /* Resulted month is leap month in Chinese but not in Korean,
+                    fix by unsetting the leap month flag */
+                    aKoreanDate.iLeapMonth = EFalse;
+                    }
+                else
+                    {
+                    if( aKoreanDate.iMonth == (KLeapExceptions[i].koreanLeapMonth + 1) )
+                        { /* Resulted month is actually a leap month on Korean Calendar,
+                        fix by setting the leap month flag and decreasing month by one */
+                        aKoreanDate.iLeapMonth = ETrue;
+                        aKoreanDate.iMonth -= 1;
+                        }
+                    
+                    /* See if month needs an offset fix */
+                    if( aKoreanDate.iMonth > KLeapExceptions[i].koreanLeapMonth &&
+                                    aKoreanDate.iMonth <= KLeapExceptions[i].chineseLeapMonth )
+                        { /* Between the leap months, fix by decreasing the month by one */
+                        aKoreanDate.iMonth -= 1;
+                        }
+                    }
+                }
+            else if( KLeapExceptions[i].koreanLeapMonth > KLeapExceptions[i].chineseLeapMonth )
+                {
+                if( aKoreanDate.iLeapMonth )
+                    { /* Resulted month is leap month in Chinese but not in Korean,
+                    fix by unsetting the leap month flag and increase the month by one */
+                    aKoreanDate.iLeapMonth = EFalse;
+                    aKoreanDate.iMonth += 1;
+                    }
+                else
+                    {
+                    if( aKoreanDate.iMonth == KLeapExceptions[i].koreanLeapMonth )
+                        { /* Resulted month is actually a leap month on Korean Calendar,
+                        fix by setting the leap month flag */
+                        aKoreanDate.iLeapMonth = ETrue;
+                        }
+                    
+                    /* See if month needs an offset fix */
+                    if( aKoreanDate.iMonth > KLeapExceptions[i].chineseLeapMonth &&
+                                aKoreanDate.iMonth < KLeapExceptions[i].koreanLeapMonth )
+                        { /* Between the leap months, fix by increasing the month by one */
+                        aKoreanDate.iMonth += 1;
+                        }
+                    }
+                }
+            break;
+            }
+        }
+    
+    /* Check if month length fix is needed */
+    for( i = 0 ; i < KMonthExceptionCnt ; i++ )
+        {
+        if( (KMonthExceptions[i].cycle == aKoreanDate.iCycle &&
+                    KMonthExceptions[i].year == aKoreanDate.iYear &&
+                    KMonthExceptions[i].koreanMonth != 12 &&
+                    aKoreanDate.iMonth != 1) ||
+                    (KMonthExceptions[i].koreanMonth == 12 && aKoreanDate.iMonth == 1 &&
+                    (KMonthExceptions[i].year == (aKoreanDate.iYear - 1) &&
+                    KMonthExceptions[i].cycle == aKoreanDate.iCycle) ||
+                    (KMonthExceptions[i].year == 60 && aKoreanDate.iYear == 1 && 
+                    KMonthExceptions[i].cycle == (aKoreanDate.iCycle - 1))) )
+            { /* Year may contain an exception */
+            if( (KMonthExceptions[i].koreanMonth == (aKoreanDate.iMonth - 1) && 
+                        !(KMonthExceptions[i].nextIsLeapMonth || aKoreanDate.iLeapMonth)) ||
+                        (KMonthExceptions[i].koreanMonth == 12 && aKoreanDate.iMonth == 1) ||
+                        (KMonthExceptions[i].koreanMonth == aKoreanDate.iMonth &&
+                        KMonthExceptions[i].nextIsLeapMonth && aKoreanDate.iLeapMonth) )
+                { /* Month contains an exception, decrease the day by one */
+                if( aKoreanDate.iDay == 1 )
+                    {
+                    aKoreanDate.iDay = 30;
+                    if( aKoreanDate.iMonth == 1 )
+                        {
+                        aKoreanDate.iMonth = 12;
+                        if( aKoreanDate.iYear == 1 )
+                            {
+                            aKoreanDate.iYear = 60;
+                            aKoreanDate.iCycle -= 1;
+                            }
+                        else
+                            {
+                            aKoreanDate.iYear -= 1;
+                            }
+                        }
+                    else
+                        {
+                        if( !aKoreanDate.iLeapMonth )
+                            { /* Leap months don't need month decreasing */
+                            aKoreanDate.iMonth -= 1;
+                            }
+                        if( KMonthExceptions[i].isLeapMonth )
+                            {
+                            aKoreanDate.iLeapMonth = ETrue;
+                            }
+                        else
+                            {
+                            aKoreanDate.iLeapMonth = EFalse;
+                            }
+                        }
+                    }
+                else
+                    {
+                    aKoreanDate.iDay -= 1;
+                    }
+                break;
+                }
+            }
+        }
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::KoreanToDateTimeL
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CKoreanCalConv::KoreanToDateTimeL( TKoreanDate& aKoreanDate, TDateTime& aDateTime )
+    {
+    TRACE_ENTRY_POINT;
+    TInt i;
+    TKoreanDate fixDate = aKoreanDate;
+    
+    /* Check if month length fix is needed */
+    for( i = 0 ; i < KMonthExceptionCnt ; i++ )
+        {
+        if( (KMonthExceptions[i].cycle == fixDate.iCycle &&
+                KMonthExceptions[i].year == fixDate.iYear &&
+                fixDate.iMonth != 1) ||
+                (fixDate.iMonth == 1 &&
+                (KMonthExceptions[i].year == (fixDate.iYear - 1) &&
+                KMonthExceptions[i].cycle == fixDate.iCycle) ||
+                (KMonthExceptions[i].year == 60 && fixDate.iYear == 1 && 
+                KMonthExceptions[i].cycle == (fixDate.iCycle - 1))) )
+            { /* Year may contain an exception */
+            if( (KMonthExceptions[i].koreanMonth == fixDate.iMonth &&
+            KMonthExceptions[i].isLeapMonth == fixDate.iLeapMonth) )
+                { /* Month contains an exception */
+                if( fixDate.iDay == 30 )
+                    { /* Fix the last day to be the first day of next month */
+                    fixDate.iDay = 1;
+                    if( fixDate.iMonth == 12 )
+                        {
+                        fixDate.iMonth = 1;
+                        if( fixDate.iYear == 60 )
+                            {
+                            fixDate.iYear = 1;
+                            fixDate.iCycle += 1;
+                            }
+                        else
+                            {
+                            fixDate.iYear += 1;
+                            }
+                        }
+                    else
+                        {
+                        if( KMonthExceptions[i].nextIsLeapMonth )
+                            { /* Leap months don't need increasing,
+                            just set the flag */
+                            fixDate.iLeapMonth = ETrue;
+                            }
+                        else
+                            {
+                            fixDate.iLeapMonth = EFalse;
+                            fixDate.iMonth += 1;
+                            }
+                        }
+                    }
+                break;
+                }
+            else if( (KMonthExceptions[i].koreanMonth == (fixDate.iMonth - 1) && 
+                    !(KMonthExceptions[i].nextIsLeapMonth || fixDate.iLeapMonth)) ||
+                    (KMonthExceptions[i].koreanMonth == 12 && fixDate.iMonth == 1) ||
+                    (KMonthExceptions[i].koreanMonth == fixDate.iMonth &&
+                    KMonthExceptions[i].nextIsLeapMonth && fixDate.iLeapMonth) )
+                { /* It is the month following the exception, increase the day by one */
+                if( fixDate.iDay == 30 )
+                    { /* Invalid day, Korean Lunar calendar has always only 29 days
+                    after the exception month */
+                    User::Leave( KErrArgument );
+                    }
+                else
+                    {
+                    fixDate.iDay += 1;
+                    }
+                break;
+                }
+            }
+        }
+    
+    /* Check if leap month fix is needed */
+    for( i = 0 ; i < KLeapExceptionCnt ; i++ )
+        {
+        if( KLeapExceptions[i].cycle == fixDate.iCycle &&
+                    KLeapExceptions[i].year == fixDate.iYear )
+            { /* Year contains an exception */
+            if( KLeapExceptions[i].koreanLeapMonth != fixDate.iMonth &&
+            fixDate.iLeapMonth )
+                { /* This year does not have the requested leap month in 
+                Korean lunar calendar, leave with error */
+                User::Leave( KErrArgument );
+                }
+            
+            if( fixDate.iMonth == KLeapExceptions[i].koreanLeapMonth &&
+            fixDate.iLeapMonth )
+                { /* Leap month in Korean lunar calendar, but not in Chinese
+                lunar calendar, fix by clearing the leap indicator*/
+                fixDate.iLeapMonth = EFalse;
+                if( KLeapExceptions[i].koreanLeapMonth < KLeapExceptions[i].chineseLeapMonth )
+                { /* Also month needs to be increased */
+                fixDate.iMonth += 1;
+                }
+                }
+            else if( fixDate.iMonth > KLeapExceptions[i].koreanLeapMonth &&
+            fixDate.iMonth < KLeapExceptions[i].chineseLeapMonth )
+                { /* Month between the leap month */
+                if( KLeapExceptions[i].koreanLeapMonth < KLeapExceptions[i].chineseLeapMonth )
+                    {
+                    fixDate.iMonth += 1;
+                    }
+                else
+                    {
+                    fixDate.iMonth -= 1;
+                    }
+                }
+            else if( fixDate.iMonth == (KLeapExceptions[i].chineseLeapMonth + 1) &&
+                            !fixDate.iLeapMonth )
+                { /* Leap month in Chinese lunar calendar, fix by decreasing
+                the monrth by one and setting the leap indicator */
+                fixDate.iMonth -= 1;
+                fixDate.iLeapMonth = ETrue;
+                }
+            chineseConv->ChineseToDateTimeL( fixDate, aDateTime );
+            
+            TRACE_EXIT_POINT;
+            return;
+            }
+        }
+    /* Use the chinese converter for result */
+    chineseConv->ChineseToDateTimeL( fixDate, aDateTime );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::DateRange
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CKoreanCalConv::DateRange( TDateTime& aLower, TDateTime& aUpper )
+    {
+    TRACE_ENTRY_POINT;
+    aLower.SetYear( 1900 );
+    aLower.SetMonth( EJanuary );
+    aLower.SetDay( 1 );
+    aUpper.SetYear( 2099 );
+    aUpper.SetMonth( EDecember );
+    aUpper.SetDay( 31 );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CKoreanCalConv::DateRange
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CKoreanCalConv::DateRange( TKoreanDate& aLower, TKoreanDate& aUpper )
+    {
+    TRACE_ENTRY_POINT;
+    aLower.iCycle = 76;
+    aLower.iYear = 36;
+    aLower.iMonth = 12;
+    aLower.iDay = 1;
+    aLower.iLeapMonth = EFalse;
+    aUpper.iCycle = 79;
+    aUpper.iYear = 56;
+    aUpper.iMonth = 11;
+    aUpper.iDay = 20;
+    aUpper.iLeapMonth = EFalse;
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
--- a/calendarui/commonutils/src/calenentryutil.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/src/calenentryutil.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -30,6 +30,8 @@
 #include <calentry.h>
 #include <calrrule.h>
 #include <calattachment.h>
+#include <bldvariant.hrh> // for feature definitions
+#include <featmgr.h>
 
 
 // Utility functions 
@@ -139,6 +141,15 @@
     delete iSummary;
     delete iLocation;
     delete iDescription;
+    
+    // Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+    
+
 
     TRACE_EXIT_POINT;
     }
@@ -692,6 +703,12 @@
                                    const TCalTime& aInstanceDateTime )
     {
     TRACE_ENTRY_POINT;
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+     
+
     iEntryType = aEntry.EntryTypeL();
     iEntryStatus = aEntry.StatusL();
     CopyDataFromEntryL( aEntry, aInstanceDateTime );
@@ -752,6 +769,10 @@
             {
             TTime event = aInstanceDateTime.TimeLocalL();
             SetEventDateL( event );
+            if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+                {
+				SetCalendarTypeL( ( TLunarCalendarType )aEntry.UserInt32L() );
+                }
             }
             break;
 
@@ -916,13 +937,25 @@
         		{
         		// If the instance matches one of the RDates
         		if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) )
-        			{
-        			// instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
-        			deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
-								- alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
-        			alarmDateTime += deltaDays;
-        			break;
-        			}
+                    {
+                    // instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
+                    deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
+                    - alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
+                    alarmDateTime += deltaDays;
+                    if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+                        {
+                        if ( aEntry.EntryTypeL() == CCalEntry::EAnniv && CalendarType() != ESolar )
+                            {
+                            alarmDateTime = aEntry.StartTimeL().TimeLocalL(); 
+                            CCalAlarm* alarm = aEntry.AlarmL();
+                            if(alarm)
+                                {
+                                alarmDateTime = aInstanceDateTime.TimeLocalL() - alarm->TimeOffset();
+                                }
+                            }
+                        }
+                    break;
+                    }
         		}
         	}        	
         SetAlarmOnL( alarmDateTime );
@@ -1040,4 +1073,31 @@
     TRACE_EXIT_POINT;
     }
 
+// ---------------------------------------------------------------------------
+// CalenViewUtils::CalendarType
+// (other items were commented in a header)
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TLunarCalendarType CCalenEntryUtil::CalendarType() const
+    { 
+	TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+
+    return iCalendarType;
+    }
+
+// ---------------------------------------------------------------------------
+// CalenViewUtils::SetCalendarTypeL
+// (other items were commented in a header)
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CCalenEntryUtil::SetCalendarTypeL(TLunarCalendarType aCalendarType)
+    {
+	TRACE_ENTRY_POINT;
+
+    iCalendarType = aCalendarType;
+	TRACE_EXIT_POINT;
+
+    }
+
 // End of file
--- a/calendarui/commonutils/src/calenlocationutil.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/commonutils/src/calenlocationutil.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-#include "calenlocationutil.h"
+#include <calenlocationutil.h>
 #include <mnproviderfinder.h>
 #include <aknPopup.h>
 #include <eikenv.h>
--- a/calendarui/controller/src/calenbackgroundstate.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calenbackgroundstate.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -105,6 +105,8 @@
         case ECalenTodoView:
         case ECalenMonthView:
         case ECalenWeekView:
+        case ECalenMissedAlarmsViewFromIdle:
+        case ECalenMissedEventViewFromIdle:
             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenIdleState);
             cmdUsed = ETrue;
             break;
--- a/calendarui/controller/src/calencmdlinelauncher.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calencmdlinelauncher.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -261,6 +261,10 @@
           	
             if( iController.ViewManager().ViewsActivated() )
                 {
+                if(command == ECalenDayView)
+                    {
+                    iController.BroadcastNotification(ECalenNotifyCalenLaunchedFromExtApp);
+                    }
                 iController.IssueCommandL( command );
                 iController.SetLaunchFromExternalApp( ETrue );
                 }
@@ -294,7 +298,7 @@
 		        if( iCmdParameters.iCommandType == CCalenCmdLineParser::EStartTypeUidAlarmViewer )
               		{
                     //When event viewer launched from alarm only we need to ignore tap. (ETrue)     
-		            iController.BroadcastNotification(ECalenNotifyEventViewLaunchedFromAlarm);
+		            iController.BroadcastNotification(ECalenNotifyCalenLaunchedFromExtApp);
               		if(! iController.ViewManager().ViewsActivated() )                    
                         {
                         iController.ViewManager().ActivateDefaultViewL( KUidCalenEventView); 
@@ -305,7 +309,7 @@
                 else if( iCmdParameters.iCommandType == CCalenCmdLineParser::EStartTypeUidAlarmViewerNoSnooze )
                     {
                     //When event viewer launched from alarm only we need to ignore tap. (ETrue)     
-                    iController.BroadcastNotification(ECalenNotifyEventViewLaunchedFromAlarm);
+                    iController.BroadcastNotification(ECalenNotifyCalenLaunchedFromExtApp);
                     if(! iController.ViewManager().ViewsActivated() )                    
                         {
                         iController.ViewManager().ActivateDefaultViewL( KUidCalenEventView);   
--- a/calendarui/controller/src/calencontroller.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calencontroller.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -435,6 +435,10 @@
 	    {
 	    SetFasterAppFlag( ETrue );
 	    aCommand = ECalenFasterAppExit;
+        if( iViewManager->CalenToolbar() )
+            {
+            iViewManager->CalenToolbar()->SetToolbarVisibilityL(ETrue);
+            }
 	    }
     else if( aCommand == EAknCmdExit || aCommand == EEikCmdExit
              || aCommand == EAknSoftkeyExit )
--- a/calendarui/controller/src/calenlocationui.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calenlocationui.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -20,7 +20,7 @@
 //debug
 #include "calendarui_debug.h"
 
-#include "calenlocationui.h"
+#include <calenlocationui.h>
 #include "calencontroller.h"
 #include <calencommands.hrh>
 #include "calenlocationactiveselector.h"
--- a/calendarui/controller/src/calennotifier.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calennotifier.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -79,10 +79,7 @@
         }
     
     iHandlers.Close();
-    
-    iBroadcastQueue.Close();
-    
-    
+  
     if( iFilnameDeleted )
         {
         delete iFilnameDeleted;
@@ -128,7 +125,10 @@
         TRAP_IGNORE(iGlobalData->CalSessionL().StopFileChangeNotification());
         iGlobalData->Release();
         }
-	TRACE_EXIT_POINT;
+    
+    iBroadcastQueue.Close();
+
+    TRACE_EXIT_POINT;
 	}
 
 // ----------------------------------------------------------------------------
--- a/calendarui/controller/src/calenviewmanager.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/controller/src/calenviewmanager.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -915,7 +915,7 @@
 		}
 	
 	// set the previous view id
-	if(cachePreviousViewId != KUidCalenEventView) 
+	if(cachePreviousViewId != KUidCalenEventView || cachePreviousViewId != iCurrentViewId.iViewUid) 
 	    {
         iPreviousViewId.iViewUid = cachePreviousViewId; 
 	    }	
@@ -1058,6 +1058,7 @@
         case ECalenNotifyEntryDeleted:
         case ECalenNotifyInstanceDeleted:    
 			{
+			iAvoidRepopulation = EFalse;
 			HandleEntryDeleteNotificationL();
 			}
 			break;
--- a/calendarui/customisationmanager/src/calencustomisationmanager.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/customisationmanager/src/calencustomisationmanager.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -593,21 +593,31 @@
         case ELangEnglish_Thailand:
             needsToBeRemoved.Append(KCalenChineseImplUid);
             needsToBeRemoved.Append(KCalenVietnameseImplUid);
+            needsToBeRemoved.Append(KCalenKoreanImplUid);
             break;
         case ELangTaiwanChinese:
         case ELangHongKongChinese:
         case ELangPrcChinese:
             needsToBeRemoved.Append(KCalenThaiImplUid);
             needsToBeRemoved.Append(KCalenVietnameseImplUid);
+            needsToBeRemoved.Append(KCalenKoreanImplUid);
             break;
         case ELangVietnamese:
             needsToBeRemoved.Append(KCalenThaiImplUid);
             needsToBeRemoved.Append(KCalenChineseImplUid);
+            needsToBeRemoved.Append(KCalenKoreanImplUid);
             break;
+        case ELangKorean:
+            needsToBeRemoved.Append(KCalenChineseImplUid);
+            needsToBeRemoved.Append(KCalenVietnameseImplUid);
+            needsToBeRemoved.Append(KCalenThaiImplUid);
+            break;
+            
         default:
             needsToBeRemoved.Append(KCalenThaiImplUid);
             needsToBeRemoved.Append(KCalenChineseImplUid);
             needsToBeRemoved.Append(KCalenVietnameseImplUid);
+            needsToBeRemoved.Append(KCalenKoreanImplUid);
             break;
         }
     
--- a/calendarui/editors/data/CalenDefaultEditorsData.rss	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/data/CalenDefaultEditorsData.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -30,6 +30,8 @@
 #include <avkon.loc>
 #include <calencommands.hrh>            // Calendar commands
 
+#include "KoreanLunarDateEditor.rh"
+#include <calenkoreanlunar.loc>
 #include "CalenDefaultEditors.hrh"
 #include "CalendarVariant.hrh"
 #include "calendar.hrh"
@@ -132,6 +134,32 @@
 
 // ---------------------------------------------------------
 //
+//    r_korean_lunar_type_popup_items
+//    Define items of "Solar/lunar:" popup list.
+//
+// ---------------------------------------------------------
+//
+RESOURCE ARRAY r_korean_lunar_type_popup_items
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_kor_cale_note_type_solar;
+            },
+        LBUF
+            {
+            txt = qtn_kor_cale_note_type_lunar;
+            },
+        LBUF
+            {
+            txt = qtn_kor_cale_note_type_leap;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//
 //    r_calen_noteview_menubar
 //    Menubar for NoteView
 //    The upper menu title is defined in , the lower display position is.
@@ -1707,5 +1735,60 @@
         LBUF { txt = qtn_cale_om_descript_exist; }
         };
     }
+    
+// ---------------------------------------------------------
+//
+//    r_korean_lunar_date_editor_line
+//    Define Lunar "Date:" line
+//
+// ---------------------------------------------------------
+//
+RESOURCE DLG_LINE r_korean_lunar_date_editor_line
+    {
+    type = ECalenCtLunarDateEditor;
+    prompt = qtn_cale_anniversary_start_date;
+    id = EKoreanLunarAniversityStart; // was ecalendata tms.
+    control = KOREAN_LUNAR_DATE_EDITOR
+        {
+	    flags = 0;
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//    r_korean_lunar_noteview_type_line
+//    Define "solar/lunar/leap:" line of Note Form
+//
+// ---------------------------------------------------------
+//
+RESOURCE DLG_LINE r_korean_lunar_noteview_type_line
+    {
+    type = EAknCtPopupField;
+    prompt = qtn_kor_cale_note_type;
+    id = EKoreanLunarTypeSelectSolarLunarLeap;
+    // means that OK-Key works - IMPORTANT!
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = POPUP_FIELD
+        {
+        flags = 0;
+        width = 8; // in characters  
+        other = " "; // Dummy
+        };
+    }
+
+RESOURCE TBUF r_kor_cale_note_offset_unit
+    {
+    buf = qtn_kor_cale_note_offset_unit;
+    }
+
+RESOURCE TBUF r_qtn_kor_cale_viewer_alarm_offset
+    {
+    buf = qtn_kor_cale_viewer_alarm_offset;
+    }
+
+RESOURCE TBUF r_qtn_kor_cale_viewer_alarm_offset_time
+    {
+    buf = qtn_kor_cale_viewer_alarm_offset_time;
+    }
 
 // End of File
--- a/calendarui/editors/group/CalenDefaultEditors.mmp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/group/CalenDefaultEditors.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -79,6 +79,9 @@
 SOURCE      	calenalldayfield.cpp 
 SOURCE          calenpriorityfield.cpp
 SOURCE			calenunifiededitorcontrol.cpp
+SOURCE          KoreanLunarDateEditor.cpp
+SOURCE          KoreanLunarDateUtil.cpp
+SOURCE          KoreanLunarTypeField.cpp
 
 
 LIBRARY         caleninterimutils2.lib
@@ -117,6 +120,7 @@
 LIBRARY         aknlayout2scalable.lib
 LIBRARY         centralrepository.lib   // Central Repository
 LIBRARY			apmime.lib
+LIBRARY         ccon.lib
 
 // File logging
 LIBRARY flogger.lib
--- a/calendarui/editors/inc/CalenDefaultEditors.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/inc/CalenDefaultEditors.h	Tue Sep 14 21:17:03 2010 +0300
@@ -110,6 +110,13 @@
      */
     MCalenServices* iServices;
     
+    /**
+    * True if FeatureManager is initialized.
+    */
+    TBool iFeatMgrInitialized;
+         
+
+    
     };
 
 #endif // __CALENDEFAULTEDITORS_H__
--- a/calendarui/editors/inc/CalenDefaultEditors.hrh	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/inc/CalenDefaultEditors.hrh	Tue Sep 14 21:17:03 2010 +0300
@@ -34,11 +34,11 @@
 #define KToDoMaxMinute                  59
 #define KToDoMaxHour                    23
 
-enum //
+enum TCalenEditorMenuPaneCommands
     {
     // THIS RANGE SHOULD NOT OVERLAP WITH CALENDAR RANGE
     //always hidden, allows easy adding of items to beginning of menu
-    ECalenCmdFirstMenuItem = 5000, 
+    ECalenCommandFirstMenuItem = 5000, 
 
     /* Description data commands */
     ECalenCmdAddDescription,
@@ -82,7 +82,8 @@
 
 enum //TCalenNoteCustomControls
     {
-    ECalenCtDescriptionField = KAknCtLastControlId + 1
+    ECalenCtDescriptionField = KAknCtLastControlId + 1,
+    ECalenCtLunarDateEditor
     };
 
 enum //TCalenNoteFormConstant
@@ -97,28 +98,6 @@
     
     /* Constants */
 
-enum // TCalenMinTime
-    {
-    ECalenMinDay = 0,
-    ECalenMinMonth = 0,
-    ECalenMinYear = 1900,
-    ECalenMinSecond = 0,
-    ECalenMinMinute = 0,
-    ECalenMinHour = 0,
-    ECalenMinAnnivYear = 1900
-    };
-
-enum // TCalenMaxTime
-    {
-    ECalenMaxDay = 29,
-    ECalenMaxMonth = 11,
-    ECalenMaxYear = 2100,
-    ECalenMaxSecond = 59,
-    ECalenMaxMinute = 59,
-    ECalenMaxHour = 23,
-    ECalenMaxAnnivYear = 2100 // FIXME, could be removed?
-    };
-
 /**
  * Date representing forever value in Repeat until field.
  */
@@ -156,7 +135,9 @@
     ECalenEditorPeople,
     ECalenEditorDBName,
     ECalenEditorAttachment,
-    ECalenEditorDescription
+    ECalenEditorDescription,
+    EKoreanLunarAniversityStart,
+    EKoreanLunarTypeSelectSolarLunarLeap
     };
 
 
--- a/calendarui/editors/inc/CalenEditorDataHandler.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/inc/CalenEditorDataHandler.h	Tue Sep 14 21:17:03 2010 +0300
@@ -279,6 +279,13 @@
      * @return ETrue if modified, EFalse otherwise.
      */
     TBool AllDayFieldEdited();
+    
+    /**
+     * @brief Returns if the `Lunar event' field is modified or not.
+     * 
+     * @return ETrue if modified, EFalse otherwise.
+     */
+    TBool LunarFieldEdited();
 
     /**
      * @brief To set default Alarm date time.
@@ -595,6 +602,13 @@
     * @brief Holds the id of the instance which is being edited currently.
     */
     TCalenInstanceId iInstanceId;
+
+
+    /**
+    * True if FeatureManager is initialized.
+    */
+    TBool iFeatMgrInitialized;
+    
     };
 
 #endif // CALENEDITORDATAHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/inc/KoreanLunarDateEditor.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* 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: 
+*
+*/
+
+#if !defined(__KOREANLUNARDATEEDITOR_H_)
+#define __KOREANLUNARDATEEDITOR_H_
+
+// INCLUDES
+#include <eikmfne.h>
+#include <calencustomisationmanager.h>
+
+//Forward Declarations
+class CKoreanCalConv;
+class CKoreanLunarDateUtil;
+
+NONSHARABLE_CLASS( CKoreanLunarDateEditor ) : public CEikMfne//CEikDateEditor// 
+    {
+    public: // public constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CKoreanLunarDateEditor(MCalenServices* aServices);
+
+        /**
+        * Two phased constructor.
+        */
+        void ConstructL( const TInt aFlags=0 );
+
+        /**
+        * Two phased constructor.
+        */
+    	static CKoreanLunarDateEditor* NewL(MCalenServices* aServices);
+	
+    public: // Methods for getting and setting values
+	        
+        /**
+        * Set's the date.
+        * @param aDate date to set
+        * 
+        */
+        void SetDate( const TTime& aDate, TBool newEntry );
+
+        /**
+        * Gets the editor's value.
+        * @return TTime struct including the date.
+        */
+        TTime Date();
+
+        /**
+     	* Sets the editor's leap mode dynamically.
+        * @param aLeap indicates if leap mode should be enabled (ETrue)
+        * or disabled (EFalse)
+        */
+        void SetLeap( const TBool aLeap );
+        
+        /**
+         * Method for reading the leap mode status.
+         * 
+         */
+        /**
+        * Gets the editor's leap mode.
+        * @return TBool indicating leap mode state.
+        */
+        TBool Leap() const;
+        
+        
+	
+    public: // from CCoeControl
+
+    	/**
+        * From @c CCoeControl. Constructs controls from a resource file.
+        * Essential for Dialog/Form construction.
+        * @param aResourceReader The resource reader with which to access 
+        * @c LUNAR_DATE_EDITOR
+        * resource.
+        */
+    	void ConstructFromResourceL(TResourceReader& aResourceReader);
+    	/**
+    	 * Prepares For FocusLoss
+    	 */
+        void PrepareForFocusLossL();
+        
+		/**
+		 * Handles Control State Change 
+		 */
+        void HandleControlStateChangeL( TInt aControlId );
+
+    private:
+        /**
+        * From CAknControl
+        */
+        void* ExtensionInterface( TUid aInterface );
+
+    private: 
+        virtual void CEikMfne_Reserved();
+
+    private:
+        HBufC*          iIndicatorField;
+        CEikMfneNumber* iMonthField;
+        CEikMfneNumber* iDayField;
+        TDateTime       iDate;
+        TBool           iLeap;
+        
+        MCalenServices* iServices;
+        
+        CKoreanCalConv* iConverter;
+        CKoreanLunarDateUtil* iDateUtil;
+	};
+
+#endif /* __KOREANLUNARDATEEDITOR_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/inc/KoreanLunarDateEditor.rh	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+STRUCT KOREAN_LUNAR_DATE_EDITOR
+	{
+	BYTE flags;		
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/inc/KoreanLunarDateUtil.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,89 @@
+/*
+* 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: 
+*
+*/
+
+#if !defined(__KOREANLUNARDATEUTIL_H_)
+#define __KOREANLUNARDATEUTIL_H_
+
+class MCalenServices;
+
+// SYSTEM INCLUDES
+#include <e32base.h>
+#include <calencustomisationmanager.h>
+#include <KoreanCalConv.h>
+#include <caltime.h>
+#include <CalendarConverter.h>
+typedef class TChineseDate TKoreanDate;
+
+
+NONSHARABLE_CLASS( CKoreanLunarDateUtil ) : public CBase
+    {
+    public: // public constructors
+        /**
+        * Two phased constructors.
+        */
+    	static CKoreanLunarDateUtil* NewL(MCalenServices* aServices);
+    	static CKoreanLunarDateUtil* NewLC(MCalenServices* aServices);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CKoreanLunarDateUtil();
+	
+    public:
+
+        /**
+        * Gets nearest possible gregorian date from lunar day and month and gregorian reference.
+        * @param aMonth lunar month
+        * @param aDay lunar day
+        * @param aLeap ETrue if leap month, EFalse otherwise
+        * @param aReference reference gregorian date
+        * @leave KErrArgument Given date is unconvertible.
+        * @return TTime struct including the date.
+        */
+        TDateTime GetNearestGregorianDateL( const TInt aMonth,
+                                            const TInt aDay,
+                                            const TBool aLeap,
+                                            const TDateTime& aReference ) const;
+
+        /**
+        * Gets lunar yearly repeats in gregorian dates.
+        * @param aRDates repeat date array
+        * @param aEntryDate gregorian entry date
+        * @param aMaxRepeats max repeat dates to get
+        * @param aFloating ETrue if repeat dates should be in floating format, EFalse otherwise
+        */
+        void GetLunarYearlyRepeatsL( RArray<TCalTime>& aRDates,
+                                     const TDateTime& aEntryDate,
+                                     const TBool aFloating ) const;
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+        CKoreanLunarDateUtil(MCalenServices* aServices);
+        /**
+        * Two phased constructor.
+        */
+        void ConstructL();
+
+    private:
+        CKoreanCalConv* iConverter;
+        MCalenServices* iServices;
+	};
+
+
+#endif /* __KOREANLUNARDATEUTIL_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/inc/KoreanLunarTypeField.h	Tue Sep 14 21:17:03 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: 
+*
+*/
+
+#ifndef KOREANLUNARTYPEFIELD_H
+#define KOREANLUNARTYPEFIELD_H
+
+// INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+
+#include "calenunifiededitor.h"
+
+#include "calenentryutil.h"
+// FORWARD DECLARATIONS
+class CCalEntry;
+class CAknQueryValueTextArray;
+class CAknQueryValueText;
+
+
+// CLASS DECLARATION
+/**
+ * Implements calendar type field for Calendar Editors.
+ */ 
+NONSHARABLE_CLASS( CKoreanLunarTypeField ) : public CBase
+    {
+public:
+	/**
+	 * @brief NewL.
+	 * @param CCalenUnifiedEditor
+	 */
+    static CKoreanLunarTypeField* NewL(CCalenUnifiedEditor& aForm);
+
+	/**
+	 * @brief destructor.
+	 */
+    virtual ~CKoreanLunarTypeField();
+
+public: 
+	/**
+	 * @brief Pre Layout.
+	 */
+    void PreLayoutDynInitL();
+	/**
+	 * @brief sets data to form
+	 */
+    void SetDataToFormL();
+	/**
+	 * @brief reads data to form
+	 * @param aContinueOnError
+	 */
+    void ReadDataFromFormL( TBool aContinueOnError );
+	/**
+	 * @brief prepares for focus transition
+	 * @param aFocusedId
+	 */
+    void PrepareForFocusTransitionL( TInt aFocusedId );
+	/**
+	 * @brief lunar calendar type
+	 */
+    TLunarCalendarType Type();
+	/**
+	 * @brief handles control state change
+	 * @param aControlId
+	 */
+    void HandleControlStateChangeL( TInt aControlId );
+
+private:
+    CKoreanLunarTypeField(CCalenUnifiedEditor& aForm);
+
+    void ConstructL();
+private:
+    // Reference to form 
+	CCalenUnifiedEditor& iUniEditor;
+
+    // Synchronization popup query values
+    CDesCArrayFlat*            iTypeArrayText;
+    CAknQueryValueTextArray*   iTypeArray;
+    CAknQueryValueText*        iTypeTextValues;
+    };
+
+#endif // KOREANLUNARTYPEFIELD_H
+
+
+// End of File
--- a/calendarui/editors/inc/calenunifiededitor.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/inc/calenunifiededitor.h	Tue Sep 14 21:17:03 2010 +0300
@@ -823,6 +823,11 @@
         
         CAsyncCallBack* iAsyncCallback; 
         
+        /**
+    	* True if FeatureManager is initialized.
+    	*/
+    	TBool iFeatMgrInitialized;
+        
     };
 
 /**
--- a/calendarui/editors/inc/calenunifiededitorcontrol.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/inc/calenunifiededitorcontrol.h	Tue Sep 14 21:17:03 2010 +0300
@@ -24,6 +24,7 @@
 
 // user includes
 #include "CalenEditorDataHandler.h"
+#include "CalenEntryUtil.h"
 
 // forward declaration
 class CCalenUnifiedEditor;
@@ -35,6 +36,8 @@
 class CCalenDbField;
 class CCalenDescription;
 class MCalenServices;
+class CKoreanLunarDateEditor;
+class CKoreanLunarTypeField;
 
 /**
  * CCalenUnifiedEditorControl class declaration
@@ -169,6 +172,12 @@
          * @param aNewEventType Holds the new event type selected in editor
          */
         void OnEventTypeChangedL( CCalEntry::TType aNewEventType );
+
+        /**
+         * @brief Handles lunar event type changed 
+         * @param aNewEventType Holds the new event type selected in editor
+         */
+        void OnLunarTypeChangedL( TLunarCalendarType aNewEventType );
     
         /**
          * @brief Reads editor data mainly for collapsed editor
@@ -338,7 +347,17 @@
          *        in updating the EndTime of editor on StartTime change.
          */
         void UpdateMeetingDurationL();
-        
+
+        /**
+         * @brief Setups Lunar Fields
+         */
+        void SetupLunarFields();
+
+        /**
+         * @brief Updates Lunar Date Fields
+         */
+        void UpdateLunarDateFields();
+
     private:
  
         /**
@@ -395,6 +414,29 @@
          */
         TTimeIntervalMinutes  iMeetingInterval;
         
+        /**
+         * @var iKoreanLunarDateEditor
+         * @brief Korean lunar data editor
+         */
+        CKoreanLunarDateEditor* iKoreanLunarDateEditor;
+        
+        /**
+         * @var iKoreanLunarTypeField
+         * @brief Korean lunar type field
+         */
+        CKoreanLunarTypeField* iKoreanLunarTypeField;
+        
+        /**
+         * @var iPrevLunarType
+         * @brief previous lunar type
+         */
+        TLunarCalendarType iPrevLunarType;
+        
+        /**
+    	* True if FeatureManager is initialized.
+    	*/
+    	TBool iFeatMgrInitialized;
+        
     };
 
 #endif // _CALENUNIFIEDEDITORCONTROL_H
\ No newline at end of file
--- a/calendarui/editors/src/CalenDefaultEditors.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/src/CalenDefaultEditors.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -21,6 +21,7 @@
 #include "calennotedatautil.h"
 #include "calenentryutil.h"
 #include "calenunifiededitor.h"
+#include "calenentryutil.h"
 
 // system includes
 #include <CalenDefaultEditorsData.rsg>
@@ -41,6 +42,8 @@
 #include <calencontext.h>
 #include <caleninstanceid.h>
 #include "CleanupResetAndDestroy.h"
+#include <bldvariant.hrh> // for feature definitions
+#include <featmgr.h>
 
 // debug
 #include "calendarui_debug.h"
@@ -95,6 +98,14 @@
     TRACE_ENTRY_POINT;
 
     iResourceLoader.Close();
+    // Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+    
+
 
     TRACE_EXIT_POINT;
     }
@@ -127,6 +138,13 @@
     BaflUtils::NearestLanguageFile(  CCoeEnv::Static()->FsSession(), resource );
     TInt err = iResourceLoader.Open( resource );
     __ASSERT_ALWAYS( err == KErrNone, Panic( EPanicCalenDefaultEditorsResourceLoading ) );
+    
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+     
+
 
     TRACE_EXIT_POINT;
     }
@@ -282,8 +300,19 @@
     // For repeat type, EThisAndAll start Date/Time is first instance Date/Time.
     TAgnEntryUiInParams inParamsCopy( aInParams );
     if( aRepeatType  == CalCommon::EThisAndAll )
-        {
-        inParamsCopy.iInstanceDate.SetTimeLocalL( aEntry.StartTimeL().TimeLocalL() ); 
+        { 
+        // remove for lunar entries
+        if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+            {
+             if ( !(aEntry.EntryTypeL() == CCalEntry::EAnniv && aEntry.UserInt32L() != ESolar) )
+                {
+                inParamsCopy.iInstanceDate.SetTimeLocalL( aEntry.StartTimeL().TimeLocalL() ); 
+                }
+            }
+        else // normal case
+            {
+            inParamsCopy.iInstanceDate.SetTimeLocalL( aEntry.StartTimeL().TimeLocalL() );
+            }
         }
 
     switch ( aEntry.EntryTypeL() )
--- a/calendarui/editors/src/CalenEditorDataHandler.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/src/CalenEditorDataHandler.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -30,6 +30,7 @@
 #include <calencontext.h>
 #include <caleninstanceid.h>            // TCalenInstanceId
 #include <calenservices.h>
+#include <featmgr.h>
 
 // User includes
 #include "CalenEditorDataHandler.h"
@@ -42,6 +43,7 @@
 #include "calenattachmentmodel.h"
 #include "calenunifiededitor.h"
 #include "calendarui_debug.h"
+#include "koreanlunardateutil.h"
 
 // Constants
 #define KNoOfDaysInWeek  7
@@ -146,7 +148,11 @@
         iInstanceId = iServices.Context().InstanceId();
         }
     
-
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+    
     TRACE_EXIT_POINT;
     }
 
@@ -188,7 +194,15 @@
 
     delete iOriginal;
     delete iEdited;
-
+    
+	
+	// Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+        
     TRACE_EXIT_POINT;
     }
 
@@ -331,7 +345,8 @@
              IsCalendarEditedL()     ||
              IsAttachmentExists()    ||
              IsEventTypeEdited()     ||
-             AllDayFieldEdited() );
+             AllDayFieldEdited()     ||
+             LunarFieldEdited() );
     }
 
 // ---------------------------------------------------------------------------
@@ -413,196 +428,218 @@
     // Repeat rule has to be modified in both cases
     if ( isNew || IsStartDateTimeEdited() || IsRepeatRuleEdited() )
         {
-
-        if ( aRepeatTarget == CalCommon::EThisOnly)
-            {
+        if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) && 
+             Edited().EntryType() == CCalEntry::EAnniv &&
+             ( Edited().CalendarType() == ELunar || Edited().CalendarType() == ELunarLeap) )
+            { /* Lunar entries need special repeating dates */
+            CKoreanLunarDateUtil* dateUtil = CKoreanLunarDateUtil::NewLC(&iServices);
+            RArray<TCalTime> repeatDateList;
+            CleanupClosePushL( repeatDateList );
+            
+            /* Clear previous repeat rules */
             iEntry.ClearRepeatingPropertiesL();
-            }
-        else if ( Edited().IsRepeating() )
-            {
-            // If we're an RDate (with repeat type ERepeatOther), don't try to set an RRule,
-            // but don't clear the repeat properties either.
-            if( Edited().RepeatType() != ERepeatOther )
+            TRAPD( err, dateUtil->GetLunarYearlyRepeatsL( repeatDateList, Edited().StartDateTime().DateTime(), UseFloatingTimeL() ) );
+            
+            if( err == KErrNone )
                 {
-                TCalRRule rrule;
-
-                CalculateRepeatRuleL( Edited().StartDateTime(),
-                                      Edited().RepeatType(),
-                                      Edited().RepeatUntilDateTime(),
-                                      rrule );
-
-                iEntry.SetRRuleL( rrule );
-                
-                // As there should not be any rdates, remove any that are
-                // still present
-                RArray<TCalTime> emptyList;
-                CleanupClosePushL( emptyList );
-                iEntry.SetRDatesL( emptyList );
-                CleanupStack::PopAndDestroy(); // emptyList
+                iEntry.SetRDatesL( repeatDateList );
                 }
-            else
+            
+            /* Pop and destroy repeatDateList and dateUtil */
+            CleanupStack::PopAndDestroy(2);
+            }
+        else
+            {
+            if ( aRepeatTarget == CalCommon::EThisOnly)
+                {
+                iEntry.ClearRepeatingPropertiesL();
+                }
+            else if ( Edited().IsRepeating() )
                 {
-                // The repeat type is ERepeatOther, therefore as 
-                // it is impossible to create an entry of type
-                // ERepeat other using the editor either the repeat until
-                // date or the start date must have been changed
-
-                // The start date/time has changed, in order for the
-                // series to maintain its pattern, any rDates and if
-                // present rRule are moved by the same offset
-                // The repeat type is ERepeatOther, so check if we have any rdates
-                RArray<TCalTime> rDateList;
-                CleanupClosePushL( rDateList );
-                iEntry.GetRDatesL( rDateList );
-                TInt count = rDateList.Count();
-
-                if ( count == 0 )
+                // If we're an RDate (with repeat type ERepeatOther), don't try to set an RRule,
+                // but don't clear the repeat properties either.
+                if( Edited().RepeatType() != ERepeatOther )
                     {
-                    // There are no rdates so the new until and start date can be applied
-                    // directly.
                     TCalRRule rrule;
-
+                    
                     CalculateRepeatRuleL( Edited().StartDateTime(),
-                                      Edited().RepeatType(),
-                                      Edited().RepeatUntilDateTime(),
-                                      rrule );
-
+                    Edited().RepeatType(),
+                    Edited().RepeatUntilDateTime(),
+                    rrule );
+                    
                     iEntry.SetRRuleL( rrule );
+                    
+                    // As there should not be any rdates, remove any that are
+                    // still present
+                    RArray<TCalTime> emptyList;
+                    CleanupClosePushL( emptyList );
+                    iEntry.SetRDatesL( emptyList );
+                    CleanupStack::PopAndDestroy(); // emptyList
                     }
                 else
                     {
-                    // There are rDates which need to be checked.
-                    if ( IsStartDateTimeEdited() )
-                        {
-                        // Need to shift any rdates
-                        TTime editedStart = iEdited->StartDateTime();
-                        TTime origStart = iOriginal->StartDateTime();
-                        TTimeIntervalMicroSeconds offSet = editedStart.MicroSecondsFrom( origStart );
-                        for ( TInt index = 0; index < count; index++ )
-                            {
-                            TCalTime& rDateTime = rDateList[ index ];
-                            TTime shiftedTime = rDateTime.TimeUtcL();
-                            TDateTime before = shiftedTime.DateTime();
-                            shiftedTime += offSet;
-                            TDateTime after = shiftedTime.DateTime();
-                            rDateTime.SetTimeUtcL( shiftedTime ); 
-                            }
-                        }
-
-                    //  Check and fix the rDates and rRules match the 
-                    //  repeat until date and time.
-                    TTime untilTime = Edited().RepeatUntilDateTime();
+                    // The repeat type is ERepeatOther, therefore as 
+                    // it is impossible to create an entry of type
+                    // ERepeat other using the editor either the repeat until
+                    // date or the start date must have been changed
                     
-                    // Remove any rdates that are after the the repeat until date
+                    // The start date/time has changed, in order for the
+                    // series to maintain its pattern, any rDates and if
+                    // present rRule are moved by the same offset
+                    // The repeat type is ERepeatOther, so check if we have any rdates
+                    RArray<TCalTime> rDateList;
+                    CleanupClosePushL( rDateList );
+                    iEntry.GetRDatesL( rDateList );
                     TInt count = rDateList.Count();
-                    if ( count > 0 )
+                    
+                    if ( count == 0 )
                         {
-                        TInt index = count - 1;
-                        do 
+                        // There are no rdates so the new until and start date can be applied
+                        // directly.
+                        TCalRRule rrule;
+                        
+                        CalculateRepeatRuleL( Edited().StartDateTime(),
+                        Edited().RepeatType(),
+                        Edited().RepeatUntilDateTime(),
+                        rrule );
+                        
+                        iEntry.SetRRuleL( rrule );
+                        }
+                    else
+                        {
+                        // There are rDates which need to be checked.
+                        if ( IsStartDateTimeEdited() )
                             {
-                            TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ index ].TimeLocalL() );
-                            TDateTime before = lastRDate.DateTime();
-                            if ( lastRDate > untilTime )
+                            // Need to shift any rdates
+                            TTime editedStart = iEdited->StartDateTime();
+                            TTime origStart = iOriginal->StartDateTime();
+                            TTimeIntervalMicroSeconds offSet = editedStart.MicroSecondsFrom( origStart );
+                            for ( TInt index = 0; index < count; index++ )
                                 {
-                                rDateList.Remove( index-- );
+                                TCalTime& rDateTime = rDateList[ index ];
+                                TTime shiftedTime = rDateTime.TimeUtcL();
+                                TDateTime before = shiftedTime.DateTime();
+                                shiftedTime += offSet;
+                                TDateTime after = shiftedTime.DateTime();
+                                rDateTime.SetTimeUtcL( shiftedTime ); 
                                 }
-                            else
-                                {
-                                index = KErrNotFound;
-                                }
-                            } while ( index != KErrNotFound );
-                        }
-                    
-                    // Need to check if the end date of the
-                    // rrule needs adjusting if it exists.
-                    TCalRRule rRule;
-                    if ( iEntry.GetRRuleL( rRule ) )
-                        {
-                        count = rDateList.Count();
+                            }
+                        
+                        //  Check and fix the rDates and rRules match the 
+                        //  repeat until date and time.
+                        TTime untilTime = Edited().RepeatUntilDateTime();
+                        
+                        // Remove any rdates that are after the the repeat until date
+                        TInt count = rDateList.Count();
                         if ( count > 0 )
                             {
-                            // There still exists some rdates, so only need to trim 
-                            // the rrule if it exists
-                            TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ count - 1 ].TimeLocalL() );
-                            const TTime& origUntilDate = Original().RepeatUntilDateTime();
-                            TTime startDT = rRule.DtStart().TimeLocalL();
-                            
-                            if ( lastRDate <= origUntilDate && startDT > lastRDate )
-                                { 
-                                if ( startDT < untilTime)
+                            TInt index = count - 1;
+                            do 
+                                {
+                                TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ index ].TimeLocalL() );
+                                TDateTime before = lastRDate.DateTime();
+                                if ( lastRDate > untilTime )
+                                    {
+                                    rDateList.Remove( index-- );
+                                    }
+                                else
                                     {
-                                    if( origUntilDate != untilTime)
-                                    	{
-										ApplyUntilDateToRRuleL( rRule, untilTime);
-                                    	iEntry.SetRRuleL( rRule );
-                                    	}
+                                    index = KErrNotFound;
                                     }
-                                 else
-                                    {
-                                    // The repeat start is after the until date
-                                    // so remove any repeat information.
-                                    iEntry.ClearRepeatingPropertiesL();
-
-                                    // If the entry date has been moved past the until
-                                    // date, need to swap the an rDate for the entry.
-                                    TTime startTime = iEntry.StartTimeL().TimeLocalL();
-
-                                    if ( startTime > untilTime )
+                                } while ( index != KErrNotFound );
+                            }
+                        
+                        // Need to check if the end date of the
+                        // rrule needs adjusting if it exists.
+                        TCalRRule rRule;
+                        if ( iEntry.GetRRuleL( rRule ) )
+                            {
+                            count = rDateList.Count();
+                            if ( count > 0 )
+                                {
+                                // There still exists some rdates, so only need to trim 
+                                // the rrule if it exists
+                                TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ count - 1 ].TimeLocalL() );
+                                const TTime& origUntilDate = Original().RepeatUntilDateTime();
+                                TTime startDT = rRule.DtStart().TimeLocalL();
+                                
+                                if ( lastRDate <= origUntilDate && startDT > lastRDate )
+                                    { 
+                                    if ( startDT < untilTime)
+                                        {
+                                        if( origUntilDate != untilTime)
+                                            {
+                                            ApplyUntilDateToRRuleL( rRule, untilTime);
+                                            iEntry.SetRRuleL( rRule );
+                                            }
+                                        }
+                                    else
                                         {
-                                        // Find the duration of the entry
-                                        TTime endTime = iEntry.EndTimeL().TimeLocalL();
-                                        TTimeIntervalMinutes duration;
-                                        //startTime.MinutesFrom( endTime, duration );// for bug: CMCA-745CZ4
-                                        endTime.MinutesFrom( startTime, duration );
+                                        // The repeat start is after the until date
+                                        // so remove any repeat information.
+                                        iEntry.ClearRepeatingPropertiesL();
                                         
-                                        // Choose the first rDate as the new start time
-                                        TCalTime newStartTime = rDateList[ 0 ];
-                                        endTime = newStartTime.TimeLocalL() + duration;
-
-                                        // FIXME.
-                                        // If there is only one rDate left, the agenda model
-                                        // will crash if it is deleted.
-                                        if ( count != 0 )
+                                        // If the entry date has been moved past the until
+                                        // date, need to swap the an rDate for the entry.
+                                        TTime startTime = iEntry.StartTimeL().TimeLocalL();
+                                        
+                                        if ( startTime > untilTime )
                                             {
-                                            rDateList.Remove( 0 );
-                                            }
-
-                                        TCalTime newEndTime;
-                                        if ( UseFloatingTimeL() )
-                                            {
-                                            newEndTime.SetTimeLocalFloatingL( endTime );
-                                            }
-                                        else
-                                            {
-                                            newEndTime.SetTimeLocalL( endTime );
-                                            }
-
-                                        iEntry.SetStartAndEndTimeL( newStartTime, newEndTime );
-                                        }    
+                                            // Find the duration of the entry
+                                            TTime endTime = iEntry.EndTimeL().TimeLocalL();
+                                            TTimeIntervalMinutes duration;
+                                            //startTime.MinutesFrom( endTime, duration );// for bug: CMCA-745CZ4
+                                            endTime.MinutesFrom( startTime, duration );
+                                            
+                                            // Choose the first rDate as the new start time
+                                            TCalTime newStartTime = rDateList[ 0 ];
+                                            endTime = newStartTime.TimeLocalL() + duration;
+                                            
+                                            // FIXME.
+                                            // If there is only one rDate left, the agenda model
+                                            // will crash if it is deleted.
+                                            if ( count != 0 )
+                                                {
+                                                rDateList.Remove( 0 );
+                                                }
+                                            
+                                            TCalTime newEndTime;
+                                            if ( UseFloatingTimeL() )
+                                                {
+                                                newEndTime.SetTimeLocalFloatingL( endTime );
+                                                }
+                                            else
+                                                {
+                                                newEndTime.SetTimeLocalL( endTime );
+                                                }
+                                            
+                                            iEntry.SetStartAndEndTimeL( newStartTime, newEndTime );
+                                            }    
+                                        }
                                     }
                                 }
                             }
+                        
+                        iEntry.SetRDatesL( rDateList );
                         }
-
-                    iEntry.SetRDatesL( rDateList );
+                    
+                    CleanupStack::PopAndDestroy(); // rDateList
                     }
-
-                CleanupStack::PopAndDestroy(); // rDateList
                 }
-            }
-        else
-            {
-            iEntry.ClearRepeatingPropertiesL();
-
-            // FIXME  As the entry is supposedly not repeating
-            // any rDates should be removed. Unforunately this
-            // is not possible at the moment because removing the 
-            // rdates will cause the agenda model to panic
-            //
-            // RArray<TCalTime> emptyList;
-            // CleanupClosePushL( emptyList );
-            // iEntry.SetRDatesL( emptyList );
-            // CleanupStack::PopAndDestroy(); // emptyList
+            else
+                {
+                iEntry.ClearRepeatingPropertiesL();
+                
+                // FIXME  As the entry is supposedly not repeating
+                // any rDates should be removed. Unforunately this
+                // is not possible at the moment because removing the 
+                // rdates will cause the agenda model to panic
+                //
+                // RArray<TCalTime> emptyList;
+                // CleanupClosePushL( emptyList );
+                // iEntry.SetRDatesL( emptyList );
+                // CleanupStack::PopAndDestroy(); // emptyList
+                }
             }
         }
 
@@ -635,7 +672,10 @@
 
             // If edit alarm of repeating entry, we have to nudge start
             // time to instance date
-            if ( isRepeating &&  aRepeatTarget == CalCommon::EThisAndAll )
+
+            if ( isRepeating &&  aRepeatTarget == CalCommon::EThisAndAll 
+			    || Edited().EntryType() == CCalEntry::EAnniv && Edited().CalendarType() != ESolar )
+				  // this is lunar anniv
                 {
                 // nudge to instance date;
                 TTime instanceDate = iInstanceDateTime.TimeLocalL();
@@ -692,6 +732,11 @@
         iEntry.SetPriorityL( priority );
         }
 
+    if (FeatureManager::FeatureSupported( KFeatureIdKorean ))
+    	{
+    	iEntry.SetUserInt32L( (TUint32)Edited().CalendarType() );	
+    	}
+    
     if ( isNew )
         {
         CCalEntry::TReplicationStatus status = CCalEntry::EOpen;
@@ -712,14 +757,15 @@
             }
         iEntry.SetReplicationStatusL( status );
         }
-    
+
     /**
      * S60 settings for new entries
      */
     if ( IsCreatingNew() )
         {
-        if ( Edited().EntryType() == CCalEntry::EAnniv )
-            {
+
+        if ( Edited().EntryType() == CCalEntry::EAnniv && Edited().CalendarType() == ESolar)
+            { /* Lunar entries have different repeating */
             TCalRRule rrule( TCalRRule::EYearly );
             rrule.SetDtStart( iEntry.StartTimeL() );
             rrule.SetInterval( 1 );
@@ -1445,6 +1491,17 @@
     TRACE_ENTRY_POINT;
 
     TError error = EFormErrNone;
+    
+	if (FeatureManager::FeatureSupported( KFeatureIdKorean )) 
+		{
+    	if( Edited().CalendarType() == ELunar ||
+    	    Edited().CalendarType() == ELunarLeap )
+    	    { /* Lunar entries have alarm as offset
+    	         and can't thus be erroneous */
+    	    return error;
+    	    }
+		}
+	
     // If alarm not active, no check
     if ( Edited().IsAlarmActivated() )
         {
@@ -2158,6 +2215,24 @@
     return fieldModified;
     }
 
+TBool CCalenEditorDataHandler::LunarFieldEdited()
+    {
+    TRACE_ENTRY_POINT;
+	TBool fieldModified = EFalse;
+	
+    if (FeatureManager::FeatureSupported( KFeatureIdKorean )) 
+    	{
+    	if( iOriginal->CalendarType() != iEdited->CalendarType() )
+    	    {
+    	    fieldModified = ETrue;
+    	    }
+    	}
+    	
+    TRACE_EXIT_POINT;
+    return fieldModified;
+    }
+
+
 // -----------------------------------------------------------------------------
 // CCalenEditorDataHandler::SetDefaultAlarmDateTimeL
 // Sets the alarm to the default value. This function is called after the user
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/src/KoreanLunarDateEditor.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,261 @@
+/*
+* 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: 
+*
+*/
+
+#include <barsread.h>
+#include <aknextendedinputcapabilities.h>
+#include "KoreanLunarDateEditor.h"
+#include "KoreanLunarDateUtil.h"
+
+// debug
+#include "calendarui_debug.h"
+
+_LIT( KDelimiter, "/" );
+_LIT( KLunarIndicator, "\xC74C\xB825" );
+_LIT( KLeapIndicator, "\xC724\xB2EC" );
+
+const TInt KNumFields = 4; /* [Indicators][month]/[day] */
+const TInt KMinLeapMonth = 2;
+const TInt KMinMonth = 1;
+const TInt KMaxLeapMonth = 11;
+const TInt KMaxMonth = 12;
+const TInt KMinDay = 1;
+const TInt KMaxDay = 31;
+
+
+/**
+ * Public method for constructing a CKoreanLunarDateEditor object.
+ */
+CKoreanLunarDateEditor* CKoreanLunarDateEditor::NewL(MCalenServices* aServices)
+    {
+    TRACE_ENTRY_POINT;
+    CKoreanLunarDateEditor* editor=new(ELeave)CKoreanLunarDateEditor(aServices);
+    CleanupStack::PushL(editor);
+    editor->ConstructL(0); // flags are not used
+    CleanupStack::Pop(editor);
+    
+    TRACE_EXIT_POINT;
+    return editor;
+    }
+
+
+CKoreanLunarDateEditor::CKoreanLunarDateEditor(MCalenServices* aServices):iServices(aServices)
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	}
+
+
+void CKoreanLunarDateEditor::ConstructL( const TInt /* aFlags */ )
+	{
+    TRACE_ENTRY_POINT;
+    HBufC* charField;
+    iConverter = CKoreanCalConv::NewL();
+    iDateUtil = CKoreanLunarDateUtil::NewL(iServices);
+    iLeap = EFalse;
+// todo add editable field to first place to go around avkon crash if avkon can not be fixed
+	CreateFieldArrayL( KNumFields );
+
+    iIndicatorField = HBufC::NewL(2);
+    iIndicatorField->Des().Append( KLunarIndicator );
+    AddField( CEikMfneSeparator::NewL( iIndicatorField ) );
+
+
+    iMonthField = CEikMfneNumber::NewL( *Font(),
+                                        KMinMonth,
+                                        KMaxMonth,
+                                        KMinMonth,
+                                        (CEikMfneNumber::EFillWithLeadingZeros|CEikMfneNumber::EPreserveOldWidthBeforeEditing) );
+    AddField( iMonthField );
+    iMonthField->SetValue( KMinMonth, *Font() );
+    charField = HBufC::NewLC(1);
+    charField->Des().Append( KDelimiter );
+    AddField( CEikMfneSeparator::NewL( charField ) );
+    CleanupStack::Pop(); // charField
+
+    iDayField = CEikMfneNumber::NewL( *Font(),
+                                      KMinDay,
+                                      KMaxDay,
+                                      KMinDay,
+                                      (CEikMfneNumber::EFillWithLeadingZeros|CEikMfneNumber::EPreserveOldWidthBeforeEditing) );
+    AddField( iDayField );
+    iDayField->SetValue( KMinDay, *Font() );
+	MObjectProvider* mop = InputCapabilities().ObjectProvider();
+	if( mop )
+	    {
+	    CAknExtendedInputCapabilities* extendedInputCapabilities = mop->MopGetObject( extendedInputCapabilities );
+	    if( extendedInputCapabilities ) 
+	        {
+	        extendedInputCapabilities->SetCapabilities( CAknExtendedInputCapabilities::ESupportsOnlyASCIIDigits );
+	        }
+	    }
+	TRACE_EXIT_POINT;
+	}
+
+/**
+ * Method for Setting the date.
+ * 
+ */
+void CKoreanLunarDateEditor::SetDate( const TTime& aDate, TBool newEntry )
+	{
+    TRACE_ENTRY_POINT;
+    iDate = aDate.DateTime();
+    TKoreanDate lunarDate;
+    TInt err = KErrNone;
+
+    if( !newEntry )
+        {
+        TRAP( err, iConverter->DateTimeToKoreanL( iDate, lunarDate ) );
+        }
+
+    if( newEntry || err != KErrNone )
+        { /* Use always initial values in case of new entry or
+             failed conversion */
+        if( iLeap )
+            {
+            iMonthField->SetValue( KMinLeapMonth, *Font() );
+            iDayField->SetValue( KMinDay, *Font() );
+            }
+        else
+            {
+            iMonthField->SetValue( KMinMonth, *Font() );
+            iDayField->SetValue( KMinDay, *Font() );
+            }
+        }
+    else
+        {
+        iMonthField->SetValue( lunarDate.iMonth, *Font() );
+        iDayField->SetValue( lunarDate.iDay, *Font() );
+        }
+    //DrawNow();
+    TBool error = EFalse;
+    TBool dataAltered = ETrue;
+    // needs to call this to make redraw work correctly
+    HandleInteraction(EFalse, 2, 0, CEikMfneField::ECursor, dataAltered, error);
+    TRACE_EXIT_POINT;
+	}
+
+/**
+ * Method for reading the editor value.
+ * 
+ */
+TTime CKoreanLunarDateEditor::Date()
+	{
+    TRACE_ENTRY_POINT;
+    TRAP_IGNORE( iDate = iDateUtil->GetNearestGregorianDateL( iMonthField->Value(), iDayField->Value(), iLeap, iDate ) );
+	
+    TRACE_EXIT_POINT;
+    return TTime(iDate);
+	}
+
+/**
+ * Method for setting the editor to leap mode.
+ * Gets one parameter:
+ * const TBool aLeap - ETrue if leap mode is to be enabled, EFalse if disabled.
+ * 
+ */
+void CKoreanLunarDateEditor::SetLeap( const TBool aLeap )
+	{
+    TRACE_ENTRY_POINT;
+    if( aLeap != iLeap )
+        {
+        iLeap = aLeap;
+        if( iLeap )
+            {
+            iIndicatorField->Des().Replace( 0, 2, KLeapIndicator );
+            iMonthField->SetValue( KMinLeapMonth, *Font() );
+            iDayField->SetValue( KMinDay, *Font() );
+            iMonthField->SetMinimumAndMaximum( KMinLeapMonth,
+                                               KMaxLeapMonth,
+                                               *Font() );
+            }
+        else
+            {
+            iIndicatorField->Des().Replace( 0, 2, KLunarIndicator );
+            iMonthField->SetValue( KMinMonth, *Font() );
+            iDayField->SetValue( KMinDay, *Font() );
+            iMonthField->SetMinimumAndMaximum( KMinMonth,
+                                               KMaxMonth,
+                                               *Font() );
+            }
+        DrawNow();
+        }
+    TRACE_EXIT_POINT;
+	}
+
+/**
+ * Method for reading the leap mode status.
+ * 
+ */
+TBool CKoreanLunarDateEditor::Leap() const
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    
+    return iLeap;
+    }
+
+/**
+ * Method for constructing the control from resources.
+ * Gets one parameter:
+ * TResourceReader& aResourceReader - Reference to a resource reader associated to a
+ * Korean lunar date editor control resource.
+ * 
+ */
+void CKoreanLunarDateEditor::ConstructFromResourceL(TResourceReader& aResourceReader)
+	{
+    TRACE_ENTRY_POINT;
+    TUint32 flags = aResourceReader.ReadUint8();
+    ConstructL( flags );
+    TRACE_EXIT_POINT;
+	}
+
+	
+void CKoreanLunarDateEditor::PrepareForFocusLossL()
+	{
+    TRACE_ENTRY_POINT;
+	CEikMfne::PrepareForFocusLossL();
+    CKoreanLunarDateUtil* dateUtil = CKoreanLunarDateUtil::NewLC(iServices);
+    TTime nowTime;
+    nowTime.HomeTime();
+
+    TRAP_IGNORE( iDate = dateUtil->GetNearestGregorianDateL( iMonthField->Value(), iDayField->Value(), iLeap, nowTime.DateTime() ) );
+    /* Pop and destroy dateUtil */
+    CleanupStack::PopAndDestroy();
+    TRACE_EXIT_POINT;
+	}
+
+void CKoreanLunarDateEditor::HandleControlStateChangeL( TInt aControlId )
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	}
+
+void* CKoreanLunarDateEditor::ExtensionInterface( TUid /*aInterface*/ )
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+
+    return NULL;
+    }
+
+void CKoreanLunarDateEditor::CEikMfne_Reserved()
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	}
+	
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/src/KoreanLunarDateUtil.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,228 @@
+/*
+* 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: 
+*
+*/
+
+
+#include "KoreanLunarDateUtil.h"
+// debug
+#include "calendarui_debug.h"
+
+const TInt KMaxLunarYear = 60;
+
+/**
+ * Public methods for constructing a CKoreanLunarDateUtil object.
+ */
+CKoreanLunarDateUtil* CKoreanLunarDateUtil::NewL(MCalenServices* aServices)
+    {
+    TRACE_ENTRY_POINT;
+    CKoreanLunarDateUtil* self = CKoreanLunarDateUtil::NewLC(aServices);
+    CleanupStack::Pop( self );
+    
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+CKoreanLunarDateUtil* CKoreanLunarDateUtil::NewLC(MCalenServices* aServices)
+    {
+    TRACE_ENTRY_POINT;
+    CKoreanLunarDateUtil* self = new (ELeave) CKoreanLunarDateUtil(aServices);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+CKoreanLunarDateUtil::CKoreanLunarDateUtil(MCalenServices* aServices):iServices(aServices)
+	{
+    TRACE_ENTRY_POINT;
+	}
+
+
+void CKoreanLunarDateUtil::ConstructL()
+	{
+    TRACE_ENTRY_POINT;
+    iConverter = CKoreanCalConv::NewL();
+	}
+
+CKoreanLunarDateUtil::~CKoreanLunarDateUtil()
+    {
+    TRACE_ENTRY_POINT;
+    delete iConverter;
+    }
+
+/**
+ * Method for getting nearest gregorian date from
+ * lunar day and month and gregorian reference.
+ */
+TDateTime CKoreanLunarDateUtil::GetNearestGregorianDateL( const TInt aMonth,
+                                                          const TInt aDay,
+                                                          const TBool aLeap,
+                                                          const TDateTime& aReference ) const
+	{
+    TRACE_ENTRY_POINT;
+    TKoreanDate refLunarDate;
+    TKoreanDate lunarDate;
+    TDateTime resDateTime;
+    TInt err = KErrNone;
+
+    iConverter->DateTimeToKoreanL( aReference, refLunarDate );
+    /* Try to convert with the year and cycle we got with the reference */
+    lunarDate.iCycle = refLunarDate.iCycle;
+    lunarDate.iYear = refLunarDate.iYear;
+    lunarDate.iMonth = aMonth;
+    lunarDate.iDay = aDay;
+    lunarDate.iLeapMonth = aLeap;
+    TRAP( err, iConverter->KoreanToDateTimeL( lunarDate, resDateTime ) );
+    if( err == KErrArgument )
+        { /* Date is invalid for this year (day 30 on a month
+             that has only 29 days on selected year or a leap month
+             not in this year), try to find suitable */
+        TKoreanDate lowerLimit;
+        TKoreanDate upperLimit;
+        iConverter->DateRange( lowerLimit, upperLimit );
+        while( 1 )
+            { /* Search by increasing year */
+            if( lunarDate.iYear < KMaxLunarYear )
+               {
+                lunarDate.iYear++;
+                }
+            else
+                {
+                lunarDate.iYear = 1;
+                lunarDate.iCycle++;
+                }
+            if( (lunarDate.iCycle == upperLimit.iCycle &&
+                 lunarDate.iYear > upperLimit.iYear)  ||
+                lunarDate.iCycle > upperLimit.iCycle )
+                { /* Could not find, just break */
+                break;
+                }
+            TRAP( err, iConverter->KoreanToDateTimeL( lunarDate, resDateTime ) );
+            if( err == KErrNone )
+                { /* Found suitable */
+                break;
+                }
+            }
+        if( err != KErrNone )
+            { /* Suitable not found by increasing,
+                 reset values and search by decreasing year */
+            lunarDate.iCycle = refLunarDate.iCycle;
+            lunarDate.iYear = refLunarDate.iYear;
+            lunarDate.iMonth = aMonth;
+            lunarDate.iDay = aDay;
+            while( 1 )
+                { /* Search by decreasing year */
+                if( lunarDate.iYear > 1 )
+                   {
+                    lunarDate.iYear--;
+                    }
+                else
+                    {
+                    if( lunarDate.iCycle == 0 )
+                        { /* Run out of cycles, break with error */
+                        break;
+                        }
+                    lunarDate.iYear = KMaxLunarYear;
+                    lunarDate.iCycle--;
+                    }
+                if( (lunarDate.iCycle == lowerLimit.iCycle &&
+                     lunarDate.iYear < lowerLimit.iYear)  ||
+                    lunarDate.iCycle < lowerLimit.iCycle )
+                    { /* Could not find, just break */
+                    break;
+                    }
+                TRAP( err, iConverter->KoreanToDateTimeL( lunarDate, resDateTime ) );
+                if( err == KErrNone )
+                    { /* Found suitable */
+                    break;
+                    }
+                }
+            }
+        }
+    /* If still not found, leave with error */
+    User::LeaveIfError( err );
+    
+    TRACE_ENTRY_POINT;
+    /* Otherwise return the result */
+    return resDateTime;
+	}
+
+/**
+* Method for getting lunar yearly repeats in gregorian dates.
+*/
+void CKoreanLunarDateUtil::GetLunarYearlyRepeatsL( RArray<TCalTime>& aRDates,
+                                                   const TDateTime& aEntryDate,
+                                                   const TBool aFloating ) const
+    {
+    TInt err = KErrNone;
+    TCalTime repeatDate;
+    TDateTime resDateTime;
+    TDateTime lowerLimit;
+    TKoreanDate upperKoreanLimit;
+    TKoreanDate lunarStartDate;
+    
+    /* Get the upper limit for dates in Korean lunar format */
+    iConverter->DateRange( lunarStartDate, upperKoreanLimit );
+    
+    /* Get the entry date in Korean lunar format */
+    iConverter->DateTimeToKoreanL( aEntryDate, lunarStartDate );
+    
+    /* Get the lower limit for dates in Gregorian format */
+    iConverter->DateRange( lowerLimit, resDateTime );
+    
+    /* Get the first occurrence of the event after
+    the lower limit in Korean lunar format */
+    iConverter->DateTimeToKoreanL(  GetNearestGregorianDateL( lunarStartDate.iMonth,
+                                  lunarStartDate.iDay,
+                                  lunarStartDate.iLeapMonth,
+                                  lowerLimit ),
+                                  lunarStartDate );
+    
+    while( 1 )
+        {
+        TRAP( err, iConverter->KoreanToDateTimeL( lunarStartDate, resDateTime ) );
+        if( err == KErrNone )
+            { /* Date exists in current year */
+            if( aFloating )
+                {
+                repeatDate.SetTimeLocalFloatingL( resDateTime );
+                }
+            else
+                {
+                repeatDate.SetTimeLocalL( resDateTime );
+                }
+            aRDates.AppendL( repeatDate );
+            }
+        /* Increase to next lunar year */
+        if( lunarStartDate.iYear < KMaxLunarYear )
+            {
+            lunarStartDate.iYear++;
+            }
+        else
+            {
+            lunarStartDate.iYear = 1;
+            lunarStartDate.iCycle++;
+            }
+        if( (lunarStartDate.iCycle == upperKoreanLimit.iCycle &&
+                lunarStartDate.iYear > upperKoreanLimit.iYear)  ||
+                lunarStartDate.iCycle > upperKoreanLimit.iCycle )
+            { /* Reached the limit, break */
+            break;
+            }
+        }
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/editors/src/KoreanLunarTypeField.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,151 @@
+/*
+* 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: 
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+#include "KoreanLunarTypeField.h"
+
+#include "CalenDefaultEditors.hrh"
+
+#include <CalenDefaultEditorsData.rsg>
+
+#include <AknPopupField.h>
+#include <AknQueryValueText.h>
+#include <badesca.h>
+#include <calentry.h>
+#include <eikcapc.h> 
+
+
+// CONSTRUCTION AND DESTRUCTION METHODS
+CKoreanLunarTypeField* CKoreanLunarTypeField::NewL(CCalenUnifiedEditor& aForm)
+    {
+    TRACE_ENTRY_POINT;
+    
+    CKoreanLunarTypeField* self = 
+        new( ELeave ) CKoreanLunarTypeField(aForm);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+CKoreanLunarTypeField::CKoreanLunarTypeField(CCalenUnifiedEditor& aForm)
+    : iUniEditor(aForm)
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+void CKoreanLunarTypeField::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+    
+    iTypeArrayText = iUniEditor.ControlEnv()->ReadDesCArrayResourceL( R_KOREAN_LUNAR_TYPE_POPUP_ITEMS );
+
+    // create textarray
+    iTypeArray = CAknQueryValueTextArray::NewL();
+    iTypeArray->SetArray(*iTypeArrayText);
+
+    iTypeTextValues = CAknQueryValueText::NewL();
+    iTypeTextValues->SetArrayL(iTypeArray);
+    
+    TRACE_EXIT_POINT;
+    }
+
+CKoreanLunarTypeField::~CKoreanLunarTypeField()
+    {
+    TRACE_ENTRY_POINT;
+    
+    delete iTypeArrayText;
+    delete iTypeArray;
+    delete iTypeTextValues;
+    
+    TRACE_EXIT_POINT;
+    }
+
+void CKoreanLunarTypeField::PreLayoutDynInitL()
+    {
+    TRACE_ENTRY_POINT;
+    SetDataToFormL();
+    CAknPopupField* pops =
+        static_cast<CAknPopupField*>( iUniEditor.Control(EKoreanLunarTypeSelectSolarLunarLeap) );
+    pops->SetQueryValueL(iTypeTextValues);
+    
+    TRACE_EXIT_POINT;
+    }
+
+void CKoreanLunarTypeField::SetDataToFormL()
+    {
+    TRACE_ENTRY_POINT;
+   //TInt pos = (TInt)Type();
+     TInt pos = iUniEditor.Edited().CalendarType();
+    iTypeTextValues->SetCurrentValueIndex( pos );
+    
+    TRACE_EXIT_POINT;
+    }
+
+void CKoreanLunarTypeField::ReadDataFromFormL( TBool /*aContinueOnError*/ )
+    {
+    TRACE_ENTRY_POINT;
+    
+    TInt pos = iTypeTextValues->CurrentValueIndex();
+    iUniEditor.Edited().SetCalendarTypeL( static_cast<TLunarCalendarType>( pos ) );
+    
+    TRACE_EXIT_POINT;
+    }
+
+void CKoreanLunarTypeField::PrepareForFocusTransitionL( TInt aFocusedId )
+    {
+	TRACE_ENTRY_POINT;
+	
+	switch( aFocusedId )
+	    {
+    	//case ECalenNoteType:
+		case ECalenEditorEventType:
+    		{
+	    	TBool continueOnError = EFalse;
+		    ReadDataFromFormL( continueOnError );
+		    break;
+            }
+    	default: 
+	    	break;
+	    }
+	TRACE_EXIT_POINT;
+    }
+
+TLunarCalendarType CKoreanLunarTypeField::Type()
+    {
+	TRACE_ENTRY_POINT;
+    TInt pos = iTypeTextValues->CurrentValueIndex();
+    
+	TRACE_EXIT_POINT;
+    return static_cast<TLunarCalendarType>( pos );
+    }
+
+
+void CKoreanLunarTypeField::HandleControlStateChangeL( TInt aControlId )
+	{
+    TRACE_ENTRY_POINT;
+    iUniEditor.EditorFields().OnLunarTypeChangedL( Type() );
+    TRACE_EXIT_POINT;
+	}
+	
+// End of File
+
--- a/calendarui/editors/src/calendbfield.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/src/calendbfield.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -264,8 +264,13 @@
             iUnifiedEditor.EditorDataHandler().SetCalendarFieldEditedL(IsCalendarEdited()
                                                             ,iPreviousColId,iCurrentColId);
             
+            
+            if(!iAsyncDBquery)
+                {
             TCallBack callback(DoAsyncShowChangeDBQueryL,this);
             iAsyncDBquery = new(ELeave) CAsyncCallBack(callback,CActive::EPriorityStandard);
+                }
+            
             iAsyncDBquery->CallBack();
             break;
             }
--- a/calendarui/editors/src/calenunifiededitor.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/src/calenunifiededitor.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -31,6 +31,8 @@
 #include "calenattachmentmodel.h"
 #include "CleanupResetAndDestroy.h"
 #include "CalendarPrivateCRKeys.h"
+#include "KoreanLunarDateEditor.h"
+#include <featmgr.h>
 #include "CalenUid.h"
 
 // system includes
@@ -174,6 +176,14 @@
     iAsyncCallback->Cancel();
     delete iAsyncCallback;
     
+    // Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+
+    
     TRACE_EXIT_POINT;
     }
 
@@ -302,6 +312,11 @@
     iIdle->Start( TCallBack( KeyCallBack, this) );
     iCoeEnv->AddFepObserverL( *this );
     
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+    
     TRACE_EXIT_POINT;
     }
 
@@ -1482,7 +1497,15 @@
 SEikControlInfo CCalenUnifiedEditor::CreateCustomControlL( TInt aControlType )
     {
     TRACE_ENTRY_POINT;
-
+    if( aControlType == ECalenCtLunarDateEditor  && FeatureManager::FeatureSupported( KFeatureIdKorean ) ) 
+            {
+            SEikControlInfo controlInfo;
+            controlInfo.iControl =  new (ELeave) CKoreanLunarDateEditor(iServices);
+            controlInfo.iControl->SetParent( this );
+            controlInfo.iFlags = 0;
+            controlInfo.iTrailerTextId = 0;
+            return controlInfo;
+            }
     __ASSERT_ALWAYS( aControlType==ECalenCtDescriptionField, User::Invariant() );
 
     TRACE_EXIT_POINT;
@@ -1504,6 +1527,11 @@
         TRACE_EXIT_POINT;
         return MEikDialogPageObserver::EEdwinDerived;
         }
+    if( aControlType == ECalenCtLunarDateEditor  && FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+        {
+        TRACE_EXIT_POINT;
+        return MEikDialogPageObserver::EMfneDerived;
+        }
 
     TRACE_EXIT_POINT;
     return MEikDialogPageObserver::EUnknownType;
@@ -2175,12 +2203,16 @@
         {
         if( entry->EntryTypeL() == CCalEntry::EAnniv )
             {
-            // Set yearly rule to Anniversary entry, to create Annaiversary instance yearly 
-            TCalRRule rrule( TCalRRule::EYearly );
-            TCalTime startDate;
-            rrule.SetDtStart( newInstanceStartDate );
-            rrule.SetInterval( 1 ); // once a year
-            entry->SetRRuleL( rrule );
+			if( !( FeatureManager::FeatureSupported( KFeatureIdKorean ) 
+					&& entry->UserInt32L() != ESolar ) )
+				{
+				// Set yearly rule to Anniversary entry, to create Annaiversary instance yearly 
+				TCalRRule rrule( TCalRRule::EYearly );
+				TCalTime startDate;
+				rrule.SetDtStart( newInstanceStartDate );
+				rrule.SetInterval( 1 ); // once a year
+				entry->SetRRuleL( rrule );
+				}
             }
 		}
     
--- a/calendarui/editors/src/calenunifiededitorcontrol.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/editors/src/calenunifiededitorcontrol.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -24,7 +24,7 @@
 #include <CalenDefaultEditorsData.rsg>
 #include <calendateutils.h>
 #include <calenservices.h>
-
+#include <featmgr.h>
 // user includes
 #include "calenunifiededitorcontrol.h"
 #include "calenunifiededitor.h"
@@ -37,6 +37,9 @@
 #include "calenpriorityfield.h"
 #include "calendbfield.h"
 #include "CalenDescription.h"
+#include "KoreanLunarDateEditor.h"
+#include "KoreanLunarTypeField.h"
+
 
 // debug
 #include "calendarui_debug.h"
@@ -81,6 +84,18 @@
     delete iDbField;
     delete iDescription;
     
+    if( iKoreanLunarTypeField )
+        {
+        delete iKoreanLunarTypeField;
+        }
+        
+    // Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+    
     TRACE_EXIT_POINT;
     }
 
@@ -101,6 +116,16 @@
     iDbField = CCalenDbField::NewL( iUnifiedEditor,aServices );
     iDescription = CCalenDescription::NewL( iUnifiedEditor );
     
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+    
+	if( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+        {
+        iKoreanLunarTypeField =  CKoreanLunarTypeField::NewL( iUnifiedEditor );
+        }   
+    
     TRACE_EXIT_POINT;    
     }
 
@@ -342,6 +367,13 @@
       }
     CleanupStack::PopAndDestroy( &calendarInfoList );
     
+    
+    if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() 
+	     && FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+        {
+        iKoreanLunarTypeField->PreLayoutDynInitL();
+        }
+
     iDescription->InitDescritpionFieldLayoutL();
     
     TRACE_EXIT_POINT;
@@ -356,40 +388,64 @@
     {
     TRACE_ENTRY_POINT;
     // event type, subject, date & year,more details
+
+     TInt prevItem = 0;
+     prevItem=ECalenEditorSubject;
     
-    RPointerArray<CCalCalendarInfo> calendarInfoList; 
-    iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
-    CleanupClosePushL( calendarInfoList );
-
-    if( calendarInfoList.Count() > 1 )
-        {
-        iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
-            ECalenEditorDBName, ECalenEditorSubject );
-
-        iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
-            ECalenEditorStartDate, ECalenEditorDBName );
-        }
+     if(FeatureManager::FeatureSupported( KFeatureIdKorean ))
+    	 {
+    	 iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_NOTEVIEW_TYPE_LINE,
+    	 EKoreanLunarTypeSelectSolarLunarLeap, ECalenEditorSubject );
+    	 prevItem=EKoreanLunarTypeSelectSolarLunarLeap;   	 
+    	 }
+    	 
+     TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+     
+     if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean ))
+    	{
+    	iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE,
+    								 EKoreanLunarAniversityStart, prevItem );
+    	prevItem=EKoreanLunarAniversityStart;
+    		
+        TTime birthDayYear = iUnifiedEditor.Edited().EventDateTime();
+        SetDateField( ECalenEditorStartDate, birthDayYear, ETrue );
+    	}
     else
-        {
-        iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
-            ECalenEditorStartDate, ECalenEditorSubject );
-        }
+    	{
+    	 RPointerArray<CCalCalendarInfo> calendarInfoList; 
+    	 iUnifiedEditor.GetServices().GetAllCalendarInfoL(calendarInfoList);
+    	 CleanupClosePushL( calendarInfoList );
 
-    CleanupStack::PopAndDestroy( &calendarInfoList );
-    
-    // "Start Date" Label should be "Date of Birth" for Birthday
-    iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
-                    R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
+    	 if( calendarInfoList.Count() > 1 )
+    	 	{
+    	    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
+    	             					 ECalenEditorDBName, prevItem );
+    	    prevItem = ECalenEditorDBName;
+    	    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
+    	             					 ECalenEditorStartDate, prevItem );
+    	    prevItem=ECalenEditorStartDate;
+    	    }
+    	 else
+    	    {
+    	    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
+    	             					 ECalenEditorStartDate, prevItem );
+    	    prevItem = ECalenEditorStartDate;
+    	    }
 
-    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM,
-                    ECalenEditorReminder, ECalenEditorStartDate );
+    	 CleanupStack::PopAndDestroy( &calendarInfoList );
+    	     
+    	 // "Start Date" Label should be "Date of Birth" for Birthday
+    	 iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
+    	                     				R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
+    	 }
+    	
+
+     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM,
+                    ECalenEditorReminder, prevItem );
+
 
     iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM,
                     ECalenEditorPlace, ECalenEditorReminder );
-/*    iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM,
-                    ECalenEditorPeople, ECalenEditorPlace );
-*/   /* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM,
-                    ECalenEditorDBName, ECalenEditorPlace );*/
 
     // TODO: Uncomment this when enabling attachment support
     // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement
@@ -564,17 +620,47 @@
     {
     TRACE_ENTRY_POINT;
 
-    CEikDateEditor* dateField = NULL;
-    dateField = static_cast<CEikDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) );
-    if( dateField )
+    TBool useLunarDate = EFalse;
+    if(aControlId == ECalenEditorStartDate 
+	  && FeatureManager::FeatureSupported( KFeatureIdKorean ))
+       	{
+        if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() )
+        	{
+        	TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+        	if( type != ESolar )
+        		{
+        		useLunarDate = ETrue;
+        		}
+        	}
+       	}
+    
+    if(useLunarDate || aControlId == EKoreanLunarAniversityStart 
+	    && FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+    	{
+    	CKoreanLunarDateEditor* dateField = NULL;
+    	    dateField = static_cast<CKoreanLunarDateEditor*>( iUnifiedEditor.ControlOrNull( EKoreanLunarAniversityStart ) );
+    	    if( dateField )
+    	        {
+    	        dateField->SetDate(aTime, EFalse);
+    	        }
+    	    if ( aDoDraw )
+			{
+			dateField->DrawDeferred();
+			}
+    	}
+    else
         {
-        dateField->SetDate( aTime );
-        if( aDoDraw )
-            {
-            dateField->DrawDeferred();
-            }
-        }
-
+    	CEikDateEditor* dateField = NULL;
+    	dateField = static_cast<CEikDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) );
+    	if( dateField )
+    	    {
+    	    dateField->SetDate( aTime );
+    	    if( aDoDraw )
+    	        {
+    	        dateField->DrawDeferred();
+    	        }
+    	    }
+    	}
     TRACE_EXIT_POINT;
     }
 
@@ -721,6 +807,19 @@
             iDbField->HandleControlStateChangeL( aControlId );
             }
             break;
+        case EKoreanLunarTypeSelectSolarLunarLeap:
+        	{
+        	if (FeatureManager::FeatureSupported( KFeatureIdKorean ))
+        		{
+        		iKoreanLunarTypeField->HandleControlStateChangeL( aControlId );
+        		}
+        	}
+            break;
+        case EKoreanLunarAniversityStart:
+        	{
+        	iKoreanLunarDateEditor->HandleControlStateChangeL( aControlId );
+        	}
+        	  
         default:
             break;
         }
@@ -750,6 +849,7 @@
             
         case ECalenEditorStartTime:    
         case ECalenEditorStartDate:
+        case EKoreanLunarAniversityStart:
             {
             ReadStartDateTimeFromEditorL( ETrue, aFocusedId );
             UpdateMeetingDurationL();
@@ -804,6 +904,8 @@
             break;
         case ECalenEditorDescription:
             break;
+        case EKoreanLunarTypeSelectSolarLunarLeap:
+        	break;
         default:
             break;
         }
@@ -844,6 +946,44 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCalenUnifiedEditorControl::OnLunarTypeChangedL
+// Handles lunar type changed
+// -----------------------------------------------------------------------------
+//
+void CCalenUnifiedEditorControl::OnLunarTypeChangedL( TLunarCalendarType aNewEventType )
+    {
+    TRACE_ENTRY_POINT;
+    if( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+        {
+    	TLunarCalendarType oldType = iUnifiedEditor.Edited().CalendarType();
+    	if(oldType != aNewEventType)
+    		{
+    		iUnifiedEditor.Edited().SetCalendarTypeL(aNewEventType);
+    		if(aNewEventType == ESolar)
+    			{
+    			iUnifiedEditor.DeleteLine(EKoreanLunarAniversityStart, ETrue);
+				iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
+						  					 ECalenEditorStartDate, EKoreanLunarTypeSelectSolarLunarLeap );
+				iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
+												   R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
+				SetDataToEditorL();
+    			}
+			else
+                {
+                if(oldType == ESolar)
+                    {
+                    iUnifiedEditor.DeleteLine(ECalenEditorStartDate, ETrue);
+                    iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE,
+                    EKoreanLunarAniversityStart, EKoreanLunarTypeSelectSolarLunarLeap );
+                    SetDataToEditorL();
+                    }
+    			}
+    		}
+    	}
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
 // CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL
 // Delete previous entry type fields on selcting 
 // the new entry type
@@ -866,7 +1006,20 @@
             break;
         case CCalEntry::EAnniv:
             {
-            iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
+          	TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+			if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+				{
+				iUnifiedEditor.DeleteLine( EKoreanLunarAniversityStart, EFalse );
+                }
+            else
+				{
+				iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
+            	}
+			
+			if(FeatureManager::FeatureSupported( KFeatureIdKorean ))
+				{
+				iUnifiedEditor.DeleteLine( EKoreanLunarTypeSelectSolarLunarLeap, EFalse );
+				}
             }
             break;
         case CCalEntry::EAppt:
@@ -1061,6 +1214,16 @@
             }
         }
     
+    if( iUnifiedEditor.GetEntryType() == CCalEntry::EAnniv 
+        &&  FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+    	{
+    	CCoeControl* lunarcaltype = iUnifiedEditor.ControlOrNull( EKoreanLunarTypeSelectSolarLunarLeap );
+    	if( lunarcaltype )
+    		{
+    	    iKoreanLunarTypeField->ReadDataFromFormL( aContinueOnError );
+    	    }
+    	}
+    
     iDbField->ReadDataFromFormL( aContinueOnError );
     
     TRACE_EXIT_POINT;
@@ -1251,6 +1414,20 @@
 TTime CCalenUnifiedEditorControl::ReadTimeField( TInt aControlId )
     {
     TRACE_ENTRY_POINT;
+
+    if(aControlId == ECalenEditorStartDate && FeatureManager::FeatureSupported( KFeatureIdKorean ))
+		{
+		if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() )
+			{
+			TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+			if( type != ESolar )
+				{
+				aControlId = EKoreanLunarAniversityStart;
+				TRACE_EXIT_POINT;
+				return static_cast<CKoreanLunarDateEditor*>( iUnifiedEditor.Control( aControlId ) )->Date();
+				}
+			}
+		}
     TRACE_EXIT_POINT;
     return static_cast<CEikTTimeEditor*>( iUnifiedEditor.Control( aControlId ) )->GetTTime();
     }
@@ -1263,6 +1440,21 @@
 TTime CCalenUnifiedEditorControl::ReadDateField( TInt aControlId )
     {
     TRACE_ENTRY_POINT;
+
+    if(aControlId == ECalenEditorStartDate && FeatureManager::FeatureSupported( KFeatureIdKorean ))
+    	{
+    	if( CCalEntry::EAnniv == iUnifiedEditor.GetEntryType() )
+    		{
+    		TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+    		if( type != ESolar )
+    			{
+    			aControlId = EKoreanLunarAniversityStart;
+				TRACE_EXIT_POINT;
+    			return static_cast<CKoreanLunarDateEditor*>( iUnifiedEditor.Control( aControlId ) )->Date();
+    			}
+    		}
+    	}
+    	
     TRACE_EXIT_POINT;
     return static_cast<CEikDateEditor*>( iUnifiedEditor.Control( aControlId ) )->Date();
     }
@@ -1355,14 +1547,23 @@
             
         case CCalEntry::EAnniv:
             {
-            iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
-            iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
-                    ECalenEditorStartDate, ECalenEditorEventType );
-            
-            // "Start Date" Label should be "Date of Birth" for Birthday
-            iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
-                            R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
-            
+            TLunarCalendarType type =  iUnifiedEditor.Edited().CalendarType();
+            if( type != ESolar && FeatureManager::FeatureSupported( KFeatureIdKorean ))
+				{
+				iUnifiedEditor.DeleteLine( EKoreanLunarAniversityStart, EFalse );
+				iUnifiedEditor.InsertFieldL( R_KOREAN_LUNAR_DATE_EDITOR_LINE,
+								EKoreanLunarAniversityStart, EKoreanLunarTypeSelectSolarLunarLeap );
+                }
+            else
+                {
+            	iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse );
+            	iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, 
+                ECalenEditorStartDate, ECalenEditorEventType );
+            	// "Start Date" Label should be "Date of Birth" for Birthday
+            	iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate,
+                            						   R_QTN_CALEN_EDITOR_DATE_OF_BIRTH );
+               	}
+
             }
             break;
             
--- a/calendarui/globaldata/inc/calencontextimpl.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/globaldata/inc/calencontextimpl.h	Tue Sep 14 21:17:03 2010 +0300
@@ -128,6 +128,21 @@
      * this will be TCalenInstanceId::NullInstanceIdL()
      */
     TCalenInstanceId InstanceId() const;
+    
+    /**
+     * Sets the start and end time of the instance that has to be created.
+     * @param aStartTime The start time of the instance that has to be created.
+     * @param aEndTime The end time of the instance that has to be created.
+     */
+    void SetStartAndEndTimeForNewInstance( const TTime& aStartTime,
+                                        const TTime& aEndTime );
+    
+    /**
+     * Gets the start and end time of the instance that has to be created.
+     * @param aStartTime The start time of the instance that has to be created.
+     * @param aEndTime The end time of the instance that has to be created.
+     */
+    void GetStartAndEndTimeForNewInstance( TTime& aStartTime, TTime& aEndTime );
 
     /**
      * Gets the id of the currently active view.
@@ -255,6 +270,10 @@
     HBufC* iCalenFileName;
     HBufC* iCalAlarmEntryFileName;
     TCalLocalUid iCalAlarmLocalUid;
+	
+	// The new instance's start and end time
+    TTime iNewInstStartTime;
+	TTime iNewInstEndTime;
     };
 
 #endif // CALENCONTEXTIMPL_H
--- a/calendarui/globaldata/src/calencontextimpl.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/globaldata/src/calencontextimpl.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -309,6 +309,36 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCalenContextImpl::SetStartAndEndTimeForNewInstance
+// Sets the start and end time of the instance that has to be created.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CCalenContextImpl::SetStartAndEndTimeForNewInstance( const TTime& aStartTime,
+                                                      const TTime& aEndTime )
+    {
+	TRACE_ENTRY_POINT;
+    iNewInstStartTime = aStartTime;
+    iNewInstEndTime = aEndTime;
+	TRACE_EXIT_POINT;
+    }
+ 
+// -----------------------------------------------------------------------------
+// CCalenContextImpl::GetStartAndEndTimeForNewInstance
+// Gets the start and end time of the instance that has to be created.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CCalenContextImpl::GetStartAndEndTimeForNewInstance( TTime& aStartTime,
+                                                        TTime& aEndTime )
+    {
+	TRACE_ENTRY_POINT;
+    aStartTime = iNewInstStartTime;
+    aEndTime = iNewInstEndTime;
+	TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
 // CCalenContextImpl::ViewId
 // Returns the view id
 // (other items were commented in a header).
--- a/calendarui/group/bld.inf	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -59,6 +59,10 @@
 ../rom/CalenLunarVietnamese_Variant.iby CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(CalenLunarVietnamese_Variant.iby)
 ../rom/CalenLunarChinese_Variant.iby CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(CalenLunarChinese_Variant.iby)
 
+#ifdef FF_CALDAV_SUPPORT
+//caldav plugin
+../rom/caldav.iby 						CORE_APP_LAYER_IBY_EXPORT_PATH(caldav.iby)
+#endif //FF_CALDAV_SUPPORT
 
 //stubsis is added to provide IAD
 ../stubsis/calendar_stub.sis   										/epoc32/data/z/system/install/calendar_stub.sis
@@ -132,4 +136,10 @@
 // Calendar aiw provider.
 #include "../calenaiwprovider/group/bld.inf"
 
+#include "../regionalplugins/KoreanLunar/group/bld.inf"
+
+#ifdef FF_CALDAV_SUPPORT
+//caldav ecom plugin
+#include "../caldav/group/bld.inf"
+#endif //FF_CALDAV_SUPPORT
 //EOF
--- a/calendarui/inc/CalenUid.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/inc/CalenUid.h	Tue Sep 14 21:17:03 2010 +0300
@@ -55,6 +55,7 @@
 const TUid KCalenThaiImplUid = {0x102823A7};
 const TUid KCalenChineseImplUid = {0x102823A5};
 const TUid KCalenVietnameseImplUid = {0x102823A6};
+const TUid KCalenKoreanImplUid = {0x200100A2};
 
 #endif // CALENUID_H
 
Binary file calendarui/regionalplugins/KoreanLunar/conf/KoreanLunar.confml has changed
Binary file calendarui/regionalplugins/KoreanLunar/conf/KoreanLunar_2001843E.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/data/CalenKoreanLunarPlugin.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* 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:
+*
+*/
+#include <CalenRegionalPluginUids.h>
+#include "CalenLunarPluginUids.hrh"
+
+#include <ecom/registryinfo.rh>
+#include <calenkoreanlunar.loc>
+
+RESOURCE REGISTRY_INFO registry_info
+    {
+    dll_uid = CALENKOREANLUNARPLUGIN_DLL_UID;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = CALENUIPLUGININTERFACE_ECOM_INTERFACE_UID;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = CALENKOREANLUNARPLUGIN_IMPLEMENTATION_UID;
+                    version_no = 1;
+                    display_name = qtn_kor_cale_lunar_calendar;
+                    // Supported languages can be inserted as follows:
+                    // "language(1)||language(14)||language(151)
+                    // Numbers can be Symbian language codes (TLanguage)
+                    // or S60 extensions (151,161...) to them
+                    //
+                    // Plugin is loaded only when current phone language
+                    // is one of the listed languages.
+                    //
+                    // If plugin should be loaded for all languages, then
+                    // language(*) can be defined,
+                    // 65 Korean
+                    // 1 English
+                    default_data = "language(65)||language(1)";
+                    opaque_data  = "";
+                    }
+                };
+            }
+        };
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/data/CalenKoreanLunarPluginData.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,297 @@
+/*
+* 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:
+*
+*/
+
+#include <calenkoreanlunar.loc>
+
+#include <calendar.loc>
+#include <calendar.rsg>
+#include <eikon.rh>
+#include <avkon.hrh>
+#include <avkon.rh>
+#include <avkon.rsg>
+
+NAME KLU1
+RESOURCE RSS_SIGNATURE { }
+
+// ---------------------------------------------------------
+// ---------------------------------------------------------
+// one version exits in calendar.rsg
+RESOURCE TBUF R_CALEN_LUNAR_SETTING_TITLE2
+    {
+    buf = qtn_kor_cale_sett_lunar_cale;
+    }
+
+// ---------------------------------------------------------
+// ---------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_calen_lunar_setting_page
+    {
+    label = qtn_kor_cale_sett_lunar_cale;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;
+    type = EAknCtPopupSettingList;
+    editor_resource_id = R_CALEN_SETTING_LISTBOX;
+    }
+
+// ---------------------------------------------------------
+// ---------------------------------------------------------
+//
+RESOURCE ARRAY r_calen_lunar_setting_choicelist
+    {
+    items =
+        {
+        LBUF
+            {
+            txt = qtn_kor_cale_lunar_cale_off;
+            },
+        LBUF
+            {
+            txt = qtn_kor_cale_lunar_cale_on;
+            }
+        };
+    }
+
+//----------------------------------------------------
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_calen_lunar_setting_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = qtn_kor_cale_lunar_cale_off;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = qtn_kor_cale_lunar_cale_on;
+            }
+        };
+    }
+
+//----------------------------------------------------
+//----------------------------------------------------
+//
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_calen_lunar_setting_texts
+    {
+    setting_texts_resource = r_calen_lunar_setting_array;
+    popped_up_texts_resource = r_calen_lunar_setting_choicelist;
+    }
+
+
+//----------------------------------------------------
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_calen_lunar_details_dialog
+     {
+     flags = EGeneralQueryFlags;
+     buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+     items =
+         {
+         DLG_LINE
+             {
+             type = EAknCtPopupHeadingPane;
+             id = EAknMessageQueryHeaderId;
+             control = AVKON_HEADING
+                {
+                 label = qtn_kor_cale_lunar_calendar;
+                 headinglayout = R_AVKON_LIST_HEADING_PANE;
+                };
+             },
+         DLG_LINE
+             {
+             type = EAknCtMessageQuery;
+             id = EAknMessageQueryContentId;
+             control = AVKON_MESSAGE_QUERY
+                 {
+                 };
+             }
+         };
+     }
+
+
+//----------------------------------------------------
+// Menu item text "Show lunar details"
+//----------------------------------------------------
+//
+RESOURCE TBUF r_calendar_show_lunar_data
+    {
+    buf = qtn_kor_cale_lunar_data;
+    }
+
+
+//----------------------------------------------------
+// Details dialog item headers
+//----------------------------------------------------
+//
+RESOURCE TBUF r_calendar_lunar_info_festival
+    {
+    buf = qtn_cale_lunar_info_festival;
+    }
+
+RESOURCE TBUF r_calendar_lunar_info_solar
+    {
+    buf = qtn_cale_lunar_info_solar;
+    }
+
+RESOURCE TBUF r_calendar_lunar_info_date
+    {
+    buf = qtn_cale_info_lunar_date;
+    }
+
+RESOURCE TBUF r_calendar_lunar_info_western_date
+    {
+    buf = qtn_cale_info_western_date;
+    }
+
+RESOURCE TBUF r_kor_cale_extra_row_lunar
+    {
+    buf = qtn_kor_cale_extra_row_lunar;
+    }
+
+RESOURCE TBUF r_cale_lunar_separator
+    {
+    buf = qtn_cale_lunar_separator;
+    }
+
+RESOURCE TBUF r_cale_lunar_full_date
+    {
+    buf = qtn_cale_lunar_full_date;
+    }
+
+RESOURCE TBUF r_cale_lunar_date
+    {
+    buf = qtn_cale_lunar_date;
+    }
+
+RESOURCE TBUF r_cale_lunar_leap_date
+    {
+    buf = qtn_cale_lunar_leap_date;
+    }
+
+RESOURCE TBUF r_cale_lunar_year
+    {
+    buf = qtn_cale_lunar_year;
+    }
+
+//test
+RESOURCE TBUF r_cale_kor_lunar_date
+    {
+    buf = qtn_cale_kor_lunar_date;
+    }
+
+RESOURCE TBUF r_cale_kor_lunar_indicator
+    {
+    buf = qtn_lunar_indicator;
+    }
+
+RESOURCE TBUF r_cale_kor_leap_year_indicator
+    {
+    buf = qtn_lunar_leap_year_indicator;
+    }
+
+// ---------------------------------------------------------
+//
+//    r_calen_kor_festivals
+//    Descriptor array for Korean festivals
+//
+// ---------------------------------------------------------
+//
+RESOURCE ARRAY r_calen_kor_festivals
+    {
+    items =
+        {
+        LBUF { txt = qtn_kor_cale_festival_name_1; },
+        LBUF { txt = qtn_kor_cale_festival_name_2; },
+        LBUF { txt = qtn_kor_cale_festival_name_3; },
+        LBUF { txt = qtn_kor_cale_festival_name_4; },
+        LBUF { txt = qtn_kor_cale_festival_name_5; },
+        LBUF { txt = qtn_kor_cale_festival_name_6; },
+        LBUF { txt = qtn_kor_cale_festival_name_7; },
+        LBUF { txt = qtn_kor_cale_festival_name_8; },
+        LBUF { txt = qtn_kor_cale_festival_name_9; },
+        LBUF { txt = qtn_kor_cale_festival_name_10; },
+        LBUF { txt = qtn_kor_cale_festival_name_11; }
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//    r_calen_kor_solar_items
+//    Descriptor array for Korean solar items
+//
+// ---------------------------------------------------------
+//
+RESOURCE ARRAY r_calen_kor_solar_items
+    {
+    items =
+        {
+        LBUF { txt = qtn_kor_cale_solar_item_1;  },
+        LBUF { txt = qtn_kor_cale_solar_item_2;  },
+        LBUF { txt = qtn_kor_cale_solar_item_3;  },
+        LBUF { txt = qtn_kor_cale_solar_item_4;  },
+        LBUF { txt = qtn_kor_cale_solar_item_5;  },
+        LBUF { txt = qtn_kor_cale_solar_item_6;  },
+        LBUF { txt = qtn_kor_cale_solar_item_7;  },
+        LBUF { txt = qtn_kor_cale_solar_item_8;  },
+        LBUF { txt = qtn_kor_cale_solar_item_9;  },
+        LBUF { txt = qtn_kor_cale_solar_item_10; },
+        LBUF { txt = qtn_kor_cale_solar_item_11; },
+        LBUF { txt = qtn_kor_cale_solar_item_12; },
+        LBUF { txt = qtn_kor_cale_solar_item_13; },
+        LBUF { txt = qtn_kor_cale_solar_item_14; },
+        LBUF { txt = qtn_kor_cale_solar_item_15; },
+        LBUF { txt = qtn_kor_cale_solar_item_16; },
+        LBUF { txt = qtn_kor_cale_solar_item_17; },
+        LBUF { txt = qtn_kor_cale_solar_item_18; },
+        LBUF { txt = qtn_kor_cale_solar_item_19; },
+        LBUF { txt = qtn_kor_cale_solar_item_20; },
+        LBUF { txt = qtn_kor_cale_solar_item_21; },
+        LBUF { txt = qtn_kor_cale_solar_item_22; },
+        LBUF { txt = qtn_kor_cale_solar_item_23; },
+        LBUF { txt = qtn_kor_cale_solar_item_24; }
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//    r_calen_kor_solar_anniversary_items
+//    Descriptor array for Korean solar anniversary items
+//
+// ---------------------------------------------------------
+//
+RESOURCE ARRAY r_calen_kor_solar_anniversary_items
+    {
+    items =
+        {
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_1;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_2;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_3;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_4;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_5;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_6;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_7;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_8;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_9;  },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_10; },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_11; },
+        LBUF { txt = qtn_kor_cale_solar_anniversary_item_12; }
+        };
+    }
+
+
Binary file calendarui/regionalplugins/KoreanLunar/data/KoreanSolarItems has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/group/CalenKoreanLunarPlugin.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* 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:
+*
+*/
+#include <platform_paths.hrh>
+#include "..\inc\CalenLunarPluginUids.hrh"
+
+#include <data_caging_paths.hrh>
+
+// Target
+TARGET CalenKoreanLunarPlugin.dll
+TARGETTYPE PLUGIN
+UID SYMBIAN_ECOM_PLUGIN_UID CALENKOREANLUNARPLUGIN_DLL_UID
+
+// Includes
+USERINCLUDE ..\inc
+USERINCLUDE ..\..\..\cenrep
+
+//SYSTEMINCLUDE ..\..\interface
+SYSTEMINCLUDE ..\..\..\inc
+SYSTEMINCLUDE ..\..\calenregionalutil\inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE \epoc32\include\ecom
+
+// Resources
+SOURCEPATH ..\data
+// Ecom Resource
+RESOURCE CalenKoreanLunarPlugin.rss
+// Normal resource
+START RESOURCE CalenKoreanLunarPluginData.rss
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+// Sources
+
+SOURCEPATH ..\src
+SOURCE CalenLunarPluginProxy.cpp
+SOURCE CalenKoreanLunarPlugin.cpp
+SOURCE CalenLunarSettingItem.cpp
+SOURCE CalenLunarInfo.cpp
+SOURCE CalenLunarInfoProvider.cpp
+SOURCE CalenSolarTerms.cpp
+SOURCE CalenLunarLocalizedInfo.cpp
+SOURCE CalenLunarLocalizer.cpp
+SOURCE CalenExtraRowFormatter.cpp
+
+
+// Libraries
+LIBRARY bafl.lib
+LIBRARY ccon.lib
+LIBRARY ecom.lib
+LIBRARY efsrv.lib
+LIBRARY estor.lib
+LIBRARY euser.lib
+LIBRARY calencommonutils.lib
+LIBRARY aknskins.lib
+
+// Libraries for view extension
+LIBRARY avkon.lib
+LIBRARY cone.lib
+LIBRARY gdi.lib
+LIBRARY eikcoctl.lib
+
+// Libraries for setting extension
+LIBRARY commonengine.lib
+LIBRARY centralrepository.lib
+
+LIBRARY         calinterimapi.lib
+
+
+// Misc
+CAPABILITY CAP_ECOM_PLUGIN
+VENDORID VID_DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+// ARMV5
+../loc/calenkoreanlunar.loc						APP_LAYER_LOC_EXPORT_PATH(calenkoreanlunar.loc)
+../data/KoreanSolarItems  /epoc32/data/z/private/10005901/KoreanSolarItems
+// WINSCW
+../data/KoreanSolarItems  /epoc32/release/winscw/udeb/z/private/10005901/KoreanSolarItems
+../data/KoreanSolarItems  /epoc32/release/winscw/urel/z/private/10005901/KoreanSolarItems
+
+../rom/KoreanCalPlugin.iby      /epoc32/rom/include/customer/app/KoreanCalPlugin.iby
+
+../conf/KoreanLunar.confml                     APP_LAYER_CONFML(KoreanLunar.confml)
+../conf/KoreanLunar_2001843E.crml 	        APP_LAYER_CRML(KoreanLunar_2001843E.crml)
+
+PRJ_MMPFILES
+CalenKoreanLunarPlugin.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenExtraRowFormatter.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENEXTRAROWFORMATTER_H__
+#define __CALENEXTRAROWFORMATTER_H__
+
+// INCLUDES
+#include <e32base.h>
+
+#include "CalenLunarLocalizedInfo.h"
+#include "CalendarVariant.hrh"
+
+// FORWARD DECLARATION
+class CFont;
+
+/**
+* Class declaration for Extra row formatter
+*/ 
+class CCalenExtraRowFormatter : public CBase
+    {
+public: // public API 
+        /**
+        * Two phased constructor.
+        */
+    static CCalenExtraRowFormatter* NewL();
+      /**
+      * destructor
+      */
+    virtual ~CCalenExtraRowFormatter();
+   /**
+    * Formats lunar based information
+    */    
+    TPtrC FormatExtraRowInformationL( CCalenLunarLocalizedInfo& aLocInfo, 
+                                      RArray<CCalenLunarLocalizedInfo::TField>& aPrioritizedFields,
+                                      TInt aMaxWidth,
+                                      const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+                                      , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                      );   
+    
+private:
+    TBool TryToFitL( const TDesC& aStr, TInt aMaxWidth, const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+                     , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                     );
+
+
+private: // own methods
+    CCalenExtraRowFormatter();
+
+    void ConstructL();
+
+
+private: // data
+    TBuf<500> iText;
+    };
+
+#endif // __CALENEXTRAROWFORMATTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenKoreanLunarPlugin.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENKOREANLUNARPLUGIN_H__
+#define __CALENKOREANLUNARPLUGIN_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <coneresloader.h>
+#include <calencommandhandler.h>
+#include <calennotificationhandler.h>
+#include <calenservices.h>
+#include <calencustomisation.h>
+#include <eiklabel.h>
+#include <KoreanCalConv.h>
+
+// FORWARD DECLARATION
+class CCalenLunarInfoProvider;
+class CCalenLunarLocalizer;
+class CCalenExtraRowFormatter;
+class CCalenLunarLocalizedInfo;
+class CFont;
+
+/**
+* Class declaration for Korean lunar plugin
+*/ 
+class CCalenKoreanLunarPlugin : public CCalenCustomisation,
+                                public MCalenCommandHandler,
+                                public MCalenNotificationHandler   
+    {
+public: // public API
+    static CCalenKoreanLunarPlugin* CreateKoreanPluginL( MCalenServices* aServices );
+
+    virtual ~CCalenKoreanLunarPlugin();
+
+public: // Plugins internal Public API
+
+    TBool LoadEnabledStatusL();
+    void StoreEnabledStatusL( TBool aEnabled );
+
+protected://From CCalenCustomisation
+    
+    	void GetCustomViewsL(  RPointerArray<CCalenView>& aCustomViewArray );
+		void GetCustomSettingsL( RPointerArray<CAknSettingItem>& aCustomSettingArray );
+        CCoeControl* InfobarL( const TRect& aRect );
+        const TDesC& InfobarL();
+        CCoeControl* PreviewPaneL(  TRect& aRect );
+        MCalenCommandHandler* CommandHandlerL( TInt aCommand );
+        void RemoveViewsFromCycle( RArray<TInt>& aViews );
+        TBool CustomiseMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+        TBool CanBeEnabledDisabled();
+        TAny* CalenCustomisationExtensionL( TUid aExtensionUid );
+        
+        /**
+        * Gets the preview pane from the plugin to be shown at the 
+        * calendar view. Offers the rectangle for the preview pane, 
+        * which it can be used to draw the pane.
+        * 
+        * @param aRect The area available for the Preview Pane
+        * @return Preview pane interface
+        */
+        virtual MCalenPreview* CustomPreviewPaneL( TRect& aRect );
+                
+        // korean support to conversion as getting new api seems too difficult
+     public:
+     	virtual void DateTimeToKoreanL( const TDateTime& aDateTime, TKoreanDate& aKoreanDate );
+
+        /* Method converting korean lunar date to gregorian date,
+           supported range is 1.1.1900 - 31.12.2099
+           Leaves with KErrArgument if date is uncovertible.
+        */
+     	virtual void KoreanToDateTimeL( TKoreanDate& aKoreanDate, TDateTime& aDateTime );
+
+        /* Method getting supported gregorian date range
+        */
+     	virtual void DateRange( TDateTime& aLower, TDateTime& aUpper );
+
+        /* Method getting supported korean lunar date range
+        */
+     	virtual void DateRange( TKoreanDate& aLower, TKoreanDate& aUpper );
+        
+protected:// From MCalenCommandHandler
+        TBool HandleCommandL( const TCalenCommand& aCommand );
+        TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid );
+    
+protected://From MCalenNotificationHandler 
+        void HandleNotification( const TCalenNotification aNotification );
+    
+private: // own methods
+        CCalenKoreanLunarPlugin(TUint32 aCenRepLunarEnabledId, MCalenServices* aServices);
+        
+        void ConstructL();        
+        void SetLunarLocalizerL();        
+        void ShowDetailsL();
+        TInt GetColor();      
+        
+        void FormatExtraRowStringL( CEikLabel& aLabel );
+        TPtrC GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo, TInt aMaxWidth, const CFont& aFont );
+        void UpdateInfoBarL();
+
+private: // data
+    /**
+     * Tells, if lunar functionality is currently enabled by user.
+     * If not, only setting item is provided by plugin
+     */
+    TBool iLunarEnabled;
+
+    /**
+     * Language independent provider of lunar calendar information
+     */
+    CCalenLunarInfoProvider* iInfoProvider;
+
+    /**
+     * Language specific localizer of lunar calendar information
+     */
+    CCalenLunarLocalizer* iLocalizer;
+
+    /**
+     * Localized lunar info for currently focused day
+     */
+    CCalenLunarLocalizedInfo* iLocInfo;
+
+    /**
+     * Currently displayed text for extra row
+     */
+    TPtrC iExtraRowText;
+
+    RConeResourceLoader iResourceLoader;
+
+    // Central repository Id for enabled setting
+    // We have different setting for Chinese and Vietnamese
+    // in case that in future they would be in same image
+    TUint32 iCenRepLunarEnabledId;    
+    CEikLabel* iLabel;    
+    MCalenServices* iServices;    
+    TInt iStart;
+    TInt iEnd;
+        
+    CKoreanCalConv* iConverter;
+    
+    // Infobar rect
+    TRect iRect;
+    
+    // Skin color
+    TRgb iSkinColor;
+    };
+
+#endif // __CALENKOREANLUNARPLUGIN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenKoreanLunarPrivateCRKeys.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+
+#ifndef CALENKOREANLUNARPRIVATECRKEYS_H
+#define CALENKOREANLUNARPRIVATECRKEYS_H
+
+const TUid KCRUidCalenKoreanPlugin = {0x2001843E};
+const TUint32 KCalenKoreanPluginEnabled = 0x00000001;
+
+#endif  // CALENKOREANLUNARPRIVATECRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarInfo.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENLUNARINFO_H__
+#define __CALENLUNARINFO_H__
+
+// INCLUDES
+#include <e32def.h>
+#include <calendarconverter.h>
+
+/**
+* Class declaration for Lunar info
+*/ 
+class TCalenLunarInfo
+    {
+public:
+    enum TLunarFestival
+        {
+        ENoFestival = KErrNotFound,
+        EFestivalNewYearDay,
+        EFestivalBuddhaBirthDay,
+        EFestivalHarvest,
+        EFestivalFullMoonDay,
+        EFestival3rdMarchDay,
+        EFestivalDano,
+        EFestivalUnknown_1,
+        EFestival7thJulyDay,
+        EFestivalUnknown_2,
+        EFestivalUnknown_3,
+        EFestival105thDayAfterWS    
+        };
+
+    enum TSolarFestival
+        {
+        ENoSolarFestival = KErrNotFound,
+        ESolarFestivalNewYearDay,
+        ESolarFestivalIndependenceMovement,
+        ESolarFestivalChildrensDay,
+        ESolarFestivalMemorialDay,
+        ESolarFestivalConstitutionDay,
+        ESolarFestivalLiberationDay,
+        ESolarFestivalFoundationDay,
+        ESolarFestivalChristmasDay,
+        ESolarFestivalHangulDay
+        };
+
+    typedef TInt TSolarTerm;
+
+public:
+    TBool HasLunarFestival();
+    TBool HasSolarFestival();
+    TBool HasSolarTerm();
+
+public:
+        /**
+        * Lunar Festival.
+        */
+    TLunarFestival  iLunarFestival;
+        /**
+        * Lunar Festival.
+        */
+    TSolarFestival  iSolarFestival;
+        /**
+        * Lunar Festival.
+        */
+    TSolarTerm      iSolarTerm;
+        /**
+        * Lunar Festival.
+        */
+    TChineseDate    iLunarDate;
+        /**
+        * Lunar Festival.
+        */
+    TTime           iGregorianDate;
+    };
+
+
+#endif // __CALENLUNARINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarInfoProvider.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENLUNARINFOPROVIDER_H__
+#define __CALENLUNARINFOPROVIDER_H__
+
+// INCLUDES
+#include "CalenLunarInfo.h"
+#include <e32base.h>
+
+// FORWARD DECLARATION
+class CKoreanCalConv;
+class CCalenSolarTerms;
+class RFs;
+
+/**
+* Class declaration for Lunar info provider
+*/ 
+class CCalenLunarInfoProvider : public CBase
+    {
+public: // public API 
+    static CCalenLunarInfoProvider* NewL(RFs& aFs);
+
+    virtual ~CCalenLunarInfoProvider();
+
+    TCalenLunarInfo GetLunarInfoL( const TTime& aDay );
+
+private: // own methods
+    CCalenLunarInfoProvider();
+    void ConstructL(RFs& aFs);
+
+private: // data
+    CKoreanCalConv* iConverter;
+    CCalenSolarTerms* iSolarTerms;
+
+    };
+
+#endif // __CALENLUNARINFOPROVIDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarLocalizedInfo.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENLUNARLOCALIZEDINFO_H__
+#define __CALENLUNARLOCALIZEDINFO_H__
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATION
+class CCalenLunarLocalizer;
+
+/**
+* Class declaration for Lunar localized info
+*/ 
+class CCalenLunarLocalizedInfo : public CBase
+    {
+public:
+    enum TField
+        {
+        ELunarFestival,
+        ESolarFestival,
+        ESolarTerm,
+        ELunarMonthAndDay,
+        EGregorianDate
+        };
+
+
+public: // public API
+    static CCalenLunarLocalizedInfo* NewL();
+
+    virtual ~CCalenLunarLocalizedInfo();
+
+    /**
+     * Get specific field. This is useful, when you have ordered array of TFields
+     * and you want to process them in a loop.
+     * If day didn't had e.g. festival or solar term, KNullDesC is returned for those.
+     */
+    const TDesC& GetField( TField aField );
+
+    const TDesC& LunarFestival() { return iLunarFestival; }
+    const TDesC& SolarFestival() { return iSolarFestival; }
+    const TDesC& SolarTerm() { return iSolarTerm; }
+    const TDesC& LunarMonthAndDay() { return iLunarMonthAndDay; }
+    const TDesC& GregorianDate() { return iGregorianDate; }
+
+private:
+    CCalenLunarLocalizedInfo();
+
+    void ConstructL();
+
+private:
+
+    TPtrC iLunarFestival;
+    TPtrC iSolarFestival;
+    TPtrC iSolarTerm;
+
+    TBuf<50> iLunarMonthAndDay;
+    TBuf<50> iGregorianDate;
+private:
+    friend class CCalenLunarLocalizer;
+    };
+
+#endif // __CALENLUNARLOCALIZEDINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarLocalizer.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENLUNARLOCALIZER_H__
+#define __CALENLUNARLOCALIZER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include "CalenLunarLocalizedInfo.h"
+#include "CalendarVariant.hrh"
+
+// FORWARD DECLARATION
+class CEikonEnv;
+class TCalenLunarInfo;
+class TChineseDate;
+class CFont;
+class CCalenExtraRowFormatter;
+
+/**
+* Class declaration for Lunar localizer
+*/ 
+class CCalenLunarLocalizer : public CBase
+    {
+public: // public API
+    static CCalenLunarLocalizer* NewL();
+
+    virtual ~CCalenLunarLocalizer();
+
+    virtual CCalenLunarLocalizedInfo* LocalizeL( TCalenLunarInfo& aInfo );
+
+    virtual TPtrC GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo,
+                                    TInt aMaxWidth,
+                                    const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+                                    , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                    );
+
+protected:
+    CCalenLunarLocalizer();
+
+    void ConstructL();
+
+    TBool TryToFitL( const TDesC& aStr );
+    virtual void LocalizeMonthAndDayL(CCalenLunarLocalizedInfo* aLocInfo,
+                                      TCalenLunarInfo& aInfo);
+private:
+
+protected: // data
+    CEikonEnv* iEikEnv;
+
+    /**
+     * Localized names of lunar festivals
+     * Own.
+     */
+    CDesCArray* iLunarFestivalNames;
+
+    /**
+     * Localized names of solar festivals
+     * Own.
+     */
+    CDesCArray* iSolarFestivalNames;
+
+    /**
+     * Localized names of solar terms
+     * Own.
+     */
+    CDesCArray* iSolarTermNames;
+
+    /**
+     * Format string for western date.
+     * Own.
+     */
+    HBufC* iGregorianDateFormat;
+
+    TBuf<1000> iLunarExtraRowText;
+
+
+    /**
+     * Language independent formatter of extra row information.
+     */
+    CCalenExtraRowFormatter* iRowFormatter;
+
+    };
+
+#endif // __CALENLUNARLOCALIZER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPanic.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef CALENLUNARPANIC_H
+#define CALENLUNARPANIC_H
+
+enum TCalenLunarPanic
+    {
+    EPanicLunarResourceLoading = 1
+    };
+
+void Panic( TCalenLunarPanic aReason )
+    {
+    _LIT(KPanicText, "CalenLunarPlugin");
+    User::Panic( KPanicText, aReason );
+    }
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPaths.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+
+#ifndef CALENLUNARPATHS_H
+#define CALENLUNARPATHS_H
+
+
+_LIT( KCalenLunarDllFile, "CalenLunar.dll" );
+
+_LIT( KCalenLunarResourceDrive, "z:" );
+
+_LIT( KCalenLunarResourceFile, "CalenLunar.rsc" );
+
+// search path for solar item file
+_LIT( KSolarTermsPath, "\\private\\10005901\\" );
+
+
+#endif  // CALENLUNARPATHS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarPluginUids.hrh	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#define SYMBIAN_ECOM_PLUGIN_UID               0x10009D8D
+#define CALENKOREANLUNARPLUGIN_DLL_UID              0x200100A1
+#define CALENKOREANLUNARPLUGIN_IMPLEMENTATION_UID   0x200100A2
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarSettingItem.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+#ifndef __CALENLUNARSETTINGITEM_H__
+#define __CALENLUNARSETTINGITEM_H__
+
+// INCLUDES
+#include <e32def.h>
+#include <aknsettingitemlist.h>
+
+// FORWARD DECLARATION
+class CRepository;
+class CCalenKoreanLunarPlugin;
+
+/**
+* Class declaration for Lunar setting item
+*/ 
+NONSHARABLE_CLASS( CCalenLunarSettingItem )
+    : public CAknBinaryPopupSettingItem
+    {
+public:
+    static CCalenLunarSettingItem* NewLC( TInt aOrdinal, CCalenKoreanLunarPlugin& aPlugin );
+    virtual ~CCalenLunarSettingItem();
+
+private: // From CAknBinaryPopupSettingItem
+    virtual void StoreL();
+    virtual void LoadL();
+
+private:
+    CCalenLunarSettingItem( CCalenKoreanLunarPlugin& aPlugin );
+
+private:
+    CCalenKoreanLunarPlugin& iPlugin;
+    TBool iLunarEnabled;
+    };
+
+#endif // __CALENLUNARSETTINGITEM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/inc/CalenSolarTerms.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+
+#ifndef C_CALENSOLARTERMS_H
+#define C_CALENSOLARTERMS_H
+
+// INCLUDES
+#include <badesca.h>
+#include <e32base.h>
+
+// FORWARD DECLARATION
+class RFs;
+
+// CONSTANTS
+const TInt KSolarTermCount( 24 );
+
+
+/**
+ * Provides Solar term dates for Lunar Calendar. 
+ *
+ * Solar term dates are listed in special binary format file. 
+ * CCalenSolarTerms reads and caches this file one year at a time.
+ *
+ *  @lib CalenLunar.dll
+ *  @since S60 v3.1
+ */
+NONSHARABLE_CLASS( CCalenSolarTerms ) : public CBase
+    {
+public:
+    static CCalenSolarTerms* NewL( RFs& aFs );
+
+    virtual ~CCalenSolarTerms();
+
+    /**
+     * Checks if date is solar term date. If it is, returns index to particular solar term, otherwise returns error code
+     * Index can be then passed to GetSolarTermNameL function. 
+     *
+     * @since S60 v3.1
+     * @param aDateTime date that is checked 
+     * @return index of solar term, if date is solar term date.
+     *         KErrNone, if date is not solar term date
+     *         KErrNotSupported, if date is outside of supported 
+     *                           range for solar term data.
+     */
+    TInt CheckSolarTermDateL( const TDateTime& aDateTime ); 
+
+
+private:
+    CCalenSolarTerms( RFs& aFs );
+
+    void ConstructL();
+
+    /** 
+     * Returns ETrue, if date fits into date range of available solar item 
+     * data.
+     * @since 3.0
+     */
+    TBool HasSolarTermDataAvailable( const TDateTime& aDate ) const;
+
+    /**
+     * Reads and caches 24 solar term dates from "SolarItems" file
+     */
+    void ReadSolarTermsL( TDateTime aDate );
+
+private: // data
+    /**
+     * File server handle.
+     */
+    RFs& iFs;
+
+    /**
+     * Year that is currently cached from file to memory
+     */
+    TInt iCachedYear;
+
+    /**
+     * Table of solar term dates for currently cached year
+     */
+    TDateTime iSolarTermDates[KSolarTermCount];
+
+    };
+
+#endif // C_CALENSOLARTERMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/loc/calenkoreanlunar.loc	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,393 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+//d:
+//l:none
+//
+#define qtn_cale_kor_lunar_date "%0U%1U/%2U"
+
+
+//d:
+//l:none
+//
+#define qtn_kor_cale_extra_row_lunar "%1U%0U%2U%0U%3U%0U%4U"
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_1 "Lunar New Year's Day"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_2 "Buddah's Birthday"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_3 "Chuseok"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_4 "Great Full Moon"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_5 "Samjit-nal"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_6 "Dano"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_7 "Yudu"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_8 "Chilwol chilseok"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_9 "Baekjung"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_10 "Jungyang"
+
+
+//d:A Korean lunar festival item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_festival_name_11 "Hansik"
+
+
+//d:Setting value. This is one of the available values of "qtn_kor_cale_lunar_calendar"
+//l:list_set_graphic_pane_t1
+//
+#define qtn_kor_cale_lunar_cale_off "Off"
+
+
+//d:Setting value. This is one of the available values of "qtn_kor_cale_lunar_calendar"
+//l:list_set_graphic_pane_t1
+//
+#define qtn_kor_cale_lunar_cale_on "On"
+
+
+//d:Setting label. The user can define whether activating or deactivating lunar calendar.
+//l:list_setting_pane_t1/opt1
+//
+#define qtn_kor_cale_lunar_calendar "Lunar calendar"
+
+
+//d:Options list item. This shows the users the lunar date as well as the corresponding gregorian date for a specific date.
+//l:list_single_pane_t1_cp2
+//
+#define qtn_kor_cale_lunar_data "Show lunar data"
+
+
+//d:Alarm offset item text of Anniversary editor form
+//l:form_field_popup_wide_pane_t1
+//
+#define qtn_kor_cale_note_alarm_offset "alarm offset"
+
+
+//d:Alarm time item text of Anniversary editor form
+//l:form_field_popup_wide_pane_t1
+//
+#define qtn_kor_cale_note_alarm_time "alarm time"
+
+
+//d:Alarm offset unit text of Anniversary editor form. Unit indicates that alarm is launched entered amount of days before the actual entry date.
+//l:form_field_popup_wide_pane_t1
+//
+#define qtn_kor_cale_note_offset_unit "days before"
+
+
+//d:Date entry type item text of Anniversary editor form
+//l:form_field_popup_wide_pane_t1
+//
+#define qtn_kor_cale_note_type "solar/lunar/leap"
+
+
+//d:Lunar calendar leap date entry text of Anniversary editor form
+//l:list_form_graphic_pane_t1
+//
+#define qtn_kor_cale_note_type_leap "Leap"
+
+
+//d:Lunar calendar date entry text of Anniversary editor form
+//l:list_form_graphic_pane_t1
+//
+#define qtn_kor_cale_note_type_lunar "Lunar"
+
+
+//d:Solar calendar leap date entry text of Anniversary editor form
+//l:list_form_graphic_pane_t1
+//
+#define qtn_kor_cale_note_type_solar "Solar"
+
+
+//d:List query heading. Heading of pop-up window that appears when a user select qtn_kor_cale_lunar_data. 
+//l:
+//
+#define qtn_kor_cale_sett_lunar_cale "Lunar calendar"
+
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_1 "New Year's Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_2 "Ind.Movement Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_3 "Children's Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_4 "Memorial Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_5 "Constitution Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_6 "Independance Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_7 "Foundation Day"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_8 "Christmas"
+
+
+//d:A Korean national anniversary item
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_anniversary_item_9 "HanGeul Day"
+
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_1 "Ipchoon"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_10 "Haji"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_11 "Soseo"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_12 "Daeseo"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_13 "Ipchoo"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_14 "Cheoseo"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_15 "Baekro"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_16 "Chooboon"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_17 "Hanro"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_18 "Sanggang"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_19 "Ipdong"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_2 "Usoo"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_20 "Soseol"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_21 "Daeseol"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_22 "Dongji"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_23 "Sohan"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_24 "Daehan"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_3 "Kyungchip"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_4 "Choonboon"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_5 "Chungmyoung"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_6 "Gogu"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_7 "Ipha"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_8 "Soman"
+
+
+//d:A Korean solar term
+//l:navi_text_pane_t1
+//
+#define qtn_kor_cale_solar_item_9 "Mangjong"
+
+
+//d:Alarm offset text in Anniversary viewer Indicates how many days before the actual entry date the alarm is launched %N is amount of days
+//l:popup_preview_text_window/opt1
+//
+#define qtn_kor_cale_viewer_alarm_offset "%N days before"
+
+//d:Alarm time and offset in Anniversary viewer %0U is the alarm time %1U is the alarm offset in days
+//l:popup_preview_text_window/opt1
+//
+#define qtn_kor_cale_viewer_alarm_offset_time "%0U, %1U"
+
+
+//d:Lunar indicator
+//l:navi_text_pane_t1
+//
+#define qtn_lunar_indicator "Lun."
+
+
+//d:Lunar indicator
+//l:navi_text_pane_t1
+//
+#define qtn_lunar_leap_year_indicator "Leap"
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/rom/KoreanCalPlugin.iby	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef KOREANCALPLUGIN_IBY
+#define KOREANCALPLUGIN_IBY
+
+#ifdef __SERIES60_LUNAR_CALENDAR
+
+#ifdef RD_CALENDAR_PLUGIN_FW
+
+#ifdef __LOCALES_65_IBY__
+
+ECOM_PLUGIN( CalenKoreanLunarPlugin.dll , CalenKoreanLunarPlugin.rsc )
+data=DATAZ_\private\10005901\KoreanSolarItems private\10005901\KoreanSolarItems
+
+// this cenrep file should be generated to image automatically by confml files but for some reason it is not so taken here
+// apparently it was generated with full s60 build so now it is removed
+//data=DATAZ_\private\10202be9\2001843E.txt private\10202be9\2001843E.txt
+
+//data=DATAZ_\resource\CalenKoreanLunarPluginData.rsc            APP_RESOURCE_DIR\CalenKoreanLunarPluginData.rsc
+
+#define USER_RESOURCE_FILES_LOCALIZED CalenKoreanLunarPluginData
+#define LANGUAGE_01
+#define LANGUAGE_65
+#include <Variant/localized_resources.iby>
+//#include <..\..\..\Variant\localized_resources.iby>
+
+#endif //__LOCALES_65_IBY__
+
+#endif /* RD_CALENDAR_PLUGIN_FW */
+
+#endif /* __SERIES60_LUNAR_CALENDAR */
+
+#endif /* KOREANCALPLUGIN_IBY */
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenExtraRowFormatter.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+#include "CalenExtraRowFormatter.h"
+
+#include <calenkoreanlunarplugindata.rsg>
+#include <aknbiditextutils.h>
+#include <badesca.h>
+#include <eikenv.h>
+#include <StringLoader.h>
+
+// CONSTANTS
+_LIT( KSeparatorFmt, "%0U" );
+const TInt KExtraRowLength = 1000;
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CollapseDuplicatesL()
+// ---------------------------------------------------------------------------
+//
+void CollapseDuplicatesL( TDes& aStr, TInt aPos, const TDesC& aSub )
+    {
+    TRACE_ENTRY_POINT;
+
+    const TInt sublen = aSub.Length();
+    if ( aStr.Length() == 0 || sublen == 0 )
+        {
+        return;
+        }
+
+    TPtrC remaining = aStr.Mid( aPos );
+    TInt fstInRemaining = remaining.Find( aSub );
+
+    if ( fstInRemaining >= 0 )
+        {
+        TInt restPos = fstInRemaining + sublen;
+        TPtrC rest = remaining.Mid( restPos );
+        TInt sndInRest = rest.Find( aSub );
+
+        // 1) two substrings found in sequence
+        if ( sndInRest == 0 )
+            {
+            // replace second substring with empty string
+            TInt fst = aPos + fstInRemaining;
+            TInt snd = aPos + restPos + sndInRest;
+            aStr.Replace( snd, sublen, KNullDesC);
+            // continue collapsing from first
+            CollapseDuplicatesL( aStr, fst, aSub );
+            }
+        // 2) substring found later in string
+        else if ( sndInRest > 0 )
+            {
+            // continue collapsing from this second substring
+            TInt snd = aPos + restPos + sndInRest;
+            CollapseDuplicatesL( aStr, snd, aSub );
+            }
+        // 3) No second substring found -> nothing to collapse
+        else
+            {
+            TRACE_EXIT_POINT;
+            return;
+            }
+        }
+    // No substring found
+    else
+        {
+        TRACE_EXIT_POINT;
+        return;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// RemoveLeadingAndTrailingL()
+// ---------------------------------------------------------------------------
+//
+void RemoveLeadingAndTrailingL( TDes& aStr, const TDesC& aSub )
+    {
+    TRACE_ENTRY_POINT;
+
+    // Trailing
+    const TInt sublen = aSub.Length();
+    if ( aStr.Right( sublen ).Find( aSub ) == 0 )
+        {
+        aStr.Replace( aStr.Length() - sublen, sublen, KNullDesC );
+        }
+
+    // Leading
+    if ( aStr.Left( sublen ).Find( aSub ) == 0 )
+        {
+        aStr.Replace( 0, sublen, KNullDesC );
+        }
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::NewL()
+// ---------------------------------------------------------------------------
+//
+CCalenExtraRowFormatter* CCalenExtraRowFormatter::NewL()
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenExtraRowFormatter* self = new (ELeave) CCalenExtraRowFormatter;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::~CCalenExtraRowFormatter()
+// ---------------------------------------------------------------------------
+//
+CCalenExtraRowFormatter::~CCalenExtraRowFormatter()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::CCalenExtraRowFormatter()
+// ---------------------------------------------------------------------------
+//
+CCalenExtraRowFormatter::CCalenExtraRowFormatter()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCalenExtraRowFormatter::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::FormatExtraRowInformationL()
+// ---------------------------------------------------------------------------
+//
+TPtrC CCalenExtraRowFormatter::FormatExtraRowInformationL(
+    CCalenLunarLocalizedInfo& aLocInfo,
+    RArray<CCalenLunarLocalizedInfo::TField>& aPrioritizedFields,
+    TInt aMaxWidth,
+    const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+    ,TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+    )
+    {
+    TRACE_ENTRY_POINT;
+
+    if ( aPrioritizedFields.Count() == 0)
+        {
+        iText = KNullDesC;
+
+        TRACE_EXIT_POINT;
+        return iText;
+        }
+
+    // Initialize substring labels
+    RArray<CCalenLunarLocalizedInfo::TField> subLabels;
+    CleanupClosePushL( subLabels );
+    subLabels.AppendL( CCalenLunarLocalizedInfo::ELunarMonthAndDay );
+    subLabels.AppendL( CCalenLunarLocalizedInfo::ELunarFestival );
+    subLabels.AppendL( CCalenLunarLocalizedInfo::ESolarFestival );
+    subLabels.AppendL( CCalenLunarLocalizedInfo::ESolarTerm );
+
+    // ASSERT that all prioritized fields can be found from subLabels
+    for ( TInt i=0; i < aPrioritizedFields.Count(); i++)
+        {
+        ASSERT( subLabels.Find( aPrioritizedFields[i] ) >= 0 );
+        }
+
+    TBool fits = EFalse;
+
+    do
+        {
+        // Initialize substring array
+        CPtrCArray* subs = new (ELeave) CPtrCArray(10);
+        CleanupStack::PushL( subs );
+        for ( TInt i = 0; i < subLabels.Count(); i++)
+            {
+            subs->AppendL( TPtrC( KNullDesC ) );
+            }
+
+        // Set wanted fields to substring array
+        for ( TInt i = 0; i < aPrioritizedFields.Count(); i++)
+            {
+            CCalenLunarLocalizedInfo::TField field = aPrioritizedFields[i];
+            TInt subIx = subLabels.Find( field );
+            // Replace
+            subs->Delete(subIx);
+            RDebug::Print( _L("A sub count  %d"), subs->Count() );
+            subs->InsertL(subIx, TPtrC( aLocInfo.GetField( field ) ) );
+            RDebug::Print( _L("B sub count %d"), subs->Count() );
+            RDebug::Print( _L("B field %S"), &(subs->At(subIx)) );
+            }
+
+        // Format all fields to extra row
+        HBufC* extraRowFmt = StringLoader::LoadLC( R_KOR_CALE_EXTRA_ROW_LUNAR ); 
+
+        RDebug::RawPrint( *extraRowFmt );
+
+        TBuf<KExtraRowLength> fmt = *extraRowFmt;
+        for ( TInt i=0; i < subLabels.Count(); i++ )
+            {
+            RDebug::Print( _L("Before Format") );
+            RDebug::RawPrint( fmt );
+            StringLoader::Format( iText,
+                                  fmt,
+                                  i + 1, // %0U is a separator
+                                  subs->At( i ) );
+            fmt = iText;
+            RDebug::Print( _L("After Format") );
+            RDebug::RawPrint( fmt );
+            }
+
+        // Now we have something like "Year of Dog%0U%0U6/11%0U%0U"
+        // First We need to remove multiple occurences of %0U
+        CollapseDuplicatesL( iText, 0, KSeparatorFmt );
+        RDebug::Print( _L("After collapse") );
+        RDebug::RawPrint( iText );
+
+        // Remove leading and trailing %0U
+        // By now, we are sure that there is max 1 %0U in the beginning
+        // and in the end of string.
+        RemoveLeadingAndTrailingL( iText, KSeparatorFmt );
+        RDebug::Print( _L("After leading and trailing removal") );
+        RDebug::RawPrint( iText );
+
+        // If there are now separators anymore, then do not fill them
+        TBool hasSeparators = iText.Find( KSeparatorFmt ) >= 0;
+
+        if ( hasSeparators )
+            {
+            // fill in separators
+            HBufC* separator = StringLoader::LoadLC( R_CALE_LUNAR_SEPARATOR );
+            fmt = iText;
+            StringLoader::Format( iText,
+                                  fmt,
+                                  0, // %0U is a separator
+                                  *separator );
+
+            RDebug::Print( _L("After separator insert") );
+            RDebug::RawPrint( iText );
+            CleanupStack::PopAndDestroy( separator );
+            }
+
+        CleanupStack::PopAndDestroy( extraRowFmt );
+        CleanupStack::PopAndDestroy( subs );
+
+        do{
+        
+        fits = TryToFitL( iText, aMaxWidth, aFont
+#ifdef RD_CALENDAR_PREVIEW
+                          , aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                          );
+        
+        if( !fits )
+        	{
+        	iText.SetLength( iText.Length()-1 );
+        	}
+        }while( !fits );
+        if ( ! fits )
+            {
+            iText = KNullDesC;
+            TInt last = aPrioritizedFields.Count() - 1;
+            if ( last >= 0 )
+                {
+                aPrioritizedFields.Remove( last );
+                }
+            }
+
+        } while ( ! fits && aPrioritizedFields.Count() );
+
+    CleanupStack::PopAndDestroy( &subLabels );
+
+    TRACE_EXIT_POINT;
+    return iText;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenExtraRowFormatter::TryToFitL()
+// ---------------------------------------------------------------------------
+//
+TBool CCalenExtraRowFormatter::TryToFitL( const TDesC& aStr, TInt aMaxWidth, const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+                                          , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                          )
+    {
+    TRACE_ENTRY_POINT;
+#ifdef RD_CALENDAR_PREVIEW
+    TBool result(EFalse);
+    if(aTwoLines)
+        {
+        CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>( 3 );
+        CleanupStack::PushL( textLines );
+
+        CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 1 );
+        CleanupStack::PushL( lineWidths );
+
+        lineWidths->AppendL( aMaxWidth );
+
+        HBufC* visualText = AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL(
+            aStr,
+            *lineWidths,
+            aFont,
+            *textLines);
+
+        result = (textLines->Count() <= 2);
+
+        CleanupStack::PopAndDestroy( lineWidths );
+        CleanupStack::PopAndDestroy( textLines );
+        delete visualText;
+        }
+    else
+        {
+        CFont::TMeasureTextInput::TFlags logicalOrder = static_cast<CFont::TMeasureTextInput::TFlags>(0);
+        TInt textW = AknBidiTextUtils::MeasureTextBoundsWidth( aFont, aStr, logicalOrder );
+        result = (textW <= aMaxWidth);
+        }
+    TRACE_EXIT_POINT;
+    return result;
+#else
+    CFont::TMeasureTextInput::TFlags logicalOrder = static_cast<CFont::TMeasureTextInput::TFlags>(0);
+    TInt textW = AknBidiTextUtils::MeasureTextBoundsWidth( aFont, aStr, logicalOrder );
+    TRACE_EXIT_POINT;
+    return ( textW <= aMaxWidth );
+#endif
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenKoreanLunarPlugin.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,647 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenKoreanLunarPlugin.h"
+#include "CalenLunarInfoProvider.h"
+#include "CalenLunarLocalizedInfo.h"
+#include "CalenLunarLocalizer.h"
+#include "CalenLunarPanic.h"
+#include <CalenKoreanLunarPluginData.rsg>
+#include "CalenLunarSettingItem.h"
+#include "CalenKoreanLunarPrivateCRKeys.h"
+#include "CleanupResetAndDestroy.h"
+
+//system includes
+#include <AknMessageQueryDialog.h>
+#include <data_caging_path_literals.hrh>
+#include <eikenv.h>
+#include <eikmenup.h>
+#include <eiklabel.h>
+#include <CentralRepository.h>
+#include <StringLoader.h>
+#include <AknUtils.h>
+#include <aknsutils.h>
+#include <aknbiditextutils.h>
+#include <CalendarConverter.h>
+
+// CONSTANTS
+_LIT( KResourceDrive, "z:" );
+_LIT( KFieldSeparator, "\n" );
+_LIT( KHeaderSeparator, "\n  ");
+_LIT( KResourceFile, "CalenKoreanLunarPluginData.rsc" );
+const TInt KFieldCount = 2;
+#define KResourcePath KDC_RESOURCE_FILES_DIR
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CreateKoreanPluginL()
+// -----------------------------------------------------------------------------
+//
+CCalenKoreanLunarPlugin* CCalenKoreanLunarPlugin::CreateKoreanPluginL( 
+        MCalenServices* aServices )
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenKoreanLunarPlugin* plugin = new (ELeave) CCalenKoreanLunarPlugin( 
+            KCalenKoreanPluginEnabled, aServices );
+    CleanupStack::PushL( plugin );
+    plugin->ConstructL();
+    plugin->SetLunarLocalizerL();
+    CleanupStack::Pop( plugin );
+
+    TRACE_EXIT_POINT;
+    return plugin;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::~CCalenKoreanLunarPlugin()
+// -----------------------------------------------------------------------------
+//
+CCalenKoreanLunarPlugin::~CCalenKoreanLunarPlugin()
+    {
+    TRACE_ENTRY_POINT;
+    
+    // Deregister services
+    if ( iServices )
+        {
+        iServices->CancelNotifications( this );
+        iServices->Release();
+        }
+    
+    delete iLocInfo;
+    delete iInfoProvider;
+    if ( iLocalizer != NULL )
+        delete iLocalizer;
+
+    iResourceLoader.Close();    
+    delete iLabel;    
+    delete iConverter;
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CCalenKoreanLunarPlugin()
+// -----------------------------------------------------------------------------
+//
+CCalenKoreanLunarPlugin::CCalenKoreanLunarPlugin(
+        TUint32 aCenRepLunarEnabledId, MCalenServices* aServices )
+    : iLocalizer( NULL ),
+      iResourceLoader( *( CEikonEnv::Static() ) ),
+      iCenRepLunarEnabledId( aCenRepLunarEnabledId ),
+      iServices( aServices )
+
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::SetLunarLocalizerL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::SetLunarLocalizerL()
+    {
+    TRACE_ENTRY_POINT;
+
+    iLocalizer = CCalenLunarLocalizer::NewL();
+
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CustomPreviewPaneL()
+// -----------------------------------------------------------------------------
+//
+MCalenPreview* CCalenKoreanLunarPlugin::CustomPreviewPaneL( TRect& aRect )
+	{
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+
+    TFileName resource( KResourceDrive );
+    resource.Append( KResourcePath );
+    resource.Append( KResourceFile );
+
+    TInt err( iResourceLoader.Open( resource ) );
+    __ASSERT_ALWAYS( err == KErrNone, Panic( EPanicLunarResourceLoading ) );
+
+    LoadEnabledStatusL();
+
+    iInfoProvider = CCalenLunarInfoProvider::NewL( CEikonEnv::Static()->FsSession() );
+    iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged );
+	iServices->GetCommandRange( iStart, iEnd );    
+	iConverter = CKoreanCalConv::NewL();
+	
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::GetCustomViewsL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::GetCustomViewsL( RPointerArray<CCalenView>& 
+    /*aCustomViewArray*/ )
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::GetCustomSettingsL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::GetCustomSettingsL( 
+    RPointerArray<CAknSettingItem>& /*aCustomSettingArray*/ )
+	{
+    TRACE_ENTRY_POINT;   
+    TRACE_EXIT_POINT;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::InfobarL()
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CCalenKoreanLunarPlugin::InfobarL( const TRect& aRect )
+	{
+	TRACE_ENTRY_POINT;
+	
+	if ( !iLabel )
+        {
+        iLabel = new ( ELeave ) CEikLabel;
+        }
+	iRect = aRect;
+    FormatExtraRowStringL( *iLabel );
+    iLabel->SetTextL( iExtraRowText );
+    iLabel->SetRect( aRect );
+    iLabel->SetLabelAlignment( ELayoutAlignCenter );
+    
+    if ( !GetColor() )
+        iLabel->OverrideColorL( EColorLabelText, iSkinColor ); 
+    
+    TRACE_EXIT_POINT;
+    return iLabel;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::InfobarL()
+// -----------------------------------------------------------------------------
+//
+const TDesC& CCalenKoreanLunarPlugin::InfobarL()
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	return iExtraRowText;	
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::GetColor()
+// -----------------------------------------------------------------------------
+//
+TInt CCalenKoreanLunarPlugin::GetColor()
+    {
+    TRACE_ENTRY_POINT;
+    // Query the text colour based on the theme
+    TInt err = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), iSkinColor,
+				KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
+    
+    TRACE_EXIT_POINT;
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::PreviewPaneL()
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CCalenKoreanLunarPlugin::PreviewPaneL( TRect& aRect )
+	{
+    TRACE_ENTRY_POINT;
+
+   
+	if (iLabel)
+	    {
+		delete iLabel;
+		iLabel = NULL;
+	    }
+
+    
+    if ( !iLabel )
+        {
+        iLabel = new ( ELeave ) CEikLabel;
+        }
+    FormatExtraRowStringL( *iLabel
+	#ifdef RD_CALENDAR_PREVIEW
+							   , EFalse
+	#endif // RD_CALENDAR_PREVIEW
+							   );
+    iLabel->SetTextL( iExtraRowText );
+    iLabel->SetRect( aRect );
+    iLabel->SetLabelAlignment( ELayoutAlignCenter );
+    
+    if ( !GetColor() )
+    	iLabel->OverrideColorL( EColorLabelText, iSkinColor );
+
+	TRACE_EXIT_POINT;
+	return iLabel;	
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::RemoveViewsFromCycle()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::RemoveViewsFromCycle( RArray<TInt>& /*aViews*/ )
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CustomiseMenuPaneL()
+// -----------------------------------------------------------------------------
+//
+TBool CCalenKoreanLunarPlugin::CustomiseMenuPaneL( TInt aResourceId, 
+    CEikMenuPane* aMenuPane )
+	{	
+	TRACE_ENTRY_POINT;
+	
+	if ( iLunarEnabled )
+		{
+		CEikMenuPaneItem* item = new ( ELeave ) CEikMenuPaneItem();
+		CleanupStack::PushL( item );
+		item->iData.iCommandId = iStart;
+	
+		HBufC* tmp = StringLoader::LoadLC( R_CALENDAR_SHOW_LUNAR_DATA );
+		item->iData.iText = *tmp;
+		CleanupStack::PopAndDestroy( tmp );
+	
+		item->iData.iCascadeId = 0;
+		item->iData.iFlags = 0;
+		
+		TInt pos = aMenuPane->NumberOfItemsInPane()-2;
+		if ( pos < 1 )
+			{
+			pos = 1;
+			}
+		
+		aMenuPane->InsertMenuItemL( item->iData, pos );
+		
+		CleanupStack::Pop( item );
+		return ETrue;
+		}
+	TRACE_EXIT_POINT;
+	return EFalse;		
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CanBeEnabledDisabled()
+// -----------------------------------------------------------------------------
+//
+TBool CCalenKoreanLunarPlugin::CanBeEnabledDisabled()
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    return ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CalenCustomisationExtensionL()
+// -----------------------------------------------------------------------------
+//
+TAny* CCalenKoreanLunarPlugin::CalenCustomisationExtensionL( TUid aExtensionUid )
+	{
+    TRACE_ENTRY_POINT;
+	TRACE_EXIT_POINT;
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CommandHandlerL()
+// -----------------------------------------------------------------------------
+//
+MCalenCommandHandler* CCalenKoreanLunarPlugin::CommandHandlerL( TInt aCommand )
+	{
+    TRACE_ENTRY_POINT;   
+    
+	if ( aCommand == iStart )
+		{
+		return this;
+		}
+	else
+		{
+		return NULL;
+		}
+	
+	TRACE_EXIT_POINT;  
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::HandleCommandL()
+// -----------------------------------------------------------------------------
+//
+TBool CCalenKoreanLunarPlugin::HandleCommandL( const TCalenCommand& aCommand )
+	{
+	TRACE_ENTRY_POINT;
+
+	TInt command( aCommand.Command() );
+	if ( command == iStart )
+		{
+		ShowDetailsL();
+		}
+	TRACE_EXIT_POINT;
+	return EFalse;		
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::CalenCommandHandlerExtensionL()
+// -----------------------------------------------------------------------------
+//
+TAny* CCalenKoreanLunarPlugin::CalenCommandHandlerExtensionL( TUid aExtensionUid )
+	{
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;  
+	return NULL;	
+	}
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::HandleNotification()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::HandleNotification( 
+    const TCalenNotification aNotification )
+	{
+	TRACE_ENTRY_POINT;
+
+    if ( aNotification == ECalenNotifyContextChanged )
+        {
+        TRAP_IGNORE( UpdateInfoBarL() );
+        }
+
+	TRACE_EXIT_POINT;
+	}
+
+// -----------------------------------------------------------------------------
+// GetCenRepIntL()
+// -----------------------------------------------------------------------------
+//
+TInt GetCenRepIntL( const TUid& aCRUid, TInt aKeyId )
+    {
+    TRACE_ENTRY_POINT;
+
+    CRepository* repository = CRepository::NewL( aCRUid );
+    CleanupStack::PushL( repository );
+    TInt tmp = 0;
+    TInt err = repository->Get( aKeyId, tmp );
+    if ( err == KErrNotFound )
+        {
+        tmp = 0;
+        }
+    else
+        {
+        User::LeaveIfError( err );
+        }
+    CleanupStack::PopAndDestroy( repository );
+
+    TRACE_EXIT_POINT;
+    return tmp;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::LoadEnabledStatusL()
+// -----------------------------------------------------------------------------
+//
+TBool CCalenKoreanLunarPlugin::LoadEnabledStatusL()
+    {
+    TRACE_ENTRY_POINT;
+
+    TInt enabled = 0;
+    TRAPD( err, enabled = GetCenRepIntL( KCRUidCalenKoreanPlugin, iCenRepLunarEnabledId ) );
+    if ( err == KErrNone )
+        {
+        iLunarEnabled = static_cast<TBool>( enabled );
+        }
+    else
+        {
+        iLunarEnabled = ETrue;
+        }
+    
+    TRACE_EXIT_POINT;
+    return iLunarEnabled;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::StoreEnabledStatusL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::StoreEnabledStatusL( TBool aEnabled )
+    {
+    TRACE_ENTRY_POINT;
+
+    CRepository* repository = CRepository::NewL( KCRUidCalenKoreanPlugin );
+    CleanupStack::PushL( repository );
+
+    User::LeaveIfError( repository->Set( iCenRepLunarEnabledId, 
+            static_cast<TInt>( aEnabled ) ) );
+    CleanupStack::PopAndDestroy( repository );
+
+    iLunarEnabled = aEnabled;
+
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::FormatExtraRowStringL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::FormatExtraRowStringL( CEikLabel& aLabel
+#ifdef RD_CALENDAR_PREVIEW
+                                               , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                               )
+    {
+    TRACE_ENTRY_POINT;
+
+    // added hero to have always lates date
+	TTime focusTime = iServices->Context().FocusDateAndTimeL().TimeLocalL();	
+    TCalenLunarInfo info = iInfoProvider->GetLunarInfoL( focusTime );
+    
+    if ( iLocInfo )
+        {
+        delete iLocInfo;
+        iLocInfo = NULL;
+        }
+    
+	iLocInfo = iLocalizer->LocalizeL( info );
+    // add end	
+	
+    const CFont* font = NULL;
+    font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont, NULL );    
+    aLabel.SetFont( font );
+    
+    TInt maxWidth = iRect.Size().iWidth;
+    
+    if ( font && iLocInfo )
+        {
+        iExtraRowText.Set( iLocalizer->GetExtraRowTextL( *iLocInfo,
+                                                         maxWidth,
+                                                         *font
+#ifdef RD_CALENDAR_PREVIEW
+                                                         , aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                                         ) );
+        }
+    else
+        {
+        iExtraRowText.Set( KNullDesC );
+        }
+
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::ShowDetailsL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::ShowDetailsL( )
+    {
+    TRACE_ENTRY_POINT;
+
+    HBufC* msg = HBufC::NewLC( 1000 );
+
+    if ( iLocInfo )
+        {
+        // Headers
+        TInt headerIds[KFieldCount] = {
+            R_CALENDAR_LUNAR_INFO_DATE,
+            R_CALENDAR_LUNAR_INFO_WESTERN_DATE
+            };
+
+        RPointerArray<HBufC> headers;
+        CleanupResetAndDestroyPushL( headers );
+
+        for ( TInt i = 0; i < KFieldCount; i++ )
+            {
+            headers.Append( StringLoader::LoadL( headerIds[i] ) );
+            }
+
+        CPtrCArray* fields = new ( ELeave ) CPtrCArray( KFieldCount );
+        CleanupStack::PushL( fields );
+        fields->AppendL( iLocInfo->LunarMonthAndDay() );
+        fields->AppendL( iLocInfo->GregorianDate() );
+
+        for ( TInt i = 0; i < KFieldCount; i++ )
+            {
+            TPtrC field = fields->At( i );
+            if ( field != KNullDesC )
+                {
+                msg->Des().Append( *( headers[i] ) );
+                msg->Des().Append( KHeaderSeparator );
+                msg->Des().Append( field );
+                if ( i < KFieldCount - 1 ) // not last
+                    {
+                    msg->Des().Append( KFieldSeparator );
+                    }
+                }
+            }
+        CleanupStack::PopAndDestroy( fields );
+        CleanupStack::PopAndDestroy( &headers );
+        }
+
+    TPtrC ptr( *msg );
+    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( ptr );
+    CleanupStack::PushL( dlg );
+    dlg->PrepareLC( R_CALEN_LUNAR_DETAILS_DIALOG );
+    CleanupStack::Pop( dlg );
+
+    dlg->RunLD();
+    CleanupStack::PopAndDestroy( msg );
+
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::DateTimeToKoreanL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::DateTimeToKoreanL( const TDateTime& aDateTime, 
+    TKoreanDate& aKoreanDate )
+    {
+    TRACE_ENTRY_POINT;
+    iConverter->DateTimeToKoreanL( aDateTime, aKoreanDate );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::KoreanToDateTimeL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::KoreanToDateTimeL( TKoreanDate& aKoreanDate, 
+    TDateTime& aDateTime )
+    {
+    TRACE_ENTRY_POINT;
+    iConverter->KoreanToDateTimeL( aKoreanDate, aDateTime );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::DateRange()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::DateRange( TDateTime& aLower, TDateTime& aUpper )
+    {
+    TRACE_ENTRY_POINT;
+    iConverter->DateRange( aLower, aUpper );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::DateRange()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::DateRange( TKoreanDate& aLower, TKoreanDate& aUpper )
+    {
+    TRACE_ENTRY_POINT;
+    iConverter->DateRange( aLower, aUpper );
+    TRACE_EXIT_POINT;
+    }
+
+// -----------------------------------------------------------------------------
+// CCalenKoreanLunarPlugin::UpdateInfoBarL()
+// -----------------------------------------------------------------------------
+//
+void CCalenKoreanLunarPlugin::UpdateInfoBarL()
+    {
+    TRACE_ENTRY_POINT;
+      
+    if ( iLabel )
+        {
+        FormatExtraRowStringL( *iLabel );
+        iLabel->SetTextL( iExtraRowText );
+        }
+        
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarInfo.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenLunarInfo.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// TCalenLunarInfo::HasLunarFestival()
+// ---------------------------------------------------------------------------
+//
+TBool TCalenLunarInfo::HasLunarFestival()
+    {
+    TRACE_ENTRY_POINT;
+
+    TRACE_EXIT_POINT;
+    return iLunarFestival >= 0;
+    }
+
+// ---------------------------------------------------------------------------
+// TCalenLunarInfo::HasSolarFestival()
+// ---------------------------------------------------------------------------
+//
+TBool TCalenLunarInfo::HasSolarFestival()
+    {
+    TRACE_ENTRY_POINT;
+
+    TRACE_EXIT_POINT;
+    return iSolarFestival >= 0;
+    }
+
+// ---------------------------------------------------------------------------
+// TCalenLunarInfo::HasSolarTerm()
+// ---------------------------------------------------------------------------
+//
+TBool TCalenLunarInfo::HasSolarTerm()
+    {
+    TRACE_ENTRY_POINT;
+
+    TRACE_EXIT_POINT;
+    return iSolarTerm >= 0;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarInfoProvider.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,279 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenLunarInfoProvider.h"
+#include "CalenLunarInfo.h"
+#include "CalenSolarTerms.h"
+#include <calendarconverter.h>
+#include "CalenKoreanLunarPlugin.h"
+#include "KoreanCalConv.h"
+
+// CONSTANTS
+const TInt KDaysInJanuary = 31; // total day count of January
+const TInt KDaysInMarch = 31; // total day count of January
+const TInt KDaysInDecemberAfterWinterSolstice = 10; // day count of December starting from winter solstice (21.12)
+const TInt K105thDayAfterWinterSolstice = 105;
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// TCalenLunarInfo::TLunarFestival()
+// ---------------------------------------------------------------------------
+//
+static TCalenLunarInfo::TLunarFestival KoreanLunarFestival(
+    const TKoreanDate& aDate,
+    const TKoreanDate& aNextDate,
+    const TTime& aDay )
+    {
+    TRACE_ENTRY_POINT;
+ 
+    TCalenLunarInfo::TLunarFestival index = TCalenLunarInfo::ENoFestival;
+    
+    if (!aDate.iLeapMonth)
+        {
+        if (aDate.iMonth == 4 && aDate.iDay == 8)
+            {
+            index = TCalenLunarInfo::EFestivalBuddhaBirthDay;
+            }
+        else if (aDate.iMonth == 8 && aDate.iDay == 15)
+            {
+            index = TCalenLunarInfo::EFestivalHarvest;
+            }
+        else if(aDate.iMonth == 1 && aDate.iDay == 15)
+            {            
+            // full moon day
+            index = TCalenLunarInfo::EFestivalFullMoonDay;            
+            }
+        else if(aDate.iMonth == 3 && aDate.iDay == 3)
+            {            
+            // 3rd of March festival
+            index = TCalenLunarInfo::EFestival3rdMarchDay;
+            }
+        else if(aDate.iMonth == 5 && aDate.iDay == 5)
+            {            
+            // dano festival
+            index = TCalenLunarInfo::EFestivalDano;
+            }
+        else if(aDate.iMonth == 6 && aDate.iDay == 15)
+            {            
+            // ?? festival
+            index = TCalenLunarInfo::EFestivalUnknown_1;
+            }                
+        else if(aDate.iMonth == 7 && aDate.iDay == 7)
+            {            
+            // 7th of July festival
+            index = TCalenLunarInfo::EFestival7thJulyDay;
+            }
+        else if(aDate.iMonth == 7 && aDate.iDay == 15)
+            {            
+            // ?? festival
+            index = TCalenLunarInfo::EFestivalUnknown_2;
+            }        
+        else if(aDate.iMonth == 9 && aDate.iDay == 9)
+            {            
+            // ?? festival
+            index = TCalenLunarInfo::EFestivalUnknown_3;
+            }
+        else
+        	{
+            TDateTime date = aDay.DateTime();
+            TMonth month = date.Month();
+            TInt day = date.Day();
+            TInt year = date.Year();
+            
+            if( month == EApril )
+            	{
+            	// Check if it's 105th hay after Dong Shi (winter solstice)
+            	TInt daysInFebruary;
+            	if(year%4 == 0)
+            		{
+            		// leap year
+            		daysInFebruary = 29;
+            		}
+            	else
+            		{
+            		daysInFebruary = 28;
+            		}
+            	
+            	// we need to count dates beginning from winter soltice (21.22) till end of march
+            	TInt daysBeforeApril = 
+            	    KDaysInDecemberAfterWinterSolstice + KDaysInJanuary + daysInFebruary + KDaysInMarch;
+            	
+            	if( daysBeforeApril + day == K105thDayAfterWinterSolstice )
+            		{
+            		index = TCalenLunarInfo::EFestival105thDayAfterWS;
+            		}
+            	}
+        	}   
+        }
+    if (!aNextDate.iLeapMonth &&
+        aDate.iMonth == 1 && aDate.iDay == 1)
+        {
+        index = TCalenLunarInfo::EFestivalNewYearDay;
+        }
+
+    TRACE_EXIT_POINT;
+    return index;
+    }
+
+// ---------------------------------------------------------------------------
+// TCalenLunarInfo::TSolarFestival()
+// ---------------------------------------------------------------------------
+//
+static TCalenLunarInfo::TSolarFestival KoreanSolarFestival(
+    const TTime& aDay )
+    {
+    TRACE_ENTRY_POINT;
+
+    TCalenLunarInfo::TSolarFestival index = TCalenLunarInfo::ENoSolarFestival;
+
+    TDateTime date = aDay.DateTime();
+    TMonth month = date.Month();
+    TInt day = date.Day();
+
+    if( month == EJanuary && day == 0 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalNewYearDay;
+        }
+    else if( month == EMarch && day == 0 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalIndependenceMovement;
+        }
+    else if( month == EMay && day == 4 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalChildrensDay;
+        }
+    else if( month == EJune && day == 5 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalMemorialDay;
+        }
+    else if( month == EJuly && day == 16 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalConstitutionDay;
+        }
+    else if( month == EAugust && day == 14 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalLiberationDay;
+        }
+    else if( month == EOctober && day == 2 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalFoundationDay;
+        }
+    else if( month == EDecember && day == 24 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalChristmasDay;
+        }   
+    else if( month == EOctober && day == 8 )
+        {
+        index = TCalenLunarInfo::ESolarFestivalHangulDay;
+        }  
+    TRACE_EXIT_POINT;
+    return index;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarInfoProvider::NewL()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarInfoProvider* CCalenLunarInfoProvider::NewL( RFs& aFs )
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenLunarInfoProvider* self = new (ELeave) CCalenLunarInfoProvider();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFs);
+    CleanupStack::Pop(self);
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarInfoProvider::~CCalenLunarInfoProvider()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarInfoProvider::~CCalenLunarInfoProvider()
+    {
+    TRACE_ENTRY_POINT;
+
+    delete iSolarTerms;
+    delete iConverter;
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarInfoProvider::CCalenLunarInfoProvider()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarInfoProvider::CCalenLunarInfoProvider()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarInfoProvider::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarInfoProvider::ConstructL( RFs& aFs )
+    {
+    TRACE_ENTRY_POINT;
+
+    iConverter = CKoreanCalConv::NewL();
+    iSolarTerms = CCalenSolarTerms::NewL( aFs );
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarInfoProvider::GetLunarInfoL()
+// ---------------------------------------------------------------------------
+//
+TCalenLunarInfo CCalenLunarInfoProvider::GetLunarInfoL( const TTime& aDay )
+    {
+    TRACE_ENTRY_POINT;
+
+    TDateTime dayDt = aDay.DateTime();
+
+    TTime nextDay = aDay + TTimeIntervalDays(1);
+    TDateTime nextDayDt = nextDay.DateTime();
+
+    TKoreanDate koreanDate;
+    TKoreanDate nextKoreanDate;
+
+    iConverter->DateTimeToKoreanL(dayDt, koreanDate);
+    iConverter->DateTimeToKoreanL(nextDayDt, nextKoreanDate);
+
+
+    TCalenLunarInfo info;
+    info.iLunarDate = koreanDate;
+    info.iGregorianDate = aDay;
+    info.iLunarFestival = KoreanLunarFestival( koreanDate, nextKoreanDate, aDay);
+    info.iSolarFestival = KoreanSolarFestival( aDay );
+    info.iSolarTerm = iSolarTerms->CheckSolarTermDateL( dayDt );
+    
+    TRACE_EXIT_POINT;
+    return info;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarLocalizedInfo.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenLunarLocalizedInfo.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizedInfo::NewL()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizedInfo* CCalenLunarLocalizedInfo::NewL()
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenLunarLocalizedInfo* self = new (ELeave) CCalenLunarLocalizedInfo;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizedInfo::~CCalenLunarLocalizedInfo()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizedInfo::~CCalenLunarLocalizedInfo()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizedInfo::CCalenLunarLocalizedInfo()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizedInfo::CCalenLunarLocalizedInfo()
+    {
+    TRACE_ENTRY_POINT;
+
+    iLunarFestival.Set( KNullDesC );
+    iSolarFestival.Set( KNullDesC );
+    iSolarTerm.Set( KNullDesC );
+    iLunarMonthAndDay = KNullDesC;
+    iGregorianDate = KNullDesC;
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizedInfo::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarLocalizedInfo::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizedInfo::GetField()
+// ---------------------------------------------------------------------------
+//
+const TDesC& CCalenLunarLocalizedInfo::GetField( TField aField )
+    {
+    TRACE_ENTRY_POINT;
+
+    switch ( aField )
+        {
+        case ELunarFestival:      return LunarFestival();
+        case ESolarFestival:      return SolarFestival();
+        case ESolarTerm:          return SolarTerm();
+        case ELunarMonthAndDay:   return LunarMonthAndDay();
+        case EGregorianDate:      return GregorianDate();
+        default:
+            ASSERT( EFalse );
+            return KNullDesC;
+        }
+
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarLocalizer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,212 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+#include "CalenLunarLocalizer.h"
+#include "CalenLunarInfo.h"
+#include "CalenLunarLocalizedInfo.h"
+#include "CalenExtraRowFormatter.h"
+#include <calenkoreanlunarplugindata.rsg>
+
+//system includes
+#include <aknbiditextutils.h>
+#include <avkon.rsg>
+#include <badesca.h>
+#include <eikenv.h>
+#include <StringLoader.h>
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::NewL()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizer* CCalenLunarLocalizer::NewL()
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenLunarLocalizer* self = new (ELeave) CCalenLunarLocalizer;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::~CCalenLunarLocalizer()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizer::~CCalenLunarLocalizer()
+    {
+    TRACE_ENTRY_POINT;
+
+    delete iLunarFestivalNames;
+    delete iSolarFestivalNames;
+    delete iSolarTermNames;
+    delete iGregorianDateFormat;
+    delete iRowFormatter;
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::CCalenLunarLocalizer()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizer::CCalenLunarLocalizer() : iEikEnv( CEikonEnv::Static() )
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarLocalizer::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+
+    iRowFormatter = CCalenExtraRowFormatter::NewL();
+
+    iLunarFestivalNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_KOR_FESTIVALS);
+    iSolarFestivalNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_KOR_SOLAR_ANNIVERSARY_ITEMS);
+    iSolarTermNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_KOR_SOLAR_ITEMS);
+    iGregorianDateFormat = StringLoader::LoadL(R_QTN_DATE_USUAL_WITH_ZERO);
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::LocalizeL()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarLocalizedInfo* CCalenLunarLocalizer::LocalizeL( TCalenLunarInfo& aInfo )
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenLunarLocalizedInfo* localized = CCalenLunarLocalizedInfo::NewL();
+    CleanupStack::PushL( localized );
+
+    if ( aInfo.HasLunarFestival() )
+        {
+        localized->iLunarFestival.Set( iLunarFestivalNames->MdcaPoint( aInfo.iLunarFestival ) );
+        }
+
+    if ( aInfo.HasSolarFestival() )
+        {
+        localized->iSolarFestival.Set( iSolarFestivalNames->MdcaPoint( aInfo.iSolarFestival ) );
+        }
+
+    if ( aInfo.HasSolarTerm() )
+        {
+        localized->iSolarTerm.Set( iSolarTermNames->MdcaPoint( aInfo.iSolarTerm ) );
+        }
+
+    LocalizeMonthAndDayL(localized, aInfo);
+
+    aInfo.iGregorianDate.FormatL( localized->iGregorianDate,
+                                 *iGregorianDateFormat );
+    CleanupStack::Pop( localized );
+
+    TRACE_EXIT_POINT;
+    return localized;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::GetExtraRowTextL()
+// ---------------------------------------------------------------------------
+//
+TPtrC CCalenLunarLocalizer::GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo, 
+        TInt aMaxWidth, const CFont& aFont
+#ifdef RD_CALENDAR_PREVIEW
+                                              , TBool aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                              )
+    {
+    TRACE_ENTRY_POINT;
+
+    RArray<CCalenLunarLocalizedInfo::TField> fields;
+    CleanupClosePushL( fields );
+
+    fields.AppendL( CCalenLunarLocalizedInfo::ELunarMonthAndDay );  //1st priority
+    fields.AppendL( CCalenLunarLocalizedInfo::ESolarFestival );     //2nd priority
+    fields.AppendL( CCalenLunarLocalizedInfo::ELunarFestival );     //3rd priority
+    fields.AppendL( CCalenLunarLocalizedInfo::ESolarTerm );         //4th priority
+
+    TPtrC text = iRowFormatter->FormatExtraRowInformationL( aLocInfo, fields, aMaxWidth, aFont
+#ifdef RD_CALENDAR_PREVIEW
+                                                            , aTwoLines
+#endif // RD_CALENDAR_PREVIEW
+                                                            );
+    CleanupStack::PopAndDestroy( &fields );
+
+    TRACE_EXIT_POINT;
+    return text;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarLocalizer::LocalizeMonthAndDayL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarLocalizer::LocalizeMonthAndDayL( CCalenLunarLocalizedInfo* aLocInfo,
+        TCalenLunarInfo& aInfo )
+    {
+    TRACE_ENTRY_POINT;
+    
+    TInt dateResource = R_CALE_KOR_LUNAR_DATE;    
+    HBufC* lunar_indicator_year = StringLoader::LoadLC( R_CALE_KOR_LUNAR_INDICATOR );    
+    HBufC* lunar_leap_year = StringLoader::LoadLC( R_CALE_KOR_LEAP_YEAR_INDICATOR );
+
+    TBuf16<2> month;
+    TBuf16<2> day;
+    HBufC* lunar_indicator_buf = HBufC::NewLC(lunar_indicator_year->Length()+lunar_leap_year->Length());
+    lunar_indicator_buf->Des().Append(*lunar_indicator_year);
+    TPtr lunar_indicator = lunar_indicator_buf->Des(); 
+        
+    if ( aInfo.iLunarDate.iLeapMonth )
+        {
+        lunar_indicator.Append(*lunar_leap_year);
+        }
+
+    month.AppendNum( aInfo.iLunarDate.iMonth );
+    day.AppendNum( aInfo.iLunarDate.iDay );
+
+    CPtrCArray* monthAndDaySubs = new (ELeave) CPtrCArray(3);
+    CleanupStack::PushL( monthAndDaySubs );
+
+    monthAndDaySubs->AppendL( lunar_indicator );
+    monthAndDaySubs->AppendL( month );
+    monthAndDaySubs->AppendL( day );
+
+    HBufC* tmp = StringLoader::LoadLC( dateResource, *monthAndDaySubs );
+    aLocInfo->iLunarMonthAndDay = *tmp;
+    CleanupStack::PopAndDestroy( tmp );
+    CleanupStack::PopAndDestroy( monthAndDaySubs );
+    
+    CleanupStack::PopAndDestroy( lunar_indicator_buf );
+    CleanupStack::PopAndDestroy( lunar_leap_year );
+    CleanupStack::PopAndDestroy( lunar_indicator_year ); 
+    
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarPluginProxy.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenLunarPluginUids.hrh"
+#include "CalenKoreanLunarPlugin.h"
+
+//system includes
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// ---------------------------------------------------------------------------
+// ImplementationTable()
+// ---------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( CALENKOREANLUNARPLUGIN_IMPLEMENTATION_UID,
+                                CCalenKoreanLunarPlugin::CreateKoreanPluginL )
+    };
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy()
+// This should be only exported function of ECom plugin DLL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    TRACE_ENTRY_POINT;
+
+    aTableCount = sizeof( ImplementationTable) / sizeof(TImplementationProxy);
+
+    TRACE_EXIT_POINT;
+    return ImplementationTable;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenLunarSettingItem.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+//User includes
+#include "CalenLunarSettingItem.h"
+#include "CalenKoreanLunarPlugin.h"
+
+//system includes
+#include <CalenKoreanLunarPluginData.rsg>
+#include <StringLoader.h>
+
+const TInt KLunarSettingItemId = 55000; //FIXME does this has to be globally unique ?
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CCalenLunarSettingItem::NewLC()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarSettingItem* CCalenLunarSettingItem::NewLC( TInt aOrdinal, 
+        CCalenKoreanLunarPlugin& aPlugin )
+    {
+    TRACE_ENTRY_POINT;
+
+    CCalenLunarSettingItem* self = new (ELeave) CCalenLunarSettingItem( aPlugin );
+    CleanupStack::PushL(self);
+    // Construct setting item with parametrized values
+    HBufC* itemTitle = StringLoader::LoadLC(R_CALEN_LUNAR_SETTING_TITLE2);
+    self->ConstructL( EFalse, aOrdinal, *itemTitle, NULL,
+              R_CALEN_LUNAR_SETTING_PAGE, EAknCtPopupSettingList,
+              NULL, R_CALEN_LUNAR_SETTING_TEXTS);
+    CleanupStack::PopAndDestroy( itemTitle );
+    // no pop, because this is NewLC
+
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarSettingItem::CCalenLunarSettingItem()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarSettingItem::CCalenLunarSettingItem( CCalenKoreanLunarPlugin& aPlugin )
+    : CAknBinaryPopupSettingItem( KLunarSettingItemId, iLunarEnabled ),
+      iPlugin( aPlugin )
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarSettingItem::~CCalenLunarSettingItem()
+// ---------------------------------------------------------------------------
+//
+CCalenLunarSettingItem::~CCalenLunarSettingItem()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarSettingItem::StoreL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarSettingItem::StoreL()
+    {
+    TRACE_ENTRY_POINT;
+
+    CAknBinaryPopupSettingItem::StoreL();
+    iPlugin.StoreEnabledStatusL( iLunarEnabled );
+
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenLunarSettingItem::LoadL()
+// ---------------------------------------------------------------------------
+//
+void CCalenLunarSettingItem::LoadL()
+    {
+    TRACE_ENTRY_POINT;
+
+    iLunarEnabled = iPlugin.LoadEnabledStatusL();
+    CAknBinaryPopupSettingItem::LoadL();
+
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/regionalplugins/KoreanLunar/src/CalenSolarTerms.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+*  Description : Class looking after alarm fields for forms.
+*
+*/
+
+//debug
+#include "calendarui_debug.h"
+
+//user includes
+#include "CalenSolarTerms.h"
+#include "CalenLunarPaths.h"
+
+//system includes
+#include <f32file.h>
+#include <s32file.h>
+
+
+// CONSTANTS
+_LIT( KSolarTermsFile, "KoreanSolarItems" );
+const TInt KFirstSolarTermYear( 1900 );
+const TInt KLastSolarTermYear( 2100 );
+
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::NewL()
+// ---------------------------------------------------------------------------
+//
+CCalenSolarTerms* CCalenSolarTerms::NewL( RFs& aFs )
+    {
+    TRACE_ENTRY_POINT;
+    
+    CCalenSolarTerms* self = new (ELeave) CCalenSolarTerms(aFs);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    TRACE_EXIT_POINT;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::~CCalenSolarTerms()
+// ---------------------------------------------------------------------------
+//
+CCalenSolarTerms::~CCalenSolarTerms()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::CheckSolarTermDateL()
+// ---------------------------------------------------------------------------
+//
+TInt CCalenSolarTerms::CheckSolarTermDateL( const TDateTime& aDate )
+    {
+    TRACE_ENTRY_POINT;
+    
+    ReadSolarTermsL( aDate );
+    if ( HasSolarTermDataAvailable( aDate ) )
+        {
+        // Solar festival data is available for this date 
+        for ( TInt i( 0 ); i < KSolarTermCount; i++ )
+            {
+            TDateTime date = iSolarTermDates[i];
+            if ( aDate.Month() == date.Month() && aDate.Day() == date.Day() )
+                {
+                // First item in iSolarTermNames is LiChun ("Spring begins")
+                // occuring around 4.2 in western year. 
+                // It is first solar term in Chinese Lunar year, but it's 
+                // third term in western year.
+                // 
+                // iSolarTermDates list terms from beginning of western year,
+                // that's why we subtract 2 and take modulo 24 here, to convert
+                // order from 
+                // Xiao Han (~ 6.1.), Da Han (~22.1), Li Chun (~4.2)...
+                // to 
+                // Li Chun (~4.2.), ..., ..., Da Han (~22.1)
+                i += KSolarTermCount - 2;
+                TInt foundIndex = i % KSolarTermCount;
+                
+                TRACE_EXIT_POINT;
+                return foundIndex;
+                }
+            }
+        TRACE_EXIT_POINT;
+        return KErrNotFound;
+        }
+    else
+        {
+        // Solar festival data is NOT available for this date 
+        TRACE_EXIT_POINT;
+        return KErrNotSupported;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::CCalenSolarTerms()
+// ---------------------------------------------------------------------------
+//
+CCalenSolarTerms::CCalenSolarTerms( RFs& aFs ) : iFs( aFs )
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCalenSolarTerms::ConstructL()
+    {
+    TRACE_ENTRY_POINT;
+    TRACE_EXIT_POINT;
+    }
+
+// ---------------------------------------------------------------------------
+// CCalenSolarTerms::HasSolarTermDataAvailable()
+// ---------------------------------------------------------------------------
+//
+TBool CCalenSolarTerms::HasSolarTermDataAvailable( const TDateTime& aDate ) const
+    {
+    TRACE_ENTRY_POINT;
+    
+    // Note: day parameter for TDateTime starts from 0, not from 1
+    const TDateTime KMinAvailable( KFirstSolarTermYear, EJanuary, 0, 0, 0, 0, 0 );
+    const TDateTime KMaxAvailable( KLastSolarTermYear, EDecember, 31 - 1, 23, 59, 59, 0 );
+    
+    TRACE_EXIT_POINT;
+    return TTime( KMinAvailable ) <= TTime( aDate ) &&
+           TTime( aDate ) <= TTime( KMaxAvailable );
+    }
+
+// ---------------------------------------------------------
+// CCalenSolarTerms::ReadSolarTermsL()
+// Reads and caches 24 solar term dates for one year
+// from "SolarItems" file
+// ---------------------------------------------------------
+//
+void CCalenSolarTerms::ReadSolarTermsL( TDateTime aDate )
+    {
+    TRACE_ENTRY_POINT;
+    
+    // Caches one year of solar items
+    if ( ! HasSolarTermDataAvailable( aDate ) )
+        {
+        return;
+        }
+
+    TInt year = aDate.Year();
+
+    if ( iCachedYear != year )
+        {
+        RFile file;
+        RFs& fs = iFs;
+        TFindFile ffile( fs );
+        User::LeaveIfError( ffile.FindByDir( KSolarTermsFile, KSolarTermsPath ) );
+        User::LeaveIfError( file.Open( fs, ffile.File(), EFileRead ) );
+        CleanupClosePushL( file );
+
+        TInt seekPos = 
+            ( year - KFirstSolarTermYear ) * sizeof( TUint8 ) * KSolarTermCount;
+
+        RFileReadStream readStream( file, seekPos );
+        readStream.PushL();
+
+         for ( TInt i( 0 ); i < KSolarTermCount; i++ )
+             {
+             TMonth month = static_cast<TMonth>( EJanuary + (i / 2) );
+             TInt day = readStream.ReadUint8L();
+             TDateTime dt( year, month, day-1, 0, 0, 0, 0 );
+             iSolarTermDates[i] = dt;
+             }
+
+        CleanupStack::PopAndDestroy( 2 ); // readStream, file
+        iCachedYear = year;
+        }
+    
+    TRACE_EXIT_POINT;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/rom/caldav.iby	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,32 @@
+/*
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Maximilian Odendahl, Sun Microsystems, Inc.
+ *
+ * Contributors:
+ *
+ * Description: iby file to include Caldav into rom
+ * 
+ */
+
+
+
+#ifndef CALDAV_IBY
+#define CALDAV_IBY
+
+#ifdef FF_CALDAV_SUPPORT
+file=ABI_DIR\BUILD_DIR\CalDavClient.dll   	SHARED_LIB_DIR\CalDavClient.dll
+file=ABI_DIR\BUILD_DIR\!CalDavServer.exe	PROGRAMS_DIR\!CalDavServer.exe
+
+ECOM_PLUGIN( calencaldavplugin.dll , calencaldavplugin.rsc )
+
+data=DATAZ_\RESOURCE_FILES_DIR\calencaldavplugindata.rsc	RESOURCE_FILES_DIR\calencaldavplugindata.rsc
+#endif //FF_CALDAV_SUPPORT
+
+#endif // CALDAV_IBY
+
+//  End of File
\ No newline at end of file
--- a/calendarui/server/CalenSvr/src/CalenServer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/server/CalenSvr/src/CalenServer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -655,7 +655,7 @@
                     TPckgC<TBool> pkgMarkAsDelete(markAsdelete);
                     TRAPD(err,pkgMarkAsDelete.Set(calendarInfo->PropertyValueL(keyBuff)));
                     markAsdelete = pkgMarkAsDelete();
-                    if( markAsdelete )
+                    if( markAsdelete && (err == KErrNone))
                         {
                         // Mark the CalFile as visible.
                         calendarInfo->SetEnabled( ETrue );
--- a/calendarui/settings/settingsui/src/calensettingsuicontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/settings/settingsui/src/calensettingsuicontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -1003,19 +1003,11 @@
     if ( index >= 0 )   // index is -1 if there are no items in the list
         {
         CAknSettingItem* item;
-        TDay day = static_cast<TDay>( iWeekFormat );
+        //Listbox will return the visible index
+        //So get the actual item index from visible index to get the correct item
+        TInt itemIndex = iSettingItemArray->ItemIndexFromVisibleIndex(index);
+        item = iSettingItemArray->At( itemIndex );          
 
-        // If the starting day of a week is other than Monday, "Title of week view" setting item 
-        // is  not displayed. For the item below "Week Format", the index in iSettingItemArray
-        // is one more than CurrentItemIndex().
-        if( ( day != EMonday && index >= 4 ) )
-            {
-            item = iSettingItemArray->At( index + 1);
-            }
-        else
-            {
-            item = iSettingItemArray->At( index );          
-            }
          // Open edit dialog if EAknCmdOpen, invert the value otherwise
         aPageStatus = ETrue;
         iPageStatus = aPageStatus;
--- a/calendarui/views/inc/caleneventviewcontainer.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/inc/caleneventviewcontainer.h	Tue Sep 14 21:17:03 2010 +0300
@@ -349,6 +349,11 @@
     void AddDateFieldL( TInt aHeadingResource, const TTime& aDate );
 
     /**
+     * Add a date field to the form.
+     */
+    void AddDateFieldL( const TDesC& aDate );
+
+    /**
      * Add a "date - date" field to the form.
      */
     void AddDateDateFieldL( const TTime& aStartDate, const TTime& aEndDate );
@@ -582,6 +587,11 @@
      CDocumentHandler*               iDocHandler; 
 	 RArray<TTextPos> iAttachmentPosInfoArray;	// Array of start and end positions of each attachment names on the viewer
 
+    /**
+    * True if FeatureManager is initialized.
+    */
+    TBool iFeatMgrInitialized;
+	     
 	};
 
 #endif // CALENEVENTCONTAINER_H
\ No newline at end of file
--- a/calendarui/views/inc/calennativeview.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/inc/calennativeview.h	Tue Sep 14 21:17:03 2010 +0300
@@ -185,7 +185,7 @@
      * 
      * @return ETrue if launched from alarm popup, EFalse otherwise
      */
-    TBool IsEventViewLaunchedFromAlarm();
+    TBool IsCalenLaunchedFromExtApp();
     
     /**
      * @brief Marks that a command is being processed currently
--- a/calendarui/views/src/calendaycontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calendaycontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -1466,7 +1466,7 @@
         {
         return;
         }
-    if(iView->IsEventViewLaunchedFromAlarm())
+    if(iView->IsCalenLaunchedFromExtApp())
         {
         return;
         }
@@ -1760,6 +1760,7 @@
     UpdateStatusPaneAndExtensionsL();
 	// Hide/unhide "today" toolbar item based on the focused day
     UpdateTodayToolbarItemL();
+    iView->SetTapIgnore(EFalse);
     DrawNow();
     TRACE_EXIT_POINT;
     }
--- a/calendarui/views/src/calendayview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calendayview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -44,7 +44,7 @@
 #include "calendaycontainer.h"
 #include "calensend.h"
 #include "calentitlepane.h"
-#include "calenlocationutil.h"
+#include <calenlocationutil.h>
 #include <CalenInterimUtils2.h>
 #include "calendar.hrh"
 #include "CalenUid.h"
--- a/calendarui/views/src/caleneventview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/caleneventview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -34,7 +34,7 @@
 #include "caleneventviewcontainer.h"
 #include <calenview.h>
 #include "CalenUid.h"
-#include "calenlocationutil.h"
+#include <calenlocationutil.h>
 #include "calenentryutil.h"
 #include "calendar.hrh"
 #include <finditem.hrh>
--- a/calendarui/views/src/caleneventviewcontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/caleneventviewcontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -70,6 +70,8 @@
 #include <calcalendarinfo.h>
 #include <DocumentHandler.h>
 
+#include <bldvariant.hrh> // for feature definitions
+
 // user includes
 #include "caleneventviewcontainer.h"
 #include "caleneventview.h"
@@ -160,6 +162,13 @@
     //Reset the attachment posiitons array
     iAttachmentPosInfoArray.Reset();
     
+    // Do not call UnInitializeLib() if InitalizeLib() leaves.
+    if ( iFeatMgrInitialized )
+        {
+        // Frees the TLS. Must be done after FeatureManager is used.
+        FeatureManager::UnInitializeLib();  
+        }  
+    
 	TRACE_EXIT_POINT;
 	}
 
@@ -199,6 +208,12 @@
         
     iDocHandler->SetExitObserver( this );
     iTextEditor->EnableKineticScrollingL(ETrue);
+
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    // Used in destructor. 
+    iFeatMgrInitialized = ETrue;
+     
 	TRACE_EXIT_POINT;
 	}
 
@@ -812,7 +827,14 @@
         case CCalEntry::EAnniv:
             {
             // date field
-            AddDateFieldL(iEventViewData->StartDateTime());
+            if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
+                {
+                AddDateFieldL( iServices.Infobar() );
+                }
+            else
+                {
+                AddDateFieldL( iEventViewData->StartDateTime() );
+                }
             
             // against the location field in the viewer
             iTimeFieldLines = 1;
@@ -1532,6 +1554,29 @@
 
     TRACE_EXIT_POINT;
     }
+
+// -----------------------------------------------------------------------------
+// CCalenEventViewContainer::AddDateFieldL
+// Add a date field to the form.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CCalenEventViewContainer::AddDateFieldL( const TDesC& aDate )
+    {
+    TRACE_ENTRY_POINT;
+	if (FeatureManager::FeatureSupported( KFeatureIdKorean )) 
+		{
+		TBuf<KMaxDateLength> formattedDate;
+    	if ( aDate.Length() < KMaxDateLength && aDate.Length() > 0 )
+    		{
+    		formattedDate.Copy( aDate );
+    		}
+    	AknTextUtils::DisplayTextLanguageSpecificNumberConversion( formattedDate );
+    	SetFormatAndAddBodyL( formattedDate );
+		}
+    TRACE_EXIT_POINT;
+    }
+
 // -----------------------------------------------------------------------------
 // CCalenEventViewContainer::AddDateFieldL
 // Add a field to the form in the format "DATE - DATE".
--- a/calendarui/views/src/calenmissedalarmscontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenmissedalarmscontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -465,6 +465,10 @@
     
     TInt pointerIndex(-1);
     TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex));
+    if(iView->IsCalenLaunchedFromExtApp())
+        {
+        return;
+        }
 
     if(isItem == EFalse)
         {
--- a/calendarui/views/src/calenmissedalarmsview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenmissedalarmsview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -264,6 +264,11 @@
             break;
         case EAknSoftkeyExit:
             {
+            MCalenToolbar* toolbar = iServices.ToolbarOrNull();
+            if(toolbar)
+                {
+                toolbar->SetToolbarVisibilityL(ETrue);  
+                } 
             iServices.IssueNotificationL(ECalenNotifyClearMissedAlarms);
             CCalenNativeView::HandleCommandL(aCommand);
             }
--- a/calendarui/views/src/calenmissedeventcontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenmissedeventcontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -73,7 +73,7 @@
 #include "calennotedatautil.h"
 #include "calenentryutil.h"
 #include "CalenUid.h"   // KUidCalendar
-#include "calenlocationutil.h"
+#include <calenlocationutil.h>
 
 // LOCAL CONSTANTS AND MACROS
 _LIT( KWesternSummaryMarker, "\x200E" );
--- a/calendarui/views/src/calenmissedeventview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenmissedeventview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -41,7 +41,7 @@
 #include "calenmissedeventcontainer.h"
 #include <calenview.h>
 #include "CalenUid.h"
-#include "calenlocationutil.h"
+#include <calenlocationutil.h>
 #include "calenentryutil.h"
 #include "CleanupResetAndDestroy.h"
 
@@ -336,6 +336,11 @@
         case EAknSoftkeyExit: 
             {
                       
+            MCalenToolbar* toolbar = iServices.ToolbarOrNull();
+            if (toolbar)
+                {
+                toolbar->SetToolbarVisibilityL(ETrue);
+                }
             CCalenNativeView::HandleCommandL(aCommand);
             }
             break;
--- a/calendarui/views/src/calenmonthcontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenmonthcontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -1228,7 +1228,7 @@
  
         CleanupReleasePushL( *setting ) ;
 
-        if( setting->WeekFormat() == EMonday && setting->WeekNumberEnable() )
+        if( setting->WeekFormat() == EMonday && setting->WeekNumberEnable() == EWeekNumberOn )
             {
             useWeeks = ETrue;
             }
@@ -1666,7 +1666,7 @@
 
     if(AknLayoutUtils::PenEnabled())
         {
-        if(iView->IsEventViewLaunchedFromAlarm())
+        if(iView->IsCalenLaunchedFromExtApp())
             {
             return;
             }
--- a/calendarui/views/src/calennativeview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calennativeview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -708,7 +708,8 @@
 	notificationArray.Append(ECalenNotifyDeleteFailed);
 	notificationArray.Append(ECalenNotifyEntryDeleted);
 	notificationArray.Append(ECalenNotifyResourceChanged);
-	notificationArray.Append(ECalenNotifyEventViewLaunchedFromAlarm);
+	notificationArray.Append(ECalenNotifyCalenLaunchedFromExtApp);
+	
 	
     iServices.RegisterForNotificationsL( this,notificationArray);
     
@@ -1079,7 +1080,7 @@
             PIM_TRAPD_HANDLE( OnLocaleChangedL( EChangesSystemTime ) );
             }
             break;
-        case ECalenNotifyEventViewLaunchedFromAlarm:
+        case ECalenNotifyCalenLaunchedFromExtApp:
             {
             SetTapIgnore(ETrue);
             }
@@ -1361,11 +1362,11 @@
     }
 
 // ----------------------------------------------------------------------------
-// CCalenNativeView::IsEventViewLaunchedFromAlarm
+// CCalenNativeView::IsCalenLaunchedFromExtApp
 // other details are commented in the header
 // ----------------------------------------------------------------------------
 // 
-TBool CCalenNativeView::IsEventViewLaunchedFromAlarm()
+TBool CCalenNativeView::IsCalenLaunchedFromExtApp()
     {
     TRACE_ENTRY_POINT;
     return iIgnoreTap;
--- a/calendarui/views/src/calentodocontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calentodocontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -1172,7 +1172,7 @@
 
     if(AknLayoutUtils::PenEnabled())
         {
-        if(iView->IsEventViewLaunchedFromAlarm())
+        if(iView->IsCalenLaunchedFromExtApp())
             {
             return;
             }
--- a/calendarui/views/src/calentodoview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calentodoview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -584,7 +584,7 @@
                 {
                 if( Container()->MarkedCount() )
                     {
-                    aMenuPane->SetItemSpecific( ECalenDeleteCurrentEntry, ETrue );
+                    aMenuPane->SetItemSpecific( ECalenDeleteCurrentEntry, EFalse );
                     if(Container()->IsCurrentItemSelected()) // If focused list item is marked
                         {
                         aMenuPane->DeleteMenuItem( ECalenViewCurrentEntry );
@@ -593,24 +593,30 @@
                     aMenuPane->DeleteMenuItem( ECalenCompleteTodo );
                     aMenuPane->DeleteMenuItem( ECalenRestoreTodo );
                     aMenuPane->DeleteMenuItem( ECalenSend );
-                    aMenuPane->DeleteMenuItem(ECalenCopyToCalendars);
-                    
-                    TBool crossout( EFalse );
-                    //When mark as done, crossout is ETrue.
-                    crossout = CheckMarkedItemCompletedL();
-                    if( crossout )
+
+                    if(Container()->MarkedCount() == 1)
                         {
-                        aMenuPane->SetItemSpecific(ECalenMarkUnDone, ETrue);
+                        aMenuPane->DeleteMenuItem( ECalenCmdComplete );
+                        TBool crossout( EFalse );
+                        crossout = CheckMarkedItemCompletedL();
+                        if( crossout )
+                            {
+                            aMenuPane->DeleteMenuItem( ECalenMarkDone );
+                            }
+                        else
+                            {
+                            aMenuPane->DeleteMenuItem( ECalenMarkUnDone );
+                            }
                         }
                     else
                         {
-                        aMenuPane->SetItemSpecific(ECalenMarkDone, ETrue);
+                        aMenuPane->DeleteMenuItem( ECalenMarkDone );
+                        aMenuPane->DeleteMenuItem( ECalenMarkUnDone );
                         }
-                    
-                    if(Container()->MarkedCount() == 1)
-                        {
-                        aMenuPane->DeleteMenuItem( ECalenCmdComplete );
-                        }
+ 					if(Container()->MarkedCount() > 1)
+ 					    {
+                        aMenuPane->DeleteMenuItem( ECalenCopyToCalendars );
+ 					    }
                     }
                 else
                     {
--- a/calendarui/views/src/calenweekcontainer.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/calendarui/views/src/calenweekcontainer.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -2197,7 +2197,7 @@
 
     if(AknLayoutUtils::PenEnabled())
         {
-        if(iView->IsEventViewLaunchedFromAlarm())
+        if(iView->IsCalenLaunchedFromExtApp())
             {
             return;
             }
--- a/clock2/clockengines/clocktimesourceinterface/group/clocktimesourceinterface.mmp	Wed Sep 01 12:32:31 2010 +0100
+++ b/clock2/clockengines/clocktimesourceinterface/group/clocktimesourceinterface.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -24,7 +24,7 @@
 UID				0x1000008d 0x200159A3
 
 // Capability and vendor info
-CAPABILITY		ALL -TCB
+CAPABILITY		CAP_GENERAL_DLL
 VENDORID		VID_DEFAULT
 
 // Source files
--- a/clock2/clockengines/clocktimezoneresolver/group/clocktimezoneresolver.mmp	Wed Sep 01 12:32:31 2010 +0100
+++ b/clock2/clockengines/clocktimezoneresolver/group/clocktimezoneresolver.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -24,7 +24,7 @@
 UID				0x1000008d 0x200159A4
 
 // Capability and vendor info
-CAPABILITY		ALL -TCB
+CAPABILITY		CAP_GENERAL_DLL
 VENDORID		VID_DEFAULT
 
 // Source files
--- a/clock2/clockui/adtupdater/group/adtupdater.mmp	Wed Sep 01 12:32:31 2010 +0100
+++ b/clock2/clockui/adtupdater/group/adtupdater.mmp	Tue Sep 14 21:17:03 2010 +0300
@@ -26,7 +26,7 @@
 
 // Uid and Capability information
 UID					0x100039CE 0x2001114C
-CAPABILITY          CAP_APPLICATION AllFiles SwEvent
+CAPABILITY          CAP_APPLICATION
 
 // Stack options
 EPOCSTACKSIZE		0x10000
--- a/clock2/clockui/uilayer/clockworldview/src/clockworldview.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/clock2/clockui/uilayer/clockworldview/src/clockworldview.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -1202,9 +1202,18 @@
 	
 	iGalleryOpen = EFalse;
 	
-	// Show the navigation pane.
-	appUi->MakeNavigationPaneVisible( ETrue, EClockAppWorldViewId );
-
+	TVwsViewId viewId;
+	AppUi()->GetActiveViewId( viewId );
+	if( viewId.iViewUid == KClockAppWorldViewId )
+	    {
+        // Show the navigation pane.
+        appUi->MakeNavigationPaneVisible( ETrue, EClockAppWorldViewId );
+	    }
+	else if(viewId.iViewUid == KClockAppMainViewId )
+	    {
+        //update the title text according to the active view
+        ClockApplicationUi()->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
+	    }
 	// If an image is selected by the user
 	if( result )
 	    {	
--- a/clock2/clockui/utilities/data/mcc.rss	Wed Sep 01 12:32:31 2010 +0100
+++ b/clock2/clockui/utilities/data/mcc.rss	Tue Sep 14 21:17:03 2010 +0300
@@ -2142,12 +2142,6 @@
 			tzid	= 2680;
 			mcc		= 202;
 			},
-		// Europe/Belfast                
-		MOBILE_COUNTRY_CODE
-			{
-			tzid	= 2744;
-			mcc		= 234;
-			},
 		// Europe/Belgrade
 		// Belgrade, Serbia and Montenegro
 		MOBILE_COUNTRY_CODE
@@ -3689,7 +3683,7 @@
 		MOBILE_COUNTRY_CODE
 			{
 			tzid	= 2744;
-			mcc		= 235;
+			mcc		= 272;
 			},
 		// Europe/London
 		// UK
--- a/organizer_plat/calendar_common_utils_api/group/bld.inf	Wed Sep 01 12:32:31 2010 +0100
+++ b/organizer_plat/calendar_common_utils_api/group/bld.inf	Tue Sep 14 21:17:03 2010 +0300
@@ -33,5 +33,6 @@
 ../inc/calenviewutils.h				APP_LAYER_PLATFORM_EXPORT_PATH( calenviewutils.h )
 ../inc/calenmulticalutil.h				APP_LAYER_PLATFORM_EXPORT_PATH( calenmulticalutil.h )
 ../inc/calenmulticaluids.hrh				APP_LAYER_PLATFORM_EXPORT_PATH( calenmulticaluids.hrh ) 
+../inc/calenlocationutil.h				APP_LAYER_PLATFORM_EXPORT_PATH( calenlocationutil.h )
 
 // End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/organizer_plat/calendar_common_utils_api/inc/calenlocationutil.h	Tue Sep 14 21:17:03 2010 +0300
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Utility class to inform calendar components if any Nokia map 
+ * 			providers are available. Its a static API.
+ *
+ */
+
+
+#ifndef CALENLOCATIONUTIL_H
+#define CALENLOCATIONUTIL_H
+
+// System includes
+#include <e32base.h>
+#include <mnprovider.h>
+
+class CCalenLocationUtil : public CBase
+	{
+	
+public:
+	
+	/**
+	 * API to tell claendar modules if Nokia maps provider is available 
+	 * in the device or not.
+	 * 
+	 * @return ETrue if Nokia maps is installed on the device else EFalse.
+	 */
+	static TBool IsMapProviderAvailableL();
+
+	/**
+	 * Utility function to display list query with three strings.
+	 * This function will be used when user selects a map location 
+	 * when there is already some invalidated location for the event.
+	 * First string will be a combination of lod text and newly 
+	 * selected map locaiton. Second string will be newly selected map location.
+	 * Third strign will be old invalidated text.
+	 * 
+	 * @params aStrings Array of three strings.
+	 * @return 0 for first string, 1 for second and 2 for third string when user 
+	 * 			selects his choice. If cancelled, returns -1. 
+	 */
+	static TInt ShowLocationAppendOrReplaceL( 
+	                                          RPointerArray< HBufC >& aStrings );
+	
+	};
+
+#endif // CALENLOCATIONUTIL_H
+
+// End of file	--Don't remove this.
--- a/organizer_plat/calendar_custamization_api/inc/calencontext.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/organizer_plat/calendar_custamization_api/inc/calencontext.h	Tue Sep 14 21:17:03 2010 +0300
@@ -131,6 +131,21 @@
 		 */
         virtual TVwsViewId ViewId() const = 0;
         
+        /**
+         * Sets the start and end time of the instance that has to be created.
+         * @param aStartTime The start time of the instance that has to be created.
+         * @param aEndTime The end time of the instance that has to be created.
+         */
+        virtual void SetStartAndEndTimeForNewInstance( const TTime& aStartTime,
+                                            const TTime& aEndTime ) = 0;
+        
+        /**
+         * Gets the start and end time of the instance that has to be created.
+         * @param aStartTime The start time of the instance that has to be created.
+         * @param aEndTime The end time of the instance that has to be created.
+         */
+        virtual void GetStartAndEndTimeForNewInstance( TTime& aStartTime, TTime& aEndTime ) = 0;
+            
  
 	public:			// For Mutliple Context Support    
  
--- a/organizer_plat/calendar_custamization_api/inc/calennotificationhandler.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/organizer_plat/calendar_custamization_api/inc/calennotificationhandler.h	Tue Sep 14 21:17:03 2010 +0300
@@ -40,7 +40,7 @@
     ECalenNotifyLostAlarms,
     ECalenNotifyAlarmStopped,    
     ECalenNotifyAlarmSnoozed,
-	ECalenNotifyEventViewLaunchedFromAlarm,
+	ECalenNotifyCalenLaunchedFromExtApp,
     ECalenNotifyCmdLineLaunch,
     ECalenNotifyAvkonViewSwitchLaunch,
     ECalenNotifySettingsChanged,
--- a/pimappservices/calendar/bwins/agnmodelv3u.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/bwins/agnmodelv3u.def	Tue Sep 14 21:17:03 2010 +0300
@@ -377,4 +377,7 @@
 	??0CAgnCalendarInfo@@IAE@XZ @ 376 NONAME ; CAgnCalendarInfo::CAgnCalendarInfo(void)
 	?ExternalizePropertiesL@CAgnCalendarInfo@@QBEXAAVCFileStore@@PBV1@@Z @ 377 NONAME ; void CAgnCalendarInfo::ExternalizePropertiesL(class CFileStore &, class CAgnCalendarInfo const *) const
 	?SetState@CAgnCalendarInfoProperty@@QAEXW4TState@1@@Z @ 378 NONAME ; void CAgnCalendarInfoProperty::SetState(enum CAgnCalendarInfoProperty::TState)
-	
+	?UserDataInt@CAgnEntry@@QBEKXZ @ 379 NONAME ; unsigned long CAgnEntry::UserDataInt(void) const
+	?SetUserDataInt@CAgnEntry@@QAEXK@Z @ 380 NONAME ; void CAgnEntry::SetUserDataInt(unsigned long)
+	?ClearMRSpecificData@CAgnEntry@@QAEXXZ @ 381 NONAME ; void CAgnEntry::ClearMRSpecificData(void)
+
--- a/pimappservices/calendar/bwins/calinterimapiv3u.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/bwins/calinterimapiv3u.def	Tue Sep 14 21:17:03 2010 +0300
@@ -338,4 +338,7 @@
 	?PropertyKeysL@CCalCalendarInfo@@QBEPAVCDesC8Array@@XZ @ 337 NONAME ; class CDesC8Array * CCalCalendarInfo::PropertyKeysL(void) const
 	?RemovePropertyL@CCalCalendarInfo@@QAEXABVTDesC8@@@Z @ 338 NONAME ; void CCalCalendarInfo::RemovePropertyL(class TDesC8 const &)
 	?PropertyValueL@CCalCalendarInfo@@QBEABVTDesC8@@ABV2@@Z @ 339 NONAME ; class TDesC8 const & CCalCalendarInfo::PropertyValueL(class TDesC8 const &) const
+	?SetUserInt32L@CCalEntry@@QAEXK@Z @ 340 NONAME ; void CCalEntry::SetUserInt32L(unsigned long)
+	?UserInt32L@CCalEntry@@QAEKXZ @ 341 NONAME ; unsigned long CCalEntry::UserInt32L(void)
+	?ClearMRSpecificDataL@CCalEntry@@QAEXXZ @ 342 NONAME ; void CCalEntry::ClearMRSpecificDataL(void)
 
--- a/pimappservices/calendar/client/inc/calentryimpl.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/client/inc/calentryimpl.h	Tue Sep 14 21:17:03 2010 +0300
@@ -49,7 +49,8 @@
 	
 	void SetPhoneOwnerL(const CCalUser* aOwner);
 	CCalUser* OrganizerL();
-	CCalUser* PhoneOwnerL();	
+	CCalUser* PhoneOwnerL();
+	void ClearMRSpecificDataL();
 	
 	void SetAlarmSoundNameL(const TDesC& aAlarmSoundName);
 	CTzRules* GetTzRulesL();
@@ -151,6 +152,9 @@
 
 	TUint8 ShortFileIdL();
 	
+    void SetUserInt32L( TUint32 aUserInt );
+    TUint32 UserInt32L();
+
 private:
 	CCalEntryImpl();
 	CCalEntryImpl(CAgnEntry& aEntry, CCalSessionImpl& aSessionImpl);
--- a/pimappservices/calendar/client/src/calentry.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/client/src/calentry.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -895,6 +895,19 @@
 	iImpl->SetPhoneOwnerL(aOwner);
 	}
 
+/** Clears the Organizer and phone owner.
+@pre None.
+@post The entry's organizer and phone owner is cleared.
+@publishedPartner
+@released
+@capability None
+*/
+EXPORT_C void CCalEntry::ClearMRSpecificDataL()
+    {
+    iImpl->ClearMRSpecificDataL();
+    }
+
+
 /** Gets the organizer for this entry.
 This function creates a new CCalUser object containing the organizer data.
 
@@ -1143,6 +1156,30 @@
 	return iImpl->ShortFileIdL();
 	}
 
+/** Sets the user data field.
+
+@param aUserInt The userdata to be set
+@capability None
+@publishedAll
+@released
+*/
+EXPORT_C void CCalEntry::SetUserInt32L( TUint32 aUserInt )    
+    {       
+    iImpl->SetUserInt32L( aUserInt );       
+    }       
+
+/** Fetches the userdata field
+
+@publishedAll
+@released
+@capability None
+@return The Userdata field.
+*/
+EXPORT_C TUint32 CCalEntry::UserInt32L()       
+    {       
+    return iImpl->UserInt32L();       
+    }       
+
 // CCalEntryId //
 
 
--- a/pimappservices/calendar/client/src/calentryimpl.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/client/src/calentryimpl.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -336,6 +336,17 @@
 	return iCalOrganizer;
 	}
 
+void CCalEntryImpl::ClearMRSpecificDataL()
+    {
+    LoadFullEntryL();
+    iFullEntry->ClearMRSpecificData();  // Clear Organizer and Phone Owner.
+    if( iCalOrganizer )
+        {
+        delete iCalOrganizer;
+        iCalOrganizer = NULL;
+        }
+    }
+
 CTzRules* CCalEntryImpl::GetTzRulesL()
 	{
 	CAgnRptDef* rptDef = SimpleEntry()->RptDef();
@@ -1666,6 +1677,15 @@
     return SimpleEntry()->UserInt();
     }
 
+void CCalEntryImpl::SetUserInt32L( TUint32 aUserInt )   
+    {       
+    iFullEntry->SetUserDataInt( aUserInt );      
+    }  
+
+TUint32 CCalEntryImpl::UserInt32L()       
+    {       
+    return iFullEntry->UserDataInt();   
+    }       
 
 //  CCalEntryIdImpl //
 
--- a/pimappservices/calendar/eabi/agnmodelv3u.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/eabi/agnmodelv3u.def	Tue Sep 14 21:17:03 2010 +0300
@@ -422,4 +422,7 @@
 	_ZTV16CAgnCalendarInfo @ 421 NONAME
 	_ZTV24CAgnCalendarInfoProperty @ 422 NONAME
 	_ZNK24CAgnCalendarInfoProperty5StateEv @ 423 NONAME
+	_ZN9CAgnEntry14SetUserDataIntEm @ 424 NONAME
+	_ZNK9CAgnEntry11UserDataIntEv @ 425 NONAME
+	_ZN9CAgnEntry19ClearMRSpecificDataEv @ 426 NONAME
 
--- a/pimappservices/calendar/eabi/calinterimapiv3u.def	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/eabi/calinterimapiv3u.def	Tue Sep 14 21:17:03 2010 +0300
@@ -408,4 +408,7 @@
 	_ZN16CCalCalendarInfo15RemovePropertyLERK6TDesC8 @ 407 NONAME
 	_ZNK16CCalCalendarInfo13PropertyKeysLEv @ 408 NONAME
 	_ZNK16CCalCalendarInfo14PropertyValueLERK6TDesC8 @ 409 NONAME
+	_ZN9CCalEntry10UserInt32LEv @ 410 NONAME
+	_ZN9CCalEntry13SetUserInt32LEm @ 411 NONAME
+	_ZN9CCalEntry20ClearMRSpecificDataLEv @ 412 NONAME
 
--- a/pimappservices/calendar/inc/calentry.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/inc/calentry.h	Tue Sep 14 21:17:03 2010 +0300
@@ -274,6 +274,7 @@
 	IMPORT_C CCalUser* OrganizerL() const;
 	IMPORT_C void SetPhoneOwnerL(const CCalUser* aOwner);
 	IMPORT_C CCalUser* PhoneOwnerL() const;
+	IMPORT_C void CCalEntry::ClearMRSpecificDataL();
 
 	// Attachments
 	IMPORT_C void AddAttachmentL(CCalAttachment& aAttachment);
@@ -318,6 +319,9 @@
 
 	IMPORT_C TCalTime FindRptUntilTimeL(TInt aCount);
     
+    IMPORT_C void SetUserInt32L( TUint32 aUserInt );
+    IMPORT_C TUint32 UserInt32L();
+
 public:
 	// Internal APIs
 	static CCalEntry* NewL(CCalEntryImpl* aImpl);
--- a/pimappservices/calendar/server/inc/agsbackuprestoreagent.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/inc/agsbackuprestoreagent.h	Tue Sep 14 21:17:03 2010 +0300
@@ -33,7 +33,7 @@
 class CAgnServBackupRestoreAgent : public CActive
 	{
 public:
- 	static CAgnServBackupRestoreAgent* NewL(CAgnServFileMgr& aFileMgr);
+ 	static CAgnServBackupRestoreAgent* NewL(CAgnServFileMgr& aFileMgr ,TBool& aBackupRestoreInProgress);
 	~CAgnServBackupRestoreAgent();
 	
 	TBool BackupInProgress() const;
@@ -41,7 +41,7 @@
 	void Start();
 	
 private:
-	CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr);
+	CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr , TBool& aBackupRestoreInProgress);
 	
 private:	// from CActive
 	void RunL();
@@ -57,6 +57,7 @@
 	RProperty iBackupRestoreNotification;
 	TInt iCurrentState;
 	CAgnServFileMgr& iFileMgr;
+	TBool& iBackupRestoreInProgress;
 	};
 
 #endif
--- a/pimappservices/calendar/server/inc/agsmain.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/inc/agsmain.h	Tue Sep 14 21:17:03 2010 +0300
@@ -117,6 +117,7 @@
 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
 	const CCAgnSystemStateObserver& SystemStateObserver() const;
 #endif
+	TBool BackupRestoreInProgress();
 protected:
 	CAgnServer(TInt aPriority);
 private:
@@ -133,6 +134,7 @@
 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
 	CCAgnSystemStateObserver* iSystemStateObserver;
 #endif
+    TBool iBackupRestoreInProgress;
 	};
 
 // inline functions
--- a/pimappservices/calendar/server/src/agsattachmentindex.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/src/agsattachmentindex.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -281,8 +281,7 @@
 		{
 		// check every attachment
 		const CAgnAttachmentIndexItem* KAttachmentItem = iIndex[i];
-		const TInt entryCount = KAttachmentItem->Entries().Count();
-		for (TInt j = 0; j < entryCount; ++j)
+		for (TInt j = 0; j < KAttachmentItem->Entries().Count(); ++j)
 			{
 			// check every entry associated with each attachment
 			if (KEntryLocalUid == (KAttachmentItem->Entries())[j])
--- a/pimappservices/calendar/server/src/agsbackuprestoreagent.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/src/agsbackuprestoreagent.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -16,9 +16,9 @@
 #include "agsbackuprestoreagent.h"
 #include <connect/sbdefs.h> // For conn::EBURNormal etc.
 
-CAgnServBackupRestoreAgent* CAgnServBackupRestoreAgent::NewL(CAgnServFileMgr& aFileMgr)
+CAgnServBackupRestoreAgent* CAgnServBackupRestoreAgent::NewL(CAgnServFileMgr& aFileMgr,TBool& aBackupRestoreInProgress)
 	{
-	CAgnServBackupRestoreAgent* self = new(ELeave) CAgnServBackupRestoreAgent(aFileMgr);
+	CAgnServBackupRestoreAgent* self = new(ELeave) CAgnServBackupRestoreAgent(aFileMgr,aBackupRestoreInProgress);
 	return self;
 	}
 
@@ -28,8 +28,8 @@
 	iBackupRestoreNotification.Close();
 	}
 
-CAgnServBackupRestoreAgent::CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr)
-	: CActive(CActive::EPriorityStandard), iFileMgr(aFileMgr)
+CAgnServBackupRestoreAgent::CAgnServBackupRestoreAgent(CAgnServFileMgr& aFileMgr, TBool& aBackupRestoreInProgress)
+	: CActive(CActive::EPriorityStandard), iFileMgr(aFileMgr),iBackupRestoreInProgress(aBackupRestoreInProgress)
 	{
 	CActiveScheduler::Add(this);
 	
@@ -90,20 +90,24 @@
 		{
 		if ( newState& (conn::EBURBackupPartial | conn::EBURBackupFull) && !BackupInProgress())
             {
+            iBackupRestoreInProgress = ETrue;
             iFileMgr.CloseScheduledFilesImmediately();
             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupStart);
             }
         else if (newState & (conn::EBURRestoreFull | conn::EBURRestorePartial)&& !RestoreInProgress())
             {
+            iBackupRestoreInProgress = ETrue;
             iFileMgr.CloseScheduledFilesImmediately();
             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreStart);      
             }
         else if (newState & (conn::EBURNormal | conn::EBURUnset) && BackupInProgress())
             {
+            iBackupRestoreInProgress = EFalse;
             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::EBackupEnd); 
             }
         else if (newState & (conn::EBURNormal | conn::EBURUnset) && RestoreInProgress())
             {
+            iBackupRestoreInProgress = EFalse;
             iFileMgr.BackupReStoreChanged(MCalChangeCallBack2::ERestoreEnd); 
             }
 		iCurrentState = newState;
--- a/pimappservices/calendar/server/src/agsmain.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/src/agsmain.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -264,7 +264,7 @@
 	User::LeaveIfError(iAlarmServer.Connect());
 	iFileMgr = CAgnServFileMgr::NewL(iFs, *this);
 	iFileMgr->CreatePermanentDataL();
-	iBackupRestoreAgent = CAgnServBackupRestoreAgent::NewL(*iFileMgr);
+	iBackupRestoreAgent = CAgnServBackupRestoreAgent::NewL(*iFileMgr,iBackupRestoreInProgress);
 	iBackupRestoreAgent->Start();
 	iAlarmServerChangeListener = CAgnAlarmServerChangeListener::NewL(iAlarmServer, *iFileMgr);
 
@@ -384,3 +384,10 @@
     return *iSystemStateObserver;
     }
 #endif
+
+TBool CAgnServer::BackupRestoreInProgress()
+    {
+    return iBackupRestoreInProgress;
+    }
+	
+
--- a/pimappservices/calendar/server/src/agssess.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/server/src/agssess.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -281,7 +281,7 @@
 */
 TBool CAgnServerSession::CheckBackupRestore()
     {
-    if(iBackupRestoreLock  
+    if((iBackupRestoreLock || iAgnServer.BackupRestoreInProgress()) 
     //All opeerations apart from the following ones are not allowed when Backup\Restore is in progress. 
     && iMessage.Function() != ECloseAgenda
     && iMessage.Function() != ECancelChangeNotification
--- a/pimappservices/calendar/shared/inc/agmentry.h	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/shared/inc/agmentry.h	Tue Sep 14 21:17:03 2010 +0300
@@ -165,6 +165,7 @@
 	IMPORT_C CAgnAttendee* Organizer() const;
 	IMPORT_C void SetPhoneOwnerL(CAgnAttendee* aOwner); // takes ownership
 	IMPORT_C CAgnAttendee* PhoneOwner() const;
+	IMPORT_C void ClearMRSpecificData();
 	void CreateAttendeeListL();
 	
 	// attachments
@@ -203,7 +204,10 @@
 	// User integer.
 	IMPORT_C void SetUserInt( TUint32 aUserInt );
 	IMPORT_C TUint32 UserInt() const;
-		
+	
+    IMPORT_C void SetUserDataInt( TUint32 aUserInt );
+    IMPORT_C TUint32 UserDataInt() const;
+
 private:
 	// following enums for internal use only	
 	enum TFlags
@@ -251,7 +255,8 @@
 	TUint8							iReplicationStatus;
 	TUint16							iFlags;
 	TReal							iLatitude;
-	TReal							iLongitude;
+	TReal						    iLongitude;
+	TUint32                         iUserDataInt;   
 	};
 
 #endif
--- a/pimappservices/calendar/shared/src/agmentry.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/shared/src/agmentry.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -29,7 +29,7 @@
 #include <e32math.h>
 
 #include <asshddefs.h>
-
+#define KUserDataInt 4 
 
 //---------------------------------- CAgnEntry ------------------------------------------
 
@@ -411,6 +411,11 @@
 		return EFalse;
 		}
 	
+    if ( UserDataInt() != aEntry.UserDataInt() )     
+        {       
+        return EFalse;       
+        }   
+    
 	return ETrue;
 	}
 
@@ -687,9 +692,15 @@
 
     // Set the user integer of the stream.
 	aStream.WriteInt32L( UserInt() );
-	
-	// future DC proofing
-	aStream.WriteUint32L(0); // number of bytes until end of entry
+
+    TInt skipCount( 0 );
+    //skip count(4) for UserDataInt is added
+    //to read those many bytes after fixed length of agmentry.
+    skipCount += KUserDataInt; 
+    
+    // Number of bytes until end of entry 
+    aStream.WriteUint32L( skipCount );
+    aStream.WriteInt32L( UserDataInt() );      
 	}
 
 
@@ -828,13 +839,18 @@
 	// Set the user integer of this entry from the stream.
 	SetUserInt(aStream.ReadInt32L());
 	
-	// future DC proofing
 	size = aStream.ReadUint32L(); // number of bytes until end of entry
+	
+	if ( size >= KUserDataInt )       
+        {       
+        SetUserDataInt( aStream.ReadInt32L() );
+		size -= KUserDataInt;
+        }  
 	while (size > 0)
 		{
-		aStream.ReadUint8L(); // ignore data
-		size--;
-		}
+			aStream.ReadUint8L(); // ignore data
+			size--;
+		}     
 	}
 
 EXPORT_C CAgnEntry* CAgnEntry::CloneL() const
@@ -1007,6 +1023,8 @@
 		HBufC8* guid = aSource.Guid().AllocL();
 		SetGuid(guid);
 		}		
+	// copy int       
+	iUserDataInt = aSource.UserDataInt();   
 	}
 	
 EXPORT_C CCalEntry::TReplicationStatus CAgnEntry::ReplicationStatus() const
@@ -1234,6 +1252,27 @@
 	iPhoneOwner = aAttendee;
 	}
 
+EXPORT_C void CAgnEntry::ClearMRSpecificData()
+    {
+    // clears the iMeetingOrganizer and iAttendeeList.
+    if( iMeetingOrganizer )
+        {
+        delete iMeetingOrganizer;
+        iMeetingOrganizer = NULL;
+
+        }
+    if( iPhoneOwner )
+        {
+        iPhoneOwner = NULL;
+        }
+
+    if( iAttendeeList )
+        {
+        iAttendeeList->ResetAndDestroy();
+        delete iAttendeeList;
+        iAttendeeList = NULL;
+        }
+    }
 
 EXPORT_C void CAgnEntry::SetDTStampUtcL(const TTime& aDTStampUtc)
 /**
@@ -2086,3 +2125,13 @@
 	{
 	return (iFlags & aFlag);
 	}
+
+EXPORT_C void CAgnEntry::SetUserDataInt( TUint32 aUserInt )       
+    {       
+    iUserDataInt = aUserInt;       
+    }       
+
+EXPORT_C TUint32 CAgnEntry::UserDataInt() const       
+    {       
+    return iUserDataInt;       
+    }       
--- a/pimappservices/calendar/tsrc/T_VCAL2.CPP	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendar/tsrc/T_VCAL2.CPP	Tue Sep 14 21:17:03 2010 +0300
@@ -388,6 +388,27 @@
                         "END:VTODO\r\n"
                         "END:VCALENDAR\r\n");
 
+_LIT8(KUserDataEntry,"BEGIN:VCALENDAR\r\n"     
+                     "VERSION:1.0\r\n"       
+                     "BEGIN:VEVENT\r\n"       
+                     "UID:ZB0tN9634EH8l818X2GVU2\r\n"       
+                     "SUMMARY:importing\r\n"       
+                     "DTSTART:20090720T070000Z\r\n"       
+                     "DTEND:20090720T070000Z\r\n"       
+                     "X-EPOCAGENDAENTRYTYPE:APPOINTMENT\r\n"       
+                     "CLASS:PRIVATE\r\n"       
+                     "SEQUENCE:0\r\n"       
+                     "X-METHOD:NONE\r\n"       
+                     "LAST-MODIFIED:20090720T154714Z\r\n"       
+                     "PRIORITY:2\r\n"       
+                     "X-SYMBIAN-LUID:5\r\n"       
+                     "TRANSP:0\r\n"       
+                     "X-USERDATA-INT:125\r\n"       
+                     "X-STRING:london\r\n"       
+                     "X-TEXTPROPERTY:class property\r\n"       
+                     "X-INTPROPERTY:521\r\n"       
+                     "END:VEVENT\r\n"       
+                     "END:VCALENDAR\r\n");          
 class CTestApp : public CBase , public MCalTestOomCallBack
 	{
 public:
@@ -686,6 +707,8 @@
 	test.Printf(_L("Import a vcal with alarm information\n"));
 	testApp->DoImportL(KAlarmVCal);
 	
+	test.Printf(_L("Import with  userdata attribute \n"));       
+	testApp->DoImportL( KUserDataEntry ); 
 	CleanupStack::PopAndDestroy(testApp);
 	}
 
--- a/pimappservices/calendarvcalplugin/src/agmvcali.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendarvcalplugin/src/agmvcali.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -379,6 +379,15 @@
 		CleanupStack::PopAndDestroy(geoString);
 		}
 	
+    TInt intProperty( 0 );
+    //Import UserDataInt
+    TBool integerFound = ImportIntegerPropertyL( aParser, KVersitExtUserInt,       
+                            intProperty );       
+    
+    if ( integerFound )       
+        {       
+        iEntry->SetUserInt32L( intProperty );       
+        }       
 	CleanupStack::PopAndDestroy(properties);
 	aEntryArray.AppendL(iEntry); // takes ownership of entry
 	iEntry = NULL;
--- a/pimappservices/calendarvcalplugin/src/agmvcalx.cpp	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappservices/calendarvcalplugin/src/agmvcalx.cpp	Tue Sep 14 21:17:03 2010 +0300
@@ -665,6 +665,9 @@
 		CCalAttachment* attach = aEntry->AttachmentL(ii);
 		AddAttachmentPropertyL(aParser, *attach);
 		}
+	
+    TInt userDataInt = aEntry->UserInt32L();       
+    AddIntegerPropertyL( aParser, KVersitExtUserInt, userDataInt );       
 	}
 
 
--- a/pimappsupport/vcardandvcal/inc/VTOKEN.H	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappsupport/vcardandvcal/inc/VTOKEN.H	Tue Sep 14 21:17:03 2010 +0300
@@ -359,5 +359,6 @@
 _LIT8(KVersitTokenClass,					"X-CLASS");
 _LIT8(KVersitAttachLabel, 					"X-NAME");
 _LIT8(KVersitAttachMimeType, 				"X-FMTTYPE");
+_LIT8(KVersitExtUserInt,                    "X-USERDATA-INT");  
 
 #endif
--- a/pimappsupport/vcardandvcal/src/VCAL.CPP	Wed Sep 01 12:32:31 2010 +0100
+++ b/pimappsupport/vcardandvcal/src/VCAL.CPP	Tue Sep 14 21:17:03 2010 +0300
@@ -567,7 +567,8 @@
 			{
 			uid.iUid = KVCalPropertyExtendedAlarmUid;
 			}
-		else if (!aToken.CompareF(KVersitTokenXLOCALUID))
+		else if ( !aToken.CompareF( KVersitTokenXLOCALUID ) ||
+                  !aToken.CompareF( KVersitExtUserInt ) )       
 		    {
 			uid.iUid = KVersitPropertyIntUid;
 		    }