15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // INCLUDE FILES |
18 // INCLUDE FILES |
19 |
19 |
20 // connection |
|
21 #include <cmconnectionmethod.h> |
|
22 #include <cmdestination.h> |
|
23 #include <cmconnectionmethoddef.h> |
|
24 #include <cmmanager.h> |
|
25 #include <sacls.h> |
|
26 #include <utf.h> |
|
27 |
20 |
28 // publish & subscribe |
21 // publish & subscribe |
29 #include <e32property.h> |
22 #include <e32property.h> |
30 #include <PSVariables.h> |
23 #include <PSVariables.h> |
31 #include <centralrepository.h> |
24 #include <centralrepository.h> |
68 #include <DRMRightsClient.h> |
56 #include <DRMRightsClient.h> |
69 #include <drmutility.h> |
57 #include <drmutility.h> |
70 #include <drmutilitytypes.h> |
58 #include <drmutilitytypes.h> |
71 #include <drmasyncobserver.h> |
59 #include <drmasyncobserver.h> |
72 #include <drmhandleerrorobserver.h> |
60 #include <drmhandleerrorobserver.h> |
|
61 |
|
62 //connectivity logic |
|
63 #include <cmconnectionmethod.h> // RCmConnectionMethod |
|
64 #include <cmdestination.h> // RCmDestination |
|
65 #include <cmmanager.h> // RCmManager |
|
66 |
|
67 |
73 |
68 |
74 #ifdef _DEBUG |
69 #ifdef _DEBUG |
75 #include <e32debug.h> |
70 #include <e32debug.h> |
76 #endif |
71 #endif |
77 |
72 |
102 const TInt KCommandShowDetailsViewData( 6 ); |
97 const TInt KCommandShowDetailsViewData( 6 ); |
103 const TInt KCommandHandleUrlFile( 7 ); |
98 const TInt KCommandHandleUrlFile( 7 ); |
104 const TInt KCommandHandleUrlData( 8 ); |
99 const TInt KCommandHandleUrlData( 8 ); |
105 const TInt KCommandAvailableUrlsFile( 9 ); |
100 const TInt KCommandAvailableUrlsFile( 9 ); |
106 const TInt KCommandAvailableUrlsData( 10 ); |
101 const TInt KCommandAvailableUrlsData( 10 ); |
107 // browser |
|
108 #ifndef __SERIES60_NATIVE_BROWSER |
|
109 const TUid KCRUidBrowser = |
|
110 {0x10008D39}; |
|
111 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; |
|
112 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; |
|
113 const TUint32 KBrowserNGDefaultSnapId = 0x00000053; |
|
114 #endif |
|
115 |
102 |
116 _LIT( KEncryptedRightsIssuerMatchString, "flk*" ); |
103 _LIT( KEncryptedRightsIssuerMatchString, "flk*" ); |
117 |
104 |
118 // buffer sizes |
105 // buffer sizes |
119 const TInt KDRMMaxETABufSize( 11 ); |
106 const TInt KDRMMaxETABufSize( 11 ); |
138 const TInt KDRMUtilityDebugPanicCode( 1 ); |
125 const TInt KDRMUtilityDebugPanicCode( 1 ); |
139 #endif |
126 #endif |
140 |
127 |
141 // ============================= LOCAL FUNCTIONS =============================== |
128 // ============================= LOCAL FUNCTIONS =============================== |
142 // ----------------------------------------------------------------------------- |
129 // ----------------------------------------------------------------------------- |
|
130 // HasDefaultConnectionL |
|
131 // Finds default IAP id |
|
132 // @return Etrue: valid AP found |
|
133 // EFalse: valid AP not found |
|
134 // @leave system wide error codes |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 LOCAL_C TBool HasDefaultConnectionL() |
|
138 { |
|
139 TBool hasDefault(EFalse); |
|
140 TCmDefConnValue defConn; |
|
141 RCmManager cmManager; |
|
142 cmManager.OpenLC(); |
|
143 cmManager.ReadDefConnL(defConn); |
|
144 if (defConn.iType == ECmDefConnConnectionMethod) |
|
145 { |
|
146 cmManager.GetConnectionMethodInfoIntL(defConn.iId, |
|
147 CMManager::ECmIapId); |
|
148 hasDefault = ETrue; |
|
149 } |
|
150 else if (defConn.iType == ECmDefConnDestination) |
|
151 { |
|
152 RCmDestination dest(cmManager.DestinationL(defConn.iId)); |
|
153 CleanupClosePushL(dest); |
|
154 |
|
155 if (dest.ConnectionMethodCount() <= 0) |
|
156 { |
|
157 User::Leave(KErrNotFound); |
|
158 } |
|
159 |
|
160 RCmConnectionMethod cMeth(dest.ConnectionMethodL(0)); |
|
161 CleanupClosePushL(cMeth); |
|
162 |
|
163 cMeth.GetIntAttributeL(CMManager::ECmIapId); |
|
164 CleanupStack::PopAndDestroy(&cMeth); |
|
165 CleanupStack::PopAndDestroy(&dest); |
|
166 hasDefault = ETrue; |
|
167 } |
|
168 CleanupStack::PopAndDestroy(&cmManager); |
|
169 return hasDefault; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // HasAccessPointsL |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 LOCAL_C TBool HasAccessPointsL() |
|
177 { |
|
178 TInt apCount(0); |
|
179 RCmManager cmManager; |
|
180 CleanupClosePushL(cmManager); |
|
181 cmManager.OpenL(); |
|
182 RArray<TUint32> aps; |
|
183 CleanupClosePushL(aps); |
|
184 cmManager.ConnectionMethodL(aps, EFalse, EFalse, ETrue); |
|
185 apCount = aps.Count(); |
|
186 CleanupStack::PopAndDestroy(2, &cmManager); //aps, cmManager |
|
187 return apCount > 0; |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
143 // MapToCallError |
191 // MapToCallError |
144 // ----------------------------------------------------------------------------- |
192 // ----------------------------------------------------------------------------- |
145 // |
193 // |
146 LOCAL_C inline TInt CheckAndMapToCallError( |
194 LOCAL_C inline TInt CheckAndMapToCallError( |
147 RDRMRightsClient& aOmaClient, |
195 RDRMRightsClient& aOmaClient, |
152 TInt err( aOmaClient.CheckRights( aIntent, aContentUri, rr ) ); |
200 TInt err( aOmaClient.CheckRights( aIntent, aContentUri, rr ) ); |
153 return err ? KErrCANoRights : KErrNone; |
201 return err ? KErrCANoRights : KErrNone; |
154 } |
202 } |
155 |
203 |
156 // ----------------------------------------------------------------------------- |
204 // ----------------------------------------------------------------------------- |
157 // IapIdOfDefaultSnapL |
205 // HasDefConn |
158 // for trapping purposes only |
206 // ----------------------------------------------------------------------------- |
159 // ----------------------------------------------------------------------------- |
207 // |
160 // |
208 inline TBool HasDefConn() |
161 LOCAL_C TUint32 IapIdOfDefaultSnapL( |
209 { |
162 RCmManager& aCmManager, |
210 TBool found( EFalse ); |
163 const TUint32 aDefaultSnap ) |
211 |
164 { |
212 TRAP_IGNORE( found = HasDefaultConnectionL() ); |
165 RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) ); |
213 |
166 CleanupClosePushL( dest ); |
214 return found; |
167 TUint32 iapIdOfDest( 0 ); |
215 } |
168 |
216 |
169 if ( dest.ConnectionMethodCount() <= 0 ) |
|
170 { |
|
171 User::Leave( KErrNotFound ); |
|
172 } |
|
173 |
|
174 RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) ); |
|
175 CleanupClosePushL( cMeth ); |
|
176 |
|
177 iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId ); |
|
178 CleanupStack::PopAndDestroy( &cMeth ); |
|
179 CleanupStack::PopAndDestroy( &dest ); |
|
180 return iapIdOfDest; |
|
181 } |
|
182 |
217 |
183 // ============================ MEMBER FUNCTIONS =============================== |
218 // ============================ MEMBER FUNCTIONS =============================== |
184 |
219 |
185 // ----------------------------------------------------------------------------- |
220 // ----------------------------------------------------------------------------- |
186 // CDrmUiHandlingImpl::CDrmUiHandlingImpl |
221 // CDrmUiHandlingImpl::CDrmUiHandlingImpl |
3826 __ASSERT_DEBUG( !aLaunchParam && aUrl && aFullPath, |
3861 __ASSERT_DEBUG( !aLaunchParam && aUrl && aFullPath, |
3827 User::Panic( KDRMUtilityDebugPanicMessage, |
3862 User::Panic( KDRMUtilityDebugPanicMessage, |
3828 KDRMUtilityDebugPanicCode ) ); |
3863 KDRMUtilityDebugPanicCode ) ); |
3829 _LIT( KMarker, "\x00" ); |
3864 _LIT( KMarker, "\x00" ); |
3830 |
3865 |
3831 RPointerArray<CDRMPermission> uriList; |
|
3832 TPtr ptr( NULL, 0 ); |
3866 TPtr ptr( NULL, 0 ); |
3833 |
|
3834 TInt localId( 0 ); |
3867 TInt localId( 0 ); |
3835 TInt err( KErrNone ); |
|
3836 |
|
3837 TRAP( err, iOmaClient.GetDBEntriesL( *aUrl, uriList ) ); |
|
3838 |
|
3839 if ( uriList.Count() == 1 ) |
|
3840 { |
|
3841 localId = ( uriList[0] )->iUniqueID; |
|
3842 } |
|
3843 |
|
3844 uriList.ResetAndDestroy(); |
|
3845 uriList.Close(); |
|
3846 |
3868 |
3847 // MaxInt will fit into 10 characters |
3869 // MaxInt will fit into 10 characters |
3848 HBufC* localIDBuf( HBufC::NewLC( KIntegerMaxLen ) ); |
3870 HBufC* localIDBuf( HBufC::NewLC( KIntegerMaxLen ) ); |
3849 ptr.Set( localIDBuf->Des() ); |
3871 ptr.Set( localIDBuf->Des() ); |
3850 ptr.AppendNum( localId ); |
3872 ptr.AppendNum( localId ); |
4032 buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( |
4054 buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( |
4033 R_DRM_QRY_CONNECT_TO_ACTIVATE, |
4055 R_DRM_QRY_CONNECT_TO_ACTIVATE, |
4034 R_DRMUTILITY_CONFIRMATION_QUERY ); |
4056 R_DRMUTILITY_CONFIRMATION_QUERY ); |
4035 } |
4057 } |
4036 } |
4058 } |
4037 else if ( !BrowserAPDefinedL() ) |
4059 else if ( !(HasDefConn()) ) |
4038 { |
4060 { |
4039 buttonCode = EAknSoftkeyNo; |
4061 buttonCode = EAknSoftkeyNo; |
4040 if ( aShowNotes ) |
4062 if ( aShowNotes ) |
4041 { |
4063 { |
4042 buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( |
4064 buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( |
4145 delete repository; |
4167 delete repository; |
4146 return !value ? EFalse : ETrue; |
4168 return !value ? EFalse : ETrue; |
4147 } |
4169 } |
4148 |
4170 |
4149 // ----------------------------------------------------------------------------- |
4171 // ----------------------------------------------------------------------------- |
4150 // CDrmUiHandlingImpl::BrowserAPDefinedL |
|
4151 // ----------------------------------------------------------------------------- |
|
4152 // |
|
4153 TBool DRM::CDrmUiHandlingImpl::BrowserAPDefinedL() |
|
4154 { |
|
4155 const TInt KDestinationSelectionMode( 2 ); |
|
4156 TInt err( KErrNone ); |
|
4157 TInt ap( 0 ); |
|
4158 TInt alwaysAsk( 0 ); |
|
4159 TInt defaultSnap( 0 ); |
|
4160 |
|
4161 CRepository* repository( CRepository::NewL( KCRUidBrowser ) ); |
|
4162 repository->Get( KBrowserDefaultAccessPoint, ap ); |
|
4163 repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); |
|
4164 repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); |
|
4165 delete repository; |
|
4166 if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) |
|
4167 { |
|
4168 alwaysAsk = ETrue; |
|
4169 } |
|
4170 else |
|
4171 { |
|
4172 RCmManager cmManager; |
|
4173 CleanupClosePushL( cmManager ); |
|
4174 cmManager.OpenL(); |
|
4175 if ( !alwaysAsk ) |
|
4176 { |
|
4177 TRAP( err, cmManager.GetConnectionMethodInfoIntL( |
|
4178 ap, CMManager::ECmIapId ) ); |
|
4179 } |
|
4180 else if ( alwaysAsk == KDestinationSelectionMode ) |
|
4181 { |
|
4182 TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) ); |
|
4183 } |
|
4184 CleanupStack::PopAndDestroy( &cmManager ); |
|
4185 if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) ) |
|
4186 { |
|
4187 return ETrue; |
|
4188 } |
|
4189 } |
|
4190 return EFalse; |
|
4191 } |
|
4192 |
|
4193 // ----------------------------------------------------------------------------- |
|
4194 // CDrmUiHandlingImpl::APCountL |
|
4195 // ----------------------------------------------------------------------------- |
|
4196 // |
|
4197 TInt DRM::CDrmUiHandlingImpl::APCountL() |
|
4198 { |
|
4199 TInt apCount( 0 ); |
|
4200 RCmManager cmManager; |
|
4201 CleanupClosePushL( cmManager ); |
|
4202 cmManager.OpenL(); |
|
4203 RArray<TUint32> aps; |
|
4204 CleanupClosePushL( aps ); |
|
4205 cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue ); |
|
4206 apCount = aps.Count(); |
|
4207 CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager |
|
4208 return apCount; |
|
4209 } |
|
4210 |
|
4211 // ----------------------------------------------------------------------------- |
|
4212 // CDrmUiHandlingImpl::HandleServerAppExit |
4172 // CDrmUiHandlingImpl::HandleServerAppExit |
4213 // ----------------------------------------------------------------------------- |
4173 // ----------------------------------------------------------------------------- |
4214 // |
4174 // |
4215 void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason ) |
4175 void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason ) |
4216 { |
4176 { |