javaextensions/pim/versit/inc.s60/cpimeventpropertyconverter.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Converts event properties PIM API <-> versit
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPIMEVENTPROPERTYCONVERTER_H
       
    20 #define CPIMEVENTPROPERTYCONVERTER_H
       
    21 
       
    22 // INTERANL INCLUDES
       
    23 #include "pimevent.h"
       
    24 #include "pimcommon.h"
       
    25 
       
    26 // EXTERNAL INCLUDES
       
    27 #include <e32base.h>
       
    28 
       
    29 // FORWARD DECLARATION
       
    30 class CParserProperty;
       
    31 class CPIMParserProperty;
       
    32 class CPIMItem;
       
    33 class CPIMEventItem;
       
    34 class CParserVCalEntity;
       
    35 class MPIMRepeatRuleData;
       
    36 class TVersitDateTime;
       
    37 class CVersitRecurrence;
       
    38 class CParserPropertyValue;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43  *  Converts Properties from versit objects to fields in PIM Event items.
       
    44  */
       
    45 NONSHARABLE_CLASS(CPIMEventPropertyConverter): public CBase
       
    46 {
       
    47 public: // Constructors and destructor
       
    48 
       
    49     /**
       
    50      * Two-phased constructor.
       
    51      */
       
    52     static CPIMEventPropertyConverter* NewL();
       
    53 
       
    54     /**
       
    55      * Destructor
       
    56      */
       
    57     virtual ~CPIMEventPropertyConverter();
       
    58 
       
    59 public: // New functions
       
    60 
       
    61     /**
       
    62      * Inserts a property from a vEvent to a PIM Event.
       
    63      * If the property is DALARM, the date is not stored in the item,
       
    64      * but in the aAlarm reference.
       
    65      *
       
    66      * @param aProperty property to insert
       
    67      * @param aItem item to insert into
       
    68      * @param aAlarm value of DALARM property is stored here
       
    69      */
       
    70     void ConvertPropertyL(const CParserProperty& aProperty,
       
    71                           CPIMEventItem& aItem,
       
    72                           TPIMDate& aAlarm);
       
    73 
       
    74     /**
       
    75      * Inserts a Field from a PIM Event Item to CParserVCalEntity.
       
    76      * The field is insterted as a property.
       
    77      *
       
    78      * @param aItem item to read the field from
       
    79      * @param aParser parser to insert the property to.
       
    80      * @param aField field to convert
       
    81      *
       
    82      */
       
    83     void ConvertEventFieldL(const CPIMItem& aItem,
       
    84                             CParserVCalEntity& aParser,
       
    85                             TPIMEventField aField);
       
    86 
       
    87     /**
       
    88      * Inserts a repeat rule to a parser.
       
    89      *
       
    90      * @param aRepeat Repeat rule to insert
       
    91      * @param aParser Parser to insert into
       
    92      */
       
    93     void ConvertRepeatRuleL(const MPIMRepeatRuleData* aRepeat,
       
    94                             CParserVCalEntity& aParser);
       
    95 
       
    96     /**
       
    97      * Adds a new property to the vCalendar parser
       
    98      * Note that property value and array of params are popped
       
    99      * from the cleanup stack inside this function
       
   100      *
       
   101      * @param aPropertyValue Property value for the vCalendar property
       
   102      *        This needs not to be pushed to the cleanup stack before
       
   103      *        this function call since it is done straight from the start
       
   104      *        of this function
       
   105      * @param aPropertyName Name of the property
       
   106      * @param aParser vCalendar parser into which the new property is pushed
       
   107      */
       
   108     void AddPropertyToParserL(
       
   109         CParserPropertyValue* aPropertyValue,
       
   110         const TDesC8& aPropertyName,
       
   111         CParserVCalEntity& aParser);
       
   112 
       
   113 private:
       
   114     /**
       
   115      * C++ default constructor.
       
   116      */
       
   117     CPIMEventPropertyConverter();
       
   118 
       
   119     /**
       
   120      * Converts a date property from a vEvent to a PIM Event Item.
       
   121      *
       
   122      * @param aProperty property to convert
       
   123      * @param aItem item to write the field to
       
   124      *
       
   125      */
       
   126     void ConvertDatePropertyL(const CPIMParserProperty& aProperty,
       
   127                               CPIMEventItem& aItem);
       
   128 
       
   129     /**
       
   130      * Converts an alarm property from a vEvent to a PIM Event Item.
       
   131      * The date is not stored in the item,
       
   132      * but in the aAlarm reference.
       
   133      *
       
   134      * @param aProperty property to convert
       
   135      * @param aAlarm the value is stored here
       
   136      *
       
   137      */
       
   138     void ConvertAlarmPropertyL(const CPIMParserProperty& aProperty,
       
   139                                TPIMDate& aAlarm);
       
   140 
       
   141     /**
       
   142      * Converts a string field from a vTodo to a PIM Event Item.
       
   143      *
       
   144      * @param aProperty property to convert
       
   145      * @param aItem item to write the field to
       
   146      *
       
   147      */
       
   148     void ConvertStringPropertyL(const CPIMParserProperty& aProperty,
       
   149                                 CPIMEventItem& aItem);
       
   150 
       
   151     /**
       
   152      * Convert RRULE property from a vCalendar to a PIM Event Item.
       
   153      * The repeat rule is stored in the repeat rule of the event item.
       
   154      * @param aProperty property to convert
       
   155      * @param aItem item to write the dates to
       
   156      */
       
   157     void ConvertRepeatRulePropertyL(const CPIMParserProperty& aProperty,
       
   158                                     CPIMEventItem& aItem);
       
   159 
       
   160     /**
       
   161      * Convert EXDATE property from a vCalendar to a PIM Event Item.
       
   162      * The exception dates are stored in the item as repeat rule
       
   163      * exception dates.
       
   164      * @param aProperty property to convert
       
   165      * @param aItem item to write the dates to
       
   166      *
       
   167      */
       
   168     void ConvertExDatePropertyL(const CPIMParserProperty& aProperty,
       
   169                                 CPIMEventItem& aItem);
       
   170 
       
   171     /**
       
   172      * Convert CLASS property from a vCalendar to a PIM Event Item.
       
   173      * (This is not done among other string/HBufC properties, because
       
   174      * the resulting data is not string, but int.)
       
   175      *
       
   176      * @param aProperty property to convert
       
   177      * @param aItem item to write the dates to
       
   178      */
       
   179     void ConvertClassPropertyL(const CPIMParserProperty& aProperty,
       
   180                                CPIMEventItem& aItem);
       
   181 
       
   182     /**
       
   183      * Inserts exception dates to a parser.
       
   184      *
       
   185      * @param aDates Exception dates to add
       
   186      * @param aParser Parser to insert into
       
   187      */
       
   188     void ConvertExceptionDatesL(const CArrayFix<TPIMDate>& aDates,
       
   189                                 CParserVCalEntity& aParser);
       
   190 
       
   191     /**
       
   192      * Converts a date field from a PIM Event Item to
       
   193      * a CParserVCalEntity.
       
   194      * The field is stored in the parser as a property.
       
   195      *
       
   196      * @param aItem item to read the field from
       
   197      * @param aParser parser to insert the property to.
       
   198      * @param aField field to convert
       
   199      * @param aIndex index to the field to convert
       
   200      *
       
   201      * @par Leaving:
       
   202      * This method leaves on an error with system wide error codes.
       
   203      */
       
   204     void ConvertDateFieldL(const CPIMItem& aItem,
       
   205                            CParserVCalEntity& aParser,
       
   206                            TPIMEventField aField,
       
   207                            TInt aIndex);
       
   208 
       
   209     /**
       
   210      * Converts an alarm field from a PIM Event Item to
       
   211      * a CParserVCalEntity.
       
   212      * The field is stored in the parser as a property.
       
   213      *
       
   214      * @param aItem item to read the field from
       
   215      * @param aParser parser to insert the property to.
       
   216      * @param aField field to convert
       
   217      * @param aIndex index to the field to convert
       
   218      *
       
   219      * @par Leaving:
       
   220      * This method leaves on an error with system wide error codes.
       
   221      */
       
   222     void ConvertAlarmFieldL(const CPIMItem& aItem,
       
   223                             CParserVCalEntity& aParser,
       
   224                             TPIMEventField aField,
       
   225                             TInt aIndex);
       
   226 
       
   227     /**
       
   228      * Converts a string field from a PIM Event Item to
       
   229      * a CParserVCalEntity.
       
   230      * The field is stored in the parser as a property.
       
   231      *
       
   232      * @param aItem item to read the field from
       
   233      * @param aParser parser to insert the property to.
       
   234      * @param aField field to convert
       
   235      * @param aIndex index to the field to convert
       
   236      *
       
   237      * @par Leaving:
       
   238      * This method leaves on an error with system wide error codes.
       
   239      */
       
   240     void ConvertStringFieldL(const CPIMItem& aItem,
       
   241                              CParserVCalEntity& aParser,
       
   242                              TPIMEventField aField,
       
   243                              TInt aIndex);
       
   244 
       
   245     /**
       
   246      * Coverts the Event.CLASS field from a PIM Event item to
       
   247      * a CParserVCalEntity.
       
   248      * The field is stored in the parser as a property.
       
   249      *
       
   250      * @param aItem item to read the field from
       
   251      * @param aParser parser to insert the property to.
       
   252      * @param aField field to convert
       
   253      * @param aIndex index to the field to convert
       
   254      *
       
   255      * @par Leaving:
       
   256      * This method leaves on an error with system wide error codes.
       
   257      */
       
   258     void ConvertClassFieldL(
       
   259         const CPIMItem& aItem,
       
   260         CParserVCalEntity& aParser,
       
   261         TPIMEventField aField,
       
   262         TInt aIndex);
       
   263 
       
   264     /**
       
   265      * Gets the fields from a repeat rule. The fields are stored in the
       
   266      * given pointers.
       
   267      *
       
   268      * @param aRepeat Fields are read from this repeat rule.
       
   269      * @param aInterval interval is stored here
       
   270      * @param aFrequency frequency is stored here
       
   271      * @param aVersitEndDate end date is stored here
       
   272      */
       
   273     void GetRepeatRuleFieldsL(const MPIMRepeatRuleData* aRepeat,
       
   274                               TInt* aInterval,
       
   275                               TInt* aFrequency,
       
   276                               TVersitDateTime** aVersitEndDate);
       
   277 
       
   278     /**
       
   279      * Creates a versit recurrence according to given parameters.
       
   280      * If aVersitEndDate is given, the created recurrence takes its
       
   281      * ownership.
       
   282      *
       
   283      * @param aFrequency frequency of the recurrence
       
   284      * @param aInterval interval of the recurrence
       
   285      * @param aVersitEndDate end date (may be NULL)
       
   286      *
       
   287      * @return Versit recurrence
       
   288      */
       
   289     CVersitRecurrence* CreateRecurrenceL(
       
   290         TInt aFrequency,
       
   291         TInt aInterval,
       
   292         TVersitDateTime* aVersitEndDate);
       
   293 
       
   294 };
       
   295 
       
   296 #endif // CPIMEVENTPROPERTYCONVERTER_H
       
   297 // End of file