|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <ecom/ecom.h> |
|
17 #include "csendasUInotifier.h" |
|
18 #include <tmsvpackednotifierrequest.h> |
|
19 #include <ecom/implementationproxy.h> |
|
20 |
|
21 /* UID of the SendAs notifier channel to get the user's confirmation */ |
|
22 const TUid KSendAsNotifierPluginUid = {0x10208C14}; |
|
23 const TUid KTechViewScreenOutputChannel = {0x10208C14}; |
|
24 const TInt KSendAsServerExeUid = {0x10204290}; |
|
25 |
|
26 |
|
27 RDummyServSession::RDummyServSession() |
|
28 { |
|
29 } |
|
30 |
|
31 static TInt StartDummyServer() |
|
32 { |
|
33 const TUidType serverUid(KNullUid, TUid::Uid(KSendAsServerExeUid)); |
|
34 TRequestStatus started( KRequestPending ); |
|
35 RProcess server; |
|
36 TInt err = server.Create(KDummyServerExe, KNullDesC(), serverUid); |
|
37 |
|
38 if( err != KErrNone ) |
|
39 { |
|
40 return err; |
|
41 } |
|
42 |
|
43 TRequestStatus status; |
|
44 server.Rendezvous(status); |
|
45 if( status != KRequestPending ) |
|
46 { |
|
47 server.Kill(0); // abort start-up |
|
48 } |
|
49 else |
|
50 { |
|
51 server.Resume(); // wait for server start-up. |
|
52 } |
|
53 User::WaitForRequest(status); |
|
54 err = (server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int(); |
|
55 server.Close(); |
|
56 return err; |
|
57 } |
|
58 |
|
59 TInt RDummyServSession::Connect() |
|
60 { |
|
61 // Start the server. |
|
62 TInt err = StartDummyServer(); |
|
63 if (err == KErrNone) |
|
64 { |
|
65 err = CreateSession(KDummyServerName,Version(),5); |
|
66 } |
|
67 |
|
68 return(err); |
|
69 } |
|
70 |
|
71 |
|
72 /** |
|
73 Returns the earliest version number of the server that we can talk to. |
|
74 */ |
|
75 TVersion RDummyServSession::Version(void) const |
|
76 { |
|
77 return(TVersion(KCountServMajorVersionNumber,KCountServMinorVersionNumber,KCountServBuildVersionNumber)); |
|
78 } |
|
79 |
|
80 |
|
81 TMsvEntry RDummyServSession::GetTMsvEntry(CMsvEntrySelection* iSelection) |
|
82 { |
|
83 TMsvEntry entry; |
|
84 TPckgBuf<TMsvEntry> pckg; |
|
85 TMsvId entryId = iSelection->At(0); |
|
86 SendReceive(EServGetTMsvEntry,TIpcArgs(entryId, &pckg)); |
|
87 entry = pckg(); |
|
88 return entry; |
|
89 } |
|
90 |
|
91 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray() |
|
92 { |
|
93 CArrayPtrFlat<MEikSrvNotifierBase2>* subjects=NULL; |
|
94 TRAPD( err, subjects=new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(1) ); |
|
95 if( err == KErrNone ) |
|
96 { |
|
97 TRAP( err, subjects->AppendL( CSendAsUINotifier::NewL() ) ); |
|
98 return(subjects); |
|
99 } |
|
100 else |
|
101 { |
|
102 return NULL; |
|
103 } |
|
104 } |
|
105 |
|
106 CSendAsUINotifier* CSendAsUINotifier::NewL() |
|
107 { |
|
108 CSendAsUINotifier* self=new (ELeave) CSendAsUINotifier(); |
|
109 CleanupStack::PushL(self); |
|
110 self->ConstructL(); |
|
111 CleanupStack::Pop(self); |
|
112 return self; |
|
113 } |
|
114 |
|
115 void CSendAsUINotifier::ConstructL() |
|
116 { |
|
117 iSelection = new (ELeave) CMsvEntrySelection(); |
|
118 } |
|
119 |
|
120 CSendAsUINotifier::~CSendAsUINotifier() |
|
121 { |
|
122 delete iSelection; |
|
123 REComSession::FinalClose(); |
|
124 } |
|
125 |
|
126 CSendAsUINotifier::CSendAsUINotifier() |
|
127 { |
|
128 iInfo.iUid = KSendAsNotifierPluginUid; |
|
129 iInfo.iChannel = KTechViewScreenOutputChannel; |
|
130 iInfo.iPriority = ENotifierPriorityHigh; |
|
131 } |
|
132 |
|
133 void CSendAsUINotifier::Release() |
|
134 { |
|
135 delete this; |
|
136 } |
|
137 |
|
138 /** |
|
139 Called when a notifier is first loaded to allow any initial construction that is required. |
|
140 */ |
|
141 CSendAsUINotifier::TNotifierInfo CSendAsUINotifier::RegisterL() |
|
142 { |
|
143 return iInfo; |
|
144 } |
|
145 |
|
146 CSendAsUINotifier::TNotifierInfo CSendAsUINotifier::Info() const |
|
147 { |
|
148 return iInfo; |
|
149 } |
|
150 |
|
151 /** |
|
152 The notifier has been deactivated so resources can be freed and outstanding messages completed. |
|
153 */ |
|
154 void CSendAsUINotifier::Cancel() |
|
155 { |
|
156 } |
|
157 |
|
158 /** |
|
159 Start the Notifier with data aBuffer. |
|
160 |
|
161 Not used for confirm notifiers |
|
162 */ |
|
163 TPtrC8 CSendAsUINotifier::StartL(const TDesC8& /*aBuffer*/) |
|
164 { |
|
165 User::Leave(KErrNotSupported); |
|
166 return KNullDesC8(); |
|
167 } |
|
168 |
|
169 /** |
|
170 Start the notifier with data aBuffer. aMessage should be completed when the notifier is deactivated. |
|
171 |
|
172 May be called multiple times if more than one client starts the notifier. The notifier is immediately |
|
173 responsible for completing aMessage. |
|
174 */ |
|
175 void CSendAsUINotifier::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, const RMessagePtr2& aMessage) |
|
176 { |
|
177 // extract the notifier request parameters |
|
178 TMsvPackedNotifierRequest::UnpackL(aBuffer, *iSelection, iSecurityInfo); |
|
179 iMessage = aMessage; |
|
180 //Start the session. |
|
181 RDummyServSession serverSession; |
|
182 serverSession.Connect(); |
|
183 |
|
184 // Simulate "User Response" |
|
185 TMsvEntry entry = serverSession.GetTMsvEntry(iSelection); |
|
186 serverSession.Close(); |
|
187 // complete with TMsvEntry::iError as return code |
|
188 if (entry.iError != KErrNone) |
|
189 { |
|
190 iMessage.Complete(KErrPermissionDenied); |
|
191 } |
|
192 else |
|
193 { |
|
194 iMessage.Complete(KErrNone); |
|
195 } |
|
196 // Clear the CMsvEntrySelection |
|
197 iSelection->Reset(); |
|
198 } |
|
199 |
|
200 /** |
|
201 Update a currently active notifier with data aBuffer. |
|
202 |
|
203 Not used for confirm notifiers |
|
204 */ |
|
205 TPtrC8 CSendAsUINotifier::UpdateL(const TDesC8& /*aBuffer*/) |
|
206 { |
|
207 User::Leave(KErrNotSupported); |
|
208 return KNullDesC8(); |
|
209 } |
|
210 |
|
211 //Adding ECOM SUPPORT |
|
212 const TImplementationProxy ImplementationTable[] = |
|
213 { |
|
214 IMPLEMENTATION_PROXY_ENTRY(0x10275530,NotifierArray) |
|
215 }; |
|
216 |
|
217 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
218 { |
|
219 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
220 return ImplementationTable; |
|
221 } |
|
222 |
|
223 |