calendarengines/agnversit2/src/AgnParseRRuleYearly.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:   This file contains implementation of iCal parser which parses 
       
    15 *                the yearly recurring event specific information.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "AgnParseRRuleYearly.h"
       
    22 
       
    23 #include "calendarengines_debug.h"
       
    24 
       
    25 #include "ICalValue.h"
       
    26 #include <calrrule.h>
       
    27 
       
    28 /**
       
    29 Constructor
       
    30 @param aAgnImpUtil AgnVersit2Importer utility functions
       
    31 */
       
    32 CAgnParseRRuleYearly::CAgnParseRRuleYearly( MAgnImpUtil& aAgnImpUtil ):
       
    33                         CAgnParseRRule( aAgnImpUtil )
       
    34     {
       
    35     TRACE_ENTRY_POINT;
       
    36     TRACE_EXIT_POINT;
       
    37     }
       
    38 
       
    39 
       
    40 /**
       
    41 Destructor
       
    42 */
       
    43 CAgnParseRRuleYearly::~CAgnParseRRuleYearly()
       
    44     {
       
    45     TRACE_ENTRY_POINT;
       
    46     TRACE_EXIT_POINT;
       
    47     }
       
    48 
       
    49 
       
    50 /**
       
    51 Constructs a new CAgnParseRRuleYearly and returns it. The object is left on the
       
    52 cleanup stack.
       
    53 @param aAgnImpUtil AgnVersit2Importer utility functions
       
    54 @return a new CAgnParseRRuleYearly.
       
    55 */
       
    56 CAgnParseRRule* CAgnParseRRuleYearly::NewLC( MAgnImpUtil& aAgnImpUtil )
       
    57     {
       
    58     TRACE_ENTRY_POINT;
       
    59     
       
    60     CAgnParseRRule *self = new (ELeave) CAgnParseRRuleYearly( aAgnImpUtil );
       
    61     CleanupStack::PushL( self );
       
    62     
       
    63     
       
    64     TRACE_EXIT_POINT;
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 /**
       
    70 Parse the keywords and update RRule
       
    71 @param aSegment recurrence rule value segment.
       
    72 @param aRule recurrence rules 
       
    73 @return True if parsed the keyword successfully
       
    74 */
       
    75 TBool CAgnParseRRuleYearly::DoParseL( CICalRuleSegment& aSegment, TCalRRule& aRule ) 
       
    76     {
       
    77     TRACE_ENTRY_POINT;
       
    78     
       
    79     TBool parsed;
       
    80     
       
    81     switch( aSegment.Type() )
       
    82         {
       
    83         //ESegByDay
       
    84         case CICalRuleSegment::ESegByDay :
       
    85             {
       
    86             parsed = SetRRuleByDayL( aSegment, aRule );
       
    87            	break;
       
    88             }
       
    89         
       
    90         //ESegByMonth
       
    91         case CICalRuleSegment::ESegByMonth :
       
    92             {
       
    93             parsed = SetRRuleByMonthL( aSegment, aRule );
       
    94            	break;
       
    95             }
       
    96         default:
       
    97             {
       
    98             parsed = EFalse;
       
    99             }
       
   100         }
       
   101 
       
   102     TRACE_EXIT_POINT;
       
   103     return parsed;
       
   104     }
       
   105 
       
   106 
       
   107 /**
       
   108 Finalize the parsing
       
   109 @param aRule recurrence rules 
       
   110 @param aStartTime The DTSTART of the parent component.
       
   111 @return True if finalized parsing successfully
       
   112 */
       
   113 TBool CAgnParseRRuleYearly::FinalizeParsingL( TCalRRule& aRule, const TCalTime& aStartTime )
       
   114     {
       
   115     TRACE_ENTRY_POINT;
       
   116     
       
   117     //Call the parent, to set some common values
       
   118     TBool finalized = CAgnParseRRule::FinalizeParsingL( aRule, aStartTime );
       
   119     
       
   120     // ByMonth is easy.
       
   121 	if ( !(iSetSegs & ESegFlagByMonth) )
       
   122 		{
       
   123 		// The specification requires certain fields to be taken from the DTSTART
       
   124 	    // if they have not already been set.
       
   125     	TDateTime startDate = aStartTime.TimeUtcL().DateTime();
       
   126 
       
   127 		RArray<TMonth> theMonths;
       
   128 		CleanupClosePushL(theMonths);
       
   129 		User::LeaveIfError(theMonths.Append(startDate.Month()));
       
   130 		aRule.SetByMonth(theMonths);
       
   131 		CleanupStack::PopAndDestroy(&theMonths);
       
   132 		}
       
   133 
       
   134     #if 0 
       
   135     //this will cause yearly repeat not to work    
       
   136     //further investigation needed 
       
   137     	else if ( !( iSetSegs & ESegFlagByDay ) )
       
   138     		{
       
   139     		/*
       
   140     		// We are in trouble here, because we are trying to work out a rule along the
       
   141     		// lines of "last saturday" from a date/time, which simply can't be done.
       
   142     		// This arrises because agenda doesn't support a yearly repeating rule with
       
   143     		// a numbered day of the month.
       
   144     		// We can't import this RRule, but we can continue with the rest of the entry.
       
   145     		*/
       
   146     		finalized = EFalse;
       
   147     		}
       
   148     #endif
       
   149 
       
   150     TRACE_EXIT_POINT;
       
   151     return finalized;
       
   152     }