messagingapp/msgutils/unidatamodel/unimmsdataplugin/inc/UniObjectList.h
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 /*
       
     2 * Copyright (c) 2005 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: 
       
    15 *       CUniObjectList, List of attachments.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __UNIOBJECTLIST_H
       
    22 #define __UNIOBJECTLIST_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <f32file.h>
       
    28 #include <apmstd.h>
       
    29 
       
    30 #include <cmsvattachment.h>
       
    31 #include <UniObject.h>
       
    32 
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CUniDataUtils;
       
    40 class CMDXMLDocument;
       
    41 class CMDXMLNode;
       
    42 class CUniObjectList;
       
    43 
       
    44 // DATA TYPES
       
    45 
       
    46 // FUNCTION PROTOTYPES
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 * MUniObjectListObserver - Callback API for object list operations.
       
    52 *
       
    53 * @since 3.1
       
    54 */
       
    55 class MUniObjectListObserver
       
    56     {
       
    57     public:
       
    58 
       
    59         /**
       
    60         * Called when object is added to the list.
       
    61         *
       
    62         * @since 3.1
       
    63         * @param aList IN List where object is added.
       
    64         * @param aObject IN Added object.
       
    65         * @param aIndex IN Index number of added object.
       
    66         */
       
    67         virtual void ObjectAddedL( CUniObjectList* aList,
       
    68                                    CUniObject* aObject,
       
    69                                    TInt aIndex ) = 0;
       
    70 
       
    71         /**
       
    72         * Called when object is removed from the list.
       
    73         *
       
    74         * @since 3.1
       
    75         * @param aList IN List where object is added.
       
    76         * @param aObject IN Removed object.
       
    77         * @param aIndex IN Index number of removed object.
       
    78         */
       
    79         virtual void ObjectRemovedL( CUniObjectList* aList,
       
    80                                      CUniObject* aObject,
       
    81                                      TInt aIndex ) = 0;
       
    82     };
       
    83 
       
    84 /**
       
    85 * CUniObjectList - List of attachments.
       
    86 *
       
    87 * @lib UniDataModel.lib
       
    88 * @since 3.1
       
    89 */
       
    90 class CUniObjectList : public CBase,
       
    91                        public MUniObjectSaveObserver
       
    92     {
       
    93 
       
    94     public:  // New methods
       
    95 
       
    96         /**
       
    97         * Factory method that creates this object.
       
    98         *
       
    99         * @since    3.1
       
   100         * @param    aMtm    IN reference to client mtm
       
   101         * @param    aData   IN reference to MsgData object
       
   102         * @return   Pointer to instance
       
   103         */
       
   104         static CUniObjectList* NewL( CBaseMtm& aMtm, CUniDataUtils& aData );
       
   105 
       
   106         /**
       
   107         * Destructor
       
   108         *
       
   109         * @since    3.1
       
   110         */
       
   111         virtual ~CUniObjectList();
       
   112 
       
   113         /**
       
   114         * AddObjectL
       
   115         * Appends object to object array.
       
   116         *
       
   117         * @since    3.1
       
   118         * @param    aObject     IN object to be added
       
   119         */
       
   120         void AddObjectL( CUniObject* aObject );
       
   121 
       
   122         /**
       
   123         * SpaceNeededForSaveAll
       
   124         * Calculates disk space needed to save all objects
       
   125         * that are not yet saved into message store.
       
   126         *
       
   127         * @since    3.1
       
   128         * @return   Disk space needed in bytes
       
   129         */
       
   130         TInt SpaceNeededForSaveAll();
       
   131 
       
   132         /**
       
   133         * SaveAll
       
   134         * Calls SaveL for each object in the object array
       
   135         *
       
   136         * @since    3.1
       
   137         * @param    aObserver   IN operation observer
       
   138         * @param    aSaveType   IN save type
       
   139         */
       
   140         void SaveAll( MUniObjectSaveObserver& aObserver, CMsvAttachment::TMsvAttachmentType aSaveType );
       
   141 
       
   142         /**
       
   143         * RemoveAllObjectsL
       
   144         * Removes all objects from message store and object
       
   145         * array. Deletes all objects.
       
   146         *
       
   147         * @since    3.1
       
   148         */
       
   149         void RemoveAllObjectsL();
       
   150 
       
   151         /**
       
   152         * RemoveObjectL
       
   153         * Removes an object from object array and also from
       
   154         * message store if requested.
       
   155         * The caller must delete the object!!!
       
   156         *
       
   157         * @since    3.1
       
   158         * @param    aObject IN object to be removed
       
   159         * @param    aRemoveFromStore    IN if EFalse remove only from object array,
       
   160         *                               if ETrue remove also from message store
       
   161         */
       
   162         void RemoveObjectL( CUniObject* aObject, TBool aRemoveFromStore = ETrue );
       
   163 
       
   164         /**
       
   165         * GetByIndex
       
   166         * Get object by index
       
   167         *
       
   168         * @since    3.1
       
   169         * @param    aIndex  IN index
       
   170         * @return   Pointer to object
       
   171         */
       
   172         CUniObject* GetByIndex( TInt aIndex );
       
   173 
       
   174         /**
       
   175         * GetByAttachmentId
       
   176         * Get object by attachment id
       
   177         *
       
   178         * @since    3.1
       
   179         * @param    aAttachmentId   IN attachment id
       
   180         * @return   Pointer to object
       
   181         */
       
   182         CUniObject* GetByAttachmentId( TMsvAttachmentId aAttachmentId );
       
   183 
       
   184         /**
       
   185         * GetByNode
       
   186         * Get object by DOM node
       
   187         *
       
   188         * @since    3.1
       
   189         * @param    aNode   IN DOM node
       
   190         * @return   Pointer to object
       
   191         */
       
   192         CUniObject* GetByNodeL( CMDXMLNode* aNode );
       
   193 
       
   194         /**
       
   195         * GetByUrl
       
   196         * Get object by URL
       
   197         *
       
   198         * @since    3.1
       
   199         * @param    aUrl    IN URL
       
   200         * @return   Pointer to object
       
   201         */
       
   202         CUniObject* GetByUrlL( const TDesC& aUrl );
       
   203 
       
   204         /**
       
   205         * ObjectByteSize
       
   206         * Calculate size of all the objects in bytes
       
   207         *
       
   208         * @since    3.1
       
   209         * @return   Size in bytes
       
   210         */
       
   211         TInt ObjectByteSize() const;
       
   212 
       
   213         /**
       
   214         * EnsureAllObjectsHaveContentLocationL
       
   215         * Makes sure that all objects have ContentLocation
       
   216         * MIME header defined. All objects must have ContentLocation
       
   217         * when SMIL is composed.
       
   218         *
       
   219         * @since    3.1
       
   220         */
       
   221         void EnsureAllObjectsHaveContentLocationL();
       
   222 
       
   223         /**
       
   224         * SetListObserver
       
   225         * Sets observer to the list that changes to list are notified.
       
   226         *
       
   227         * @since    3.1
       
   228         * @param aObserver IN New object list observer. Setting observer
       
   229         *                     to NULL resets observer.
       
   230         */
       
   231         void SetListObserver( MUniObjectListObserver* aObserver );
       
   232 
       
   233         /**
       
   234         * Returns object based on unique handle.
       
   235         *
       
   236         * @param  aUniqueControlHandle Control handle that uniquely identified the control
       
   237         * @return Pointer to matched uniobject or NULL if not found.
       
   238         */
       
   239         CUniObject* GetObjectByUniqueHandle( TInt aUniqueControlHandle );
       
   240 
       
   241         /**
       
   242         * Count
       
   243         *
       
   244         * @since    3.1
       
   245         * @return   Number of objects
       
   246         */
       
   247         inline TInt Count() const;
       
   248 
       
   249     public:
       
   250 
       
   251         /**
       
   252         * From MUniObjectSaveObserver
       
   253         */
       
   254         void ObjectSaveReady( TInt aError );
       
   255 
       
   256     protected:
       
   257 
       
   258         /**
       
   259         * Constructor.
       
   260         *
       
   261         * @since    3.1
       
   262         * @param    aMtm    IN reference to client mtm
       
   263         * @param    aData   IN reference to MsgData object
       
   264         */
       
   265         CUniObjectList( CBaseMtm& aMtm, CUniDataUtils& aData );
       
   266 
       
   267         /**
       
   268         * 2nd phase constructor.
       
   269         *
       
   270         * @since    3.1
       
   271         */
       
   272         void ConstructL();
       
   273 
       
   274     protected: // data
       
   275 
       
   276         CArrayPtrFlat<CUniObject>* iObjectArray;
       
   277         CUniDataUtils& iData;
       
   278         CBaseMtm& iMtm;
       
   279 
       
   280         MUniObjectSaveObserver* iSaveObserver;
       
   281         CMsvAttachment::TMsvAttachmentType iSaveType;
       
   282         TInt iSaveCount;
       
   283 
       
   284         MUniObjectListObserver* iListObserver;
       
   285     };
       
   286 
       
   287 #include <UniObjectList.inl>
       
   288 
       
   289 #endif // __UNIOBJECTLIST_H