pimappservices/calendar/client/src/calinstanceview.cpp
changeset 0 f979ecb2b13e
child 18 c198609911f9
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "calsessionimpl.h"
       
    17 #include "calinstanceviewimpl.h"
       
    18 #include "calentryimpl.h"
       
    19 #include "agmsimpleentry.h"
       
    20 #include "calinstanceiteratorall.h"
       
    21 #include "calinstanceiteratoruid.h"
       
    22 #ifdef SYMBIAN_SKIPPED_CALENDAR_ALARMS
       
    23 #include <asshdalarm.h>
       
    24 #endif //SYMBIAN_SKIPPED_CALENDAR_ALARMS
       
    25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    26 #include <asshdalarmcal.h>
       
    27 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include "agmsortcriteria.h"
       
    29 
       
    30 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
    31 const TInt KDefaultSortCriteriaGranularity = 1;
       
    32 #endif
       
    33 // CCalInstanceView::TCalSearchParams //
       
    34 
       
    35 /** Constructor for the search parameter data structure.
       
    36 
       
    37 @param aText The text to search for. This string cannot be longer than 32 characters. 
       
    38 Note that ownership is not taken, so the string passed in should not be deleted before the TCalSearchParams is used.
       
    39 @param aBehaviour The type of text search to do.
       
    40 
       
    41 @publishedAll
       
    42 @released
       
    43 @capability None
       
    44 */
       
    45 EXPORT_C CCalInstanceView::TCalSearchParams::TCalSearchParams(const TDesC& aText, CalCommon::TCalSearchBehaviour aBehaviour)
       
    46  : iSearchBehaviour(aBehaviour)
       
    47 	{
       
    48 	iSearchText.Set(aText);
       
    49 	}
       
    50 
       
    51 /** Get the search text.
       
    52 @return The search text.
       
    53 
       
    54 @publishedAll
       
    55 @released
       
    56 @capability None
       
    57 */
       
    58 EXPORT_C const TDesC& CCalInstanceView::TCalSearchParams::Text() const
       
    59 	{
       
    60 	return iSearchText;
       
    61 	}
       
    62 
       
    63 /** Get the search behaviour.
       
    64 @return The search behaviour.
       
    65 
       
    66 @publishedAll
       
    67 @released
       
    68 @capability None
       
    69 */
       
    70 EXPORT_C CalCommon::TCalSearchBehaviour CCalInstanceView::TCalSearchParams::Behaviour() const
       
    71 	{
       
    72 	return iSearchBehaviour;
       
    73 	}
       
    74 
       
    75 // CCalInstanceView //
       
    76 
       
    77 CCalInstanceView::CCalInstanceView()
       
    78 	{
       
    79 	}
       
    80 
       
    81 void CCalInstanceView::ConstructL(CCalSession& aSession, MCalProgressCallBack* aProgressCallBack)
       
    82 	{
       
    83 	iImpl = CCalInstanceViewImpl::NewL(aSession, aProgressCallBack);
       
    84 	}
       
    85 
       
    86 /** Allocates and constructs an instance view.
       
    87 
       
    88 The instance view can not be used until the Completed() function is called on the progress
       
    89 callback with the value KErrNone.
       
    90 
       
    91 @param aSession The calendar session from which to create the instance view.
       
    92 @param aProgressCallBack Reference to a callback object which reports the progress of the operation.
       
    93 @return Pointer to the newly created instance view.
       
    94 
       
    95 @publishedAll
       
    96 @released
       
    97 @capability None
       
    98 */
       
    99 EXPORT_C CCalInstanceView* CCalInstanceView::NewL(CCalSession& aSession, MCalProgressCallBack& aProgressCallBack)
       
   100 	{
       
   101 	CCalInstanceView* self = new (ELeave) CCalInstanceView();
       
   102 	CleanupStack::PushL(self);
       
   103 	self->ConstructL(aSession, &aProgressCallBack);
       
   104 	CleanupStack::Pop(self);
       
   105 	return self;
       
   106 	}
       
   107 	
       
   108 /** Allocates and constructs an instance view.
       
   109 
       
   110 The instance view is created synchronously.
       
   111 
       
   112 @param aSession The calendar session from which to create the instance view.
       
   113 @return Pointer to the newly created instance view.
       
   114 
       
   115 @publishedAll
       
   116 @released
       
   117 @capability None
       
   118 */
       
   119 
       
   120 EXPORT_C CCalInstanceView* CCalInstanceView::NewL(CCalSession& aSession)
       
   121 	{
       
   122 	CCalInstanceView* self = new (ELeave) CCalInstanceView();
       
   123 	CleanupStack::PushL(self);
       
   124 	self->ConstructL(aSession, NULL);
       
   125 	CleanupStack::Pop(self);
       
   126 	return self;
       
   127 	}
       
   128 
       
   129 /** Allocates and constructs an instance view.
       
   130  The instance view is created synchronously.
       
   131  
       
   132 @pre Every CCalSession has to be instantiated.
       
   133 @pre All CCalSession objects share the same handle to the Calendar server. 
       
   134 @pre A correspondent file has been opened by each CCalSession
       
   135 
       
   136 @param aSessions An array of CCalSession objects from which to create the instance view.
       
   137 @param aProgressCallBack Reference to a callback object which reports the progress of the operation.
       
   138 @return Pointer to the newly created instance view.
       
   139 
       
   140 @publishedAll
       
   141 @released
       
   142 @capability None
       
   143 */
       
   144 EXPORT_C CCalInstanceView* CCalInstanceView::NewL(RPointerArray<CCalSession>& aSessions)
       
   145 	{
       
   146 	CCalInstanceView* self = new (ELeave) CCalInstanceView();
       
   147 	CleanupStack::PushL(self);
       
   148 	self->ConstructL(aSessions, NULL);
       
   149 	CleanupStack::Pop(self);
       
   150 	return self;
       
   151 	}
       
   152 
       
   153 void CCalInstanceView::ConstructL(RPointerArray<CCalSession>& aSessions, MCalProgressCallBack* aProgressCallBack)
       
   154 	{
       
   155 	iImpl = CCalInstanceViewImpl::NewL(aSessions, aProgressCallBack);
       
   156 	}
       
   157 
       
   158 /** Allocates and constructs an instance view.
       
   159  The instance view is created asynchronously.
       
   160  
       
   161 @pre Every CCalSession has to be instantiated.
       
   162 @pre All CCalSession objects share the same handle to the Calendar server. 
       
   163 @pre A correspondent file has been opened by each CCalSession
       
   164 
       
   165 @param aSessions An array of CCalSession objects from which to create the instance view.
       
   166 @return Pointer to the newly created instance view.
       
   167 
       
   168 @publishedAll
       
   169 @released
       
   170 @capability None
       
   171 */
       
   172 EXPORT_C CCalInstanceView* CCalInstanceView::NewL(RPointerArray<CCalSession>& aSessions, MCalProgressCallBack& aProgressCallBack)
       
   173 	{
       
   174 	CCalInstanceView* self = new (ELeave) CCalInstanceView();
       
   175 	CleanupStack::PushL(self);
       
   176 	self->ConstructL(aSessions, &aProgressCallBack);
       
   177 	CleanupStack::Pop(self);
       
   178 	return self;
       
   179 	}
       
   180 /** Destructor for the view. Clear away any resources.
       
   181 @publishedAll
       
   182 @released
       
   183 @capability None
       
   184 */
       
   185 EXPORT_C CCalInstanceView::~CCalInstanceView()
       
   186 	{
       
   187 	delete iImpl;
       
   188 	}
       
   189 
       
   190 /** Gets all instances found in the specified date range, filtered as required.
       
   191 
       
   192 @param aInstanceList On return, this array contains all instances that were found.
       
   193 @param aCalViewFilter Filters instances based on the values in TCalViewFilter.
       
   194 @param aTimeRange Specifies the start and end dates between which instances should be searched for.
       
   195 Any matching instances on these dates will be included.
       
   196 
       
   197 @publishedAll
       
   198 @released
       
   199 @capability ReadUserData
       
   200 */
       
   201 EXPORT_C void CCalInstanceView::FindInstanceL(RPointerArray<CCalInstance>& aInstanceList,
       
   202 									CalCommon::TCalViewFilter aCalViewFilter,
       
   203 									const CalCommon::TCalTimeRange& aTimeRange) const
       
   204 	{
       
   205 	iImpl->FindInstanceL(aInstanceList, aCalViewFilter, aTimeRange);
       
   206 	}
       
   207 
       
   208 /** Deletes this instance, and other instances of this entry as required.
       
   209 
       
   210 This function is intended to be used together with CCalInstanceView::FindInstanceL().
       
   211 FindInstanceL() may be called to get an instance, and it can then be passed to this function to be deleted.
       
   212 
       
   213 If all instances of an entry are deleted, then the entry itself will be removed.
       
   214 
       
   215 @param aInstance The instance to be deleted. This function takes ownership of the instance.
       
   216 @param aWhichInstances Indicates whether only this instance should be deleted, or future/past/all
       
   217 instances of the same entry should also be deleted.
       
   218 
       
   219 @leave KErrNotReady If the calendar file is on a drive where the media has been removed.
       
   220 @publishedAll
       
   221 @released
       
   222 @capability WriteUserData
       
   223 */
       
   224 EXPORT_C void CCalInstanceView::DeleteL(CCalInstance* aInstance, CalCommon::TRecurrenceRange aWhichInstances)
       
   225 	{
       
   226 	iImpl->DeleteL(aInstance, aWhichInstances);
       
   227 	}
       
   228 
       
   229 /** Gets all unexcepted instances found in the specified date range, filtered as required,
       
   230 with the specified text.
       
   231 
       
   232 @param aMatchedInstanceList On return, this array contains all instances that match the search criteria specified
       
   233 .
       
   234 @param aCalViewFilter Filters instances based on the values in TCalViewFilter.
       
   235 @param aTimeRange Specifies the start and end dates between which instances should be searched for. Any
       
   236 matching instances on these dates will be included.
       
   237 @param aSearchParams Contains the text to search for and flags for use with text searching. This is optional and the text can be an empty descriptor.
       
   238 @leave KErrArgument The search text in aSearchParams contains more than 32 characters
       
   239 
       
   240 @publishedAll
       
   241 @released
       
   242 @capability ReadUserData
       
   243 */
       
   244 EXPORT_C void CCalInstanceView::FindInstanceL(RPointerArray<CCalInstance>& aMatchedInstanceList, CalCommon::TCalViewFilter aCalViewFilter,
       
   245 												const CalCommon::TCalTimeRange& aTimeRange, const TCalSearchParams& aSearchParams) const
       
   246 	{
       
   247 	iImpl->FindInstanceL(aMatchedInstanceList, aCalViewFilter, aTimeRange, aSearchParams);
       
   248 	}
       
   249 
       
   250 /** Creates an instance iterator that contains instances which match the given search criteria.
       
   251 
       
   252 @param aSettings The search settings. These include a time range, an entry type filter and an optional text
       
   253 search. @see CCalFindInstanceSettings
       
   254 
       
   255 @return The instance iterator. Ownership is returned.
       
   256 
       
   257 @pre The instance view has been created and there is an open calendar session.
       
   258 
       
   259 @publishedPartner
       
   260 @released
       
   261 
       
   262 @capability ReadUserData
       
   263 */
       
   264 EXPORT_C CCalInstanceIterator* CCalInstanceView::FindInstanceL(const CCalFindInstanceSettings& aSettings) const
       
   265 	{
       
   266 	return iImpl->FindInstanceL(aSettings);
       
   267 	}
       
   268 
       
   269 /** Creates an instance iterator that contains instances which match the given search criteria, starting from a specified instance.
       
   270 
       
   271 The instances in this iterator should be treated as if they were a snapshot from when the iterator was created.
       
   272 Note that if a view is opened with more than one file and attempts to use this method then a panic "CalInterimAPI" 15 (enum EAmbiguousInstance) will be raised.
       
   273 
       
   274 @param aSettings The search settings. These include a time range, an entry type filter and an optional text
       
   275 search. @see CCalFindInstanceSettings
       
   276 @param aStartingInstance The instance that iterator should start iterating from.
       
   277 
       
   278 @return The instance iterator. Ownership is returned.
       
   279 
       
   280 @leave KErrArgument If the starting instance does not match the filter requirements. i.e. It is outside
       
   281 of the search range or is the wrong entry type.
       
   282 @leave KErrNotFound If the starting instance does not exist in the database.
       
   283 
       
   284 @pre The instance view has been created and there is an open calendar session.
       
   285 
       
   286 @publishedPartner
       
   287 @released
       
   288 
       
   289 @capability ReadUserData
       
   290 @deprecated
       
   291 */
       
   292 EXPORT_C CCalInstanceIterator* CCalInstanceView::FindInstanceL(const CCalFindInstanceSettings& aSettings, TCalLocalUid  aLocalId, const TCalTime& aInstanceTime) const
       
   293 	{
       
   294 	return iImpl->FindInstanceL(aSettings, aLocalId, aInstanceTime);
       
   295 	}
       
   296 
       
   297 /** Creates an instance iterator that contains instances relating to a UID.
       
   298 
       
   299 Note that if a view is opened with more than one file and attempts to use this method then a panic "CalInterimAPI" 15 (enum EAmbiguousInstance) will be raised.
       
   300  
       
   301 The iterator is a snapshot of the instances that existed when it was created.  If any changes are made to
       
   302 the entries after the iterator was created they will not be seen in the results of the iterator. 
       
   303 
       
   304 @param aUid All instances have.
       
   305 @param aInstanceTime The instance time that iterator should start iterating from.
       
   306 
       
   307 @return The instance iterator containing the results. Ownership is returned.
       
   308 
       
   309 @pre The instance view has been created and there is an open calendar session.
       
   310 
       
   311 @publishedPartner
       
   312 @deprecated
       
   313 @capability ReadUserData
       
   314 */
       
   315 EXPORT_C CCalInstanceIterator* CCalInstanceView::FindInstanceByUidL(const TDesC8& aUid, const TCalTime& aInstanceTime) const
       
   316 	{
       
   317 	return iImpl->FindInstanceByUidL(aUid, aInstanceTime);
       
   318 	}
       
   319 
       
   320 /** Creates an instance iterator that contains instances relating to a UID.
       
   321 
       
   322 The iterator is a snapshot of the instances that existed when it was created.  If any changes are made to
       
   323 the entries after the iterator was created they will not be seen in the results of the iterator. 
       
   324 
       
   325 @param aUid All instances have.
       
   326 @param aInstanceTime The instance time that iterator should start iterating from.
       
   327 @param aCollectionId The Calendar Collection ID which is associated with the instance (belongs to which file) that iterator should start iterating from.
       
   328 
       
   329 @return The instance iterator containing the results. Ownership is returned.
       
   330 
       
   331 @pre The instance view has been created and there is an open calendar session.
       
   332 
       
   333 @publishedPartner
       
   334 @deprecated
       
   335 @capability ReadUserData
       
   336 */
       
   337 EXPORT_C CCalInstanceIterator* CCalInstanceView::FindInstanceByUidL(TCalCollectionId aCollectionId, const TDesC8& aUid, const TCalTime& aInstanceTime) const
       
   338 	{
       
   339 	return iImpl->FindInstanceByUidL(aCollectionId, aUid, aInstanceTime);
       
   340 	}
       
   341 
       
   342 /** Creates an instance iterator that contains instances which match the given search criteria, starting from a specified instance.
       
   343 
       
   344 The instances in this iterator should be treated as if they were a snapshot from when the iterator was created.
       
   345 
       
   346 @param aSettings The search settings. These include a time range, an entry type filter and an optional text
       
   347 search. @see CCalFindInstanceSettings
       
   348 @param aInstanceId The instance id @see TCalInstanceId
       
   349 
       
   350 @return The instance iterator. Ownership is returned.
       
   351 
       
   352 @leave KErrArgument If the starting instance does not match the filter requirements. i.e. It is outside
       
   353 of the search range or is the wrong entry type.
       
   354 @leave KErrNotFound If the starting instance does not exist in the database.
       
   355 
       
   356 @pre The instance view has been created and there is an open calendar session.
       
   357 
       
   358 @publishedPartner
       
   359 @released
       
   360 
       
   361 @capability ReadUserData
       
   362 */
       
   363 EXPORT_C CCalInstanceIterator* CCalInstanceView::FindInstanceL(const CCalFindInstanceSettings& aSettings, TCalInstanceId& aInstanceId) const
       
   364 	{
       
   365 	return iImpl->FindInstanceL(aSettings, aInstanceId);
       
   366 	}
       
   367 
       
   368 /** Creates an instance iterator starting from a specified instance.
       
   369  Note that if a view is opened with more than one file and attempts to use this method then a panic "CalInterimAPI" 15 (enum EAmbiguousInstance) will be raised.
       
   370  
       
   371 @param aInstanceTime The time from which the iterator should start iterating instances.
       
   372 @return The instance. The ownership is returned.
       
   373 @pre The instance view has been created and there is an open calendar session.
       
   374 @deprecated
       
   375 */
       
   376 EXPORT_C CCalInstance* CCalInstanceView::FindInstanceL(TCalLocalUid aLocalId, const TCalTime& aInstanceTime) const
       
   377 	{
       
   378 	return iImpl->FindInstanceL(aLocalId, aInstanceTime);
       
   379 	}
       
   380 
       
   381 /** Creates an instance iterator based on the TCalInstanceId
       
   382 
       
   383 @pre The instance view has been created and there is an open calendar session.
       
   384 @param aInstanceId The instance id.
       
   385 @return The instance.  
       
   386 */
       
   387 EXPORT_C CCalInstance* CCalInstanceView::FindInstanceL(TCalInstanceId& aInstanceId) const
       
   388 	{
       
   389 	return iImpl->FindInstanceL(aInstanceId);
       
   390 	}
       
   391 
       
   392 #ifdef SYMBIAN_SKIPPED_CALENDAR_ALARMS
       
   393 /** Gets all instances which have alarms within the time range specified in aAlarmedInstanceParams.
       
   394 
       
   395 @param aAlarmedInstanceList On return, a list of alarmed Calendar instances 
       
   396 that meet the parameters of the search given in aAlarmedInstanceParams.
       
   397 @param aAlarmedInstanceParams The parameters for the search.
       
   398 @see KSkippedAlarmInstancesPubSubKey
       
   399 @publishedPartner
       
   400 @released
       
   401 */
       
   402 EXPORT_C void CCalInstanceView::FindAlarmedInstanceL(RPointerArray<CCalInstance>& aAlarmedInstanceList,    
       
   403 								   					 TASShdAlarmedInstanceParams aAlarmedInstanceParams) const
       
   404 	{
       
   405 	iImpl->FindAlarmedInstanceL(aAlarmedInstanceList, aAlarmedInstanceParams);					   
       
   406 	}
       
   407 #endif
       
   408 
       
   409 /** Gets the next day with an instance on it that matches the filter.
       
   410 
       
   411 @param aCalViewFilter Filters instances based on the values in TCalViewFilter.
       
   412 @param aStartDate Specifies the start date from which instances should be searched. Any
       
   413 matching instances on this date will NOT be included.
       
   414 @return The next day that contains at least one suitable instance, or Time::NullTime() if none is found.
       
   415 
       
   416 @publishedAll
       
   417 @released
       
   418 @capability None
       
   419 */
       
   420 EXPORT_C TCalTime CCalInstanceView::NextInstanceL(CalCommon::TCalViewFilter aCalViewFilter, const TCalTime& aStartDate) const
       
   421  	{
       
   422  	return iImpl->NextInstanceL(aCalViewFilter, aStartDate);
       
   423 	}
       
   424 
       
   425 /** Gets the previous day with an instance on it that matches the filter.
       
   426 
       
   427 @param aCalViewFilter Filters instances based on the values in TCalViewFilter.
       
   428 @param aStartDate Specifies the start date before which instances should be searched. Any
       
   429 matching instances on this date will NOT be included.
       
   430 @return The previous day that contains at least one suitable instance, or Time::NullTime() if none is found.
       
   431 
       
   432 @publishedAll
       
   433 @released
       
   434 @capability None
       
   435 */
       
   436 EXPORT_C TCalTime CCalInstanceView::PreviousInstanceL(CalCommon::TCalViewFilter aCalViewFilter, const TCalTime& aStartDate) const
       
   437  	{
       
   438  	return iImpl->PreviousInstanceL(aCalViewFilter, aStartDate);
       
   439 	}
       
   440 
       
   441 // CCalFindInstanceSettings //
       
   442 
       
   443 
       
   444 /** Create a new search settings object for use in CCalInstanceView::FindInstanceL.
       
   445 @param aFilter Filters instances based on the values in TCalViewFilter.
       
   446 @param aTimeRange Specifies the start and end dates between which instances should be searched for. Any
       
   447 matching instances on these dates will be included.
       
   448 @return A pointer to the new search settings object. Ownership is returned.
       
   449 @pre None
       
   450 @post A new search settings object is constructed and initialised using the given parameters.
       
   451 @capability None
       
   452 */
       
   453 EXPORT_C CCalFindInstanceSettings* CCalFindInstanceSettings::NewL(CalCommon::TCalViewFilter aFilter, const CalCommon::TCalTimeRange& aTimeRange)
       
   454 	{
       
   455 	CCalFindInstanceSettings* self = new (ELeave) CCalFindInstanceSettings(aFilter,aTimeRange);
       
   456 	CleanupStack::PushL(self);
       
   457 	self->ConstructL();
       
   458 	CleanupStack::Pop(self);
       
   459 	return self;
       
   460 	
       
   461 	}
       
   462 
       
   463 CCalFindInstanceSettings::CCalFindInstanceSettings(CalCommon::TCalViewFilter aFilter, const CalCommon::TCalTimeRange& aTimeRange) :
       
   464 	iTimeRange(aTimeRange), iFilter(aFilter), iPriorityRange(0, KMaxTUint)
       
   465 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
   466 , iSortCriteria(NULL)
       
   467 #endif
       
   468 	{
       
   469 	}
       
   470 
       
   471 void CCalFindInstanceSettings::ConstructL()
       
   472 	{
       
   473 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
   474 	iSortCriteria = CCalSortCriteria::NewL();
       
   475 #endif
       
   476 	}
       
   477 
       
   478 /** Destructor.
       
   479 @pre The search settings object has been constructed.
       
   480 @post The object is destroyed.
       
   481 @publishedPartner
       
   482 @released
       
   483 @capability None
       
   484 */
       
   485 EXPORT_C CCalFindInstanceSettings::~CCalFindInstanceSettings()
       
   486 	{
       
   487 	delete iSearchText;
       
   488 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
   489 	delete iSortCriteria;
       
   490 #endif
       
   491 	}
       
   492 
       
   493 /** Specifies text to be searched for in CCalInstanceView::FindInstanceL.
       
   494 @param aSearchParams Contains the text to search for and flags for use with text searching. 
       
   495 @leave KErrArgument The search text in aSearchParams contains more than 32 characters
       
   496 @pre None
       
   497 @post The text search criteria of the CCalFindInstanceSettings have been updated.
       
   498 @publishedPartner
       
   499 @released
       
   500 @capability None
       
   501 */
       
   502 EXPORT_C void CCalFindInstanceSettings::SetTextSearchL(const CCalInstanceView::TCalSearchParams& aSearchParams)
       
   503 	{
       
   504 	delete iSearchText;
       
   505 	iSearchText = NULL;
       
   506 	iSearchText = aSearchParams.Text().AllocL();
       
   507 	iSearchBehaviour = aSearchParams.Behaviour();
       
   508 	}
       
   509 
       
   510 /** Filters which types of entries will be found in CCalInstanceView::FindInstanceL.
       
   511 @param aFilter A selection of flags defining the filter, as defined in CalCommon::TCalViewFilter.
       
   512 @pre None
       
   513 @post The filter of this CCalFindInstanceSettings object has been updated.
       
   514 @publishedPartner
       
   515 @released
       
   516 @capability None
       
   517 */
       
   518 EXPORT_C void CCalFindInstanceSettings::SetFilter(CalCommon::TCalViewFilter aFilter)
       
   519 	{
       
   520 	iFilter = aFilter;
       
   521 	}
       
   522 
       
   523 /** Specifies the time range to be searched in CCalInstanceView::FindInstanceL.
       
   524 @param aTimeRange The start and end of the time range to be searched. 
       
   525 @pre None
       
   526 @post The time range setting of this CCalFindInstanceSettings object has been updated.
       
   527 @publishedPartner
       
   528 @released
       
   529 @capability None
       
   530 */
       
   531 EXPORT_C void CCalFindInstanceSettings::SetTimeRange(const CalCommon::TCalTimeRange& aTimeRange)
       
   532 	{
       
   533 	iTimeRange = aTimeRange;
       
   534 	}
       
   535 
       
   536 CalCommon::TCalSearchBehaviour CCalFindInstanceSettings::Behaviour() const
       
   537 	{
       
   538 	return iSearchBehaviour;
       
   539 	}
       
   540 
       
   541 CalCommon::TCalViewFilter CCalFindInstanceSettings::Filter() const
       
   542 	{
       
   543 	return iFilter;
       
   544 	}
       
   545 
       
   546 const CalCommon::TCalTimeRange& CCalFindInstanceSettings::TimeRange() const
       
   547 	{
       
   548 	return iTimeRange;
       
   549 	}
       
   550 	
       
   551 const TDesC& CCalFindInstanceSettings::Text() const
       
   552 	{
       
   553 	if(iSearchText)
       
   554 		{
       
   555 		return *iSearchText;	
       
   556 		}
       
   557 	else
       
   558 		{
       
   559 		return KNullDesC;	
       
   560 		}
       
   561 	}
       
   562 
       
   563 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
   564 /** Specifies the priority range to be searched in CCalInstanceView::FindInstanceL.
       
   565 @param aPriorityRange The priority range that will be searched.
       
   566 @pre None
       
   567 @post The filter of this CCalFindInstanceSettings object has been updated.
       
   568 @publishedAll
       
   569 @prototype
       
   570 @capability None
       
   571 */
       
   572 EXPORT_C void CCalFindInstanceSettings::SetPriorityRange(const CalCommon::TCalPriorityRange& aPriorityRange)
       
   573 	{
       
   574 	iPriorityRange = aPriorityRange;
       
   575 	}
       
   576 #endif
       
   577 
       
   578 const CalCommon::TCalPriorityRange& CCalFindInstanceSettings::PriorityRange() const
       
   579 	{
       
   580 	return iPriorityRange;
       
   581 	}
       
   582 
       
   583 #ifdef SYMBIAN_CALENDAR_ENHANCEDSEARCHANDSORT
       
   584 /** Return the reference of sort criteria which defines the sort order of the instances 
       
   585     returned by CCalInstanceView::FindInstanceL. If sort criteria is not defined the 
       
   586     default sort order will apply.
       
   587 @return The reference to sort criteria object    
       
   588 @pre None
       
   589 @post None.
       
   590 @publishedAll
       
   591 @prototype
       
   592 @capability None
       
   593 */
       
   594 EXPORT_C CCalSortCriteria& CCalFindInstanceSettings::SortCriteria()
       
   595 	{
       
   596 	return *iSortCriteria;
       
   597 	}
       
   598 
       
   599 
       
   600 /** Return the reference of sort criteria which defines the sort order of the instances 
       
   601     returned by CCalInstanceView::FindInstanceL. If sort criteria is not defined the 
       
   602     default sort order will apply.
       
   603 @return The reference to sort criteria object    
       
   604 @pre None
       
   605 @post None.
       
   606 @publishedAll
       
   607 @prototype
       
   608 @capability None
       
   609 */
       
   610 EXPORT_C const CCalSortCriteria& CCalFindInstanceSettings::SortCriteria() const
       
   611 	{
       
   612 	return *iSortCriteria;
       
   613 	}
       
   614 
       
   615 
       
   616 // CCalSortCriteria //
       
   617 
       
   618 /** Create CCalSortCriteria object.
       
   619 @return Pointer to new created CCalSortCriteria object 
       
   620 @pre None
       
   621 @post A new CCalSortCriteria object is created.
       
   622 @internalComponent
       
   623 @prototype
       
   624 @capability None
       
   625 */
       
   626 EXPORT_C CCalSortCriteria* CCalSortCriteria::NewL()
       
   627 	{
       
   628 	CCalSortCriteria* self = new (ELeave) CCalSortCriteria();
       
   629 	CleanupStack::PushL(self);
       
   630 	self->ConstructL();
       
   631 	CleanupStack::Pop();
       
   632 	return self;
       
   633 	}
       
   634 
       
   635 /** CCalSortCriteria destructor.
       
   636 @pre The sort criteria object has been constructed.
       
   637 @post The object is destroyed.
       
   638 @internalComponent
       
   639 @prototype
       
   640 @capability None
       
   641 */
       
   642 EXPORT_C CCalSortCriteria::~CCalSortCriteria()
       
   643 	{
       
   644 	iSortCriterionList.ResetAndDestroy();
       
   645 	delete iSortCriteria;
       
   646 	}
       
   647 
       
   648 CCalSortCriteria::CCalSortCriteria()
       
   649 	: iSortCriterionList(KDefaultSortCriteriaGranularity)
       
   650 	{
       
   651 	}
       
   652 
       
   653 void CCalSortCriteria::ConstructL()
       
   654 	{
       
   655 	iSortCriteria = CAgnSortCriteria::NewL();
       
   656 	}
       
   657 
       
   658 const CAgnSortCriteria& CCalSortCriteria::SortCriteria() const
       
   659 	{
       
   660 	return *iSortCriteria;
       
   661 	}
       
   662 
       
   663 /** Append sort criterion to the end of sort criteria list.
       
   664 @param aAttribute Sort attribute of the sort criterion
       
   665 @param aAttribute Sort direction of the sort criterion
       
   666 @pre None
       
   667 @post the new sort criterion has been added into the sort criteria list.
       
   668 @publishedAll
       
   669 @prototype
       
   670 @capability None
       
   671 */
       
   672 EXPORT_C void CCalSortCriteria::AppendCriterionL(CalCommon::TCalSortAttribute aAttr, CalCommon::TCalSortDirection aDir)
       
   673 	{
       
   674 	//reserve the memory space in case the failure when calling iSortCriterionList.AppendL later
       
   675 	const TInt KNumOfCriteria(1);
       
   676 	iSortCriterionList.ReserveL(KNumOfCriteria);
       
   677 	
       
   678 	TInt index = iSortCriteria->AppendCriterionL(aAttr, aDir);
       
   679 	CCalSortCriterion* sortCriterion = CCalSortCriterion::NewL(iSortCriteria->AtL(index));
       
   680 	iSortCriterionList.Append(sortCriterion);
       
   681 	}
       
   682 
       
   683 /** Get the number of sort criteria.
       
   684 @return The number of sort criteria 
       
   685 @pre None
       
   686 @post None.
       
   687 @publishedAll
       
   688 @prototype
       
   689 @capability None
       
   690 */
       
   691 EXPORT_C TInt CCalSortCriteria::Count() const
       
   692 	{
       
   693 	return iSortCriteria->Count();
       
   694 	}
       
   695 
       
   696 /** Get the sort criterion at specified index.
       
   697 @param aIndex The index of wanted sort criterion  
       
   698 @return Reference to the sort criterion 
       
   699 @pre None
       
   700 @post None.
       
   701 @publishedAll
       
   702 @prototype
       
   703 @capability None
       
   704 */
       
   705 EXPORT_C const CCalSortCriterion& CCalSortCriteria::AtL(TInt aIndex) const
       
   706 	{
       
   707 	if((aIndex < 0) || (aIndex >= iSortCriteria->Count()))
       
   708 		{
       
   709 		//avoid the panic mightly raised by iSortCriteria[aIndex] 
       
   710 		User::Leave(KErrArgument);
       
   711 		}
       
   712 	
       
   713 	return *iSortCriterionList[aIndex]; 
       
   714 	}
       
   715 
       
   716 /** Set the sort orders which are used to sort instances type.
       
   717 @param aTypeOrder Reference to an array of CCalEntry::TType  
       
   718 @pre None
       
   719 @post The sort order of entry types have been updated.
       
   720 @publishedAll
       
   721 @prototype
       
   722 @capability None
       
   723 */
       
   724 EXPORT_C void CCalSortCriteria::SetEntryTypeOrderL(const RArray<CCalEntry::TType>& aTypeOrder)
       
   725 	{
       
   726 	iSortCriteria->SetEntryTypeOrderL(aTypeOrder);
       
   727 	}
       
   728 
       
   729 /** Get the sort order which are used to sort entry type.
       
   730 @return Reference to the array of CCalEntry::TType stored in the sort criteria 
       
   731 @pre None
       
   732 @post None.
       
   733 @publishedAll
       
   734 @prototype
       
   735 @capability None
       
   736 */
       
   737 EXPORT_C const RArray<CCalEntry::TType>& CCalSortCriteria::EntryTypeOrder() const
       
   738 	{
       
   739 	return iSortCriteria->EntryTypeOrder();
       
   740 	}
       
   741 
       
   742 CCalSortCriterion* CCalSortCriterion::NewL(const TAgnSortCriterion& aSortCriterion)
       
   743 	{
       
   744 	CCalSortCriterion* self = new (ELeave) CCalSortCriterion(aSortCriterion);
       
   745 	return self;
       
   746 	}
       
   747 
       
   748 CCalSortCriterion::CCalSortCriterion(const TAgnSortCriterion& aSortCriterion) 
       
   749 	: iSortCriterion(aSortCriterion)
       
   750 	{
       
   751 	}
       
   752 
       
   753 CCalSortCriterion::~CCalSortCriterion()
       
   754 	{
       
   755 	}
       
   756 
       
   757 /** Get the sort attribute.
       
   758 @return The sort attribute of the sort criterion 
       
   759 @pre None
       
   760 @post None.
       
   761 @publishedAll
       
   762 @prototype
       
   763 @capability None
       
   764 */
       
   765 EXPORT_C CalCommon::TCalSortAttribute CCalSortCriterion::SortAttribute() const
       
   766 	{
       
   767 	return iSortCriterion.iSortAttribute;
       
   768 	}
       
   769 
       
   770 /** Get the sort direction.
       
   771 @return The sort direction of the sort criterion 
       
   772 @pre None
       
   773 @post None.
       
   774 @publishedAll
       
   775 @prototype
       
   776 @capability None
       
   777 */
       
   778 EXPORT_C CalCommon::TCalSortDirection CCalSortCriterion::SortDirection() const
       
   779 	{
       
   780 	return iSortCriterion.iSortDirection;
       
   781 	}
       
   782 #endif