30
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: This class handles send functionality in calendar application.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
//debug
|
|
21 |
#include "calendarui_debug.h"
|
|
22 |
|
|
23 |
#include "calensend.h"
|
|
24 |
#include "CalenInterimUtils2.h"
|
|
25 |
#include "CalenPaths.h"
|
|
26 |
#include "calenvcalexport.h"
|
|
27 |
#include "calenglobaldata.h"
|
|
28 |
|
|
29 |
#include "cmrmailboxutils.h"
|
|
30 |
|
|
31 |
#include <eikenv.h>
|
|
32 |
#include <MsgBioUids.h>
|
|
33 |
#include <sendui.h>
|
|
34 |
#include <TSendingCapabilities.h>
|
|
35 |
#include <CMessageData.h>
|
|
36 |
#include <CMessageAddress.h>
|
|
37 |
#include <SendUiConsts.h>
|
|
38 |
#include <sysutil.h>
|
|
39 |
#include <txtrich.h>
|
|
40 |
#include <calsession.h>
|
|
41 |
|
|
42 |
|
|
43 |
// ---------------------------------------------------------
|
|
44 |
// CCalenSend::NewL
|
|
45 |
// Static constructor
|
|
46 |
// (other items were commented in a header).
|
|
47 |
// ---------------------------------------------------------
|
|
48 |
//
|
|
49 |
EXPORT_C CCalenSend* CCalenSend::NewL(TInt aMenuCommandId,
|
|
50 |
CCalSession& aCalSession)
|
|
51 |
{
|
|
52 |
TRACE_ENTRY_POINT;
|
|
53 |
|
|
54 |
CCalenSend* self = new (ELeave) CCalenSend(aCalSession);
|
|
55 |
CleanupStack::PushL(self);
|
|
56 |
self->ConstructL(aMenuCommandId);
|
|
57 |
CleanupStack::Pop(self);
|
|
58 |
|
|
59 |
TRACE_EXIT_POINT;
|
|
60 |
return self;
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------
|
|
64 |
// CCalenSend::CCalenSend
|
|
65 |
// C++ constructor
|
|
66 |
// (other items were commented in a header).
|
|
67 |
// ---------------------------------------------------------
|
|
68 |
//
|
|
69 |
CCalenSend::CCalenSend(CCalSession& aCalSession) : iSession(aCalSession)
|
|
70 |
{
|
|
71 |
TRACE_ENTRY_POINT;
|
|
72 |
TRACE_EXIT_POINT;
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------
|
|
76 |
// CCalenSend::ConstructL
|
|
77 |
// 2nd phase constructor
|
|
78 |
// (other items were commented in a header).
|
|
79 |
// ---------------------------------------------------------
|
|
80 |
//
|
|
81 |
void CCalenSend::ConstructL(TInt aMenuCommandId)
|
|
82 |
{
|
|
83 |
TRACE_ENTRY_POINT;
|
|
84 |
|
|
85 |
iSendUi = CSendUi::NewL();
|
|
86 |
iSendAsCmdId=aMenuCommandId;
|
|
87 |
iSendMtmsToDim = new (ELeave) CArrayFixFlat<TUid>(3);
|
|
88 |
|
|
89 |
// Always disable sending via Audio message
|
|
90 |
iSendMtmsToDim->AppendL( KSenduiMtmAudioMessageUid );
|
|
91 |
// Always disable sending via Postcard
|
|
92 |
iSendMtmsToDim->AppendL( KSenduiMtmPostcardUid );
|
|
93 |
iSendMtmsToDim->AppendL( KMmsDirectUpload );
|
|
94 |
iSendMtmsToDim->AppendL( KMmsIndirectUpload );
|
|
95 |
|
|
96 |
if( ! iSendUi->CanSendBioMessage( KMsgBioUidVCalendar ) )
|
|
97 |
{
|
|
98 |
// This disables sending of vCalendars via SMS
|
|
99 |
iSendMtmsToDim->AppendL(KSenduiMtmSmsUid);
|
|
100 |
}
|
|
101 |
|
|
102 |
TRACE_EXIT_POINT;
|
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------
|
|
106 |
// CCalenSend::~CCalenSend
|
|
107 |
// Destructor
|
|
108 |
// (other items were commented in a header).
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
//
|
|
111 |
EXPORT_C CCalenSend::~CCalenSend()
|
|
112 |
{
|
|
113 |
TRACE_ENTRY_POINT;
|
|
114 |
|
|
115 |
delete iSendUi;
|
|
116 |
delete iSendMtmsToDim;
|
|
117 |
|
|
118 |
TRACE_EXIT_POINT;
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------
|
|
122 |
// CCalenSend::CanSendL
|
|
123 |
// Check wheter sending is possible
|
|
124 |
// (other items were commented in a header).
|
|
125 |
// ---------------------------------------------------------
|
|
126 |
//
|
|
127 |
EXPORT_C TBool CCalenSend::CanSendL(TInt /*aCommandId*/)
|
|
128 |
{
|
|
129 |
TRACE_ENTRY_POINT;
|
|
130 |
|
|
131 |
TBool ret( EFalse );
|
|
132 |
if( iSelectedMtmUid != KNullUid )
|
|
133 |
{
|
|
134 |
TRACE_EXIT_POINT;
|
|
135 |
return ETrue;
|
|
136 |
}
|
|
137 |
|
|
138 |
TRACE_EXIT_POINT;
|
|
139 |
return ret;
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------
|
|
143 |
// CCalenSend::DisplaySendMenuItemL
|
|
144 |
// Show sendui menu
|
|
145 |
// (other items were commented in a header).
|
|
146 |
// ---------------------------------------------------------
|
|
147 |
//
|
|
148 |
EXPORT_C void CCalenSend::DisplaySendMenuItemL( CEikMenuPane& aMenuPane,
|
|
149 |
TInt aIndex)
|
|
150 |
{
|
|
151 |
TRACE_ENTRY_POINT;
|
|
152 |
|
|
153 |
iSendUi->AddSendMenuItemL( aMenuPane, aIndex, iSendAsCmdId, TSendingCapabilities() );
|
|
154 |
|
|
155 |
TRACE_EXIT_POINT;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------
|
|
159 |
// CCalenSend::DisplaySendCascadeMenuL
|
|
160 |
// Show send quesry / cascaded menu
|
|
161 |
// (other items were commented in a header).
|
|
162 |
// ---------------------------------------------------------
|
|
163 |
//
|
|
164 |
EXPORT_C void CCalenSend::DisplaySendCascadeMenuL()
|
|
165 |
{
|
|
166 |
TRACE_ENTRY_POINT;
|
|
167 |
|
|
168 |
iSelectedMtmUid = iSendUi->ShowSendQueryL( NULL, KCapabilitiesForAllServices, iSendMtmsToDim, KNullDesC );
|
|
169 |
|
|
170 |
TRACE_EXIT_POINT;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
// CCalenSend::SendAsVCalendarL
|
|
175 |
// Send a vCal via SendUi
|
|
176 |
// (other items were commented in a header).
|
|
177 |
// ---------------------------------------------------------
|
|
178 |
//
|
|
179 |
EXPORT_C void CCalenSend::SendAsVCalendarL(TInt /*aCommand*/, CCalEntry& aEntry)
|
|
180 |
{
|
|
181 |
TRACE_ENTRY_POINT;
|
|
182 |
|
|
183 |
// If the user selected email as their protocol, and the entry is a MR, send using MR utils.
|
|
184 |
if( iSelectedMtmUid == KSenduiMtmSmtpUid || iSelectedMtmUid == KSenduiMtmImap4Uid
|
|
185 |
|| iSelectedMtmUid == KSenduiMtmPop3Uid || iSelectedMtmUid == KSenduiMtmSyncMLEmailUid)
|
|
186 |
{
|
|
187 |
// CalenSend can NOT have GlobalData as a member variable
|
|
188 |
CCalenGlobalData* gd = CCalenGlobalData::InstanceL();
|
|
189 |
CleanupReleasePushL(*gd);
|
|
190 |
|
|
191 |
TBool sentUsingMRUtils(EFalse);
|
|
192 |
if( CCalenInterimUtils2::IsMeetingRequestL(aEntry) && gd->InterimUtilsL().MRViewersEnabledL())
|
|
193 |
{
|
|
194 |
gd->MRMailboxUtilsL(); // to create it, if not yet created
|
|
195 |
CMRMailboxUtils::TMailboxInfo info;
|
|
196 |
ASSERT(gd->AttemptToRetrieveDefaultMailboxL(info));
|
|
197 |
// Send using the singleton's MR utils.
|
|
198 |
gd->MeetingRequestUtilsL().SendWithUiL( aEntry, info.iEntryId );
|
|
199 |
sentUsingMRUtils = ETrue;
|
|
200 |
}
|
|
201 |
CleanupStack::PopAndDestroy(gd);
|
|
202 |
|
|
203 |
if (sentUsingMRUtils)
|
|
204 |
{
|
|
205 |
return;
|
|
206 |
}
|
|
207 |
}
|
|
208 |
|
|
209 |
CEikonEnv* eikonEnv = CEikonEnv::Static();
|
|
210 |
CRichText* text = CRichText::NewL(
|
|
211 |
eikonEnv->SystemParaFormatLayerL(),
|
|
212 |
eikonEnv->SystemCharFormatLayerL());
|
|
213 |
CleanupStack::PushL(text);
|
|
214 |
|
|
215 |
TCalenVCalExport exporter(iSession, eikonEnv->FsSession());
|
|
216 |
HBufC8* vcal = exporter.ExportVCalLC(aEntry);
|
|
217 |
|
|
218 |
TUid mtmUid = iSelectedMtmUid;
|
|
219 |
TSendingCapabilities capabilities;
|
|
220 |
iSendUi->ServiceCapabilitiesL( mtmUid, capabilities );
|
|
221 |
|
|
222 |
if (capabilities.iFlags & TSendingCapabilities::ESupportsAttachments)
|
|
223 |
{
|
|
224 |
RFs fs;
|
|
225 |
User::LeaveIfError( fs.Connect() );
|
|
226 |
CleanupClosePushL( fs );
|
|
227 |
// must share the handle between processes
|
|
228 |
User::LeaveIfError( fs.ShareProtected() );
|
|
229 |
|
|
230 |
fs.MkDirAll(KVCalAttachmentFilename);
|
|
231 |
RFile file;
|
|
232 |
User::LeaveIfError(file.Replace(fs,KVCalAttachmentFilename,EFileWrite | EFileShareAny ));
|
|
233 |
CleanupClosePushL(file);
|
|
234 |
TInt spaceNeeded = vcal->Size();
|
|
235 |
if ( SysUtil::FFSSpaceBelowCriticalLevelL( &fs, spaceNeeded ) )
|
|
236 |
{
|
|
237 |
// don't show any own notes here
|
|
238 |
User::Leave( KErrDiskFull );
|
|
239 |
}
|
|
240 |
|
|
241 |
User::LeaveIfError(file.Write(*vcal));
|
|
242 |
|
|
243 |
TParse parse;
|
|
244 |
User::LeaveIfError(parse.SetNoWild(KVCalAttachmentFilename,
|
|
245 |
NULL, NULL));
|
|
246 |
|
|
247 |
TRAPD(err, DoSendAsAttachmentHandleL(file));
|
|
248 |
|
|
249 |
CleanupStack::PopAndDestroy(&file);
|
|
250 |
fs.Delete(parse.FullName());
|
|
251 |
CleanupStack::PopAndDestroy( &fs );
|
|
252 |
User::LeaveIfError(err);
|
|
253 |
}
|
|
254 |
else
|
|
255 |
{
|
|
256 |
TPtrC8 p8(*vcal);
|
|
257 |
HBufC* bufCnv = HBufC::NewLC(p8.Length());
|
|
258 |
TPtr16 des(bufCnv->Des());
|
|
259 |
des.Copy(p8);
|
|
260 |
text->InsertL(0, des);
|
|
261 |
|
|
262 |
CMessageData* messageData = CMessageData::NewL();
|
|
263 |
CleanupStack::PushL( messageData );
|
|
264 |
messageData->SetBodyTextL( text );
|
|
265 |
iISEditorOpen = ETrue;
|
|
266 |
iSendUi->CreateAndSendMessageL( iSelectedMtmUid, messageData, KMsgBioUidVCalendar, ETrue );
|
|
267 |
iISEditorOpen = EFalse;
|
|
268 |
CleanupStack::PopAndDestroy(); // messagedata
|
|
269 |
CleanupStack::PopAndDestroy(bufCnv);
|
|
270 |
}
|
|
271 |
CleanupStack::PopAndDestroy(vcal);
|
|
272 |
CleanupStack::PopAndDestroy(text);
|
|
273 |
|
|
274 |
TRACE_EXIT_POINT;
|
|
275 |
}
|
|
276 |
|
|
277 |
// ---------------------------------------------------------
|
|
278 |
// CCalenSend::IsMessagingEditorOpen
|
|
279 |
// Prcess "Send As" for attachment file
|
|
280 |
// (other items were commented in a header).
|
|
281 |
// ---------------------------------------------------------
|
|
282 |
//
|
|
283 |
|
|
284 |
EXPORT_C TBool CCalenSend::IsMessagingEditorOpen()
|
|
285 |
{
|
|
286 |
TRACE_ENTRY_POINT;
|
|
287 |
|
|
288 |
return iISEditorOpen;
|
|
289 |
|
|
290 |
TRACE_EXIT_POINT;
|
|
291 |
}
|
|
292 |
|
|
293 |
|
|
294 |
// ---------------------------------------------------------
|
|
295 |
// CCalenSend::DoSendAsAttachmentFileL
|
|
296 |
// Prcess "Send As" for attachment file
|
|
297 |
// (other items were commented in a header).
|
|
298 |
// ---------------------------------------------------------
|
|
299 |
//
|
|
300 |
void CCalenSend::DoSendAsAttachmentFileL(TInt /*aCommand*/, TParse& aFilename)
|
|
301 |
{
|
|
302 |
TRACE_ENTRY_POINT;
|
|
303 |
|
|
304 |
CMessageData* messageData = CMessageData::NewL();
|
|
305 |
CleanupStack::PushL( messageData );
|
|
306 |
messageData->AppendAttachmentL( aFilename.FullName() );
|
|
307 |
iISEditorOpen = ETrue;
|
|
308 |
iSendUi->CreateAndSendMessageL( iSelectedMtmUid, messageData, KMsgBioUidVCalendar, ETrue );
|
|
309 |
iISEditorOpen = EFalse;
|
|
310 |
CleanupStack::PopAndDestroy(); // messagedata
|
|
311 |
|
|
312 |
TRACE_EXIT_POINT;
|
|
313 |
}
|
|
314 |
|
|
315 |
// ---------------------------------------------------------
|
|
316 |
// CCalenSend::DoSendAsAttachmentHandleL
|
|
317 |
// We are passing file handle to SendUi
|
|
318 |
// (other items were commented in a header).
|
|
319 |
// ---------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CCalenSend::DoSendAsAttachmentHandleL(const RFile& aHandle)
|
|
322 |
{
|
|
323 |
TRACE_ENTRY_POINT;
|
|
324 |
|
|
325 |
CMessageData* messageData = CMessageData::NewL();
|
|
326 |
CleanupStack::PushL( messageData );
|
|
327 |
messageData->AppendAttachmentHandleL(aHandle);
|
|
328 |
iISEditorOpen = ETrue;
|
|
329 |
iSendUi->CreateAndSendMessageL( iSelectedMtmUid, messageData, KMsgBioUidVCalendar, ETrue );
|
|
330 |
iISEditorOpen = EFalse;
|
|
331 |
CleanupStack::PopAndDestroy( messageData );
|
|
332 |
|
|
333 |
TRACE_EXIT_POINT;
|
|
334 |
}
|
|
335 |
|
|
336 |
// End of File
|