inc/wmdrmclient.h
changeset 0 95b198f216e5
child 47 5ed7931150e9
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Client definitions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __WMDRMCLIENT_H
       
    20 #define __WMDRMCLIENT_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 // Name of the WMDRM server executable
       
    26 _LIT(KWmDrmServerName,"!wmdrmserver.exe");
       
    27 
       
    28 // Name of the WMDRM server
       
    29 _LIT(KWmDrmServerImg,"wmdrmserver");
       
    30 
       
    31 const TInt KWmDrmIdSize = 16;
       
    32 const TInt KMaxWmDrmNamespaceNameSize = 64;
       
    33 const TInt KMaxWmDrmStoreNameSize = 64;
       
    34 
       
    35 enum TWmDrmStoreState
       
    36 	{
       
    37     EStoreSpaceOK,
       
    38     EStoreSpaceLow,
       
    39     EStoreSpaceFull
       
    40     };
       
    41 
       
    42 /**
       
    43 * wmdrmclient.dll
       
    44 *
       
    45 * All methods may not be supported and will always
       
    46 * return KErrNotSupported
       
    47 */
       
    48 class RWmDrmClient: public RSessionBase
       
    49 	{
       
    50 public:
       
    51     /**
       
    52     * Connect()
       
    53     * Connect to the server
       
    54     *
       
    55     * @return KErrNone if successful    
       
    56     *         Otherwise Symbian OS error codes
       
    57     */
       
    58 	IMPORT_C TInt Connect();
       
    59 
       
    60     /**
       
    61     * InitStore
       
    62     * Initialize a hds store
       
    63     *
       
    64     * @param aStoreName         Name of the store
       
    65     * @param aCreateIfMissing   Boolean value to create 
       
    66     *                           if the store is missing
       
    67     * @return KErrNone if successful
       
    68     *         Otherwise Symbian OS error code
       
    69     */
       
    70     
       
    71     IMPORT_C TInt InitStore(
       
    72         const TDesC8& aStoreName,
       
    73         TBool aCreateIfMissing );
       
    74 
       
    75     /**
       
    76     * RemoveStore
       
    77     * Removes the store
       
    78     *
       
    79     * @param aStoreName         Name of the store
       
    80     * @return KErrNone if successful
       
    81     *         Otherwise Symbian OS error code
       
    82     */
       
    83             
       
    84     IMPORT_C TInt RemoveStore(
       
    85         const TDesC8& aStoreName );
       
    86 
       
    87     /**
       
    88     * InitNamespace
       
    89     * Initializes a namespace
       
    90     *
       
    91     * @param aStoreName         Name of the store
       
    92     * @param aNamespace         Name of the namespace
       
    93     * @param aCreateIfMissing   Boolean value to create 
       
    94     *                           if the namespace is missing
       
    95     * @return KErrNone if successful
       
    96     *         Otherwise Symbian OS error code
       
    97     */
       
    98     
       
    99     IMPORT_C TInt InitNamespace(
       
   100         const TDesC8& aStoreName,
       
   101         const TDesC8& aNamespace,
       
   102         TBool aCreateIfMissing );
       
   103  
       
   104      /**
       
   105     * RemoveNamespace
       
   106     * Removes a namespace
       
   107     *
       
   108     * @param aStoreName         Name of the store
       
   109     * @param aNamespace         Name of the namespace
       
   110     * @return KErrNone if successful
       
   111     *         Otherwise Symbian OS error code
       
   112     */
       
   113        
       
   114     IMPORT_C TInt RemoveNamespace(
       
   115         const TDesC8& aStoreName,
       
   116         const TDesC8& aNamespace );
       
   117 
       
   118     /**
       
   119     * SlotOpen
       
   120     * Open a slot from the namespace
       
   121     *
       
   122     * @param aStoreName         Name of the store
       
   123     * @param aNamespace         Name of the namespace
       
   124     * @param aHashKey           Hash key part of the identifier         
       
   125     * @param aUniqueKey         Unique key part of the identifier
       
   126     * @return KErrNone if successful
       
   127     *         Otherwise Symbian OS error code
       
   128     */
       
   129     
       
   130     IMPORT_C TInt SlotOpen(
       
   131         const TDesC8& aStoreName,
       
   132         const TDesC8& aNamespace,
       
   133         const TDesC8& aHashKey,
       
   134         const TDesC8& aUniqueKey,
       
   135         TInt& aSize );
       
   136 
       
   137     /**
       
   138     * SlotCreate
       
   139     * Create a slot to the namespace
       
   140     *
       
   141     * @param aStoreName         Name of the store
       
   142     * @param aNamespace         Name of the namespace
       
   143     * @param aHashKey           Hash key part of the identifier         
       
   144     * @param aUniqueKey         Unique key part of the identifier
       
   145     * @param aSize              Size of the slot to be created
       
   146     * @return KErrNone if successful
       
   147     *         Otherwise Symbian OS error code
       
   148     */
       
   149             
       
   150     IMPORT_C TInt SlotCreate(
       
   151         const TDesC8& aStoreName,
       
   152         const TDesC8& aNamespace,
       
   153         const TDesC8& aHashKey,
       
   154         const TDesC8& aUniqueKey,
       
   155         TInt& aSize );
       
   156 
       
   157     /**
       
   158     * SlotSeek
       
   159     * Seek within a slot
       
   160     *
       
   161     * @param aPos               Requested position
       
   162     * @param aOrigin            Seekmode
       
   163     * @return KErrNone if successful
       
   164     *         Otherwise Symbian OS error code
       
   165     */
       
   166             
       
   167     IMPORT_C TInt SlotSeek(
       
   168         TInt& aPos,
       
   169         TSeek aOrigin );
       
   170 
       
   171     /**
       
   172     * SlotRead
       
   173     * Read data from a slot
       
   174     *
       
   175     * @param aData              Slot data
       
   176     * @return KErrNone if successful
       
   177     *         Otherwise Symbian OS error code
       
   178     */
       
   179             
       
   180     IMPORT_C TInt SlotRead(
       
   181         TDes8& aData );
       
   182 
       
   183     /**
       
   184     * SlotWrite
       
   185     * Write data to the slot
       
   186     *
       
   187     * @param aData              Slot data
       
   188     * @return KErrNone if successful
       
   189     *         Otherwise Symbian OS error code
       
   190     */
       
   191             
       
   192     IMPORT_C TInt SlotWrite(
       
   193         const TDesC8& aData );
       
   194 
       
   195     /**
       
   196     * SlotResize
       
   197     * Resize the slot
       
   198     *
       
   199     * @param aSize              New size of the slot
       
   200     * @return KErrNone if successful
       
   201     *         Otherwise Symbian OS error code
       
   202     */
       
   203             
       
   204     IMPORT_C TInt SlotResize(
       
   205         TInt aSize );
       
   206 
       
   207     /**
       
   208     * SlotDelete
       
   209     * Delete the slot identified by the parameters
       
   210     *
       
   211     * @param aStoreName         Name of the store
       
   212     * @param aNamespace         Name of the namespace
       
   213     * @param aHashKey           Hash key part of the identifier         
       
   214     * @param aUniqueKey         Unique key part of the identifier
       
   215     * @return KErrNone if successful
       
   216     *         Otherwise Symbian OS error code
       
   217     */
       
   218             
       
   219     IMPORT_C TInt SlotDelete(
       
   220         const TDesC8& aStoreName,
       
   221         const TDesC8& aNamespace,
       
   222         const TDesC8& aHashKey,
       
   223         const TDesC8& aUniqueKey );
       
   224 
       
   225     /**
       
   226     * SlotClose
       
   227     * Close the current slot in use
       
   228     *
       
   229     * @return KErrNone if successful
       
   230     *         Otherwise Symbian OS error code
       
   231     */
       
   232                 
       
   233     IMPORT_C TInt SlotClose();
       
   234 
       
   235     /**
       
   236     * EnumerateStart
       
   237     * Initializes an enumeration
       
   238     *
       
   239     * @param aStoreName         Name of the store
       
   240     * @param aNamespace         Name of the namespace
       
   241     * @param aHashKey           Haskey to be used
       
   242     *
       
   243     * @return KErrNone if successful
       
   244     *         Otherwise Symbian OS error code
       
   245     */
       
   246         
       
   247     IMPORT_C TInt EnumerateStart(
       
   248         const TDesC8& aStoreName,
       
   249         const TDesC8& aNamespace,
       
   250         const TDesC8& aHashKey );
       
   251 
       
   252     /**
       
   253     * EnumerateReload
       
   254     * Reloads an enumeration
       
   255     *
       
   256     * @param aStoreName         Name of the store
       
   257     * @param aNamespace         Name of the namespace
       
   258     * @param aHashKey           Hash key part of the identifier         
       
   259     * @param aUniqueKey         Unique key part of the identifier
       
   260     *
       
   261     * @return KErrNone if successful
       
   262     *         Otherwise Symbian OS error code
       
   263     */
       
   264             
       
   265     IMPORT_C TInt EnumerateReload(
       
   266         TDes8& aStoreName,
       
   267         TDes8& aNamespace,
       
   268         TDes8& aHashKey,
       
   269         TDes8& aUniqueKey );
       
   270 
       
   271     /**
       
   272     * EnumerateNext
       
   273     * Moves to the next enumeration part
       
   274     *
       
   275     * @param aStoreName         Name of the store
       
   276     * @param aNamespace         Name of the namespace
       
   277     * @param aHashKey           Hash key part of the identifier         
       
   278     * @param aUniqueKey         Unique key part of the identifier
       
   279     *
       
   280     * @return KErrNone if successful
       
   281     *         Otherwise Symbian OS error code
       
   282     */
       
   283             
       
   284     IMPORT_C TInt EnumerateNext(
       
   285         TDes8& aStoreName,
       
   286         TDes8& aNamespace,
       
   287         TDes8& aHashKey,
       
   288         TDes8& aUniqueKey );
       
   289 
       
   290     /**
       
   291     * EnumerateDeleteCurrent
       
   292     * Deletes the current enumerated slot
       
   293     *
       
   294     * @return KErrNone if successful
       
   295     *         Otherwise Symbian OS error code
       
   296     */
       
   297             
       
   298     IMPORT_C TInt EnumerateDeleteCurrent();
       
   299 
       
   300     /**
       
   301     * EnumerateEnd
       
   302     * Finishes the enumeration session
       
   303     *
       
   304     * @return KErrNone if successful
       
   305     *         Otherwise Symbian OS error code
       
   306     */
       
   307         
       
   308     IMPORT_C TInt EnumerateEnd();
       
   309 
       
   310     /**
       
   311     * LogStats
       
   312     * Logs the stats of the server
       
   313     *
       
   314     * @return KErrNone if successful
       
   315     *         Otherwise Symbian OS error code
       
   316     */
       
   317     
       
   318     IMPORT_C TInt LogStats();
       
   319 
       
   320     /**
       
   321     * EmptyCache
       
   322     * Empties the cache used by the wmdrmserver
       
   323     *
       
   324     * @return KErrNone if successful
       
   325     *         Otherwise Symbian OS error code
       
   326     */
       
   327     
       
   328     IMPORT_C TInt EmptyCache();
       
   329 
       
   330     /**
       
   331     * TimeValid
       
   332     * returns the validity of the time
       
   333     *
       
   334     * @return ETrue if the time is Valid
       
   335     *         EFalse if the time is Invalid
       
   336     */
       
   337         
       
   338     IMPORT_C TBool TimeValid();
       
   339 
       
   340     /**
       
   341     * SetTimeAsValid
       
   342     * Sets the time as valid
       
   343     *
       
   344     * @param aValid             Validity of the time
       
   345     *                           ETrue if Valid
       
   346     *                           EFalse if Invalid
       
   347     * @return KErrNone if successful
       
   348     *         Otherwise Symbian OS error code
       
   349     */
       
   350     
       
   351     IMPORT_C void SetTimeAsValid( TBool aValid );
       
   352 
       
   353     /**
       
   354     * DeleteRights
       
   355     * Deletes allowed things from the rights database
       
   356     * Requires Capabilities or SecureID:s    
       
   357     *
       
   358     * @return KErrNone if successful
       
   359     *         Otherwise Symbian OS error code
       
   360     */    
       
   361     // Requires Capabilities or SecureID:s
       
   362     IMPORT_C TInt DeleteRights();
       
   363 
       
   364     /**
       
   365     * StoreState
       
   366     * Get the store state
       
   367     *
       
   368     * @param aState        State of the store
       
   369     * @return KErrNone if successful
       
   370     *         Otherwise Symbian OS error code
       
   371     */
       
   372         
       
   373     IMPORT_C TInt StoreState( TWmDrmStoreState& aState );
       
   374 
       
   375     /**
       
   376     * GetTime
       
   377     * Returns the time kept in the WMDRM server
       
   378     *
       
   379     * @param aTime              Time in UTC
       
   380     * @param aValid             ETrue if the time is secure
       
   381     *                           EFalse if the time is not secure
       
   382     * @return KErrNone if successful
       
   383     *         Otherwise Symbian OS error code
       
   384     */
       
   385         
       
   386     IMPORT_C TInt GetTime( TTime& aTime, TBool& aValid );
       
   387 	};
       
   388 
       
   389 #endif