diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/src/DRMRightsServer.cpp --- a/omadrm/drmengine/server/src/DRMRightsServer.cpp Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/src/DRMRightsServer.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -294,6 +294,29 @@ // ============================ MEMBER FUNCTIONS =============================== +// CUsageUrl: + +//-------------------------------------------------------------------------- +// CUsageUrl::CUsageUrl +// Storage class default constructor +//-------------------------------------------------------------------------- +// +CUsageUrl::CUsageUrl() + { + } + +//-------------------------------------------------------------------------- +// CUsageUrl::~CUsageUrl +// Storage class destructor +//-------------------------------------------------------------------------- +// +CUsageUrl::~CUsageUrl() + { + delete iUrl; + } + +// CDRMRightsServer: + // ----------------------------------------------------------------------------- // CDRMRightsServer::NewLC // Two-phased constructor. @@ -354,6 +377,8 @@ delete iNotifier; iNotifier = NULL; } + iActiveUrls.ResetAndDestroy(); + //An empty semaphore RSemaphore semaphore; } @@ -599,13 +624,13 @@ #ifndef RD_MULTIPLE_DRIVE - iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI ); + iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI, const_cast(this) ); #else //RD_MULTIPLE_DRIVE tempPath.Format( KRightsDir, (TUint)driveLetter ); - iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI ); + iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI, const_cast(this) ); #endif @@ -1337,6 +1362,85 @@ } } + + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::IsAccessingUrl +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +TInt CDRMRightsServer::IsAccessingUrl( const TDesC8& aContentId ) + { + for( TInt i = 0; i < iActiveUrls.Count(); i++ ) + { + if( !iActiveUrls[i]->iUrl->Compare( aContentId ) ) + { + return i; + } + } + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::RemoveAccessingUrl +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +void CDRMRightsServer::RemoveAccessingUrl( const TDesC8& aContentId ) + { + CUsageUrl* usage = NULL; + TInt index = KErrNotFound; + + index = IsAccessingUrl( aContentId ); + + if( index != KErrNotFound ) + { + // If there are negative or 0 values in the list for some reason + // remove them + if( iActiveUrls[index]->iRefCounter <= 1 ) + { + usage = iActiveUrls[index]; + iActiveUrls.Remove( index ); + delete usage; + } + else + { + iActiveUrls[index]->iRefCounter--; + } + } + } + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::AddAccessingUrlL +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +void CDRMRightsServer::AddAccessingUrlL( const TDesC8& aContentId ) + { + CUsageUrl* usage = NULL; + TInt index = KErrNotFound; + + index = IsAccessingUrl( aContentId ); + + if( index == KErrNotFound ) + { + usage = new ( ELeave ) CUsageUrl(); + CleanupStack::PushL( usage ); + usage->iUrl = aContentId.AllocL(); + usage->iRefCounter = 1; + iActiveUrls.AppendL( usage ); + CleanupStack::Pop( usage ); + } + else + { + usage = iActiveUrls[index]; + usage->iRefCounter++; + } + } + + + + // ----------------------------------------------------------------------------- // CDRMRightsServer::StopWatchingL // Delete the watchers @@ -1425,6 +1529,8 @@ } #endif + + // ========================== OTHER EXPORTED FUNCTIONS =========================