mobilemessaging/unieditor/utils/inc/UniSlideLoader.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005-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:   Unified Message Editor slide loader.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_UNISLIDELOADER_H
       
    21 #define C_UNISLIDELOADER_H
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <MsgMedia.hrh>
       
    27 #include <msgasynccontrolobserver.h>
       
    28 #include <ConeResLoader.h>
       
    29 
       
    30 #include <MsgEditorView.h>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // DATA TYPES
       
    37 
       
    38 enum TUniControlMode
       
    39     {
       
    40     EUniControlEditorMode = 0,
       
    41     EUniControlViewerMode
       
    42     };
       
    43 
       
    44 // FUNCTION PROTOTYPES
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 
       
    48 class CMsgBaseControl;
       
    49 //Hma class CMsgEditorView;
       
    50 class CUniObject;
       
    51 class CUniDataModel;
       
    52 class CMsgMediaControl;
       
    53 class MMsgAsyncControl;
       
    54 class CMsgXhtmlBodyControl;
       
    55 class MUniObjectObserver;
       
    56 
       
    57 // CLASS DECLARATION
       
    58 
       
    59 class MUniSlideLoaderObserver
       
    60     {
       
    61     public:
       
    62     
       
    63         /**
       
    64         * Called when slide loading has finished.
       
    65         *
       
    66         * @since S60 3.1
       
    67         *
       
    68         * @param aError KErrNone if no error happened,
       
    69         *               otherwise some systemwide error code.        
       
    70         */
       
    71         virtual void SlideLoadReady( TInt aError ) = 0;
       
    72     };
       
    73 
       
    74 
       
    75 // ==========================================================
       
    76 
       
    77 /**
       
    78 *  Unified Editor slide loader class declaration.
       
    79 *
       
    80 *  @lib UniUtils.lib
       
    81 *
       
    82 *  @since S60 3.2
       
    83 */
       
    84 NONSHARABLE_CLASS( CUniSlideLoader ): public CActive,
       
    85                                       public MMsgAsyncControlObserver
       
    86     {
       
    87     public:  // Constructor and destructor
       
    88 
       
    89         /**
       
    90         * Two-phased constructor.
       
    91         *
       
    92         * @since S60 3.2
       
    93         *
       
    94         * @param aControlObserver Observer for added control.
       
    95         * @param aModel Reference to UniDataModel
       
    96         * @param aView View to which controls are added.
       
    97         * @param aControlMode TUniControlMode enumeration
       
    98         *
       
    99         * @return new object
       
   100         */
       
   101         IMPORT_C static CUniSlideLoader* NewL(
       
   102             MMsgAsyncControlObserver& aControlObserver,
       
   103             CUniDataModel& aModel,
       
   104             CMsgEditorView& aView,
       
   105             TUniControlMode aControlMode );
       
   106 
       
   107         /**
       
   108         * Two-phased constructor.
       
   109         *
       
   110         * @since S60 5.0
       
   111         *
       
   112         * @param aUniObjectObserver Observer for CUniObjet events. When slide is loaded 
       
   113         * observer is added to CUniObject. When ResetViewL() is called, observer is removed 
       
   114         * from CUniObject. When control is reloaded, observer remains untouched. 
       
   115         * @param aControlObserver Observer for added control.
       
   116         * @param aModel Reference to UniDataModel
       
   117         * @param aView View to which controls are added.
       
   118         * @param aControlMode TUniControlMode enumeration
       
   119         *
       
   120         * @return new object
       
   121         */
       
   122         IMPORT_C static CUniSlideLoader* NewL(
       
   123             MUniObjectObserver*         aUniObjectObserver,
       
   124             MMsgAsyncControlObserver&   aControlObserver,
       
   125             CUniDataModel&              aModel,
       
   126             CMsgEditorView&             aView,
       
   127             TUniControlMode             aControlMode );
       
   128 
       
   129 
       
   130         /**
       
   131         * Destructor.
       
   132         *
       
   133         * @since S60 3.2
       
   134         */
       
   135         virtual ~CUniSlideLoader();
       
   136 
       
   137     public: 
       
   138 
       
   139         /**
       
   140         * Loads all the slide from given slide.
       
   141         *
       
   142         * @since S60 3.2
       
   143         *
       
   144         * @param aSlideObserver Slide loader observer.
       
   145         * @param aSlideNum Loaded slide number
       
   146         */
       
   147         IMPORT_C void LoadSlideL(
       
   148             MUniSlideLoaderObserver& aSlideObserver,
       
   149             TInt aSlideNum );
       
   150 
       
   151         /**
       
   152         * Loads given object.
       
   153         *
       
   154         * @since S60 3.2
       
   155         *
       
   156         * @param aSlideObserver Slide loader observer.
       
   157         * @param aObject Object to be loaded.
       
   158         */
       
   159         IMPORT_C void LoadObject(
       
   160             MUniSlideLoaderObserver& aSlideObserver,
       
   161             CUniObject* aObject );
       
   162             
       
   163         /**
       
   164         * Removes all the controls from the view.
       
   165         *
       
   166         * @since S60 3.2
       
   167         */
       
   168         IMPORT_C void ResetViewL();
       
   169 
       
   170         /**
       
   171         * Updates correct icon for media control.
       
   172         *
       
   173         * @since S60 3.2
       
   174         *
       
   175         * @param aMediaControl Control that icon is wanted to be updated.
       
   176         * @param aObject Object related to the control
       
   177         */
       
   178         IMPORT_C void UpdateControlIconL( CMsgMediaControl& aMediaControl, CUniObject* aObject );
       
   179 
       
   180         /**
       
   181         * Reloads one control without need to reload whole slide.
       
   182         *
       
   183         * @since S60 5.0
       
   184         *
       
   185         * @param aMediaControl Control which needs to be reloaded.
       
   186         * @param aObject Object related to the control
       
   187         */
       
   188         IMPORT_C void ReLoadControlL( CMsgMediaControl* aControl, CUniObject* aObject );
       
   189 
       
   190     public:
       
   191     
       
   192         /**
       
   193         * From CActive. See e32base.h
       
   194         *
       
   195         * @since S60 3.2
       
   196         *
       
   197         */
       
   198         void DoCancel();
       
   199 
       
   200         /**
       
   201         * From CActive. See e32base.h
       
   202         *
       
   203         * @since S60 3.2
       
   204         */
       
   205         void RunL();
       
   206     
       
   207         /**
       
   208         * From CActive. See e32base.h
       
   209         *
       
   210         * @since S60 3.2
       
   211         */
       
   212         TInt RunError( TInt aError );
       
   213 
       
   214         /**
       
   215         * From MMsgAsyncControlObserver. See MsgAsyncControlObserver.h
       
   216         *
       
   217         * @since S60 3.2
       
   218         */
       
   219         void MsgAsyncControlStateChanged( CMsgBaseControl& aControl,
       
   220                                           TMsgAsyncControlState aNewState,
       
   221                                           TMsgAsyncControlState aOldState );
       
   222         
       
   223         /**
       
   224         * From MMsgAsyncControlObserver. See MsgAsyncControlObserver.h
       
   225         *
       
   226         * @since S60 3.2       
       
   227         */
       
   228         void MsgAsyncControlResourceChanged( CMsgBaseControl& aControl, TInt aType );
       
   229                                                    
       
   230     private: // Constructors
       
   231 
       
   232         /**
       
   233         * Hidden C++ default constructor.
       
   234         */
       
   235         CUniSlideLoader();
       
   236         
       
   237         /**
       
   238         * C++ constructor
       
   239         */
       
   240         CUniSlideLoader(    MUniObjectObserver*         aUniObjectObserver,
       
   241                             MMsgAsyncControlObserver&   aControlObserver,
       
   242                             CUniDataModel&              aDataModel,
       
   243                             CMsgEditorView&             aView,                         
       
   244                             TUniControlMode             aControlMode );
       
   245 
       
   246         /**
       
   247         * Symbian constructor.
       
   248         */
       
   249         void ConstructL();
       
   250         
       
   251         /**
       
   252         * Completed current active scheduler loop.
       
   253         */
       
   254         void CompleteSelf();
       
   255         
       
   256         /**
       
   257         * Performs single load slide operation step.
       
   258         */
       
   259         void LoadSlideStepL();
       
   260 
       
   261         /**
       
   262         * Performs single load object operation step.
       
   263         */
       
   264         void LoadObjectStepL();
       
   265 
       
   266         /**
       
   267         * Loads object. Common function for all objects.
       
   268         */
       
   269         void LoadObjectL( CUniObject* aObject );
       
   270 
       
   271         /**
       
   272         * Loads text object.
       
   273         */
       
   274         void LoadTextL( CUniObject* aObject );
       
   275 
       
   276         /**
       
   277         * Loads image object.
       
   278         */
       
   279         void LoadImageL( CUniObject* aObject );
       
   280 
       
   281         /**
       
   282         * Loads audio object.
       
   283         */
       
   284         void LoadAudioL( CUniObject* aObject );
       
   285 
       
   286         /**
       
   287         * Loads video object.
       
   288         */
       
   289         void LoadVideoL( CUniObject* aObject );
       
   290         
       
   291         /**
       
   292         * Loads the svg
       
   293         */
       
   294         void LoadSvgL( CUniObject* aObject );
       
   295         
       
   296         /**
       
   297         * Loads content for media control.
       
   298         */
       
   299         TBool LoadControlL( MMsgAsyncControl& aMediaControl, CUniObject* aObject );
       
   300                 
       
   301         /**
       
   302         * Adds control to view.
       
   303         */
       
   304         void AddToViewL( CMsgBaseControl* aControl,
       
   305                          TInt aControlId,
       
   306                          TMsgMediaType aType,
       
   307                          CUniObject* aObject );
       
   308         
       
   309         /**
       
   310         * Determines if error code is DRM error code or not.
       
   311         */
       
   312         TBool IsDRMError( TInt aError ) const;
       
   313         
       
   314         /**
       
   315         * Determines whether UniObject DRM rights are valid.
       
   316         */
       
   317         TBool DrmRightsValid( CUniObject* aObject ) const;
       
   318         
       
   319         /**
       
   320         * Consumes DRM righs from the UniObject.
       
   321         */
       
   322         TBool ConsumeDrmRights( CUniObject* aObject ) const;
       
   323         
       
   324         /**
       
   325         * Sets correct layout for media icon for specified control.
       
   326         */
       
   327         void SetIconLayoutL( CMsgMediaControl& aMediaControl );
       
   328         
       
   329         /**
       
   330         * Performs media control resource change event handling
       
   331         */
       
   332         void DoMsgAsyncControlResourceChangedL( CMsgBaseControl& aControl, TInt aType );
       
   333         
       
   334         /**
       
   335         * Resolves base control type and returns correct type pointer.
       
   336         */
       
   337         void ResolveCorrectControlType( CMsgBaseControl& aControl,
       
   338                                         CMsgMediaControl*& aMediaControl,
       
   339                                         CMsgXhtmlBodyControl*& aXhtmlControl );
       
   340         
       
   341         /**
       
   342         * Implements part of reloading control code
       
   343         *
       
   344         * @since S60 5.0
       
   345         *
       
   346         * @param aMediaControl Control which needs to be reloaded.
       
   347         * @param aObject Object related to the control
       
   348         */
       
   349         TBool DoReLoadControlL( MMsgAsyncControl& aMediaControl, CUniObject* aObject );
       
   350 
       
   351         /**
       
   352         * Removes observers of the slide
       
   353         *
       
   354         * @since S60 5.0
       
   355         */
       
   356         void  RemoveObservers( );
       
   357         
       
   358         /**
       
   359         * Resolve CUniObject related to media control.
       
   360         *
       
   361         * @since S60 5.0
       
   362         * @param aControl control for which CUniObjects is needed
       
   363         * @return CUniObject related to the given control
       
   364         */
       
   365         CUniObject* ObjectByBaseControl( CMsgBaseControl* aControl );
       
   366 
       
   367     private: //Data
       
   368 
       
   369         enum TMmsLoadOperation
       
   370             {
       
   371             ELoadSlide,
       
   372             ELoadObject
       
   373             };
       
   374 
       
   375         MMsgAsyncControlObserver&   iControlObserver;
       
   376         CUniDataModel&              iDataModel;
       
   377         CMsgEditorView&             iView;
       
   378         TUniControlMode             iControlMode;
       
   379 
       
   380         MUniSlideLoaderObserver*    iSlideObserver;
       
   381 
       
   382         TInt                        iLoadedSlide;
       
   383         TInt                        iObjectNum;
       
   384         TMmsLoadOperation           iOperation;
       
   385         CUniObject*                 iLoadedObject;
       
   386         
       
   387         TInt                        iError;
       
   388         
       
   389         RConeResourceLoader         iResourceLoader;
       
   390 
       
   391         MUniObjectObserver*         iUniObjectObserver;
       
   392     };
       
   393 
       
   394 #endif // C_UNISLIDELOADER_H