214 // ----------------------------------------------------------------------------- |
214 // ----------------------------------------------------------------------------- |
215 // Function StartDBServer(). |
215 // Function StartDBServer(). |
216 // This function starts the actual server under TRAP harness and starts |
216 // This function starts the actual server under TRAP harness and starts |
217 // waiting for connections. This function returns only if there has been |
217 // waiting for connections. This function returns only if there has been |
218 // errors during server startup or the server is stopped for some reason. |
218 // errors during server startup or the server is stopped for some reason. |
219 // |
219 // |
220 // Returns: TInt: Symbian OS error code. |
220 // Returns: TInt: Symbian OS error code. |
221 // ----------------------------------------------------------------------------- |
221 // ----------------------------------------------------------------------------- |
222 TInt StartDBServer( void ) |
222 TInt StartDBServer( void ) |
223 { |
223 { |
224 TInt error = KErrNone; |
224 TInt error = KErrNone; |
225 CDRMRightsServer* server = NULL; |
225 CDRMRightsServer* server = NULL; |
226 TUint8 count = 0; |
226 TUint8 count = 0; |
227 |
227 |
228 do |
228 do |
229 { |
229 { |
230 DRMLOG2( _L( "RightsServer.exe: StartDBServer: %d" ), error ); |
230 DRMLOG2( _L( "RightsServer.exe: StartDBServer: %d" ), error ); |
231 |
231 |
232 ++count; |
232 ++count; |
233 |
233 |
234 TRAP( error, ( server = CDRMRightsServer::NewL() ) ); |
234 TRAP( error, ( server = CDRMRightsServer::NewL() ) ); |
235 |
235 |
236 if ( error ) |
236 if ( error ) |
237 { |
237 { |
238 User::After( TTimeIntervalMicroSeconds32(KWaitingTime) ); |
238 User::After( TTimeIntervalMicroSeconds32(KWaitingTime) ); |
239 } |
239 } |
240 |
240 |
241 } while( error && ( count <= KMaxStartTries ) ); |
241 } while( error && ( count <= KMaxStartTries ) ); |
242 |
242 |
243 if( error ) |
243 if( error ) |
244 { |
244 { |
245 DRMLOG2( _L( "RightsServer.exe: CDRMRightsServer::NewL failed: %d " ), error ); |
245 DRMLOG2( _L( "RightsServer.exe: CDRMRightsServer::NewL failed: %d " ), error ); |
246 // Failed |
246 // Failed |
247 return error; |
247 return error; |
248 } |
248 } |
249 |
249 |
250 // Release the semaphore if necessary. |
250 // Release the semaphore if necessary. |
251 SignalClient(); |
251 SignalClient(); |
252 |
252 |
253 // Start waiting for connections |
253 // Start waiting for connections |
254 CActiveScheduler::Start(); |
254 CActiveScheduler::Start(); |
255 |
255 |
256 // Dying... |
256 // Dying... |
257 // Delete CDRMRigntsServer |
257 // Delete CDRMRigntsServer |
258 |
258 |
259 DRMLOG( _L( "RightsServer.exe: DB server dying..." ) ); |
259 DRMLOG( _L( "RightsServer.exe: DB server dying..." ) ); |
260 |
260 |
261 delete server; |
261 delete server; |
262 |
262 |
263 return KErrNone; |
263 return KErrNone; |
264 } |
264 } |
265 |
265 |
266 #ifdef DRM_USE_SERIALNUMBER_URI |
266 #ifdef DRM_USE_SERIALNUMBER_URI |
267 // ----------------------------------------------------------------------------- |
267 // ----------------------------------------------------------------------------- |
300 // ----------------------------------------------------------------------------- |
300 // ----------------------------------------------------------------------------- |
301 // |
301 // |
302 CDRMRightsServer* CDRMRightsServer::NewL() |
302 CDRMRightsServer* CDRMRightsServer::NewL() |
303 { |
303 { |
304 CDRMRightsServer* self = new( ELeave ) CDRMRightsServer(); |
304 CDRMRightsServer* self = new( ELeave ) CDRMRightsServer(); |
305 |
305 |
306 CleanupStack::PushL( self ); |
306 CleanupStack::PushL( self ); |
307 |
307 |
308 self->ConstructL(); |
308 self->ConstructL(); |
309 |
309 |
310 CleanupStack::Pop( self ); |
310 CleanupStack::Pop( self ); |
311 |
311 |
312 return self; |
312 return self; |
313 } |
313 } |
314 |
314 |
315 // ----------------------------------------------------------------------------- |
315 // ----------------------------------------------------------------------------- |
316 // Destructor |
316 // Destructor |
317 // ----------------------------------------------------------------------------- |
317 // ----------------------------------------------------------------------------- |
318 CDRMRightsServer::~CDRMRightsServer() |
318 CDRMRightsServer::~CDRMRightsServer() |
319 { |
319 { |
320 DRMLOG( _L( "CDRMRightsServer::~" ) ); |
320 DRMLOG( _L( "CDRMRightsServer::~" ) ); |
321 |
321 |
322 delete iIMEI; iIMEI = NULL; |
322 delete iIMEI; iIMEI = NULL; |
323 |
323 |
324 delete iIMSI; iIMSI = NULL; |
324 delete iIMSI; iIMSI = NULL; |
325 |
325 |
326 delete iDb; iDb = NULL; |
326 delete iDb; iDb = NULL; |
327 |
327 |
328 iClock.Close(); |
328 iClock.Close(); |
329 iCache.Close(); |
329 iCache.Close(); |
330 |
330 |
331 iMeteringDb.Close(); |
331 iMeteringDb.Close(); |
332 |
332 |
333 iFs.Close(); |
333 iFs.Close(); |
334 iActiveCountConstraints.ResetAndDestroy(); |
334 iActiveCountConstraints.ResetAndDestroy(); |
335 iActiveCountConstraints.Close(); |
335 iActiveCountConstraints.Close(); |
336 |
336 |
337 delete iBackupObserver; |
337 delete iBackupObserver; |
338 delete iBackupHandler; |
338 delete iBackupHandler; |
339 delete iActiveBackupClient; |
339 delete iActiveBackupClient; |
340 delete iDbWatcher; |
340 delete iDbWatcher; |
341 |
341 |
342 #if 0 |
342 #if 0 |
343 // Close and delete the shared data client |
343 // Close and delete the shared data client |
344 if( iSharedDataClient ) |
344 if( iSharedDataClient ) |
345 { |
345 { |
346 iSharedDataClient->Close(); |
346 iSharedDataClient->Close(); |
347 delete iSharedDataClient; |
347 delete iSharedDataClient; |
348 iSharedDataClient = NULL; |
348 iSharedDataClient = NULL; |
349 } |
349 } |
516 // CDRMRightsServer::CDRMRightsServer |
516 // CDRMRightsServer::CDRMRightsServer |
517 // C++ default constructor can NOT contain any code, that |
517 // C++ default constructor can NOT contain any code, that |
518 // might leave. |
518 // might leave. |
519 // ----------------------------------------------------------------------------- |
519 // ----------------------------------------------------------------------------- |
520 // |
520 // |
521 CDRMRightsServer::CDRMRightsServer() : |
521 CDRMRightsServer::CDRMRightsServer() : |
522 CServer2( EPriorityStandard ), |
522 CServer2( EPriorityStandard ), |
523 iIMEI( NULL ), |
523 iIMEI( NULL ), |
524 iArmed( EFalse ), |
524 iArmed( EFalse ), |
525 iIMSI( NULL ), |
525 iIMSI( NULL ), |
526 iGetImsi( ETrue ) |
526 iGetImsi( ETrue ) |
527 { |
527 { |
528 // Nothing |
528 // Nothing |
529 } |
529 } |
530 |
530 |
531 // ----------------------------------------------------------------------------- |
531 // ----------------------------------------------------------------------------- |
532 // CDRMRightsServer::ConstructL |
532 // CDRMRightsServer::ConstructL |
533 // Symbian 2nd phase constructor can leave. |
533 // Symbian 2nd phase constructor can leave. |
534 // ----------------------------------------------------------------------------- |
534 // ----------------------------------------------------------------------------- |
535 // |
535 // |
536 void CDRMRightsServer::ConstructL() |
536 void CDRMRightsServer::ConstructL() |
537 { |
537 { |
538 DRMLOG( _L( "CDRMRightsServer::ConstructL" ) ); |
538 DRMLOG( _L( "CDRMRightsServer::ConstructL" ) ); |
539 |
539 |
540 TDRMKey key; |
540 TDRMKey key; |
541 RSemaphore semaphore; |
541 RSemaphore semaphore; |
542 RProcess currentprocess; |
542 RProcess currentprocess; |
543 |
543 |
544 // Ignore errors |
544 // Ignore errors |
545 User::RenameThread( KRightsServerThread ); |
545 User::RenameThread( KRightsServerThread ); |
546 User::LeaveIfError( iFs.Connect() ); |
546 User::LeaveIfError( iFs.Connect() ); |
547 |
547 |
548 #ifndef RD_MULTIPLE_DRIVE |
548 #ifndef RD_MULTIPLE_DRIVE |
549 |
549 |
550 // Ignore errors |
550 // Ignore errors |
551 iFs.MkDirAll( KDRMDbTempPath ); |
551 iFs.MkDirAll( KDRMDbTempPath ); |
552 |
552 |
553 #else //RD_MULTIPLE_DRIVE |
553 #else //RD_MULTIPLE_DRIVE |
554 |
554 |
555 TFileName tempPath; |
555 TFileName tempPath; |
556 TFileName tempPath2; |
556 TFileName tempPath2; |
557 TFileName tempRemovablePath; |
557 TFileName tempRemovablePath; |
558 TInt driveNumber( -1 ); |
558 TInt driveNumber( -1 ); |
559 TChar driveLetter; |
559 TChar driveLetter; |
560 TChar driveLetterRemovable; |
560 TChar driveLetterRemovable; |
561 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); |
561 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); |
562 iFs.DriveToChar( driveNumber, driveLetter ); |
562 iFs.DriveToChar( driveNumber, driveLetter ); |
563 |
563 |
564 tempPath.Format( KDbTempPath, (TUint)driveLetter ); |
564 tempPath.Format( KDbTempPath, (TUint)driveLetter ); |
565 |
565 |
566 // Ignore errors |
566 // Ignore errors |
567 iFs.MkDirAll( tempPath ); |
567 iFs.MkDirAll( tempPath ); |
568 |
568 |
569 #endif |
569 #endif |
570 |
570 |
571 DRMLOG( _L( "CDRMRightsServer::ConstructL: SharedDataClient" ) ); |
571 DRMLOG( _L( "CDRMRightsServer::ConstructL: SharedDataClient" ) ); |
572 |
572 |
573 // Create and instance of the shared data client |
573 // Create and instance of the shared data client |
574 // iSharedDataClient = new (ELeave) RSharedDataClient(this); |
574 // iSharedDataClient = new (ELeave) RSharedDataClient(this); |
575 |
575 |
579 /* XXX Backup via Publish/Subscribe |
579 /* XXX Backup via Publish/Subscribe |
580 User::LeaveIfError(iSharedDataClient->NotifyChange( |
580 User::LeaveIfError(iSharedDataClient->NotifyChange( |
581 KSDUidSystem, &KBackupRestoreStatus ) ); |
581 KSDUidSystem, &KBackupRestoreStatus ) ); |
582 User::LeaveIfError(iSharedDataClient->NotifyChange( |
582 User::LeaveIfError(iSharedDataClient->NotifyChange( |
583 KSDUidSystem, &KDRMBackupRestoreStatus) ); |
583 KSDUidSystem, &KDRMBackupRestoreStatus) ); |
584 */ |
584 */ |
585 |
585 |
586 |
586 |
587 GetDbKeyL( key ); |
587 GetDbKeyL( key ); |
588 |
588 |
589 |
589 |
590 DRMLOG( _L( "CDRMRightsServer::ConstructL: database" ) ); |
590 DRMLOG( _L( "CDRMRightsServer::ConstructL: database" ) ); |
591 |
591 |
592 GetIMEIL(); |
592 GetIMEIL(); |
593 |
593 |
594 // Create the imsi pointer array: |
594 // Create the imsi pointer array: |
595 iIMSI = CDRMPointerArray<HBufC8>::NewL(); |
595 iIMSI = CDRMPointerArray<HBufC8>::NewL(); |
596 iIMSI->SetAutoCleanup(ETrue); |
596 iIMSI->SetAutoCleanup(ETrue); |
597 |
597 |
598 GetIMSIL(); |
598 GetIMSIL(); |
599 |
599 |
600 #ifndef RD_MULTIPLE_DRIVE |
600 #ifndef RD_MULTIPLE_DRIVE |
601 |
601 |
602 iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI ); |
602 iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI ); |
603 |
603 |
604 #else //RD_MULTIPLE_DRIVE |
604 #else //RD_MULTIPLE_DRIVE |
605 |
605 |
606 tempPath.Format( KRightsDir, (TUint)driveLetter ); |
606 tempPath.Format( KRightsDir, (TUint)driveLetter ); |
607 |
607 |
608 iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI ); |
608 iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI ); |
609 |
609 |
610 #endif |
610 #endif |
611 |
611 |
612 key.FillZ(); |
612 key.FillZ(); |
613 |
613 |
614 DRMLOG( _L( "CDRMRightsServer::ConstructL: DB started." ) ); |
614 DRMLOG( _L( "CDRMRightsServer::ConstructL: DB started." ) ); |
615 |
615 |
616 DRMLOG( _L( "CDRMRightsServer::ConstructL: Starting Notifier ." ) ); |
616 DRMLOG( _L( "CDRMRightsServer::ConstructL: Starting Notifier ." ) ); |
617 |
617 |
618 User::LeaveIfError( semaphore.CreateGlobal( KDRMEngCommonSemaphore, 0 ) ); |
618 User::LeaveIfError( semaphore.CreateGlobal( KDRMEngCommonSemaphore, 0 ) ); |
619 CleanupClosePushL( semaphore ); |
619 CleanupClosePushL( semaphore ); |
620 |
620 |
621 StartThreadL( DRMNotifier::KServerName, StartupNotifier, semaphore ); |
621 StartThreadL( DRMNotifier::KServerName, StartupNotifier, semaphore ); |
622 DRMLOG( _L( "CDRMRightsServer::ConstructL: Notifier thread created." ) ); |
622 DRMLOG( _L( "CDRMRightsServer::ConstructL: Notifier thread created." ) ); |
623 |
623 |
624 StartThreadL( Roap::KServerName, StartupRoapStorage, semaphore ); |
624 StartThreadL( Roap::KServerName, StartupRoapStorage, semaphore ); |
625 DRMLOG( _L( "CDRMRightsServer::ConstructL: ROAP thread created." ) ); |
625 DRMLOG( _L( "CDRMRightsServer::ConstructL: ROAP thread created." ) ); |
626 |
626 |
627 #ifdef __DRM_CLOCK |
627 #ifdef __DRM_CLOCK |
628 StartThreadL( DRMClock::KServerName, StartupClock, semaphore ); |
628 StartThreadL( DRMClock::KServerName, StartupClock, semaphore ); |
629 DRMLOG( _L( "CDRMRightsServer::ConstructL: clock thread created." ) ); |
629 DRMLOG( _L( "CDRMRightsServer::ConstructL: clock thread created." ) ); |
630 #endif |
630 #endif |
631 |
631 |
632 CleanupStack::PopAndDestroy(); // semaphore |
632 CleanupStack::PopAndDestroy(); // semaphore |
633 |
633 |
634 iNotifier = CDRMNotifier::NewL(); |
634 iNotifier = CDRMNotifier::NewL(); |
635 |
635 |
636 iCache.Set( iFs ); |
636 iCache.Set( iFs ); |
637 |
637 |
638 #ifndef RD_MULTIPLE_DRIVE |
638 #ifndef RD_MULTIPLE_DRIVE |
639 |
639 |
640 iCache.InitL( KTimedReplayCacheFile, KPlainReplayCacheFile ); |
640 iCache.InitL( KTimedReplayCacheFile, KPlainReplayCacheFile ); |
641 |
641 |
642 #ifdef RD_DRM_METERING |
642 #ifdef RD_DRM_METERING |
643 iMeteringDb.Set( iFs ); |
643 iMeteringDb.Set( iFs ); |
644 iMeteringDb.InitL( KMeteringDataBaseFile ); |
644 iMeteringDb.InitL( KMeteringDataBaseFile ); |
645 #endif |
645 #endif |
646 |
646 |
647 #else //RD_MULTIPLE_DRIVE |
647 #else //RD_MULTIPLE_DRIVE |
648 |
648 |
649 tempPath.Format( KTimedReplayCacheFile, (TUint)driveLetter ); |
649 tempPath.Format( KTimedReplayCacheFile, (TUint)driveLetter ); |
650 tempPath2.Format( KPlainReplayCacheFile, (TUint)driveLetter ); |
650 tempPath2.Format( KPlainReplayCacheFile, (TUint)driveLetter ); |
651 |
651 |
652 iCache.InitL( tempPath, tempPath2 ); |
652 iCache.InitL( tempPath, tempPath2 ); |
653 |
653 |
654 #ifdef RD_DRM_METERING |
654 #ifdef RD_DRM_METERING |
655 |
655 |
656 tempPath.Format( KMeteringDataBaseFile, (TUint)driveLetter ); |
656 tempPath.Format( KMeteringDataBaseFile, (TUint)driveLetter ); |
657 |
657 |
658 iMeteringDb.Set( iFs ); |
658 iMeteringDb.Set( iFs ); |
659 iMeteringDb.InitL( tempPath ); |
659 iMeteringDb.InitL( tempPath ); |
660 |
660 |
661 #endif |
661 #endif |
662 |
662 |
663 #endif |
663 #endif |
664 |
664 |
665 User::LeaveIfError( iClock.Connect() ); |
665 User::LeaveIfError( iClock.Connect() ); |
666 |
666 |
667 // xoma header list creation |
667 // xoma header list creation |
668 iXOmaHeaders = new (ELeave) RPointerArray< CDRMXOma >(); |
668 iXOmaHeaders = new (ELeave) RPointerArray< CDRMXOma >(); |
669 |
669 |
670 // p/s |
670 // p/s |
671 iBackupObserver = CDRMBackupObserver::NewL( *(const_cast<CDRMRightsServer*>(this))); |
671 iBackupObserver = CDRMBackupObserver::NewL( *(const_cast<CDRMRightsServer*>(this))); |
672 iBackupObserver->Start(); |
672 iBackupObserver->Start(); |
673 |
673 |
674 #ifdef USE_RO_IMPORT |
674 #ifdef USE_RO_IMPORT |
675 // Import any OMA DRM 1.0 RO in the import directory, ignore all errors (except |
675 // Import any OMA DRM 1.0 RO in the import directory, ignore all errors (except |
676 // when checking the default removable mass storage) |
676 // when checking the default removable mass storage) |
677 TInt r = KErrNone; |
677 TInt r = KErrNone; |
678 |
678 |
679 #ifndef RD_MULTIPLE_DRIVE |
679 #ifndef RD_MULTIPLE_DRIVE |
680 |
680 |
681 TRAP( r, ImportRightsObjectsL( KInternalImportDir ) ); |
681 TRAP( r, ImportRightsObjectsL( KInternalImportDir ) ); |
682 TRAP( r, ImportRightsObjectsL( KUserDiskImportDir ) ); |
682 TRAP( r, ImportRightsObjectsL( KUserDiskImportDir ) ); |
683 |
683 |
684 #else //RD_MULTIPLE_DRIVE |
684 #else //RD_MULTIPLE_DRIVE |
685 |
685 |
686 tempPath.Format( KInternalImportDir, (TUint)driveLetter ); |
686 tempPath.Format( KInternalImportDir, (TUint)driveLetter ); |
687 |
687 |
688 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber ); |
688 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber ); |
689 iFs.DriveToChar( driveNumber, driveLetter ); |
689 iFs.DriveToChar( driveNumber, driveLetter ); |
690 |
690 |
691 // Default mass storage is usually eMMC |
691 // Default mass storage is usually eMMC |
692 tempPath2.Format( KUserDiskImportDir, (TUint)driveLetter ); |
692 tempPath2.Format( KUserDiskImportDir, (TUint)driveLetter ); |
693 |
693 |
694 // Find out if a removable mass storage also exists |
694 // Find out if a removable mass storage also exists |
695 r = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNumber ); |
695 r = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNumber ); |
696 iFs.DriveToChar( driveNumber, driveLetterRemovable ); |
696 iFs.DriveToChar( driveNumber, driveLetterRemovable ); |
697 |
697 |
698 // Import is not needed from the default removable mass storage drive if the drive |
698 // Import is not needed from the default removable mass storage drive if the drive |
699 // letter of the default mass storage and the default removable mass storage are |
699 // letter of the default mass storage and the default removable mass storage are |
700 // the same or the removable mass storage is not supported |
700 // the same or the removable mass storage is not supported |
701 if ( ( driveLetter != driveLetterRemovable ) && ( r == KErrNone ) ) |
701 if ( ( driveLetter != driveLetterRemovable ) && ( r == KErrNone ) ) |
702 { |
702 { |
703 tempRemovablePath.Format( KUserRemovableDiskImportDir, (TUint)driveLetterRemovable ); |
703 tempRemovablePath.Format( KUserRemovableDiskImportDir, (TUint)driveLetterRemovable ); |
704 TRAP( r, ImportRightsObjectsL( tempRemovablePath ) ); |
704 TRAP( r, ImportRightsObjectsL( tempRemovablePath ) ); |
705 } |
705 } |
706 |
706 |
707 TRAP( r, ImportRightsObjectsL( tempPath ) ); |
707 TRAP( r, ImportRightsObjectsL( tempPath ) ); |
708 TRAP( r, ImportRightsObjectsL( tempPath2 ) ); |
708 TRAP( r, ImportRightsObjectsL( tempPath2 ) ); |
709 |
709 |
710 #endif |
710 #endif |
711 |
711 |
712 #endif |
712 #endif |
713 |
713 |
714 // Add the server to the scheduler. |
714 // Add the server to the scheduler. |
715 StartL( DRMEngine::KServerName ); |
715 StartL( DRMEngine::KServerName ); |
716 |
716 |
717 // Start watching our RDB |
717 // Start watching our RDB |
718 iDbWatcher = CDbWatcher::NewL( *this ); |
718 iDbWatcher = CDbWatcher::NewL( *this ); |
719 iDbWatcher->StartWatching(); |
719 iDbWatcher->StartWatching(); |
720 |
720 |
721 // Start watching the helper server |
721 // Start watching the helper server |
722 iProcWatcher = CProcWatcher::NewL( *this, _L( "*DcfRepSrv*" ), _L( "DcfRepSrv" ) ); |
722 iProcWatcher = CProcWatcher::NewL( *this, _L( "*DcfRepSrv*" ), _L( "DcfRepSrv" ) ); |
723 iProcWatcher->StartWatching(); |
723 iProcWatcher->StartWatching(); |
724 |
724 |
725 // Ready to watch |
725 // Ready to watch |
726 iArmed = ETrue; |
726 iArmed = ETrue; |
727 |
727 |
728 __UHEAP_MARK; |
728 __UHEAP_MARK; |
729 TRAP( r, FeatureManager::InitializeLibL() ); |
729 TRAP( r, FeatureManager::InitializeLibL() ); |
730 if( !r && FeatureManager::FeatureSupported( KFeatureIdWindowsMediaDrm ) ) |
730 if( !r && FeatureManager::FeatureSupported( KFeatureIdWindowsMediaDrm ) ) |
731 { |
731 { |
732 static const TInt KGateOrdinal = 1; |
732 static const TInt KGateOrdinal = 1; |
733 RLibrary library; |
733 RLibrary library; |
734 r = library.Load( KWmDrmClientWrapperName ); |
734 r = library.Load( KWmDrmClientWrapperName ); |
735 if( !r ) |
735 if( !r ) |
746 } |
746 } |
747 delete wrapper; |
747 delete wrapper; |
748 __UHEAP_MARKEND; |
748 __UHEAP_MARKEND; |
749 } |
749 } |
750 } |
750 } |
751 library.Close(); |
751 library.Close(); |
752 } |
752 } |
753 FeatureManager::UnInitializeLib(); |
753 FeatureManager::UnInitializeLib(); |
754 __UHEAP_MARKEND; |
754 __UHEAP_MARKEND; |
755 } |
755 } |
756 |
756 |
757 // ----------------------------------------------------------------------------- |
757 // ----------------------------------------------------------------------------- |
758 // CDRMRightsServer::StartThreadL |
758 // CDRMRightsServer::StartThreadL |
759 // Start a new thread. |
759 // Start a new thread. |
760 // ----------------------------------------------------------------------------- |
760 // ----------------------------------------------------------------------------- |
761 void CDRMRightsServer::StartThreadL( const TDesC& aThreadName, |
761 void CDRMRightsServer::StartThreadL( const TDesC& aThreadName, |
762 TThreadFunction aFunc, |
762 TThreadFunction aFunc, |
763 RSemaphore& aSemaphore ) |
763 RSemaphore& aSemaphore ) |
764 { |
764 { |
765 RThread thread; |
765 RThread thread; |
766 |
766 |
767 User::LeaveIfError( |
767 User::LeaveIfError( |
768 thread.Create( aThreadName, |
768 thread.Create( aThreadName, |
769 aFunc, |
769 aFunc, |
770 KDefaultStackSize, |
770 KDefaultStackSize, |
771 KMinHeapSize, |
771 KMinHeapSize, |
772 KMaxHeapsize, |
772 KMaxHeapsize, |
773 NULL ) ); |
773 NULL ) ); |
774 |
774 |
775 thread.Resume(); |
775 thread.Resume(); |
776 |
776 |
777 aSemaphore.Wait(); |
777 aSemaphore.Wait(); |
778 |
778 |
779 thread.Close(); |
779 thread.Close(); |
780 } |
780 } |
781 |
781 |
782 // ----------------------------------------------------------------------------- |
782 // ----------------------------------------------------------------------------- |
783 // CDRMRightsServer::GetDbKeyL |
783 // CDRMRightsServer::GetDbKeyL |
784 // Fetches the rights database key from Wallet or uses a constant |
784 // Fetches the rights database key from Wallet or uses a constant |
785 // key if Wallet is not supported. |
785 // key if Wallet is not supported. |
786 // ----------------------------------------------------------------------------- |
786 // ----------------------------------------------------------------------------- |
787 // |
787 // |
788 void CDRMRightsServer::GetDbKeyL( TDRMKey& aKey ) |
788 void CDRMRightsServer::GetDbKeyL( TDRMKey& aKey ) |
789 { |
789 { |
790 TInt r = KErrNone; |
790 TInt r = KErrNone; |
791 |
791 |
792 DRMLOG( _L( "CDRMRightsServer::GetDbKey" ) ); |
792 DRMLOG( _L( "CDRMRightsServer::GetDbKey" ) ); |
793 MDrmKeyStorage* storage = DrmKeyStorageNewL(); |
793 MDrmKeyStorage* storage = DrmKeyStorageNewL(); |
794 TRAP( r, storage->GetDeviceSpecificKeyL( aKey ) ); |
794 TRAP( r, storage->GetDeviceSpecificKeyL( aKey ) ); |
795 delete storage; |
795 delete storage; |
796 User::LeaveIfError( r ); |
796 User::LeaveIfError( r ); |
799 // ----------------------------------------------------------------------------- |
799 // ----------------------------------------------------------------------------- |
800 // CDRMRightsServer::GenerateKeyL |
800 // CDRMRightsServer::GenerateKeyL |
801 // Generates the actual key based on the given key seed. |
801 // Generates the actual key based on the given key seed. |
802 // ----------------------------------------------------------------------------- |
802 // ----------------------------------------------------------------------------- |
803 // |
803 // |
804 void CDRMRightsServer::GenerateKeyL( HBufC*& aKeySeed, |
804 void CDRMRightsServer::GenerateKeyL( HBufC*& aKeySeed, |
805 TDRMKey& aKey ) const |
805 TDRMKey& aKey ) const |
806 { |
806 { |
807 __ASSERT_ALWAYS( aKeySeed->Size() >= KDRMKeyLength, |
807 __ASSERT_ALWAYS( aKeySeed->Size() >= KDRMKeyLength, |
808 User::Leave( KErrUnderflow ) ); |
808 User::Leave( KErrUnderflow ) ); |
809 |
809 |
810 TPtrC8 key( reinterpret_cast< TUint8* >( const_cast< TUint16* >( aKeySeed->Ptr() ) ), |
810 TPtrC8 key( reinterpret_cast< TUint8* >( const_cast< TUint16* >( aKeySeed->Ptr() ) ), |
811 KDRMKeyLength ); |
811 KDRMKeyLength ); |
812 |
812 |
813 aKey = key; |
813 aKey = key; |
814 } |
814 } |
815 |
815 |
816 |
816 |
817 // ----------------------------------------------------------------------------- |
817 // ----------------------------------------------------------------------------- |
818 // CDRMRightsServer::XOmaHeaders() |
818 // CDRMRightsServer::XOmaHeaders() |
819 // return the pointer of the X-Oma headers list |
819 // return the pointer of the X-Oma headers list |
820 // ----------------------------------------------------------------------------- |
820 // ----------------------------------------------------------------------------- |
821 // |
821 // |
822 RPointerArray< CDRMXOma >& CDRMRightsServer::XOmaHeaders( void ) |
822 RPointerArray< CDRMXOma >& CDRMRightsServer::XOmaHeaders( void ) |
823 { |
823 { |
824 return *iXOmaHeaders; |
824 return *iXOmaHeaders; |
825 } |
825 } |
826 |
826 |
827 |
827 |
828 |
828 |
829 // ----------------------------------------------------------------------------- |
829 // ----------------------------------------------------------------------------- |
830 // CDRMRightsServer::GetIMEIL |
830 // CDRMRightsServer::GetIMEIL |
834 { |
834 { |
835 if ( iIMEI ) |
835 if ( iIMEI ) |
836 { |
836 { |
837 return *iIMEI; |
837 return *iIMEI; |
838 } |
838 } |
839 |
839 |
840 #ifdef DRM_USE_SERIALNUMBER_URI |
840 #ifdef DRM_USE_SERIALNUMBER_URI |
841 TInt error( KErrNone ); |
841 TInt error( KErrNone ); |
842 TInt count( 0 ); |
842 TInt count( 0 ); |
843 TInt count2( 0 ); |
843 TInt count2( 0 ); |
844 TUint32 caps( 0 ); |
844 TUint32 caps( 0 ); |
845 TBool found (EFalse); |
845 TBool found (EFalse); |
846 |
846 |
847 RTelServer etelServer; |
847 RTelServer etelServer; |
848 RMobilePhone phone; |
848 RMobilePhone phone; |
849 |
849 |
850 TUint KMaxImeiTries = 5; |
850 TUint KMaxImeiTries = 5; |
851 |
851 |
852 for ( TUint8 i = 0; i < KMaxImeiTries; ++i ) |
852 for ( TUint8 i = 0; i < KMaxImeiTries; ++i ) |
853 { |
853 { |
854 error = etelServer.Connect(); |
854 error = etelServer.Connect(); |
855 if ( error ) |
855 if ( error ) |
856 { |
856 { |
857 User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) ); |
857 User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) ); |
858 } |
858 } |
859 else |
859 else |
860 { |
860 { |
861 break; |
861 break; |
862 } |
862 } |
863 } |
863 } |
864 |
864 |
865 User::LeaveIfError( error ); |
865 User::LeaveIfError( error ); |
866 CleanupClosePushL( etelServer ); |
866 CleanupClosePushL( etelServer ); |
867 |
867 |
868 User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
868 User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
869 |
869 |
870 TUnloadModule unload; |
870 TUnloadModule unload; |
871 unload.iServer = &etelServer; |
871 unload.iServer = &etelServer; |
872 unload.iName = &KMmTsyModuleName; |
872 unload.iName = &KMmTsyModuleName; |
873 |
873 |
874 TCleanupItem item( DoUnloadPhoneModule, &unload ); |
874 TCleanupItem item( DoUnloadPhoneModule, &unload ); |
875 CleanupStack::PushL( item ); |
875 CleanupStack::PushL( item ); |
876 User::LeaveIfError( etelServer.EnumeratePhones( count ) ); |
876 User::LeaveIfError( etelServer.EnumeratePhones( count ) ); |
877 |
877 |
878 for ( count2 = 0; count2 < count && !found; ++count2 ) |
878 for ( count2 = 0; count2 < count && !found; ++count2 ) |
879 { |
879 { |
880 RTelServer::TPhoneInfo phoneInfo; |
880 RTelServer::TPhoneInfo phoneInfo; |
881 User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) ); |
881 User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) ); |
882 |
882 |
883 if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 ) |
883 if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 ) |
884 { |
884 { |
885 User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) ); |
885 User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) ); |
886 User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) ); |
886 User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) ); |
887 CleanupClosePushL( phone ); |
887 CleanupClosePushL( phone ); |
888 found = ETrue; |
888 found = ETrue; |
892 if ( !found ) |
892 if ( !found ) |
893 { |
893 { |
894 // Not found. |
894 // Not found. |
895 User::Leave( KErrNotFound ); |
895 User::Leave( KErrNotFound ); |
896 } |
896 } |
897 |
897 |
898 User::LeaveIfError( phone.GetIdentityCaps( caps ) ); |
898 User::LeaveIfError( phone.GetIdentityCaps( caps ) ); |
899 if ( caps & RMobilePhone::KCapsGetSerialNumber ) |
899 if ( caps & RMobilePhone::KCapsGetSerialNumber ) |
900 { |
900 { |
901 RMobilePhone::TMobilePhoneIdentityV1 id; |
901 RMobilePhone::TMobilePhoneIdentityV1 id; |
902 TRequestStatus status; |
902 TRequestStatus status; |
903 |
903 |
904 phone.GetPhoneId( status, id ); |
904 phone.GetPhoneId( status, id ); |
905 |
905 |
906 User::WaitForRequest( status ); |
906 User::WaitForRequest( status ); |
907 |
907 |
908 User::LeaveIfError( status.Int() ); |
908 User::LeaveIfError( status.Int() ); |
909 |
909 |
910 iIMEI = id.iSerialNumber.AllocL(); |
910 iIMEI = id.iSerialNumber.AllocL(); |
911 |
911 |
912 CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer |
912 CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer |
913 |
913 |
914 HBufC8* buf = HBufC8::NewL( iIMEI->Size() ); |
914 HBufC8* buf = HBufC8::NewL( iIMEI->Size() ); |
915 TPtr8 ptr( buf->Des() ); |
915 TPtr8 ptr( buf->Des() ); |
916 ptr.Copy( *iIMEI ); |
916 ptr.Copy( *iIMEI ); |
917 |
917 |
918 DRMLOG(_L("IMEI:")); |
918 DRMLOG(_L("IMEI:")); |
919 DRMLOGHEX(ptr); |
919 DRMLOGHEX(ptr); |
920 delete buf; |
920 delete buf; |
921 |
921 |
922 return *iIMEI; |
922 return *iIMEI; |
923 } |
923 } |
924 |
924 |
925 User::Leave( KErrNotFound ); |
925 User::Leave( KErrNotFound ); |
926 |
926 |
927 // Never happens... |
927 // Never happens... |
928 return *iIMEI; |
928 return *iIMEI; |
929 |
929 |
930 #else |
930 #else |
931 _LIT( KDefaultSerialNumber, "123456789123456789" ); |
931 _LIT( KDefaultSerialNumber, "123456789123456789" ); |
932 iIMEI = KDefaultSerialNumber().AllocL(); |
932 iIMEI = KDefaultSerialNumber().AllocL(); |
933 |
933 |
934 return *iIMEI; |
934 return *iIMEI; |
935 #endif |
935 #endif |
936 } |
936 } |
937 |
937 |
938 // ----------------------------------------------------------------------------- |
938 // ----------------------------------------------------------------------------- |
939 // CDRMRightsServer::GetIMSIL |
939 // CDRMRightsServer::GetIMSIL |
940 // ----------------------------------------------------------------------------- |
940 // ----------------------------------------------------------------------------- |
941 // |
941 // |
942 const CDRMPointerArray<HBufC8>& CDRMRightsServer::GetIMSIL() |
942 const CDRMPointerArray<HBufC8>& CDRMRightsServer::GetIMSIL() |
943 { |
943 { |
944 |
944 |
945 if ( !iGetImsi ) |
945 if ( !iGetImsi ) |
946 { |
946 { |
947 return *iIMSI; |
947 return *iIMSI; |
948 } |
948 } |
949 |
949 |
950 #ifndef __WINS__ |
950 #ifndef __WINS__ |
951 TInt error( KErrNone ); |
951 TInt error( KErrNone ); |
952 TInt count( 0 ); |
952 TInt count( 0 ); |
953 TInt count2( 0 ); |
953 TInt count2( 0 ); |
954 TUint32 caps( 0 ); |
954 TUint32 caps( 0 ); |
955 TBool found (EFalse); |
955 TBool found (EFalse); |
956 HBufC8* imsi = NULL; |
956 HBufC8* imsi = NULL; |
957 HBufC8* imsiNumber = NULL; |
957 HBufC8* imsiNumber = NULL; |
958 |
958 |
959 RTelServer etelServer; |
959 RTelServer etelServer; |
960 RMobilePhone phone; |
960 RMobilePhone phone; |
961 |
961 |
962 TUint KMaxImeiTries = 5; |
962 TUint KMaxImeiTries = 5; |
963 for ( TUint8 i = 0; i < KMaxImeiTries; ++i ) |
963 for ( TUint8 i = 0; i < KMaxImeiTries; ++i ) |
964 { |
964 { |
965 error = etelServer.Connect(); |
965 error = etelServer.Connect(); |
966 if ( error ) |
966 if ( error ) |
967 { |
967 { |
968 User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) ); |
968 User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) ); |
969 } |
969 } |
970 else |
970 else |
971 { |
971 { |
972 break; |
972 break; |
973 } |
973 } |
974 } |
974 } |
975 |
975 |
976 User::LeaveIfError( error ); |
976 User::LeaveIfError( error ); |
977 CleanupClosePushL( etelServer ); |
977 CleanupClosePushL( etelServer ); |
978 User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
978 User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
979 |
979 |
980 TUnloadModule unload; |
980 TUnloadModule unload; |
981 unload.iServer = &etelServer; |
981 unload.iServer = &etelServer; |
982 unload.iName = &KMmTsyModuleName; |
982 unload.iName = &KMmTsyModuleName; |
983 |
983 |
984 TCleanupItem item( DoUnloadPhoneModule, &unload ); |
984 TCleanupItem item( DoUnloadPhoneModule, &unload ); |
985 CleanupStack::PushL( item ); |
985 CleanupStack::PushL( item ); |
986 |
986 |
987 User::LeaveIfError( etelServer.EnumeratePhones( count ) ); |
987 User::LeaveIfError( etelServer.EnumeratePhones( count ) ); |
988 |
988 |
989 for ( count2 = 0; count2 < count && !found; ++count2 ) |
989 for ( count2 = 0; count2 < count && !found; ++count2 ) |
990 { |
990 { |
991 RTelServer::TPhoneInfo phoneInfo; |
991 RTelServer::TPhoneInfo phoneInfo; |
992 User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) ); |
992 User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) ); |
993 |
993 |
994 if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 ) |
994 if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 ) |
995 { |
995 { |
996 User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) ); |
996 User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) ); |
997 User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) ); |
997 User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) ); |
998 CleanupClosePushL( phone ); |
998 CleanupClosePushL( phone ); |
999 found = ETrue; |
999 found = ETrue; |
1003 if ( !found ) |
1003 if ( !found ) |
1004 { |
1004 { |
1005 // Not found. |
1005 // Not found. |
1006 User::Leave( KErrNotFound ); |
1006 User::Leave( KErrNotFound ); |
1007 } |
1007 } |
1008 |
1008 |
1009 |
1009 |
1010 User::LeaveIfError( phone.GetIdentityCaps( caps ) ); |
1010 User::LeaveIfError( phone.GetIdentityCaps( caps ) ); |
1011 |
1011 |
1012 if( caps & RMobilePhone::KCapsGetSubscriberId ) |
1012 if( caps & RMobilePhone::KCapsGetSubscriberId ) |
1013 { |
1013 { |
1014 RMobilePhone::TMobilePhoneSubscriberId imsiId; |
1014 RMobilePhone::TMobilePhoneSubscriberId imsiId; |
1015 TRequestStatus status; |
1015 TRequestStatus status; |
1016 |
1016 |
1017 phone.GetSubscriberId( status, imsiId ); |
1017 phone.GetSubscriberId( status, imsiId ); |
1018 |
1018 |
1019 User::WaitForRequest( status ); |
1019 User::WaitForRequest( status ); |
1020 |
1020 |
1021 if( ! status.Int() ) |
1021 if( ! status.Int() ) |
1022 { |
1022 { |
1023 imsi = HBufC8::NewMaxLC( imsiId.Length() + KImsiId().Size() ); |
1023 imsi = HBufC8::NewMaxLC( imsiId.Length() + KImsiId().Size() ); |
1024 TPtr8 imsiPtr(const_cast<TUint8*>(imsi->Ptr()), 0, imsi->Size()); |
1024 TPtr8 imsiPtr(const_cast<TUint8*>(imsi->Ptr()), 0, imsi->Size()); |
1025 |
1025 |
1026 imsiNumber = CnvUtfConverter::ConvertFromUnicodeToUtf8L( imsiId ); |
1026 imsiNumber = CnvUtfConverter::ConvertFromUnicodeToUtf8L( imsiId ); |
1027 CleanupStack::PushL( imsiNumber ); |
1027 CleanupStack::PushL( imsiNumber ); |
1028 |
1028 |
1029 imsiPtr.Copy( KImsiId() ); |
1029 imsiPtr.Copy( KImsiId() ); |
1030 imsiPtr.Append( *imsiNumber ); |
1030 imsiPtr.Append( *imsiNumber ); |
1031 CleanupStack::PopAndDestroy(); // imsiNumber |
1031 CleanupStack::PopAndDestroy(); // imsiNumber |
1032 } |
1032 } |
1033 else |
1033 else |
1034 { |
1034 { |
1035 imsi = NULL; |
1035 imsi = NULL; |
1036 } |
1036 } |
1037 } |
1037 } |
1038 else |
1038 else |
1039 { |
1039 { |
1040 imsi = NULL; |
1040 imsi = NULL; |
1041 } |
1041 } |
1042 |
1042 |
1043 |
1043 |
1044 // Clean up whatever is in there |
1044 // Clean up whatever is in there |
1045 iIMSI->ResetAndDestroy(); |
1045 iIMSI->ResetAndDestroy(); |
1046 |
1046 |
1047 if( imsi ) |
1047 if( imsi ) |
1048 { |
1048 { |
1049 // if we got it we wont try again |
1049 // if we got it we wont try again |
1050 iIMSI->AppendL( imsi ); |
1050 iIMSI->AppendL( imsi ); |
1051 CleanupStack::Pop(); // imsi |
1051 CleanupStack::Pop(); // imsi |
1052 iGetImsi = EFalse; |
1052 iGetImsi = EFalse; |
1053 } |
1053 } |
1054 |
1054 |
1055 // Check for possible extra IMSI individual constraints |
1055 // Check for possible extra IMSI individual constraints |
1056 AppendExtendedIndividualConstraintsL(&phone); |
1056 AppendExtendedIndividualConstraintsL(&phone); |
1057 |
1057 |
1058 CleanupStack::PopAndDestroy(); // phone |
1058 CleanupStack::PopAndDestroy(); // phone |
1059 CleanupStack::PopAndDestroy(); // cleanup item |
1059 CleanupStack::PopAndDestroy(); // cleanup item |
1060 CleanupStack::PopAndDestroy(); // etel server |
1060 CleanupStack::PopAndDestroy(); // etel server |
1061 |
1061 |
1062 return *iIMSI; |
1062 return *iIMSI; |
1063 |
1063 |
1064 #else |
1064 #else |
1065 HBufC8* imsi = NULL; |
1065 HBufC8* imsi = NULL; |
1066 |
1066 |
1067 if( iGetImsi ) |
1067 if( iGetImsi ) |
1068 { |
1068 { |
1069 iGetImsi = EFalse; |
1069 iGetImsi = EFalse; |
1070 _LIT8( KDefaultSerialNumber, "IMSI:123456789123456789" ); |
1070 _LIT8( KDefaultSerialNumber, "IMSI:123456789123456789" ); |
1071 imsi = KDefaultSerialNumber().AllocLC(); |
1071 imsi = KDefaultSerialNumber().AllocLC(); |
1072 iIMSI->AppendL( imsi ); |
1072 iIMSI->AppendL( imsi ); |
1073 CleanupStack::Pop(); |
1073 CleanupStack::Pop(); |
1074 AppendExtendedIndividualConstraintsL(); |
1074 AppendExtendedIndividualConstraintsL(); |
1075 } |
1075 } |
1076 |
1076 |
1077 |
1077 |
1078 return *iIMSI; |
1078 return *iIMSI; |
1079 #endif // __WINS__ |
1079 #endif // __WINS__ |
1080 } |
1080 } |
1081 |
1081 |
1082 // ----------------------------------------------------------------------------- |
1082 // ----------------------------------------------------------------------------- |
1083 // CDRMRightsServer::AppendExtendedIndividualConstraintsL |
1083 // CDRMRightsServer::AppendExtendedIndividualConstraintsL |
1084 // If the extension DLL exists it is loaded and used to obtain additional |
1084 // If the extension DLL exists it is loaded and used to obtain additional |
1085 // valid individual constraints |
1085 // valid individual constraints |
1086 // ----------------------------------------------------------------------------- |
1086 // ----------------------------------------------------------------------------- |
1087 void CDRMRightsServer::AppendExtendedIndividualConstraintsL(RMobilePhone* aMobilePhone) |
1087 void CDRMRightsServer::AppendExtendedIndividualConstraintsL(RMobilePhone* aMobilePhone) |
1088 { |
1088 { |
1089 // Load the externsion DLL |
1089 // Load the externsion DLL |
1090 RLibrary lib; |
1090 RLibrary lib; |
1091 |
1091 |
1092 #ifndef RD_MULTIPLE_DRIVE |
1092 #ifndef RD_MULTIPLE_DRIVE |
1093 |
1093 |
1094 if (lib.LoadRomLibrary(KDRMIndividualConstraintExtensionDll,KNullDesC)==KErrNone) |
1094 if (lib.LoadRomLibrary(KDRMIndividualConstraintExtensionDll,KNullDesC)==KErrNone) |
1095 |
1095 |
1096 #else //RD_MULTIPLE_DRIVE |
1096 #else //RD_MULTIPLE_DRIVE |
1097 |
1097 |
1098 TInt driveNumber( -1 ); |
1098 TInt driveNumber( -1 ); |
1099 TChar driveLetter; |
1099 TChar driveLetter; |
1100 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber ); |
1100 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber ); |
1101 iFs.DriveToChar( driveNumber, driveLetter ); |
1101 iFs.DriveToChar( driveNumber, driveLetter ); |
1102 |
1102 |
1103 TFileName individualConstraindExtensionDll; |
1103 TFileName individualConstraindExtensionDll; |
1104 individualConstraindExtensionDll.Format( |
1104 individualConstraindExtensionDll.Format( |
1105 KIndividualConstraintExtensionDll, (TUint)driveLetter ); |
1105 KIndividualConstraintExtensionDll, (TUint)driveLetter ); |
1106 |
1106 |
1107 if ( lib.LoadRomLibrary( individualConstraindExtensionDll, KNullDesC ) == KErrNone ) |
1107 if ( lib.LoadRomLibrary( individualConstraindExtensionDll, KNullDesC ) == KErrNone ) |
1108 |
1108 |
1109 #endif |
1109 #endif |
1110 |
1110 |
1111 { |
1111 { |
1112 CleanupClosePushL(lib); |
1112 CleanupClosePushL(lib); |
1113 |
1113 |
1114 // Get first exported ordinal - factory method returning |
1114 // Get first exported ordinal - factory method returning |
1115 // MDRMIndividualConstraintExtension* |
1115 // MDRMIndividualConstraintExtension* |
1116 TLibraryFunction factory = lib.Lookup(1); |
1116 TLibraryFunction factory = lib.Lookup(1); |
1117 |
1117 |
1118 if (factory) |
1118 if (factory) |
1119 { |
1119 { |
1120 // Instantiate object |
1120 // Instantiate object |
1121 MDRMIndividualConstraintExtension* extendedConstraints = |
1121 MDRMIndividualConstraintExtension* extendedConstraints = |
1122 reinterpret_cast<MDRMIndividualConstraintExtension*>(factory()); |
1122 reinterpret_cast<MDRMIndividualConstraintExtension*>(factory()); |
1123 |
1123 |
1124 if (extendedConstraints) |
1124 if (extendedConstraints) |
1125 { |
1125 { |
1126 CleanupStack::PushL(TCleanupItem(Release,extendedConstraints)); |
1126 CleanupStack::PushL(TCleanupItem(Release,extendedConstraints)); |
1127 extendedConstraints->AppendConstraintsL(*iIMSI,aMobilePhone); |
1127 extendedConstraints->AppendConstraintsL(*iIMSI,aMobilePhone); |
1128 CleanupStack::PopAndDestroy(extendedConstraints); //calls Release |
1128 CleanupStack::PopAndDestroy(extendedConstraints); //calls Release |
1129 } |
1129 } |
1130 } |
1130 } |
1131 |
1131 |
1132 // unload library |
1132 // unload library |
1133 CleanupStack::PopAndDestroy(&lib); //close |
1133 CleanupStack::PopAndDestroy(&lib); //close |
1150 // ----------------------------------------------------------------------------- |
1150 // ----------------------------------------------------------------------------- |
1151 // |
1151 // |
1152 |
1152 |
1153 void CDRMRightsServer::HandleBackupEventL( TInt aBackupEvent ) |
1153 void CDRMRightsServer::HandleBackupEventL( TInt aBackupEvent ) |
1154 { |
1154 { |
1155 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::BackupCalled\n\r")); |
1155 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::BackupCalled\n\r")); |
1156 |
1156 |
1157 //conn::TBURPartType eventType; |
1157 //conn::TBURPartType eventType; |
1158 //conn::TBackupIncType incType; |
1158 //conn::TBackupIncType incType; |
1159 TDriveList aDriveList; |
1159 TDriveList aDriveList; |
1160 |
1160 |
1161 //RFileLogger::WriteFormat(KLogDir, KLogName, EFileLoggingModeAppend, _L8("backupevent: %d"), aBackupEvent); |
1161 //RFileLogger::WriteFormat(KLogDir, KLogName, EFileLoggingModeAppend, _L8("backupevent: %d"), aBackupEvent); |
1162 |
1162 |
1163 // If there is no operation going or state is normal |
1163 // If there is no operation going or state is normal |
1164 // Delete the client and handler |
1164 // Delete the client and handler |
1165 |
1165 |
1166 if( aBackupEvent == conn::EBURUnset || |
1166 if( aBackupEvent == conn::EBURUnset || |
1167 aBackupEvent & conn::EBURNormal ) |
1167 aBackupEvent & conn::EBURNormal ) |
1168 { |
1168 { |
1169 /* |
1169 /* |
1170 if( aBackupEvent == conn::EBURUnset ) |
1170 if( aBackupEvent == conn::EBURUnset ) |
1171 { |
1171 { |
1172 RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Unset\n\r")); |
1172 RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Unset\n\r")); |
1173 } |
1173 } |
1174 else |
1174 else |
1175 { |
1175 { |
1176 RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Normal\n\r")); |
1176 RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Normal\n\r")); |
1177 } |
1177 } |
1178 */ |
1178 */ |
1179 if( iActiveBackupClient ) |
1179 if( iActiveBackupClient ) |
1180 { |
1180 { |
1181 delete iActiveBackupClient; |
1181 delete iActiveBackupClient; |
1182 iActiveBackupClient = NULL; |
1182 iActiveBackupClient = NULL; |
1183 } |
1183 } |
1184 |
1184 |
1185 if( iBackupHandler ) |
1185 if( iBackupHandler ) |
1186 { |
1186 { |
1187 delete iBackupHandler; |
1187 delete iBackupHandler; |
1188 iBackupHandler = NULL; |
1188 iBackupHandler = NULL; |
1189 } |
1189 } |
1190 } |
1190 } |
1191 else if( aBackupEvent & conn::EBURBackupFull || |
1191 else if( aBackupEvent & conn::EBURBackupFull || |
1192 aBackupEvent & conn::EBURRestoreFull ) |
1192 aBackupEvent & conn::EBURRestoreFull ) |
1193 { |
1193 { |
1194 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Full\n\r")); |
1194 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Full\n\r")); |
1195 // ab handler |
1195 // ab handler |
1196 iBackupHandler = CDRMBackup::NewL( iDb, iFs ); |
1196 iBackupHandler = CDRMBackup::NewL( iDb, iFs ); |
1197 |
1197 |
1198 // ab client |
1198 // ab client |
1199 iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler ); |
1199 iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler ); |
1200 |
1200 |
1201 // Confirm that we have done everything if there even was anything to do |
1201 // Confirm that we have done everything if there even was anything to do |
1202 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm F \n\r")); |
1202 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm F \n\r")); |
1203 iActiveBackupClient->ConfirmReadyForBURL( KErrNone ); |
1203 iActiveBackupClient->ConfirmReadyForBURL( KErrNone ); |
1204 } |
1204 } |
1205 else if( aBackupEvent & conn::EBURBackupPartial || |
1205 else if( aBackupEvent & conn::EBURBackupPartial || |
1206 aBackupEvent & conn::EBURRestorePartial ) |
1206 aBackupEvent & conn::EBURRestorePartial ) |
1207 { |
1207 { |
1208 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Partial\n\r")); |
1208 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Partial\n\r")); |
1209 // ab handler |
1209 // ab handler |
1210 iBackupHandler = CDRMBackup::NewL( iDb, iFs ); |
1210 iBackupHandler = CDRMBackup::NewL( iDb, iFs ); |
1211 |
1211 |
1212 // ab client |
1212 // ab client |
1213 iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler ); |
1213 iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler ); |
1214 |
1214 |
1215 if( !iActiveBackupClient->DoesPartialBURAffectMeL() ) |
1215 if( !iActiveBackupClient->DoesPartialBURAffectMeL() ) |
1216 { |
1216 { |
1217 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::NotMe\n\r")); |
1217 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::NotMe\n\r")); |
1218 delete iActiveBackupClient; |
1218 delete iActiveBackupClient; |
1219 iActiveBackupClient = NULL; |
1219 iActiveBackupClient = NULL; |
1220 |
1220 |
1221 delete iBackupHandler; |
1221 delete iBackupHandler; |
1222 iBackupHandler = NULL; |
1222 iBackupHandler = NULL; |
1223 } |
1223 } |
1224 else |
1224 else |
1225 { |
1225 { |
1226 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P \n\r")); |
1226 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P \n\r")); |
1227 // Confirm that we have done everything if there even was anything to do |
1227 // Confirm that we have done everything if there even was anything to do |
1228 iActiveBackupClient->ConfirmReadyForBURL( KErrNone ); |
1228 iActiveBackupClient->ConfirmReadyForBURL( KErrNone ); |
1229 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P Done \n\r")); |
1229 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P Done \n\r")); |
1230 } |
1230 } |
1231 } |
1231 } |
1232 else |
1232 else |
1233 { |
1233 { |
1234 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Argument\n\r")); |
1234 //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Argument\n\r")); |
1235 // Unknown operation |
1235 // Unknown operation |
1236 User::Leave(KErrArgument); |
1236 User::Leave(KErrArgument); |
1237 } |
1237 } |
1238 }; |
1238 }; |
1239 |
1239 |
1240 // ----------------------------------------------------------------------------- |
1240 // ----------------------------------------------------------------------------- |
1241 // CDRMRightsServer::WatchedObjectChangedL |
1241 // CDRMRightsServer::WatchedObjectChangedL |
1242 // Handle Backup Events |
1242 // Handle Backup Events |
1243 // ----------------------------------------------------------------------------- |
1243 // ----------------------------------------------------------------------------- |
1244 // |
1244 // |
1245 void CDRMRightsServer::WatchedObjectChangedL( const TDesC& aObject ) |
1245 void CDRMRightsServer::WatchedObjectChangedL( const TDesC& aObject ) |
1246 { |
1246 { |
1247 DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL ->" ) ); |
1247 DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL ->" ) ); |
1248 DRMLOG( aObject ); |
1248 DRMLOG( aObject ); |
1249 |
1249 |
1250 if ( aObject.Left( KDirIdentifier().Length() ) == KDirIdentifier && |
1250 if ( aObject.Left( KDirIdentifier().Length() ) == KDirIdentifier && |
1251 !iDb->Updating() && iArmed ) |
1251 !iDb->Updating() && iArmed ) |
1252 { |
1252 { |
1253 #ifdef _DEBUG |
1253 #ifdef _DEBUG |
1254 DRMLOG( _L( "RDB modified by outside party (DEBUG mode, not deleting the DB)" ) ); |
1254 DRMLOG( _L( "RDB modified by outside party (DEBUG mode, not deleting the DB)" ) ); |