javacommons/fileutils/src.s60/filedrmcontenthandler.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:  Handler for DRM File IO Operations
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FILEDRMCONTENTHANDLER_H
       
    20 #define FILEDRMCONTENTHANDLER_H
       
    21 
       
    22 #include <caf/caf.h>
       
    23 #include <caf/content.h>
       
    24 #include <caf/data.h>
       
    25 #include <caf/rightsmanager.h>
       
    26 
       
    27 #include "nativefileiohandler.h"
       
    28 
       
    29 namespace java
       
    30 {
       
    31 namespace util
       
    32 {
       
    33 class FunctionServer;
       
    34 }
       
    35 
       
    36 namespace fileutils
       
    37 {
       
    38 
       
    39 OS_NONSHARABLE_CLASS(FileDRMContentHandler): public NativeFileIOHandler
       
    40 {
       
    41 public:
       
    42     /**
       
    43      * Checks to see if the specified file is DRM protected or not.
       
    44      */
       
    45     static TBool isDRMProtectedFile(const TDesC& aFullName);
       
    46 
       
    47     /**
       
    48      * Maps Java side intent to native intent type
       
    49      */
       
    50     static ContentAccess::TIntent mapIntentToCAF(TInt aIntent);
       
    51 
       
    52     /**
       
    53      * Sets the DRM arguments.
       
    54      */
       
    55     void setDrmArguments(TInt aIntent, TBool aExecuteIntent);
       
    56 
       
    57     FileDRMContentHandler(const std::wstring aName);
       
    58 
       
    59     virtual ~FileDRMContentHandler();
       
    60 
       
    61     // Methods fron NativeFileIOHandler
       
    62 
       
    63     /**
       
    64      * Reads data from the file into aBuffer upto aLength bytes.
       
    65      * Returns the amount of data read.
       
    66      * In case of errors, exception is thrown with errno value.
       
    67      */
       
    68     virtual int readBytes(char* aBuffer, int aLength);
       
    69 
       
    70     /**
       
    71      * Writes data from aBuffer into the file upto aLength bytes.
       
    72      * Returns the amount of data written.
       
    73      * In case of errors, exception is thrown with errno value.
       
    74      */
       
    75     virtual int writeBytes(char* aBuffer, int aLength);
       
    76 
       
    77     /**
       
    78      * Stops read operation. In case the file is opened in read-write mode and
       
    79      * if the write operations are in progress, the file is kept open to allow
       
    80      * for write operations. Else the file is closed.
       
    81      */
       
    82     virtual void stopReading();
       
    83 
       
    84     /**
       
    85      * Stops write operation. In case the file is opened in read-write mode and
       
    86      * if the read operations are in progress, the file is kept open to allow
       
    87      * for read operations. Else the file is closed.
       
    88      */
       
    89     virtual void stopWriting();
       
    90 
       
    91     /**
       
    92      * Opens the file specified during the construction of the object for read
       
    93      * operations.
       
    94      */
       
    95     virtual void openForReading();
       
    96 
       
    97     /**
       
    98      * Opens the file specified during the construction of the object for write
       
    99      * operations.
       
   100      */
       
   101     virtual void openForWriting(const long aOffset);
       
   102 
       
   103     /**
       
   104      * Skips aOffset number of bytes.
       
   105      * Positive value of aOffset moves the position forward and negatve backwards.
       
   106      * Return value is the actual value that can be skipped.
       
   107      */
       
   108     virtual long skip(const long aOffset);
       
   109 
       
   110     /**
       
   111      * Closes the file descriptors but will not delete all data.
       
   112      * On next call to read or write, we continue from previous offset.
       
   113      */
       
   114     virtual void closeFileToReopen();
       
   115 
       
   116     /**
       
   117      * Returns the amount of data available in the file from current read offset.
       
   118      */
       
   119     virtual long available();
       
   120 
       
   121     /**
       
   122      * Skips aOffset number of bytes.
       
   123      * Positive value of aOffset moves the position forward and negatve backwards.
       
   124      * To be called in Function Server context.
       
   125      * Return value is the actual value that can be skipped.
       
   126      */
       
   127     long skipFs(const long aOffset);
       
   128 
       
   129     /**
       
   130      * Reads data from the file into aBuffer upto aLength bytes.
       
   131      * Returns the amount of data read.
       
   132      * To be called in FunctionServer Context.
       
   133      * In case of errors, exception is thrown with errno value.
       
   134      */
       
   135     int readBytesFs(char* aBuffer, int aLength);
       
   136 
       
   137 private:
       
   138     virtual void handleReopenCase();
       
   139 
       
   140     void initializeAndOpenL();
       
   141 
       
   142     void clearContent();
       
   143 private:
       
   144     ContentAccess::CContent *mContent;
       
   145     ContentAccess::CData *mData;
       
   146     ContentAccess::TIntent mDrmIntent;
       
   147 
       
   148     java::util::FunctionServer* mFunctionServer;
       
   149     TInt mReadPosition;
       
   150     TBool mExecuteIntent;
       
   151 };
       
   152 
       
   153 }
       
   154 }
       
   155 
       
   156 #endif // FILEDRMCONTENTHANDLER_H