calendarengines/versit2/src/ICalEvent.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation 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 Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implements the definition of CICalEvent.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // Class include.
       
    21 #include "ICalEvent.h"	// CICalEvent
       
    22 
       
    23 //debug
       
    24 #include "calendarengines_debug.h"
       
    25 
       
    26 // User includes.
       
    27 #include "ICalKeyWords.h"			// Literals
       
    28 
       
    29 /**
       
    30 Static factory construction
       
    31 @return A new event component
       
    32 @internalTechnology
       
    33 */
       
    34 CICalEvent* CICalEvent::NewLC(TICalMethod aMethod)
       
    35 	{
       
    36 	TRACE_ENTRY_POINT;
       
    37 	
       
    38 	CICalEvent* self = new (ELeave) CICalEvent;
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL(aMethod);
       
    41 	TRACE_EXIT_POINT;
       
    42 	
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 /**
       
    47 Destructor
       
    48 @internalTechnology
       
    49 */
       
    50 CICalEvent::~CICalEvent()
       
    51 	{
       
    52 	TRACE_ENTRY_POINT;
       
    53 	TRACE_EXIT_POINT;
       
    54 	}
       
    55 
       
    56 /**
       
    57 Constructor
       
    58 @internalTechnology
       
    59 */
       
    60 CICalEvent::CICalEvent()
       
    61 	{
       
    62 	TRACE_ENTRY_POINT;
       
    63 	
       
    64 	iComponentType = EICalEvent;
       
    65 	
       
    66 	TRACE_EXIT_POINT;
       
    67 	}
       
    68 
       
    69 /**
       
    70 Internal construction
       
    71 @internalTechnology
       
    72 */
       
    73 void CICalEvent::ConstructL(TICalMethod aMethod)
       
    74 	{
       
    75 	TRACE_ENTRY_POINT;
       
    76 	
       
    77 	iMethod = aMethod;
       
    78 	switch(iMethod)
       
    79 		{
       
    80 		case EMethodNone:
       
    81 			iComponentMethodBitMask = EMaskEventNone;
       
    82 			break;
       
    83 		case EMethodPublish:
       
    84 			iComponentMethodBitMask = EMaskEventPublish;
       
    85 			break;
       
    86 		case EMethodRequest:
       
    87 			iComponentMethodBitMask = EMaskEventRequest;
       
    88 			break;
       
    89 		case EMethodReply:
       
    90 			iComponentMethodBitMask = EMaskEventReply;
       
    91 			break;
       
    92 		case EMethodAdd:
       
    93 			iComponentMethodBitMask = EMaskEventAdd;
       
    94 			break;
       
    95 		case EMethodCancel:
       
    96 			iComponentMethodBitMask = EMaskEventCancel;
       
    97 			break;
       
    98 		case EMethodRefresh:
       
    99 			iComponentMethodBitMask = EMaskEventRefresh;
       
   100 			break;
       
   101 		case EMethodCounter:
       
   102 			iComponentMethodBitMask = EMaskEventCounter;
       
   103 			break;
       
   104 		case EMethodDeclineCounter:
       
   105 			iComponentMethodBitMask = EMaskEventDeclineCounter;
       
   106 			break;
       
   107 		}
       
   108 	TRACE_EXIT_POINT;
       
   109 	}
       
   110 	
       
   111 /**
       
   112 Checks that the iCalendar specification allows this calendar component to
       
   113 contain the property aName
       
   114 @param aName the name of the property to validate
       
   115 @return ETrue if the property is valid for this component, otherwise EFalse
       
   116 @internalTechnology
       
   117 */
       
   118 TBool CICalEvent::ValidatePropertyImpl(const TDesC& aName) const
       
   119 	{
       
   120 	TRACE_ENTRY_POINT;
       
   121 	
       
   122 	if ((aName.CompareF(KICalClass) == 0) || (aName.CompareF(KICalCreated) == 0) ||
       
   123 		(aName.CompareF(KICalDescription) == 0) || (aName.CompareF(KICalDtstart) == 0) ||
       
   124 		(aName.CompareF(KICalGeo) == 0) || (aName.CompareF(KICalLastmodified) == 0) ||
       
   125 		(aName.CompareF(KICalLocation) == 0) || (aName.CompareF(KICalOrganizer) == 0) ||
       
   126 		(aName.CompareF(KICalPriority) == 0) || (aName.CompareF(KICalDtstamp) == 0) ||
       
   127 		(aName.CompareF(KICalSequence) == 0) || (aName.CompareF(KICalStatus) == 0) ||
       
   128 		(aName.CompareF(KICalSummary) == 0) || (aName.CompareF(KICalTransp) == 0) ||
       
   129 		(aName.CompareF(KICalUid) == 0) || (aName.CompareF(KICalUrl) == 0) ||
       
   130 		(aName.CompareF(KICalRecurrenceId) == 0))
       
   131 		{
       
   132 		//	0..1	CLASS	
       
   133 		//	0..1	CREATED
       
   134 		//	0..1	DESCRIPTION
       
   135 		//	0..1	DTSTART
       
   136 		//	0..1	GEO
       
   137 		//	0..1	LAST-MOD
       
   138 		//	0..1	LOCATION
       
   139 		//	0..1	ORGANIZER
       
   140 		//	0..1	PRIORITY
       
   141 		//	0..1	DTSTAMP
       
   142 		//	0..1	SEQUENCE
       
   143 		//	0..1	STATUS
       
   144 		//	0..1	SUMMARY
       
   145 		//	0..1	TRANSP
       
   146 		//	0..1	UID
       
   147 		//	0..1	URL
       
   148 		//	0..1	RECURRENCE-ID
       
   149 		TRACE_EXIT_POINT;
       
   150 		return (FindProperty(aName) == NULL);
       
   151 		}
       
   152 	// Either DTEND or DURATION may exist but *not* both
       
   153 	else if (aName.CompareF(KICalDtend) == 0)
       
   154 		{
       
   155 		//	0..1	DTEND
       
   156 		if (FindProperty(aName) == NULL)
       
   157 			{
       
   158 			TRACE_EXIT_POINT;
       
   159 			return (FindProperty(KICalDuration) == NULL);
       
   160 			}
       
   161 		TRACE_EXIT_POINT;
       
   162 		return EFalse;
       
   163 		}
       
   164 	else if (aName.CompareF(KICalDuration) == 0)
       
   165 		{
       
   166 		//	0..1	DURATION
       
   167 		if (FindProperty(aName) == NULL)
       
   168 			{
       
   169 			TRACE_EXIT_POINT;
       
   170 			return (FindProperty(KICalDtend) == NULL);
       
   171 			}
       
   172         
       
   173         TRACE_EXIT_POINT;			
       
   174 		return EFalse;
       
   175 		}
       
   176 	else if ((aName.CompareF(KICalAttach) == 0) || (aName.CompareF(KICalAttendee) == 0) ||
       
   177 			(aName.CompareF(KICalCategories) == 0) || (aName.CompareF(KICalComment) == 0) ||
       
   178 			(aName.CompareF(KICalContact) == 0) || (aName.CompareF(KICalExdate) == 0) ||
       
   179 			(aName.CompareF(KICalExrule) == 0) || (aName.CompareF(KICalRequeststatus) == 0) ||
       
   180 			(aName.CompareF(KICalRelatedto) == 0) || (aName.CompareF(KICalResources) == 0) ||
       
   181 			(aName.CompareF(KICalRdate) == 0) || (aName.CompareF(KICalRRule) == 0))
       
   182 		{
       
   183 		//	0..*	ATTACH
       
   184 		//	0..*	ATTENDEE
       
   185 		//	0..*	CATEGORIES
       
   186 		//	0..*	COMMENT
       
   187 		//	0..*	CONTACT
       
   188 		//	0..*	EXDATE
       
   189 		//	0..*	EXRULE
       
   190 		//	0..*	REQUEST-STATUS
       
   191 		//	0..*	RELATED-TO
       
   192 		//	0..*	RESOURCES
       
   193 		//	0..*	RDATE
       
   194 		//	0..*	RRULE
       
   195 		TRACE_EXIT_POINT;
       
   196 		return ETrue;
       
   197 		}
       
   198 	else if ((aName.Length() >= 2) && (aName.Left(2).CompareF(KICalXProperty) == 0))
       
   199 		{
       
   200 		//	0..*	X-[anything]
       
   201 		TRACE_EXIT_POINT;
       
   202 		return ETrue;
       
   203 		}
       
   204 
       
   205 	// If we got this far we didn't match any of the possible property names
       
   206 	TRACE_EXIT_POINT;
       
   207 	return EFalse;	
       
   208 	}
       
   209 	
       
   210 /**
       
   211 Checks that the iCalendar specification allows this calendar component to
       
   212 contain a nested component of type aType.
       
   213 @param aType the type of component to validate.
       
   214 @return ETrue if the component is a valid child for this component, otherwise
       
   215 EFalse.
       
   216 @internalTechnology
       
   217 */
       
   218 TBool CICalEvent::ValidateComponent(TICalComponentType aType) const
       
   219 	{
       
   220 	TRACE_ENTRY_POINT;
       
   221     TRACE_EXIT_POINT;
       
   222 	// VEVENTs can only contain VALARMs.
       
   223 	return (aType == EICalAlarm);
       
   224 	}
       
   225 	
       
   226 // End of File