1 /* |
|
2 * Copyright (c) 2006 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: SendUi service class. Receives message data from the |
|
15 * SendUi host. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <eikenv.h> |
|
23 #include <s32mem.h> |
|
24 |
|
25 #include <CMessageData.h> |
|
26 #include <SendUiConsts.h> |
|
27 #include <CSendingService.h> |
|
28 |
|
29 #include "senduiservice.h" |
|
30 #include "senduilauncherappui.h" |
|
31 #include "senduiserviceslog.h" |
|
32 #include "SendUiPrivateCRKeys.h" |
|
33 #include "senduiservicecommands.h" |
|
34 #include "senduilauncher.h" |
|
35 #include <senduisingleton.h> |
|
36 |
|
37 typedef TBuf8<KTransferBufferSize> TTransferBuf; |
|
38 // --------------------------------------------------------------------------- |
|
39 // ConstructL |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CSendUiService::ConstructL() |
|
43 { |
|
44 iAppUi = (CSendUiLauncherAppUi*)CEikonEnv::Static()->EikAppUi(); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // NewLC |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSendUiService* CSendUiService::NewL() |
|
52 { |
|
53 CSendUiService* self = new( ELeave ) CSendUiService; |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Destructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CSendUiService::~CSendUiService() |
|
67 { |
|
68 LOGTEXT(_L("CSendUiService->~ >>")); |
|
69 delete iMessageData; |
|
70 delete iTransferBuffer; |
|
71 delete iReadStream; |
|
72 LOGTEXT(_L("CSendUiService->~ <<")); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // ServiceL |
|
77 // Receives message from SendUi and passes data to AppUi |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CSendUiService::ServiceL( const RMessage2& aMessage ) |
|
81 { |
|
82 LOGTEXT(_L("CSendUiService->ServiceL >>")); |
|
83 |
|
84 TTransferBuf transferBuffer; |
|
85 |
|
86 switch (aMessage.Function()) |
|
87 { |
|
88 case ESendUiDataBlock: // receive main message data in blocks |
|
89 { |
|
90 TPckgBuf<TTransferBuf> bufPckg; |
|
91 TPckgBuf<TInt> blockSizePckg; |
|
92 TPckgBuf<TInt> totalSizePckg; |
|
93 |
|
94 aMessage.ReadL( ESlot1, bufPckg ); |
|
95 aMessage.ReadL( ESlot2, blockSizePckg ); |
|
96 aMessage.ReadL( ESlot3, totalSizePckg ); |
|
97 |
|
98 TInt blockSize = blockSizePckg(); |
|
99 TInt totalSize = totalSizePckg(); |
|
100 |
|
101 transferBuffer = bufPckg(); |
|
102 |
|
103 if (!iTransferBuffer) |
|
104 { |
|
105 iTransferredBytes = 0; |
|
106 iTransferBuffer = HBufC8::NewL( totalSize ); |
|
107 } |
|
108 TPtr8 bufferPtr8( iTransferBuffer->Des() ); |
|
109 bufferPtr8.Insert( iTransferredBytes, transferBuffer ); |
|
110 |
|
111 iTransferredBytes += blockSize; |
|
112 break; |
|
113 } |
|
114 case EDataSent: // this is the last data block, start reading |
|
115 { |
|
116 |
|
117 iReadStream = new(ELeave)RDesReadStream( *iTransferBuffer ); |
|
118 TUid serviceProviderUid(KNullUid); |
|
119 TUid dataTypeUid(KNullUid); |
|
120 |
|
121 if ( iTransferBuffer ) |
|
122 { |
|
123 LOGTEXT(_L("CSendUiService->ServiceL: ELaunchSendUi: openstream")); |
|
124 |
|
125 TUint32 tmpVal = iReadStream->ReadUint32L(); |
|
126 serviceProviderUid = TUid::Uid( tmpVal ); |
|
127 |
|
128 tmpVal = iReadStream->ReadUint32L(); |
|
129 dataTypeUid = TUid::Uid( tmpVal ); |
|
130 } |
|
131 iMessageData = CMessageData::NewL(); |
|
132 break; |
|
133 } |
|
134 case ECopyFileHandle: // receive file handles |
|
135 { |
|
136 LOGTEXT(_L("CSendUiService->ServiceL: ECopyFileHandle")); |
|
137 |
|
138 // open source file handle |
|
139 RFile sourceFile; |
|
140 User::LeaveIfError(sourceFile.AdoptFromClient(aMessage, 0, 1)); |
|
141 CleanupClosePushL(sourceFile); |
|
142 iMessageData->AppendAttachmentHandleL( sourceFile ); |
|
143 CleanupStack::Pop(&sourceFile); |
|
144 |
|
145 LOGTEXT(_L("CSendUiService->ServiceL: ECopyFileHandle done")); |
|
146 break; |
|
147 } |
|
148 case ELaunchSendUi: // construct message data and invoke sendui |
|
149 { |
|
150 LOGTEXT(_L("CSendUiService->ServiceL: ELaunchSendUi>>")); |
|
151 |
|
152 if ( iReadStream ) |
|
153 { |
|
154 LOGTEXT(_L("CSendUiService->ServiceL: ELaunchSendUi: openstream")); |
|
155 |
|
156 |
|
157 TUint32 tmpVal = iReadStream->ReadUint32L(); |
|
158 TUid serviceUid( TUid::Uid( tmpVal )); |
|
159 |
|
160 tmpVal = iReadStream->ReadUint32L(); |
|
161 TBool launchEmbedded( tmpVal ); |
|
162 |
|
163 tmpVal = iReadStream->ReadUint32L(); |
|
164 |
|
165 if (tmpVal ) |
|
166 { |
|
167 iMessageData->InternalizeL( *iReadStream ); |
|
168 } |
|
169 |
|
170 iReadStream->Release(); |
|
171 iReadStream->Close(); |
|
172 |
|
173 iAppUi->CreateAndSendMessageL( |
|
174 serviceUid, |
|
175 iMessageData, |
|
176 launchEmbedded ); |
|
177 } |
|
178 iAppUi->DoDelayedExitL( 0 ); |
|
179 |
|
180 LOGTEXT(_L("CSendUiService->ServiceL: complete message")); |
|
181 |
|
182 break; |
|
183 } |
|
184 default: |
|
185 // No other commands exist. |
|
186 LOGTEXT(_L("CSendUiService->ServiceL: ERROR! Unknown command")); |
|
187 } |
|
188 aMessage.Complete( KErrNone ); |
|
189 |
|
190 }; |
|
191 |
|
192 // End of File |
|
193 |
|