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