javaextensions/pim/versit/inc.s60/cpimversit.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14: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 PIM Items to Versit objects and vice versa.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPIMVERSIT_H
       
    20 #define CPIMVERSIT_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <badesca.h> // CDesCArray
       
    25 #include <vutil.h> // Versit
       
    26 #include "pimcommon.h" // TPIMListType
       
    27 #include "functionserver.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CPIMManager;
       
    31 class CPIMContactValidator;
       
    32 class CPIMEventValidator;
       
    33 class CPIMToDoValidator;
       
    34 class CPIMCardConverter;
       
    35 class CPIMCalendarConverter;
       
    36 class CPIMItem;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  *  Converts PIM Items to Versit objects and vice versa.
       
    42  */
       
    43 NONSHARABLE_CLASS(CPIMVersit): public CBase
       
    44 {
       
    45 
       
    46 public: // Constructors and destructor
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      * @param aContactValidator Validator to validate created contacts
       
    51      * @param aEventValidator Validator to validate created events
       
    52      * @param aToDoValidator Validator to validate created todos
       
    53      */
       
    54 
       
    55     static CPIMVersit* NewL(CPIMManager* aManager);
       
    56 
       
    57     /**
       
    58      * Destructor.
       
    59      */
       
    60     virtual ~CPIMVersit();
       
    61 
       
    62 public: // new methods
       
    63 
       
    64     /**
       
    65      * Converts a PIM Item to a Versit object.
       
    66      *
       
    67      * @param aItem Item to convert
       
    68      * @return HBufC pointer representing the Versit object.
       
    69      *         The ownership of the object is transferred to the caller.
       
    70      * @par Leaving:
       
    71      * This method may leave on error
       
    72      */
       
    73     HBufC8* ItemToStringL(const CPIMItem& aItem,
       
    74                           Versit::TVersitCharSet aCharset);
       
    75 
       
    76     /**
       
    77      * Converts a Versit object to PIM Items.
       
    78      *
       
    79      * @param aString Versit object in a descriptor
       
    80      *                In case of a vCard, contains one vCard.
       
    81      *                In case of a vCalendar, may contain several
       
    82      *                vTodos or vEvents
       
    83      * @return Array containing the items
       
    84      *         The ownership of the object is transferred to the caller.
       
    85      * @par Leaving:
       
    86      * @li \c KErrNotSupported - \a aString is not a vCard or vCalendar
       
    87      * @li \c KErrCorrupt - \a aString is corrupted
       
    88      * @li \c KErrEof - vCalendar does not have terminating delimiter
       
    89      * @li \c KErrTooBig - vCard has a name or address array with too
       
    90      *                       many elements
       
    91      */
       
    92     RPointerArray<CPIMItem>*
       
    93     StringToItemL(const TDesC8& aString,
       
    94                   Versit::TVersitCharSet aCharset);
       
    95 
       
    96     /**
       
    97      * Returns an array of supported formats for a specific pim list type.
       
    98      *
       
    99      * @param aPimListType Type of list for which the formats are queried.
       
   100      *
       
   101      * @return Array of descriptors, each descriptor containing one format
       
   102      */
       
   103     const CDesCArray& SupportedSerialFormatsL
       
   104     (TPIMListType aPimListType) const;
       
   105 
       
   106 private:
       
   107 
       
   108     /**
       
   109      * C++ constructor.
       
   110      */
       
   111     CPIMVersit(CPIMManager* aManager);
       
   112 
       
   113     /**
       
   114      * By default Symbian 2nd phase constructor is private.
       
   115      */
       
   116     void ConstructL();
       
   117 
       
   118     /**
       
   119      * Converts a vCard to contacts.
       
   120      *
       
   121      * @param aString vCard
       
   122      * @param aItemArray contacts are stored here
       
   123      */
       
   124     void StringToContactL(const TDesC8& aString,
       
   125                           RPointerArray<CPIMItem>& aItemArray,
       
   126                           Versit::TVersitCharSet aCharset);
       
   127 
       
   128     /**
       
   129      * Combines 3 8-bit descriptors into one.
       
   130      *
       
   131      * @param aDesC1 First descriptor
       
   132      * @param aDesC2 Second descriptor
       
   133      * @param aDesC3 Third descriptor
       
   134      *
       
   135      * @return descriptors combined into one HBufC8
       
   136      */
       
   137     HBufC8* Combine3DesC8L(const TDesC8& aDesC1,
       
   138                            const TDesC8& aDesC2,
       
   139                            const TDesC8& aDesC3);
       
   140 
       
   141     /**
       
   142      * Combines 3 16-bit descriptors into one.
       
   143      * The returned value is pushed into the cleanup stack
       
   144      *
       
   145      * @param aDesC1 First descriptor
       
   146      * @param aDesC2 Second descriptor
       
   147      * @param aDesC3 Third descriptor
       
   148      *
       
   149      * @return descriptors combined into one HBufC, which is pushed into
       
   150      * cleanup stack.
       
   151      */
       
   152     HBufC* Combine3DesCLC(const TDesC& aDesC1,
       
   153                           const TDesC& aDesC2,
       
   154                           const TDesC& aDesC3);
       
   155 
       
   156 private: // Data
       
   157     // Converts Contact Item <-> vCard
       
   158     CPIMCardConverter* iCardConverter;
       
   159 
       
   160     // Converts PIM Item <--> vCalendar
       
   161     CPIMCalendarConverter* iCalendarConverter;
       
   162 
       
   163     // Validates contacts
       
   164     const CPIMContactValidator& iContactValidator;
       
   165 
       
   166     // Validates events
       
   167     const CPIMEventValidator& iEventValidator;
       
   168 
       
   169     // Validates ToDos
       
   170     const CPIMToDoValidator& iToDoValidator;
       
   171 
       
   172     // Supported vCard formats
       
   173     CDesC16ArrayFlat* iVCardFormats;
       
   174 
       
   175     // Supported vCalendar formats
       
   176     CDesC16ArrayFlat* iVCalendarFormats;
       
   177 
       
   178     java::util::FunctionServer* iFuncServer;
       
   179 
       
   180 };
       
   181 
       
   182 #endif // CPIMVERSIT_H
       
   183 // End of File