omadrm/drmplugins/drmrohandler/inc/CRoHandler.h
changeset 0 95b198f216e5
child 32 457cd4423b8c
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2004-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:  ECOM plugin for receiving OMA Rights Objects
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CROHANDLER_H
       
    20 #define CROHANDLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <mtclreg.h>                // for CClientMtmRegistry
       
    24 #include "RoapEngBase.h"
       
    25 #include "wbxmlroaptriggerparser.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TUid KUidMsgTypeRO = {0x101F6DC2};
       
    29 const TInt KWait = 5*60*1000000;  // Timeout value to be used for waiting in "disk full" situation
       
    30 
       
    31 enum TMessageType
       
    32     {
       
    33     EOma1Ro,
       
    34     EOma2RoapPdu,
       
    35     EOma2RoapTrigger,
       
    36     EOma2RoapTriggerRoAcquisition,
       
    37     EOma2RoapTriggerMetering
       
    38     };
       
    39 
       
    40 // MACROS
       
    41 
       
    42 // DATA TYPES
       
    43 
       
    44 // FUNCTION PROTOTYPES
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 
       
    48 class CDRMMessageParser;
       
    49 
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 // DESCRIPTION
       
    54 //  ECOM listener plugin for DRM server.
       
    55 //  Plugin is instantiated by the wap listener in the system watcher.
       
    56 //  It delivers rights object to DRM server.
       
    57 
       
    58 class CRoHandler
       
    59         : public CPushHandlerBase , public MMsvSessionObserver
       
    60     {
       
    61     public:  // Constructors and destructor
       
    62 
       
    63         /**
       
    64         * Destructor
       
    65         */
       
    66         ~CRoHandler();
       
    67 
       
    68         /**
       
    69         * Default 1st phase factory method.
       
    70         * returns created instance of the CRoHandler class
       
    71         */
       
    72         static CRoHandler* NewL();
       
    73 
       
    74         /**
       
    75         * Method for handling a received message asynchronously.
       
    76         * param aPushMsg object representing the received push message
       
    77         * param aStatus Status of the asynchronous call
       
    78         */
       
    79         void HandleMessageL( CPushMessage* aPushMsg, TRequestStatus& aStatus );
       
    80 
       
    81         /**
       
    82         * Method for handling a received message synchronously.
       
    83         * param aPushMsg object representing the received push message
       
    84         */
       
    85         void HandleMessageL( CPushMessage* aPushMsg );
       
    86 
       
    87         /**
       
    88         * Cancels the requested asynchronous message handling.
       
    89         */
       
    90         void CancelHandleMessage();
       
    91 
       
    92     protected:  // Functions from base classes
       
    93 
       
    94         /**
       
    95         * Performs operations needed for cancelling the message handling.
       
    96         * Called by the Active Scheduler after user calling Cancel().
       
    97         */
       
    98         void DoCancel();
       
    99 
       
   100         /**
       
   101         * Performs the actual tasks related to message handling.
       
   102         * Called by the Active Scheduler.
       
   103         */
       
   104         void RunL();
       
   105 
       
   106         /**
       
   107         * Performs error handling tasks in case RunL() left.
       
   108         * Called by the Active Scheduler.
       
   109         * Currently does nothing.
       
   110         * param aError specifies the error code related to RunL()'s leave.
       
   111         * return error value after error handling.
       
   112         */
       
   113         TInt RunError( TInt aError );
       
   114 
       
   115     private:    // New functions
       
   116 
       
   117         /**
       
   118         * Default constructor.
       
   119         */
       
   120         CRoHandler();
       
   121 
       
   122         /**
       
   123         * 2nd phase constructor.
       
   124         */
       
   125         void ConstructL();
       
   126 
       
   127         /**
       
   128         * Performs basic sanity checks for the received message.
       
   129         * Only the body is checked since header is not of interest to us.
       
   130         * @return standard error code
       
   131         */
       
   132         TInt PerformChecks();
       
   133 
       
   134         TMessageType CheckMessageTypeL();
       
   135 
       
   136         void HandleRightsMessageL();
       
   137 
       
   138         void HandleRoapPduL();
       
   139 
       
   140         void HandleRoapTriggerL();
       
   141 
       
   142         void HandleMeteringTriggerSilentlyL();
       
   143 
       
   144 
       
   145         /**
       
   146         * Creates new empty message.
       
   147         */
       
   148         TMsvId CreateNewMessageL();
       
   149 
       
   150         /**
       
   151         * Set message entry.
       
   152         */
       
   153         void SetEntryL( TMsvId aEntryId );
       
   154 
       
   155         /**
       
   156         * Moves message entry.
       
   157         */
       
   158         TMsvId MoveMessageEntryL( TMsvId aTarget );
       
   159 
       
   160         /**
       
   161         * Adds content to the message.
       
   162         */
       
   163         void AddRoContentL( TDesC& aMessageContent );
       
   164 
       
   165     private:    // Functions from base classes
       
   166 
       
   167         /**
       
   168         * Reserved for future expansion.
       
   169         */
       
   170         void CPushHandlerBase_Reserved1();
       
   171 
       
   172         /**
       
   173         * Reserved for future expansion.
       
   174         */
       
   175         void CPushHandlerBase_Reserved2();
       
   176 
       
   177         HBufC* ConvertDetailsL( const TDesC8& aFrom );
       
   178 
       
   179         HBufC* GetDetailLC();
       
   180 
       
   181         HBufC* GetDescriptionLC();
       
   182 
       
   183         void ReadFromResourceLC(
       
   184             const TDesC& aFile ,
       
   185             const TInt& aIndex ,
       
   186             HBufC*& aBuf );
       
   187 
       
   188         HBufC* ConvertUriToDisplayFormL( const TDesC& aUri );
       
   189 
       
   190         /**
       
   191          * Do a synchronous ROAP request.
       
   192          *
       
   193          * @since S60 3.1
       
   194          * @param aTrigger ROAP Trigger
       
   195          * @return ETrue if the ROAP could be started silently, EFalse otherwise (e.g. when
       
   196          *         no RI context exists)
       
   197          */
       
   198         TBool DoRoapL( const TDesC8& aTrigger );
       
   199 
       
   200     private: // from MMsvSessionObserver
       
   201 
       
   202         /**
       
   203         * Handles session events.
       
   204         */
       
   205         void HandleSessionEventL( TMsvSessionEvent aEvent,
       
   206                                   TAny* aArg1, TAny* aArg2,
       
   207                                   TAny* aArg3 );
       
   208 
       
   209         enum TState
       
   210             {
       
   211             ERunning,
       
   212             EFileSystemWait
       
   213             };
       
   214 
       
   215         // internal state
       
   216         TState iState;
       
   217         // message type
       
   218         TMessageType iMsgType;
       
   219         // flag to handle message one time.
       
   220         TBool iFirstTime;
       
   221         // uid of the ro handler
       
   222         enum { RoHandlerUid = 0x101F7B92 };
       
   223         // Pushed message
       
   224         CPushMessage* iPushMsg;
       
   225         // The body of the pushed message as HBufC8 descriptor
       
   226         // api to store the OMA 1 RO
       
   227         CDRMMessageParser* iMessageParser;
       
   228         // pointer to message body
       
   229         TPtrC8 iMessageBodyPtr;
       
   230         CMsvSession* iSession;          // Client session on the message server
       
   231         CBaseMtm* iMtm;                 // Message Type Module (sms)
       
   232         CClientMtmRegistry* iMtmReg;    // Mtm client registry for creating new mtms
       
   233         TMsvId iMsvId;                  // message server entry id
       
   234         RFs iFs;
       
   235         Roap::CRoapEngBase* iRoapHandler;
       
   236 
       
   237         TBool iMeteringSupported;       // state variable showing whether
       
   238                                         // metering is supported or not
       
   239                                         // initialised at instantiation
       
   240         DRM::CWbxmlRoapTriggerParser* iWbxmlTriggerParser;
       
   241         HBufC8* iParsedXmlTrigger;
       
   242         TBool iPutRightsToInbox;         // whether received RO is put into Inbox as an
       
   243                                         // entry or not. Initialized at instantiation.
       
   244                                         
       
   245     };
       
   246 
       
   247 #endif CROHANDLER_H
       
   248 
       
   249 // End of File