41
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*/
|
|
16 |
#include <QtTest/QtTest>
|
|
17 |
#include <QtDebug>
|
|
18 |
#include <QTimer>
|
|
19 |
#include <QSignalSpy>
|
|
20 |
#include <xqconversions.h>
|
|
21 |
#include <bsp.h>
|
|
22 |
#include <biodb.h>
|
|
23 |
#include <biouids.h>
|
|
24 |
#include <biocmtm.h>
|
|
25 |
#include "convergedmessageaddress.h"
|
|
26 |
|
|
27 |
#include "testunidatamodelvcalplugin.h"
|
|
28 |
#include <unidatamodelloader.h>
|
|
29 |
#include "testunidatamodelvcalplugin.ini"
|
|
30 |
#include "unidatamodelplugininterface.h"
|
|
31 |
#include <convergedmessage.h>
|
|
32 |
|
|
33 |
const TInt KTelephoneNumberMaxLength = 32;
|
|
34 |
_LIT(KBIOTxtFilePath, "C:\\test\\");
|
|
35 |
_LIT(KBIOvCalenderPrefix, "vcal*");
|
|
36 |
// vCalender
|
|
37 |
_LIT(KUnixEpoch, "19700000:000000.000000");
|
|
38 |
#define KBioUidValue 0x10001262
|
|
39 |
|
|
40 |
const TUid KBioUidValueUid =
|
|
41 |
{KBioUidValue};
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
//out put directory for test results.
|
|
47 |
QString OUTPUTDIRECTORY = "c:/logs/TestUniDataModelVCalPlugin";
|
|
48 |
//o/p directory for data to be written on temp file.
|
|
49 |
QString TEMPDIR = "c:/logs/TestUniDataModelVCalPlugin/testdata";
|
|
50 |
//test result O/P file name.
|
|
51 |
QString RESULTFILE = "c:/logs/TestUniDataModelVCalPlugin/result_%1.txt";
|
|
52 |
// folder named UID3 of TestUniDataModelVCalPlugin inside private folder.
|
|
53 |
const QString PRIVATE_DIR("C:/private/Ed034a47");
|
|
54 |
|
|
55 |
//factory method to create objects.
|
|
56 |
QObject* getObject(QString className)
|
|
57 |
{
|
|
58 |
if(className == "TestUniDataModelVCalPlugin" )
|
|
59 |
{
|
|
60 |
return new TestUniDataModelVCalPlugin;
|
|
61 |
}
|
|
62 |
else
|
|
63 |
{
|
|
64 |
return 0;
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
//creating o/p directory.
|
|
69 |
void createOutPutDirectory()
|
|
70 |
{
|
|
71 |
QDir dir;
|
|
72 |
//o/p dir
|
|
73 |
dir.mkdir(OUTPUTDIRECTORY);
|
|
74 |
//tmp dir
|
|
75 |
dir.mkdir(TEMPDIR);
|
|
76 |
// dir inside private folder.
|
|
77 |
dir.mkdir(PRIVATE_DIR);
|
|
78 |
}
|
|
79 |
|
|
80 |
//main entry point
|
|
81 |
int main(int argc, char *argv[])
|
|
82 |
{
|
|
83 |
int ret = -1;
|
|
84 |
QCoreApplication app(argc, argv);
|
|
85 |
|
|
86 |
//creating output directory.
|
|
87 |
createOutPutDirectory();
|
|
88 |
|
|
89 |
//the configuration file.
|
|
90 |
QFile data("c:/TestUniDataModelVCalPlugin.cfg");
|
|
91 |
|
|
92 |
if (data.open(QFile::ReadOnly))
|
|
93 |
{
|
|
94 |
QTextStream in(&data);
|
|
95 |
while(!in.atEnd())
|
|
96 |
{
|
|
97 |
QStringList args;
|
|
98 |
QString appName = argv[0];
|
|
99 |
args << appName;
|
|
100 |
|
|
101 |
QString option = "-o";
|
|
102 |
args << option;
|
|
103 |
|
|
104 |
QString outFile = RESULTFILE;
|
|
105 |
QString name = in.readLine();
|
|
106 |
outFile = outFile.arg(name);
|
|
107 |
args << outFile;
|
|
108 |
|
|
109 |
QObject* tc = getObject(name);
|
|
110 |
|
|
111 |
if(tc)
|
|
112 |
{
|
|
113 |
|
|
114 |
ret = QTest::qExec(tc, args);
|
|
115 |
delete tc;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
}
|
|
119 |
data.close();
|
|
120 |
return ret;
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
//---------------------------------------------------------------
|
|
128 |
// TestUniDataModelVCalPlugin::init
|
|
129 |
//---------------------------------------------------------------
|
|
130 |
|
|
131 |
|
|
132 |
void TestUniDataModelVCalPlugin::initTestCase()
|
|
133 |
{
|
|
134 |
iObserver = new (ELeave) MsgObserver();
|
|
135 |
|
|
136 |
// Create a new messaging server session..
|
|
137 |
iMSession = CMsvSession::OpenSyncL(*iObserver);
|
|
138 |
|
|
139 |
iMsvEntry = iMSession->GetEntryL(KMsvRootIndexEntryId);
|
|
140 |
newEntryId = 0;
|
|
141 |
pluginLoader = new UniDataModelLoader();
|
|
142 |
|
|
143 |
retTimeStamp = QDateTime::currentDateTime();
|
|
144 |
int err = iFs.Connect();
|
|
145 |
QVERIFY(err == 0);
|
|
146 |
iBioDb = CBIODatabase::NewL(iFs);
|
|
147 |
iFs.SetSessionPath(_L("c:\\"));
|
|
148 |
inbox = EFalse;
|
|
149 |
drafts = EFalse;
|
|
150 |
}
|
|
151 |
void TestUniDataModelVCalPlugin::cleanupTestCase()
|
|
152 |
{
|
|
153 |
delete iMsvEntry;
|
|
154 |
iMsvEntry = NULL;
|
|
155 |
delete iObserver;
|
|
156 |
iObserver = NULL;
|
|
157 |
delete iMSession;
|
|
158 |
iMSession = NULL;
|
|
159 |
delete pluginLoader;
|
|
160 |
}
|
|
161 |
|
|
162 |
void TestUniDataModelVCalPlugin::init()
|
|
163 |
{
|
|
164 |
|
|
165 |
}
|
|
166 |
|
|
167 |
//---------------------------------------------------------------
|
|
168 |
// TestUniDataModelVCalPlugin::cleanup
|
|
169 |
//---------------------------------------------------------------
|
|
170 |
void TestUniDataModelVCalPlugin::cleanup()
|
|
171 |
{
|
|
172 |
|
|
173 |
|
|
174 |
}
|
|
175 |
|
|
176 |
void TestUniDataModelVCalPlugin::testInBoxVCalMessage()
|
|
177 |
{
|
|
178 |
inbox = ETrue;
|
|
179 |
GenerateMessagesL();
|
|
180 |
|
|
181 |
pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
|
|
182 |
pluginInterface->setMessageId(newEntryId);
|
|
183 |
|
|
184 |
int count = pluginInterface->attachmentCount();
|
|
185 |
QVERIFY(count == 1);
|
|
186 |
|
|
187 |
UniMessageInfoList attachmentlist = pluginInterface->attachmentList();
|
|
188 |
QVERIFY(!attachmentlist.isEmpty());
|
|
189 |
|
|
190 |
UniMessageInfo* att = attachmentlist.at(0);
|
|
191 |
QString path = att->path();
|
|
192 |
|
|
193 |
QString recepient(TEST_MSG_FROM1);
|
|
194 |
QString fromaddress;
|
|
195 |
pluginInterface->fromAddress(fromaddress);
|
|
196 |
QVERIFY(recepient == fromaddress);
|
|
197 |
|
|
198 |
QString body;
|
|
199 |
pluginInterface->body(body);
|
|
200 |
QVERIFY(!body.isEmpty());
|
|
201 |
|
|
202 |
// Compare input message , with the read message
|
|
203 |
RFile origFile;
|
|
204 |
int op = origFile.Open(iFs, currentFile, EFileRead);
|
|
205 |
QVERIFY(op == 0);
|
|
206 |
|
|
207 |
TBuf8<1000> readBuf;
|
|
208 |
HBufC* readBuf16 = HBufC::NewL(2000);
|
|
209 |
|
|
210 |
origFile.Read(readBuf);
|
|
211 |
readBuf16->Des().Copy(readBuf);
|
|
212 |
|
|
213 |
QString orig = XQConversions::s60DescToQString(*readBuf16);
|
|
214 |
origFile.Close();
|
|
215 |
|
|
216 |
HBufC* filepath = XQConversions::qStringToS60Desc(path);
|
|
217 |
|
|
218 |
int size = pluginInterface->messageSize();
|
|
219 |
|
|
220 |
MsgPriority priority = pluginInterface->messagePriority();
|
|
221 |
// Normal priority
|
|
222 |
qDebug() << "prority" << priority;
|
|
223 |
QVERIFY(priority == 1);
|
|
224 |
|
|
225 |
QVERIFY(pluginInterface->timeStamp() == retTimeStamp);
|
|
226 |
|
|
227 |
ConvergedMessageAddressList recipientList;
|
|
228 |
pluginInterface->toRecipientList(recipientList);
|
|
229 |
QVERIFY(recipientList.count() == 0);
|
|
230 |
qDebug() << "recipientList.count" << recipientList.count();
|
|
231 |
|
|
232 |
if (inbox)
|
|
233 |
{
|
|
234 |
iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
|
|
235 |
qDebug() << "SetEntry" ;
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
}
|
|
240 |
|
|
241 |
void TestUniDataModelVCalPlugin::testDraftsVCalMessage()
|
|
242 |
{
|
|
243 |
drafts = ETrue;
|
|
244 |
GenerateMessagesL();
|
|
245 |
|
|
246 |
pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
|
|
247 |
pluginInterface->setMessageId(newEntryId);
|
|
248 |
|
|
249 |
int count = pluginInterface->attachmentCount();
|
|
250 |
QVERIFY(count == 1);
|
|
251 |
|
|
252 |
UniMessageInfoList attachmentlist = pluginInterface->attachmentList();
|
|
253 |
QVERIFY(!attachmentlist.isEmpty());
|
|
254 |
|
|
255 |
UniMessageInfo* att = attachmentlist.at(0);
|
|
256 |
QString path = att->path();
|
|
257 |
|
|
258 |
QString fromaddress;
|
|
259 |
pluginInterface->fromAddress(fromaddress);
|
|
260 |
QVERIFY(!fromaddress.isEmpty()); //added ! shweta
|
|
261 |
|
|
262 |
QString body;
|
|
263 |
pluginInterface->body(body);
|
|
264 |
QVERIFY(!body.isEmpty());
|
|
265 |
|
|
266 |
// Compare input message , with the read message
|
|
267 |
RFile origFile;
|
|
268 |
int op = origFile.Open(iFs, currentFile, EFileRead);
|
|
269 |
QVERIFY(op == 0);
|
|
270 |
|
|
271 |
TBuf8<1000> readBuf;
|
|
272 |
HBufC* readBuf16 = HBufC::NewL(2000);
|
|
273 |
|
|
274 |
origFile.Read(readBuf);
|
|
275 |
readBuf16->Des().Copy(readBuf);
|
|
276 |
|
|
277 |
QString orig = XQConversions::s60DescToQString(*readBuf16);
|
|
278 |
origFile.Close();
|
|
279 |
|
|
280 |
int size = pluginInterface->messageSize();
|
|
281 |
|
|
282 |
MsgPriority priority = pluginInterface->messagePriority();
|
|
283 |
// Normal priority
|
|
284 |
qDebug() << "prority" << priority;
|
|
285 |
QVERIFY(priority == 1);
|
|
286 |
|
|
287 |
QVERIFY(pluginInterface->timeStamp() == retTimeStamp);
|
|
288 |
|
|
289 |
QString recepient(TEST_MSG_FROM1);
|
|
290 |
ConvergedMessageAddressList recipientList;
|
|
291 |
ConvergedMessageAddress alias(recepient);
|
|
292 |
|
|
293 |
recipientList.append(&alias);
|
|
294 |
pluginInterface->toRecipientList(recipientList);
|
|
295 |
|
|
296 |
QVERIFY( recipientList.count() != 0 );
|
|
297 |
qDebug() << "recipientList.count()"<<recipientList.count() ;
|
|
298 |
|
|
299 |
const QString& copy = recipientList[0]->address();
|
|
300 |
qDebug() << "copy = "<<recipientList[0]->address();
|
|
301 |
QVERIFY(recepient == copy);
|
|
302 |
qDebug() << "Receipient Verified";
|
|
303 |
|
|
304 |
if (drafts)
|
|
305 |
{
|
|
306 |
iMsvEntry->SetEntryL(KMsvDraftEntryId);
|
|
307 |
qDebug() << "SetEntry" ;
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
void TestUniDataModelVCalPlugin::testUnusedAPIs()
|
|
314 |
{
|
|
315 |
pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
|
|
316 |
|
|
317 |
QVERIFY(pluginInterface->objectCount() == 0);
|
|
318 |
|
|
319 |
UniMessageInfoList objectlist = pluginInterface->objectList();
|
|
320 |
QVERIFY(objectlist.isEmpty());
|
|
321 |
|
|
322 |
QVERIFY(pluginInterface->slideCount() == 0);
|
|
323 |
|
|
324 |
UniMessageInfoList slidelist = pluginInterface->slideContent(0);
|
|
325 |
QVERIFY(slidelist.isEmpty());
|
|
326 |
|
|
327 |
QVERIFY(pluginInterface->hasAttachment() == true );
|
|
328 |
|
|
329 |
ConvergedMessageAddressList recipientList;
|
|
330 |
|
|
331 |
pluginInterface->ccRecipientList(recipientList);
|
|
332 |
QVERIFY(recipientList.count() == 0);
|
|
333 |
|
|
334 |
pluginInterface->bccRecipientList(recipientList);
|
|
335 |
QVERIFY(recipientList.count() == 0);
|
|
336 |
}
|
|
337 |
|
|
338 |
CMsvEntrySelection* TestUniDataModelVCalPlugin::GenerateMessagesL()
|
|
339 |
{
|
|
340 |
HBufC* aFileDirectory = KBIOTxtFilePath().AllocL();
|
|
341 |
TMsvId messageId;
|
|
342 |
TBIOMessageType currentMsgType;
|
|
343 |
|
|
344 |
CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection();
|
|
345 |
CleanupStack::PushL(selection);
|
|
346 |
|
|
347 |
TInt err = iFs.GetDir(aFileDirectory->Des(),
|
|
348 |
KEntryAttMatchMask,
|
|
349 |
ESortByName,
|
|
350 |
iDir);
|
|
351 |
if (err == KErrPathNotFound)
|
|
352 |
{
|
|
353 |
TInt makeDirErr = iFs.MkDirAll(aFileDirectory->Des());
|
|
354 |
makeDirErr == KErrNone ? User::Leave(KErrNotFound)
|
|
355 |
: User::Leave(makeDirErr);
|
|
356 |
}
|
|
357 |
else if (err != KErrNone)
|
|
358 |
{
|
|
359 |
User::Leave(err);
|
|
360 |
}
|
|
361 |
|
|
362 |
// Set the session path for the RFs
|
|
363 |
SetSessionPath(aFileDirectory->Des());
|
|
364 |
if (iDir)
|
|
365 |
{
|
|
366 |
delete iDir;
|
|
367 |
iDir = NULL;
|
|
368 |
}
|
|
369 |
|
|
370 |
User::LeaveIfError(iFs.GetDir(_L("*.txt"), KEntryAttNormal, ESortByName, iDir));
|
|
371 |
TInt count = iDir->Count();
|
|
372 |
if (count == 0)
|
|
373 |
{
|
|
374 |
User::Leave(KErrNotFound); // No files to process
|
|
375 |
}
|
|
376 |
|
|
377 |
TBuf<60> outputBuf;
|
|
378 |
|
|
379 |
for (TInt loop = 0; loop < count; loop++)
|
|
380 |
{
|
|
381 |
TEntry as = (*iDir)[0];
|
|
382 |
currentFile = (as.iName);
|
|
383 |
// Not processed all the messages - so keep the current state
|
|
384 |
iFilesProcessed++; // Here because need to update the counter promptly
|
|
385 |
currentMsgType = SetMessageType(currentFile);
|
|
386 |
if (currentMsgType != ENoMessage) // skip any dodgy filenames
|
|
387 |
{
|
|
388 |
messageId = CreateBIOEntryFromFileL(currentFile, currentMsgType);
|
|
389 |
selection->AppendL(messageId);
|
|
390 |
TPtrC tempPtr = (currentFile.Des());
|
|
391 |
|
|
392 |
}
|
|
393 |
}
|
|
394 |
CleanupStack::Pop(); // selection
|
|
395 |
|
|
396 |
return selection;
|
|
397 |
}
|
|
398 |
|
|
399 |
TBIOMessageType TestUniDataModelVCalPlugin::SetMessageType(
|
|
400 |
const TDesC& aFileName)
|
|
401 |
{
|
|
402 |
|
|
403 |
if (aFileName.MatchF(KBIOvCalenderPrefix) == 0)
|
|
404 |
{
|
|
405 |
return EBiovCalenderMessage;
|
|
406 |
}
|
|
407 |
|
|
408 |
return ENoMessage;
|
|
409 |
}
|
|
410 |
|
|
411 |
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryFromFileL(
|
|
412 |
const TDesC& aFilename,
|
|
413 |
TBIOMessageType aMessageType)
|
|
414 |
{
|
|
415 |
//First use the filename to get the message body,
|
|
416 |
// then convert '\n' to the paragraph delimiters used in proper SMS
|
|
417 |
HBufC* tempBuffer;
|
|
418 |
|
|
419 |
tempBuffer = ReadFromFileL(aFilename);
|
|
420 |
CleanupStack::PushL(tempBuffer);
|
|
421 |
|
|
422 |
newEntryId = CreateBIOEntryL(*tempBuffer, aMessageType);
|
|
423 |
|
|
424 |
// Finished with our local descriptors - free up some memory
|
|
425 |
CleanupStack::PopAndDestroy();
|
|
426 |
|
|
427 |
return newEntryId;
|
|
428 |
}
|
|
429 |
|
|
430 |
void TestUniDataModelVCalPlugin::SetSessionPath(const TDesC& aSessionPath)
|
|
431 |
{
|
|
432 |
iFs.SetSessionPath(aSessionPath);
|
|
433 |
}
|
|
434 |
|
|
435 |
HBufC* TestUniDataModelVCalPlugin::ReadFromFileL(const TDesC& aFile)
|
|
436 |
{
|
|
437 |
RFile file;
|
|
438 |
TBuf8<1024> lineBuffer;
|
|
439 |
TInt err = KErrNone;
|
|
440 |
|
|
441 |
err = file.Open(iFs, aFile, EFileStreamText | EFileRead | EFileShareAny);
|
|
442 |
|
|
443 |
if (err != KErrNone) // Didn't find the file, so leave - should only get valid filenames!
|
|
444 |
{
|
|
445 |
User::Leave(KErrNotFound);
|
|
446 |
}
|
|
447 |
|
|
448 |
HBufC* bioBuf = HBufC::NewLC(65535); // Create a new descriptor on the heap.
|
|
449 |
HBufC* copyBuffer = HBufC::NewLC(1024);
|
|
450 |
|
|
451 |
do // Read in the text from file, and also check if there is a name field:
|
|
452 |
{
|
|
453 |
err = file.Read(lineBuffer);// Read upto 256 chars, '\n' and all...
|
|
454 |
//err = ReadLineL(file,lineBuffer);
|
|
455 |
if (err == KErrNone) // Made a valid read,
|
|
456 |
if (lineBuffer.Length() == 0) // but read 0 chars
|
|
457 |
err = KErrEof; // so set err value to end processing
|
|
458 |
|
|
459 |
if (err == KErrNone)
|
|
460 |
{
|
|
461 |
copyBuffer->Des().Copy(lineBuffer);// Copy, and overwrite existing text
|
|
462 |
if ( (bioBuf->Length() + copyBuffer->Length())
|
|
463 |
> bioBuf->Des().MaxLength())
|
|
464 |
{
|
|
465 |
bioBuf = bioBuf->ReAllocL(bioBuf->Length()
|
|
466 |
+ copyBuffer->Length());
|
|
467 |
}
|
|
468 |
bioBuf->Des().Append(*copyBuffer);
|
|
469 |
//bioBuf->Des().Append(_L("\n"));
|
|
470 |
}
|
|
471 |
}while (err != KErrEof);
|
|
472 |
|
|
473 |
CleanupStack::PopAndDestroy(); // Destroy the copyBuffer.
|
|
474 |
CleanupStack::Pop();// Remove the bioBuf.
|
|
475 |
|
|
476 |
file.Close();
|
|
477 |
return bioBuf;
|
|
478 |
}
|
|
479 |
|
|
480 |
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText,
|
|
481 |
TBIOMessageType aMessageType)
|
|
482 |
{
|
|
483 |
// Ensure that we have a valid service ID to work with:
|
|
484 |
TMsvId iBioServiceId;
|
|
485 |
|
|
486 |
iBioServiceId = SetBIOServiceIdL();
|
|
487 |
|
|
488 |
HBufC* localBuffer = aText.AllocL();
|
|
489 |
CleanupStack::PushL(localBuffer);
|
|
490 |
|
|
491 |
TPtr messDes = localBuffer->Des();
|
|
492 |
|
|
493 |
if (aMessageType != EBiovCardMessage && aMessageType
|
|
494 |
!= EBiovCalenderMessage)
|
|
495 |
{
|
|
496 |
// convert \r\n to \n since this is what is expected from SMS when not vCard data
|
|
497 |
for (TInt i = 0; i < messDes.Length(); i++)
|
|
498 |
{
|
|
499 |
if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1
|
|
500 |
&& messDes[i + 1] == (TText) '\n')
|
|
501 |
messDes.Delete(i, 1);
|
|
502 |
}
|
|
503 |
}
|
|
504 |
|
|
505 |
// Create and fill a CRichText object for the jobbie:
|
|
506 |
CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
|
|
507 |
CleanupStack::PushL(paraFormatLayer);
|
|
508 |
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
|
|
509 |
CleanupStack::PushL(charFormatLayer);
|
|
510 |
CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer);
|
|
511 |
CleanupStack::PushL(richText);
|
|
512 |
|
|
513 |
TInt pos = richText->DocumentLength();
|
|
514 |
richText->InsertL(pos, messDes);
|
|
515 |
|
|
516 |
TMsvEntry newBioEntry;
|
|
517 |
newBioEntry.SetNew(ETrue);
|
|
518 |
newBioEntry.SetComplete(EFalse);
|
|
519 |
newBioEntry.SetUnread(ETrue);
|
|
520 |
newBioEntry.SetVisible(ETrue);
|
|
521 |
newBioEntry.SetReadOnly(EFalse);
|
|
522 |
newBioEntry.SetFailed(EFalse);
|
|
523 |
newBioEntry.SetOperation(EFalse);
|
|
524 |
newBioEntry.SetMultipleRecipients(EFalse);
|
|
525 |
newBioEntry.SetAttachment(EFalse);
|
|
526 |
newBioEntry.iMtm = KUidBIOMessageTypeMtm;
|
|
527 |
newBioEntry.iType = KUidMsvMessageEntry;
|
|
528 |
newBioEntry.iServiceId = iBioServiceId;
|
|
529 |
TTime now;
|
|
530 |
now.UniversalTime();
|
|
531 |
newBioEntry.iDate = now;
|
|
532 |
|
|
533 |
TTime unixEpoch(KUnixEpoch);
|
|
534 |
TTimeIntervalSeconds seconds;
|
|
535 |
TTime timeStamp = newBioEntry.iDate;
|
|
536 |
timeStamp.SecondsFrom(unixEpoch, seconds);
|
|
537 |
retTimeStamp.setTime_t(seconds.Int());
|
|
538 |
|
|
539 |
newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength()));
|
|
540 |
TBufC<KTelephoneNumberMaxLength> telNumber;
|
|
541 |
|
|
542 |
QString recepient(TEST_MSG_FROM1);
|
|
543 |
tempNumber = XQConversions::qStringToS60Desc(recepient);
|
|
544 |
|
|
545 |
telNumber = tempNumber->Des();
|
|
546 |
newBioEntry.iDetails.Set(telNumber);
|
|
547 |
|
|
548 |
SetForMtmTypeL(newBioEntry, aMessageType);
|
|
549 |
|
|
550 |
newBioEntry.iSize = richText->DocumentLength();// msgSize;
|
|
551 |
CreateBioEntryClientSideL(newBioEntry, *richText);
|
|
552 |
|
|
553 |
CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer
|
|
554 |
return newBioEntry.Id();
|
|
555 |
}
|
|
556 |
|
|
557 |
void TestUniDataModelVCalPlugin::CreateBioEntryClientSideL(TMsvEntry& aEntry,
|
|
558 |
CRichText& aBody)
|
|
559 |
{
|
|
560 |
if (inbox)
|
|
561 |
{
|
|
562 |
iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
|
|
563 |
}
|
|
564 |
else if (drafts)
|
|
565 |
{
|
|
566 |
iMsvEntry->SetEntryL(KMsvDraftEntryId);
|
|
567 |
}
|
|
568 |
// Get the global inbox.
|
|
569 |
|
|
570 |
iMsvEntry->CreateL(aEntry);
|
|
571 |
iMsvEntry->SetEntryL(aEntry.Id());
|
|
572 |
|
|
573 |
// Save all the changes
|
|
574 |
CMsvStore* store = iMsvEntry->EditStoreL();
|
|
575 |
CleanupStack::PushL(store);
|
|
576 |
|
|
577 |
if (store->HasBodyTextL())
|
|
578 |
{
|
|
579 |
store->DeleteBodyTextL();
|
|
580 |
}
|
|
581 |
|
|
582 |
CPlainText* pText = CPlainText::NewL();
|
|
583 |
CleanupStack::PushL(pText);
|
|
584 |
|
|
585 |
if (inbox)
|
|
586 |
{
|
|
587 |
CSmsHeader* smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *pText);
|
|
588 |
CleanupStack::PushL(smsHeader);
|
|
589 |
smsHeader->SetFromAddressL(*tempNumber);
|
|
590 |
smsHeader->StoreL(*store);
|
|
591 |
|
|
592 |
}
|
|
593 |
else if (drafts)
|
|
594 |
{
|
|
595 |
|
|
596 |
QString recepient(TEST_MSG_FROM1);
|
|
597 |
QString recepient2(TEST_MSG_FROM2);
|
|
598 |
QString alias(TEST_MSG_ALIAS1);
|
|
599 |
|
|
600 |
HBufC* addr = XQConversions::qStringToS60Desc(recepient);
|
|
601 |
HBufC* addr2 = XQConversions::qStringToS60Desc(recepient2);
|
|
602 |
HBufC* alias1 = XQConversions::qStringToS60Desc(alias);
|
|
603 |
|
|
604 |
CSmsHeader* smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *pText);
|
|
605 |
CleanupStack::PushL(smsHeader);
|
|
606 |
|
|
607 |
CSmsNumber* number1 = CSmsNumber::NewL(); // create the instance
|
|
608 |
CleanupStack::PushL(number1);
|
|
609 |
|
|
610 |
number1->SetNameL(TPtrC());
|
|
611 |
number1->SetAddressL(*addr);
|
|
612 |
smsHeader->Recipients().AppendL(number1);
|
|
613 |
CleanupStack::Pop(number1);
|
|
614 |
|
|
615 |
CSmsNumber* number2 = CSmsNumber::NewL();
|
|
616 |
CleanupStack::PushL(number2);
|
|
617 |
|
|
618 |
number2->SetNameL(*alias1);
|
|
619 |
number2->SetAddressL(*addr2);
|
|
620 |
|
|
621 |
smsHeader->Recipients().AppendL(number2);
|
|
622 |
CleanupStack::Pop(number2);
|
|
623 |
smsHeader->StoreL(*store);
|
|
624 |
|
|
625 |
}
|
|
626 |
|
|
627 |
store->StoreBodyTextL(aBody);
|
|
628 |
store->CommitL();
|
|
629 |
|
|
630 |
CleanupStack::PopAndDestroy(3); //store - close the store
|
|
631 |
|
|
632 |
aEntry.SetComplete(ETrue);
|
|
633 |
// Update the entry
|
|
634 |
iMsvEntry->ChangeL(aEntry);
|
|
635 |
iMsvEntry->SetEntryL(KMsvRootIndexEntryId);
|
|
636 |
}
|
|
637 |
|
|
638 |
TMsvId TestUniDataModelVCalPlugin::SetBIOServiceIdL()
|
|
639 |
{
|
|
640 |
// Haven't found an entry so create a BIO Message service:
|
|
641 |
TMsvEntry bioServiceEntry;
|
|
642 |
bioServiceEntry.iMtm = KUidBIOMessageTypeMtm;
|
|
643 |
bioServiceEntry.iType = KUidMsvServiceEntry;
|
|
644 |
bioServiceEntry.SetVisible(EFalse);
|
|
645 |
bioServiceEntry.iDate.UniversalTime();
|
|
646 |
bioServiceEntry.iDescription.Set(_L("BIO Message Service ")); // Is there such a thing?
|
|
647 |
bioServiceEntry.iDetails.Set(_L("BIO Message Service"));
|
|
648 |
|
|
649 |
TMsvId newBIOServiceId;
|
|
650 |
|
|
651 |
iMsvEntry->SetEntryL(KMsvRootIndexEntryId);
|
|
652 |
iMsvEntry->CreateL(bioServiceEntry); // Needs to be a child of the root!
|
|
653 |
newBIOServiceId = bioServiceEntry.Id();
|
|
654 |
|
|
655 |
return newBIOServiceId;
|
|
656 |
}
|
|
657 |
|
|
658 |
void TestUniDataModelVCalPlugin::SetForMtmTypeL(TMsvEntry& aEntry,
|
|
659 |
TBIOMessageType aType)
|
|
660 |
{
|
|
661 |
TInt index;
|
|
662 |
|
|
663 |
aEntry.iBioType = KUidBIOVCalenderMsg;
|
|
664 |
|
|
665 |
// Set other TMsvEntry fields if we have a BIO message type
|
|
666 |
if (aType != ENoMessage)
|
|
667 |
{
|
|
668 |
aEntry.SetMtmData2(0);
|
|
669 |
aEntry.SetMtmData3(0);
|
|
670 |
}
|
|
671 |
|
|
672 |
// set description from BIF file
|
|
673 |
iBioDb->GetBioIndexWithMsgIDL(TUid::Uid(aEntry.iBioType), index);
|
|
674 |
if (index == KErrNotFound)
|
|
675 |
User::Leave(KErrNotFound);
|
|
676 |
aEntry.iDescription.Set(iBioDb->BifReader(index).Description());
|
|
677 |
}
|
|
678 |
|
|
679 |
void MsgObserver::HandleSessionEventL(TMsvSessionEvent /*aEvent*/,
|
|
680 |
TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
|
|
681 |
{
|
|
682 |
}
|