diff -r bd7edf625bdd -r 97232defd20e calendarui/caldav/src/calencaldavplugin.cpp --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#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& /*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& aCustomSettingArray) + { + TRACE_ENTRY_POINT + + RPointerArray calendarInfoList; + iServices->GetAllCalendarInfoL(calendarInfoList); + CleanupClosePushL(calendarInfoList); + + TInt count = calendarInfoList.Count(); + for (TInt i = 0; i < count; i++) + { + TPtrC calendar = calendarInfoList[i]->FileNameL(); + + RPointerArray 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& +/*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