calendarui/caldav/src/calencaldavplugin.cpp
branchRCL_3
changeset 31 97232defd20e
equal deleted inserted replaced
30:bd7edf625bdd 31:97232defd20e
       
     1 /*
       
     2 * Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributor:
       
    10 * Maximilian Odendahl
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: CalDav ECOM plugin
       
    15 *
       
    16 */
       
    17 
       
    18 #include <eikenv.h>
       
    19 #include <aknutils.h>
       
    20 #include <eiklabel.h>
       
    21 #include <avkon.hrh>
       
    22 #include <StringLoader.h>
       
    23 #include <AknMessageQueryDialog.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <bautils.h>
       
    26 #include <aknbiditextutils.h>
       
    27 #include <aknsettingitemlist.h>
       
    28 
       
    29 #include <caldavsession.h>
       
    30 #include <calcalendarinfo.h>
       
    31 #include <calenservices.h>
       
    32 #include <calendar.rsg>
       
    33 
       
    34 #include <CalenCaldavPluginData.rsg>
       
    35 #include <calencommands.hrh>
       
    36 #include "caldavsettingitems.h"
       
    37 #include "calennestedsettingitem.h"
       
    38 #include "calendarui_debug.h" 
       
    39 #include "CalenCaldavPlugin.h"
       
    40 
       
    41 _LIT( KResourceCCalDavPluginFile, "calencaldavplugindata.rsc" );
       
    42 
       
    43 #define KResourcePath KDC_RESOURCE_FILES_DIR
       
    44 
       
    45 /**
       
    46  * CCalenCalDavPlugin::CCalenCalDavPlugin
       
    47  * default constructor
       
    48  */
       
    49 CCalenCalDavPlugin::CCalenCalDavPlugin(MCalenServices* aServices) :
       
    50 	iServices(aServices), iResourceFileOffset(NULL)
       
    51 
       
    52 	{
       
    53 	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
       
    54 	}
       
    55 
       
    56 /**
       
    57  * CCalenCalDavPlugin::NewL
       
    58  * first phase construction
       
    59  */
       
    60 CCalenCalDavPlugin* CCalenCalDavPlugin::NewL(MCalenServices* aServices)
       
    61 	{
       
    62 	TRACE_ENTRY_POINT;
       
    63 	CCalenCalDavPlugin* self = new (ELeave) CCalenCalDavPlugin(aServices);
       
    64 	CleanupStack::PushL(self);
       
    65 	self->ConstructL();
       
    66 	CleanupStack::Pop(self);TRACE_EXIT_POINT;
       
    67 	return self;
       
    68 	}
       
    69 
       
    70 /**
       
    71  * CCalenCalDavPlugin::~CCalenCalDavPlugin
       
    72  * default destructor
       
    73  */
       
    74 CCalenCalDavPlugin::~CCalenCalDavPlugin()
       
    75 	{
       
    76 	TRACE_ENTRY_POINT;
       
    77 
       
    78 	delete iSession;
       
    79 
       
    80 	if (iServices)
       
    81 		{
       
    82 		iServices->CancelNotifications(this);
       
    83 		iServices->Release();
       
    84 		}
       
    85 
       
    86 	if (iResourceFileOffset)
       
    87 		{
       
    88 		CCoeEnv::Static()->DeleteResourceFile(iResourceFileOffset);
       
    89 		}TRACE_EXIT_POINT;
       
    90 	}
       
    91 
       
    92 /**
       
    93  * CCalenCalDavPlugin::ConstructL
       
    94  * second phase construction
       
    95  */
       
    96 void CCalenCalDavPlugin::ConstructL()
       
    97 	{
       
    98 	TRACE_ENTRY_POINT;
       
    99 
       
   100 	TFileName dllName;
       
   101 	// Get the complate path of the DLL from where it is currently loaded
       
   102 	Dll::FileName(dllName);
       
   103 
       
   104 	TFileName resourceFilename;
       
   105 	resourceFilename.Append(dllName.Mid(0, 2));
       
   106 	resourceFilename.Append(KResourcePath);
       
   107 	resourceFilename.Append(KResourceCCalDavPluginFile);
       
   108 	BaflUtils::NearestLanguageFile(CEikonEnv::Static()->FsSession(),
       
   109 			resourceFilename);
       
   110 	// Add the resource file.
       
   111 	iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL(
       
   112 			resourceFilename);
       
   113 
       
   114 	iServices->GetCommandRange(iStart, iEnd);
       
   115 
       
   116 	iSession = CCalDavSession::NewL();
       
   117 
       
   118 	TRACE_EXIT_POINT;
       
   119 	}
       
   120 
       
   121 /**
       
   122  * CCalenCalDavPlugin::InfobarL
       
   123  * show an additional infobar
       
   124  */
       
   125 CCoeControl* CCalenCalDavPlugin::InfobarL(const TRect& /*aRect*/)
       
   126 	{
       
   127 	TRACE_ENTRY_POINT;
       
   128 	return NULL;TRACE_EXIT_POINT;
       
   129 	}
       
   130 
       
   131 /**
       
   132  * CCalenCalDavPlugin::InfobarL
       
   133  * show an additional infobar
       
   134  */
       
   135 const TDesC& CCalenCalDavPlugin::InfobarL()
       
   136 	{
       
   137 	TRACE_ENTRY_POINT;
       
   138 	return KNullDesC;
       
   139 	TRACE_EXIT_POINT;
       
   140 	}
       
   141 
       
   142 /**
       
   143  * CCalenCalDavPlugin::PreviewPaneL
       
   144  * show an additional preview pabe
       
   145  */
       
   146 CCoeControl* CCalenCalDavPlugin::PreviewPaneL(TRect& /* aRect */)
       
   147 	{
       
   148 	TRACE_ENTRY_POINT;
       
   149 	return NULL;
       
   150 	TRACE_EXIT_POINT;
       
   151 	}
       
   152 
       
   153 /**
       
   154  * CCalenCalDavPlugin::CustomPreviewPaneL
       
   155  * show an additional custom preview pane
       
   156  */
       
   157 MCalenPreview* CCalenCalDavPlugin::CustomPreviewPaneL(TRect& /* aRect */)
       
   158 	{
       
   159 	TRACE_ENTRY_POINT;
       
   160 	return NULL;
       
   161 	TRACE_EXIT_POINT;
       
   162 	}
       
   163 
       
   164 /**
       
   165  * CCalenCalDavPlugin::CustomiseMenuPaneL
       
   166  * customize menu pane
       
   167  */
       
   168 TBool CCalenCalDavPlugin::CustomiseMenuPaneL(TInt /*aResourceId*/,
       
   169 		CEikMenuPane* /*aMenuPane*/)
       
   170 	{
       
   171 	TRACE_ENTRY_POINT;
       
   172 	return EFalse;
       
   173 	TRACE_EXIT_POINT;
       
   174 	}
       
   175 
       
   176 /**
       
   177  * CCalenCalDavPlugin::HandleCommandL
       
   178  * let this plugin handle its own commands
       
   179  */
       
   180 TBool CCalenCalDavPlugin::HandleCommandL(const TCalenCommand& /*aCommand*/)
       
   181 	{
       
   182 	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
       
   183 	return EFalse;
       
   184 	}
       
   185 
       
   186 /**
       
   187  * CCalenCalDavPlugin::CommandHandlerL
       
   188  * let this plugin handle its own commands
       
   189  */
       
   190 MCalenCommandHandler* CCalenCalDavPlugin::CommandHandlerL(TInt /*aCommand*/)
       
   191 	{
       
   192 	TRACE_ENTRY_POINT;
       
   193 	MCalenCommandHandler* commandHandler = NULL;
       
   194 	return commandHandler;TRACE_EXIT_POINT;
       
   195 	}
       
   196 
       
   197 /**
       
   198  * CCalenCalDavPlugin::RemoveViewsFromCycle
       
   199  * remove added views from cycle
       
   200  */
       
   201 void CCalenCalDavPlugin::RemoveViewsFromCycle(RArray<TInt>& /*aViews*/)
       
   202 	{
       
   203 	TRACE_ENTRY_POINT;TRACE_EXIT_POINT;
       
   204 	}
       
   205 
       
   206 /**
       
   207  * CCalenCalDavPlugin::GetCustomSettingsL
       
   208  * add custom settings to calendar setting pane
       
   209  * all CalDav settings are added here into UI
       
   210  */
       
   211 void CCalenCalDavPlugin::GetCustomSettingsL(
       
   212 		RPointerArray<CAknSettingItem>& aCustomSettingArray)
       
   213 	{
       
   214 	TRACE_ENTRY_POINT
       
   215 
       
   216 	RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   217 	iServices->GetAllCalendarInfoL(calendarInfoList);
       
   218 	CleanupClosePushL(calendarInfoList);
       
   219 
       
   220 	TInt count = calendarInfoList.Count();
       
   221 	for (TInt i = 0; i < count; i++)
       
   222 		{
       
   223 		TPtrC calendar = calendarInfoList[i]->FileNameL();
       
   224 
       
   225 		RPointerArray<CAknSettingItem> settings;
       
   226 
       
   227 		CCalDavBooleanSettingItem * enable = CCalDavBooleanSettingItem::NewL(
       
   228 				ECalDavSettingEnable, iSession, calendar);
       
   229 
       
   230 		CCalDavTextSettingItem* url = CCalDavTextSettingItem::NewL(
       
   231 				ECalDavSettingUrl, iSession, calendar);
       
   232 		url->SetEnableSettingItem(enable);
       
   233 		settings.Append(url);
       
   234 
       
   235 		CCalDavTextSettingItem* user = CCalDavTextSettingItem::NewL(
       
   236 				ECalDavSettingUser, iSession, calendar);
       
   237 		user->SetEnableSettingItem(enable);
       
   238 		settings.Append(user);
       
   239 
       
   240 		CCalDavPasswordSettingItem* password = CCalDavPasswordSettingItem::NewL(
       
   241 				ECalDavSettingPassword, iSession, calendar);
       
   242 		password->SetEnableSettingItem(enable);
       
   243 		settings.Append(password);
       
   244 
       
   245 		CCalDavBooleanSettingItem * keepserver =
       
   246 				CCalDavBooleanSettingItem::NewL(ECalDavSettingKeepServer,
       
   247 						iSession, calendar);
       
   248 		settings.Append(keepserver);
       
   249 
       
   250 		//    CCalDavBooleanSettingItem * immediatesync = CCalDavBooleanSettingItem::NewL(ECalDavSettingSyncImmediate,iSession, calendar);
       
   251 		//    settings.Append(immediatesync);
       
   252 
       
   253 		CCalDavEnumeratedTextSettingItem* range =
       
   254 				CCalDavEnumeratedTextSettingItem::NewL(ECalDavSettingSyncRange,
       
   255 						iSession, calendar);
       
   256 		settings.Append(range);
       
   257 
       
   258 		CCalDavEnumeratedTextSettingItem* time =
       
   259 				CCalDavEnumeratedTextSettingItem::NewL(
       
   260 						ECalDavSettingSyncInterval, iSession, calendar);
       
   261 		settings.Append(time);
       
   262 		settings.Append(enable);
       
   263 
       
   264 		CCalenNestedSettingItem* item = new (ELeave) CCalenNestedSettingItem(0,
       
   265 				settings, calendarInfoList[i]->NameL());
       
   266 		CleanupStack::PushL(item);
       
   267 
       
   268 		item->SetEmptyItemTextL(KNullDesC);
       
   269 
       
   270 		if (count == 1)
       
   271 			{
       
   272 			HBufC16* name = StringLoader::LoadLC(R_CALDAV);
       
   273 			item->ConstructL(EFalse, 0, *name, NULL,
       
   274 			R_CALEN_EMPTY_SETTING_PAGE, EAknSetListBox, NULL,
       
   275 			R_CALEN_EMPTY_POPUP_SETTING_TEXTS );
       
   276 			CleanupStack::PopAndDestroy(name);
       
   277 			}
       
   278 		else
       
   279 			{
       
   280 			item->ConstructL(EFalse, 0, calendarInfoList[i]->NameL(), NULL,
       
   281 			R_CALEN_EMPTY_SETTING_PAGE, EAknSetListBox, NULL,
       
   282 			R_CALEN_EMPTY_POPUP_SETTING_TEXTS );
       
   283 			}
       
   284 		aCustomSettingArray.Append(item);
       
   285 		CleanupStack::Pop(item);
       
   286 		}
       
   287 	CleanupStack::PopAndDestroy(&calendarInfoList);
       
   288 
       
   289 	TRACE_EXIT_POINT;
       
   290 	}
       
   291 
       
   292 /**
       
   293  * CCalenCalDavPlugin::GetCustomViewsL
       
   294  * add custom views
       
   295  */
       
   296 void CCalenCalDavPlugin::GetCustomViewsL(RPointerArray<CCalenView>&
       
   297 /*aCustomViewArray*/)
       
   298 	{
       
   299 	TRACE_ENTRY_POINT;
       
   300 	TRACE_EXIT_POINT;
       
   301 	}
       
   302 
       
   303 /**
       
   304  * CCalenCalDavPlugin::HandleNotification
       
   305  * handle received notifications in this plugin
       
   306  */
       
   307 void CCalenCalDavPlugin::HandleNotification(const TCalenNotification /*aNotification*/)
       
   308 	{
       
   309 	TRACE_ENTRY_POINT;
       
   310 	TRACE_EXIT_POINT;
       
   311 	}
       
   312 
       
   313 /**
       
   314  * CCalenCalDavPlugin::CanBeEnabledDisabled
       
   315  * can the plugin be disabled or enabled, called by customization manager
       
   316  */
       
   317 TBool CCalenCalDavPlugin::CanBeEnabledDisabled()
       
   318 	{
       
   319 	return EFalse;
       
   320 	}
       
   321 
       
   322 /**
       
   323  * CCalenCalDavPlugin::CalenCustomisationExtensionL
       
   324  * add custom extensions
       
   325  */
       
   326 TAny* CCalenCalDavPlugin::CalenCustomisationExtensionL(TUid /*aExtensionUid*/)
       
   327 	{
       
   328 	TRACE_ENTRY_POINT;
       
   329 	TRACE_EXIT_POINT;
       
   330 	return NULL;
       
   331 	}
       
   332 
       
   333 /**
       
   334  * CCalenCalDavPlugin::CalenCommandHandlerExtensionL
       
   335  * CalenCommandHandlerExtensionL
       
   336  */
       
   337 TAny* CCalenCalDavPlugin::CalenCommandHandlerExtensionL(TUid /*aExtensionUid*/)
       
   338 	{
       
   339 	TRACE_ENTRY_POINT;
       
   340 	TRACE_EXIT_POINT;
       
   341 	return NULL;
       
   342 	}
       
   343 //EOF