|
1 /* |
|
2 * Copyright (c) 2009 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: This class provides the functionalities which are needed |
|
15 * for implementing configurable OMA DRM rights storing |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE |
|
21 #include <centralrepository.h> |
|
22 #include <f32file.h> |
|
23 #include <driveinfo.h> |
|
24 #include "drmrightsstoringlocation.h" |
|
25 #include "drmstoringinternalcrkeys.h" |
|
26 #include "drmutilityinternaltypes.h" |
|
27 |
|
28 // LOCAL CONSTANTS AND MACROS |
|
29 const TInt KStringMaxSize = 1024; |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // DrmRightsStoringLocation::CheckDrmRightsStorageDriveL |
|
33 // Checks if the storing location of DRM Rights is configured in the |
|
34 // Central Repository key. |
|
35 // ---------------------------------------------------------------------------- |
|
36 EXPORT_C TBool DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( RFs &aFs, |
|
37 TDrmScheme& aDrmScheme, TChar& aDriveLetter ) |
|
38 { |
|
39 TInt err( KErrNotFound ); |
|
40 CRepository* repository( NULL ); |
|
41 TBuf<KStringMaxSize> string; |
|
42 TBool configStoringLocationFound( EFalse ); |
|
43 TInt driveNumber( -1 ); |
|
44 TInt systemDriveNumber( -1 ); |
|
45 TDriveInfo driveInfo; |
|
46 TInt loc( 0 ); |
|
47 TDriveList driveList; |
|
48 |
|
49 aDriveLetter = ' '; |
|
50 |
|
51 // Check the Central Repository key for configurable storing location of |
|
52 // the given DRM scheme |
|
53 switch( aDrmScheme ) |
|
54 { |
|
55 case EDrmSchemeOmaDrm: |
|
56 { |
|
57 break; |
|
58 } |
|
59 case EDrmSchemeWmDrm: |
|
60 { |
|
61 TRAP( err, repository = |
|
62 CRepository::NewL( KCrUidWmDrmRightsServer ) ); |
|
63 if ( !err ) |
|
64 { |
|
65 // Read the string which should contain the drive letter |
|
66 err = repository->Get( KConfigWmDrmStoringLocation, string ); |
|
67 delete repository; |
|
68 repository = NULL; |
|
69 } |
|
70 break; |
|
71 } |
|
72 default: |
|
73 { |
|
74 break; |
|
75 } |
|
76 } |
|
77 |
|
78 if ( !err ) |
|
79 { |
|
80 |
|
81 // Find out the first alphabet character of the string. It is expected |
|
82 // that it corresponds to the drive letter. |
|
83 while ( ( loc < string.Length() ) && ( !aDriveLetter.IsAlpha() ) ) |
|
84 { |
|
85 aDriveLetter = string[ loc ]; |
|
86 loc++; |
|
87 } |
|
88 |
|
89 aFs.CharToDrive( aDriveLetter, driveNumber ); |
|
90 aFs.Drive( driveInfo, driveNumber ); |
|
91 |
|
92 // Check if the drive actually exists |
|
93 User::LeaveIfError( aFs.DriveList( driveList ) ); |
|
94 |
|
95 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, systemDriveNumber ); |
|
96 |
|
97 // Configured storing location is the same as the default system drive. |
|
98 // This is not considered as an actual configuration. Use system drive also if |
|
99 // the drive for the configured storing location of rights does not exist |
|
100 if ( ( systemDriveNumber == driveNumber ) || ( !driveList[ driveNumber ] ) ) |
|
101 { |
|
102 return configStoringLocationFound; |
|
103 } |
|
104 |
|
105 // Check that the given drive exists and it is not RAM drive (D:) |
|
106 if ( aDriveLetter.IsAlpha() && ( ( aDriveLetter != 'd' ) |
|
107 && ( aDriveLetter != 'D' ) ) ) |
|
108 { |
|
109 |
|
110 // Do not accept substed or ROM drive |
|
111 if ( ( driveInfo.iDriveAtt & KDriveAttLocal ) && |
|
112 !( driveInfo.iDriveAtt & KDriveAttRom ) && |
|
113 !( driveInfo.iDriveAtt & KDriveAttSubsted ) && |
|
114 !( driveInfo.iDriveAtt & KDriveAttRemote ) ) |
|
115 { |
|
116 configStoringLocationFound = ETrue; |
|
117 } |
|
118 } |
|
119 } |
|
120 |
|
121 if ( !configStoringLocationFound ) |
|
122 { |
|
123 // Central repository key was not found or was found not to be |
|
124 // alphabetic -> use the default path for storing OMA DRM rights |
|
125 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); |
|
126 aFs.DriveToChar( driveNumber, aDriveLetter ); |
|
127 } |
|
128 |
|
129 return configStoringLocationFound; |
|
130 } |
|
131 |
|
132 |
|
133 |