40 // CWmDrmSession::CWmDrmSession |
40 // CWmDrmSession::CWmDrmSession |
41 // Constructor |
41 // Constructor |
42 //--------------------------------------------------------------------------- |
42 //--------------------------------------------------------------------------- |
43 // |
43 // |
44 CWmDrmSession::CWmDrmSession() |
44 CWmDrmSession::CWmDrmSession() |
45 { |
45 { |
46 } |
46 } |
47 |
47 |
48 //--------------------------------------------------------------------------- |
48 //--------------------------------------------------------------------------- |
49 // CWmDrmSession::~CWmDrmSession |
49 // CWmDrmSession::~CWmDrmSession |
50 // Destructor |
50 // Destructor |
51 //--------------------------------------------------------------------------- |
51 //--------------------------------------------------------------------------- |
52 // |
52 // |
53 CWmDrmSession::~CWmDrmSession() |
53 CWmDrmSession::~CWmDrmSession() |
54 { |
54 { |
55 LOGFN( "CWmDrmSession::~CWmDrmSession" ); |
55 LOGFN( "CWmDrmSession::~CWmDrmSession" ); |
56 //Server().Cache()->FlushL(); |
56 //Server().Cache()->FlushL(); |
57 delete iEnumerator; |
57 delete iEnumerator; |
58 iEnumerator = NULL; |
58 iEnumerator = NULL; |
59 delete iSlot; |
59 delete iSlot; |
60 iSlot = NULL; |
60 iSlot = NULL; |
61 } |
61 } |
62 |
62 |
63 //--------------------------------------------------------------------------- |
63 //--------------------------------------------------------------------------- |
64 // CWmDrmSession::InitStoreL |
64 // CWmDrmSession::InitStoreL |
65 //--------------------------------------------------------------------------- |
65 //--------------------------------------------------------------------------- |
66 // |
66 // |
67 TInt CWmDrmSession::InitStoreL( const RMessage2& aMessage ) |
67 TInt CWmDrmSession::InitStoreL( const RMessage2& aMessage ) |
68 { |
68 { |
69 TInt r = KErrNone; |
69 TInt r = KErrNone; |
70 TBuf8<KMaxWmDrmStoreNameSize> store; |
70 TBuf8<KMaxWmDrmStoreNameSize> store; |
71 |
71 |
72 LOGFNR( "CWmDrmSession::InitStoreL", r ); |
72 LOGFNR( "CWmDrmSession::InitStoreL", r ); |
73 if ( aMessage.GetDesLength( 0 ) > KMaxWmDrmStoreNameSize || aMessage.GetDesLength( 0 ) <= 0 ) |
73 if ( aMessage.GetDesLength( 0 ) > KMaxWmDrmStoreNameSize || aMessage.GetDesLength( 0 ) <= 0 ) |
74 { |
74 { |
75 User::Leave( KErrArgument ); |
75 User::Leave( KErrArgument ); |
76 } |
76 } |
104 } |
104 } |
105 |
105 |
106 //--------------------------------------------------------------------------- |
106 //--------------------------------------------------------------------------- |
107 // CWmDrmSession::InitNamespaceL |
107 // CWmDrmSession::InitNamespaceL |
108 //--------------------------------------------------------------------------- |
108 //--------------------------------------------------------------------------- |
109 // |
109 // |
110 TInt CWmDrmSession::InitNamespaceL( const RMessage2& aMessage ) |
110 TInt CWmDrmSession::InitNamespaceL( const RMessage2& aMessage ) |
111 { |
111 { |
112 TInt r = KErrNone; |
112 TInt r = KErrNone; |
113 TBuf8<KMaxWmDrmStoreNameSize> store; |
113 TBuf8<KMaxWmDrmStoreNameSize> store; |
114 TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace; |
114 TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace; |
115 |
115 |
116 LOGFNR( "CWmDrmSession::InitNamespaceL", r ); |
116 LOGFNR( "CWmDrmSession::InitNamespaceL", r ); |
117 // :KLUDGE: Note: store length of zero is allowed |
117 // :KLUDGE: Note: store length of zero is allowed |
118 if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize || |
118 if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize || |
119 aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize || |
119 aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize || |
120 aMessage.GetDesLength( 1 ) <= 0 ) |
120 aMessage.GetDesLength( 1 ) <= 0 ) |
137 } |
137 } |
138 |
138 |
139 //--------------------------------------------------------------------------- |
139 //--------------------------------------------------------------------------- |
140 // CWmDrmSession::RemoveNamespaceL |
140 // CWmDrmSession::RemoveNamespaceL |
141 //--------------------------------------------------------------------------- |
141 //--------------------------------------------------------------------------- |
142 // |
142 // |
143 TInt CWmDrmSession::RemoveNamespaceL( const RMessage2& aMessage ) |
143 TInt CWmDrmSession::RemoveNamespaceL( const RMessage2& aMessage ) |
144 { |
144 { |
145 TInt r = KErrNone; |
145 TInt r = KErrNone; |
146 TBuf8<KMaxWmDrmStoreNameSize> store; |
146 TBuf8<KMaxWmDrmStoreNameSize> store; |
147 TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace; |
147 TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace; |
148 |
148 |
149 LOGFNR( "CWmDrmSession::RemoveNamespaceL", r ); |
149 LOGFNR( "CWmDrmSession::RemoveNamespaceL", r ); |
150 // :KLUDGE: Note: store length of zero is allowed |
150 // :KLUDGE: Note: store length of zero is allowed |
151 if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize || |
151 if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize || |
152 aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize || |
152 aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize || |
153 aMessage.GetDesLength( 1 ) <= 0 ) |
153 aMessage.GetDesLength( 1 ) <= 0 ) |
221 if ( iSlot != NULL ) |
221 if ( iSlot != NULL ) |
222 { |
222 { |
223 delete iSlot; |
223 delete iSlot; |
224 iSlot = NULL; |
224 iSlot = NULL; |
225 } |
225 } |
226 |
226 |
227 iSlot = CSlot::NewL( &Server(), messageBuffer ); |
227 iSlot = CSlot::NewL( &Server(), messageBuffer ); |
228 iSlot->CreateL( size ); |
228 iSlot->CreateL( size ); |
229 CleanupStack::PopAndDestroy( &messageBuffer ); |
229 CleanupStack::PopAndDestroy( &messageBuffer ); |
230 return r; |
230 return r; |
231 } |
231 } |
232 |
232 |
233 //--------------------------------------------------------------------------- |
233 //--------------------------------------------------------------------------- |
234 // CWmDrmSession::SlotSeekL |
234 // CWmDrmSession::SlotSeekL |
235 //--------------------------------------------------------------------------- |
235 //--------------------------------------------------------------------------- |
236 // |
236 // |
237 TInt CWmDrmSession::SlotSeekL( const RMessage2& aMessage ) |
237 TInt CWmDrmSession::SlotSeekL( const RMessage2& aMessage ) |
238 { |
238 { |
239 TInt r = KErrNone; |
239 TInt r = KErrNone; |
240 TSeek whence = ESeekStart; |
240 TSeek whence = ESeekStart; |
241 TInt pos = aMessage.Int0(); |
241 TInt pos = aMessage.Int0(); |
242 TInt size; |
242 TInt size; |
243 |
243 |
244 LOGFNR( "CWmDrmSession::SlotSeekL", r ); |
244 LOGFNR( "CWmDrmSession::SlotSeekL", r ); |
245 if ( iSlot == NULL ) |
245 if ( iSlot == NULL ) |
246 { |
246 { |
247 User::Leave( KErrNotReady ); |
247 User::Leave( KErrNotReady ); |
248 } |
248 } |
516 //--------------------------------------------------------------------------- |
516 //--------------------------------------------------------------------------- |
517 // |
517 // |
518 TInt CWmDrmSession::EmptyCacheL( const RMessage2& aMessage ) |
518 TInt CWmDrmSession::EmptyCacheL( const RMessage2& aMessage ) |
519 { |
519 { |
520 TInt r = KErrNone; |
520 TInt r = KErrNone; |
521 |
521 |
522 LOGFNR( "CWmDrmSession::EmptyCacheL", r ); |
522 LOGFNR( "CWmDrmSession::EmptyCacheL", r ); |
523 TRAP_IGNORE( EnumerateEndL( aMessage ) ); |
523 TRAP_IGNORE( EnumerateEndL( aMessage ) ); |
524 TRAP_IGNORE( SlotCloseL( aMessage ) ); |
524 TRAP_IGNORE( SlotCloseL( aMessage ) ); |
525 Server().ResetCacheL(); |
525 Server().ResetCacheL(); |
526 return r; |
526 return r; |
527 } |
527 } |
528 |
528 |
529 //--------------------------------------------------------------------------- |
529 //--------------------------------------------------------------------------- |
530 // CWmDrmSession::LogStats |
530 // CWmDrmSession::LogStats |
531 //--------------------------------------------------------------------------- |
531 //--------------------------------------------------------------------------- |
532 // |
532 // |
533 TInt CWmDrmSession::LogStats( const RMessage2& /*aMessage*/ ) |
533 TInt CWmDrmSession::LogStats( const RMessage2& /*aMessage*/ ) |
534 { |
534 { |
535 TInt r = KErrNone; |
535 TInt r = KErrNone; |
536 |
536 |
537 #ifdef _LOGGING |
537 #ifdef _LOGGING |
538 TInt cells; |
538 TInt cells; |
539 TInt amount; |
539 TInt amount; |
540 TInt i; |
540 TInt i; |
541 TInt j; |
541 TInt j; |
542 _LIT( KStatsDir, "wmdrm" ); |
542 _LIT( KStatsDir, "wmdrm" ); |
543 _LIT( KStatsFile, "wmdrmserver.txt" ); |
543 _LIT( KStatsFile, "wmdrmserver.txt" ); |
544 |
544 |
545 LOGFNR( "CWmDrmSession::LogStatsL", r ); |
545 LOGFNR( "CWmDrmSession::LogStatsL", r ); |
546 cells = User::AllocSize( amount ); |
546 cells = User::AllocSize( amount ); |
547 RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, _L( "Statistics:" ) ); |
547 RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, _L( "Statistics:" ) ); |
548 RFileLogger::WriteFormat( KStatsDir, KStatsFile, EFileLoggingModeAppend, |
548 RFileLogger::WriteFormat( KStatsDir, KStatsFile, EFileLoggingModeAppend, |
549 _L( "Memory: %d cells, %d bytes allocated" ), cells, amount ); |
549 _L( "Memory: %d cells, %d bytes allocated" ), cells, amount ); |
582 RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, |
582 RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, |
583 *Server().EnumeratorCache()->iEnumeratorCache[i]->iEntries[j] ); |
583 *Server().EnumeratorCache()->iEnumeratorCache[i]->iEntries[j] ); |
584 } |
584 } |
585 } |
585 } |
586 #endif |
586 #endif |
587 |
587 |
588 return r; |
588 return r; |
589 } |
589 } |
590 |
590 |
591 //--------------------------------------------------------------------------- |
591 //--------------------------------------------------------------------------- |
592 // CWmDrmSession::TimeValid |
592 // CWmDrmSession::TimeValid |
593 //--------------------------------------------------------------------------- |
593 //--------------------------------------------------------------------------- |
594 // |
594 // |
595 TInt CWmDrmSession::TimeValid( const RMessage2& /*aMessage*/ ) |
595 TInt CWmDrmSession::TimeValid( const RMessage2& /*aMessage*/ ) |
596 { |
596 { |
597 TInt r = KErrNone; |
597 TInt r = KErrNone; |
598 |
598 |
599 LOGFNR( "CWmDrmSession::TimeValid", r ); |
599 LOGFNR( "CWmDrmSession::TimeValid", r ); |
600 r = Server().Clock()->TimeIsGood(); |
600 r = Server().Clock()->TimeIsGood(); |
601 return r; |
601 return r; |
602 } |
602 } |
603 |
603 |
604 //--------------------------------------------------------------------------- |
604 //--------------------------------------------------------------------------- |
605 // CWmDrmSession::SetTimeAsValidL |
605 // CWmDrmSession::SetTimeAsValidL |
606 //--------------------------------------------------------------------------- |
606 //--------------------------------------------------------------------------- |
607 // |
607 // |
608 void CWmDrmSession::SetTimeAsValidL( const RMessage2& aMessage ) |
608 void CWmDrmSession::SetTimeAsValidL( const RMessage2& aMessage ) |
609 { |
609 { |
610 LOGFN( "CWmDrmSession::TimeValid" ); |
610 LOGFN( "CWmDrmSession::TimeValid" ); |
611 Server().Clock()->SetTimeAsGoodL( aMessage.Int0() == 0 ? EFalse : ETrue ); |
611 Server().Clock()->SetTimeAsGoodL( aMessage.Int0() == 0 ? EFalse : ETrue ); |
612 } |
612 } |
613 |
613 |
614 |
614 |
615 //--------------------------------------------------------------------------- |
615 //--------------------------------------------------------------------------- |
616 // CWmDrmSession::DeleteRightsL |
616 // CWmDrmSession::DeleteRightsL |
617 //--------------------------------------------------------------------------- |
617 //--------------------------------------------------------------------------- |
618 // |
618 // |
619 TInt CWmDrmSession::DeleteRightsL( const RMessage2& /*aMessage*/ ) |
619 TInt CWmDrmSession::DeleteRightsL( const RMessage2& /*aMessage*/ ) |
620 { |
620 { |
621 TInt r = KErrNone; |
621 TInt r = KErrNone; |
622 TBool wmDrmRightsConfigFound( EFalse ); |
622 TBool wmDrmRightsConfigFound( EFalse ); |
623 TChar driveLetter; |
623 TChar driveLetter; |
624 TDrmScheme drmScheme( EDrmSchemeWmDrm ); |
624 TDrmScheme drmScheme( EDrmSchemeWmDrm ); |
625 |
625 |
626 LOGFNR( "CWmDrmSession::DeleteRightsL", r ); |
626 LOGFNR( "CWmDrmSession::DeleteRightsL", r ); |
627 // Close EVERYTHING down, clear cache etc, so that we have nothing going on |
627 // Close EVERYTHING down, clear cache etc, so that we have nothing going on |
628 // When we start to delete stuff |
628 // When we start to delete stuff |
629 Server().ResetCacheL(); |
629 Server().ResetCacheL(); |
630 |
630 |
631 wmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( |
631 wmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( |
632 Server().Fs(), drmScheme, driveLetter ); |
632 Server().Fs(), drmScheme, driveLetter ); |
633 |
633 |
634 // If WM DRM rights storage configuration is found, update both databases |
634 // If WM DRM rights storage configuration is found, update both databases |
635 if ( wmDrmRightsConfigFound ) |
635 if ( wmDrmRightsConfigFound ) |
636 { |
636 { |
637 Server().DataStore()->UpdateDummyDbFileL( |
637 Server().DataStore()->UpdateDummyDbFileL( |
638 Server().DataStore()->DummyDBSizeL( ETrue ), ETrue ); |
638 Server().DataStore()->DummyDBSizeL( ETrue ), ETrue ); |
639 } |
639 } |
640 Server().DataStore()->UpdateDummyDbFileL( |
640 Server().DataStore()->UpdateDummyDbFileL( |
641 Server().DataStore()->DummyDBSizeL( EFalse ), EFalse ); |
641 Server().DataStore()->DummyDBSizeL( EFalse ), EFalse ); |
642 |
642 |
643 // Delete license store |
643 // Delete license store |
644 Server().Db()->DeleteLicenseStoreL(); |
644 Server().Db()->DeleteLicenseStoreL(); |
645 |
645 |
646 // If WM DRM rights storage configuration is found, update both databases |
646 // If WM DRM rights storage configuration is found, update both databases |
647 if ( wmDrmRightsConfigFound ) |
647 if ( wmDrmRightsConfigFound ) |
648 { |
648 { |
649 Server().DataStore()->UpdateDummyDbFileL( 0, ETrue ); |
649 Server().DataStore()->UpdateDummyDbFileL( 0, ETrue ); |
650 } |
650 } |
651 Server().DataStore()->UpdateDummyDbFileL( 0, EFalse ); |
651 Server().DataStore()->UpdateDummyDbFileL( 0, EFalse ); |
652 |
652 |
653 return r; |
653 return r; |
654 } |
654 } |
655 |
655 |
656 //--------------------------------------------------------------------------- |
656 //--------------------------------------------------------------------------- |
657 // CWmDrmSession::StoreStateL |
657 // CWmDrmSession::StoreStateL |
658 //--------------------------------------------------------------------------- |
658 //--------------------------------------------------------------------------- |
659 // |
659 // |
660 void CWmDrmSession::StoreStateL( const RMessage2& aMessage ) |
660 void CWmDrmSession::StoreStateL( const RMessage2& aMessage ) |
661 { |
661 { |
662 TWmDrmStoreState state; |
662 TWmDrmStoreState state; |
663 |
663 |
664 LOGFN( "CWmDrmSession::StoreStateL" ); |
664 LOGFN( "CWmDrmSession::StoreStateL" ); |
665 state = Server().DataStore()->DataStoreStateL(); |
665 state = Server().DataStore()->DataStoreStateL(); |
666 aMessage.WriteL( 0, TPckg<TWmDrmStoreState>( state ) ); |
666 aMessage.WriteL( 0, TPckg<TWmDrmStoreState>( state ) ); |
667 } |
667 } |
668 |
668 |
674 { |
674 { |
675 TTime time = Time::NullTTime(); |
675 TTime time = Time::NullTTime(); |
676 TBool validity = EFalse; |
676 TBool validity = EFalse; |
677 TPckg<TTime> timePckg(time); |
677 TPckg<TTime> timePckg(time); |
678 TPckg<TBool> validityPckg(validity); |
678 TPckg<TBool> validityPckg(validity); |
679 |
679 |
680 LOGFN( "CWmDrmSession::GetTimeL" ); |
680 LOGFN( "CWmDrmSession::GetTimeL" ); |
681 |
681 |
682 // Get the time from the clock |
682 // Get the time from the clock |
683 Server().Clock()->GetTimeL( time, validity ); |
683 Server().Clock()->GetTimeL( time, validity ); |
684 |
684 |
685 aMessage.WriteL(0, timePckg); |
685 aMessage.WriteL(0, timePckg); |
686 aMessage.WriteL(1, validityPckg); |
686 aMessage.WriteL(1, validityPckg); |
687 } |
687 } |
688 |
688 |
689 |
689 |
690 //--------------------------------------------------------------------------- |
690 //--------------------------------------------------------------------------- |
691 // CWmDrmSession::CommitDataL |
691 // CWmDrmSession::CommitDataL |
692 //--------------------------------------------------------------------------- |
692 //--------------------------------------------------------------------------- |
693 // |
693 // |
694 void CWmDrmSession::CommitDataL( const RMessage2& aMessage ) |
694 void CWmDrmSession::CommitDataL( const RMessage2& /*aMessage*/ ) |
695 { |
695 { |
696 |
696 |
697 LOGFN( "CWmDrmSession::CommitDataL" ); |
697 LOGFN( "CWmDrmSession::CommitDataL" ); |
698 |
698 |
699 // Force a commit on the database |
699 // Force a commit on the database |
700 Server().Db()->CheckDatabaseCommitL( ETrue ); |
700 Server().Db()->CheckDatabaseCommitL( ETrue ); |
701 } |
701 } |
702 |
702 |
703 |
703 |
704 |
704 |
705 //--------------------------------------------------------------------------- |
705 //--------------------------------------------------------------------------- |
706 // CWmDrmSession::ServiceL |
706 // CWmDrmSession::ServiceL |
707 //--------------------------------------------------------------------------- |
707 //--------------------------------------------------------------------------- |
708 // |
708 // |
709 void CWmDrmSession::ServiceL( const RMessage2& aMessage ) |
709 void CWmDrmSession::ServiceL( const RMessage2& aMessage ) |
710 { |
710 { |
711 TInt r = KErrNone; |
711 TInt r = KErrNone; |
712 TInt trap = KErrNone; |
712 TInt trap = KErrNone; |
713 _LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM); |
713 _LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM); |
714 RThread client; |
714 RThread client; |
715 |
715 |
716 LOGFNR( "CWmDrmSession::ServiceL", r ); |
716 LOGFNR( "CWmDrmSession::ServiceL", r ); |
717 #ifdef _LOGGING |
717 #ifdef _LOGGING |
718 TInt c; |
718 TInt c; |
719 TInt s; |
719 TInt s; |
720 c = User::AllocSize(s); |
720 c = User::AllocSize(s); |
721 LOG3( "Memory: %d cells, %d bytes allocated", c, s ); |
721 LOG3( "Memory: %d cells, %d bytes allocated", c, s ); |
820 } |
820 } |
821 } |
821 } |
822 client.Close(); |
822 client.Close(); |
823 LOG2( "** ServiceL error: %d", r ); |
823 LOG2( "** ServiceL error: %d", r ); |
824 aMessage.Complete( r ); |
824 aMessage.Complete( r ); |
825 } |
825 } |
826 |
826 |
827 //--------------------------------------------------------------------------- |
827 //--------------------------------------------------------------------------- |
828 // CWmDrmSession::ServiceError |
828 // CWmDrmSession::ServiceError |
829 //--------------------------------------------------------------------------- |
829 //--------------------------------------------------------------------------- |
830 // |
830 // |
831 void CWmDrmSession::ServiceError( const RMessage2& aMessage, TInt aError ) |
831 void CWmDrmSession::ServiceError( const RMessage2& aMessage, TInt aError ) |
832 { |
832 { |
833 LOGFN( "CWmDrmSession::ServiceError" ); |
833 LOGFN( "CWmDrmSession::ServiceError" ); |
834 LOG2( "** Error: %d", aError ); |
834 LOG2( "** Error: %d", aError ); |
835 CSession2::ServiceError( aMessage, aError ); |
835 CSession2::ServiceError( aMessage, aError ); |
836 } |
836 } |
837 |
837 |
838 //--------------------------------------------------------------------------- |
838 //--------------------------------------------------------------------------- |
839 // CWmDrmSession::Server |
839 // CWmDrmSession::Server |
840 //--------------------------------------------------------------------------- |
840 //--------------------------------------------------------------------------- |
841 // |
841 // |
842 CWmDrmServer& CWmDrmSession::Server() |
842 CWmDrmServer& CWmDrmSession::Server() |
843 { |
843 { |
844 return *static_cast<CWmDrmServer*>( const_cast<CServer2*>( CSession2::Server() ) ); |
844 return *static_cast<CWmDrmServer*>( const_cast<CServer2*>( CSession2::Server() ) ); |
845 } |
845 } |