drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/src/DRM_CAFBlocks.cpp
changeset 84 b09186059647
parent 0 95b198f216e5
equal deleted inserted replaced
82:a117e284a2c6 84:b09186059647
     1 /*
     1 /*
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 // [INCLUDE FILES] - do not remove
    18 // [INCLUDE FILES] - do not remove
    27 #include <e32svr.h>
    19 #include <e32svr.h>
    28 #include <StifParser.h>
    20 #include <StifParser.h>
    29 #include <Stiftestinterface.h>
    21 #include <Stiftestinterface.h>
    30 #include "DRM_CAF.h"
       
    31 #include <caf/caftypes.h>
    22 #include <caf/caftypes.h>
    32 #include <caf/caf.h>
    23 #include <caf/caf.h>
    33 #include <caf/data.h>
    24 #include <caf/data.h>
    34 #include <f32file.h>
    25 #include <f32file.h>
    35 #include <bautils.h>
    26 #include <bautils.h>
    36 #include <TestclassAssert.h>
    27 #include <TestclassAssert.h>
       
    28 #include "DRM_CAF.h"
       
    29 #include "drmrightsparser.h"
       
    30 #include "drmpointerarray.h"
       
    31 #include "drmrights.h"
       
    32 #include "drmrightsclient.h"
       
    33 
    37 using namespace ContentAccess;
    34 using namespace ContentAccess;
    38 // LOCAL CONSTANTS AND MACROS
    35 // LOCAL CONSTANTS AND MACROS
    39 
    36 
    40 #define NUM_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
    37 #define NUM_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
    41 
    38 
   213 DbCnt: 109ms r:0\r\n\
   210 DbCnt: 109ms r:0\r\n\
   214 Fixes:\r\n\
   211 Fixes:\r\n\
   215 \r\n\
   212 \r\n\
   216 --random78o6bP%[GB6b/8&/45&%*^'?vS--");
   213 --random78o6bP%[GB6b/8&/45&%*^'?vS--");
   217 
   214 
       
   215 _LIT8(KROHeadOMA1, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\
       
   216 <!DOCTYPE o-ex:rights PUBLIC \"-//OMA//DTD DRMREL 1.0//EN\" \
       
   217 \"http://www.oma.org/dtd/dr\">\
       
   218 <o-ex:rights\
       
   219    xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\" \
       
   220    xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\" \
       
   221    xmlns:oma-dd=\"http://www.openmobilealliance.com/oma-dd\" \
       
   222    xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\">\
       
   223   <o-ex:context>\
       
   224     <o-dd:version>1.0</o-dd:version>\
       
   225   </o-ex:context>\
       
   226   <o-ex:agreement>\
       
   227     <o-ex:asset>\
       
   228       <o-ex:context>\
       
   229         <o-dd:uid>");
       
   230 
       
   231 _LIT8(KROTailFullOMA1, "</o-dd:uid>\
       
   232       </o-ex:context>\
       
   233       <ds:KeyInfo><ds:KeyValue>qtyAvglXxJNuAJVM2yxHQA==</ds:KeyValue></ds:KeyInfo>\
       
   234     </o-ex:asset>\
       
   235   <o-ex:permission>\
       
   236 \
       
   237 <o-dd:play>\
       
   238       <o-ex:constraint>\
       
   239       </o-ex:constraint>\
       
   240     </o-dd:play>\
       
   241 \
       
   242 <o-dd:display>\
       
   243       <o-ex:constraint>\
       
   244       </o-ex:constraint>\
       
   245     </o-dd:display>\
       
   246 \
       
   247 <o-dd:execute>\
       
   248       <o-ex:constraint>\
       
   249       </o-ex:constraint>\
       
   250     </o-dd:execute>\
       
   251 \
       
   252 <o-dd:print>\
       
   253       <o-ex:constraint>\
       
   254       </o-ex:constraint>\
       
   255     </o-dd:print>\
       
   256   </o-ex:permission>\
       
   257   </o-ex:agreement>\
       
   258 </o-ex:rights>");
       
   259 
   218 _LIT(KOma1Content, "c:\\content.dcf");
   260 _LIT(KOma1Content, "c:\\content.dcf");
       
   261 _LIT(KOma1Content2, "c:\\content2.dcf");
   219 _LIT(KOma2Content, "c:\\content.odf");
   262 _LIT(KOma2Content, "c:\\content.odf");
   220 _LIT(KOma2ContentNoEnc, "c:\\content-noenc.odf");
   263 _LIT(KOma2ContentNoEnc, "c:\\content-noenc.odf");
   221 _LIT(KOma2ContentNoEncTruncated, "c:\\content-noenc-trunc.odf");
   264 _LIT(KOma2ContentNoEncTruncated, "c:\\content-noenc-trunc.odf");
       
   265 _LIT8(KOma1ContentID, "cid:testcontent20090526095637-2657230746@testcontent.com");
   222 
   266 
   223 _LIT(KEncryptedDir, "c:\\");
   267 _LIT(KEncryptedDir, "c:\\");
   224 _LIT(KTempDcfName, "test.dcf");
   268 _LIT(KTempDcfName, "test.dcf");
   225 _LIT(KTempDcfPathName, "c:\\test.dcf");
   269 _LIT(KTempDcfPathName, "c:\\test.dcf");
   226 _LIT(KFVariantFile,"c:\\DrmCAFVarFile.txt");
   270 _LIT(KFVariantFile,"c:\\DrmCAFVarFile.txt");
   227 
   271 
   228 
   272 // LOCAL FUNCTION PROTOTYPES
       
   273 LOCAL_C void AddROL(const TDesC8& aHead, const TDesC8& aCID, const TDesC8& aTail);
       
   274 LOCAL_C void DeleteRODBL();
   229 // ============================= LOCAL FUNCTIONS ===============================
   275 // ============================= LOCAL FUNCTIONS ===============================
   230 
   276 
   231 
   277 
   232 NONSHARABLE_CLASS( CActiveWaiter ): public CActive
   278 NONSHARABLE_CLASS( CActiveWaiter ): public CActive
   233     {
   279     {
   347         }
   393         }
   348     agents.Close();
   394     agents.Close();
   349     CleanupStack::PopAndDestroy();
   395     CleanupStack::PopAndDestroy();
   350     return rm;
   396     return rm;
   351     }
   397     }
       
   398 
       
   399 // -----------------------------------------------------------------------------
       
   400 // AddROL
       
   401 // Helper function with which test cases can add ROs
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 LOCAL_C void AddROL(const TDesC8& aHead, const TDesC8& aCID,
       
   405     const TDesC8& aTail)
       
   406     {
       
   407     TInt roSize(aHead.Size() + aCID.Size() + aTail.Size());
       
   408     HBufC8* buf(HBufC8::NewLC(roSize));
       
   409     TPtr8 tmp(buf->Des());
       
   410 
       
   411     tmp.Append(aHead);
       
   412     tmp.Append(aCID);
       
   413     tmp.Append(aTail);
       
   414 
       
   415     CDRMPointerArray<CDRMRights>* rights(CDRMPointerArray<CDRMRights>::NewLC());
       
   416     rights->SetAutoCleanup(ETrue);
       
   417 
       
   418     CDrmRightsParser* rp(CDrmRightsParser::NewL());
       
   419     CleanupStack::PushL(rp);
       
   420 
       
   421     rp->ParseAndStoreL(*buf, *rights);
       
   422 
       
   423     CleanupStack::PopAndDestroy(3, buf); // rp, rights, buf
       
   424     }
       
   425 
       
   426 // -----------------------------------------------------------------------------
       
   427 // DeleteRODBL
       
   428 // Helper function with which test cases can delete RO DB.
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 LOCAL_C void DeleteRODBL()
       
   432     {
       
   433     RDRMRightsClient client;
       
   434     User::LeaveIfError(client.Connect());
       
   435     client.DeleteAll();
       
   436     client.Close();
       
   437     }
       
   438 
   352 
   439 
   353 // ============================ MEMBER FUNCTIONS ===============================
   440 // ============================ MEMBER FUNCTIONS ===============================
   354 
   441 
   355 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   356 // CDRM_CAF::Delete
   443 // CDRM_CAF::Delete
  1706 
  1793 
  1707     return KErrNone;
  1794     return KErrNone;
  1708     }
  1795     }
  1709 TInt  CDRM_CAF::CContent_NotifyStatusChangeL()
  1796 TInt  CDRM_CAF::CContent_NotifyStatusChangeL()
  1710     {
  1797     {
  1711     _LIT(KSdkVersion31,"Z:\\System\\install\\Series60v3.1.sis");
       
  1712     _LIT(KSdkVersion50,"Z:\\System\\install\\Series60v5.0.sis");
       
  1713     RFs fs;
       
  1714     TBool found = EFalse;
       
  1715     User::LeaveIfError(fs.Connect ());
       
  1716     CleanupClosePushL (fs);
       
  1717     if(BaflUtils::FileExists (fs, KSdkVersion31))
       
  1718         {
       
  1719         found = ETrue;
       
  1720         }
       
  1721     else if(BaflUtils::FileExists (fs, KSdkVersion50))
       
  1722         {
       
  1723         found = ETrue;
       
  1724         }
       
  1725     CContent* content = NULL;
  1798     CContent* content = NULL;
  1726     TRequestStatus status = KRequestPending;
  1799     TRequestStatus status = KRequestPending;
  1727     content = CContent::NewLC(KOma2Content);
  1800     content = CContent::NewLC(KOma1Content2);
  1728     STIF_ASSERT_NOT_NULL(content);
  1801     STIF_ASSERT_NOT_NULL(content);
  1729     content->NotifyStatusChange(ERightsAvailable, status);//ERightsAvailable
  1802     content->NotifyStatusChange(ERightsAvailable, status); //ERightsAvailable
  1730     if(found)
  1803     
  1731     	{
  1804     AddROL(KROHeadOMA1, KOma1ContentID, KROTailFullOMA1);
  1732     	User::After(10000);
  1805     
  1733 			content->CancelNotifyStatusChange(status);
  1806     User::After(10000);
  1734     	User::WaitForRequest(status);
  1807 	content->CancelNotifyStatusChange(status);
  1735    		}
  1808     User::WaitForRequest(status);
  1736    else
  1809     
  1737    		{
  1810     DeleteRODBL();
  1738    	  User::WaitForRequest(status);
  1811     
  1739   		}
  1812     CleanupStack::PopAndDestroy(content);
  1740     CleanupStack::PopAndDestroy(2);
       
  1741     return KErrNone;
  1813     return KErrNone;
  1742     }
  1814     }
  1743 
  1815 
  1744 TInt  CDRM_CAF::CContent_CancelNotifyStatusChangeL()
  1816 TInt  CDRM_CAF::CContent_CancelNotifyStatusChangeL()
  1745     {
  1817     {