omadrm/drmplugins/drmromtm/ui/src/drmmsgwatcherobserver.cpp
branchRCL_3
changeset 24 99ea7534c5ab
equal deleted inserted replaced
22:ad2863178d17 24:99ea7534c5ab
       
     1 /*
       
     2 * Copyright (c) 2010 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 *     Msv operation for drm viewing
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "drmmsgwatcherobserver.h"
       
    22 
       
    23 
       
    24 // CONSTANTS
       
    25 const TInt KiProgressBufferSize = 1;
       
    26 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // CDrmMsgWatcherObserver::NewL
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 CDrmMsgWatcherObserver* CDrmMsgWatcherObserver::NewL( 
       
    35 	CMsvSession& aMsvSession,
       
    36     TInt aPriority,
       
    37     TRequestStatus& aObserverRequestStatus,
       
    38     TUid aMtm,
       
    39     CAiwGenericParamList* aParamList)
       
    40 	{
       
    41 	CDrmMsgWatcherObserver* self = 
       
    42 		new(ELeave) CDrmMsgWatcherObserver( 
       
    43 			aMsvSession,
       
    44 			aPriority,
       
    45 			aObserverRequestStatus,
       
    46 			aMtm);
       
    47 	CleanupStack::PushL(self);
       
    48     self->ConstructL( aParamList );
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CDrmMsgWatcherObserver::NewL
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CDrmMsgWatcherObserver* CDrmMsgWatcherObserver::NewL( 
       
    58 	CMsvSession& aMsvSession,
       
    59     TInt aPriority,
       
    60     TRequestStatus& aObserverRequestStatus,
       
    61     TUid aMtm,
       
    62     const TDesC& aFileName,
       
    63     TDataType& aDataType )
       
    64 	{
       
    65 	CDrmMsgWatcherObserver* self = 
       
    66 		new(ELeave) CDrmMsgWatcherObserver( 
       
    67 			aMsvSession,
       
    68 			aPriority,
       
    69 			aObserverRequestStatus,
       
    70 			aMtm);
       
    71 	CleanupStack::PushL(self);
       
    72     self->ConstructL( aFileName, aDataType );
       
    73 	CleanupStack::Pop(self);
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CDrmMsgWatcherObserver::ConstructL
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 void CDrmMsgWatcherObserver::ConstructL( CAiwGenericParamList* aParamList )
       
    83     {
       
    84     const TUid KUidDRMUI = { 0x101f85c7 };        
       
    85     iService = CAknLaunchAppService::NewL( KUidDRMUI, this, aParamList );        
       
    86     iObserverRequestStatus = KRequestPending;
       
    87     Start();
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CDrmMsgWatcherObserver::ConstructL
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 void CDrmMsgWatcherObserver::ConstructL( const TDesC& aFileName, TDataType& aDataType )
       
    95     {
       
    96     iDocHandler = CDocumentHandler::NewL();
       
    97 
       
    98     iDocHandler->SetExitObserver(this);
       
    99 
       
   100     iDocHandler->OpenFileEmbeddedL(aFileName, aDataType);
       
   101      
       
   102     iObserverRequestStatus = KRequestPending;
       
   103     Start();
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CDrmMsgWatcherObserver::CDrmMsgWatcherObserver
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 CDrmMsgWatcherObserver::CDrmMsgWatcherObserver
       
   111 	(
       
   112     CMsvSession& aMsvSession, 
       
   113     TInt aPriority, 
       
   114     TRequestStatus& aObserverRequestStatus, 
       
   115     TUid aMtm
       
   116     )
       
   117     :   
       
   118     CMsvOperation(
       
   119     aMsvSession, 
       
   120     aPriority, 
       
   121     aObserverRequestStatus )
       
   122     {
       
   123     iMtm = aMtm;        
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CDrmMsgWatcherObserver::~CDrmMsgWatcherObserver
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 CDrmMsgWatcherObserver::~CDrmMsgWatcherObserver()
       
   131     {
       
   132     Cancel();
       
   133     if( iService )
       
   134         {
       
   135         delete iService;
       
   136         iService = NULL;
       
   137         } 
       
   138     if( iDocHandler )
       
   139         {
       
   140         delete iDocHandler;
       
   141         iDocHandler = NULL;
       
   142         }         
       
   143     delete iProgress;    
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CDrmMsgWatcherObserver::DoCancel
       
   148 // From CActive
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CDrmMsgWatcherObserver::DoCancel()
       
   152     {
       
   153     if ( iStatus == KRequestPending )
       
   154         {
       
   155         TRequestStatus* pstat = &iStatus;
       
   156         User::RequestComplete( pstat, KErrCancel );
       
   157         }
       
   158     CompleteObserver( KErrCancel );
       
   159     }
       
   160 
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CMsgEditorServerWatchingOperation::ProgressL
       
   164 // From CMsvOperation
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 const TDesC8& CDrmMsgWatcherObserver::ProgressL()
       
   168     {
       
   169     if ( !iProgress )
       
   170         {
       
   171         iProgress = HBufC8::NewL( KiProgressBufferSize );
       
   172         }
       
   173     return *iProgress;
       
   174     }
       
   175 
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CMsgEditorServerWatchingOperation::FinalProgress
       
   179 // From CMsvOperation
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 const TDesC8& CDrmMsgWatcherObserver::FinalProgress()
       
   183     {
       
   184     return *iProgress;
       
   185     }
       
   186 
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CDrmMsgWatcherObserver::RunL
       
   190 // From CActive
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 void CDrmMsgWatcherObserver::RunL()
       
   194     {
       
   195     CompleteObserver( iStatus.Int( ) );
       
   196     }
       
   197 
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CDrmMsgWatcherObserver::Start
       
   201 //
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CDrmMsgWatcherObserver::Start()
       
   205     {
       
   206     CActiveScheduler::Add( this );
       
   207     iStatus = KRequestPending;
       
   208     SetActive();
       
   209     }
       
   210 
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CDrmMsgWatcherObserver::CompleteObserver
       
   214 // Completes observer with the completion code
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CDrmMsgWatcherObserver::CompleteObserver( TInt aCode )
       
   218     {
       
   219     TRequestStatus* status = &iObserverRequestStatus;
       
   220     
       
   221     if( ( *status ) == KRequestPending )
       
   222         {
       
   223         User::RequestComplete( status, aCode );
       
   224         }
       
   225     }
       
   226 
       
   227 
       
   228 
       
   229 // ---------------------------------------------------------
       
   230 // CDrmMsgWatcherObserver::HandleServerAppExit
       
   231 // ---------------------------------------------------------
       
   232 //
       
   233 void CDrmMsgWatcherObserver::HandleServerAppExit( TInt aReason )
       
   234 	{
       
   235     TInt exitMode = aReason;
       
   236     if ( iStatus == KRequestPending )
       
   237     	{
       
   238     	TRequestStatus* pstat = &iStatus;
       
   239     	User::RequestComplete( pstat, exitMode );
       
   240     	}
       
   241 	MAknServerAppExitObserver::HandleServerAppExit( aReason );	
       
   242 	}
       
   243 
       
   244 // End of file