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