|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Utility class for SendUI. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <s32mem.h> |
|
23 #include <e32base.h> |
|
24 #include <mtclbase.h> |
|
25 #include <tmsvpackednotifierrequest.h> |
|
26 |
|
27 #include "SendUiCapabilityCheck.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TUid KSendUiNotifierPluginUid = {0x10282895}; |
|
31 const TInt32 KSendUiServiceMaxNameLength = 40; // original defined in SendUIPrivateCRKeys.h |
|
32 const TInt32 KSendUiNotifierBufferSize = KSendUiServiceMaxNameLength + sizeof(TUint32); |
|
33 |
|
34 typedef TBuf8<KSendUiNotifierBufferSize> TTransferBuf; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CSendUiCapabilityCheck:CSendUiCapabilityCheck |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CSendUiCapabilityCheck::CSendUiCapabilityCheck() |
|
45 : CActive( EPriorityStandard ) |
|
46 { |
|
47 CActiveScheduler::Add( this ); |
|
48 iNotifierUid = KSendUiNotifierPluginUid; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSendUiCapabilityCheck::NewL |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CSendUiCapabilityCheck* CSendUiCapabilityCheck::NewLC() |
|
57 { |
|
58 CSendUiCapabilityCheck* self = new (ELeave) CSendUiCapabilityCheck(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CSendUiCapabilityCheck::ConstructL |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CSendUiCapabilityCheck::ConstructL() |
|
69 { |
|
70 User::LeaveIfError( iNotifier.Connect() ); |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CSendUiCapabilityCheck::CheckCapabilitiesL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 TBool CSendUiCapabilityCheck::CheckCapabilitiesL( |
|
79 const TSecurityInfo& aSecurityInfo, |
|
80 CMsvSession& aSession, |
|
81 const TUid aMtmType, |
|
82 const TDesC& aServiceName ) |
|
83 { |
|
84 TBool capabilitiesOK = EFalse; |
|
85 // get required capabilities |
|
86 TCapabilitySet caps; |
|
87 aSession.GetMtmRequiredCapabilitiesL( aMtmType, caps ); |
|
88 |
|
89 // check client capabilities with required capabilities |
|
90 if( aSecurityInfo.iCaps.HasCapabilities( caps ) ) |
|
91 { |
|
92 capabilitiesOK = ETrue; |
|
93 } |
|
94 else |
|
95 { |
|
96 // compile a message buffer containing service name and service ID |
|
97 TInt nameLength = aServiceName.Length(); |
|
98 CBufFlat* buffer = CBufFlat::NewL( nameLength + sizeof(TUint32) ); |
|
99 CleanupStack::PushL( buffer ); |
|
100 |
|
101 RBufWriteStream bufStream; |
|
102 bufStream.Open( *buffer ); |
|
103 bufStream.WriteUint32L( nameLength ); |
|
104 |
|
105 if ( nameLength ) |
|
106 { |
|
107 bufStream << aServiceName; |
|
108 } |
|
109 bufStream.WriteUint32L( aSecurityInfo.iSecureId ); |
|
110 bufStream.CommitL(); |
|
111 bufStream.Close(); |
|
112 |
|
113 TTransferBuf transferBuffer; |
|
114 buffer->Read( 0, transferBuffer, buffer->Size() ); |
|
115 CleanupStack::PopAndDestroy( buffer ); |
|
116 |
|
117 iNotifier.StartNotifierAndGetResponse( iStatus, iNotifierUid, transferBuffer, iNotifierResult ); |
|
118 SetActive(); |
|
119 iWait.Start(); |
|
120 |
|
121 if ( iStatus == KErrNone ) |
|
122 { |
|
123 capabilitiesOK = ETrue; |
|
124 } |
|
125 } |
|
126 |
|
127 return capabilitiesOK; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CSendUiCapabilityCheck::~CSendUiCapabilityCheck |
|
132 // Destructor |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 CSendUiCapabilityCheck::~CSendUiCapabilityCheck() |
|
136 { |
|
137 iNotifier.Close(); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CSendUiCapabilityCheck::RunL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CSendUiCapabilityCheck::RunL() |
|
145 { |
|
146 iWait.AsyncStop(); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CSendUiCapabilityCheck::DoCancel |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CSendUiCapabilityCheck::DoCancel() |
|
154 { |
|
155 iNotifier.NotifyCancel(); |
|
156 } |
|
157 |
|
158 |
|
159 // End of File |