inc/wmdrmfileserverclient.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 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:  Client definitions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __WMDRMFILESERVERCLIENT_H
       
    20 #define __WMDRMFILESERVERCLIENT_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 // Name of the WMDRM file server executable
       
    25 _LIT( KWmDrmFileServerName, "!wmdrmfileserver.exe" );
       
    26 
       
    27 // Name of the WMDRM file server process
       
    28 _LIT( KWmDrmFileServerImg, "wmdrmfileserver" );
       
    29 
       
    30 // Location of the WMDRM file server root folder
       
    31 _LIT( KStoreRoot, "%c:\\sys\\private\\2000B180" );
       
    32 
       
    33 /* Interface to the WMDRM file server, which manages files in protected location.
       
    34  * Clients need DRM capability to access all functions.
       
    35  */
       
    36 
       
    37 class RWmDrmFileServerClient: public RSessionBase
       
    38 	{
       
    39 public:
       
    40 
       
    41     /* Connect to the server.
       
    42      *
       
    43      * @capability DRM
       
    44      * @return KErrNone if successful
       
    45      */
       
    46 	IMPORT_C TInt Connect();
       
    47     
       
    48 
       
    49     /* Open the given file under the file server root.
       
    50      *
       
    51      * @capability DRM
       
    52      * @param aFilename File to open
       
    53      * @return  KErrNone if successful, KErrNotFound if the file does not exist,
       
    54      *          KErrArgument if the file name is not valid
       
    55      */
       
    56     IMPORT_C TInt Open( const TDesC& aFilename );
       
    57     
       
    58 
       
    59     /* Closes an open file.
       
    60      */
       
    61     IMPORT_C void CloseFile();
       
    62 
       
    63 
       
    64     /* Creates a file under the file server root and opens it.
       
    65      *
       
    66      * @capability DRM
       
    67      * @param aFilename File to create
       
    68      * @return KErrNone if successful, KErrArgument if the file name is not valid,
       
    69      *         KErrDiskFull if system drive doesn't have enough free space
       
    70      */
       
    71     IMPORT_C TInt Create( const TDesC& aFilename );
       
    72 
       
    73 
       
    74     /* Read the whole content of the file into a buffer
       
    75      *
       
    76      * @capability DRM
       
    77      * @param aBuffer   Buffer for file content
       
    78      * @return  KErrNone if successful, KErrNotReady if the file is not open,
       
    79      *          KErrBadDescriptor if not enough space is available in the buffer.
       
    80      */
       
    81     IMPORT_C TInt Read( TDes8& aBuffer );
       
    82 
       
    83     /* Replaces the file content with a buffer, truncating the file if needed.
       
    84      *
       
    85      * @capability DRM
       
    86      * @param aBuffer   New file content
       
    87      * @return  KErrNone if successful, KErrNotReady if the file is not open,
       
    88      *          KErrDiskFull if system drive doesn't have enough free space
       
    89      */
       
    90     IMPORT_C TInt Write( const TDesC8& aBuffer );
       
    91 
       
    92     /* Returns the size of the currently open file
       
    93      *
       
    94      * @capability DRM
       
    95      * @param aSize Output parameter for the size
       
    96      * @return KErrNone if successful, KErrNotReady if the file is not open
       
    97      */
       
    98     IMPORT_C TInt Size( TInt& aSize );
       
    99 
       
   100     /* Deletes a given file under the store root.
       
   101      *
       
   102      * @capability DRM
       
   103      * @param aFilename File to delete
       
   104      * @return  KErrNone if successful, KErrArgument if the file name is not valid
       
   105      */
       
   106     IMPORT_C TInt Delete( const TDesC& aFilename );
       
   107 
       
   108     /* Checks whether a file is currently opened for this session.
       
   109      *
       
   110      * @capability DRM
       
   111      * @return  ETrue if a file is open, EFalse otherwise
       
   112      */
       
   113     IMPORT_C TBool IsOpen();
       
   114 
       
   115 
       
   116     /* Creates a complete path under the file server root, including all path
       
   117      * components.
       
   118      *
       
   119      * @capability DRM
       
   120      * @param aPath             Path to create
       
   121      * @param aCreateIfMissing  Flag indicating whether the path should be created if
       
   122      *                          it doesn't exist
       
   123      * @return KErrNone if successful, KErrArgument if the file name is not valid
       
   124      *         KErrDiskFull if system drive doesn't have enough free space
       
   125      */
       
   126     IMPORT_C TInt MkDirAll( const TDesC& aPath, TBool aCreateIfMissing = ETrue );
       
   127 
       
   128     /* Remove a complete path including all contents.
       
   129      *
       
   130      * @capability DRM
       
   131      * @param aPath Path to remove
       
   132      * @return KErrNone if successful, KErrArgument if the file name is not valid
       
   133      */
       
   134     IMPORT_C TInt RmDirAll( const TDesC& aPath );
       
   135 
       
   136     /* Remove the last directory in a path, if the last directory is empty.
       
   137      *
       
   138      * @capability DRM
       
   139      * @param aPath 
       
   140      * @return KErrNone if successful, KErrArgument if the file name is not valid
       
   141      */
       
   142     IMPORT_C TInt RmDir( const TDesC& aPath );
       
   143     
       
   144     
       
   145     /* Updates the secure time, only callable by DRM Rights Server
       
   146      *
       
   147      * @capability DRM
       
   148      * @return  KErrNone if the operation succeeds
       
   149      *          Symbian OS error code if an error occurs
       
   150      */    
       
   151     IMPORT_C TInt UpdateSecureTime( TTime& aHomeTime, TTime& aUTCTime );
       
   152     
       
   153     /* Delete all the rights
       
   154      *
       
   155      * @capability DRM
       
   156      * @return  KErrNone if successful
       
   157      */
       
   158     IMPORT_C TInt DeleteRights();
       
   159     
       
   160 	};
       
   161 
       
   162 #endif