Revision: 201025
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 14:12:40 +0300
changeset 44 36f374c67aa8
parent 43 35b64624a9e7
child 47 5b14749788d7
child 52 12db4185673b
Revision: 201025 Kit: 2010127
inc/msgcontacthandler.h
messagingapp/conf/backup_registration.xml
messagingapp/conf/messaging_101F87EB.crml
messagingapp/conf/messaging_101F87EC.crml
messagingapp/conf/messaging_101F87ED.crml
messagingapp/conf/messaging_101F87EE.crml
messagingapp/conf/messaging_101F87EF.crml
messagingapp/conf/messaging_101F8873.crml
messagingapp/conf/messaging_101F8F28.crml
messagingapp/conf/messaging_102071F2.crml
messagingapp/conf/messaging_102072E2.crml
messagingapp/conf/messaging_102072E5.crml
messagingapp/conf/messaging_102824A0.crml
messagingapp/conf/messaging_1028281E.crml
messagingapp/conf/messaging_conf.pro
messagingapp/msgappfw/client/bwins/csserverclientapiu.def
messagingapp/msgappfw/client/eabi/csserverclientapiu.def
messagingapp/msgappfw/client/src/ccsnotificationhandler.cpp
messagingapp/msgappfw/client/src/ccsrequesthandler.cpp
messagingapp/msgappfw/client/src/rcssession.cpp
messagingapp/msgappfw/msghistory/tsrc/tsrc.pro
messagingapp/msgappfw/plugins/msgplugin/inc/ccsmsghandler.h
messagingapp/msgappfw/plugins/msgplugin/src/ccsmsghandler.cpp
messagingapp/msgappfw/plugins/previewplugin/src/ccspreviewpluginhandler.cpp
messagingapp/msgappfw/server/backup_registration.xml
messagingapp/msgappfw/server/inc/ccsbackuphandler.h
messagingapp/msgappfw/server/inc/ccscontactsmanager.h
messagingapp/msgappfw/server/inc/ccsconversationcache.h
messagingapp/msgappfw/server/inc/ccsconversationdeletehandler.h
messagingapp/msgappfw/server/inc/ccsconversationevent.h
messagingapp/msgappfw/server/inc/ccsserver.h
messagingapp/msgappfw/server/inc/ccssession.h
messagingapp/msgappfw/server/rom/csserver.iby
messagingapp/msgappfw/server/server.pro
messagingapp/msgappfw/server/src/ccsbackuphandler.cpp
messagingapp/msgappfw/server/src/ccscontactsmanager.cpp
messagingapp/msgappfw/server/src/ccscontactsresolver.cpp
messagingapp/msgappfw/server/src/ccsconversationcache.cpp
messagingapp/msgappfw/server/src/ccsconversationcachehelper.cpp
messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp
messagingapp/msgappfw/server/src/ccsconversationevent.cpp
messagingapp/msgappfw/server/src/ccsconversationmarkreadhandler.cpp
messagingapp/msgappfw/server/src/ccsserver.cpp
messagingapp/msgappfw/server/src/ccssession.cpp
messagingapp/msgappfw/utils/src/ccsdebug.cpp
messagingapp/msgnotifications/msgerrornotifier/src/msgerrornotifiersvc.cpp
messagingapp/msgnotifications/msgnotificationdialogplugin/msgnotificationdialogplugin.pro
messagingapp/msgnotifications/msgnotificationdialogplugin/msgnotificationdialogplugin.qrc
messagingapp/msgnotifications/msgnotificationdialogplugin/resources/mms.svg
messagingapp/msgnotifications/msgnotificationdialogplugin/resources/ringingtone.svg
messagingapp/msgnotifications/msgnotificationdialogplugin/resources/sms.svg
messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp
messagingapp/msgnotifications/msgnotifier/inc/msgnotifier_p.h
messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmsreadfile.h
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestbed.h
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestbed.hrh
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmsteststaticutils.h
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestuitimer.h
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/mmstestbed.pro
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmsreadfile.cpp
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmstestbed.cpp
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmsteststaticutils.cpp
messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmstestuitimer.cpp
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/group/testmmsplugin.pro
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/inc/testmmsplugin.h
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/inc/testmmsplugin.ini
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/mms.rsc
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/not.rsc
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/plugin_commonU.def
messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/src/testmmsplugin.cpp
messagingapp/msgservices/msgserviceapp/inc/msgsendinterface.h
messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h
messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h
messagingapp/msgservices/msgserviceapp/src/msgsendinterface.cpp
messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp
messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp
messagingapp/msgsettings/msginit/src/simscnumberdetector.cpp
messagingapp/msgsettings/settingsview/inc/msgsettingengine.h
messagingapp/msgsettings/settingsview/inc/msgsettingsview.h
messagingapp/msgsettings/settingsview/src/mmssettingsprivate.cpp
messagingapp/msgsettings/settingsview/src/msgsettingsform.cpp
messagingapp/msgsettings/settingsview/src/msgsmscentersettingsform.cpp
messagingapp/msgui/appengine/appengine.pro
messagingapp/msgui/appengine/inc/conversationlistchangehandler.h
messagingapp/msgui/appengine/inc/conversationsengine.h
messagingapp/msgui/appengine/inc/conversationsengine_p.h
messagingapp/msgui/appengine/inc/conversationsmodel.h
messagingapp/msgui/appengine/inc/conversationssummarymodel.h
messagingapp/msgui/appengine/src/conversationchangehandler.cpp
messagingapp/msgui/appengine/src/conversationlistchangehandler.cpp
messagingapp/msgui/appengine/src/conversationsengine.cpp
messagingapp/msgui/appengine/src/conversationsengine_p.cpp
messagingapp/msgui/appengine/src/conversationsmodel.cpp
messagingapp/msgui/appengine/src/conversationssummarymodel.cpp
messagingapp/msgui/appengine/tsrc/testconversationengine/testconversationengine.pro
messagingapp/msgui/bwins/appengineu.def
messagingapp/msgui/bwins/conversationviewu.def
messagingapp/msgui/bwins/msgaudiofetcheru.def
messagingapp/msgui/bwins/unifiededitoru.def
messagingapp/msgui/conversationview/conversationview.pro
messagingapp/msgui/conversationview/inc/msgcontactcardwidget.h
messagingapp/msgui/conversationview/inc/msgconversationbaseview.h
messagingapp/msgui/conversationview/inc/msgconversationview.h
messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.css
messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.widgetml
messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp
messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp
messagingapp/msgui/conversationview/src/msgconversationview.cpp
messagingapp/msgui/conversationview/src/msgconversationviewitem.cpp
messagingapp/msgui/conversationview/src/msgconversationwidget.cpp
messagingapp/msgui/conversationview/src/msgeditorwidget.cpp
messagingapp/msgui/eabi/appengineu.def
messagingapp/msgui/eabi/conversationviewu.def
messagingapp/msgui/eabi/msgaudiofetcheru.def
messagingapp/msgui/eabi/unifiededitoru.def
messagingapp/msgui/inc/msgbaseview.h
messagingapp/msgui/msgapp/inc/msglistview.h
messagingapp/msgui/msgapp/msgapp.pro
messagingapp/msgui/msgapp/resources/icons/qtg_large_message.svg
messagingapp/msgui/msgapp/src/draftslistview.cpp
messagingapp/msgui/msgapp/src/main.cpp
messagingapp/msgui/msgapp/src/msglistview.cpp
messagingapp/msgui/msgapp/src/msglistviewitem.cpp
messagingapp/msgui/msgapp/src/msgviewmanager.cpp
messagingapp/msgui/msgaudiofetcher/inc/msgaudiofetcherview.h
messagingapp/msgui/msgaudiofetcher/src/msgaudiofetcherview.cpp
messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp
messagingapp/msgui/unifiededitor/inc/msgunieditorbody.h
messagingapp/msgui/unifiededitor/inc/msgunieditormonitor.h
messagingapp/msgui/unifiededitor/inc/msgunieditorview.h
messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp
messagingapp/msgui/unifiededitor/src/msgunieditorbody.cpp
messagingapp/msgui/unifiededitor/src/msgunieditormonitor.cpp
messagingapp/msgui/unifiededitor/src/msgunieditorprocessimageoperation.cpp
messagingapp/msgui/unifiededitor/src/msgunieditorsubject.cpp
messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h
messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp
messagingapp/msgui/unifiedviewer/src/univieweraddresswidget.cpp
messagingapp/msgui/unifiedviewer/src/univiewerheadercontainer.cpp
messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp
messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp
messagingapp/msgui/unifiedviewer/src/univiewslidewidget.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsreadfile.h
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.h
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.hrh
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsteststaticutils.h
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestuitimer.h
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/mmstestbed.pro
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsreadfile.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestbed.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsteststaticutils.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestuitimer.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.h
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.ini
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/src/testconvergedmessageutils.cpp
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.cfg
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pl
messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pro
messagingapp/msgutils/convergedmessageutils/tsrc/tsrc.pro
messagingapp/msgutils/unidatautils/unidatamodel/src/UniDataUtils.cpp
messagingapp/msgutils/unidatautils/unidatamodel/src/UniObjectList.cpp
messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilModel.cpp
messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilParams.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/bwins/test_mms_pluginu.def
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmsreadfile.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestbed.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestbed.hrh
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmsteststaticutils.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestuitimer.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/mmstestbed.pro
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmsreadfile.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmstestbed.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmsteststaticutils.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmstestuitimer.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/inc/testmmsplugin.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/inc/testmmsplugin.ini
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/mms.rsc
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/not.rsc
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/src/testmmsplugin.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.cpp
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.ini
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.pro
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmsg.h
messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/tsrc.pro
messagingapp/shareui/inc/shareuiprivate.h
messagingapp/shareui/src/shareuiprivate.cpp
messagingappbase/msgmedia/src/MsgMediaResolver.cpp
messagingappbase/msgmedia/src/MsgVideoInfo.cpp
mmsengine/conf/mmsengine.confml
mmsengine/mmscodec/src/mmsencode.cpp
mmsengine/mmsserversettings/src/mmssettings.cpp
msg_plat/conversation_services_client_api/inc/ccsrequesthandler.h
msg_plat/conversation_services_client_api/inc/mcsconversationlistchangeobserver.h
msg_plat/conversation_services_client_api/inc/rcssession.h
msg_plat/conversation_services_utilities_api/inc/ccsdefs.h
msg_plat/messaging_media_resolver_api/inc/MsgMediaInfo.inl
--- a/inc/msgcontacthandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/inc/msgcontacthandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -53,36 +53,56 @@
                                          int& countPhoneNumber)
     {
         QContactManager phonebookManager;
+        QVariant address(contactNumber);
+
+        // apply filter on phone number field
         QContactDetailFilter phoneFilter;
-        
-        phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName,
-                                            QContactPhoneNumber::FieldNumber);
+        phoneFilter.setDetailDefinitionName(
+                QContactPhoneNumber::DefinitionName,
+                QContactPhoneNumber::FieldNumber);
 
-        QVariant address(contactNumber);
         phoneFilter.setValue(address);
         phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
-
         QList<QContact> matchingContacts =
                 phonebookManager.contacts(phoneFilter);
-
         if (matchingContacts.count() > 0)
         {
             // Fill the contact details
             QContact match = matchingContacts.at(0);
 
             displayName = match.displayLabel();
-            QList<QContactPhoneNumber> numbers = 
+            QList<QContactPhoneNumber> numbers =
                     match.details<QContactPhoneNumber> ();
             countPhoneNumber = numbers.count();
             return match.localId();
         }
-        else // no matching contacts
+
+        // apply filter on email address field
+        QContactDetailFilter emailFilter;
+        emailFilter.setDetailDefinitionName(
+                QContactEmailAddress::DefinitionName,
+                QContactEmailAddress::FieldEmailAddress);
+
+        emailFilter.setValue(address);
+        emailFilter.setMatchFlags(QContactFilter::MatchExactly);
+        matchingContacts = phonebookManager.contacts(emailFilter);
+        if ( matchingContacts.count() > 0 )
         {
-            displayName = contactNumber;
-            return -1;
+            // Fill the contact details
+            QContact match = matchingContacts.at(0);
+
+            displayName = match.displayLabel();
+            QList<QContactEmailAddress> numbers =
+                    match.details<QContactEmailAddress> ();
+            countPhoneNumber = numbers.count();
+            return match.localId();
         }
+
+        // no matching contact
+        displayName = contactNumber;
+        return -1;
     }
-    
+
     /**
      * This shall resolve contact number with display name
      * @param contactNumber number to resolve
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/conf/backup_registration.xml	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration version="1.0">
+    <proxy_data_manager sid = "0x10202BE9" />
+    <restore requires_reboot = "no"/>
+</backup_registration>
Binary file messagingapp/conf/messaging_101F87EB.crml has changed
Binary file messagingapp/conf/messaging_101F87EC.crml has changed
Binary file messagingapp/conf/messaging_101F87ED.crml has changed
Binary file messagingapp/conf/messaging_101F87EE.crml has changed
Binary file messagingapp/conf/messaging_101F87EF.crml has changed
Binary file messagingapp/conf/messaging_101F8873.crml has changed
Binary file messagingapp/conf/messaging_101F8F28.crml has changed
Binary file messagingapp/conf/messaging_102071F2.crml has changed
Binary file messagingapp/conf/messaging_102072E2.crml has changed
Binary file messagingapp/conf/messaging_102072E5.crml has changed
Binary file messagingapp/conf/messaging_102824A0.crml has changed
Binary file messagingapp/conf/messaging_1028281E.crml has changed
--- a/messagingapp/conf/messaging_conf.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/conf/messaging_conf.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -35,6 +35,7 @@
 		"messaging_102072E5.crml APP_LAYER_CRML(messaging_102072E5.crml)" \
 		"messaging_102824A0.crml APP_LAYER_CRML(messaging_102824A0.crml)" \
 		"messaging_1028281E.crml APP_LAYER_CRML(messaging_1028281E.crml)" \
-		"messaging_101F8F28.crml APP_LAYER_CRML(messaging_101F8F28.crml)"
+		"messaging_101F8F28.crml APP_LAYER_CRML(messaging_101F8F28.crml)" \
+		"backup_registration.xml z:/private/2001FE79/backup_registration.xml"
 		}
 
--- a/messagingapp/msgappfw/client/bwins/csserverclientapiu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/client/bwins/csserverclientapiu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -24,4 +24,5 @@
 	?GetConversationIdL@CCSRequestHandler@@QAEHH@Z @ 23 NONAME ; int CCSRequestHandler::GetConversationIdL(int)
 	?NewL@CCSRequestHandler@@SAPAV1@XZ @ 24 NONAME ; class CCSRequestHandler * CCSRequestHandler::NewL(void)
 	?GetConversationFromMessageIdL@CCSRequestHandler@@QAEPAVCCsClientConversation@@H@Z @ 25 NONAME ; class CCsClientConversation * CCSRequestHandler::GetConversationFromMessageIdL(int)
+	?GetConversationFromConversationIdL@CCSRequestHandler@@QAEPAVCCsClientConversation@@H@Z @ 26 NONAME ; class CCsClientConversation * CCSRequestHandler::GetConversationFromConversationIdL(int)
 
--- a/messagingapp/msgappfw/client/eabi/csserverclientapiu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/client/eabi/csserverclientapiu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -30,4 +30,5 @@
 	_ZTV17CCSRequestHandler @ 29 NONAME
 	_ZTV22CCsNotificationHandler @ 30 NONAME
 	_ZTV29CCsConversationChangeObserver @ 31 NONAME
+	_ZN17CCSRequestHandler34GetConversationFromConversationIdLEi @ 32 NONAME
 
--- a/messagingapp/msgappfw/client/src/ccsnotificationhandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/client/src/ccsnotificationhandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -126,7 +126,11 @@
         case EModifyConversationListEvent:
             iRequestHandler->HandleModifyConversationList(iNotificationBuffer);
             break;
-
+            
+        case EPartialDeleteConversationListEvent:
+            iRequestHandler->HandlePartialDeleteConversationList(iNotificationBuffer);
+            break;
+            
         case EAddConversationEvent:
             iRequestHandler->HandleAddConversation(iNotificationBuffer);
             break;
--- a/messagingapp/msgappfw/client/src/ccsrequesthandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/client/src/ccsrequesthandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -178,6 +178,12 @@
         //call panic
         }
     
+    // Speed up the allocation
+    if( listCount > 0 )
+        {
+        clientConversationList.Reserve(listCount);
+        }
+
     for (TInt iloop = 0 ; iloop < listCount; iloop++)
         {
         TRAP(error,
@@ -240,7 +246,12 @@
         {
         //call panic
         }
-
+    // Speed up the allocation
+    if( conversationEntryCount > 0 )
+        {
+        ConversationEntryList.Reserve(conversationEntryCount);
+        }
+    
     PRINT1 ( _L("Number of conversation entries = %d"), conversationEntryCount );
 
     // conversation entries
@@ -319,8 +330,11 @@
     stream.Close();
 
     // Delete and recreate the results buffer
-    delete iListResultsBuffer;
-    iListResultsBuffer = NULL;
+    if ( iListResultsBuffer)
+        {
+        delete iListResultsBuffer;
+        iListResultsBuffer = NULL;
+        }
 
     // Buffer created for the new size
     TRAP(error, 
@@ -370,8 +384,11 @@
     stream.Close();
 
     // Delete and recreate the results buffer
-    delete iConvResultsBuffer;
-    iConvResultsBuffer = NULL;
+    if ( iConvResultsBuffer )
+        {
+        delete iConvResultsBuffer;
+        iConvResultsBuffer = NULL;
+        }
 
     // Buffer created for the new size
     TRAP(error, 
@@ -429,10 +446,14 @@
 EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL(
         MCsConversationListChangeObserver* /*aObserver*/)
     {
-    iConversationListChangeObserver = NULL;
-
-    // De-register from the server           
-    iNotificationHandler->RemoveConversationListChangeEventL();   
+    // Before removing observer, make sure it was added earlier.
+    if( iConversationListChangeObserver )
+        {
+        iConversationListChangeObserver = NULL;
+    
+        // De-register from the server           
+        iNotificationHandler->RemoveConversationListChangeEventL();  
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -466,11 +487,12 @@
         {
         delete iConversationChangeObserver;
         iConversationChangeObserver = NULL;
-        }
-
-    iNotificationHandler->RemoveConversationChangeEventL(aClientConversation);
+        if(aClientConversation)
+            {
+            iNotificationHandler->RemoveConversationChangeEventL(aClientConversation);
+            }
+         }
     }
-
 // -----------------------------------------------------------------------------
 // CCSRequestHandler::RequestCachingStatusEventL()
 // Add caching status Observer
@@ -895,6 +917,50 @@
     }
 
 // -----------------------------------------------------------------------------
+// CCSRequestHandler::HandlePartialDeleteConversationList()
+// Process partial delete conversation lsit event received from server
+// -----------------------------------------------------------------------------
+
+void CCSRequestHandler::HandlePartialDeleteConversationList(HBufC8* aResultsBuffer)
+{
+    PRINT( _L("Enter CCSRequestHandler::HandlePartialDeleteConversationList") );
+
+    TInt error = KErrNone;
+
+    // perpare client conversation
+    CCsClientConversation* clientConversation = NULL;
+    RDesReadStream resultStream(aResultsBuffer->Des());
+
+    TRAP(error,
+        resultStream.PushL();
+        clientConversation = CCsClientConversation::NewL();
+        CleanupStack::PushL(clientConversation);
+        clientConversation->InternalizeL(resultStream);
+        CleanupStack::Pop(clientConversation);
+        resultStream.Pop());
+
+    if ( error != KErrNone )
+        {
+        // Ignore this conversation
+        }
+
+    // Cleanup
+    resultStream.Close();
+    
+    // Pass the results to the observer
+    if ( iConversationListChangeObserver )
+        {
+        CleanupStack::PushL( clientConversation );
+        iConversationListChangeObserver->
+        PartialDeleteConversationList(*clientConversation);
+        }
+    
+    CleanupStack::PopAndDestroy();// clientConversation*/
+
+    PRINT( _L("End CCSRequestHandler::HandlePartialDeleteConversationList") );
+}
+
+// -----------------------------------------------------------------------------
 // CCSRequestHandler::HandleModifyConversationList
 // Process modify conversation lsit event received from server
 // -----------------------------------------------------------------------------
@@ -1198,6 +1264,39 @@
     }
 	
 // -----------------------------------------------------------------------------
+// CCSRequestHandler::GetConversationFromConversationIdL()
+// -----------------------------------------------------------------------------
+EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromConversationIdL(TInt aConversationId)
+{
+    // Create a buffer to store the results.
+    if(iResultsBuffer)
+    {
+        delete iResultsBuffer;
+        iResultsBuffer = NULL;
+    }
+    iResultsBuffer = HBufC8::NewL(KBigIpcBuffer);
+
+    // Send the request
+    iSession.GetConversationFromConversationIdL(aConversationId, iResultsBuffer->Des());
+
+    // Parse the results
+    RDesReadStream resultStream(iResultsBuffer->Des());
+    resultStream.PushL();
+    CCsClientConversation* clientConversation = CCsClientConversation::NewL();
+    CleanupStack::PushL(clientConversation);
+    clientConversation->InternalizeL(resultStream);
+    CleanupStack::Pop(clientConversation);
+
+    // Cleanup
+    delete iResultsBuffer;
+    iResultsBuffer = NULL;
+    resultStream.Pop();
+    resultStream.Close();
+
+    return clientConversation;
+}
+
+// -----------------------------------------------------------------------------
 // CCSRequestHandler::GetConversationFromMessageIdL()
 // -----------------------------------------------------------------------------
 EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromMessageIdL(TInt aMessageId)        
--- a/messagingapp/msgappfw/client/src/rcssession.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/client/src/rcssession.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -397,6 +397,20 @@
     }
 	
 // ----------------------------------------------------------------------------
+// RCsSession::GetConversationFromConversationIdL
+// ----------------------------------------------------------------------------
+void RCsSession::GetConversationFromConversationIdL(TInt aConversationId, TPtr8 aResultsBuffer)
+    {
+    PRINT( _L("Enter RCsSession::GetConversationFromConversationIdL") );
+
+    TIpcArgs args(aConversationId, &aResultsBuffer);
+
+    // Initiate the request
+    User::LeaveIfError (SendReceive(EGetConversationFromConversationId, args ) );
+    PRINT( _L("End RCsSession::GetConversationFromConversationIdL") );
+    }
+
+// ----------------------------------------------------------------------------
 // RCsSession::GetConversationFromMessageIdL
 // ----------------------------------------------------------------------------
 void RCsSession::GetConversationFromMessageIdL(TInt aMessageId, TPtr8 aResultsBuffer)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgappfw/msghistory/tsrc/tsrc.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+
+#Sub .pro files
+SUBDIRS += msghistorytest/msghistorytest.pro
+
+# Platforms
+SYMBIAN_PLATFORMS = DEFAULT
\ No newline at end of file
--- a/messagingapp/msgappfw/plugins/msgplugin/inc/ccsmsghandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/plugins/msgplugin/inc/ccsmsghandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -114,7 +114,13 @@
      * Checks if the MTM type supported
      */
     TBool IsMtmSupported(long uid);
-
+    
+    /**
+     * Read all message Id in iMessageArray
+     * @aFolderId - Folder Id whose message need to be sync.
+     */
+    void UpdateMessageArrayL(const TMsvId& aFolderId);
+    
 private:
 
     /**
@@ -175,11 +181,6 @@
             RPointerArray<HBufC>& addressList);
 
     /**
-     * Cleanup
-     */
-    void CleanupL();
-
-    /**
      * Extracts the Message type based on the MTM value 
      * @param aEntry, TMsvEntry
      */
@@ -232,21 +233,6 @@
     TMsvEntry iPrevEntry;
 
     /**
-     * Root entry
-     */
-    CMsvEntry* iRootEntry;
-
-    /**
-     * Mesage count
-     */
-    TInt iMessageCount;
-
-    /**
-     * Messages under root entry
-     */
-    CMsvEntrySelection* iMessages;
-
-    /**
      * Master array for holding all the messages 
      */
    RArray<TMsvId>* iMessageArray;
--- a/messagingapp/msgappfw/plugins/msgplugin/src/ccsmsghandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/plugins/msgplugin/src/ccsmsghandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -21,6 +21,7 @@
 // USER INCLUDES
 #include "ccsmsghandler.h"
 #include "msgbiouids.h"
+#include "ccsdefs.h"
 
 // SYSTEM INCLUDES
 #include <smsclnt.h>                   
@@ -68,7 +69,12 @@
 CCsMsgHandler::~CCsMsgHandler()
     {
     PRINT ( _L("Enter CCsMsgHandler::~CCsMsgHandler") );
-
+    if(iIdle)
+        {
+        iIdle->Cancel();
+        delete iIdle;
+        iIdle=NULL;
+        }
     if(iMsgPluginUtility)
         {
         delete iMsgPluginUtility;
@@ -107,19 +113,6 @@
         iSession = NULL;
         }
 
-    if ( iRootEntry )
-        {
-        delete iRootEntry;
-        iRootEntry = NULL;
-        }
-
-    if ( iMessages )
-        {
-	    iMessages->Reset();
-        delete iMessages;
-        iMessages = NULL;
-        }
-    
     if(iMessageArray)
     {
         iMessageArray->Reset();
@@ -146,7 +139,7 @@
 
     iMsgPluginUtility = CCsMsgPluginUtility::NewL();
 
-    iConverstationEntryList = new(ELeave)RPointerArray<CCsConversationEntry>();
+    iConverstationEntryList = new(ELeave) RPointerArray<CCsConversationEntry>(1);
 
     iMtmRegistry = CClientMtmRegistry::NewL( *iSession );
 
@@ -160,8 +153,6 @@
 
     iMessageArray = new (ELeave)RArray <TMsvId>(KMessageArrayGranularity);
 
-    iMessageCount = 0;
-
     PRINT ( _L("End CCsMsgHandler::ConstructL") );
     }
 
@@ -201,12 +192,15 @@
          entry.Parent() == KMsvSentEntryIdValue ||
          entry.Parent() == KMsvGlobalOutBoxIndexEntryIdValue )
         {
+        CleanupResetAndDestroyPushL(addressList);
+        
         iMsgPluginUtility->CreateContactL(iSession, entry, addressList);
 
         //process entry
         ExtractAddressesL(entry, ERead, addressList);
-
-        addressList.ResetAndDestroy();	
+        
+        // Cleanup addressList
+        CleanupStack::PopAndDestroy(&addressList);
         }
 
     PRINT ( _L("Exit CCsMsgHandler::ProcessResultsL") );
@@ -348,6 +342,7 @@
             if ( aParent == KMsvSentEntryIdValue ||
                  aParent == KMsvGlobalInBoxIndexEntryIdValue )
                 {
+                CleanupResetAndDestroyPushL(addressList);
                 // currently server needs number, so getting it from header
                 iMsgPluginUtility->CreateContactL(iSession, entry,
                         addressList);
@@ -356,7 +351,7 @@
                 // entry created in sent already exists, hence an update
                 ExtractAddressesL(entry, EUpdate, addressList);
 
-                addressList.ResetAndDestroy();
+                CleanupStack::PopAndDestroy(&addressList);
                 }  
                 
             //for drafts and outbox, the entry changes multiple times,
@@ -372,6 +367,7 @@
                     // as it is going to appear in sent items
                     if( ECsSendStateSent != iMsgPluginUtility->GetSendState(entry) )
                         {
+                         CleanupResetAndDestroyPushL(addressList);
                         // currently server needs number, so getting it from header
                         iMsgPluginUtility->CreateContactL(iSession, entry,
                                 addressList);
@@ -382,7 +378,7 @@
                         
                         iPrevEntry = entry;
                         
-                        addressList.ResetAndDestroy();
+                        CleanupStack::PopAndDestroy(&addressList);
                         }
                     }//end check changed entry
                 }
@@ -408,13 +404,11 @@
 
     if (aContact.Length()>0)
         {
-        contact = aContact.AllocL();
-        CleanupStack::PushL(contact);
+        contact = aContact.AllocLC();
         }
     if (aDescription.Length()>0)
         {
-        sDescription = aDescription.AllocL();
-        CleanupStack::PushL(sDescription);
+        sDescription = aDescription.AllocLC();
         }
 
     //use utility to create conversation entry
@@ -504,7 +498,7 @@
 	      aEntry.iBioType != KUidMsgSubTypeMmsAudioMsg.iUid ) || 
 		  aEntry.iMtm == KSenduiMtmBtUid ) 
         {
-        tmpBuffer = aEntry.iDescription.AllocL();
+        tmpBuffer = aEntry.iDescription.AllocLC();
         description.Set( tmpBuffer->Des() );         
         }    
     else if ( aEntry.iMtm == KSenduiMtmSmsUid )  
@@ -514,7 +508,7 @@
             
         CRichText& body = iSmsMtm->Body();
         TInt smsLength = body.DocumentLength();      
-        tmpBuffer = HBufC::NewL(smsLength);
+        tmpBuffer = HBufC::NewLC(smsLength);
         TPtr ptr(tmpBuffer->Des());
         body.Extract(ptr, 0);
         description.Set( tmpBuffer->Des() );  
@@ -522,7 +516,7 @@
     else if ( aEntry.iMtm == KSenduiMtmMmsUid  || 
 	          aEntry.iMtm == KSenduiMMSNotificationUid)  
         {
-        tmpBuffer = aEntry.iDescription.AllocL();
+        tmpBuffer = aEntry.iDescription.AllocLC();
         description.Set( tmpBuffer->Des() );         
 
         iMmsMtm->SwitchCurrentEntryL( aEntry.Id() );
@@ -568,8 +562,12 @@
         // Unknown
         ProcessEntryL(aEvent, KNullDesC, description, aEntry);       
         }
-
-    delete tmpBuffer;
+    
+    //Cleanup tmpBuffer
+    if ( tmpBuffer )
+        {
+		 CleanupStack::PopAndDestroy();
+        }
 
     PRINT ( _L("Exit CCsMsgHandler::ExtractAddressesL") );
     }
@@ -589,108 +587,59 @@
 // -----------------------------------------------------------------------------
 //
 TInt CCsMsgHandler::UploadMsgL() 
-{
+    {
+    //Release scheduler for scheduling.    
+    User::After(1);
+    
     switch ( iState ) 
-    {
-        case EReadInbox:
         {
-            iRootEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
-
-            // Set sort order
-            TMsvSelectionOrdering order;
-            order.SetSorting(EMsvSortById);
-            iRootEntry->SetSortTypeL(order);
-
-            iMessages = iRootEntry->ChildrenL();
-            iMessageCount = iRootEntry->Count();
-            if(iMessageCount)
+        case EReadInbox:
             {
-                for(int i = 0; i < iMessageCount; i ++)
-                {
-                    iMessageArray->Append(iMessages->At(i));
-                }
+            UpdateMessageArrayL(KMsvGlobalInBoxIndexEntryId);
+            iState = EReadSent;
+            return 1;
             }
 
-            iState = EReadSent;
-            CleanupL();              
-
-            return 1;
-        }
-
         case EReadSent:
-        {
-            iRootEntry = iSession->GetEntryL(KMsvSentEntryId);
-
-            // Set sort order
-            TMsvSelectionOrdering order;
-            order.SetSorting(EMsvSortById);
-            iRootEntry->SetSortTypeL(order);
-
-            iMessages = iRootEntry->ChildrenL();    
-            iMessageCount = iRootEntry->Count();
-            if(iMessageCount)
             {
-                for(int i = 0; i < iMessageCount; i++ )
-                {
-                    iMessageArray->Append(iMessages->At(i));
-                }
+            UpdateMessageArrayL(KMsvSentEntryId);
+            iState = EReadOutbox;
+            return 1;
             }
 
-            iState = EReadOutbox;
-            CleanupL();
-
-            return 1;
-        }
-
         case EReadOutbox:
-        {
-            iRootEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
-
-            // Set sort order
-            TMsvSelectionOrdering order;
-            order.SetSorting(EMsvSortById);
-            iRootEntry->SetSortTypeL(order);
-
-            iMessages = iRootEntry->ChildrenL();  
-            iMessageCount = iRootEntry->Count();
-
-            if(iMessageCount)
             {
-                for(int i = 0; i < iMessageCount; i ++)
-                {
-                    iMessageArray->Append(iMessages->At(i));
-                }
-                iMessageCount=0;
+            UpdateMessageArrayL(KMsvGlobalOutBoxIndexEntryId);
+            iState = ESortEntries;            
+            return 1;
             }
-            iState = ESortEntries;
-            CleanupL();
-
-            return 1;
-        }
         case ESortEntries:
-        {
-             //Sort the elements in the array by descending order of TMsvId's
+            {
+            //Sort the elements in the array by descending order of TMsvId's
             TLinearOrder<TMsvId> order(CompareOrder);
             iMessageArray->Sort(order);
             iState = EProcessEntries;
             return 1;
-        }
-        
+            }            
         case EProcessEntries:
-        { 
+            { 
             //Process one entry at a time in sequence
             //Process the first element in the array on each call, till the end
             if(iMessageArray->Count())
-            {
-                ProcessResultsL(iSession->GetEntryL(iMessageArray->operator[](0))->Entry());
+                {
+                CMsvEntry* msvEntry= iSession->
+                        GetEntryL(iMessageArray->operator[](0));
+                CleanupStack::PushL(msvEntry);
+                ProcessResultsL(msvEntry->Entry());
+                CleanupStack::PopAndDestroy(msvEntry);
                 iMessageArray->Remove(0);
-            }
+                }
             else
-            {
+                {
+                iMessageArray->Reset();
                 iMsgObserver->HandleCachingCompleted();
                 return 0; //DONE 
-            }
-
+                }            
             iState = EProcessEntries;
             return 1; 
         }
@@ -722,36 +671,19 @@
 
     iState = EReadInbox;
     TCallBack callback = TCallBack(UploadMsg, (TAny*) this);
-    iIdle = CIdle::NewL(CActive::EPriorityLow);
+    
+    if(iIdle)
+        {
+        delete iIdle;
+        iIdle = NULL;
+        }
+    iIdle = CIdle::NewL(CActive::EPriorityIdle);
     iIdle->Start(callback);
 
     PRINT ( _L("End CCsMsgHandler::Start") );
     }
 
 // -----------------------------------------------------------------------------
-// CCsMsgHandler::CleanupL()
-// Helper function for state machine cleanup
-// -----------------------------------------------------------------------------
-//
-void CCsMsgHandler::CleanupL()
-    {
-    if ( iRootEntry )
-        {
-        delete iRootEntry;
-        iRootEntry = NULL;
-        }
-
-    if ( iMessages )
-        {
-	    iMessages->Reset();
-        delete iMessages;
-        iMessages = NULL;
-        }
-
-    iMessageCount = 0;     
-    }
-
-// -----------------------------------------------------------------------------
 // CCsMsgHandler::IsMtmSupported()
 // 
 // -----------------------------------------------------------------------------
@@ -835,5 +767,40 @@
     }
     return (type);
 }
+// -----------------------------------------------------------------------------
+// void CCsMsgHandler::UpdateMessageArrayL(const TMsvId& aFolderId)
+// Update iMessageArray with the message ID before upload message to csserver. 
+// -----------------------------------------------------------------------------
+//
+void CCsMsgHandler::UpdateMessageArrayL(const TMsvId& aFolderId)
+    {
+    CMsvEntry* msvEntry = iSession->GetEntryL(aFolderId);
+    CleanupStack::PushL(msvEntry);
+    // Set sort order
+    TMsvSelectionOrdering order;
+    order.SetSorting(EMsvSortById);
+    msvEntry->SetSortTypeL(order);
+
+    CMsvEntrySelection* messages = msvEntry->ChildrenL();  
+    // Cleanup msvEntry
+    CleanupStack::PopAndDestroy(msvEntry);
+    CleanupStack::PushL(messages);
+
+    TInt messageCount = messages->Count();
+    
+    // In case of large number of message caching
+    // to avoid multiple reallocation alloc memory
+    // one shot.
+    if( messageCount > KMessageArrayGranularity)
+        iMessageArray->Reserve(messageCount);
+    
+    for(int i = 0; i < messageCount; i ++)
+        {
+        TMsvId msgId=messages->At(i);
+        iMessageArray->Append(msgId);
+        }
+    // Cleanup messages
+    CleanupStack::PopAndDestroy(messages); 
+    }
 // End of file
 
--- a/messagingapp/msgappfw/plugins/previewplugin/src/ccspreviewpluginhandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/plugins/previewplugin/src/ccspreviewpluginhandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -55,6 +55,9 @@
 _LIT(KRemoveMsgStmnt,"DELETE FROM conversation_messages WHERE message_id=:message_id");
 
 const TInt KDefaultMaxSize = 300 * 1024;
+//Preview thumbnail size
+const TInt KWidth = 9.5 * 6.7;
+const TInt KHeight = 9.5 * 6.7;
 
 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN
 
@@ -362,7 +365,7 @@
                     }
 
                     //image parsing
-                    if (!isImageSet && (mimetype.Find(_L8("image"))
+                    if (!isVideoSet && !isImageSet && (mimetype.Find(_L8("image"))
                             != KErrNotFound))
                     {
                         //get thumbnail for this image
@@ -389,7 +392,7 @@
                     }
 
                     //audio content
-                    if (!isAudioSet && (mimetype.Find(_L8("audio"))
+                    if (!isVideoSet && !isAudioSet && (mimetype.Find(_L8("audio"))
                             != KErrNotFound))
                     {
                         isAudioSet = ETrue;
@@ -405,7 +408,7 @@
                     }
 
                     //video content
-                    if (!isVideoSet && (mimetype.Find(_L8("video"))
+                    if (!( isImageSet || isAudioSet) && !isVideoSet && (mimetype.Find(_L8("video"))
                             != KErrNotFound))
                     {
                         videoPath.Set(mediaInfo->FullFilePath());
@@ -796,7 +799,7 @@
     iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio);
 
     //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels
-    iThumbnailManager->SetThumbnailSizeL(TSize(63.65, 63.65)); 
+    iThumbnailManager->SetThumbnailSizeL(TSize(KWidth, KHeight)); 
     
     //optimize for performace
     iThumbnailManager->SetQualityPreferenceL(
Binary file messagingapp/msgappfw/server/backup_registration.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgappfw/server/inc/ccsbackuphandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <babackup.h>
+#include <f32file.h>
+
+class CCsServer;
+
+class CCsBackUpHandler: public CBase, public MBackupObserver
+{
+public:
+    static CCsBackUpHandler* NewL(CCsServer& aServer);
+    ~CCsBackUpHandler();
+    // from MBackupObserver
+    virtual void ChangeFileLockL(const TDesC& aFileAffected, TFileLockFlags aFlags);
+
+private:
+    void ConstructL();
+    CCsBackUpHandler(CCsServer& aServer);
+    void CloseConversationsDbL();
+    void OpenConversationsDbL();
+
+private:
+    CBaBackupSessionWrapper* iBackup;  
+    TFileName iFileName;
+    CCsServer& iServer;
+};
+
--- a/messagingapp/msgappfw/server/inc/ccscontactsmanager.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccscontactsmanager.h	Tue Jul 06 14:12:40 2010 +0300
@@ -19,6 +19,7 @@
 
 // SYSTEM INCLUDES
 #include <QObject>
+#include <qtcontacts.h>
 #include "qtcontactsglobal.h"
 // USER INCLUDES
 #include "mcscontactsmanagerobserver.h"
--- a/messagingapp/msgappfw/server/inc/ccsconversationcache.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccsconversationcache.h	Tue Jul 06 14:12:40 2010 +0300
@@ -148,8 +148,9 @@
      * 
      * @param aConversationId Conversation Id.
      * @param aDeleted ETrue if conversation is being deleted else EFalse
+	 * @param aCount = 0, count of messages in sending-state/not-deleted
      */
-    void MarkConversationAsDeleted(TInt aConversationId, TBool aDeleted);
+    void MarkConversationAsDeleted(TInt aConversationId, TBool aDeleted, TInt aCount = 0);
 
     /**
      * IsDeleted
@@ -188,6 +189,8 @@
      */
     TInt GetConversationIdFromAddressL(TDesC& aContactAddress);
     
+    CCsClientConversation* GetConversationFromConversationIdL(TInt aConversationId);
+
     /**
      * Get conversation from message-id
      * @param aMessageId Message id
--- a/messagingapp/msgappfw/server/inc/ccsconversationdeletehandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccsconversationdeletehandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -106,6 +106,13 @@
      * Conversation Id currently being deleted.
      */
     TInt iConversationId;
+    
+    /**
+     *  Number of Messages in Sending state that are not deleted
+     */
+    TInt iSendStateMsgs;
+    
+    
     };
 
 #endif // __C_CS_CONVERSATION_DELETE_HANDLER_H__
--- a/messagingapp/msgappfw/server/inc/ccsconversationevent.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccsconversationevent.h	Tue Jul 06 14:12:40 2010 +0300
@@ -115,6 +115,12 @@
      */
     TBool IsDeleteConversationListEventSet() const;
     
+	/**
+	 * Is partial delete conversation event set in this object
+	 * @ retrun TBool
+	 */
+    TBool IsPartialDeleteConversationListEventSet() const;
+    
     /**
      * Is new conversation event set in this object 
      * 
--- a/messagingapp/msgappfw/server/inc/ccsserver.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccsserver.h	Tue Jul 06 14:12:40 2010 +0300
@@ -30,6 +30,7 @@
 class CCsSession;
 class CCsContactsManager;
 class CCsClientConversation;
+class CCsBackUpHandler;
 
 // CLASS DECLARATION
 /** 
@@ -131,7 +132,18 @@
     {
     }
     ;
-
+    
+	/**
+	 * Reload the plugins, once they are unloaded after a 
+	 * backup/ restore
+	 */
+    void LoadPlugins();
+	
+	/**
+	 * Unload the plugins, for backup/ restore
+	 */
+    void DeletePlugins();
+    
 public:
 
     /**
@@ -183,6 +195,11 @@
      * Caching status
      */
     TUint8 iCsCachingStatus;
+    
+    /**
+     * The backup handler class
+     */
+    CCsBackUpHandler* iBackUpHandler;
 };
 
 #endif // __C_CS_SERVER_H
--- a/messagingapp/msgappfw/server/inc/ccssession.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/inc/ccssession.h	Tue Jul 06 14:12:40 2010 +0300
@@ -92,6 +92,13 @@
     void HandleModifyConversationListEventL(
             CCsClientConversation* aClientConversation);      
 
+	/**
+	 * HandlePartialDeleteConversationListEvent
+	 * Handles the partial delete conversation event from cache
+	 */
+    void HandlePartialDeleteConversationListEvent(
+            CCsClientConversation* aClientConversation);
+    
     /**
      * HandleNewConversationEventL
      * Handles the new conversation event received from cache
@@ -329,6 +336,8 @@
      * @param aMessage RMessage instance
      */
     void GetConversationIdfromAddressL(const RMessage2& aMessage);
+
+    void GetConversationFromConversationIdL(const RMessage2& aMessage);
 	
 	/**
      * GetConversationFromMessageIdL
@@ -358,7 +367,7 @@
      * Buf for doing IPC
      * Own
      */
-    HBufC8* des;
+    HBufC8*  iDes;
 
     /**
      * iEventList
--- a/messagingapp/msgappfw/server/rom/csserver.iby	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/rom/csserver.iby	Tue Jul 06 14:12:40 2010 +0300
@@ -21,5 +21,6 @@
 data=DATAZ_\system\install\csserver_stub.sis			system\install\csserver_stub.sis
 
 file=ABI_DIR\BUILD_DIR\csserver.exe            				PROGRAMS_DIR\csserver.exe
+data=EPOCROOT##epoc32\data\Z\private\2002A542\backup_registration.xml		private\2002A542\backup_registration.xml
 
 #endif // __CSSERVER_IBY__
--- a/messagingapp/msgappfw/server/server.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/server.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -25,7 +25,6 @@
                ./../utils/inc \
                ./../../../mmsengine/inc
 
-INCLUDEPATH += /ext/mw/qtextensions/qtmobileextensions/include
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
 SYMBIAN_PLATFORMS = WINSCW ARMV5
@@ -33,9 +32,9 @@
 symbian {
     TARGET.UID3 =  0x2002A542
     TARGET.CAPABILITY = CAP_SERVER
-    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCSTACKSIZE = 0x14000
     VENDORID =  VID_DEFAULT
-    TARGET.EPOCHEAPSIZE = 0x100000 0x500000
+    TARGET.EPOCHEAPSIZE = 0x100000 0x1000000
     VERSION = 1.0
 }
 
@@ -50,7 +49,8 @@
            ccsconversationevent.h \
            ccsconversationcontact.h \                     
            ccsconversationdeletehandler.h \
-           ccsconversationmarkreadhandler.h
+           ccsconversationmarkreadhandler.h \
+           ccsbackuphandler.h
 
 SOURCES += ccsstartup.cpp \
            ccsserver.cpp \
@@ -64,14 +64,16 @@
            ccsconversationevent.cpp \
            ccsconversationcontact.cpp \                      
            ccsconversationdeletehandler.cpp \
-           ccsconversationmarkreadhandler.cpp
+           ccsconversationmarkreadhandler.cpp \
+           ccsbackuphandler.cpp
 
 # Build.inf rules
 BLD_INF_RULES.prj_exports += \
      "$${LITERAL_HASH}include <platform_paths.hrh>" \
      "$${LITERAL_HASH}include <data_caging_paths.hrh>" \
      "rom/csserver.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(csserver.iby)" \
-     "stub_sis/csserver_stub.sis   /epoc32/data/z/system/install/csserver_stub.sis"
+     "stub_sis/csserver_stub.sis   /epoc32/data/z/system/install/csserver_stub.sis" \
+     "backup_registration.xml z:/private/2002A542/backup_registration.xml"
      
 LIBS += -leuser \
         -lcone \
@@ -89,4 +91,4 @@
         -lQtContacts \
         -lxqutils 
         
-        
\ No newline at end of file
+        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgappfw/server/src/ccsbackuphandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,123 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#include "ccsbackuphandler.h"
+#include <e32base.h>
+#include <e32property.h>
+#include <connect/sbdefs.h>
+#include "ccsserver.h"
+#include "ccsdebug.h"
+
+_LIT(KDbFileNamePath,"c:\\private\\10281e17\\[2002A542]conversations.db");
+
+
+// ========================== Member Functions ===============================
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::NewL 
+// ----------------------------------------------------------------------------
+CCsBackUpHandler* CCsBackUpHandler::NewL(CCsServer& aServer)
+{
+    PRINT ( _L("Enter CCsBackUpHandler::NewL") );
+    CCsBackUpHandler* self = new (ELeave) CCsBackUpHandler(aServer);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    PRINT ( _L("Exit CCsBackUpHandler::NewL") );
+    return (self);
+    
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::CCsBackUpHandler 
+// ----------------------------------------------------------------------------
+CCsBackUpHandler::CCsBackUpHandler(CCsServer& aServer): iServer(aServer)
+{
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::~CCsBackUpHandler 
+// destructor
+// ----------------------------------------------------------------------------
+CCsBackUpHandler::~CCsBackUpHandler()
+{
+    // Unregister ourselves with backup server
+    if (iBackup) 
+    {
+        iBackup->DeregisterFile(iFileName);
+        delete iBackup;
+    }
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::ConstructL 
+// The 2-phase constructor
+// ----------------------------------------------------------------------------
+void CCsBackUpHandler::ConstructL()
+{
+    PRINT ( _L("Enter CCsBackUpHandler::ConstructL") );
+    iFileName = KDbFileNamePath;
+    // Create backup session
+    iBackup = CBaBackupSessionWrapper::NewL();
+    // Register with the backup server
+    iBackup->RegisterFileL(iFileName, *this);
+    PRINT ( _L("Exit  CCsBackUpHandler::ConstructL 2") );
+    PRINT1 ( _L("KDbFileNamePath: %S"), &iFileName);
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::ChangeFileLockL 
+// Call back from the backup engine observer when a backup/restore is taking place
+// ----------------------------------------------------------------------------
+void CCsBackUpHandler::ChangeFileLockL(const TDesC& aFileAffected, TFileLockFlags aFlags)
+{
+    PRINT1 ( _L("ChangeFileLockL: %d"), aFlags);
+    PRINT1 ( _L("ChangeFileLockL affected file : %S"), &aFileAffected);
+    switch (aFlags) {
+    case ETakeLock:
+    {
+        OpenConversationsDbL();
+        break;
+    }
+    case EReleaseLockNoAccess:    
+    case EReleaseLockReadOnly:
+    {
+        CloseConversationsDbL();
+        break;
+    }
+    default:
+    {
+        __ASSERT_DEBUG(EFalse,User::Invariant());
+        break;
+    }
+    }
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::CloseConversationsDbL 
+// Unloads the plugins, so that the DB handle is closed
+// ----------------------------------------------------------------------------
+void CCsBackUpHandler::CloseConversationsDbL()
+{
+    iServer.DeletePlugins();
+}
+
+// ----------------------------------------------------------------------------
+// CCsBackUpHandler::OpenConversationsDbL 
+// Loads the plugins, so that the DB handle is again opened
+// ----------------------------------------------------------------------------
+void CCsBackUpHandler::OpenConversationsDbL()
+{
+    iServer.LoadPlugins();
+}
--- a/messagingapp/msgappfw/server/src/ccscontactsmanager.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccscontactsmanager.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -16,7 +16,6 @@
  */
 
 // System includes
-#include "qtcontacts.h" 
 #include <QList>
 // User includes
 #include "ccscontactsmanager.h"
--- a/messagingapp/msgappfw/server/src/ccscontactsresolver.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccscontactsresolver.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -16,7 +16,7 @@
  */
 
 // SYSTEM INCLUDES
-#include "qtcontacts.h" 
+#include "qtcontacts.h"
 #include "qcontactdetailfilter.h"
 #include <QList>
 
@@ -50,21 +50,37 @@
         const QString &address,
         CCsContactDetail &contactDetail)
     {
+    // apply filter on phone number field
     QContactDetailFilter phoneFilter;
     phoneFilter.setDetailDefinitionName(
-            QContactPhoneNumber::DefinitionName, 
+            QContactPhoneNumber::DefinitionName,
             QContactPhoneNumber::FieldNumber);
-    
+
     phoneFilter.setValue(address);
     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
-
     QList<QContact> matchingContacts = mPhonebookManager->contacts(phoneFilter);
+    if ( matchingContacts.count() > 0 ) {
+        QContact match = matchingContacts.at(0);
+        // Fill the contact details
+        contactDetail.contactId = match.localId();
+        contactDetail.displayName = match.displayLabel();
+        return true;
+    }
 
-    if ( matchingContacts.count() > 0 ) {	        
+    // apply filter on email address field
+    QContactDetailFilter emailFilter;
+    emailFilter.setDetailDefinitionName(
+            QContactEmailAddress::DefinitionName,
+            QContactEmailAddress::FieldEmailAddress);
+
+    emailFilter.setValue(address);
+    emailFilter.setMatchFlags(QContactFilter::MatchExactly);
+    matchingContacts = mPhonebookManager->contacts(emailFilter);
+    if ( matchingContacts.count() > 0 ) {
         QContact match = matchingContacts.at(0);
-        // Fill the contact details        
+        // Fill the contact details
         contactDetail.contactId = match.localId();
-        contactDetail.displayName = match.displayLabel();   
+        contactDetail.displayName = match.displayLabel();
         return true;
     }
     return false;
@@ -76,14 +92,14 @@
 // ----------------------------------------------------------------------------
 void CCsContactsResolver::resolveContactId(
         const quint32 &contactId,
-        CCsContactDetail &contactDetail)	
+        CCsContactDetail &contactDetail)
     {
     // Fetch back the persisted contact
     QContact contact = mPhonebookManager->contact(contactId);
-    contactDetail.contactId = contact.localId(); 
-    
+    contactDetail.contactId = contact.localId();
+
     contactDetail.displayName = contact.displayLabel();
-        
+
     QList<QContactPhoneNumber> numbers = contact.details<QContactPhoneNumber>();
     int numberCount = numbers.count();
 
@@ -91,7 +107,16 @@
         {
         QString phoneNumber= numbers.at(a).number();
         contactDetail.addressList.append(phoneNumber);
-        }    
+        }
+
+    QList<QContactEmailAddress> emailAddresses = contact.details<QContactEmailAddress>();
+    int emailCount = emailAddresses.count();
+
+    for ( int a=0; a<emailCount ;++a)
+        {
+        QString emailAddr= emailAddresses.at(a).emailAddress();
+        contactDetail.addressList.append(emailAddr);
+        }
     }
 
 // EOF
--- a/messagingapp/msgappfw/server/src/ccsconversationcache.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsconversationcache.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -405,6 +405,20 @@
         CleanupStack::PopAndDestroy(clientConv);
     }
 
+    // send all CV entry delete events, required in case CV is open
+    // Notify client of conversation change
+    TInt totalEntryCount = conversation->GetEntryCount();
+    for (TInt entryCounter = totalEntryCount - 1; entryCounter >= 0;
+            entryCounter--)
+    {
+        CCsConversationEntry* entryInConversation =
+                conversation->GetEntryL(entryCounter);
+        CCsClientConversation * clientConv =
+                CreateClientConvLC(conversation, entryInConversation);
+        NotifyL(clientConv, KConversationEventDelete);
+        CleanupStack::PopAndDestroy(clientConv);
+    }
+
     iConversationList->Remove(aIndex);
     entryList.ResetAndDestroy();
 
@@ -436,7 +450,7 @@
 // CCsConversationCache::MarkConversationAsDeleted
 // ----------------------------------------------------------------------------
 void CCsConversationCache::MarkConversationAsDeleted(TInt aConversationId,
-                                                     TBool aDeleted)
+                                                     TBool aDeleted, TInt aCount)
 {
     TInt conversationCount = iConversationList->Count();
 
@@ -449,6 +463,14 @@
         if (id == aConversationId)
         {
             conversation->MarkDeleted(aDeleted);
+            if( aCount )
+                {
+                CCsClientConversation* clientConversation =
+                                    CreateClientConvLC(conversation,
+                                                       conversation->GetLatestEntryL());
+                NotifyL(clientConversation, KConversationListEventPartialDelete);
+                CleanupStack::PopAndDestroy();// clientConversation
+                }
             break;
         }
     }
@@ -639,6 +661,29 @@
     }
 
 // ----------------------------------------------------------------------------
+// CCsConversationCache::GetConversationFromConversationId
+// ----------------------------------------------------------------------------
+CCsClientConversation* CCsConversationCache::GetConversationFromConversationIdL(TInt aConversationId)
+    {
+
+    CCsClientConversation* clientConv = NULL;
+
+    for ( TInt loop = 0; loop < iConversationList->Count(); ++loop )
+       {
+        CCsConversation* conversation =
+            static_cast<CCsConversation*>((*iConversationList)[loop]);
+
+            if (aConversationId == conversation->GetConversationId())
+              {
+                clientConv = CreateClientConvLC(conversation, conversation->GetLatestEntryL());
+                CleanupStack::Pop();
+                break;
+              }
+       }
+    return clientConv;
+    }
+
+// ----------------------------------------------------------------------------
 // CCsConversationCache::GetConversationFromMessageIdL
 // ---------------------------------------------------------------------------
 CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId)
--- a/messagingapp/msgappfw/server/src/ccsconversationcachehelper.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsconversationcachehelper.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -523,13 +523,17 @@
             }
 
             // Notify client of conversation change
-            CCsClientConversation
-                    * clientConv =
-                            iConversationCache->CreateClientConvLC(conversation,
-                                                                   aConversationEntry);
-            iConversationCache->NotifyL(clientConv,
-                                        KConversationEventDelete);
-            CleanupStack::PopAndDestroy(clientConv);
+            if (!conversation->IsDeleted())
+            {
+                CCsClientConversation
+                        * clientConv =
+                                iConversationCache->CreateClientConvLC(conversation,
+                                                                       aConversationEntry);
+                iConversationCache->NotifyL(clientConv,
+                                            KConversationEventDelete);
+                CleanupStack::PopAndDestroy(clientConv);
+            }
+
             // check if all entries are deleted then 
             // delete the conversation from cache
             if (conversation->GetEntryCount() == 0
--- a/messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -39,7 +39,9 @@
 // Constructor
 // ----------------------------------------------------------------------------
 CCsConversationDeleteHandler::CCsConversationDeleteHandler():
-        CActive(CActive::EPriorityLow)
+        CActive(CActive::EPriorityLow),
+        iState(EIdle),
+        iConversationEntryList(NULL)
     {
     CActiveScheduler::Add( this );
     }
@@ -50,9 +52,6 @@
 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache)
     {
     iCache = aCache;
-    iState = EIdle;
-     
-    iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
     iSession = CMsvSession::OpenSyncL(*this);
     }
 
@@ -61,6 +60,15 @@
 // ----------------------------------------------------------------------------
 CCsConversationDeleteHandler::~CCsConversationDeleteHandler()
 {
+    // Make sure Aync request cancel.
+    Cancel();
+    
+    if(iSession)
+        {
+        delete iSession;
+        iSession = NULL;
+        }
+    
     if (iConversationEntryList)
     {
         iConversationEntryList->ResetAndDestroy();
@@ -68,13 +76,7 @@
         delete iConversationEntryList;
         iConversationEntryList = NULL;
     }
-
-    if (iSession)
-    {
-        delete iSession;
-        iSession = NULL;
-        }
-    }
+}
 
 // ----------------------------------------------------------------------------
 // Delete set of messages
@@ -96,12 +98,16 @@
     CCsClientConversation* clientConversation = CCsClientConversation::NewL();
     clientConversation->SetConversationEntryId(iConversationId);
     CleanupStack::PushL(clientConversation);
-
+    
+    // Create entry list
+    iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
+    
     // Get conversationlist for given client conversation
     iCache->GetConversationsL (clientConversation, iConversationEntryList);
     iCache->MarkConversationAsDeleted(iConversationId, ETrue);
     
     iDeletedCount = 0;
+    iSendStateMsgs = 0;
     
     // Cleanup  
     CleanupStack::PopAndDestroy(clientConversation);
@@ -124,6 +130,10 @@
         {
         iSession->RemoveEntry(id);
         }
+    else
+        {
+        iSendStateMsgs++;
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -163,10 +173,7 @@
             break;
             
         case EDeleteComplete:
-            // Mark delete complete.
-            iCache->MarkConversationAsDeleted(iConversationId, EFalse);
-            // Done with the processing , cleanup the AO since this is the last 
-            //call to the delete handler.
+            iCache->MarkConversationAsDeleted(iConversationId, EFalse, iSendStateMsgs );
             delete this;
             break;
         }
--- a/messagingapp/msgappfw/server/src/ccsconversationevent.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsconversationevent.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -31,6 +31,8 @@
 // Default constructor
 // ----------------------------------------------------------------------------
 CCsConversationEvent::CCsConversationEvent()
+    :iClientConversation(NULL),
+    iEvent(KConversationEventNone)
     {
     }
 
@@ -40,8 +42,6 @@
 // ----------------------------------------------------------------------------
 void CCsConversationEvent::ConstructL()
     {
-    iClientConversation = NULL;
-    iEvent = KConversationEventNone;
     }
 
 // ----------------------------------------------------------------------------
@@ -164,6 +164,13 @@
     }
 
 // ----------------------------------------------------------------------------
+// CCsConversationEvent::IsPartialDeleteConversationListEventSet
+// ----------------------------------------------------------------------------
+TBool CCsConversationEvent::IsPartialDeleteConversationListEventSet() const
+    {
+    return iEvent & KConversationListEventPartialDelete;
+    }
+// ----------------------------------------------------------------------------
 // CCsNotifyConversationEvent::IsNewConversationEventSet
 // ----------------------------------------------------------------------------
 TBool CCsConversationEvent::IsNewConversationEventSet() const
--- a/messagingapp/msgappfw/server/src/ccsconversationmarkreadhandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsconversationmarkreadhandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -177,7 +177,7 @@
     }
 }
 
-TInt CCsConversationMarkReadHandler::RunError(TInt aError)
+TInt CCsConversationMarkReadHandler::RunError(TInt /*aError*/)
 {
     // RunL left so stop processing the AO and clean it.
     delete this;                     
--- a/messagingapp/msgappfw/server/src/ccsserver.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccsserver.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -29,7 +29,7 @@
 #include "ccsconversationevent.h"
 #include "ccsconversationcache.h"
 #include "ccscontactsmanager.h"
-
+#include "ccsbackuphandler.h"
 //Costant Declaration
 
 // ============================== MEMBER FUNCTIONS ============================
@@ -66,6 +66,33 @@
 }
 
 // ----------------------------------------------------------------------------
+// CCsServer::DeletePlugins
+// Unload the plugins for backup/restore
+// ----------------------------------------------------------------------------
+void CCsServer::DeletePlugins()
+{
+    if (iConversationPlugin) {
+        delete iConversationPlugin;
+        iConversationPlugin = NULL;
+    }
+}
+
+// ----------------------------------------------------------------------------
+// CCsServer::LoadPlugins
+// Load the plugins after a backup/restore
+// ----------------------------------------------------------------------------
+
+void CCsServer::LoadPlugins()
+{
+    iConversationPlugin = CCsPluginInterface::NewL();
+    // Create the plugin for the required entries
+    iConversationPlugin->InstantiatePluginL(this);
+    //fetch all initial set of messages
+    iConversationPlugin->GetConversationsL();
+    RefreshConversations();
+}
+
+// ----------------------------------------------------------------------------
 // CCsServer::ConstructL
 // Second phase constructor
 // ----------------------------------------------------------------------------
@@ -88,7 +115,9 @@
     iConversationCache = CCsConversationCache::NewL(iContactsManager, this);
 
     iCsCachingStatus = KCachingStatusUnknown;
-
+	
+    iBackUpHandler = CCsBackUpHandler::NewL(*this);
+    
     PRINT ( _L("End CCsServer::ConstructL") );
 }
 
@@ -121,6 +150,11 @@
         iContactsManager = NULL;
     }
 
+	if(iBackUpHandler)
+	{
+		delete iBackUpHandler;
+		iBackUpHandler = NULL;
+	}
     REComSession::FinalClose();
 
     PRINT ( _L("End CCsServer::~CCsServer") );
--- a/messagingapp/msgappfw/server/src/ccssession.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/server/src/ccssession.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -58,7 +58,16 @@
 // Construtor
 // ----------------------------------------------------------------------------
 CCsSession::CCsSession(CCsServer* aServer) :
-    iServer(aServer)
+    iServer(aServer),
+	    iDes(NULL),
+	    iMonitoredConversation(NULL),
+	    iBufferOverflow(EFalse),
+	    iGetConversationBufferOverflow( EFalse),
+	    iNotifyHandling(EFalse),
+	    iConversationListChangeObserver(EFalse),
+	    iConversationChangeObserver(EFalse),
+	    iCachingChangeObserver(EFalse),
+	    iReqCnt(1) //Let's start the event ID from 1    
 {
 }
 
@@ -70,21 +79,10 @@
 {
     PRINT ( _L("Enter CCsSession::ConstructL") );
 
-    iBufferOverflow = EFalse;
-    iGetConversationBufferOverflow = EFalse;
-    des = NULL;
-
-    iNotifyHandling = EFalse;
-    iConversationListChangeObserver = EFalse;
-    iConversationChangeObserver = EFalse;
-    iCachingChangeObserver = EFalse;
-    iMonitoredConversation = NULL;
 
     // initialize the event List
     iEventList = new (ELeave) RPointerArray<CCsConversationEvent> ();
 
-    iReqCnt = 1; //Let's start the event ID from 1
-
     PRINT ( _L("End CCsSession::ConstructL") );
 }
 
@@ -96,14 +94,14 @@
 {
     PRINT ( _L("Enter CCsSession::~CCsSession") );
 
-    if (des)
-    {
-        delete des;
-        des = NULL;
-    }
-
-    if (iEventList)
-    {
+    if ( iDes )
+        {
+        delete iDes;
+        iDes = NULL;
+        }
+		
+    if ( iEventList )
+        {
         iEventList->ResetAndDestroy();
         iEventList->Close();
         delete iEventList;
@@ -133,6 +131,12 @@
     // Check the error status returned
     if (errStatus != KErrNone)
     {
+        // Free memory.
+        if(iDes)
+            {
+            delete iDes;
+            iDes=NULL;
+            }
         aMessage.Complete(errStatus);
     }
 }
@@ -228,6 +232,11 @@
             PRINT ( _L("Received function EGetConversationIdFromAddress") )
             GetConversationIdfromAddressL(aMessage);
             break;
+
+        case EGetConversationFromConversationId:
+            PRINT ( _L("Received function EGetConversationFromConversationId") )
+            GetConversationFromConversationIdL(aMessage);
+            break;
 			
 		case EGetConversationFromMessageId:
             PRINT ( _L("Received function EGetConversationFromMessageId") )
@@ -249,6 +258,11 @@
 // ----------------------------------------------------------------------------
 void CCsSession::ServiceError(const RMessage2& aMessage, TInt aError)
 {
+    if(iDes)
+        {
+        delete iDes;
+        iDes=NULL;
+        }
     aMessage.Complete(aError);
 }
 
@@ -267,14 +281,13 @@
     {
         RPointerArray<CCsClientConversation>* ClientConversationList =
                 new (ELeave) RPointerArray<CCsClientConversation> ();
-
+        CleanupResetAndDestroyPushL(ClientConversationList);
         // get cache pointer
         CCsConversationCache* cache = iServer->ConversationCacheInterface();
 
         // Call cache function to get recent conversation entry list
         // with dispaly name for all stored conversation entry ID
         cache->GetConversationListL(ClientConversationList);
-        CleanupStack::PushL(ClientConversationList);
 
         //write all list data into stream
         // create a new buffer for writing into stream
@@ -309,24 +322,19 @@
 
         // --------------------------------------------------------------
         // Create a heap descriptor from the buffer
-        des = HBufC8::NewLC(buf->Size());
-        CleanupStack::Pop(des);
-        TPtr8 ptr(des->Des());
+        iDes = HBufC8::NewL(buf->Size());
+        TPtr8 ptr(iDes->Des());
         buf->Read(0, ptr, buf->Size());
 
-        // cleanup
+        // Cleanup
         CleanupStack::PopAndDestroy(2, buf); // writestream, buf
-        CleanupStack::Pop(ClientConversationList);
-
-        // destroy objects inside list
-        ClientConversationList->ResetAndDestroy();
-        ClientConversationList->Close();
-        delete ClientConversationList;
-        ClientConversationList = NULL;
-    }
+        
+        // Cleanup ClientConversationList
+        CleanupStack::PopAndDestroy(ClientConversationList);
+        }
 
     TInt rcevdBufferSize = aMessage.GetDesMaxLength(1);
-    TInt reqdBufferSize = des->Size();
+    TInt reqdBufferSize  = iDes->Size();
 
     PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize );
     PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize );
@@ -349,13 +357,13 @@
         PRINT ( _L("Adequate buffer received") );
         PRINT ( _L("Packing the results in response") )
 
-        aMessage.Write(1, *des);
+        aMessage.Write(1, *iDes);
         aMessage.Complete(EGetConversationListOperationComplete);
         iBufferOverflow = EFalse;
-        delete des;
-        des = NULL;
-    }
-
+        delete iDes;
+        iDes = NULL;
+        }
+    
     PRINT_TIMESTAMP ("End CCsSession::GetConversationListL");
     PRINT ( _L("End CCsSession::GetConversationListL") );
 }
@@ -375,7 +383,7 @@
         {
         RPointerArray<CCsClientConversation>* ClientConversationList =
                 new (ELeave) RPointerArray<CCsClientConversation> ();
-
+        CleanupResetAndDestroyPushL(ClientConversationList);
         // get cache pointer
         CCsConversationCache* cache = iServer->ConversationCacheInterface();
 
@@ -383,8 +391,6 @@
         // with dispaly name for all stored conversation entry ID
         cache->GetConversationUnreadListL(ClientConversationList);
 
-        CleanupStack::PushL(ClientConversationList);
-
         //write all list data into stream
         // create a new buffer for writing into stream
         CBufFlat* buf = CBufFlat::NewL(KBigBuffer);
@@ -417,24 +423,18 @@
 
         // --------------------------------------------------------------
         // Create a heap descriptor from the buffer
-        des = HBufC8::NewLC(buf->Size());
-        CleanupStack::Pop(des);
-        TPtr8 ptr(des->Des());
+        iDes = HBufC8::NewL(buf->Size());
+        TPtr8 ptr(iDes->Des());
         buf->Read(0, ptr, buf->Size());
 
         // cleanup
         CleanupStack::PopAndDestroy(2, buf); // writestream, buf
-        CleanupStack::Pop(ClientConversationList);
+        CleanupStack::PopAndDestroy(ClientConversationList);
 
-        // destroy objects inside list
-        ClientConversationList->ResetAndDestroy();
-        ClientConversationList->Close();
-        delete ClientConversationList;
-        ClientConversationList = NULL;
         }
 
     TInt rcevdBufferSize = aMessage.GetDesMaxLength(1);
-    TInt reqdBufferSize  = des->Size();
+    TInt reqdBufferSize  = iDes->Size();
 
     PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize );
     PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize );
@@ -458,11 +458,11 @@
 
         TPckgC<TInt> overflowPackage(EFalse);
         aMessage.WriteL(0, overflowPackage);
-        aMessage.Write(1, *des);
+        aMessage.Write(1, *iDes);
         aMessage.Complete(KErrNone);
         iBufferOverflow = EFalse;
-        delete des;
-        des = NULL;
+        delete iDes;
+        iDes = NULL;
         }
 
     PRINT_TIMESTAMP ("End CCsSession::GetConversationUnreadListL");
@@ -502,9 +502,9 @@
         CleanupStack::PopAndDestroy(2, buffer);//stream, buffer
 
         CleanupStack::PushL(ClientConversation);
-        RPointerArray<CCsConversationEntry>* conversationEntryList =
-                new (ELeave) RPointerArray<CCsConversationEntry> ();
-        CleanupStack::PushL(conversationEntryList);
+        RPointerArray<CCsConversationEntry>* conversationEntryList=
+                new (ELeave) RPointerArray<CCsConversationEntry>(10);
+        CleanupResetAndDestroyPushL(conversationEntryList);
 
         // get conversationlist for given ClientConversation 
         cache->GetConversationsL(ClientConversation, conversationEntryList);
@@ -535,24 +535,19 @@
 
         // --------------------------------------------------------------
         // Create a heap descriptor from the buffer
-        des = HBufC8::NewLC(buf->Size());
-        CleanupStack::Pop(des);
-        TPtr8 ptr(des->Des());
+        iDes = HBufC8::NewL(buf->Size());
+        TPtr8 ptr(iDes->Des());
         buf->Read(0, ptr, buf->Size());
 
         CleanupStack::PopAndDestroy(2, buf); // writestream, buf
-        CleanupStack::Pop(conversationEntryList);
-
+     
         // Cleanup
-        conversationEntryList->ResetAndDestroy();
-        conversationEntryList->Close();
-        delete conversationEntryList;
-        conversationEntryList = NULL;
+        CleanupStack::PopAndDestroy(conversationEntryList);
         CleanupStack::PopAndDestroy(ClientConversation);
     }
 
     TInt rcevdBufferSize = aMessage.GetDesMaxLength(1);
-    TInt reqdBufferSize = des->Size();
+    TInt reqdBufferSize  = iDes->Size();
 
     PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize );
     PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize );
@@ -574,12 +569,12 @@
         PRINT ( _L("Adequate buffer received") );
         PRINT ( _L("Packing the results in response") )
 
-        aMessage.Write(1, *des);
+        aMessage.Write(1, *iDes);
         aMessage.Complete(EGetConversationOperationComplete);
         iGetConversationBufferOverflow = EFalse;
-        delete des;
-        des = NULL;
-    }
+        delete iDes;
+        iDes = NULL;
+        }
 
     PRINT ( _L("End CCsSession::GetConversationsL") );
 }
@@ -701,6 +696,57 @@
 }
 
 // ----------------------------------------------------------------------------
+// CCsSession::HandlePartialDeleteConversationListEventL
+// Notify client about partial delete conversation event
+// ----------------------------------------------------------------------------
+
+void CCsSession::HandlePartialDeleteConversationListEvent(
+                                                    CCsClientConversation* aClientConversation)
+{
+    PRINT ( _L("Enter CCsSession::HandlePartialDeleteConversationListEvent") );
+
+    if (!iConversationListChangeObserver)
+        return;
+    
+    if (! (iNotifyHandling))
+    {
+        //append in notify list
+        CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL();
+        conversationEvent->SetClientConversationL(*aClientConversation);
+        CleanupStack::PushL(conversationEvent);
+        conversationEvent->SetEvent(KConversationListEventPartialDelete);
+        iEventList->AppendL(conversationEvent);
+        CleanupStack::Pop(conversationEvent);
+    }
+    else
+    {
+        // create a new buffer for writing into stream
+        CBufFlat* buf = CBufFlat::NewL(KBigBuffer);
+        CleanupStack::PushL(buf);
+
+        RBufWriteStream writeStream(*buf);
+        writeStream.PushL();
+
+        //externalize ClientConversation
+        aClientConversation->ExternalizeL(writeStream);
+
+        // Results are already packed in the stream
+        writeStream.CommitL();
+
+        // --------------------------------------------------------------
+        // Create a heap descriptor from the buffer
+        HBufC8* notifyDes = HBufC8::NewLC(buf->Size());
+        TPtr8 ptr(notifyDes->Des());
+        buf->Read(0, ptr, buf->Size());
+
+        iAsyncReqRMessage.Write(1, *notifyDes);
+        iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent);
+        CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf
+        iNotifyHandling = EFalse;
+    }
+}
+
+// ----------------------------------------------------------------------------
 // CCsSession::HandleModifyConversationListEventL
 // Notify client about update conversation event
 // ----------------------------------------------------------------------------
@@ -865,8 +911,7 @@
     // --------------------------------------------------------------
 
     // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    CleanupStack::Pop(des);
+    HBufC8* des = HBufC8::NewL(buf->Size());
     TPtr8 ptr(des->Des());
     buf->Read(0, ptr, buf->Size());
 
@@ -904,8 +949,7 @@
     // --------------------------------------------------------------
 
     // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    CleanupStack::Pop(des);
+    HBufC8* des = HBufC8::NewL(buf->Size());
     TPtr8 ptr(des->Des());
     buf->Read(0, ptr, buf->Size());
 
@@ -1145,8 +1189,8 @@
         // --------------------------------------------------------------
 
         // Create a heap descriptor from the buffer
-        HBufC8* des = HBufC8::NewLC(buf->Size());
-        CleanupStack::Pop(des);
+        HBufC8* des = HBufC8::NewL(buf->Size());
+
         TPtr8 ptr(des->Des());
         buf->Read(0, ptr, buf->Size());
 
@@ -1213,8 +1257,7 @@
             // --------------------------------------------------------------
     
             // Create a heap descriptor from the buffer
-            HBufC8* des = HBufC8::NewLC(buf->Size());
-            CleanupStack::Pop(des);
+            HBufC8* des = HBufC8::NewL(buf->Size());
             TPtr8 ptr(des->Des());
             buf->Read(0, ptr, buf->Size());
     
@@ -1247,6 +1290,10 @@
     {
         iAsyncReqRMessage.Complete(EModifyConversationListEvent);
     }
+    else if(aConversationEvent->IsPartialDeleteConversationListEventSet())
+    {
+        iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent);
+    }
     else if (aConversationEvent->IsNewConversationEventSet())
     {
         iAsyncReqRMessage.Complete(EAddConversationEvent);
@@ -1288,6 +1335,10 @@
     {
         HandleDeleteConversationListEventL(aConversation);
     }
+    else if(aEvent & KConversationListEventPartialDelete)
+    {
+        HandlePartialDeleteConversationListEvent(aConversation);
+    }
     else if (aEvent & KConversationEventNew)
     {
         HandleNewConversationEventL(aConversation);
@@ -1402,8 +1453,7 @@
     writeStream.CommitL();
 
     // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    CleanupStack::Pop(des);
+    HBufC8* des = HBufC8::NewL(buf->Size());
     TPtr8 ptr(des->Des());
     buf->Read(0, ptr, buf->Size());
 
@@ -1414,6 +1464,57 @@
     delete des;
 }
 
+void CCsSession::GetConversationFromConversationIdL(const RMessage2& aMessage)
+{
+    // create a new buffer for writing into stream
+    CBufFlat* buf = CBufFlat::NewL(KBigBuffer);
+    CleanupStack::PushL(buf);
+
+    RBufWriteStream writeStream(*buf);
+    writeStream.PushL();
+
+    // Get the conversation id
+    TInt conversationId = aMessage.Int0();
+    CCsConversationCache* cache = iServer->ConversationCacheInterface();
+    CCsClientConversation* clientConv = cache->GetConversationFromConversationIdL(conversationId);
+
+    // if no conversation exists for given message-id,
+    // create a dummy conversation and complete response
+    if(clientConv == NULL)
+    {
+        //create dummy conversation
+        clientConv = CCsClientConversation::NewL();
+        CleanupStack::PushL(clientConv);
+        clientConv->SetConversationEntryId(-1);
+        CCsConversationEntry* entry = CCsConversationEntry::NewL();
+        CleanupStack::PushL(entry);
+        entry->SetEntryId(-1);
+        clientConv->SetConversationEntryL(entry); // clone
+        CleanupStack::PopAndDestroy(entry);
+    }
+    else
+    {
+        CleanupStack::PushL(clientConv);
+    }
+
+    // Externalize
+    clientConv->ExternalizeL(writeStream);
+
+    // Results are already packed in the stream
+    writeStream.CommitL();
+
+    // Create a heap descriptor from the buffer
+    HBufC8* des = HBufC8::NewL(buf->Size());
+    TPtr8 ptr(des->Des());
+    buf->Read(0, ptr, buf->Size());
+
+    CleanupStack::PopAndDestroy(3, buf); // clientConv, writestream, buf
+
+    aMessage.Write(1, *des);
+    aMessage.Complete(EGetConversationFromConversationIdComplete);
+    delete des;
+}
+
 // ----------------------------------------------------------------------------
 // GetConversationFromMessageIdL
 // ----------------------------------------------------------------------------
@@ -1457,8 +1558,7 @@
     writeStream.CommitL();
     
     // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    CleanupStack::Pop(des);
+    HBufC8* des = HBufC8::NewL(buf->Size());
     TPtr8 ptr(des->Des());
     buf->Read(0, ptr, buf->Size());
     
@@ -1500,8 +1600,7 @@
     writeStream.CommitL();
 
     // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    CleanupStack::Pop(des);
+    HBufC8* des = HBufC8::NewL(buf->Size());
     TPtr8 ptr(des->Des());
     buf->Read(0, ptr, buf->Size());
  
--- a/messagingapp/msgappfw/utils/src/ccsdebug.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgappfw/utils/src/ccsdebug.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -69,19 +69,14 @@
 	  	dbgArr = static_cast<CCsDebugArr*>( Dll::Tls() );
 	}
 
-    if ( dbgArr->IsEmpty() )
-    {
-        delete dbgArr;
-        Dll::SetTls( NULL );
-    }
-    else
+    if ( dbgArr && !(dbgArr->IsEmpty()) )
     {
     	CCsDebug* dbg = dbgArr->Pop();
 		dbg->UnMark(str);
 		delete dbg;			  	
     }
     
-    if ( !dbgArr && dbgArr->IsEmpty() )
+    if ( dbgArr && dbgArr->IsEmpty() )
     {
         delete dbgArr;
         Dll::SetTls( NULL );
--- a/messagingapp/msgnotifications/msgerrornotifier/src/msgerrornotifiersvc.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgnotifications/msgerrornotifier/src/msgerrornotifiersvc.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -31,7 +31,7 @@
 #define LOC_VIEW hbTrId("txt_messaging_button_view")
 #define LOC_CANCEL hbTrId("txt_common_button_cancel")
 #define LOC_SEND_FAILURE hbTrId("txt_messaging_list_message_sending_failed")
-
+#define LOC_MMS_RETRIEVAL_FAILED hbTrId("txt_messaging_dialog_mms_retrieval_failed")
 //---------------------------------------------------------
 // Constructor
 //---------------------------------------------------------
@@ -73,7 +73,7 @@
     int msgType = third.toInt();
     if (msgType == ECsMmsNotification)
     {
-        errorNote.append("Message Retrieval Failed!");//TODO: use logical str name
+        errorNote.append(LOC_MMS_RETRIEVAL_FAILED);
     }
     else
     {
@@ -90,18 +90,18 @@
     messageBox.setAction(actionView,HbDeviceMessageBox::AcceptButtonRole);
 
     QAction* actionQuit = new QAction(LOC_CANCEL,this);
-    actionQuit->setMenuRole(QAction::QuitRole);
-    messageBox.setAction(actionView,HbDeviceMessageBox::RejectButtonRole);
+    messageBox.setAction(actionQuit,HbDeviceMessageBox::RejectButtonRole);
 
     setCurrentRequestAsync();
-    
+
     //Play audio alert when error notification is shown
     mSts->playTone(XQSystemToneService::MessageSendFailureTone);
     
+    // launch Messagebox
     const QAction* result = messageBox.exec();
-
-    // TODO: use XQAiwrequest
-    if (result->menuRole() != QAction::QuitRole) {
+  
+    // if accepted launch view else quit
+    if (messageBox.isAcceptAction(result)) {
         QList<QVariant> args;
         QString serviceName("com.nokia.services.hbserviceprovider");
         QString operation("open(qint64)");
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/msgnotificationdialogplugin.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgnotifications/msgnotificationdialogplugin/msgnotificationdialogplugin.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -32,8 +32,6 @@
 SOURCES += src/msgnotificationdialogplugin.cpp
 SOURCES += src/msgnotificationdialogwidget.cpp
 
-RESOURCES += msgnotificationdialogplugin.qrc
-
 symbian: {
     TARGET.EPOCALLOWDLLDATA = 1
     TARGET.CAPABILITY = CAP_GENERAL_DLL
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/msgnotificationdialogplugin.qrc	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<RCC>
-    <qresource prefix="/" >
-        <file alias="sms.svg" >resources/sms.svg</file>
-        <file alias="mms.svg" >resources/mms.svg</file>  
-        <file alias="ringingtone.svg" >resources/ringingtone.svg</file> 
-    </qresource>
-</RCC>
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/resources/mms.svg	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg width="60" height="80" viewBox="0 0 60 80">
-<linearGradient id="_16" gradientUnits="userSpaceOnUse" x1="29.07" y1="41.3" x2="44.55" y2="71.79">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<path fill="url(#_16)" d="M49.016,37.091c0.002-0.243,0.18-14.048,0.18-14.048s-13.2-2.759-13.444-2.81 c-0.146-0.191-3.754-4.769-3.754-4.769s-3.308,3.02-3.552,3.242c-0.341-0.071-12.516-2.615-12.516-2.615L13,16.895 c0,0,0.193,4.464,0.236,5.455c-0.487-0.268-1.092-0.601-1.092-0.601c-2.808-1.516-5.711-3.083-6.703-6.004l-0.094-0.277 L3.418,15.76L2.31,16.677c0,0,7.204,21.364,7.46,22.125c-0.023,0.003-0.091,0.011-0.091,0.011 c-2.993,0.54-5.909,3.611-6.502,6.846c-0.072,0.392-0.108,0.774-0.108,1.143c0,1.214,0.385,2.272,1.114,3.005 c0.866,0.87,2.125,1.209,3.544,0.955c1.581-0.285,3.172-1.313,4.425-2.76c0.089,1.518,0.754,12.864,0.754,12.864l34.567,9.214 l2.23-2.29l1.248-28.238C50.952,39.552,49.156,37.27,49.016,37.091z M12.067,34.596c0.014,0.248,0.062,1.048,0.062,1.048 l-0.681,0.132L8.188,26.1l0.466-0.02c2.116-0.089,3.901,0.234,5.307,0.96l0.18,0.093l0.232,5.357 C14.373,32.492,12.286,34.396,12.067,34.596z"/>
-<linearGradient id="_17" gradientUnits="userSpaceOnUse" x1="31.15" y1="21.14" x2="31.15" y2="52.27">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<polygon fill="url(#_17)" points="50.598,39.666 48.663,37.21 48.841,23.327 46.32,24.611 46.262,34.159 31.949,15.976 11.708,34.45 29.276,59.111 "/>
-<linearGradient id="_18" gradientUnits="userSpaceOnUse" x1="9.88" y1="14.78" x2="50.13" y2="25.08">
-<stop stop-color="#FFFFFF" offset="0.15"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_18)" points="46.32,24.611 48.841,23.327 15.934,16.451 13.534,17.135 "/>
-<linearGradient id="_19" gradientUnits="userSpaceOnUse" x1="44.2" y1="53.45" x2="25.56" y2="27.32">
-<stop stop-color="#FFFFFF" offset="0.05"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_19)" points="44.98,52.053 15.814,42.759 14.786,18.917 45.296,25.875 "/>
-<linearGradient id="_20" gradientUnits="userSpaceOnUse" x1="42.72" y1="62.47" x2="25.68" y2="41.62">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<path fill="url(#_20)" d="M15.698,39.176c2.905,1.69,8.717,4.592,8.717,4.592l10.229,1.852 c6.33-1.096,9.934,2.101,9.934,2.101L44.57,55.99l-28.473-9.07L15.698,39.176z"/>
-<path fill="#FFFFFF" d="M14.698,25.884l12.66,3.574c0,0,0.498-4.445,0.514-4.448c-1.134-3.994-5.332-3.909-6.059-2.261 c-2.441-2.681-4.211,0.478-4.211,0.478l-3.105-0.808L14.698,25.884z"/>
-<linearGradient id="_21" gradientUnits="userSpaceOnUse" x1="69.49" y1="77.01" x2="12.49" y2="17.68">
-<stop stop-color="#FFFFFF" offset="0.15"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<path fill="url(#_21)" d="M13.36,17.158l1.343,31.076L46.004,58.2l0.346-33.523L13.36,17.158z M44.502,55.311l-28.479-9.062 l-0.954-26.913l29.71,6.763L44.502,55.311z"/>
-<path fill="#115B7E" d="M37.396,41.982c0,0-14.091-2.843-16.311-2.398l3.277,2.841C26.026,43.034,34,44.227,34,44.227 L37.396,41.982z"/>
-<polygon fill="#BFDAE1" points="26.558,40.739 28.2,40.902 31.15,43.898 29.417,43.736 "/>
-<path fill="#298595" d="M24.368,42.408l-3.275-2.861c-0.738,4.539,6.156,6.268,8.631,6.871c5.781,1.275,7.03-1.984,7.668-4.45 C35.027,45.823,25.01,42.932,24.368,42.408z"/>
-<path fill="#CFECFF" d="M21.09,39.568l3.275,2.907c9.263,3.502,11.865,1.424,13.027-0.507 C34.404,41.021,23.302,39.122,21.09,39.568z M24.622,42.031l-2.455-2.148c1.853-0.195,12.074,1.387,14.62,2.193 C35.422,43.964,31.639,44.707,24.622,42.031z"/>
-<linearGradient id="_22" gradientUnits="userSpaceOnUse" x1="28.28" y1="32.08" x2="17.62" y2="31.3">
-<stop stop-color="#2B98A0" offset="0"/>
-<stop stop-color="#0A4A60" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_22)" points="28.434,41.582 28.821,22.619 20.849,36.979 "/>
-<polygon fill="#2F8E9A" points="29.49,42.729 28.971,26.357 34.188,42.412 "/>
-<linearGradient id="_23" gradientUnits="userSpaceOnUse" x1="48.98" y1="41.75" x2="48.98" y2="77.75">
-<stop stop-color="#DEE9F3" offset="0"/>
-<stop stop-color="#235487" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_23)" points="47.365,69.689 49.359,67.643 50.598,39.666 47.848,41.723 "/>
-<linearGradient id="_24" gradientUnits="userSpaceOnUse" x1="14.35" y1="22.25" x2="34.6" y2="43.5">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_24)" points="47.848,41.723 33.469,50.964 28.481,49.768 11.708,34.447 27.026,51.219 32.658,52.456 "/>
-<linearGradient id="_25" gradientUnits="userSpaceOnUse" x1="41.79" y1="6.95" x2="19.04" y2="90.7">
-<stop stop-color="#FFFFFF" offset="0.15"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_25)" points="47.848,41.723 32.441,52.41 26.95,50.989 11.708,34.45 13.241,60.593 47.365,69.689 "/>
-<linearGradient id="_26" gradientUnits="userSpaceOnUse" x1="5.62" y1="67.79" x2="25.37" y2="51.04">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.53"/>
-<stop stop-color="#6C83BB" offset="0.87"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_26)" points="13.255,60.582 25.621,49.561 26.919,50.98 "/>
-<linearGradient id="_27" gradientUnits="userSpaceOnUse" x1="49.93" y1="73.86" x2="35.68" y2="54.87">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.53"/>
-<stop stop-color="#6C83BB" offset="0.87"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<polygon fill="url(#_27)" points="47.384,69.659 34.361,51.236 32.441,52.41 "/>
-<linearGradient id="_28" gradientUnits="userSpaceOnUse" x1="20.65" y1="0.35" x2="1.28" y2="57.72">
-<stop stop-color="#E6EEF4" offset="0"/>
-<stop stop-color="#A3740A" offset="0.44"/>
-<stop stop-color="#474105" offset="0.94"/>
-</linearGradient>
-<path fill="url(#_28)" d="M18.344,27.406C16.046,22.166,7.092,21.7,5.107,15.857c0-0.001-0.916,0.818-0.916,0.818 l7.613,22.598l2.155,2.863l-6.151-18.26l9.799,4.177c0,0,0.716,10.753,0.708,10.754l0.507-0.613 C19.839,34.412,19.658,29.728,18.344,27.406z"/>
-<polygon fill="#6D5607" points="2.719,16.793 4.183,16.679 5.106,15.858 3.566,16.091 "/>
-<path fill="#6D5607" d="M17.695,28.032c-3.77-6.2-10.994-4.212-13.51-11.337l-1.467,0.099l7.516,22.292l1.569,0.189L7.505,26.499 c9.891-1.063,10.806,6.229,9.826,12.022l0.992,0.286C19.276,35.021,19.036,30.337,17.695,28.032z"/>
-<radialGradient id="_29" gradientUnits="userSpaceOnUse" cx="8.12" cy="44.13" r="4.15">
-<stop stop-color="#E6EEF4" offset="0"/>
-<stop stop-color="#A3740A" offset="0.44"/>
-<stop stop-color="#474105" offset="0.94"/>
-</radialGradient>
-<path fill="url(#_29)" d="M13.886,43.857c-0.572,3.104-3.355,6.041-6.22,6.56c-2.86,0.513-4.717-1.59-4.144-4.694 c0.57-3.104,3.355-6.048,6.22-6.563C12.602,38.646,14.459,40.745,13.886,43.857z"/>
-<linearGradient id="_30" gradientUnits="userSpaceOnUse" x1="11" y1="25.7" x2="6.63" y2="3.59">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<path fill="url(#_30)" d="M14.016,32.378l-0.2-5.026c-2.068-1.156-5.16-0.934-5.16-0.934l3.136,9.274l-0.083-1.242 L14.016,32.378z M9.186,26.812c0,0,2.604-0.188,4.347,0.787l0.168,4.58l-2.042,1.868L9.186,26.812z"/>
-</svg>
\ No newline at end of file
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/resources/ringingtone.svg	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg width="84" height="58" viewBox="0 0 84 58">
-<linearGradient id="_63" gradientUnits="userSpaceOnUse" x1="58.89" y1="32.29" x2="47.46" y2="54.8">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<path fill="url(#_63)" d="M50.352,2.42l-0.033,0.031h-0.021c-5.285,0.285-9.418,11.98-9.418,26.625 c0,14.652,3.979,26.092,9.34,26.643h4.996c2.131,0,4.117-1.807,5.758-5.184c0.346-0.199,11.242-6.574,11.441-6.697 c0.359,0.002,3.687,0.006,4.562,0.006c1.478,0,3.543-0.817,5.007-4.725c0.941-2.527,1.467-5.91,1.467-9.523 c0-6.525-1.715-13.109-5.547-13.109c0,0-4.617-0.059-5.055-0.064C72.563,16.205,60.8,7.319,60.8,7.319 c-1.607-3.166-3.521-4.902-5.59-4.902C55.211,2.416,50.352,2.42,50.352,2.42z M71.582,42.778l-0.012-0.005 c0,0,0.014-0.013,0.016-0.013C71.584,42.768,71.584,42.773,71.582,42.778z"/>
-<linearGradient id="_64" gradientUnits="userSpaceOnUse" x1="23.27" y1="39.8" x2="29.04" y2="51.16">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<path fill="url(#_64)" d="M17.562,28.336c0,0,0.029,15.633,0.029,17.166c-2.504-0.234-5.418,1.236-6.758,3.471 c-0.734,1.229-0.873,2.525-0.377,3.566c0.467,1,1.451,1.66,2.746,1.858c2.557,0.392,5.662-1.121,7.057-3.444 c0.439-0.729,0.66-1.488,0.66-2.215c0-0.105,0-9.92,0.004-10.86c0.828-0.254,8.742-2.697,10.209-3.144 c0.006,1.358,0.025,6.089,0.029,7.347c-2.527-0.289-5.496,1.203-6.854,3.457c-0.732,1.223-0.877,2.526-0.385,3.564 c0.469,1.005,1.449,1.662,2.742,1.859c2.564,0.397,5.672-1.117,7.061-3.445c0.475-0.791,0.705-1.629,0.654-2.426 c0.027,0.082,0.031-21.328,0.031-21.328L17.562,28.336z M20.912,33.031l0.037-1.875l10.15-3l0.037,1.969L20.912,33.031z"/>
-<linearGradient id="_65" gradientUnits="userSpaceOnUse" x1="8.43" y1="17.5" x2="13.41" y2="27.31">
-<stop stop-color="#A2C2DD" offset="0.1"/>
-<stop stop-color="#6C83BB" offset="0.71"/>
-<stop stop-color="#003D6D" offset="0.99"/>
-</linearGradient>
-<path fill="url(#_65)" d="M10.357,4.115c0,0,0.059,15.676,0.066,17.59c-0.09-0.043-0.285-0.129-0.285-0.129 c-2.498-0.621-5.703,0.594-7.293,2.768c-0.832,1.143-1.09,2.414-0.699,3.486c0.375,1.03,1.277,1.771,2.543,2.088 c2.496,0.621,5.699-0.594,7.291-2.764c0.529-0.719,0.822-1.512,0.861-2.299v-0.014l0.035,0.047c0,0,0.02-9.523,0.027-11.434 c1.617,0.777,2.738,1.641,3.152,2.742c0.164,0.43,0.235,0.906,0.246,1.426c0.05,2.549-1.719,5.125-1.719,5.125l1.664,1.191 l0.383-0.674c5.229-8.719-1.746-13.855-1.746-13.855c-1.194-1.27-2.147-2.294-2.209-4.645l-0.016-0.697L10.357,4.115z"/>
-<linearGradient id="_66" gradientUnits="userSpaceOnUse" x1="74.45" y1="14.49" x2="80.52" y2="55.82">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<path fill="url(#_66)" d="M76.977,43.148c-3.813,0,1.066-0.009-4.766-0.009c4.779-16.506-0.037-26.047-0.037-26.047 s0.111,0.068,5.729,0.094C84.465,17.188,84.563,43.148,76.977,43.148z"/>
-<linearGradient id="_67" gradientUnits="userSpaceOnUse" x1="50.98" y1="-8.01" x2="61.11" y2="70.44">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<path fill="url(#_67)" d="M50.219,55.023h4.611c0.057,0,0.311,0,0.385,0c4.922,0,8.918-11.62,8.918-25.95 c0-14.334-3.992-25.958-8.918-25.958c-0.049,0-0.098,0.02-0.146,0.023C55.033,3.134,55,3.115,54.963,3.115h-4.615 C49.453,3.115,49.32,55.028,50.219,55.023z"/>
-<linearGradient id="_68" gradientUnits="userSpaceOnUse" x1="44.01" y1="3.76" x2="54.2" y2="43.53">
-<stop stop-color="#FFFFFF" offset="0.05"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<ellipse fill="url(#_68)" cx="50.498" cy="29.072" rx="8.92" ry="25.951"/>
-<linearGradient id="_69" gradientUnits="userSpaceOnUse" x1="17.85" y1="19.4" x2="53.78" y2="29.8">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<ellipse fill="url(#_69)" cx="50.25" cy="28.776" rx="7.582" ry="22.063"/>
-<linearGradient id="_70" gradientUnits="userSpaceOnUse" x1="48.39" y1="29.87" x2="64.59" y2="29.87">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#A2C2DD" offset="0.35"/>
-<stop stop-color="#6C83BB" offset="0.7"/>
-<stop stop-color="#003D6D" offset="1"/>
-</linearGradient>
-<path fill="url(#_70)" d="M57.133,19.283c-10.832,2.801-10.906,17.543-0.467,21.167 C57.445,36.153,58.727,28.428,57.133,19.283z"/>
-<linearGradient id="_71" gradientUnits="userSpaceOnUse" x1="60.77" y1="1.82" x2="67.04" y2="35.32">
-<stop stop-color="#FFFFFF" offset="0.05"/>
-<stop stop-color="#A2C2DD" offset="1"/>
-</linearGradient>
-<path fill="url(#_71)" d="M72.174,43.172c-4.053,2.31-5.025,3.236-11.775,6.889c7.934-22.026,0-42.171,0-42.171 l12.182,9.205C72.578,17.094,77.602,29.258,72.174,43.172z"/>
-<path fill="#58A015" d="M11.131,23.658l-0.07-18.859l0.924-0.02c0.064,2.68,1.224,3.856,2.394,5.106 c2.654,2.84,5.955,5.496,1.652,13.033l-0.537-0.385c3.109-5.91,1.119-8.543-3.293-10.238c0,0-0.027,10.623-0.027,12.594 C11.732,23.776,11.131,23.658,11.131,23.658z"/>
-<path fill="#A15EB6" d="M33.701,45.18c-0.008-2.008,0.004-20.498,0.004-20.498l-15.441,4.191l0.031,18.166 c0,0,1.158-0.227,1.928,1.471c0-1.998,0-11.146,0-11.146l11.604-3.578l0.039,9.86C31.857,43.646,32.838,43.371,33.701,45.18z M20.223,34.066v-3.474l11.604-3.217v3.279L20.223,34.066z"/>
-<radialGradient id="_72" gradientUnits="userSpaceOnUse" cx="7.81" cy="25.18" r="3.46">
-<stop stop-color="#DCE8E4" offset="0"/>
-<stop stop-color="#43910A" offset="1"/>
-</radialGradient>
-<path fill="url(#_72)" d="M11.424,26.74c-1.414,1.928-4.344,3.047-6.555,2.499c-2.207-0.549-2.855-2.556-1.445-4.482 c1.41-1.927,4.344-3.051,6.549-2.5C12.178,22.803,12.834,24.817,11.424,26.74z"/>
-<radialGradient id="_73" gradientUnits="userSpaceOnUse" cx="15.45" cy="48.88" r="3.31">
-<stop stop-color="#DEDEED" offset="0"/>
-<stop stop-color="#9646AC" offset="1"/>
-</radialGradient>
-<path fill="url(#_73)" d="M19.658,50.596c-1.242,2.066-4.082,3.459-6.355,3.115c-2.273-0.348-3.107-2.301-1.871-4.375 c1.238-2.066,4.086-3.461,6.359-3.117C20.059,46.569,20.896,48.528,19.658,50.596z"/>
-<radialGradient id="_74" gradientUnits="userSpaceOnUse" cx="30.34" cy="45.16" r="3.27">
-<stop stop-color="#DEDEED" offset="0"/>
-<stop stop-color="#9646AC" offset="1"/>
-</radialGradient>
-<path fill="url(#_74)" d="M33.123,47.162c-1.238,2.066-4.086,3.463-6.359,3.114c-2.266-0.349-3.105-2.306-1.859-4.375 c1.232-2.063,4.078-3.464,6.355-3.116C33.529,43.133,34.365,45.094,33.123,47.162z"/>
-</svg>
\ No newline at end of file
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/resources/sms.svg	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" height="40px" version="1.1" viewBox="0 0 30 40" width="30px" x="0px" y="0px">
-<g>
-<path d="M27.458,17.31l-0.81-0.416l0.81-0.418c0.624-0.317,0.62-1.024,0.405-1.392l-0.881-1.512   c-0.251-0.43-0.877-0.683-1.406-0.336l-0.748,0.484l0.051-0.892c0.025-0.453-0.309-1.056-0.998-1.056h-1.764   c-0.57,0-1.031,0.48-0.998,1.056l0.051,0.892l-0.748-0.484c-0.402-0.263-1.08-0.22-1.406,0.336l-0.879,1.512   c-0.219,0.376-0.126,0.735-0.049,0.916H6C4.346,16,3,17.345,3,19v12c0,1.621,1.293,2.944,2.901,2.997v2.695   c0,1.407,1.723,2.251,2.869,1.029l3.063-3.723h11.165C24.654,33.999,26,32.653,26,31V20.706c0.185,0.031,0.699-0.003,0.982-0.487   l0.881-1.516C28.278,17.989,27.701,17.435,27.458,17.31z" fill-opacity="0.2" stroke-opacity="0.2"/>
-<path d="M27,15.588l-0.882-1.512c0,1.023-6.239,1.58-6.239,0L19,15.588l7.118,4.126L27,18.199l-2.536-1.305   L27,15.588z" fill-opacity="0.5" stroke-opacity="0.5"/>
-<path d="M4,26.718V31c0,1.101,0.9,2,2,2h0.901v3.692c0,0.517,0.646,0.86,1.098,0.394L11.362,33H23c1.1,0,2-0.899,2-2   v-4.282c0-0.004-0.001-0.007-0.001-0.011L4,26.718z" fill-opacity="0.5" stroke-opacity="0.5"/>
-<linearGradient gradientTransform="matrix(1 0 0 1 -1530 0)" gradientUnits="userSpaceOnUse" id="SVGID_1_" x1="1544.5" x2="1544.5" y1="13.4609" y2="38.8497">
-<stop offset="0" style="stop-color:#FFE23D"/>
-<stop offset="0.2239" style="stop-color:#FAD337"/>
-<stop offset="0.6537" style="stop-color:#EFAB26"/>
-<stop offset="1" style="stop-color:#E48717"/>
-</linearGradient>
-<path d="M23,16H6c-1.1,0-2,0.9-2,2v12c0,1.101,0.9,2,2,2h0.901v3.692c0,0.438,0.599,0.907,1.098,0.394   L11.362,32H23c1.1,0,2-0.899,2-2V18C25,16.9,24.1,16,23,16z" fill="url(#SVGID_1_)"/>
-<rect fill="#A55B11" height="1" width="10" x="9.5" y="20.5"/>
-<rect fill="#A55B11" height="1" width="10" x="9.5" y="23.5"/>
-<rect fill="#A55B11" height="1" width="6.25" x="9.5" y="26.5"/>
-<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_2_" x1="14.7773" x2="14.7773" y1="17" y2="32.9845">
-<stop offset="0" style="stop-color:#FFE23D"/>
-<stop offset="0.2239" style="stop-color:#FAD337"/>
-<stop offset="0.6537" style="stop-color:#EFAB26"/>
-<stop offset="1" style="stop-color:#E48717"/>
-</linearGradient>
-<path d="M25,18c0-0.572-0.243-1.089-0.631-1.454l-0.706,0.705C23.869,17.435,24,17.702,24,18   v11.999c0,0.554-0.5,1.002-1,1.002H10.891l-2.989,3.627v-3.627H6c-0.263,0-0.499-0.107-0.678-0.274   c0.009,0.009,0.013,0.021,0.022,0.03l-0.79,0.616C4.92,31.757,5.432,32,6,32h0.901v3.692c0.005,0.61,0.755,0.782,1.098,0.394   L11.362,32H23c1.172,0,2-0.947,2-2V18z" fill="url(#SVGID_2_)" fill-opacity="0.2" stroke-opacity="0.2"/>
-<path d="M7.901,34.628v-3.627l-1,0.999v3.692c0,0.262,0.164,0.494,0.411,0.583L7.901,34.628z" fill="#FFFFFF" fill-opacity="0.2" stroke-opacity="0.2"/>
-<path d="M5.345,30.757c-0.212-0.184-0.347-0.455-0.347-0.758V18c0-0.552,0.449-1.001,1.002-1.001h17   c0.254,0,0.457,0.069,0.663,0.252l0.706-0.705C24.011,16.208,23.528,16,23,16H6c-1.1,0-2,0.9-2,2v12   c0,0.532,0.211,1.017,0.552,1.376L5.345,30.757z" fill="#FFFFFF" fill-opacity="0.4" stroke-opacity="0.4"/>
-<path d="M7.901,31.001H6c-0.263,0-0.499-0.107-0.678-0.274c0.009,0.009,0.013,0.021,0.022,0.03l-0.79,0.616   C4.92,31.757,5.432,32,6,32h0.901L7.901,31.001z" fill-opacity="0.2" stroke-opacity="0.2"/>
-<path d="M25,18c0-0.572-0.243-1.089-0.631-1.454l-0.706,0.705C23.869,17.435,24,17.702,24,18v11.999   c0,0.585-0.562,1.002-1,1.002H10.891l-2.989,3.627l-0.589,1.647c0.067,0.024,0.422,0.105,0.687-0.189L11.362,32H23   c0.984,0,2-0.775,2-2V18z" fill-opacity="0.2" stroke-opacity="0.2"/>
-<path d="M25,16.619L24.25,16h-5.518c0.014,0.009,1.713,0.894,1.713,0.894l-1.675,0.86   c-0.317,0.205-0.271,0.577-0.204,0.694l0.879,1.515c0.352,0.402,0.623,0.224,0.705,0.171l1.574-1.017l-0.105,1.856   c0.021,0.438,0.361,0.527,0.498,0.527h1.764c0.4,0,0.508-0.391,0.498-0.527l-0.104-1.856L25,19.587V16.619z" fill-opacity="0.3" stroke-opacity="0.3"/>
-<polygon fill="#EA2227" points="27,17.199 26.118,18.714 23.722,17.162 23.881,20 22.117,20 22.277,17.162 19.879,18.714    19,17.199 21.537,15.895 19,14.588 19.879,13.076 22.277,14.625 22.117,11.771 23.881,11.771 23.722,14.625 26.118,13.076    27,14.588 24.464,15.895  "/>
-<rect fill="none" height="40" width="30"/>
-</g>
-</svg>
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -39,7 +39,7 @@
 const QString BT_ICON("qtg_large_bluetooth");
 const QString SMS_ICON("qtg_large_new_message");
 const QString MMS_ICON("qtg_large_new_message");
-const QString RINGTONE_ICON("qtg_large_tone");
+const QString RINGTONE_ICON("qtg_large_new_message");
 const QString VCARD_ICON("qtg_large_new_message");
 // ----------------------------------------------------------------------------
 // ServiceRequestSenderTask::ServiceRequestSenderTask
--- a/messagingapp/msgnotifications/msgnotifier/inc/msgnotifier_p.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgnotifications/msgnotifier/inc/msgnotifier_p.h	Tue Jul 06 14:12:40 2010 +0300
@@ -66,6 +66,16 @@
      */
     void DeleteConversationList(
             const CCsClientConversation& aClientConversation);
+    
+	/**
+	 * PartialDeleteConversationList
+	 * This is for handling partial delete of conversation event
+	 * Asynchronous
+	 * @param aClientConversation CCsClientConversation - The conversation object
+	 */
+    void PartialDeleteConversationList(
+            const CCsClientConversation& aClientConversation);
+
 
     /**  
      * ModifyConversationList
--- a/messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgnotifications/msgnotifier/src/msgnotifier_p.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -28,17 +28,16 @@
 #include <XQSettingsManager>
 #include <xqpublishandsubscribeutils.h>
 #include <xqsystemtoneservice.h>
+#include <xqconversions.h>
 
 //USER INCLUDES
 #include "msgnotifier.h"
 #include "msgnotifier_p.h"
-#include <xqconversions.h>
 #include "msgstorehandler.h"
 #include "msginfodefs.h"
 #include "conversationidpsconsts.h"
 #include "debugtraces.h"
 
-
 // ----------------------------------------------------------------------------
 // MsgNotifierPrivate::MsgNotifierPrivate
 // @see MsgNotifierPrivate.h
@@ -301,39 +300,44 @@
 // @see MsgNotifierPrivate.h
 // ----------------------------------------------------------------------------
 void MsgNotifierPrivate::displayFailedNote(MsgInfo info)
-{
-    // TODO: use XQAiwRequest
-    QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : entered")
-    // change to com.nokia.symbian.messaging (servicename), IMsgErrorNotifier
-    // as the service name.
-    XQServiceRequest snd("messaging.com.nokia.symbian.MsgErrorNotifier",
-        "displayErrorNote(QVariantList)", false);
+    {
+    QDEBUG_WRITE("MsgNotifierPrivate::displayFailedNote start.")
+            
+    // check whether opened cv id and received 
+    // cv id are same then dont show failed note
+    if (!showNotification(info.mConversationId))
+        {
+        return;
+        }
 
-    QVariantList args;
+    //Even if name string is empty we shall add name into args
+    QString nameString;
+
     info.mDisplayName.removeDuplicates();
     info.mDisplayName.sort();
-    
-    QString nameString;
-    
+
     nameString.append(info.mDisplayName.at(0));
-    for(int i = 1; i < info.mDisplayName.count(); ++i){
+    for (int i = 1; i < info.mDisplayName.count(); ++i)
+        {
         nameString.append(", ");
         nameString.append(info.mDisplayName.at(i));
-    }
-      
-    //Even if name string is empty we shall add name into args
-    QVariant nameV(nameString);
-    args << nameV;
+        }
 
-    QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : name and contactnumber")
-
+    // create request arguments
+    QVariantList args;
+    args << QVariant(nameString);
     args << info.mConversationId;
     args << info.mMessageType;
+
+    // TODO: use XQAiwRequest
+    XQServiceRequest snd("messaging.com.nokia.symbian.MsgErrorNotifier",
+            "displayErrorNote(QVariantList)", false);
+
     snd << args;
     snd.send();
-    QDEBUG_WRITE("[MsgNotifierPrivate::handleFailedState] : left")
-
-}
+    
+    QDEBUG_WRITE("MsgNotifierPrivate::displayFailedNote end.")
+    }
 
 // ----------------------------------------------------------------------------
 // MsgNotifierPrivate::showNotification
@@ -375,4 +379,11 @@
     wsSession.Close();
     return showNotification;
 }
+// ----------------------------------------------------------------------------
+// MsgNotifierPrivate::PartialDeleteConversationList
+// @see mcsconversationclientchangeobserver.h
+// ----------------------------------------------------------------------------
+void MsgNotifierPrivate::PartialDeleteConversationList(
+        const CCsClientConversation& aClientConversation){/*empty implementation*/}
+
 //EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmsreadfile.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSREADFILE_H
+#define MMSREADFILE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include <f32file.h>
+#include <msvstd.h>
+
+// forward references
+class CMmsAttaStructure;
+class CMmsHeaders;
+class CEikonEnv;
+class CMmsClientMtm;
+
+// Out-of-range value for any MMS header with assigned number
+// Used in coverage tests to get coverage for "default" branches
+// in "case" statements.
+const TInt KMmsTestIllegalValue = 255;
+
+//
+// TEST KEY WORDS
+// Extended to include all MMS headers to allow generation of arbitrary PDUs
+// Content type header cannot be separately defined,
+// it will always be "multipat/mixed" or "multipart/related"
+_LIT8( KTestEndOfFile,          "EOF" );
+_LIT8( KTestNewMessage,         "MESSAGE BEGIN" );
+//------------------------------------------------
+_LIT8( KTestMessageType,        "MESSAGE-TYPE" ); //X-Mms-Message-Type
+_LIT8( KTestDate,               "DATE" ); // Date
+_LIT8( KTestFrom,               "FROM" ); // From
+_LIT8( KTestTo,                 "TO" ); // To
+_LIT8( KTestCc,                 "CC" ); // Cc
+_LIT8( KTestBcc,                "BCC" ); // Bcc
+_LIT8( KTestSubject,            "SUBJECT" ); // Subject
+_LIT8( KTestExpiryRel,          "EXPIRY-REL" ); // X-Mms-Expiry, relative
+_LIT8( KTestExpiryAbs,          "EXPIRY-ABS" ); // X-Mms-Expiry, absolute
+_LIT8( KTestDeliveryTimeRel,    "DELIVERY-TIME-REL" ); // X-Mms-Delivery-Time, relative
+_LIT8( KTestDeliveryTimeAbs,    "DELIVERY-TIME-ABS" ); // X-Mms-Delivery-Time, absolute
+_LIT8( KTestPriority,           "PRIORITY" ); // X-Mms-Priority
+_LIT8( KTestSenderVisibility,   "SENDER-VISIBILITY" ); // X-Mms-Sender-Visibility
+_LIT8( KTestDeliveryReport,     "DELIVERY-REPORT" ); // X-Mms-Delivery-Report
+_LIT8( KTestReadReply,          "READ-REPLY" ); // X-Mms-Read-Report
+// ---------------------------------------------------
+_LIT8( KTestNewAttachment,      "ATTACHMENT" );
+_LIT8( KTestAttachmentType,     "ATTACHMENTTYPE" );
+_LIT8( KTestAttachmentName,     "ATTACHMENTNAME" );
+_LIT8( KTestAttachmentContLoc,  "ATTACHMENTCONTLOC" );
+_LIT8( KTestAttachmentCharset,  "ATTACHMENTCHARSET" );
+_LIT8( KTestAttachmentCid,      "ATTACHMENTCID" );
+_LIT8( KTestAttachmentRoot,     "ATTACHMENTROOT" );
+// content-type and x-type parameters for attachments
+// should appear in name-value pairs.
+// Test program is not responsible for verifying illegal scripts
+_LIT8( KTestAttContTypeParamName, "ContTypeParamName" );
+_LIT8( KTestAttContTypeParamValue, "ContTypeParamValue" );
+_LIT8( KTestAttXTypeParamName, "X-TypeParamName" );
+_LIT8( KTestAttXTypeParamValue, "X-TypeParamValue" );
+// -----------------------------------------------------
+_LIT8( KTestMessageClass,       "MESSAGE-CLASS" ); // X-Mms-Message-Class
+_LIT8( KTestDelivRepSendAllow,  "DELIV-REP-SEND-ALLOW" ); // X-Mms-Report-Allowed
+_LIT8( KTestAcceptAdvertis,     "ACCEPT-ADVERTISEMENTS" );
+_LIT8( KTestRetryCount,         "RETRY-COUNT" );
+_LIT8( KTestRetryInterval,      "RETRY-INTERVAL" );
+// -------------------------------------------------
+_LIT8( KTestAlias,				"ALIAS" );
+_LIT8( KTestFromAlias,			"FROMALIAS" );
+_LIT8( KTestToAlias,			"TOALIAS" );
+_LIT8( KTestCcAlias,			"CCALIAS" );
+_LIT8( KTestBccAlias,			"BCCALIAS" );
+// -------------------------------------------------
+// more Message headers to allow testing all possible PDUs and
+// MMS 1.1 headers
+_LIT8( KTestReplyCharging,      "REPLY-CHARGING" ); // X-Mms-Reply-Charging
+_LIT8( KTestReplyChargAbs,      "REPLY-CHARG-DEADLINE-ABS" ); // X-Mms-Reply-Charging, absolute
+_LIT8( KTestReplyChargRel,      "REPLY-CHARG-DEADLINE-REL" ); // X-Mms-Reply-Charging, relative
+_LIT8( KTestReplyChargSize,     "REPLY-CHARG-SIZE" ); // X-Mms-Reply-Charging-Size (octets)
+_LIT8( KTestReplyChargID,       "REPLY-CHARGING-ID" ); // X-Mms-Reply-Charging-ID
+_LIT8( KTestTID,                "TID" );
+_LIT8( KTestContentLocation,    "CONTLOC" ); // X-Mms-Content-Location
+// The following three must appear as triplets.
+// index must be first, address and date may appear in any order
+_LIT8( KTestPreviouslySentIndex, "PREVIOUSINDEX" ); // forwarded count for X-Mms-PreviouslySent headers
+_LIT8( KTestPreviouslySentBy,    "PREV-SENT-BY" ); // X-Mms-Previously-Sent-By
+_LIT8( KTestPreviouslySentDate,  "PREV-SENT-DATE" ); // X-Mms-Previously-Sent-Date
+//---
+_LIT8( KTestMessageId,           "MESSAGE-ID" ); // Message-ID
+_LIT8( KTestMessageSize,         "MESSAGE-SIZE" ); // X-Mms-Message-Size (octets)
+_LIT8( KTestVersion,             "MMS-VERSION" ); // X-MMS-Version (hex:, 10 = 1.0, 11 = 1.1 etc. )
+_LIT8( KTestReadStatus,          "READ-STATUS" ); // X-Mms-Read-Status
+_LIT8( KTestResponseStatus,      "RESPONSE-STATUS" ); // X-Mms-Response-Status
+_LIT8( KTestResponseText,        "RESPONSE-TEXT" ); // X-Mms-Response-Text
+_LIT8( KTestRetrieveStatus,      "RETRIEVE-STATUS" ); // X-Mms-Retrieve-Status
+_LIT8( KTestRetrieveText,        "RETRIEVE-TEXT" ); // X-Mms-Retrieve-Text
+_LIT8( KTestStatus,              "STATUS" ); // X-Mms-Status
+// -------------------------------------------------
+// MMS 1.2 headers
+_LIT8( KTestAttribute,          "ATTRIBUTE" ); // X-Mms-Attribute
+// The value should be one of the following:
+// BCC, CC, CONTENT, CONTENT-TYPE, DATE, DELIVERY-REPORT, DELIVERY-TIME-ABS,
+// EXPIRY-ABS, FROM, MESSAGE-CLASS, MESSAGE-ID, MESSAGE-SIZE, PRIORITY,
+// READ-REPLY, SUBJECT, TO, REPLY-CHARGING, REPLY-CHARGING-ID,
+// REPLY-CHARG-DEADLINE-ABS, REPLY-CHARG-SIZE, PREV-SENT-BY,
+// PREV-SENT-DATE, ADDITIONAL-HEADERS
+_LIT8( KTestDistributionIndicator,  "DISTRIBUTION-INDICATOR" ); // X-Mms-Distribution-Indicator
+_LIT8( KTestLimit,              "LIMIT" ); // X-Mms-Limit
+_LIT8( KTestMessageQuota,       "MESSAGE-QUOTA" ); // X-Mms-Mbox-Quota, message number
+_LIT8( KTestSizeQuota,          "SIZE-QUOTA" ); // X-Mms-Mbox-Quota, size quota
+_LIT8( KTestMessageTotal,       "MESSAGE-TOTAL" ); // X-Mms-Mbox-Totals, message number
+_LIT8( KTestSizeTotal,          "SIZE-TOTAL" ); // X-Mms-Mbox-Totals, total size
+_LIT8( KTestMessageCount,       "MESSAGE-COUNT" ); // X-Mms-Message-Count
+_LIT8( KTestAddKeyword,         "ADD-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestRemoveKeyword,      "REMOVE-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestFilterKeyword,      "FILTER-KEYWORD" ); // X-Mms-MM-FLags
+_LIT8( KTestMMState,            "MESSAGE-STATE" ); // X-Mms-MM-State
+_LIT8( KTestQuota,              "QUOTA" ); // X-Mms-Quotas
+_LIT8( KTestStart,              "START" ); // X-Mms-Start
+_LIT8( KTestStore,              "STORE" ); // X-Mms-Store
+_LIT8( KTestStored,             "STORED" ); // X-Mms-Stored
+_LIT8( KTestStoreStatus,        "STORE-STATUS" ); // X-Mms-Store-Status
+_LIT8( KTestStoreStatusText,    "STORE-STATUS-TEXT" ); // X-Mms-Store-Status-Text
+_LIT8( KTestTotals,             "TOTALS" ); // X-Mms-Totals
+// Delete confirmation header structure
+// This consists of index, content location, response status and response status text.
+// All three values are not always necessary for each index, but at least content-location
+// and response status should be present.
+// The index retains its value until a new index is encountered.
+_LIT8( KTestDeleteInfoIndex,    "DELETESTATUSINDEX" ); // index for next delete info fields
+// This header must precede content-location, response-status and response-text fields
+// in a delete confirmation. Index retains its value until a new index is encountered.
+
+// Element descriptor header not implemented
+
+// Application id headers
+// These will officially be supported in MMS encapsulation version 1.3
+// Java has non-standard support even earlier
+
+_LIT8( KTestApplicId,            "APPLIC-ID" ); // X-Mms-Applic-ID
+_LIT8( KTestReplyApplicId,       "REPLY-APPLIC-ID" ); // X-Mms-Reply-Applic-ID
+_LIT8( KTestApplicInfo,          "AUX-APPLIC-INFO" ); // X-Mms-Aux-Applic-Info
+
+// Since Encapsulation 1.3
+_LIT8( KTestContentClass,        "CONTENT-CLASS" ); // X-Mms-Content-Class
+_LIT8( KTestDrmContent,          "DRM-CONTENT" ); // X-Mms-DRM-Content
+_LIT8( KTestAdaptationAllowed,   "ADAPTATION-ALLOWED" ); // X-Mms-Adaptation-Allowed
+_LIT8( KTestRecommendedRetrievalMode, "REC-RETRIEVAL-MODE" ); // X-Mms-Recommended-Retrieval-Mode
+_LIT8( KTestRecRetrievalModeText, "REC-RETR-MODE-TEXT" ); // X-Mms-Recommended-Retrieval-Mode-Text
+_LIT8( KTestReplaceId,           "REPLACE-ID" ); // X-Mms-Replace-ID
+_LIT8( KTestStatusText,          "STATUS-TEXT" ); // X-Mms-Status-Text
+_LIT8( KTestCancelId,            "CANCEL-ID" ); // X-Mms-Cancel-ID
+_LIT8( KTestCancelStatus,        "CANCEL-STATUS" ); // X-Mms-Cancel-Status
+
+// DATA TYPES
+#define aSet            1
+#define aReset          0
+#define PartCount      100
+#define MaxAttaCount   10
+#define DefaultBufLen 256
+#define MaxRecipients   5
+
+// status returned by ReadRow
+enum TTestReadStatus
+    {
+    ETestUnknown,
+    ETestNewMessage,
+    ETestNewAttachment,
+    ETestEof,    // End of file
+    ETestMessageType,
+    ETestDate,
+    ETestFrom,
+    ETestTo,
+    ETestCc,
+    ETestBcc,
+	ETestAlias,
+	ETestFromAlias,
+	ETestToAlias,
+	ETestCcAlias,
+	ETestBccAlias,
+    ETestSubject,
+    ETestExpiryRel,
+    ETestExpiryAbs,
+    ETestDeliveryTimeRel,
+    ETestDeliveryTimeAbs,
+    ETestPriority,
+    ETestSenderVisibility,
+    ETestDeliveryReport,
+    ETestReadReply,
+    ETestAttachmentType,
+//    ETestAttachmentName,
+    ETestAttachmentCharset,
+    ETestAttachmentCid,
+	ETestAttachmentRoot,
+    ETestSettings,
+    ETestMessageClass,
+    ETestDelivReportSendAllow,
+    ETestSingleMessageClass,
+    ETestReplyCharging,
+    ETestReplyChargAbs,
+    ETestReplyChargRel,
+    ETestReplyChargSize,
+    ETestReplyChargID,
+    ETestTID,
+    ETestContentLocation,
+    ETestPreviouslySentIndex,
+    ETestPreviouslySentBy,
+    ETestPreviouslySentDate,
+    ETestMessageId,
+    ETestMessageSize,
+    ETestVersion,
+    ETestReadStatus,
+    ETestResponseStatus,
+    ETestResponseText,
+    ETestRetrieveStatus,
+    ETestRetrieveText,
+    ETestStatus,
+    ETestAttribute,
+    ETestDistributionIndicator,
+    ETestLimit,
+    ETestMessageQuota,
+    ETestSizeQuota,
+    ETestMessageTotal,
+    ETestSizeTotal,
+    ETestMessageCount,
+    ETestAddKeyword,
+    ETestRemoveKeyword,
+    ETestFilterKeyword,
+    ETestMMState,
+    ETestQuota,
+    ETestStart,
+    ETestStore,
+    ETestStored,
+    ETestStoreStatus,
+    ETestStoreStatusText,
+    ETestTotals,
+    ETestDeleteInfoIndex,
+    ETestApplicId,
+    ETestReplyApplicId,
+    ETestApplicInfo,
+    ETestContentClass,
+    ETestDrmContent,
+    ETestAdaptationAllowed,
+    ETestRecommendedRetrievalMode,
+    ETestRecRetrievalModeText,
+    ETestReplaceId,
+    ETestStatusText,
+    ETestCancelId,
+    ETestCancelStatus,
+    ETestAttaRecommendedName,
+    ETestAttachmentContLoc,
+    ETestAttContTypeParamName,
+    ETestAttContTypeParamValue,
+    ETestAttXTypeParamName,
+    ETestAttXTypeParamValue
+
+    };
+
+// VALUE KEYWORDS
+_LIT( KPersonal,      "Personal" );
+_LIT( KAdvertisement, "Advertisement" );
+_LIT( KInformational, "Informational" );
+_LIT( KAuto,          "Auto" );
+_LIT( KLow,    "Low" );
+_LIT( KNormal, "Normal" );
+_LIT( KHigh,   "High" );
+_LIT( KHide,   "Hide" );
+_LIT( KShow,   "Show" );
+_LIT( KYes,    "Yes" );
+_LIT( KNo,     "No" );
+_LIT( KOn,     "On" );
+_LIT( KOff,     "Off" );
+_LIT( KDeferred, "Deferred" );
+_LIT( KExpired,  "Expired" );
+_LIT( KRetrieved, "Retrieved" );
+_LIT( KRejected, "Rejected" );
+_LIT( KUnrecognized, "Unrecognized" );
+_LIT( KIndeterminate, "Indeterminate" );
+_LIT( KForwarded, "Forwarded" );
+_LIT( KUnreachable, "Unreachable" );
+_LIT( KDraft, "Draft");
+_LIT( KSent, "Sent" );
+_LIT( KNew, "New" );
+// X-Mms-Message-Type
+_LIT( KSendReq, "SendReq" );
+_LIT( KSendConf, "SendConf" );
+_LIT( KNotifInd, "NotifInd" );
+_LIT( KNotifResp, "NotifResp" );
+_LIT( KRetrConf, "RetrConf" );
+_LIT( KAckInd, "AckInd" );
+_LIT( KDelInd, "DelInd" );
+_LIT( KReadReqInd, "ReadReqInd" );
+_LIT( KReadOrigInd, "ReadOrigInd" );
+_LIT( KForwardRec, "ForwardReq" );
+_LIT( KForwardConf, "ForwardConf" );
+_LIT( KMBoxStoreReq, "MBoxStoreReq" );
+_LIT( KMBoxStoreConf, "MBoxStoreConf" );
+_LIT( KMBoxViewReq, "MBoxViewReq" );
+_LIT( KMBoxViewConf, "MBoxViewConf" );
+_LIT( KMBoxUploadReq, "MBoxUploadReq" );
+_LIT( KMBoxUploadConf, "MBoxUploadConf" );
+_LIT( KMBoxDeleteReq, "MBoxDeleteReq" );
+_LIT( KMBoxDeleteConf, "MBoxDeleteConf" );
+_LIT( KMBoxDescr, "MBoxDescr" );
+_LIT( KDeleteReq, "DeleteReq" );
+_LIT( KDeleteConf, "DeleteConf" );
+_LIT( KCancelReq, "CancelReq" );
+_LIT( KCancelResp, "CancelConf" );
+// X-Mms-Read-Status
+_LIT( KRead, "Read" );
+_LIT( KDelNotRead, "DeletedNotRead" );
+// X-Mms-Reply-Charging
+_LIT( KRequested, "Requested" );
+_LIT( KReqTextOnly, "ReqTextOnly" );
+_LIT( KAccepted, "Accepted" );
+_LIT( KAccTextOnly, "AccTextOnly" );
+// X-Mms-Cancel-Status (only receival of request, not actual cancellation)
+_LIT( KCancelSuccessful, "CancelSuccess" );
+_LIT( KCancelCorrupted, "CancelCorrupted" );
+// X-Mms-Content-Class
+_LIT( KText, "Text" );
+_LIT( KImageBasic, "ImageBasic" );
+_LIT( KImageRich, "ImageRich" );
+_LIT( KVideoBasic, "VideoBasic" );
+_LIT( KVideoRich, "VideoRich" );
+_LIT( KMegaPixel, "MegaPixel" );
+_LIT( KContentBasic, "ContentBasic" );
+_LIT( KContentRich, "ContentRich" );
+// X-Mms-Recommended-Retrieval-Mode
+_LIT( KManual, "Manual" );
+
+//X-Mms-ResponseStatus
+// legacy values
+_LIT( KOk, "OK" );
+_LIT( KErrUnspecified, "Unspecified" );
+_LIT( KErrServiceDenied, "ServiceDenied" );
+_LIT( KErrMessageFormatCorrupt, "FormatCorrupt" );
+_LIT( KErrAddressUnresolved, "AddressUnresolved" );
+_LIT( KErrMessageNotFound, "MessageNotFound" );
+_LIT( KErrNetworkProblem, "NetworkProblem" );
+_LIT( KErrContentNotAccepted, "ContentNotAccepted" );
+_LIT( KErrUnsupportedMessage, "UnsupportedMessage" );
+// values since 1.1 (and 1.2)
+_LIT( KErrTransient, "TransientFailure" );
+_LIT( KErrTransientAddressUnresolved, "TransientAddressUnresolved" );
+_LIT( KErrTransientNotFound, "TransientMessageNotFound" );
+_LIT( KErrTransientNetworkproblem, "TransientNetworkProblem" );
+_LIT( KErrTransientPartialSuccess, "PartialSuccess" );
+_LIT( KErrPermanent, "PermanentFailure" );
+_LIT( KErrPermanentServiceDenied, "PermanentServiceDenied" );
+_LIT( KErrPermanentMessageFormatCorrupt, "PermanentFormatCorrupt" );
+_LIT( KErrPermanentAddressUnresolved, "PermanentAddressUnresolved" );
+_LIT( KErrPermanentNotFound, "PermanentMessageNotFound" );
+_LIT( KErrPermanentContentNotAccepted, "PermanentContentNotAccepted" );
+_LIT( KErrReplyChargingLimitNotMet, "ReplyChargingLimitNotMet" );
+_LIT( KErrReplyChargingRequestNotAccepted, "ReplyChargingRequestNotAccepted" );
+_LIT( KErrReplyChargingForwardingDenied, "ReplyChargingForwardingDenied" );
+_LIT( KErrReplyChargingNotSupported, "ReplyChargingNotSupported" );
+_LIT( KErrAddressHidingNotSupported, "AddressHidingNotSupported" );
+_LIT( KErrPermanentLackOfPrepaid, "PermanentLackOfPrepaid" );
+//X-Mms-RetrieveStatus (one extra value)
+_LIT( KErrRetrieveContentUnsupported, "PermanentContentUnsupported" );
+//X-Mms-Store-Status (one extra value)
+_LIT( KErrMMBoxFull, "MMBoxFull" );
+
+_LIT8( KTestContent,  "Content" ); // For attribute list only
+_LIT8( KTestAdditionalHeaders,  "ADDITIONAL-HEADERS" ); // For attribute list only
+_LIT8( KTestDeliveryTime,       "DELIVERY-TIME"); // for attribute list only
+_LIT8( KTestExpiry,             "EXPIRY"); // for attribute list only
+_LIT8( KTestReplyCharg,         "REPLY-CHARG-DEADLINE" ); // for attribute list only
+_LIT8( KTestContentType,        "CONTENT-TYPE" );  // for attribute list only
+
+/**
+*  CMmsReadFile
+*/
+NONSHARABLE_CLASS( CMmsReadFile ):public CBase
+    {
+    public:  // Constructors and destructor
+
+        static CMmsReadFile* NewL(RFs& aFs, RFileReadStream& aReadStream ); // Two-phased constructor.
+        virtual ~CMmsReadFile(); // Destructor
+
+    public: // New functions
+
+        TInt CompleteTestL(TInt aMessageCounter, CMmsHeaders& aMmsHeaders);
+        TTestReadStatus ReadRowL();
+        void CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders );
+		TInt FindAlias(TPtrC alias);
+		void SetAttaStructure( TBool aOldAttaStructure = EFalse );
+
+    protected:  // Functions from base classes
+
+    private:
+
+        CMmsReadFile(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL( RFs& aFs, RFileReadStream& aReadStream );
+        void Reset();
+
+    public: // data
+        TInt                            iMessageType;
+
+
+    private:     // Data
+
+        RFs                             iFs;
+        RFileReadStream*                iReader;
+        TBuf<DefaultBufLen>             iValueBuffer;
+        CDesCArray*     iAliasArray;    // aliases
+        HBufC8*         iByteBuffer;
+        TTime                           iDate;
+        CArrayPtrFlat<CMmsAttaStructure>* iAttaStructures;
+        TInt                            iAttaCount;
+		TInt							iAttaRoot;
+		TInt							iAliasCount;
+        TInt                            iNextMessageType;
+        TParse                          iParse;
+        TFileName                       iFilename;
+
+    protected:  // Data
+    private:    // Data
+
+        // CArrayFixFlat <TestMessage>* iMessages;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+    };
+
+
+NONSHARABLE_CLASS( CMmsAttaStructure ):public CBase
+    {
+    public:  // Constructors and destructor
+        static CMmsAttaStructure* NewL(); // Two-phased constructor.
+        virtual ~CMmsAttaStructure(); // Destructor
+    private:
+        CMmsAttaStructure(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL();
+
+    public:     // Data
+        HBufC8*         iAtta;
+        HBufC8*         iAttaName; // content location
+        HBufC8*         iAttaType;
+        HBufC8*         iAttaCid;
+        TInt            iAttaCharset;
+        HBufC*          iAttaRecommendedName; // recommended filename
+       	CDesC8ArrayFlat* iContentTypeParams;  // zero or more "parameter"
+    	CDesC8ArrayFlat* iXTypeParams;        // zero or more X-Type "parameters"
+
+    };
+
+
+#endif      // MMSREADFILE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestbed.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTBED_H
+#define MMSTESTBED_H
+
+#ifdef BUILD_MMSTESTBED_DLL
+#define MMSTESTBED_EXPORT Q_DECL_EXPORT
+#else
+#define MMSTESTBED_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <QString>
+
+#include <msvids.h>  //for consts like KMsvNullIndexEntryIdValue
+#include <MSVAPI.H>
+#include <MTCLREG.H>
+#include <mmsclient.h>
+//#include <mmsservercommon.h>
+
+class CTestUiTimer;
+class CMsvSession;
+class CMmsClientMtm;
+class CMmsSettings;
+class CMmsHeaders;
+class CLogEvent;
+class CLogViewEvent;
+class CLogFilter;
+class CLogClient;
+
+class MMSTESTBED_EXPORT MmsTestBed : public QObject, public MMsvSessionObserver
+    {
+    Q_OBJECT
+
+public:
+    /**
+     *
+     */
+    MmsTestBed();
+    ~MmsTestBed();
+    void setConnectionLocal(bool value);
+    void fromOutboxToMmsc();
+    void fromMmscToInbox();
+    /**
+     * cleanup MMS service
+     */
+    void cleanupAndCreateNewService();
+    void deleteNotifications();
+    void restoreFactorySettings();
+    void setFetchingState( TMmsReceivingMode aState );
+    void sendFromFile();
+    void sendOneByOne();
+    void sendNotifications();
+    void copyDrafts();
+    void garbageCollection(TUint32 aReason = 0x00000001); //0x00000001 == KMmsReasonBoot
+    void messageVariation();
+    void cancelSendScheduling();
+    void scheduledSend(TMsvId aBoxId, TInt aDelay = 5);
+    void deleteSendSchedule();
+    void cancelFetchScheduling();
+    void fetchForced(TInt aDelay = 5);
+    void deleteFetchSchedule();
+    void doAFetchCycle();
+    void createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry);
+    void cleanOutbox();
+    void cleanInbox();
+    void cleanSent();
+    void cleanDrafts();
+    void cleanAll();
+    void reply();
+    void replyToAll();
+    void forward();
+    void sendReadReport(); // send a read report
+    int fromOutboxToMmscWithMemoryFailure(); // returns memory failure count
+    int fromMmscToInboxWithMemoryFailure(); // returns memory failure count
+    void sendViaClient();
+    void scheduledFetch(TInt aDelay = 5);
+    void fetchForcedImmediate();
+    void getEventType();
+    void addEventType();
+    void deleteEventType();
+    void cleanLog();
+    void setOnline(bool value);
+    void generateDeliveryReport( CMmsHeaders* aMmsHeaders );
+    void sendDeliveryReport();
+
+signals:
+    void entryCreatedInDraft(long int id);
+    void entryMovedToOutbox(long int id);
+    void entryMovedToSent(long int id);
+    void entryCreatedInInbox(long int id);
+
+protected:
+    /**
+     * From MMsvSessionObserver
+     */
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+            TAny* aArg2, TAny* aArg3);
+
+private:
+    void findDefaultL();
+    void createMmsService();
+    void cleanup();
+    void deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry);
+    void testFile(TFileName& aFilePath, TInt aCommand = 0, TMsvId aBox = KMsvGlobalOutBoxIndexEntryId);
+    void addMMBoxDescriptions();
+    void encodeMessageFromDrafts();
+    TMsvId findMMSFolder();
+    bool checkLogClient();
+    int getLogEntries();
+
+private:
+    //data
+    CTestUiTimer* iTimer;
+    CMsvOperationActiveSchedulerWait* iWait;
+    CMsvSession* iSession;
+    CClientMtmRegistry* iClientMtmRegistry;
+    CMmsClientMtm* iMmsClient;
+    CMmsSettings* iSettings;
+    CMmsHeaders* iMmsHeaders;
+    TMsvId iServiceId;
+    TMsvId iDefaultServiceId;
+    TMsvSessionEvent iEvent;
+    RFs iFs;
+    TFileName iFilename;
+    TFileName iCurrentFile;
+    TFileName iCurrentPath;
+    TParse iParse;     // parse buffer as member to save stack space
+    CBufFlat* iEncodeBuffer;
+    CMsvEntrySelection* iMsvEntrySelection;
+    CLogEvent* iLogEvent;
+    CLogClient* iLogClient;
+    CLogViewEvent* iLogView;
+    CLogFilter* iLogFilter;
+    };
+
+#endif // MMSTESTBED_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestbed.hrh	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <bldvariant.hrh>
+
+
+#ifndef MMSTESTBED_HRH
+#define MMSTESTBED_HRH
+
+enum
+{
+    EAppMainOk = 1,
+    EAppMainCancel,
+    //
+    EMenufrmCmdCascadeTest,
+    ECleanup,
+    ECleanOutbox,
+    ESaveSettings,
+    ELoadSettings,
+    ECleanInbox,
+    EShowIn,
+    EShowOut,
+    EOutToMMSC,
+    EMMSCToIn,
+    ESendScheduled,
+    EReceiveScheduled,
+    EShowSent,
+    ECleanSent,
+    EStartMyNotifier,
+    EGetEventType,
+    EAddEventType,
+    EDeleteEventType,
+    EViewLog,
+    ECleanLog,
+    EShowWapAccessPoints,
+    ESelectWapAccessPoint,
+    EShowConnectionMode,
+    EShowIAP,
+    EConnectToIAP,
+    EDeleteSendSchedule,
+    EDeleteReceiveSchedule,
+    EDeleteNotifications,
+    ERestoreFactorySettings,
+    ECreateFromFile,
+    EShowNotifications,
+    ESendDeliveryReport,
+    EShowDrafts,
+    ECleanDrafts,
+    ECleanAll,
+    EFetchingDeferred,
+    EFetchingOn,
+    ESendFromFile,
+    ESwitchToLocal,
+    ESwitchToGlobal,
+    EDecodeLoggingOn,
+    EDecodeLoggingOff,
+    EBinaryDumpOn,
+    EBinaryDumpOff,
+    ESendNotification,
+    ECreateToInbox,
+    ECreateToSentItems,
+    ESendFromDrafts,
+    EFindMMSFolder,
+    ESendOneByOne,
+    ECreateToDrafts,
+    ESendViaClient,
+    ESendMemFail,
+    EFetchMemFail,
+    EReceiveForced,
+    ECreateHeadersFromFile,
+    ESwitchToOffline,
+    ESwitchToOnline,
+    ECopyDrafts,
+    ECreateNotification,
+    EReply,
+    EReplyToAll,
+    EForward,
+    EFetchingManual,
+    EFirstBoot,
+    ENoFirstBoot,
+    EFindNetworkStatus,
+    ESendReadReport,
+    ECreateMMBoxViewConf,
+    EGetMMBoxView,
+    ECleanMMBox,
+    EShowMMBox
+};
+
+#define 	ETestLabel1 1
+#define 	ETestLabel2 2
+#define 	ETestLabel3 3
+#define 	ETestLabel4 4
+
+#define     EServiceList 2
+
+
+enum TTestBedDlgCtrlIds
+	{
+	ETestEditField = 1
+	};
+
+enum TEditServiceControls
+	{
+	EFolderLabel = 1,
+    EEditUri
+//	EEditServiceFolder,
+//	ENameLabel,
+//	EEditServiceName,
+//	ENumberLabel,
+//	EEditServiceNumber
+	};
+
+enum
+	{
+	EFsViewDialogId = 1
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmsteststaticutils.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTSTATICUTILS_H
+#define MMSTESTSTATICUTILS_H
+
+#include <e32std.h>
+#include <msvstd.h>
+#include <badesca.h>
+
+#include "mmsconst.h"
+
+class RFs;
+class CMsvSession;
+class CMmsEncode;
+class CMmsHeaders;
+
+#ifdef __WINS__
+_LIT( KRootPath, "c:\\" );
+#else
+// This is removable disk.
+// drive letter should not be hard coded, must be investigated further
+// We use c: for a while for the tests (to be cahnged later)
+_LIT( KRootPath, "c:\\" );
+//_LIT( KRootPath, "e:\\" );
+#endif
+
+// directory where mmbox descriptions are created
+_LIT( KMmsMMBoxDescriptionDirectory, "C:\\mmsmmboxdescriptions\\");
+// directory where created headers are dumped
+_LIT( KMmsDumpDirectory, "C:\\mmsdump\\");
+// content type of MMS PDUs
+_LIT8( KMmsMimeType, "application/vnd.wap.mms-message" );
+
+_LIT( KWild, "*" );
+
+
+/**
+ *  joined array structure
+ *
+ */
+NONSHARABLE_CLASS( TMmsJoinedArrays ): public MDesCArray
+    {
+public:
+    TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2);
+    TInt MdcaCount() const;
+    TPtrC16 MdcaPoint(TInt aIndex) const;
+private:
+    CDesCArray* const & iArray1;
+    CDesCArray* const & iArray2;
+    };
+
+/**
+ *  static utility functions
+ *
+ */
+class TMmsTestUtils
+    {
+
+public:
+
+    /**
+     *
+     */
+    TMmsTestUtils();
+
+    /**
+     * read phone number for sending messages
+     *
+     * @param aFileName full path for filename
+     * @param aFs file system handle
+     * @return allocated pointer containing the name
+     *     The caller must delete the pointer when no longer needed
+     */
+    static HBufC* ReadContactFromFileL( TDesC& aFileName, RFs& aFs );
+
+    static void DecodeLoggingOnL();
+    static void DecodeLoggingOffL();
+    static void BinaryDumpOnL();
+    static void BinaryDumpOffL();
+
+    /**
+     * Clean all temporary directories used in local mode.
+     * Does not delete the directories, only the contents
+     *
+     * @param aFs file system handle
+     */
+    static void CleanDirectoryL( RFs& aFs );
+
+    /**
+     * Dump a binary message
+     *
+     * @param aBuffer buffer containing the binary message
+     * @param aFilename full path of the directory whenre the dump goes
+     * @param aParse reference to parser (to save stack space)
+     * @param aFs file system handle
+     */
+    static void Dump(
+        CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs );
+
+    /**
+     * Delete all MMS messages and notifications from a given folder
+     *
+     * @param aBoxId folder id
+     * @param aSession Messaging server session
+     */
+    static void CleanBoxL(TMsvId aBoxId, CMsvSession& aSession);
+
+    /**
+     * turn on logging messages sent to email addresses
+     */
+    static void EmailLoggingOnL();
+
+    /**
+     * turn off logging messages sent to email addresses
+     */
+    static void EmailLoggingOffL();
+
+    /**
+     * load list of children into selection and return count
+     *
+     * @param aBoxId folder id
+     * @param aMsvEntrySelection reference to a pointer that will contain the list of child ids
+     *     caller is responsible of deleting the pointer afterwards.
+     *     Pointer may be NULL at entry, and a new pointer will be allocated
+     * @param aSession messge server session
+     * @param aMessageType child MTM type, default is multimedia message
+     * @return number of entries in selection
+     */
+    static TInt CountChildrenL(
+        TMsvId aBoxId,
+        CMsvEntrySelection*& aMsvEntrySelection,
+        CMsvSession& aSession,
+        TUid aMessageType = KUidMsgTypeMultimedia);
+
+    /**
+     * Create a folder entry
+     *
+     * @param aSession messge server session
+     * @param aParentFolder the parent folder
+     * @param aFolderName name of the folder
+     * @param aFolderId will contain the if of the new folder if creation was successful
+     */
+    static void CreateFolderEntryL(
+        CMsvSession& aSession,
+        TMsvId aParentFolder,
+        const TDesC& aFolderName,
+        TMsvId& aFolderId );
+
+    /**
+    * Create an MMS notification from data in buffer
+    * @param aNotificationFolder mms notification folder (target folder)
+    * @param aServiceId id of MMS service
+    * @param aEncodeBuffer buffer that contains the data
+    * @param aSession message server session
+    * @return id of the created notification
+    */
+    static TMsvId CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession );
+
+    /**
+    * Encode an MMS notification into buffer
+    * @param aUrl url of the notification for local messages a filepath
+    * @param aSize size of the message
+    * @param aMmsHeaders MMS headers structure for creating the notification
+    * @param aMmsEncoder reference to CMmsEncode class
+    * @param aEncodeBuffer flat buffer that will contain the encoded notification
+    */
+    static void FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer );
+
+
+    static TBool IsDrive(const TDesC& aFileName);
+    static TBool IsDir(const TDesC& aFileName, RFs& aFs);
+    static TBool IsFile(const TDesC& aFileName, RFs& aFs);
+
+
+private:
+
+    };
+
+
+#endif // MMSTESTSTATICUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/inc/mmstestuitimer.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef C_TESTUITIMER_H
+#define C_TESTUITIMER_H
+
+
+#include <e32base.h>
+
+#define KPeriod 10000 // period of timer
+
+/**
+ *  timer for test programs
+ */
+NONSHARABLE_CLASS( CTestUiTimer ): public CTimer
+    {
+public:
+
+    static CTestUiTimer* NewL();
+    virtual  ~CTestUiTimer();
+
+    void RunL();
+    void DoCancel();
+    void ConstructL();
+    void IssueRequest();
+    void TimeoutOperation(CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds);
+
+private:
+    CTestUiTimer();
+
+public:
+    TTimeIntervalMicroSeconds32 period;
+
+private: // data
+    CActive* iObject;
+    };
+
+#endif // C_TESTUITIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/mmstestbed.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,84 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+QT += testlib
+QT -= gui
+
+TEMPLATE = lib
+
+TARGET = mmstestbed
+
+INCLUDEPATH += .
+INCLUDEPATH += inc
+INCLUDEPATH += ../../inc
+
+INCLUDEPATH += ../../../../../mmsengine/inc
+INCLUDEPATH += ../../../../../mmsengine/mmsserver/inc
+INCLUDEPATH += ../../../../../mmsengine/mmsmessage/inc
+INCLUDEPATH += ../../../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../inc
+INCLUDEPATH += ../../../../../mmsengine/mmsengine/inc
+INCLUDEPATH += ../../../../../../../mmsengine/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmshttptransport/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsmessage/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsconninit/inc
+#INCLUDEPATH += ../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsserver/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+DEFINES += BUILD_MMSTESTBED_DLL
+
+SOURCES += src/mmstestbed.cpp \
+           src/mmsteststaticutils.cpp \
+           src/mmsreadfile.cpp \
+           src/mmstestuitimer.cpp
+
+HEADERS += inc/mmstestbed.h \
+           inc/mmsteststaticutils.h \
+           inc/mmsreadfile.h \
+           inc/mmstestuitimer.h \
+           inc/mmstestbed.hrh
+
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+
+symbian {
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000
+    TARGET.EPOCALLOWDLLDATA = 1 
+	}
+
+# Build.inf rules
+BLD_INF_RULES.prj_exports += \
+     "$${LITERAL_HASH}include <platform_paths.hrh>"
+
+LIBS += -lmsgs \
+        -lmmsmessage \
+        -lmmsconninit \
+        -lmmscodec \
+        -lmmsserversettings \
+        -lcentralrepository \
+        -lapparc \
+        -lbafl \
+        -lefsrv \
+        -lesock \
+        -lestor \
+        -leuser \
+        -llogcli \
+        -llogwrap \
+        -lapgrfx \
+        -lapmime
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmsreadfile.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,1799 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <badesca.h>
+#include    <e32def.h>
+#include    <s32file.h>
+#include    <msvids.h>
+#include    <mtmdef.h>
+//#include    <eikenv.h>
+#include    <apgcli.h>
+#include    <CMsvMimeHeaders.h>
+#include    <AknNoteWrappers.h>
+
+#include    <mmsservercommon.h>
+#include    "mmsconst.h"
+#include    "mmsclient.h"
+#include    "mmsheaders.h"
+#include    "mmsreadfile.h"
+#include    "mmsmmboxviewheaders.h"
+#include    "mmsmmboxmessageheaders.h"
+#include    "mmsmmboxflags.h"
+#include    "mmssettings.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMmsGranularity = 8;
+_LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsReadFile::CMmsReadFile()
+    {
+    // all member variables in a class derived from CBase
+    // are automatically set to 0.
+    }
+
+
+//
+void CMmsReadFile::ConstructL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    // iRowBuffer = HBufC8::NewMaxL( 500 ); // Max row length!!!!
+    iFs = aFs;
+    iReader = &aReadStream;
+    iByteBuffer = HBufC8::NewL( DefaultBufLen );
+    iAliasArray = new ( ELeave ) CDesCArrayFlat( KMmsGranularity );
+    iAttaStructures = new ( ELeave ) CArrayPtrFlat<CMmsAttaStructure>( KMmsGranularity );
+    Reset();
+    }
+
+// Two-phased constructor.
+CMmsReadFile* CMmsReadFile::NewL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    CMmsReadFile* self = new ( ELeave ) CMmsReadFile();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFs, aReadStream );
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// Destructor
+CMmsReadFile::~CMmsReadFile()
+    {
+    Reset(); // resets and destroys all array data
+    if (iAliasArray != NULL) iAliasArray->Reset();
+    delete iByteBuffer;
+    delete iAliasArray;
+    delete iAttaStructures;
+    }
+
+void CMmsReadFile::Reset()
+    {
+    // reset all arrays
+    if (iAttaStructures != NULL) iAttaStructures->ResetAndDestroy();
+    iAttaCount = 0;
+    iAttaRoot = 0;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CompleteTest
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::CompleteTestL( TInt aMessageCounter, CMmsHeaders& aMmsHeaders )
+{
+    Reset(); // new message
+
+    TUint32 val;
+    TUint   limit = 1000000;
+    TUint   sizeLimit = 1000 * 1024; //max message size 1000 kB!
+    TUint   allLimit = 999999;
+    TInt    error;
+    TRadix  radix = EDecimal;
+    TLex16  lex;
+    TTestReadStatus readStatus = ETestUnknown;
+    CMmsAttaStructure* oneAtta = NULL;
+	TInt    index;
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    TTime date;
+    TInt order = 0;
+    TInt16 shortInteger = 0;
+
+    //iso luuppi, joka kiertää ja lukee kunnes EOF tule vastaan
+    //Big Loop, which passes around and read until the EOF
+
+    iMessageType = iNextMessageType;
+    while(readStatus != ETestEof)
+        {
+        readStatus = ReadRowL();
+        if ( readStatus ==  ETestEof )
+            {
+            return(-1);
+            }
+        if ( readStatus == ETestUnknown )
+            {
+            // A line containing only comments, or an unknown tag
+            // As using the scripts to test settings is no longer supported,
+            // any old keywords used to test CMmsSettings class are ignored
+            continue;
+            }
+        if( readStatus == ETestNewMessage )
+            {
+            iNextMessageType = readStatus;
+            if(aMessageCounter++)
+                {
+                return(NULL);
+                }
+            else
+                {
+                iMessageType = iNextMessageType;
+                continue;
+                }
+            }
+        if ( iMessageType == ETestNewMessage)
+            {
+            switch(readStatus)
+                {
+                case ETestFrom:
+                    aMmsHeaders.SetSenderL( iValueBuffer );
+                    break;
+                case ETestFromAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.SetSenderL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ) );
+	    				}
+                    break;
+                case ETestTo:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientTo );
+                    break;
+                case ETestToAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsTo );
+						}
+                    break;
+                case ETestCc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientCc );
+                    break;
+                case ETestCcAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsCc );
+						}
+                    break;
+                case ETestBcc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientBcc );
+                    break;
+                case ETestBccAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsBcc );
+						}
+                    break;
+                case ETestSubject:
+                    aMmsHeaders.SetSubjectL( iValueBuffer );
+                    break;
+                case ETestExpiryRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetExpiryInterval( val );
+                        }
+                    break;
+                case ETestExpiryAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    // expiry date in seconds from 1.1.1970.
+                    aMmsHeaders.SetExpiryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDeliveryTimeRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetDeliveryTimeInterval( val );
+                        }
+                    break;
+                case ETestDeliveryTimeAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDeliveryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDate:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDate( (interval.Int64())/1000000 );
+                case ETestPriority:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KLow)) == 0)
+                        {
+                        val = EMmsPriorityLow;
+                        }
+                    else if ((iValueBuffer.CompareF(KNormal)) == 0)
+                        {
+                        val = EMmsPriorityNormal;
+                        }
+                    else if ((iValueBuffer.CompareF(KHigh)) == 0)
+                        {
+                        val = EMmsPriorityHigh;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessagePriority( val );
+                    break;
+                case ETestSenderVisibility:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KHide)) == 0)
+                        {
+                        val = EMmsSenderVisibilityHide;
+                        }
+                    else if ((iValueBuffer.CompareF(KShow)) == 0)
+                        {
+                        val = EMmsSenderVisibilityShow;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetSenderVisibility( val );
+                    break;
+                case ETestDeliveryReport:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDeliveryReport( val );
+                    break;
+                case ETestDelivReportSendAllow:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReportAllowed( val );
+                    break;
+
+                case ETestReadReply:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadReply( val );
+                    break;
+                case ETestNewAttachment:
+                    oneAtta = CMmsAttaStructure::NewL();
+                    iAttaStructures->AppendL(oneAtta);
+                    oneAtta->iAtta->Des().Copy( iValueBuffer );
+                    iAttaCount++;
+                    break;
+                case ETestAttachmentType:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaType->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentContLoc:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttaRecommendedName:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaRecommendedName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentCharset:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        if (oneAtta != NULL)
+                            {
+                            oneAtta->iAttaCharset = val;
+                            }
+                        }
+                    break;
+                case ETestAttachmentCid:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaCid->Des().Copy(iValueBuffer);
+                        }
+                    break;
+                case ETestAttContTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttContTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttachmentRoot:
+                    iAttaRoot = iAttaCount;
+                    break;
+                case ETestAlias:
+                    // all aliases are global even if they appear
+                    // in the middle of a message
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+                case ETestMessageClass: // should be handled!
+                    val = EMmsClassPersonal;
+                    if ((iValueBuffer.CompareF(KPersonal)) == 0)
+                        {
+                        val = EMmsClassPersonal;
+                        }
+                    else if ((iValueBuffer.CompareF(KAdvertisement)) == 0)
+                        {
+                        val = EMmsClassAdvertisement;
+                        }
+                    else if ((iValueBuffer.CompareF(KInformational)) == 0)
+                        {
+                        val = EMmsClassInformational;
+                        }
+                    else if ((iValueBuffer.CompareF(KAuto)) == 0)
+                        {
+                        val = EMmsClassAuto;
+                        }
+                    else
+                        {
+                        val = (TMmsMessageClass)KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageClass( val );
+                    break;
+                case ETestReplyCharging:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRequested)) == 0)
+                        {
+                        val = KMmsReplyChargingRequested;
+                        }
+                    else if ((iValueBuffer.CompareF(KReqTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingRequestedTextOnly;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccepted)) == 0)
+                        {
+                        val = KMmsReplyChargingAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingAcceptedTextOnly;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReplyCharging( val );
+                    break;
+                case ETestReplyChargAbs:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.SetReplyChargingDate( (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestReplyChargRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingInterval( val );
+                        }
+                    break;
+                case ETestReplyChargSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingSize( val );
+                        }
+                    break;
+                case ETestReplyChargID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplyChargingIdL( iByteBuffer->Des() );
+                    break;
+                case ETestTID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetTidL( iByteBuffer->Des() );
+                    break;
+                case ETestContentLocation:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteReq )
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().ContentLocationList().AppendL( iByteBuffer->Des() );
+                        }
+                    else if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteContentLocationL( order, iByteBuffer->Des() );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetContentLocationL( iByteBuffer->Des() );
+                        }
+                    break;
+                case ETestPreviouslySentIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+                case ETestPreviouslySentBy:
+                    aMmsHeaders.InsertPreviouslySentByL( order, iValueBuffer );
+                    break;
+                case ETestPreviouslySentDate:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.InsertPreviouslySentDateL( order, (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestMessageId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetMessageIdL( iByteBuffer->Des() );
+                    break;
+                case ETestMessageSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMessageSize( val );
+                        }
+                    break;
+                case ETestVersion:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,EHex,limit);
+                    shortInteger = TInt16( val );
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMmsVersion( shortInteger );
+                        }
+                    break;
+                case ETestReadStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRead)) == 0)
+                        {
+                        val = KMmsReadStatusRead;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelNotRead)) == 0)
+                        {
+                        val = KMmsReadStatusDeletedWithoutBeingRead;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadStatus( val );
+                    break;
+                case ETestResponseStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnspecified)) == 0)
+                        {
+                        val = KMmsErrorUnspecified;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageNotFound)) == 0)
+                        {
+                        val = KMmsErrorMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrNetworkProblem)) == 0)
+                        {
+                        val = KMmsErrorNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorNoContentAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnsupportedMessage)) == 0)
+                        {
+                        val = KMmsErrorUnsupportedMessage;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorTransientSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorPermanentSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentContentNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingLimitNotMet)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingLimitationsNotMet;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingRequestNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingRequestNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingForwardingDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingForwardingDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingNotSupported;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientPartialSuccess)) == 0)
+                        {
+                        val = KMmsErrorTransientPartialSuccess;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressHidingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentAddressHidingNotSupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteStatusL( order, val );
+                        }
+                    else
+                        {
+                         aMmsHeaders.SetResponseStatus( val );
+                        }
+                    break;
+                case ETestResponseText:
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteResponseTextL( order, iValueBuffer );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetResponseTextL( iValueBuffer );
+                        }
+                    break;
+                case ETestRetrieveStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrRetrieveContentUnsupported)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentContentUnsupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetResponseStatus( val );
+                    break;
+                case ETestRetrieveText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDeferred)) == 0)
+                        {
+                        val = KMmsMessageStatusDeferred;
+                        }
+                    else if ((iValueBuffer.CompareF(KExpired)) == 0)
+                        {
+                        val = KMmsMessageStatusExpired;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsMessageStatusRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KRejected)) == 0)
+                        {
+                        val = KMmsMessageStatusRejected;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnrecognized)) == 0)
+                        {
+                        val = KMmsMessageStatusUnrecognized;
+                        }
+                    else if ((iValueBuffer.CompareF(KIndeterminate)) == 0)
+                        {
+                        val = KMmsMessageStatusIndeterminate;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsMessageStatusForwarded;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnreachable)) == 0)
+                        {
+                        val = KMmsMessageStatusUnreachable;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetStatus( val );
+                    break;
+                case ETestMessageType:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KSendReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KSendConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifInd)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotificationInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifResp)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotifyRespInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMRetrieveConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KAckInd)) == 0)
+                        {
+                        val = KMmsMessageTypeAcknowledgeInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelInd)) == 0)
+                        {
+                        val = KMmsMessageTypeDeliveryInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadReqInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadRecInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadOrigInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadOrigInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardRec)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardConf)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDescr)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDescr;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelReq)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelResp)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelConf;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageType( val );
+                    break;
+                case ETestAttribute:
+                    val = 0;
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ((iByteBuffer->Des().CompareF(KTestBcc)) == 0)
+                        {
+                        val = KMmsAssignedBcc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestCc)) == 0)
+                        {
+                        val = KMmsAssignedCc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContent)) == 0)
+                        {
+                        val = KMmsAssignedContent;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContentType)) == 0)
+                        {
+                        val = KMmsAssignedContentType;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDate)) == 0)
+                        {
+                        val = KMmsAssignedDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryReport)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryReport;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryTime)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryTime;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestExpiry)) == 0)
+                        {
+                        val = KMmsAssignedExpiry;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestFrom)) == 0)
+                        {
+                        val = KMmsAssignedFrom;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageClass)) == 0)
+                        {
+                        val = KMmsAssignedMessageClass;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageId)) == 0)
+                        {
+                        val = KMmsAssignedMessageId;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageSize)) == 0)
+                        {
+                        val = KMmsAssignedMessageSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPriority)) == 0)
+                        {
+                        val = KMmsAssignedPriority;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReadReply)) == 0)
+                        {
+                        val = KMmsAssignedReadReply;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestSubject)) == 0)
+                        {
+                        val = KMmsAssignedSubject;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestTo)) == 0)
+                        {
+                        val = KMmsAssignedTo;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharging)) == 0)
+                        {
+                        val = KMmsAssignedReplyCharging;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargID)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingID;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharg)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingDeadline;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargSize)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentBy)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentBy;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentDate)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestAdditionalHeaders)) == 0)
+                        {
+                        val = KMmsAssignedAdditionalHeaders;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().AttributeArray().InsertInOrder(val);
+                    break;
+                case ETestDistributionIndicator:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDistributionIndicator( val );
+                    break;
+                case ETestLimit:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if( error == KErrNone )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(val);
+                        }
+                    break;
+                case ETestMessageQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(val);
+                        }
+                    break;
+                case ETestSizeQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(val);
+                        }
+                    break;
+                case ETestMessageTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(val);
+                        }
+                    break;
+                case ETestSizeTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(val);
+                        }
+                    break;
+                case ETestMessageCount:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(val);
+                        }
+                    break;
+                case ETestAddKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsAddToken, iValueBuffer);
+                    break;
+                case ETestRemoveKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsRemoveToken, iValueBuffer);
+                    break;
+                case ETestFilterKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsFilterToken, iValueBuffer);
+                    break;
+                case ETestMMState:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDraft)) == 0)
+                        {
+                        val = KMmsDraft;
+                        }
+                    else if ((iValueBuffer.CompareF(KSent)) == 0)
+                        {
+                        val = KMmsSent;
+                        }
+                    else if ((iValueBuffer.CompareF(KNew)) == 0)
+                        {
+                        val = KMmsNew;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsForwarded;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().MMStateArray().InsertInOrder( val );
+                        }
+                    else
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().SetMMState( val );
+                        }
+                    break;
+                case ETestQuota:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsQuotas( val );
+                    break;
+                case ETestStart:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsStart(val);
+                        }
+                    break;
+                case ETestStore:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStore( val );
+                    break;
+                case ETestStored:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStored( val );
+                    break;
+                case ETestStoreStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMMBoxFull)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMmboxFull;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatus( val );
+                    break;
+                case ETestStoreStatusText:
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatusTextL( iValueBuffer );
+                    break;
+                case ETestTotals:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsTotals( val );
+                    break;
+
+                case ETestDeleteInfoIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+
+                case ETestApplicId:
+                    aMmsHeaders.SetApplicIdL( iValueBuffer );
+                    break;
+                case ETestReplyApplicId:
+                    aMmsHeaders.SetReplyApplicIdL( iValueBuffer );
+                    break;
+                case ETestApplicInfo:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetAuxApplicInfoL( iByteBuffer->Des() );
+                    break;
+                case ETestContentClass:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KText)) == 0)
+                        {
+                        val = KMmsContentClassText;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageBasic)) == 0)
+                        {
+                        val = KMmsContentClassImageBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageRich)) == 0)
+                        {
+                        val = KMmsContentClassImageRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoBasic)) == 0)
+                        {
+                        val = KMmsContentClassVideoBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoRich)) == 0)
+                        {
+                        val = KMmsContentClassVideoRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KMegaPixel)) == 0)
+                        {
+                        val = KMmsContentClassMegaPixel;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentBasic)) == 0)
+                        {
+                        val = KMmsContentClassContentBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentRich)) == 0)
+                        {
+                        val = KMmsContentClassContentRich;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetContentClass( val );
+                    break;
+                case ETestDrmContent:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDrmContent( val );
+                    break;
+                case ETestAdaptationAllowed:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetAdaptationAllowed( val );
+                    break;
+                case ETestRecommendedRetrievalMode:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KManual)) == 0)
+                        {
+                        val = KMmsRecommendedRetrievalModeManual;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetRecommendedRetrievalMode( val );
+                    break;
+                case ETestRecRetrievalModeText:
+                    aMmsHeaders.SetRecommendedRetrievalModeTextL( iValueBuffer );
+                    break;
+                case ETestReplaceId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestStatusText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestCancelId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestCancelStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KCancelSuccessful)) == 0)
+                        {
+                        val = KMmsCancelRequestSuccessfullyReceived;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelCorrupted)) == 0)
+                        {
+                        val = KMmsCancelRequestCorrupted;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetCancelStatus( val );
+                    break;
+                default:
+                    break;
+                }
+            }
+            else
+            {
+            switch(readStatus)
+                {
+                case ETestAlias:
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+
+                default:
+                    break;
+                }
+
+            }
+        }
+    return(-1);
+}
+
+// ---------------------------------------------------------
+// CMmsReadFile()::ReadRowL
+// ---------------------------------------------------------
+//
+TTestReadStatus CMmsReadFile::ReadRowL()
+    {
+
+        TBuf8<DefaultBufLen> RowBuffer;
+        TBuf8<32> KeyBuffer;
+
+        // READ ONE ROW AND DROP CR+LF FROM THE END OF LINE
+        TChar delim( 10 );
+        iReader->ReadL( RowBuffer, delim);
+        TInt length = RowBuffer.Length();
+        if ( RowBuffer.Length() < 2 )
+            {
+            return ETestEof;
+            }
+        RowBuffer.Delete(length - 2,2);
+
+        // DROP POSSIBLE COMMENT OUT
+        TInt pos = RowBuffer.Locate( ';' );
+		if ( pos >= 0 ) RowBuffer.Delete( pos, length-pos-2 );
+
+        if ( RowBuffer.Length() == 0 )
+            {
+            // the line contained only comment
+            return ETestUnknown;
+            }
+
+        // First split the row (:)
+        pos = RowBuffer.Locate( ':' );
+        if (pos > 0)
+        {
+            TPtrC8 p = RowBuffer.Mid( pos+1 );
+            length = p.Length();
+            iValueBuffer.Zero();
+            for (TInt i=0; i < length; ++i)
+                {
+                iValueBuffer.Append(p[i]);
+                }
+            iValueBuffer.Trim();
+            TPtrC8 pp = RowBuffer.Left(pos);
+            KeyBuffer.CopyUC(pp);
+            KeyBuffer.Trim();
+        }
+        // TRY TO FIND CORRECT TAG
+        if ((KeyBuffer.CompareF(KTestNewMessage)) == 0) return(ETestNewMessage);
+        if ((KeyBuffer.CompareF(KTestMessageType)) == 0) return ETestMessageType;
+        if ((KeyBuffer.CompareF(KTestDate)) == 0) return ETestDate;
+        if ((KeyBuffer.CompareF(KTestFrom)) == 0) return ETestFrom;
+        if ((KeyBuffer.CompareF(KTestTo)) == 0) return ETestTo;
+        if ((KeyBuffer.CompareF(KTestCc)) == 0) return ETestCc;
+        if ((KeyBuffer.CompareF(KTestBcc)) == 0) return ETestBcc;
+        if ((KeyBuffer.CompareF(KTestSubject)) == 0) return ETestSubject;
+        if ((KeyBuffer.CompareF(KTestExpiryRel)) == 0) return ETestExpiryRel;
+        if ((KeyBuffer.CompareF(KTestExpiryAbs)) == 0) return ETestExpiryAbs;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeRel)) == 0) return ETestDeliveryTimeRel;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeAbs)) == 0) return ETestDeliveryTimeAbs;
+        if ((KeyBuffer.CompareF(KTestPriority)) == 0) return ETestPriority;
+        if ((KeyBuffer.CompareF(KTestSenderVisibility)) == 0) return ETestSenderVisibility;
+        if ((KeyBuffer.CompareF(KTestDeliveryReport)) == 0) return ETestDeliveryReport;
+        if ((KeyBuffer.CompareF(KTestReadReply)) == 0) return ETestReadReply;
+        if ((KeyBuffer.CompareF(KTestNewAttachment)) == 0) return ETestNewAttachment;
+        if ((KeyBuffer.CompareF(KTestAttachmentName)) == 0) return ETestAttaRecommendedName;
+        if ((KeyBuffer.CompareF(KTestAttachmentContLoc)) == 0) return ETestAttachmentContLoc;
+        if ((KeyBuffer.CompareF(KTestAttachmentType)) == 0) return ETestAttachmentType;
+        if ((KeyBuffer.CompareF(KTestAttachmentCharset)) == 0) return ETestAttachmentCharset;
+        if ((KeyBuffer.CompareF(KTestAttachmentCid)) == 0) return ETestAttachmentCid;
+        if ((KeyBuffer.CompareF(KTestAttachmentRoot)) == 0) return ETestAttachmentRoot;
+        if ((KeyBuffer.CompareF(KTestEndOfFile)) == 0) return ETestEof;
+        if ((KeyBuffer.CompareF(KTestMessageClass)) == 0) return ETestMessageClass;
+        if ((KeyBuffer.CompareF(KTestDelivRepSendAllow)) == 0) return ETestDelivReportSendAllow;
+        if ((KeyBuffer.CompareF(KTestAlias)) == 0 ) return ETestAlias;
+        if ((KeyBuffer.CompareF(KTestFromAlias)) == 0 ) return ETestFromAlias;
+        if ((KeyBuffer.CompareF(KTestToAlias)) == 0 ) return ETestToAlias;
+        if ((KeyBuffer.CompareF(KTestCcAlias)) == 0 ) return ETestCcAlias;
+        if ((KeyBuffer.CompareF(KTestBccAlias)) == 0 ) return ETestBccAlias;
+        if ((KeyBuffer.CompareF(KTestReplyCharging)) == 0 ) return ETestReplyCharging;
+        if ((KeyBuffer.CompareF(KTestReplyChargAbs)) == 0 ) return ETestReplyChargAbs;
+        if ((KeyBuffer.CompareF(KTestReplyChargRel)) == 0 ) return ETestReplyChargRel;
+        if ((KeyBuffer.CompareF(KTestReplyChargSize)) == 0 ) return ETestReplyChargSize;
+        if ((KeyBuffer.CompareF(KTestReplyChargID)) == 0 ) return ETestReplyChargID;
+        if ((KeyBuffer.CompareF(KTestTID)) == 0 ) return ETestTID;
+        if ((KeyBuffer.CompareF(KTestContentLocation)) == 0 ) return ETestContentLocation;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentIndex)) == 0 ) return ETestPreviouslySentIndex;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentBy)) == 0 ) return ETestPreviouslySentBy;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentDate)) == 0 ) return ETestPreviouslySentDate;
+        if ((KeyBuffer.CompareF(KTestMessageId)) == 0 ) return ETestMessageId;
+        if ((KeyBuffer.CompareF(KTestMessageSize)) == 0 ) return ETestMessageSize;
+        if ((KeyBuffer.CompareF(KTestVersion)) == 0 ) return ETestVersion;
+        if ((KeyBuffer.CompareF(KTestReadStatus)) == 0 ) return ETestReadStatus;
+        if ((KeyBuffer.CompareF(KTestResponseStatus)) == 0 ) return ETestResponseStatus;
+        if ((KeyBuffer.CompareF(KTestResponseText)) == 0 ) return ETestResponseText;
+        if ((KeyBuffer.CompareF(KTestRetrieveStatus)) == 0 ) return ETestRetrieveStatus;
+        if ((KeyBuffer.CompareF(KTestRetrieveText)) == 0 ) return ETestRetrieveText;
+        if ((KeyBuffer.CompareF(KTestStatus)) == 0 ) return ETestStatus;
+        if ((KeyBuffer.CompareF(KTestAttribute)) == 0 ) return ETestAttribute;
+        if ((KeyBuffer.CompareF(KTestDistributionIndicator)) == 0 ) return ETestDistributionIndicator;
+        if ((KeyBuffer.CompareF(KTestLimit)) == 0 ) return ETestLimit;
+        if ((KeyBuffer.CompareF(KTestMessageQuota)) == 0 ) return ETestMessageQuota;
+        if ((KeyBuffer.CompareF(KTestSizeQuota)) == 0 ) return ETestSizeQuota;
+        if ((KeyBuffer.CompareF(KTestMessageTotal)) == 0 ) return ETestMessageTotal;
+        if ((KeyBuffer.CompareF(KTestSizeTotal)) == 0 ) return ETestSizeTotal;
+        if ((KeyBuffer.CompareF(KTestMessageCount)) == 0 ) return ETestMessageCount;
+        if ((KeyBuffer.CompareF(KTestAddKeyword)) == 0 ) return ETestAddKeyword;
+        if ((KeyBuffer.CompareF(KTestRemoveKeyword)) == 0 ) return ETestRemoveKeyword;
+        if ((KeyBuffer.CompareF(KTestFilterKeyword)) == 0 ) return ETestFilterKeyword;
+        if ((KeyBuffer.CompareF(KTestMMState)) == 0 ) return ETestMMState;
+        if ((KeyBuffer.CompareF(KTestQuota)) == 0 ) return ETestQuota;
+        if ((KeyBuffer.CompareF(KTestStart)) == 0 ) return ETestStart;
+        if ((KeyBuffer.CompareF(KTestStore)) == 0 ) return ETestStore;
+        if ((KeyBuffer.CompareF(KTestStored)) == 0 ) return ETestStored;
+        if ((KeyBuffer.CompareF(KTestStoreStatus)) == 0 ) return ETestStoreStatus;
+        if ((KeyBuffer.CompareF(KTestStoreStatusText)) == 0 ) return ETestStoreStatusText;
+        if ((KeyBuffer.CompareF(KTestTotals)) == 0 ) return ETestTotals;
+        if ((KeyBuffer.CompareF(KTestDeleteInfoIndex)) == 0 ) return ETestDeleteInfoIndex;
+        if ((KeyBuffer.CompareF(KTestApplicId)) == 0 ) return ETestApplicId;
+        if ((KeyBuffer.CompareF(KTestReplyApplicId)) == 0 ) return ETestReplyApplicId;
+        if ((KeyBuffer.CompareF(KTestApplicInfo)) == 0 ) return ETestApplicInfo;
+        if ((KeyBuffer.CompareF(KTestContentClass)) == 0 ) return ETestContentClass;
+        if ((KeyBuffer.CompareF(KTestDrmContent)) == 0 ) return ETestDrmContent;
+        if ((KeyBuffer.CompareF(KTestAdaptationAllowed)) == 0 ) return ETestAdaptationAllowed;
+        if ((KeyBuffer.CompareF(KTestRecommendedRetrievalMode)) == 0 ) return ETestRecommendedRetrievalMode;
+        if ((KeyBuffer.CompareF(KTestRecRetrievalModeText)) == 0 ) return ETestRecRetrievalModeText;
+        if ((KeyBuffer.CompareF(KTestReplaceId)) == 0 ) return ETestReplaceId;
+        if ((KeyBuffer.CompareF(KTestStatusText)) == 0 ) return ETestStatusText;
+        if ((KeyBuffer.CompareF(KTestCancelId)) == 0 ) return ETestCancelId;
+        if ((KeyBuffer.CompareF(KTestCancelStatus)) == 0 ) return ETestCancelStatus;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamName)) == 0 ) return ETestAttContTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamValue)) == 0 ) return ETestAttContTypeParamValue;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamName)) == 0 ) return ETestAttXTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamValue)) == 0 ) return ETestAttXTypeParamValue;
+        return ETestUnknown;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CreateMessageL
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+void CMmsReadFile::CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders )
+    {
+
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+
+    TInt      i;
+    TInt error = KErrNone;
+    RFile attaFile;
+    _LIT8(KLeftAngle, "<");
+    _LIT8(KRightAngle, ">");
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+
+    CMsvStore* store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    aMmsHeaders->StoreL(*store);
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    aMmsClient->LoadMessageL(); // read store is needed to do this
+
+    store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    CMsvAttachment* attaInfo = NULL;
+    TMsvAttachmentId attaId = 0;
+
+    for ( i=0; i < iAttaStructures->Count(); ++i)
+        {
+        attaId = KMsvNullIndexEntryId;
+        iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+
+        error = attaFile.Open( iFs, iFilename, EFileShareReadersOnly | EFileRead );
+        User::LeaveIfError( error );
+
+		CleanupClosePushL(attaFile);
+
+		CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+		CleanupStack::PushL( mimeHeaders );
+		TPtrC8 contentType = iAttaStructures->At(i)->iAttaType->Des();
+
+        TDataRecognitionResult result;
+        result.Reset(); // make sure that it is cleared
+
+        if(iAttaStructures->At(i)->iAttaCid->Length())
+            {
+            TPtr8 attaCID = iAttaStructures->At(i)->iAttaCid->Des();
+            if (attaCID.Find(KLeftAngle) == 0 &&
+                attaCID.Find(KRightAngle) == attaCID.Length()-1 )
+                {
+                // remove angle brackets from cid
+                attaCID = attaCID.Mid(1,attaCID.Length()-2);
+                }
+            mimeHeaders->SetContentIdL(attaCID);
+            }
+
+        if (iAttaStructures->At(i)->iAttaCharset)
+            {
+            mimeHeaders->SetMimeCharset(iAttaStructures->At(i)->iAttaCharset);
+            }
+
+        if (iAttaStructures->At(i)->iAttaName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaName->Des());
+            }
+        iParse.Set( iFilename, NULL, NULL );
+        iFilename.Copy( iParse.NameAndExt() );
+
+        mimeHeaders->SetContentLocationL( iFilename );
+
+		// if Mime type has not been set, use RapaRecognizer
+		if ( iAttaStructures->At(i)->iAttaType->Length() == 0 && iFilename.Length() > 0)
+		    {
+		    // TO BE IMPLEMENTED
+
+            RApaLsSession lsSession;
+
+            if ( lsSession.Connect() == KErrNone )
+                {
+                CleanupClosePushL( lsSession );
+
+                iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+                if ( lsSession.RecognizeData( iFilename, TPtrC8(), result ) == KErrNone )
+                    {
+                    // Check confidence level. Recognization must be at least
+                    // "EProbable". We don't accept the result if it is "EPossible"
+                    // or "EUnlikely" or "ENotRecognized"!
+
+                    if ( result.iConfidence < CApaDataRecognizerType::EProbable )
+                        {
+                        result.Reset(); // clear buffer and try again with longer buffer
+                        }
+
+                    TPtrC8 mimeBuf8 = result.iDataType.Des8();
+
+                    if ( mimeBuf8.Length() == 0 )
+                        {
+                        // Open file buffer and try again..
+
+                        TInt bufSize = 0;
+                        (void)lsSession.GetMaxDataBufSize( bufSize ); // ignore errors
+                        if ( bufSize <= 0 )
+                            {
+                            bufSize = 30;
+                            }
+                        HBufC8* buf = HBufC8::NewLC( bufSize );
+                        TPtr8 des = buf->Des();
+
+                        RFile file;
+                        TInt err=file.Open( iFs, iFilename, EFileShareReadersOnly );
+                        if ( err == KErrNone )
+                            {
+                            err = file.Read( des );
+                            file.Close();
+                            if ( err == KErrNone )
+                                {
+                                if ( ( lsSession.RecognizeData( iFilename, des, result ) ) == KErrNone )
+                                    {
+                                    mimeBuf8.Set( result.iDataType.Des8() );
+                                    }
+                                }
+
+                            }
+                        CleanupStack::PopAndDestroy(); // buf
+                        }
+                    if ( mimeBuf8.Length() > 0 &&
+                        result.iConfidence >= CApaDataRecognizerType::EProbable )
+                        {
+                        contentType.Set( result.iDataType.Des8() );
+                        }
+                    }
+                CleanupStack::PopAndDestroy(1); // lssession
+                }
+		    }
+
+        if ( contentType.Length() > 0 )
+            {
+            TInt position = contentType.Find( KMmsSlash8 );
+            if ( position >= 0 )
+                {
+                mimeHeaders->SetContentTypeL( contentType.Left( position ) );
+                }
+            if ( position < contentType.Length() - 1 )
+                {
+                mimeHeaders->SetContentSubTypeL( contentType.Mid( position + 1 ) );
+                }
+//          CreateAttachment2L sets the content type to attaInfo
+//            attaInfo->SetMimeTypeL( contentType );
+            }
+
+        if (iAttaStructures->At(i)->iAttaRecommendedName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaRecommendedName->Des());
+            iParse.Set( iFilename, NULL, NULL );
+            iFilename.Copy( iParse.NameAndExt() );
+            mimeHeaders->SetSuggestedFilenameL( iFilename );
+            }
+
+        TInt j = 0;
+        for ( j = 0; j < iAttaStructures->At(i)->iContentTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->ContentTypeParams().AppendL( iAttaStructures->At(i)->iContentTypeParams->MdcaPoint( j ) );
+            }
+        for ( j = 0; j < iAttaStructures->At(i)->iXTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->XTypeParams().AppendL( iAttaStructures->At(i)->iXTypeParams->MdcaPoint( j ) );
+            }
+
+        attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
+        // attaInfo does not go onto cleaunpstack because ownership will
+        // be transferred to attachment manager.
+
+        aMmsClient->CreateAttachment2L(
+            *store,
+            attaFile,
+            contentType,
+            *mimeHeaders,
+            attaInfo,
+            attaId);
+        attaInfo = NULL; // ownership transferred
+
+        CleanupStack::PopAndDestroy(); // mimeHeaders
+        CleanupStack::PopAndDestroy(); // attaFile.Close()
+
+        if ( iAttaRoot > 0 && iAttaRoot == ( i + 1 ) )
+            {
+            aMmsClient->SetMessageRootL( attaId );
+            }
+        }
+
+    store->CommitL();
+    CleanupStack::PopAndDestroy(); // store
+
+    // This frees all memory and resets all values
+    Reset();
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+    }
+
+
+// ---------------------------------------------------------
+// CMmsReadFile()::FindAlias
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::FindAlias( TPtrC aAlias )
+    {
+	TBuf<DefaultBufLen> abuf;
+	for( TInt i=0; i < iAliasCount; ++i )
+	    {
+		abuf.Copy( iAliasArray->MdcaPoint(i) );
+		abuf.SetLength( abuf.Locate('=') );
+		if( ( abuf.CompareF( aAlias ) ) == 0 ) return( i );
+	    }
+	return( -1 );
+    }
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsAttaStructure::CMmsAttaStructure()
+    {
+    iAtta = NULL;
+    iAttaType = NULL;
+    iAttaName = NULL;
+    iAttaCid = NULL;
+    iAttaRecommendedName = NULL;
+    }
+
+
+//
+void CMmsAttaStructure::ConstructL()
+    {
+    iAtta = HBufC8::NewL(DefaultBufLen);
+    iAttaType = HBufC8::NewL(DefaultBufLen);
+    iAttaName = HBufC8::NewL(DefaultBufLen);
+    iAttaCid = HBufC8::NewL(DefaultBufLen);
+    iAttaRecommendedName = HBufC::NewL(DefaultBufLen);
+    iAttaCharset = 0;
+   	iXTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+   	iContentTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+
+    }
+
+// Two-phased constructor.
+CMmsAttaStructure* CMmsAttaStructure::NewL()
+    {
+    CMmsAttaStructure* self = new ( ELeave ) CMmsAttaStructure;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// Destructor
+CMmsAttaStructure::~CMmsAttaStructure()
+    {
+    delete iAtta;
+    delete iAttaName;
+    delete iAttaType;
+    delete iAttaCid;
+    delete iAttaRecommendedName;
+    if ( iContentTypeParams )
+        {
+    	iContentTypeParams->Reset();
+        }
+  	delete iContentTypeParams;
+    if ( iXTypeParams )
+        {
+      	iXTypeParams->Reset();
+        }
+	delete iXTypeParams;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmstestbed.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,2357 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <mtmdef.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <mmsheaders.h>
+#include <mmscmds.h>
+#include <mmsencode.h>
+#include <mmscliententry.h>
+#include <logwrap.h>
+#include <logcli.h>
+#include <logview.h>
+#include "mmssettings.h"  //use mmssettings.h instead of cmmssettings.h
+#include "mmstestbed.h"
+#include "mmsreadfile.h"
+#include "mmstestuitimer.h"
+#include "mmsteststaticutils.h"
+#include "mmstestbed.hrh"
+
+//constants
+_LIT( KMmsSender, "0601234567" );
+
+MmsTestBed::MmsTestBed()
+    {
+    //start the timer
+    iTimer = CTestUiTimer::NewL();
+    iTimer->Cancel();
+
+    iWait = CMsvOperationActiveSchedulerWait::NewLC();
+    // don't leave iWait on cleanup stack
+    CleanupStack::Pop();
+
+    //open msvsession
+    iSession = CMsvSession::OpenSyncL(*this);
+    //create client registry
+    iClientMtmRegistry = CClientMtmRegistry::NewL(*iSession);
+    //create client mtm
+    iMmsClient = (CMmsClientMtm *) iClientMtmRegistry->NewMtmL(
+            KUidMsgTypeMultimedia);
+
+    User::LeaveIfError( iFs.Connect() );
+    iFs.SetSessionPath( KRootPath );
+    iSettings = CMmsSettings::NewL();
+    iMmsHeaders = CMmsHeaders::NewL(iSettings->MmsVersion());
+    findDefaultL();
+    iServiceId = iDefaultServiceId;
+
+    //validate the settings
+    iSettings->ValidateSettings();
+
+    iLogEvent = CLogEvent::NewL();
+    iLogEvent->SetEventType(KLogMmsEventTypeUid);
+    iLogClient = NULL; // we test soon if this is available
+    iLogView = NULL; // needs log client
+    if ( checkLogClient() )
+        {
+        // first we generate a general view of all events
+        // we'll set the filter when we update the view
+        iLogView = CLogViewEvent::NewL( *iLogClient );
+        }
+    iLogFilter = CLogFilter::NewL();
+    // we try to filter MMS events
+    iLogFilter->SetEventType(KLogMmsEventTypeUid);
+    }
+
+MmsTestBed::~MmsTestBed()
+    {
+    delete iLogView;
+    delete iLogFilter;
+    delete iLogClient;
+    delete iLogEvent;
+    delete iSettings;
+    delete iMmsHeaders;
+    if(iTimer)
+    {
+        iTimer->Cancel();
+        delete iTimer;
+    }
+    //delete iMsvEntrySelection;
+    delete iMmsClient;
+    delete iClientMtmRegistry;
+    //delete iClientMtmRegistry;
+    delete iSession;
+    delete iWait;
+    }
+
+void MmsTestBed::setConnectionLocal(bool value)
+    {
+    //value = true for global off, local on
+    //value = false for global on, local off
+    iSettings->LoadSettingsL();
+    iSettings->SetLocalMode( value );
+    iSettings->SaveSettingsL();
+    }
+
+void MmsTestBed::fromOutboxToMmsc()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    // Get List of services
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL(
+            KUidMsgTypeMultimedia);
+    CleanupStack::PushL(selection);
+
+    // Change state to "KMsvSendStateUnknown" in case the entry has been suspended earlier
+    for (TInt i = 0; i < selection->Count(); ++i)
+        {
+        cEntry->SetEntryL(selection->At(i));
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly(EFalse);
+        entry.SetSendingState(KMsvSendStateUnknown);
+        cEntry->ChangeL(entry);
+        }
+
+    selection->InsertL(0, iServiceId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iSession->TransferCommandL(*selection, EMmsSend, paramPack,
+            iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    CleanupStack::PopAndDestroy(); //cEntry
+    }
+
+void MmsTestBed::fromMmscToInbox()
+    {
+    CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+    CleanupStack::PushL(msvEntrySelection);
+
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        msvEntrySelection->InsertL(0, iServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iMmsClient->InvokeAsyncFunctionL(EMmsReceive, *msvEntrySelection,
+            paramPack, iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to receive, return status %d"),iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); //msvEntrySelection
+    }
+
+void MmsTestBed::findDefaultL()
+    {
+    iSettings->LoadSettingsL();
+    iDefaultServiceId = iSettings->Service();
+    }
+
+void MmsTestBed::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+        TAny* aArg2, TAny* /*aArg3*/)
+    {
+    iEvent = aEvent;
+    if (aEvent == EMsvGeneralError)
+        {
+        return;
+        }
+    TMsvId parentId = KMsvNullIndexEntryId;
+    if (aArg2 != NULL)
+        {
+        parentId = *(TMsvId*) aArg2;
+        }
+
+    CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+    TMsvEntry tEntry;
+    TMsvId service;
+    TInt error = KErrNone;
+    error = iSession->GetEntry(selection->At(0), service, tEntry);
+
+    CMsvEntry* cEntry = NULL;
+    switch (aEvent)
+        {
+        case EMsvEntriesCreated:
+            {
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+                // emit signal for new entry into INBOX
+                emit entryCreatedInInbox(tEntry.Id());
+                }
+            else if (parentId == KMsvDraftEntryIdValue)
+                {
+                // emit signal for new entry into Draft
+                emit entryCreatedInDraft(tEntry.Id());
+                }
+            else if (parentId == iServiceId)
+                {
+                // emit signal for new Entry into SERVICE
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        case EMsvEntriesChanged:
+            {
+            TMsvId id;
+            CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+            if (selection == NULL)
+                {
+                // no selection, cannot handle
+                return;
+                }
+            id = selection->At(0);
+            //DEBUG Entry changed"));
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+/*
+                cEntry = iSession->GetEntryL( parentId );
+                CleanupStack::PushL( cEntry );
+                TRAPD (error, cEntry->SetEntryL( id ));
+                if ( error != KErrNone )
+                    {
+                    CleanupStack::PopAndDestroy(); // cEntry
+                    return;
+                    }
+                TMsvEntry tEntry = cEntry->Entry();
+                if ( tEntry.Visible() )
+                    {
+                    // generate fake delivery report
+                    CMsvStore* store = cEntry->ReadStoreL();
+                    CleanupStack::PushL( store );
+                    CMmsHeaders* mmsHeaders = CMmsHeaders::NewL( iSettings->MmsVersion() );
+                    CleanupStack::PushL( mmsHeaders );
+                    mmsHeaders->RestoreL( *store );
+                    iEncodeBuffer->ResizeL( 0 );
+                    generateDeliveryReport( mmsHeaders );
+                    CleanupStack::PopAndDestroy( 2 ); // mmsHeaders, store
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+*/
+                }
+            }
+            break;
+        case EMsvEntriesDeleted:
+            {
+            //emit signal for entry deleted
+            }
+            break;
+        case EMsvEntriesMoved:
+            {
+            if (parentId == KMsvGlobalOutBoxIndexEntryIdValue)
+                {
+                // entry moved to outbox
+                emit entryMovedToOutbox(tEntry.Id());
+                }
+            else if (parentId == KMsvSentEntryIdValue)
+                {
+                // entry moved to sent folder
+                emit entryMovedToSent(tEntry.Id());
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+void MmsTestBed::createMmsService()
+    {
+    CMmsSettings * settings = CMmsSettings::NewL();
+    CleanupStack::PushL( settings );
+    settings->CreateNewServiceL( *iSession );
+    CleanupStack::PopAndDestroy(); // settings
+    return;
+    }
+
+void MmsTestBed::cleanup()
+    {
+    TMsvId entryToBeKilled;
+    // Get access to root index
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    entryToBeKilled = iSettings->Service();
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    while (entryToBeKilled != KMsvNullIndexEntryId)
+        {
+        // delete child of root entry
+        deleteEntry(entryToBeKilled, *cEntry);
+        entryToBeKilled = iSettings->Service();
+        }
+
+    CleanupStack::PopAndDestroy(); // cEntry
+    // We deleted everything!
+    iDefaultServiceId = KMsvNullIndexEntryId;
+    iServiceId = KMsvNullIndexEntryId;
+    }
+
+void MmsTestBed::deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry)
+    {
+    aClientEntry.DeleteL(aEntryId);
+    }
+
+void MmsTestBed::cleanupAndCreateNewService()
+    {
+    cleanup();
+    // all old service entries have been destroyed, create a new one
+    createMmsService();
+    }
+
+void MmsTestBed::testFile(TFileName& aFilePath, TInt aCommand /* = 0 */, TMsvId aBox /* = KMsvGlobalOutBoxIndexEntryId */ )
+    {
+    // update settings in mmsclient
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    RFileReadStream readStream;
+    readStream.PushL();
+//    TMsvId id = KMsvNullIndexEntryId;
+    CBufFlat* encodeBuffer = NULL;
+    CMmsEncode* encoder = NULL;
+
+    // Open the file
+    TInt err = readStream.Open(iFs, aFilePath, EFileShareReadersOnly );
+    if (err != KErrNone) User::Leave( err );
+
+    TInt   retCode = 0;
+    CMmsReadFile* readFile = NULL;
+    readFile = CMmsReadFile::NewL( iFs, readStream );
+    CleanupStack::PushL( readFile );
+
+    TInt messageCounter = 0;
+    CMsvEntry* cEntry = NULL;
+
+    while(!retCode)
+        {
+        // READ MESSAGE TO BUFFERS
+        iMmsHeaders->Reset(iSettings);
+        // put in some message type just for fun (testing...)
+        iMmsHeaders->SetMessageType( KMmsMessageTypeForwardReq );
+        retCode = readFile->CompleteTestL( messageCounter++, *iMmsHeaders );
+        if(readFile->iMessageType == ETestNewMessage)
+            {
+            // CREATE MESSAGE ENTRY
+            switch ( aCommand )
+                {
+                case ECreateToInbox:
+                case ECreateNotification:
+                    cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+                    break;
+                case ECreateToSentItems:
+                    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+                    break;
+                case ECreateToDrafts:
+                    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                    break;
+                case ECreateHeadersFromFile:
+                    // here we just encode headers, no message entry
+                    // the entry is fake.
+                    break;
+                case ECreateMMBoxViewConf:
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // entry is not created for the description items
+                        // they become attachments
+                        cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                        }
+                    break;
+                default:
+                    cEntry = iSession->GetEntryL(aBox);
+                    break;
+                }
+
+            // if we are just playing with headers we have no entry
+            if ( aCommand != ECreateHeadersFromFile && aCommand != ECreateMMBoxViewConf )
+                {
+                CleanupStack::PushL(cEntry);
+                iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                // CREATE MESSAGE
+                iMmsClient->CreateMessageL(iServiceId);
+                }
+            else if ( aCommand == ECreateMMBoxViewConf )
+                {
+                if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                    {
+                    CleanupStack::PushL(cEntry);
+                    iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                    // CREATE MESSAGE
+                    iMmsClient->CreateMessageL(iServiceId);
+                    }
+                else
+                    {
+                    encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                    CleanupStack::PushL( encodeBuffer );
+                    encoder = CMmsEncode::NewL( iFs );
+                    CleanupStack::PushL( encoder );
+
+                    // encode headers to a binary file
+                    encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                    iFilename = KMmsMMBoxDescriptionDirectory;
+                    TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                    CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                    encodeBuffer = NULL;
+                    encoder = NULL;
+                    }
+                }
+            else
+                {
+                encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                CleanupStack::PushL( encodeBuffer );
+                encoder = CMmsEncode::NewL( iFs );
+                CleanupStack::PushL( encoder );
+
+                // encode headers to a binary file
+                encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                iFilename = KMmsDumpDirectory;
+                TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                encodeBuffer = NULL;
+                encoder = NULL;
+                }
+            }
+
+        if ( aCommand != ECreateHeadersFromFile &&
+            ( aCommand != ECreateMMBoxViewConf || iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) )
+            {
+            if(readFile->iMessageType == ETestSettings)
+                {
+                TMsvId ServiceId = iMmsClient->DefaultServiceL();
+                iMmsClient->RestoreSettingsL();
+                iSettings->CopyL( iMmsClient->MmsSettings() );
+                }
+
+            TMemoryInfoV1Buf memory;
+            UserHal::MemoryInfo( memory );
+            TInt available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory before CreateMessageL %d"), available );
+
+            TRAP (err, readFile->CreateMessageL(iMmsClient, iMmsHeaders));
+
+            available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory after CreateMessageL %d"), available );
+
+            if(readFile->iMessageType == ETestNewMessage)
+                {
+                TMsvEntry tEntry = iMmsClient->Entry().Entry();
+                TMsvId id = tEntry.Id();
+                if ( err == KErrNone )
+                    {
+                    // SAVE MESSAGE
+                    iMmsClient->SaveMessageL();
+
+                    // If we are creating a MMBox View confirmation,
+                    // we add all binary files from KMmsMMBoxDirectory
+                    // as attachments.
+
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        addMMBoxDescriptions();
+                        }
+
+                    // reload the entry in case mms client put something into it
+                    // MESSAGE MUST BE SET VISIBLE
+                    tEntry = iMmsClient->Entry().Entry();
+                    if ( iMmsClient->MessageClass() == EMmsClassAdvertisement )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageAdvertisement;
+                        }
+                    else if ( iMmsClient->MessageClass() == EMmsClassInformational )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageInformational;
+                        }
+                    tEntry.iMtmData1 &= ~KMmsMessageMobileTerminated;
+
+                    // Test: Set all as editor oriented - except notifications!
+                    if ( aCommand == ECreateNotification )
+                        {
+                        tEntry.iMtm = KUidMsgMMSNotification;
+                        }
+                    else
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageEditorOriented;
+                        }
+                    if ( aCommand == ECreateToInbox )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageMobileTerminated;
+                        tEntry.SetReadOnly( ETrue );
+                        tEntry.SetNew( ETrue );
+                        tEntry.SetUnread( ETrue );
+                        }
+                    else if ( aCommand == ECreateToSentItems )
+                        {
+                        tEntry.SetReadOnly( ETrue );
+                        }
+                    tEntry.SetVisible( ETrue );
+                    tEntry.SetInPreparation( EFalse );
+                    TTime now;
+                    now.UniversalTime();
+                    tEntry.iDate = now;
+                    TMsvId entryId = tEntry.Id();
+                    iMmsClient->Entry().ChangeL( tEntry );
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // Encode to the directory that is used to fetch MMBox view
+                        iFilename.Copy( KMmsMMBoxDirectory );
+                        encodeMessageFromDrafts();
+                        cEntry->SetEntryL( KMsvDraftEntryId );
+                        cEntry->DeleteL( entryId );
+                        }
+                    }
+                else
+                    {
+                    //TMmsLogger::Log(_L("CreateMessageL left with error %d"), err );
+                    iSession->RemoveEntry(id);
+                    err = KErrNone; // clear error
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+                cEntry = NULL;
+                }
+            if(readFile->iMessageType == ETestSettings)
+                {
+                iMmsClient->SetSettingsL( *iSettings );
+                iMmsClient->StoreSettingsL();
+                }
+        }
+    }
+
+    CleanupStack::PopAndDestroy(); //readFile
+
+    readStream.Close();
+    readStream.Pop();
+
+    /*
+    iMmsClient->SwitchCurrentEntryL(id);
+    */
+    }
+
+void MmsTestBed::addMMBoxDescriptions()
+    {
+    // add the contents of KMmsMMBoxDescriptionDirectory as attachments
+    CDir* fileList = NULL;
+    TInt i = 0;  // general counter
+    TInt error = KErrNone;
+    iCurrentPath = KMmsMMBoxDescriptionDirectory;
+
+    iFs.SetSessionPath(iCurrentPath);
+
+    TFindFile finder( iFs );
+    error = finder.FindWildByPath( KWild, NULL, fileList );
+    CleanupStack::PushL( fileList );
+    TInt fileCounter = 0;
+
+    if ( error == KErrNone )
+        {
+        fileCounter = fileList->Count();
+        }
+
+    TEntry entry;
+
+    if ( error == KErrNone )
+        {
+        for ( i = 0; i < fileCounter; ++i )
+            {
+            // Reset inactivity timer to keep viewServer from crashing
+            User::ResetInactivityTime();
+            entry = (*fileList)[i]; // name is entry.iName
+            iFilename.Copy( iCurrentPath );
+            iFilename.Append( entry.iName );
+            TPtrC ptr;
+            ptr.Set( iFilename );
+            iWait->iStatus = KErrNone;
+            iMmsClient->AddAttachmentL( ptr, KMmsMimeType, 0, iWait->iStatus );
+
+            iWait->Start();
+            // The descriptions are cleared after being used
+            iFs.Delete( ptr);
+            }
+        }
+
+    iMmsClient->SaveMessageL(); // just in case somthing must be updated
+    CleanupStack::PopAndDestroy(); // fileList
+    fileList = NULL;
+    }
+
+void MmsTestBed::encodeMessageFromDrafts()
+    {
+    CMmsEncode* encoder = CMmsEncode::NewL( iFs );
+    CleanupStack::PushL( encoder );
+    // encode a message iMmsClientPoints to
+    iMmsClient->LoadMessageL();
+    CMsvStore* store = iMmsClient->Entry().ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy(); // store
+    store = NULL;
+    iWait->iStatus = KErrNone;
+
+// caller sets the directory
+//    iFilename = KMmsMessageDumpDirectory;
+
+    CMmsClientEntry* entryWrapper = CMmsClientEntry::NewL( iFs, iMmsClient->Entry(), iServiceId );
+    CleanupStack::PushL( entryWrapper );
+    iEncodeBuffer->ResizeL(0);
+    encoder->StartL( *entryWrapper, *iMmsHeaders, *iEncodeBuffer, iWait->iStatus );
+    iWait->Start();
+    if ( iWait->iStatus == KErrNone )
+        {
+        TMmsTestUtils::Dump( *iEncodeBuffer, iFilename, iParse, iFs );
+        }
+    iEncodeBuffer->ResizeL(0);
+    CleanupStack::PopAndDestroy(); // entryWrapper
+    CleanupStack::PopAndDestroy(); // encoder
+    }
+
+void MmsTestBed::deleteNotifications()
+    {
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    if ( mmsFolderId != KMsvNullIndexEntryId )
+        {
+        cEntry->SetEntryL(mmsFolderId);
+
+        // show invisible entries
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+        CleanupStack::PushL(msvEntrySelection);
+
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        // These cannot be deleted unless we have the a server mtm
+        // corresponding to this mtm type.
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgMMSNotification );
+        CleanupStack::PushL(msvEntrySelection);
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    }
+
+TMsvId MmsTestBed::findMMSFolder()
+    {
+    return iSettings->NotificationFolder();
+    }
+
+void MmsTestBed::restoreFactorySettings()
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+    // do not reset access point
+    TInt accessPoint = iSettings->AccessPoint( 0 );
+    iSettings->RestoreFactorySettingsL( iMmsClient->Session(), EMmsFactorySettingsLevelDeep );
+    TInt count = iSettings->AccessPointCount();
+    TInt i = 0;
+    for ( i = count - 1; i >= 0; --i )
+        {
+        iSettings->DeleteAccessPointL( i );
+        }
+    // restore the original access point
+    if ( accessPoint > 0 )
+        {
+        // a negative access point is an error (most likely "KErrNotFound")
+        iSettings->AddAccessPointL( accessPoint, 0 );
+        }
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::setFetchingState( TMmsReceivingMode aState )
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    iSettings->SetReceivingModeHome( aState );
+
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::sendFromFile()
+    {
+    CMsvOperation * op = NULL;
+
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    CleanupStack::PushL( selection );
+
+    TRAPD (error, op = iMmsClient->SendL(*selection, iWait->iStatus));
+    if ( error != KErrNone )
+        {
+        CleanupStack::PopAndDestroy(); // selection
+        delete op;
+        return;
+        }
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(2); // op, selection
+    }
+
+void MmsTestBed::sendOneByOne()
+    {
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL( selection );
+
+    CMsvEntrySelection* shortSelection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( shortSelection );
+
+    TInt i;
+
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        shortSelection->Reset();
+        shortSelection->AppendL( selection->At( i ) );
+
+        CMsvOperation * op = NULL;
+
+        TTime now;
+        now.UniversalTime();
+
+        TRAPD (error, op = iMmsClient->SendL(*shortSelection, iWait->iStatus, now ));
+        if ( error != KErrNone )
+            {
+            delete op;
+            CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+            return;
+            }
+        CleanupStack::PushL(op);
+        iWait->Start();
+
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // op
+
+        }
+    CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+    }
+
+void MmsTestBed::sendNotifications()
+    {
+    // Only send one notification!!
+
+    TInt error = KErrNone;
+
+    if (! TMmsTestUtils::IsFile(iCurrentFile, iFs) )
+        {
+        //Not a file
+        return;
+        }
+    TMsvId mmsFolder = findMMSFolder();
+
+    TEntry entry;
+
+
+    // now I think we have a filename
+    TEntry orgEntry;
+    TUint size = 0;
+    error = iFs.Entry( iCurrentFile, orgEntry );
+    size = orgEntry.iSize;
+
+    //TMmsLogger::Log(_L("- notification %S "), &iCurrentFile);
+    if ( size == 0 )
+        {
+        //empty file
+        //TMmsLogger::Log(_L("- empty file"));
+        return;
+        }
+
+    if ( iEncodeBuffer == NULL )
+        {
+        iEncodeBuffer = CBufFlat::NewL( size );
+        }
+    else
+        {
+        iEncodeBuffer->ResizeL( 0 );
+        iEncodeBuffer->ResizeL( size );
+        }
+
+    RFile inFile;
+    error = inFile.Open( iFs, iCurrentFile, EFileShareReadersOnly );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+    if ( error == KErrNone )
+        {
+        error = inFile.Read( ptr, size );
+        inFile.Close();
+        }
+    else
+       {
+       //Error
+       //TMmsLogger::Log(_L("- can't read file"));
+       return;
+       }
+
+    TUint8 byte;
+    TUint position = 0;
+    TUint32 uintvar = 0;
+
+    if ( size > 2 )
+        {
+        iEncodeBuffer->Read( 1, &byte, 1 );
+        if ( byte == 6 ) // PUSH PDU
+            {
+            // try to find out length of header
+            position = 2;
+            iEncodeBuffer->Read( position, &byte, 1);
+
+            while ( byte & 0x80  && position < size )
+                {
+                uintvar += ( byte & 0x7f );
+                uintvar <<= 7;
+                position++;
+                iEncodeBuffer->Read( position, &byte, 1 );
+                }
+
+            // add last byte without shift
+            uintvar += byte;
+            position++;
+           }
+        }
+
+    position += uintvar;
+
+    if ( position < size )
+        {
+        ptr = iEncodeBuffer->Ptr( position );
+        size = ptr.Length();
+        }
+
+    if ( size == 0 )
+        {
+        //no MMS stuff
+        //TMmsLogger::Log(_L("- no MMS stuff"));
+        return;
+        }
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    User::After(1000000);
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::copyDrafts()
+    {
+    CMsvEntry* cEntry = NULL;
+// Copies contents of sent folder to drafts for retrying sending.
+
+    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    TMsvLocalOperationProgress progress;
+    cEntry->CopyL( *selection, KMsvDraftEntryId, progress );
+
+    TInt i = 0;
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        cEntry->SetEntryL( selection->At( i ) );
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly( EFalse );
+        cEntry->ChangeL( entry );
+        }
+
+    CleanupStack::PopAndDestroy(2); // selection, cEntry
+    }
+
+void MmsTestBed::garbageCollection(TUint32 aReason)
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    TMMSGarbageCollectionParameters parameters; // initialized to zero
+    parameters.iReasonFlags = aReason;
+    TMMSGarbageCollectionParametersBuf paramPack( parameters );
+    op = iSession->TransferCommandL(
+        *selection, EMmsGarbageCollection, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::messageVariation()
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsMessageGeneration, TPtrC8(), iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::cancelSendScheduling()
+    {
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    scheduledSend(KMsvGlobalOutBoxIndexEntryIdValue, 10000); // long delay so that we have time to cancel
+    deleteSendSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy();
+    }
+
+void MmsTestBed::scheduledSend(TMsvId aBoxId, TInt aDelay /* = 5 */)
+    {
+    CMsvEntry* cEntry = NULL;
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(aBoxId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+//    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledSend,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::deleteSendSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::cancelFetchScheduling()
+    {
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+
+    // Wait until notification has arrived - may take a while in global mode
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) == 0
+        && i < 2000 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+
+    fetchForced( 10000 ); // delay to allow cancelling
+    deleteFetchSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(mmsFolder);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::fetchForced(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::deleteFetchSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+    cEntry = iSession->GetEntryL( mmsFolderId );
+    CleanupStack::PushL(cEntry);
+    // Get all notifications
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::doAFetchCycle()
+    {
+    // Sends a message from iCurrentFile and lets it come back
+    TMsvId mmsFolder = findMMSFolder();
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+    // fetching will start automatically
+
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( KMsvGlobalInBoxIndexEntryId, iMsvEntrySelection, *iSession ) == 0
+         && i < 2000
+         && TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) > 0 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+    }
+
+bool MmsTestBed::checkLogClient()
+    {
+    if ( iLogClient == NULL )
+        {
+        TRAP_IGNORE( iLogClient = CLogClient::NewL( iFs ) );
+        }
+    return ( iLogClient != NULL );
+    }
+
+int MmsTestBed::getLogEntries()
+    {
+    TInt count = 0;
+    if ( !iLogView )
+        {
+        return 0;
+        }
+
+    if ( iLogView->SetFilterL( *iLogFilter, iWait->iStatus ) )
+        {
+        // should complete with KErrNone
+        iWait->Start();
+        if ( iWait->iStatus.Int() == KErrNone )
+            {
+            count = iLogView->CountL();
+            }
+        }
+    return count;
+    }
+
+void MmsTestBed::createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry)
+    {
+    CMsvOperation*  opert = aClientEntry.CreateL(aNewEntry, iWait->iStatus);
+    iWait->Start();
+    if (!opert->iStatus.Int()==KErrNone)
+        {
+        // what should we do? panic?
+        }
+
+    TPckgBuf<TMsvLocalOperationProgress> package;
+    package.Copy(opert->ProgressL());
+    *(TMsvId*)&aNewEntry = package().iId;
+
+    delete opert; opert=NULL;
+    }
+
+void MmsTestBed::cleanOutbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalOutBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanInbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanSent()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvSentEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanDrafts()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvDraftEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanAll()
+    {
+    cleanInbox();
+    cleanOutbox();
+    cleanSent();
+    cleanDrafts();
+    TMmsTestUtils::CleanBoxL( iSettings->MMBoxFolder(), *iSession );
+    deleteNotifications();
+    }
+
+void MmsTestBed::reply()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::replyToAll()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply to all, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::forward()
+    {
+    // The first message from inbox is forwarded
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient | KMsvMessagePartAttachments;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ForwardL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create forward, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                iMmsClient->SwitchCurrentEntryL( newEntry );
+                // Add a sender: 0601234567
+                iMmsClient->LoadMessageL();
+                iMmsClient->SetSenderL( KMmsSender );
+                iMmsClient->SaveMessageL();
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::sendReadReport()
+    {
+    // TURN READ REPORTS ON (until available from menu)
+    iSettings->LoadSettingsL();
+    iSettings->SetReadReplyReportSendingAllowed( ETrue );
+    iSettings->SaveSettingsL();
+    iMmsClient->RestoreSettingsL();
+
+
+    // Read report is sent for the first message in inbox
+    CMsvEntry* cEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+
+    if ( iMsvEntrySelection->Count() == 0 )
+        {
+        return;
+        }
+    TMsvId originalEntry = iMsvEntrySelection->At( 0 );
+
+    // new test using Client MTM
+    CMsvOperation * op = NULL;
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+    // Try sending the read report to current entry
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+/*
+    cEntry->SetEntryL( originalEntry );
+    iMmsHeaders->Reset();
+    CMsvStore* store = cEntry->ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+    HBufC8* messageId = HBufC8::NewL( iMmsHeaders->MessageId().Length() );
+    CleanupStack::PushL( messageId );
+    messageId->Des().Copy( iMmsHeaders->MessageId() );
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    iMmsClient->LoadMessageL();
+
+    iMmsHeaders->Reset();
+    iMmsHeaders->SetMessageType( KMmsMessageTypeReadRecInd );
+    // Message id cannot be accessed via MMS Client MTM!
+
+    iMmsHeaders->SetMessageIdL( messageId->Des() );
+    CleanupStack::PopAndDestroy( messageId );
+
+    iMmsHeaders->AddTypedAddresseeL( iMmsClient->Sender(), EMsvRecipientTo );
+    // sender must be insert-address-token because we don't know our number
+    TTime now;
+    now.UniversalTime();
+
+    _LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+    interval = now.MicroSecondsFrom( y1970 );
+    // date in iMmsHeaders() in seconds from 1.1.1970.
+    iMmsHeaders->SetDate( (interval.Int64() ) / KMmsMillion );
+    iMmsHeaders->SetReadStatus( KMmsReadStatusRead );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = FindMMSFolderL();
+
+    cEntry->SetEntryL( mmsFolderId );
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = iDefaultServiceId;
+    entry.iMtmData1 = KMmsMessageReadRecInd;
+    cEntry->CreateL( entry );
+    TMsvId entryId = entry.Id();
+
+    cEntry->SetEntryL( entryId );
+
+    store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->StoreL( *store );
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, entryId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    op = iSession->TransferCommandL(*selection,EMmsScheduledReadReport,paramPack,iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    CleanupStack::PopAndDestroy( selection );
+*/
+    CleanupStack::PopAndDestroy( cEntry );
+    }
+
+int MmsTestBed::fromOutboxToMmscWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt messageCount = 0;
+    TInt failureCount = 0;
+    do {
+        CMsvEntry* cEntry = NULL;
+
+        // Get List of services
+        cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+        CleanupStack::PushL(cEntry);
+        // Get all mms messages of outbox
+        CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        CleanupStack::PushL( selection );
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        selection->InsertL(0, iServiceId);
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iSession->TransferCommandL(*selection,EMmsSend,paramPack,iWait->iStatus));
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // selection
+        CleanupStack::PopAndDestroy(); // cEntry
+        selection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( KMsvGlobalOutBoxIndexEntryIdValue );
+        CleanupStack::PushL(cEntry);
+        selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = selection->Count();
+        delete selection;
+        selection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    return failureCount;
+    }
+
+int MmsTestBed::fromMmscToInboxWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt failureCount = 0;
+    TInt messageCount = 0;
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    do {
+        // Inbox must be cleaned if failure makes message to be fetched more than once.
+        // should not happen, but this test is quite stressful, and perfect result
+        // cannot be guaranteed.
+        // What is expected:
+        // 1. Program does not crash
+        // 2. After sufficient number of retries the message is fetched and notification deleted.
+        TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+        CMsvEntry* cEntry = NULL;
+        CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+        CleanupStack::PushL(msvEntrySelection);
+
+        cEntry = iSession->GetEntryL(iServiceId);
+        CleanupStack::PushL(cEntry);
+
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        // if we have a selected service, insert it into selection
+        if (iServiceId != KMsvNullIndexEntryId)
+            {
+            msvEntrySelection->InsertL(0, iServiceId);
+            }
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iMmsClient->InvokeAsyncFunctionL(
+            EMmsReceiveForced,
+            *msvEntrySelection,
+            paramPack,
+            iWait->iStatus) );
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to receive, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // msvEntrySelection
+        CleanupStack::PopAndDestroy(); // cEntry
+        msvEntrySelection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( mmsFolderId );
+        CleanupStack::PushL(cEntry);
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = msvEntrySelection->Count();
+        delete msvEntrySelection;
+        msvEntrySelection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    if ( error != KErrNoMemory && error != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Memory failure loop ended with %d"), error);
+        }
+    return failureCount;
+    }
+
+void MmsTestBed::sendViaClient()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    CMsvOperation * op = NULL;
+    TTime now;
+    now.UniversalTime();
+    op = iMmsClient->SendL( *selection, iWait->iStatus, now );
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::scheduledFetch(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceive,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::fetchForcedImmediate()
+    {
+    TCommandParameters parameters;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::getEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    iLogClient->GetEventType( *eventType, iWait->iStatus );
+
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::addEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    eventType->SetDescription(_L("Multimedia Message") );
+    eventType->SetLoggingEnabled( ETrue );
+
+//    iWait->iStatus = KRequestPending;
+    iLogClient->AddEventType( *eventType, iWait->iStatus );
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::deleteEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+//    iWait->iStatus = KRequestPending;
+    iLogClient->DeleteEventType( iLogEvent->EventType(), iWait->iStatus );
+    iWait->Start();
+    }
+
+void MmsTestBed::cleanLog()
+    {
+    TInt count = 0;
+
+    count = getLogEntries();
+
+    TInt i;
+    for ( i = 0; i < count; ++i )
+        {
+        // when a view is created, it will be positioned on the first event
+//        iWait->iStatus = KRequestPending;
+        iLogClient->DeleteEvent(iLogView->Event().Id(), iWait->iStatus);
+        iWait->Start();
+
+        if ( iLogView->NextL( iWait->iStatus ) )
+            {
+            // should complete with KErrNone
+            iWait->Start();
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                // could not get next event!
+                break;
+                }
+            }
+        else
+            {
+            break; // no more events!
+            }
+        }
+    }
+
+void MmsTestBed::setOnline(bool value)
+    {
+    //value = true for online mode
+    //value = false for offline mode
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KCRUidCoreApplicationUIs ) );
+    if( retval == KErrNone )
+        {
+        repository->Set( KCoreAppUIsNetworkConnectionAllowed, value );
+        delete repository;
+        }
+    }
+
+void MmsTestBed::generateDeliveryReport( CMmsHeaders* aMmsHeaders )
+    {
+    iEncodeBuffer->ResizeL( 1024 );
+
+    TInt position = 0;
+
+    // encode message type
+    iEncodeBuffer->Write( position, &KMmsAssignedMessageType, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageTypeDeliveryInd, 1 );
+    position++;
+
+    // version
+    iEncodeBuffer->Write( position, &KMmsAssignedMmsVersion, 1 );
+    position++;
+
+    TUint8 version = aMmsHeaders->MmsVersion() | 0x80; // current version as short integer
+    iEncodeBuffer->Write( position, &version, 1 );
+    position++;
+
+    // message id from the headers
+    // At least once MMSC did not send us the message id!
+    // if message id is missing, we cannot match the entry!
+    // This only a fake. Real delivery reports should always
+    // contain the message id.
+    if ( aMmsHeaders->MessageId().Length() > 0 )
+        {
+        iEncodeBuffer->Write( position, &KMmsAssignedMessageId, 1 );
+        position++;
+        iEncodeBuffer->Write( position, &(aMmsHeaders->MessageId()[0]), aMmsHeaders->MessageId().Length() );
+        position += aMmsHeaders->MessageId().Length();
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // To is taken from the headers
+    iEncodeBuffer->Write( position, &KMmsAssignedTo, 1 );
+    position++;
+
+    TPtrC recipient;
+    if ( aMmsHeaders->ToRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->ToRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->ToRecipients()[0] );
+        }
+    else if( aMmsHeaders->CcRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->CcRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->CcRecipients()[0] );
+        }
+    else if( aMmsHeaders->BccRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->BccRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->BccRecipients()[0] );
+        }
+    else
+        {
+        recipient.Set( _L("Jasso-Kissa@jii.fi") );
+        }
+
+    TMmsAddressType addressType = EMmsAddressTypeUnknown;
+
+    if ( recipient.Find( KMiuMau ) != KErrNotFound )
+        {
+        addressType = EMmsAddressTypeEmail;
+        }
+    else
+        {
+        addressType = EMmsAddressTypeMobile;
+        }
+
+    TUint8 character;
+    TInt i;
+    if ( addressType == EMmsAddressTypeEmail )
+        {
+        // email address - ASCII ONLY - THIS IS JUST A TEST!
+
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+
+        }
+    else
+        {
+        // must be a phone number
+        // We expect for now that the format is correct as is
+        // All legal characters present in a phone number are ASCII
+
+        TInt i;
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, KMmsPlmn, KMmsPlmnLength );
+        position += KMmsPlmnLength;
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // date
+    iEncodeBuffer->Write( position, &KMmsAssignedDate, 1 );
+    position++;
+
+    TLocale locale;
+    locale.Refresh();
+    TInt64 UtcDate;
+    TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
+
+    TTime now;
+    now.UniversalTime();
+    UtcDate = ( now.MicroSecondsFrom( TTime( KMmsYear1970String ) ).Int64() ) / 1000000 ;
+
+    UtcDate -= universalTimeOffset.Int();
+
+    if ( locale.QueryHomeHasDaylightSavingOn() )
+        {
+        TTimeIntervalSeconds daylightSaving( 60 * 60 );
+        UtcDate -= daylightSaving.Int();
+        }
+
+    TUint8 len; // number of bytes we will need
+    len = 0;
+    TUint8 array[8];
+
+    TInt64 temp = UtcDate;
+
+    for (i = 7; i >= 0; --i)
+        {
+        array[i] = TInt8( ( I64INT( temp ) ) & 0xFF );
+        I64LSR( temp, 8 );
+        }
+
+    len = 8;
+    i = 0;
+    while( ( array[i]== 0 ) && ( i < 8 ) )
+        {
+        i++;
+        len--;
+        }
+
+    // a zero should be coded as short integer.
+    // However, if there is a valid reason to code a zero as a long integer,
+    // we allow it. The caller should know what he is doing.
+    if ( len == 0 )
+        {
+        len = 1;
+        }
+    // write short length
+    iEncodeBuffer->Write( position, &len, 1 );
+    position++;
+    // write as many bytes as were non-zero
+    iEncodeBuffer->Write( position, &(array[8 - len] ), len );
+    position+= len;
+    // status
+    iEncodeBuffer->Write( position, &KMmsAssignedStatus, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageStatusRetrieved, 1 );
+    position++;
+    // DONE!!!
+    iEncodeBuffer->ResizeL( position );
+    return;
+    }
+
+void MmsTestBed::sendDeliveryReport()
+    {
+    if ( iEncodeBuffer->Size() == 0 )
+        {
+        //No delivery report
+        return;
+        }
+
+
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+//    iWait->iStatus = KRequestPending;
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmsteststaticutils.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <f32file.h>
+#include <centralrepository.h>
+#include <apparc.h>
+#include <msvapi.h>
+#include <msvids.h>
+
+#include "mmsteststaticutils.h"
+#include "mmsconst.h"
+#include <MmsEnginePrivateCRKeys.h>
+#include "mmssettings.h"
+#include <mmsheaders.h>
+#include "mmsservercommon.h"
+#include <mmsencode.h>
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsJoinedArrays::TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2)
+: iArray1(aArray1), iArray2(aArray2)
+    {
+    }
+
+TInt TMmsJoinedArrays::MdcaCount() const
+    {
+    TInt count=0;
+    if (iArray1)
+        count += iArray1->MdcaCount();
+    if (iArray2)
+        count += iArray2->MdcaCount();
+    return count;
+    }
+
+TPtrC16 TMmsJoinedArrays::MdcaPoint(TInt aIndex) const
+    {
+    if (iArray1)
+        {
+        if (aIndex < iArray1->MdcaCount())
+            return iArray1->MdcaPoint(aIndex);
+        else
+            aIndex -= iArray1->MdcaCount();
+        }
+    return iArray2->MdcaPoint(aIndex);
+    }
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsTestUtils::TMmsTestUtils()
+    {
+
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+HBufC* TMmsTestUtils::ReadContactFromFileL( TDesC& aFileName, RFs& aFs )
+    {
+    RFile file;
+    TInt error = KErrNone;
+
+    TInt textBufferSize = 256;
+    HBufC* textBuffer = HBufC::NewL( textBufferSize );
+    TPtr textPtr = textBuffer->Des();
+    TFileText textFile;
+
+    error = file.Open( aFs, aFileName,
+            EFileRead|EFileShareReadersOnly );
+
+    if ( error == KErrNone )
+        {
+        textFile.Set( file );
+        error = textFile.Seek( ESeekStart );
+        }
+
+    if ( error == KErrNone )
+        {
+        error = textFile.Read( textPtr );
+        }
+
+    file.Close();
+
+    if ( textBuffer->Des().Find( &KMmsByteOrderMark, 1 ) == 0 )
+        {
+        textBuffer->Des().Copy( textBuffer->Des().Mid( 1 ) );
+        }
+
+    return textBuffer;
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOnL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOffL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanDirectoryL( RFs& aFs )
+    {
+    // Delete the files in the directory
+    CFileMan* fileMan = CFileMan::NewL( aFs );
+    CleanupStack::PushL( fileMan );
+    fileMan->RmDir( KMmsDefaultLocalModeDir );
+    fileMan->RmDir( KMmsMMBoxDirectory );
+    fileMan->RmDir( KMmsMMBoxDescriptionDirectory );
+    CleanupStack::PopAndDestroy(); // fileManager
+    // we don't want to throw these away!
+    aFs.MkDirAll( KMmsDefaultLocalModeDir );
+    aFs.MkDirAll( KMmsMMBoxDirectory );
+    aFs.MkDirAll( KMmsMMBoxDescriptionDirectory );
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::Dump( CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs )
+    {
+    TInt error = KErrNone;
+    aFs.MkDirAll( aFilename );
+    TUint att;
+    if ( aFs.Att( aFilename, att ) == KErrNone )
+        {
+        _LIT( KRelated, "dump.mms");
+        aParse.Set( aFilename, &KRelated, NULL );
+        aFilename = aParse.FullName();
+        error = CApaApplication::GenerateFileName( aFs, aFilename );
+        if ( error == KErrNone )
+            {
+            RFile file;
+            error = file.Create( aFs, aFilename, EFileWrite | EFileShareExclusive );
+            // for message id generation
+            aParse.Set( aFilename, NULL, NULL );
+            if ( error == KErrNone )
+                {
+                // the data is supposed to be in the encode buffer
+                TPtr8 ptr = aBuffer.Ptr( 0 );
+                file.Write( ptr );
+                file.Flush();
+                }
+
+            // done - close files
+            file.Close();
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanBoxL(TMsvId aBoxId, CMsvSession& aSession)
+    {
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    // show invisible entries
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL(msvEntrySelection);
+
+    CMsvEntrySelection* selection = NULL;
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    selection = cEntry->ChildrenWithMtmL(KUidMsgMMSNotification);
+    CleanupStack::PushL( selection );
+    if ( selection->Count() > 0 )
+        {
+        msvEntrySelection->AppendL( selection->Back( 0 ), selection->Count() );
+        }
+    CleanupStack::PopAndDestroy(); // selection
+
+    int i;
+    for (i = 0; i < msvEntrySelection->Count(); ++i)
+        {
+        CMsvEntry* entry = aSession.GetEntryL( msvEntrySelection->At(i) );
+        CleanupStack::PushL( entry );
+        TMsvEntry tEntry = entry->Entry();
+        tEntry.SetReadOnly(EFalse);
+        entry->ChangeL(tEntry);
+        cEntry->DeleteL( msvEntrySelection->At(i) );
+        CleanupStack::PopAndDestroy( entry );
+        }
+
+    CleanupStack::PopAndDestroy(msvEntrySelection);
+    CleanupStack::PopAndDestroy(cEntry);
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 1;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 0;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TInt TMmsTestUtils::CountChildrenL(TMsvId aBoxId, CMsvEntrySelection*& aMsvEntrySelection, CMsvSession& aSession, TUid aMessageType )
+    {
+    CMsvEntry* cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    if (aMsvEntrySelection != NULL)
+        {
+        delete aMsvEntrySelection;
+        aMsvEntrySelection = NULL;
+        }
+    aMsvEntrySelection = cEntry->ChildrenWithMtmL(aMessageType);
+    CleanupStack::PopAndDestroy(); // cEntry
+    return aMsvEntrySelection->Count();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CreateFolderEntryL
+//
+// -----------------------------------------------------------------------------
+//
+void TMmsTestUtils::CreateFolderEntryL(
+    CMsvSession& aSession,
+    TMsvId aParentFolder,
+    const TDesC& aFolderName,
+    TMsvId& aFolderId )
+    {
+    aFolderId = KMsvNullIndexEntryId;
+    CMsvEntry* cEntry = aSession.GetEntryL( aParentFolder );
+    CleanupStack::PushL( cEntry );
+
+    // Create a new folder.
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvFolderEntry;
+    entry.iMtm = KUidMsvLocalServiceMtm;
+    entry.iDetails.Set( aFolderName );
+    entry.SetVisible( EFalse );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    cEntry->CreateL( entry );
+    aFolderId = entry.Id();
+    CleanupStack::PopAndDestroy( cEntry );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TMsvId TMmsTestUtils::CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession )
+    {
+    TMsvId entryId = KMsvNullIndexEntryId;
+    if ( aNotificationFolder == KMsvNullIndexEntryId )
+        {
+        // no folder no entry
+        return entryId;
+        }
+
+    CMsvEntry* cEntry = aSession.GetEntryL( aNotificationFolder );
+    CleanupStack::PushL(cEntry);
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    // If we want to put data here, InPreparation must be set to true first
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = aServiceId;
+    entry.iMtmData2 = KMmsNotificationBinary;
+    cEntry->CreateL( entry );
+    entryId = entry.Id();
+
+    //
+    // Stream
+    // 1) length of the data as 32 bit integer
+    // 2) pushed message data
+    // into created entry's stream
+    //
+    cEntry->SetEntryL( entryId );
+    CMsvStore* store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );   // ***
+    RMsvWriteStream outs;
+    outs.AssignLC( *store, KUidBinaryNotificationStream ); // ***
+    TPtrC8 ptr = aEncodeBuffer->Ptr( 0 );
+    outs.WriteUint32L( ptr.Length() );
+    outs.WriteL( ptr );
+    outs.CommitL();
+    outs.Close();
+    store->CommitL();
+
+    CleanupStack::PopAndDestroy( &outs ); // close outs
+    CleanupStack::PopAndDestroy( store );
+    CleanupStack::PopAndDestroy( cEntry );
+
+    return entryId;
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer )
+    {
+    // for test purposes aUrl will contain the filename.
+
+    // Reset sets the default encapsulation version
+    // The default version has been set from MmsSettings in NewL
+    aMmsHeaders.Reset();
+
+    // construct the notification into iMmsHeaders, and call encode
+
+    aMmsHeaders.SetMessageType( KMmsMessageTypeMNotificationInd );
+
+    TTime currentTime;
+    currentTime.UniversalTime();
+    currentTime.Int64();
+
+    TPtrC8 tid;
+    TBufC8<KMMSMAXTIDLENGTH> target;
+    TInt random = 0;
+
+    // we don't generate a true random TID: We generate the
+    // TID from the URL so that if we generate a notification
+    // twice from the same file, we get the same TID and the
+    // same URL. This way we can test the pruning function in
+    // server MTM
+
+    TInt i;
+    for ( i = 0; i < aUrl.Length(); ++i )
+        {
+        random += aUrl[ i ];
+        }
+
+    target.Des().Num( random );
+    tid.Set( target.Des() );
+    aMmsHeaders.SetTidL( tid );
+
+    aMmsHeaders.SetMessageClass( EMmsClassPersonal );
+    aMmsHeaders.SetMessageSize( aSize );
+    const TInt KTenHours = 10 * 60 * 60; // 10 hours relative expiry
+    aMmsHeaders.SetExpiryInterval( KTenHours );
+    aMmsHeaders.SetContentLocationL( aUrl );
+
+    aMmsEncoder.EncodeHeadersL( aMmsHeaders, *aEncodeBuffer );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsFile(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a file?
+    if (IsDrive(aFileName))
+        return EFalse;
+    return !(IsDir(aFileName, aFs));
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDir(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a directory?
+    TEntry entry;
+    TInt err = aFs.Entry(aFileName, entry);
+    if (err)
+        return EFalse;
+    else
+        return entry.IsDir();
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDrive(const TDesC& aFileName)
+    {
+    //horrible little function to figure if the path is just a drive
+    TBool retVal = EFalse;
+    if (aFileName.Length()==3) //eg "c:\"
+        {
+        if ((aFileName[1] == ':')  && (aFileName[2] == '\\'))
+            retVal=ETrue;
+        }
+    else if (aFileName.Length()==2) //eg "c:"
+        {
+        if (aFileName[1] == ':')
+            retVal=ETrue;
+        }
+    return retVal;
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmstestuitimer.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include "mmstestuitimer.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::CTestUiTimer(): CTimer( 5 )
+    {
+    period = KPeriod;
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer* CTestUiTimer::NewL()
+    {
+    CTestUiTimer* self = new(ELeave) CTestUiTimer();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::~CTestUiTimer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::IssueRequest()
+    {
+    // No operation to cancel if this function is called
+    iObject = NULL;
+    After(period);
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::TimeoutOperation( CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds )
+    {
+    iObject = aObject;
+    TTimeIntervalMicroSeconds32 timeout = aTimeoutInSeconds.Int() * 1000000;
+    After( timeout );
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    if ( iObject )
+        {
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::RunL()
+    {
+    if ( iObject )
+        {
+        // If we timeout while holding an active object, we cancel it
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    else
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/group/testmmsplugin.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,110 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+QT += testlib
+QT -= gui
+
+TEMPLATE = lib
+TARGET = test-mms-plugin
+
+INCLUDEPATH += ../inc
+INCLUDEPATH += ../../../inc
+#INCLUDEPATH += ../../../../inc
+
+INCLUDEPATH += ../../../../../../../../inc
+INCLUDEPATH += ../../../../../../inc
+INCLUDEPATH += ../../../../../msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/inc
+INCLUDEPATH += ../../../../../msgutils/unidatautils/unidatamodel/inc
+INCLUDEPATH += ../../../../../msgutils/unieditorutils/editorgenutils/inc
+INCLUDEPATH += ../../../../../msgutils/s60qconversions/inc
+INCLUDEPATH += ../../../../../../../../mmsengine/mmsmessage/inc 
+INCLUDEPATH += ../../../../../../../../mmsengine/inc
+INCLUDEPATH += ../../mmstestbed/inc
+INCLUDEPATH +=
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+DEFINES += BUILD_TEST_DLL
+
+CONFIG += hb plugin
+
+SOURCES += \
+  ../src/testmmsplugin.cpp \
+  ../../../../../msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin.cpp \
+  ../../../../../msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp  
+      
+
+# Input
+HEADERS += \
+  ../inc/testmmsplugin.h \
+  ../../../../../msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/inc/unieditormmsplugin.h \
+  ../../../../../msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/inc/unieditormmsplugin_p.h 
+               
+   
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+    symbian {
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000
+    TARGET.EPOCALLOWDLLDATA = 1
+	}
+
+ LIBS += -leuser \
+    -lconvergedmessageutils \
+    -ls60qconversions \
+    -lMsgMedia \
+    -leikctl \
+    -leditorgenutils \
+    -lcone \
+    -leikcoctl \
+    -leikcore \
+    -leikdlg \
+    -lmsgs \
+    -letext \
+    -lmmsserversettings \
+    -lgsmu \
+    -lmmsgenutils \
+    -lefsrv \
+    -lestor \
+    -lsmcm \
+    -lCommonEngine \
+    -lbafl \
+    -lCdlEngine \
+    -lFeatMgr \
+    -lapmime \
+    -lapgrfx \
+    -lcharconv \
+    -lInetProtUtil \
+    -lsmildtd \  
+    -lxmldom \
+    -lxmlparser \
+    -lcone \
+    -lQtCore \
+    -letel \
+    -lmmsmessage \  
+    -lcommdb \
+    -lcommsdat \
+    -letelmm \
+    -lunidatamodelloader \
+    -lunidatamodel \
+    -lavkon \
+    -leikcoctl \
+    -leikctl \
+    -lform \
+    -luiklaf\ 
+    -lxqutils\ 
+    -lmmstestbed
+  	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/inc/testmmsplugin.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: - Main test class for Msgnotification -indicator plugin, 
+ *                                                   -notification dialog plugin
+ */
+
+#ifndef TEST_MMS_PLUGIN_H
+#define TEST_MMS_PLUGIN_H
+
+#ifdef BUILD_TEST_DLL
+#define TEST_EXPORT Q_DECL_EXPORT
+#else
+#define TEST_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <e32const.h>
+
+class UniEditorMmsPlugin;
+class ConvergedMessage;
+class MmsTestBed;
+class QSignalSpy;
+
+class TEST_EXPORT TestMmsPlugin: public QObject
+    {
+    Q_OBJECT
+
+private slots:
+     
+    /**
+        * Called by framework,its called before the 1st test function is executed.
+     */  
+   
+    void initTestCase();
+
+    /**
+        * Called by framework,its called before each test function is executed.
+     */  
+
+    void init();
+
+    /**
+        * Test Sending MMS
+     */  
+
+    void testSendMMS(); 
+
+    /**
+        * Test receiving MMS
+     */  
+
+    void testMmsReceived();
+
+    /**
+        * Called by framework,its called after each test function is executed.
+     */  
+
+    void cleanup();
+
+    /**
+        * Called by framework,its called after the last test function is executed.
+     */  
+
+    void cleanupTestCase();
+
+private:
+
+    QSignalSpy *spy_draft;
+    QSignalSpy *spy_outbox;
+    QSignalSpy *spy_sent;
+
+    UniEditorMmsPlugin* msgPlugin;
+    int mmsId;
+    MmsTestBed* mmstestbed;
+   
+    };
+#endif //TEST_MMS_PLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/inc/testmmsplugin.ini	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,12 @@
+//this file is used to provide predefined set of input data.
+
+const char TEST_MSG_RECIEPIENT[]         = "+919000";
+const char TEST_MSG_FROM2[]              = "999";
+const char TEST_MSG_SUBJECT[]            = "Message Subject";
+const char TEST_SERVICE_NAME_MMS[] 	 = "messaging.mserver.testservice.MMS";
+const char TEST_SENDER[]		 = "+918888";
+const char TEST_ATTACHMENT[]		 = "c:\\sample.txt";
+const char TEST_ATTACHMENT4[]		 = "c:\\SmileyFace.gif";
+const char TEST_ATTACHMENT5[]		 = "c:\\sample.txt";
+const char TEST_CC[]			 = "DummyCCAddress";
+const char TEST_BCC[]			 = "DummyBCCAddress";
\ No newline at end of file
Binary file messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/mms.rsc has changed
Binary file messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/not.rsc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/plugin_commonU.def	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,31 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.3) on: 2010-06-21T15:39:25
+; This file is generated by qmake and should not be modified by the
+; user.
+;  Name        : plugin_commonU.def
+;  Part of     : test-mms-plugin
+;  Description : Fixes common plugin symbols to known ordinals
+;  Version     : 
+;
+; ==============================================================================
+
+
+EXPORTS
+	qt_plugin_query_verification_data @ 1 NONAME
+	qt_plugin_instance @ 2 NONAME
+	?qt_metacast@TestMmsPlugin@@UAEPAXPBD@Z @ 3 NONAME ; void * TestMmsPlugin::qt_metacast(char const *)
+	?init@TestMmsPlugin@@AAEXXZ @ 4 NONAME ; void TestMmsPlugin::init(void)
+	?staticMetaObject@TestMmsPlugin@@2UQMetaObject@@B @ 5 NONAME ; struct QMetaObject const TestMmsPlugin::staticMetaObject
+	?tr@TestMmsPlugin@@SA?AVQString@@PBD0H@Z @ 6 NONAME ; class QString TestMmsPlugin::tr(char const *, char const *, int)
+	?initTestCase@TestMmsPlugin@@AAEXXZ @ 7 NONAME ; void TestMmsPlugin::initTestCase(void)
+	?cleanup@TestMmsPlugin@@AAEXXZ @ 8 NONAME ; void TestMmsPlugin::cleanup(void)
+	?trUtf8@TestMmsPlugin@@SA?AVQString@@PBD0H@Z @ 9 NONAME ; class QString TestMmsPlugin::trUtf8(char const *, char const *, int)
+	?qt_metacall@TestMmsPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int TestMmsPlugin::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?testMmsReceived@TestMmsPlugin@@AAEXXZ @ 11 NONAME ; void TestMmsPlugin::testMmsReceived(void)
+	?testSendMMS@TestMmsPlugin@@AAEXXZ @ 12 NONAME ; void TestMmsPlugin::testSendMMS(void)
+	?trUtf8@TestMmsPlugin@@SA?AVQString@@PBD0@Z @ 13 NONAME ; class QString TestMmsPlugin::trUtf8(char const *, char const *)
+	?tr@TestMmsPlugin@@SA?AVQString@@PBD0@Z @ 14 NONAME ; class QString TestMmsPlugin::tr(char const *, char const *)
+	?metaObject@TestMmsPlugin@@UBEPBUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const * TestMmsPlugin::metaObject(void) const
+	?getStaticMetaObject@TestMmsPlugin@@SAABUQMetaObject@@XZ @ 16 NONAME ; struct QMetaObject const & TestMmsPlugin::getStaticMetaObject(void)
+	?cleanupTestCase@TestMmsPlugin@@AAEXXZ @ 17 NONAME ; void TestMmsPlugin::cleanupTestCase(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgnotifications/msgnotifier/tsrc/testmmsgplugin/src/testmmsplugin.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: - Main test class for Msgnotification -indicator plugin, 
+ *                                                   -notification dialog plugin
+ */
+
+#include "testmmsplugin.h"
+#include <QtTest/QtTest>
+#include "debugtraces.h"
+#include <QTimer>
+#include <QSignalSpy>
+#include "convergedmessage.h"
+#include "convergedmessageid.h"
+#include "unieditormmsplugin.h"
+#include "mmstestbed.h"
+#include "testmmsplugin.ini"
+#include <QSignalSpy>
+
+
+//---------------------------------------------------------------
+// TestMmsPlugin::initTestCase
+//---------------------------------------------------------------
+
+void TestMmsPlugin::initTestCase()
+{
+    qRegisterMetaType<long int> ("long int"); 
+    msgPlugin = new UniEditorMmsPlugin();
+    QVERIFY(msgPlugin != 0);
+    mmsId = -1;
+    mmstestbed = new MmsTestBed;
+	QVERIFY(mmstestbed != 0);
+	if(!mmstestbed)
+	{
+		QSKIP("Mmstestbed creation failed", SkipAll); 
+	}
+
+    spy_draft  = new QSignalSpy(mmstestbed,SIGNAL(entryCreatedInDraft(long int)));
+    spy_outbox = new QSignalSpy(mmstestbed,SIGNAL(entryMovedToOutbox(long int)));
+    spy_sent   = new QSignalSpy(mmstestbed,SIGNAL(entryMovedToSent(long int)));
+
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::init
+//---------------------------------------------------------------
+
+void TestMmsPlugin::init()
+{
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testSendMMS
+//---------------------------------------------------------------
+
+void TestMmsPlugin::testSendMMS()
+{
+   
+    qRegisterMetaType<long int> ("long int");
+    QString service = TEST_SERVICE_NAME_MMS;
+	
+	QString subject  = TEST_MSG_SUBJECT;
+	qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
+	
+	QString sender(TEST_SENDER);
+	ConvergedMessageAddress address(sender);
+	ConvergedMessageAttachmentList attachmentList;    
+
+	QString attachment2Path = TEST_ATTACHMENT4;
+	ConvergedMessageAttachment* attachment2 = 
+			new ConvergedMessageAttachment(attachment2Path, ConvergedMessageAttachment::EAttachment);
+	
+	QString attachmentPath = TEST_ATTACHMENT5;
+	ConvergedMessageAttachment* attachment = 
+		new ConvergedMessageAttachment(attachmentPath, ConvergedMessageAttachment::EAttachment);
+		
+	attachmentList.append(attachment);
+	attachmentList.append(attachment2);
+	ConvergedMessage msg;
+	msg.setMessageType(ConvergedMessage::Mms);
+	msg.setSubject(subject);
+	msg.setTimeStamp(timeStamp);
+	msg.addToRecipient(address);
+	msg.addAttachments(attachmentList);
+	msg.setPriority(ConvergedMessage::Normal);
+	//Adding alias
+	ConvergedMessageAddress address1;
+	address1.setAlias(QString(TEST_MSG_RECIEPIENT));
+	msg.addToRecipient(address1);
+	
+	//Adding CC Address
+	QString ccAddress(TEST_CC);
+	ConvergedMessageAddress ccAdd(ccAddress);
+	msg.addCcRecipient(ccAdd);
+	
+	//Adding BCC Address
+	QString bccAddress(TEST_BCC);
+	ConvergedMessageAddress bccAdd(bccAddress);
+	msg.addBccRecipient(bccAdd);
+	
+	mmstestbed->cleanAll();
+	mmstestbed->setConnectionLocal(true);
+	long int id = msgPlugin->convertTo(&msg);
+	
+	QVERIFY(id != 0);
+	msgPlugin->send(id);
+	QTest::qWait(5000); 
+	long int idRec;
+	
+	if( 1 == spy_draft->count())
+		{
+		void * temp = const_cast<void*>(spy_draft->at(0).at(0).data());
+		idRec = *reinterpret_cast< long int(*)>(temp);
+		QDEBUG_WRITE("passed: spy_draft.count");
+		}
+	else
+		{
+		QFAIL("testSendReceiveMMS: Failed to create message in Draft");
+		mmstestbed->setConnectionLocal(false);
+		return;
+		}
+	if( 1 == spy_outbox->count())
+		{
+		mmstestbed->fromOutboxToMmsc();
+		QDEBUG_WRITE("passed: spy_outbox.count");
+		}
+	else
+		{
+		QFAIL("testSendReceiveMMS: Failed to move message to Outbox");
+		mmstestbed->setConnectionLocal(false);
+		return;
+		}
+
+	if( 1 == spy_sent->count())
+		{
+		void * temp = const_cast<void*>(spy_sent->at(0).at(0).data());
+		long int sentmsgid = *reinterpret_cast< long int(*)>(temp);
+		QCOMPARE(sentmsgid, idRec);
+		mmstestbed->fromMmscToInbox();
+		QDEBUG_WRITE("passed: spy_sent.count");
+		}
+	else
+		{
+		QFAIL("testSendReceiveMMS: Failed to move message to Sent folder");
+		mmstestbed->setConnectionLocal(false);
+		return;
+		}
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testMmsReceived
+//---------------------------------------------------------------
+void TestMmsPlugin::testMmsReceived()
+{
+        QTest::qWait(5000);
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::cleanup
+//---------------------------------------------------------------
+void TestMmsPlugin::cleanup()
+{
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::cleanupTestCase
+//---------------------------------------------------------------
+void TestMmsPlugin::cleanupTestCase()
+{
+    delete msgPlugin;
+    delete mmstestbed;
+}
+
--- a/messagingapp/msgservices/msgserviceapp/inc/msgsendinterface.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/inc/msgsendinterface.h	Tue Jul 06 14:12:40 2010 +0300
@@ -60,6 +60,15 @@
     void send(const QString phoneNumber, const QString alias, 
                             const QString bodyText);
 
+    /**
+     * Send message.
+     * @param addressList list of phone numbers and displaynames. 
+     * key is the phone number and value is the display name.
+     * @param bodyText body text.
+     */
+    void send(const QVariantMap addressList, 
+              const QString bodyText = QString());
+
 private:
     
     /**
--- a/messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h	Tue Jul 06 14:12:40 2010 +0300
@@ -65,7 +65,16 @@
     void send(const QString phoneNumber, 
               const QString alias, 
               const QString bodyText);
-    
+              
+    /**
+     * Send message.
+     * @param addressList list of phone numbers and displaynames. 
+     * key is the phone number and value is the display name.
+     * @param bodyText body text.
+     */
+    void send(const QVariantMap addressList, 
+              const QString bodyText = QString());
+
     /**
      * Send message.
      * @param data data to be sent.
@@ -94,7 +103,7 @@
      * Handle sms and mms messge
      * @param msgId message id
      */
-    void handleSmsMmsMsg(int msgId);
+    void handleSmsMmsMsg(int msgId,int msgType);
 
     /**
      * Handle ringtone message
--- a/messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -58,6 +58,13 @@
      */
     void deleteMessage(int msgId);
     
+    /**
+     * is draft message.
+     * @param msgId id of the message to be checked.
+     * @return true if it is a draft message,else false
+     */
+    bool isDraftMessage(int msgId);
+    
 private:
     /**
      * Does all initilaizations
--- a/messagingapp/msgservices/msgserviceapp/src/msgsendinterface.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/src/msgsendinterface.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -61,5 +61,14 @@
     mViewManager->send(phoneNumber, alias, bodyText);    
     }
 
+//----------------------------------------------------------------------------
+// MsgSendInterface::send
+// @see header
+//----------------------------------------------------------------------------
+void MsgSendInterface::send(const QVariantMap addressList, 
+              const QString bodyText)
+      {
+      mViewManager->send(addressList,bodyText);    
+      }
 //EOF
 
--- a/messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -36,11 +36,8 @@
 #include "unidatamodelplugininterface.h"
 
 // LOCALIZATION
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
 #define LOC_DLG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
-#define LOC_BUTTON_SAVE hbTrId("txt_common_menu_save")
 
 //----------------------------------------------------------------------------
 // MsgViewInterface::MsgViewInterface
@@ -215,6 +212,43 @@
 // MsgServiceViewManager::send
 // @see header
 //----------------------------------------------------------------------------
+void MsgServiceViewManager::send(const QVariantMap addressList, 
+              const QString bodyText)
+    {
+    QStringList phoneNumList = addressList.keys();
+ 
+    ConvergedMessageAddressList addrList; 
+	
+    int count = phoneNumList.count();
+    for( int i = 0; i < count; ++ i )
+        {
+        QString phNum = phoneNumList[i];
+        ConvergedMessageAddress* address = new ConvergedMessageAddress(phNum,
+                addressList.value(phNum).toString());	
+        addrList.append(address);
+        }
+    
+    ConvergedMessage message;
+    message.addToRecipients(addrList);
+    message.setBodyText(bodyText);
+    
+    QVariantList param;
+    QByteArray dataArray;
+    QDataStream messageStream(&dataArray, 
+            QIODevice::WriteOnly | QIODevice::Append);
+    message.serialize(messageStream);
+    param << dataArray;
+
+    // switch to editor
+    switchToUniEditor(param);
+
+    XQServiceUtil::toBackground(false);
+    }
+
+//----------------------------------------------------------------------------
+// MsgServiceViewManager::send
+// @see header
+//----------------------------------------------------------------------------
 void MsgServiceViewManager::send(QVariant data)
     {
     ConvergedMessage message;
@@ -310,7 +344,7 @@
         case ConvergedMessage::Mms:
         case ConvergedMessage::MmsNotification:
             {
-            handleSmsMmsMsg(msgId);
+            handleSmsMmsMsg(msgId,msgType);
             break;
             }
         case ConvergedMessage::BioMsg:
@@ -332,9 +366,8 @@
             {
             // for un supported message show delete option
             HbMessageBox::question(LOC_DELETE_MESSAGE, 
-                this,SLOT(onDialogDeleteMsg(HbAction*)),    
-                LOC_BUTTON_DELETE,
-                LOC_BUTTON_CANCEL);
+                                   this,SLOT(onDialogDeleteMsg(HbAction*)),    
+                                   HbMessageBox::Delete | HbMessageBox::Cancel);
             break;
             }
     }
@@ -344,22 +377,64 @@
 // MsgServiceViewManager::handleSmsMmsMsg
 // @see header
 // ----------------------------------------------------------------------------
-void MsgServiceViewManager::handleSmsMmsMsg(int msgId)
+void MsgServiceViewManager::handleSmsMmsMsg(int msgId,int msgType)
+{
+    if(mStoreHandler->isDraftMessage(msgId))
     {
-    if (!mUniViewer) {
-    mUniViewer = new UnifiedViewer(msgId);
-    mUniViewer->setNavigationAction(mBackAction);
-    mMainWindow->addView(mUniViewer);
-    connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
-            SLOT(switchView(const QVariantList&)));
+        ConvergedMessageId convergedMsgId = ConvergedMessageId(msgId);
+        ConvergedMessage message;
+        message.setMessageType((ConvergedMessage::MessageType) msgType);
+        message.setMessageId(convergedMsgId);
+
+        // Launch uni-editor view
+        QByteArray dataArray;
+        QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
+        message.serialize(messageStream);
+
+        QVariantList params;
+        params << MsgBaseView::UNIEDITOR; // target view
+        params << MsgBaseView::SERVICE; // source view
+
+        params << dataArray;
+        
+        // except first 2 parameters pass other parameters
+        QVariantList editorData;
+        for(int a = 2; a < params.length(); ++a)
+        {
+            editorData << params.at(a);
+        }
+        // construct
+          if (!mUniEditor) {
+          mUniEditor = new MsgUnifiedEditorView();
+          mMainWindow->addView(mUniEditor);
+          mUniEditor->setNavigationAction(mBackAction);
+          connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
+                  SLOT(switchView(const QVariantList&)));
+          }
+          
+          // check if additional data for unieditor's consumption is available
+          mUniEditor->openDraftsMessage(editorData);
+
+          mMainWindow->setCurrentView(mUniEditor);
+          mCurrentView = MsgBaseView::UNIEDITOR;
     }
-    mUniViewer->populateContent(msgId, true, 1);
+    else
+    {
+        if (!mUniViewer) {
+            mUniViewer = new UnifiedViewer(msgId);
+            mUniViewer->setNavigationAction(mBackAction);
+            mMainWindow->addView(mUniViewer);
+            connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
+                SLOT(switchView(const QVariantList&)));
+        }
+        mUniViewer->populateContent(msgId, true, 1);
 
-    mMainWindow->setCurrentView(mUniViewer);
-    
-    // set current view as viewer
-    mCurrentView = MsgBaseView::UNIVIEWER;
+        mMainWindow->setCurrentView(mUniViewer);
+
+        // set current view as viewer
+        mCurrentView = MsgBaseView::UNIVIEWER;
     }
+}
 
 // ----------------------------------------------------------------------------
 // MsgServiceViewManager::handleRingtoneMsg
@@ -369,7 +444,8 @@
     {
     mMessageId = msgId;
     HbMessageBox::question(LOC_DLG_SAVE_RINGTONE, this,
-        SLOT(onDialogSaveTone(HbAction*)), LOC_BUTTON_SAVE, LOC_BUTTON_CANCEL);
+                           SLOT(onDialogSaveTone(HbAction*)),
+                           HbMessageBox::Save | HbMessageBox::Cancel);
     }
 
 // ----------------------------------------------------------------------------
--- a/messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -155,4 +155,27 @@
     {
     iMsvSession->RemoveEntry(msgId);
     }
+
+//----------------------------------------------------------------------------
+// MsgStoreHandler::isDraftMessage
+// @see header
+//----------------------------------------------------------------------------
+bool MsgStoreHandler::isDraftMessage(int msgId)
+{       
+    bool draftmsg = false;
+    CMsvEntry* cEntry = NULL;
+    TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId));
+    if ( err == KErrNone)
+    {
+        TMsvEntry msvEntry = cEntry->Entry();
+        TMsvId parent = msvEntry.Parent();
+        if(parent == KMsvDraftEntryIdValue)
+        {
+            draftmsg = true;  
+        }
+    }
+
+    delete cEntry;
+    return draftmsg;
+}
 // End of file
--- a/messagingapp/msgsettings/msginit/src/simscnumberdetector.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/msginit/src/simscnumberdetector.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -256,6 +256,13 @@
             }
         aServiceSettings->SetSmsBearer((CSmsSettings::TMobileSmsBearer) readedSetting);
 
+        // Check if we need to store SMSC time stamp OR device Time stamp
+        if (iCenRepSession->Get(KSmumShowSMSCTimeStamp, readedSetting) != KErrNone) 
+					 {
+            readedSetting = 0;
+       		 }
+        aServiceSettings->SetUseServiceCenterTimeStampForDate(readedSetting);
+
         // Reply via same centre 
         if (iCenRepSession->Get(KSmumRemoveReplyViaSameCentre, readedSetting)
                 != KErrNone)
@@ -308,22 +315,15 @@
         {
         if ( HasSIMChanged() || HasNoSmscSettings() )
             {
-            QDEBUG_WRITE("CMsgSimOperation::StartL Reading sim settings") 
+            QDEBUG_WRITE("CMsgSimOperation::StartL Reading sim settings start") 
 
-            CMsvOperationWait* wait = CMsvOperationWait::NewLC();
+            CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
             iSimOperation = iSmsClientMtm->ReadSimParamsL(wait->iStatus);       
             wait->Start();
-
-            QDEBUG_WRITE("CMsgSimOperation::StartL Before CActiveScheduler::Start") 
-
-            CActiveScheduler::Start();
-
-            QDEBUG_WRITE("CMsgSimOperation::StartL After CActiveScheduler::Start") 
-
-            TInt err = wait->iStatus.Int(); 
+            TInt err = wait->iStatus.Int();
             StartRunL(err);
             CleanupStack::PopAndDestroy();
-
+						QDEBUG_WRITE("CMsgSimOperation::StartL Reading sim settings end") 
             }
         }
     CompleteClientRequest(0);
@@ -510,8 +510,7 @@
 
     TInt status = KErrNone;
     TInt value = 0;
-
-    status = RProperty::Get(KPSUidStartup, KPSSimStatus, value);
+		status = RProperty::Get(KPSUidStartup, KPSSimStatus, value);
 
     if (status == KErrNone && value != ESimNotPresent)
         {
@@ -519,14 +518,9 @@
 
         return ETrue;      
         }
-    else
-        {
-        QDEBUG_WRITE("CMsgSimOperation::IsSIMPresent returned False")
-
-        return EFalse;    
-        }
-
-
+    
+		QDEBUG_WRITE("CMsgSimOperation::IsSIMPresent returned False")
+		return EFalse;
     }
 
 TBool CMsgSimOperation::HasSIMChanged()
--- a/messagingapp/msgsettings/settingsview/inc/msgsettingengine.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/settingsview/inc/msgsettingengine.h	Tue Jul 06 14:12:40 2010 +0300
@@ -46,7 +46,7 @@
      */
     enum MmsRetrieval
     {
-        AlwaysAutomatic, AutomInHomeNetwork, Maual, Off, No
+        AlwaysAutomatic, AutomInHomeNetwork, Manual, Off, No
     };
     
 public:
--- a/messagingapp/msgsettings/settingsview/inc/msgsettingsview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/settingsview/inc/msgsettingsview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -53,12 +53,13 @@
     void onNewSMSCCenterClicked(int index);
     void onSmsCenterEditViewClosed();
         
-private:
+private:    
+    //Sms Center View
+    MsgSMSCenterView* mSMSCenterView;  
+    
     //Settings Form
     MsgSettingsForm* mSettingsForm;
     
-    //Sms Center View
-    MsgSMSCenterView* mSMSCenterView;  
     HbMainWindow* mMainWindow;
 };
 #endif // MSGSETTINGSVIEW_H
--- a/messagingapp/msgsettings/settingsview/src/mmssettingsprivate.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/settingsview/src/mmssettingsprivate.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -149,26 +149,42 @@
     mMmsClient->RestoreSettingsL();
     mMmsSetting->CopyL( mMmsClient->MmsSettings() );
 
-    //do your operation
-    TMmsReceivingMode receveMode = EMmsReceivingAutomatic;
-
-    if (aRetrieval == MsgSettingEngine::Maual)
-        receveMode = EMmsReceivingManual;
-    else if (aRetrieval == MsgSettingEngine::Off)
-        receveMode = EMmsReceivingPostpone;
-    else if (aRetrieval == MsgSettingEngine::No)
-        receveMode = EMmsReceivingReject;
-
-    if (aRetrieval == MsgSettingEngine::AlwaysAutomatic)
-        {
-        mMmsSetting->SetReceivingModeForeign(receveMode);
-        }
-    else
-        {
-        mMmsSetting->SetReceivingModeForeign(EMmsReceivingManual);
-        }
-
-    mMmsSetting->SetReceivingModeHome(receveMode);
+    switch ( aRetrieval )
+                {
+                case MsgSettingEngine::AutomInHomeNetwork:
+                    {
+                    mMmsSetting->SetReceivingModeHome( EMmsReceivingAutomatic );
+                    mMmsSetting->SetReceivingModeForeign( EMmsReceivingManual );
+                    break;
+                    }
+                case MsgSettingEngine::AlwaysAutomatic:
+                    { 
+                    mMmsSetting->SetReceivingModeHome( EMmsReceivingAutomatic );
+                    mMmsSetting->SetReceivingModeForeign( EMmsReceivingAutomatic );
+                    break;
+                    }
+                case  MsgSettingEngine::Manual:
+                    {
+                    mMmsSetting->SetReceivingModeHome( EMmsReceivingManual );
+                    mMmsSetting->SetReceivingModeForeign( EMmsReceivingManual );
+                    break;
+                    }
+                case MsgSettingEngine::Off:
+                    {   
+                    mMmsSetting->SetReceivingModeHome( EMmsReceivingPostpone );
+                    mMmsSetting->SetReceivingModeForeign( EMmsReceivingPostpone );
+                    break;
+                    }
+                case MsgSettingEngine::No:
+                   {   
+                   mMmsSetting->SetReceivingModeHome( EMmsReceivingReject );
+                   mMmsSetting->SetReceivingModeForeign( EMmsReceivingReject );
+                   break;
+                   }
+                default:
+                    break;
+                }
+    
     
     //save the settings
     mMmsClient->SetSettingsL( *mMmsSetting );
@@ -229,21 +245,36 @@
 
     mMmsAccount->LoadSettingsL(*mMmsSetting);
 
-    TMmsReceivingMode receveMode = mMmsSetting->ReceivingModeHome();
+    TMmsReceivingMode receveModeHome = mMmsSetting->ReceivingModeHome();
+    TMmsReceivingMode receveModeForeign = mMmsSetting->ReceivingModeForeign();
+   
     
-    if (receveMode == EMmsReceivingManual)
-        aRetrieval = MsgSettingEngine::Maual;
-    else if (receveMode == EMmsReceivingPostpone)
-        aRetrieval = MsgSettingEngine::Off;
-    else if (receveMode == EMmsReceivingReject)
-        aRetrieval = MsgSettingEngine::No;
-
-    receveMode = mMmsSetting->ReceivingModeForeign();
-    if (receveMode == EMmsReceivingAutomatic)
-        {
-        aRetrieval = MsgSettingEngine::AlwaysAutomatic;
-        }
-
+    // if default value is not acceptable, choose next by keeping costs low
+       if ( receveModeHome == EMmsReceivingAutomatic &&
+           receveModeForeign == EMmsReceivingAutomatic )
+       {
+       aRetrieval = MsgSettingEngine::AlwaysAutomatic;
+       }
+       else if ( receveModeHome == EMmsReceivingManual &&
+           receveModeForeign == EMmsReceivingManual )
+       {
+       aRetrieval = MsgSettingEngine::Manual;   
+       }
+       else if ( receveModeHome == EMmsReceivingReject &&
+           receveModeForeign == EMmsReceivingReject )
+       {
+       aRetrieval = MsgSettingEngine::No; 
+       }
+       else if ( receveModeHome == EMmsReceivingPostpone &&
+           receveModeForeign == EMmsReceivingPostpone )
+       {
+       aRetrieval = MsgSettingEngine::Off;   
+       }
+       // Should always be automatic@home & manaul@roam
+       else
+       {
+       aRetrieval = MsgSettingEngine::AutomInHomeNetwork;   
+       }
     aAnonymousStatus = mMmsSetting->AcceptAnonymousMessages();
 
     aMmsAdvertsStatus = mMmsSetting->AcceptAdvertisementMessages();
--- a/messagingapp/msgsettings/settingsview/src/msgsettingsform.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/settingsview/src/msgsettingsform.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -45,7 +45,7 @@
 #define LOC_ADD_NEW hbTrId("txt_messaging_button_add_new")
 #define LOC_ALWAYS_AUTOMATIC hbTrId("txt_messaging_setlabel_val_always_automatic")
 #define LOC_AUTO_HOME_NETWORK hbTrId("txt_messaging_setlabel_val_auto_home_network")
-#define LOC_MANUAL hbTrId("txt_messaging_setlabel_val_mannual")
+#define LOC_MANUAL hbTrId("txt_messaging_setlabel_val_manual")
 #define LOC_MMS_YES hbTrId("txt_messaging_setlabel_allow_anonymous_mms_val_yes")
 #define LOC_MMS_NO hbTrId("txt_messaging_setlabel_allow_anonymous_mms_val_no")
 
--- a/messagingapp/msgsettings/settingsview/src/msgsmscentersettingsform.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgsettings/settingsview/src/msgsmscentersettingsform.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -34,8 +34,6 @@
 #define LOC_SMS_CENTRE_NUMBER hbTrId("txt_messaging_setlabel_message_centre_number")
 #define LOC_SMS_CENTRE_DELETE hbTrId("txt_messaging_button_delete_message_centre")
 #define LOC_MESSAGE_CENTER_SAVED hbTrId("txt_messaging_setlabel_message_centre_saved")
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 
 MsgSMSCenterSettingsForm::MsgSMSCenterSettingsForm(int view,
                                                    QGraphicsItem *parent) :
@@ -191,7 +189,9 @@
 
 void MsgSMSCenterSettingsForm::onPressedCustomButton()
 {
-   HbMessageBox::question(LOC_SMS_CENTRE_DELETE, this, SLOT(onDialogDeleteMsgCentre(HbAction*)), LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
+   HbMessageBox::question(LOC_SMS_CENTRE_DELETE, this,
+                          SLOT(onDialogDeleteMsgCentre(HbAction*)),
+                          HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 void MsgSMSCenterSettingsForm::onDialogDeleteMsgCentre(HbAction* action)
--- a/messagingapp/msgui/appengine/appengine.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/appengine.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -23,7 +23,7 @@
 INCLUDEPATH += ../msguiutils/inc
 INCLUDEPATH += ../../msgutils/unieditorutils/editorgenutils/inc
 INCLUDEPATH += ../../smartmessaging/ringbc/inc
-INCLUDEPATH += /ext/mw/qtextensions/qtmobileextensions/include
+
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
 DEFINES += BUILD_DLL
--- a/messagingapp/msgui/appengine/inc/conversationlistchangehandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/inc/conversationlistchangehandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -110,7 +110,14 @@
 
     void ModifyConversationList(
         const CCsClientConversation& aClientConversation);
-
+    
+	/**
+	 * PartialDeleteConversationList
+	 * This is for handling the partial delete of conversation event from server
+	 * @param aClientConversation CCsClientConversation& - reference to client conversation
+	 */
+    void PartialDeleteConversationList(
+            const CCsClientConversation& aClientConversation);
     /**
      * RefreshConversationList
      * This is for handling refresh asynchronusly from the server.
@@ -129,7 +136,18 @@
      * Handles Conversation List received from server and updates into model
      */
     void HandleConversationListL();
-
+    
+    /**
+     * CompareByConvTimeStamp
+     * Helper method to compare conversations by timestamp
+     * 
+     * @param aObj1  CCsConversation object
+     * @param aObj2  CCsConversation object
+     * @return value based of timestamp comparison
+     */
+    static TInt CompareByConvTimeStamp(const CCsClientConversation& aObj1,
+            const CCsClientConversation& aObj2);
+   
 private:
     // data
 
--- a/messagingapp/msgui/appengine/inc/conversationsengine.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/inc/conversationsengine.h	Tue Jul 06 14:12:40 2010 +0300
@@ -161,11 +161,23 @@
     void emitConversationModelUpdated();
     
     /**
+     * Updates the new conversation id for list view
+     */
+    void emitOpenConversationViewIdUpdate(int newConversationId);
+    
+    void disableRegisterationForCVEvents();
+    
+    /**
      * Emits conversationListModelPopulated signal
      */ 
     void emitConversationListModelPopulated();
 
     /**
+     * Emits conversationListModelEntryDeleted
+     */
+    void emitConversationListModelEntryDeleted( int conversationId );
+    
+    /**
      *  Starts fetching remaing conversations
      */
     void fetchMoreConversations();
@@ -243,6 +255,17 @@
      */
     void conversationListModelPopulated();
     
+	/** 
+	 * Signal to indicate the completion of conversation delete
+	 * operation.
+	 */
+     void conversationListEntryDeleted( int conversationId );
+	 
+    /**
+     * Signal to specify the CV model empty now
+     */
+    void conversationViewEmpty();
+    
 private:
 
     /**
--- a/messagingapp/msgui/appengine/inc/conversationsengine_p.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/inc/conversationsengine_p.h	Tue Jul 06 14:12:40 2010 +0300
@@ -119,6 +119,18 @@
     void registerForConversationUpdatesL();
     
     /**
+     *  Remove the CV notifs temporary for some time
+     *  does not destroy the model as such
+     */
+    void deRegisterCVUpdatesTemporary();
+    
+    /**
+     *  Register again after temporary de-register
+     * just need to set the new conversation id
+     */
+    void registerAgainForConversationUpdatesL(int newConversationId);
+    
+    /**
      *  Fetch ConversationId from contactId
      *  @param contactId , contactId
      *  @return conversationId
@@ -133,6 +145,12 @@
     TInt getConversationIdFromAddressL(TDesC& contactAddress);
 
     /**
+     *  Get the latest conversation from the conversation cache by Id
+     *  @param aConversationId for conversation is required
+     */
+    CCsClientConversation* getConversationFromConversationIdL(TInt aConversationId);
+
+    /**
      *  Starts fetching remaing conversations
      */
     void fetchMoreConversations();
--- a/messagingapp/msgui/appengine/inc/conversationsmodel.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/inc/conversationsmodel.h	Tue Jul 06 14:12:40 2010 +0300
@@ -89,6 +89,8 @@
      * Clears the pixmap cache & model
      */
     void clearModel();
+    
+    void emitConversationViewEmpty();
 
 signals:
 
@@ -96,6 +98,8 @@
      * Signal emitted to retrieve the pixmap icon
      */
     void retrievePreviewIcon(int msgId, QString& filepath) const;
+    
+    void conversationViewEmpty();
 
 private slots:
 
--- a/messagingapp/msgui/appengine/inc/conversationssummarymodel.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/inc/conversationssummarymodel.h	Tue Jul 06 14:12:40 2010 +0300
@@ -66,9 +66,10 @@
      * Add a new row to the conversation summary model.
      * Overwrite the row if the message already exists.
      * @param conversation, CCsClientConversation
+     * @param caching, initial caching flag
      * 
      */    
-    void addRow(const CCsClientConversation& conversation);
+    void addRow(const CCsClientConversation& conversation, bool caching = false);
 
     /**
      * Delete a row from conversation summary model.
--- a/messagingapp/msgui/appengine/src/conversationchangehandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationchangehandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -114,6 +114,13 @@
     const CCsConversationEntry& aConvEntry)
 {
     mConversationsModel->deleteRow(aConvEntry.EntryId());
+    
+    //check if the CV model row count has become zero
+    // then needs to emit signal
+    if (mConversationsModel->rowCount() == 0)
+    {
+        mConversationsModel->emitConversationViewEmpty();
+    }
 }
 
 //-----------------------------------------------------------------------
--- a/messagingapp/msgui/appengine/src/conversationlistchangehandler.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationlistchangehandler.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -99,7 +99,8 @@
     for (TInt i = 0; i < aClientConversationList.Count(); ++i)
     {        
         CCsClientConversation *entry = aClientConversationList[i]->CloneL();
-        mClientConversationList.AppendL(entry);
+        mClientConversationList.InsertInOrderAllowRepeats( entry,
+                ConversationsListChangeHandler::CompareByConvTimeStamp );
     }
 
     if (aClientConversationList.Count() > 0)
@@ -137,6 +138,17 @@
 }
 
 //-----------------------------------------------------------------------
+// This is for handling partial delete conversation event asynchronusly from the server
+//-----------------------------------------------------------------------
+//
+
+void ConversationsListChangeHandler::PartialDeleteConversationList(
+            const CCsClientConversation& aClientConversation)
+{
+    ConversationsEngine::instance()->emitConversationListModelEntryDeleted( aClientConversation.GetConversationEntryId() );
+}
+
+//-----------------------------------------------------------------------
 // This is for handling modify conversation event asynchronusly from the server
 //-----------------------------------------------------------------------
 //
@@ -180,7 +192,7 @@
         if (mCurrentIndex < mClientConversationList.Count())
         {
             mConvSummaryModel->addRow(
-                * (mClientConversationList[mCurrentIndex]));
+                * (mClientConversationList[mCurrentIndex]),true);
             mCurrentIndex++;
         }
         else
@@ -213,4 +225,24 @@
 
 }
 
+// ----------------------------------------------------------------------------
+// ConversationsListChangeHandler::CompareByConvTimeStamp
+// ---------------------------------------------------------------------------
+TInt ConversationsListChangeHandler::CompareByConvTimeStamp(const CCsClientConversation& aObj1,
+        const CCsClientConversation& aObj2)
+    {
+    TInt64 timestamp1 = aObj1.GetConversationEntry()->TimeStamp();
+    TInt64 timestamp2 = aObj2.GetConversationEntry()->TimeStamp();
+
+    if (timestamp1 == timestamp2)
+        {
+        return 0;
+        }
+    else if (timestamp1 < timestamp2)
+        {
+        return 1;
+        }
+    return -1;
+    }
+
 // EOF
--- a/messagingapp/msgui/appengine/src/conversationsengine.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationsengine.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -16,6 +16,9 @@
  */
 #include "conversationsengine.h"
 
+#include <ccsconversationentry.h>
+#include <ccsclientconversation.h>
+
 #include "conversationsenginedefines.h"
 #include "convergedmessage.h"
 #include "conversationmsgstorehandler.h"
@@ -52,6 +55,12 @@
     d_ptr = new ConversationsEnginePrivate(mConversationMsgStoreHandler,
         mConversationsSummaryModel,
         mConversationsModel);
+    
+    connect (mConversationsModel,
+            SIGNAL(conversationViewEmpty()),
+            this,
+            SIGNAL(conversationViewEmpty())); 
+   
 }
 
 //---------------------------------------------------------------
@@ -212,7 +221,27 @@
     {
         displayName = indexList[0].data(DisplayName).toString();
         address = indexList[0].data(ConversationAddress).toString();
-    }         
+    }
+    else
+    {
+        int error;
+        CCsClientConversation* clientConv = NULL;
+        TRAP(error, clientConv = d_ptr->getConversationFromConversationIdL(conversationId));
+
+        HBufC *name = clientConv->GetDisplayName();
+        if (name && name->Length())
+        {
+            displayName = XQConversions::s60DescToQString(*name);
+        }
+
+        HBufC *addr = clientConv->GetConversationEntry()->Contact();
+        if (addr && addr->Length())
+        {
+            address = XQConversions::s60DescToQString(*addr);
+        }
+
+        delete clientConv;
+    }
 }
 
 //---------------------------------------------------------------
@@ -284,6 +313,35 @@
 }
 
 //---------------------------------------------------------------
+// ConversationsEngine::emitConversationListModelEntryDeleted
+// @see header
+//---------------------------------------------------------------
+void ConversationsEngine::emitConversationListModelEntryDeleted( int conversationId )
+{
+    emit conversationListEntryDeleted( conversationId );
+}
+
+//---------------------------------------------------------------
+// ConversationsEngine::emitOpenConversationViewIdUpdate
+// @see header
+//---------------------------------------------------------------
+void ConversationsEngine::emitOpenConversationViewIdUpdate(
+        int newConversationId)
+{
+    //also register for subscription now
+    d_ptr->registerAgainForConversationUpdatesL(newConversationId);   
+}
+
+//---------------------------------------------------------------
+// ConversationsEngine::disableRegisterationForCVEvents
+// @see header
+//---------------------------------------------------------------
+void ConversationsEngine::disableRegisterationForCVEvents()
+{
+    d_ptr->deRegisterCVUpdatesTemporary();
+}
+
+//---------------------------------------------------------------
 // ConversationsEngine::fetchMoreConversations
 // @see header
 //---------------------------------------------------------------
--- a/messagingapp/msgui/appengine/src/conversationsengine_p.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationsengine_p.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -51,13 +51,10 @@
 //---------------------------------------------------------------
 ConversationsEnginePrivate::~ConversationsEnginePrivate()
 {
-    delete mConvChangeHandler;
-    
-    delete mConvListChangeHandler;
-    
+
     if( mClientConv )
     {        
-        if(mServer)
+        if(mServer && mConvChangeHandler)
         {    
         TRAP_IGNORE(mServer->RemoveConversationChangeEventL(
                 mConvChangeHandler,mClientConv));
@@ -65,7 +62,7 @@
         delete mClientConv;
         mClientConv = NULL;
     }
-    if(mServer)
+    if(mServer && mConvListChangeHandler)
     {
         TRAP_IGNORE(mServer->RemoveConversationListChangeEventL(
                 mConvListChangeHandler));
@@ -74,6 +71,11 @@
         delete mServer;
         mServer = NULL;
     }
+    
+    delete mConvChangeHandler;
+    
+    delete mConvListChangeHandler;
+    
 }
 
 //---------------------------------------------------------------
@@ -219,6 +221,14 @@
     return convId;
 }
 
+//---------------------------------------------------------------
+// ConversationsEnginePrivate::getConversationFromConversationId
+// @see header
+//---------------------------------------------------------------
+CCsClientConversation* ConversationsEnginePrivate::getConversationFromConversationIdL(TInt aConversationId)
+{
+     return mServer->GetConversationFromConversationIdL(aConversationId);
+}
 
 //---------------------------------------------------------------
 // ConversationsEnginePrivate::clearConversationsL
@@ -235,10 +245,12 @@
     // Delete old CCsClientConversation object 
     // Remove the old Conversation change observer
     if(mClientConv)
-    {    
-        mServer->RemoveConversationChangeEventL (mConvChangeHandler ,mClientConv);
+    {   
+        int error = KErrNone;
+        TRAP(error, mServer->RemoveConversationChangeEventL (mConvChangeHandler ,mClientConv));
         delete mClientConv;
         mClientConv = NULL;
+        User::LeaveIfError(error);
     }
     
     QCRITICAL_WRITE("ConversationsEnginePrivate::clearConversationsL end.");
@@ -258,6 +270,30 @@
 }
 
 //---------------------------------------------------------------
+// ConversationsEnginePrivate::deRegisterCVUpdatesTemporary
+// @see header
+//---------------------------------------------------------------
+void ConversationsEnginePrivate::deRegisterCVUpdatesTemporary()
+{
+    mServer->RemoveConversationChangeEventL (mConvChangeHandler ,mClientConv);
+}
+
+//---------------------------------------------------------------
+// ConversationsEnginePrivate::registerAgainForConversationUpdatesL
+// @see header
+//---------------------------------------------------------------
+void ConversationsEnginePrivate::registerAgainForConversationUpdatesL(
+        int newConversationId)
+{
+    //Add the Conversation Change for new  conversationId
+    if(mClientConv)
+    {    
+    mClientConv->SetConversationEntryId(newConversationId);
+    mServer->RequestConversationChangeEventL (mConvChangeHandler ,mClientConv);
+    }
+}
+
+//---------------------------------------------------------------
 // ConversationsEnginePrivate::ConversationList
 // @see header
 //---------------------------------------------------------------
--- a/messagingapp/msgui/appengine/src/conversationsmodel.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationsmodel.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -49,6 +49,9 @@
 
 // preview-cache max cost (items)
 const int CACHE_COST =  50;
+//Preview thumbnail size
+const int KWidth = 9.5 * 6.7;
+const int KHeight = 9.5 * 6.7;
 //---------------------------------------------------------------
 // ConversationsModel::ConversationsModel
 // Constructor
@@ -512,7 +515,12 @@
     //populate from data plugins
     if (!isEntryInDb || err != KErrNone)
     {
-        iMmsDataPlugin->setMessageId(entry.EntryId());
+        int error = iMmsDataPlugin->setMessageId(entry.EntryId());
+        if(error != KErrNone)
+        {
+            // skip all
+            return;
+        }
         int msgProperty = 0;
 
         if (iMmsDataPlugin->attachmentCount() > 0)
@@ -552,7 +560,7 @@
                     isBodyTextSet = true;
                     file.close();
                 }
-                if (!isImageSet && objectList[index]->mimetype().contains(
+                if (!isVideoSet && !isImageSet && objectList[index]->mimetype().contains(
                     "image"))
                 {
                     isImageSet = true;
@@ -567,7 +575,7 @@
                     }
                     imagePath = objectList[index]->path();
                 }
-                if (!isAudioSet && objectList[index]->mimetype().contains(
+                if (!isVideoSet && !isAudioSet && objectList[index]->mimetype().contains(
                     "audio"))
                 {
                     msgProperty |= EPreviewAudio;
@@ -581,7 +589,7 @@
                     }
                     isAudioSet = true;
                 }
-                if (!isVideoSet && objectList[index]->mimetype().contains(
+                if (!( isImageSet || isAudioSet) && !isVideoSet && objectList[index]->mimetype().contains(
                     "video"))
                 {
                     isVideoSet = true;
@@ -604,6 +612,7 @@
         }
         QPixmap pixmap;
         //populate item  with the attachment list
+        //TODO: This code is not required bcoz video icon is show and not preview  
         if (isVideoSet)
         {
             item.setData(videoPath, Attachments);
@@ -825,7 +834,7 @@
     if (!inDb)
     {
         QPixmap pixmap(filePath);
-        QPixmap scaledPixmap = pixmap.scaled(63.65, 63.65, Qt::IgnoreAspectRatio);
+        QPixmap scaledPixmap = pixmap.scaled(KWidth, KHeight, Qt::IgnoreAspectRatio);
         HbIcon *previewIcon = new HbIcon(scaledPixmap);
 
         previewIconCache.insert(msgId, previewIcon);
@@ -963,4 +972,8 @@
     previewIconCache.clear();
 }
 
+void ConversationsModel:: emitConversationViewEmpty()
+{
+    emit conversationViewEmpty();
+}
 //EOF
--- a/messagingapp/msgui/appengine/src/conversationssummarymodel.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/src/conversationssummarymodel.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -38,6 +38,8 @@
 ConversationsSummaryModel::ConversationsSummaryModel(QObject* parent)
 :QStandardItemModel(parent)
     {
+    QStandardItemModel::setSortRole(TimeStamp);
+    QStandardItemModel::sort(0, Qt::DescendingOrder);
     }
 
 //---------------------------------------------------------------
@@ -156,7 +158,7 @@
 // @see header
 //---------------------------------------------------------------
 void ConversationsSummaryModel::addRow(
-        const CCsClientConversation& conversation)
+        const CCsClientConversation& conversation, bool caching)
     {  
     int convId = conversation.GetConversationEntryId();
     
@@ -178,7 +180,12 @@
         QModelIndex index = indexList[0];
         QStandardItem* item = this->item(index.row(), 0);
         populateItem(*item,conversation);
-    }        
+    }  
+    // no need to sort if it is initial caching, as sorting is already done
+    if (!caching)
+        {
+        QStandardItemModel::sort(0, Qt::DescendingOrder);
+        }
     }
 
 //---------------------------------------------------------------
--- a/messagingapp/msgui/appengine/tsrc/testconversationengine/testconversationengine.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/appengine/tsrc/testconversationengine/testconversationengine.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -31,8 +31,8 @@
 INCLUDEPATH += ../../../appengine/inc
 INCLUDEPATH += ../../../../msgappfw/client/inc
 INCLUDEPATH += ../../../../smartmessaging/ringbc/inc
-INCLUDEPATH += /ext/mw/qtextensions/qtmobileextensions/include
 INCLUDEPATH += ../../../../msgutils/unieditorutils/editorgenutils/inc
+
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
 DEFINES += BUILD_DLL
--- a/messagingapp/msgui/bwins/appengineu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/bwins/appengineu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -1,42 +1,45 @@
 EXPORTS
 	?fetchMoreConversations@ConversationsEngine@@QAEXXZ @ 1 NONAME ; void ConversationsEngine::fetchMoreConversations(void)
-	?getConversationIdFromAddress@ConversationsEngine@@QAE_JVQString@@@Z @ 2 NONAME ; long long ConversationsEngine::getConversationIdFromAddress(class QString)
-	?deleteAllDraftMessages@ConversationsEngine@@QAEXXZ @ 3 NONAME ; void ConversationsEngine::deleteAllDraftMessages(void)
-	?metaObject@ConversationsEngine@@UBEPBUQMetaObject@@XZ @ 4 NONAME ; struct QMetaObject const * ConversationsEngine::metaObject(void) const
-	??1ConversationsEngine@@UAE@XZ @ 5 NONAME ; ConversationsEngine::~ConversationsEngine(void)
-	?markAsReadAndGetType@ConversationsEngine@@QAEXHAAH0@Z @ 6 NONAME ; void ConversationsEngine::markAsReadAndGetType(int, int &, int &)
-	?deleteConversations@ConversationsEngine@@QAE_N_J@Z @ 7 NONAME ; bool ConversationsEngine::deleteConversations(long long)
-	?trUtf8@ConversationsEngine@@SA?AVQString@@PBD0@Z @ 8 NONAME ; class QString ConversationsEngine::trUtf8(char const *, char const *)
-	?qt_metacast@ConversationsEngine@@UAEPAXPBD@Z @ 9 NONAME ; void * ConversationsEngine::qt_metacast(char const *)
-	?emitConversationListModelPopulated@ConversationsEngine@@QAEXXZ @ 10 NONAME ; void ConversationsEngine::emitConversationListModelPopulated(void)
-	?getDraftsModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 11 NONAME ; class QStandardItemModel * ConversationsEngine::getDraftsModel(void)
-	?trUtf8@ConversationsEngine@@SA?AVQString@@PBD0H@Z @ 12 NONAME ; class QString ConversationsEngine::trUtf8(char const *, char const *, int)
-	?tr@ConversationsEngine@@SA?AVQString@@PBD0H@Z @ 13 NONAME ; class QString ConversationsEngine::tr(char const *, char const *, int)
-	?conversationModelUpdated@ConversationsEngine@@IAEXXZ @ 14 NONAME ; void ConversationsEngine::conversationModelUpdated(void)
-	?getStaticMetaObject@ConversationsEngine@@SAABUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const & ConversationsEngine::getStaticMetaObject(void)
-	?downloadOperationSupported@ConversationsEngine@@QAE_NH@Z @ 16 NONAME ; bool ConversationsEngine::downloadOperationSupported(int)
-	?markMessagesRead@ConversationsEngine@@QAE_NAAV?$QList@H@@@Z @ 17 NONAME ; bool ConversationsEngine::markMessagesRead(class QList<int> &)
-	?conversationModelPopulated@ConversationsEngine@@IAEXXZ @ 18 NONAME ; void ConversationsEngine::conversationModelPopulated(void)
-	?downloadMessage@ConversationsEngine@@QAEHH@Z @ 19 NONAME ; int ConversationsEngine::downloadMessage(int)
-	?getConversationsModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 20 NONAME ; class QStandardItemModel * ConversationsEngine::getConversationsModel(void)
-	?getCurrentConversationId@ConversationsEngine@@QAE_JXZ @ 21 NONAME ; long long ConversationsEngine::getCurrentConversationId(void)
-	?markConversationRead@ConversationsEngine@@QAE_N_J@Z @ 22 NONAME ; bool ConversationsEngine::markConversationRead(long long)
-	??_EConversationsEngine@@UAE@I@Z @ 23 NONAME ; ConversationsEngine::~ConversationsEngine(unsigned int)
-	?getConversationsSummaryModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 24 NONAME ; class QStandardItemModel * ConversationsEngine::getConversationsSummaryModel(void)
-	?conversationListModelPopulated@ConversationsEngine@@IAEXXZ @ 25 NONAME ; void ConversationsEngine::conversationListModelPopulated(void)
-	??0ConversationsEngine@@AAE@PAVQObject@@@Z @ 26 NONAME ; ConversationsEngine::ConversationsEngine(class QObject *)
-	?getContactDetails@ConversationsEngine@@QAEX_JAAVQString@@1@Z @ 27 NONAME ; void ConversationsEngine::getContactDetails(long long, class QString &, class QString &)
-	?instance@ConversationsEngine@@SAPAV1@XZ @ 28 NONAME ; class ConversationsEngine * ConversationsEngine::instance(void)
-	?tr@ConversationsEngine@@SA?AVQString@@PBD0@Z @ 29 NONAME ; class QString ConversationsEngine::tr(char const *, char const *)
-	?resendMessage@ConversationsEngine@@QAE_NH@Z @ 30 NONAME ; bool ConversationsEngine::resendMessage(int)
-	?emitConversationModelUpdated@ConversationsEngine@@QAEXXZ @ 31 NONAME ; void ConversationsEngine::emitConversationModelUpdated(void)
-	?getConversations@ConversationsEngine@@QAE_N_J@Z @ 32 NONAME ; bool ConversationsEngine::getConversations(long long)
-	?clearConversations@ConversationsEngine@@QAE_NXZ @ 33 NONAME ; bool ConversationsEngine::clearConversations(void)
-	?getDBHandle@ConversationsEngine@@QAEAAVRSqlDatabase@@AAH@Z @ 34 NONAME ; class RSqlDatabase & ConversationsEngine::getDBHandle(int &)
-	?getMsgSubType@ConversationsEngine@@QAEHH@Z @ 35 NONAME ; int ConversationsEngine::getMsgSubType(int)
-	?getConversationIdFromContactId@ConversationsEngine@@QAE_JH@Z @ 36 NONAME ; long long ConversationsEngine::getConversationIdFromContactId(int)
-	?staticMetaObject@ConversationsEngine@@2UQMetaObject@@B @ 37 NONAME ; struct QMetaObject const ConversationsEngine::staticMetaObject
-	?deleteMessages@ConversationsEngine@@QAEXAAV?$QList@H@@@Z @ 38 NONAME ; void ConversationsEngine::deleteMessages(class QList<int> &)
-	?emitConversationModelPopulated@ConversationsEngine@@QAEXXZ @ 39 NONAME ; void ConversationsEngine::emitConversationModelPopulated(void)
-	?qt_metacall@ConversationsEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 40 NONAME ; int ConversationsEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?disableRegisterationForCVEvents@ConversationsEngine@@QAEXXZ @ 2 NONAME ; void ConversationsEngine::disableRegisterationForCVEvents(void)
+	?getConversationIdFromAddress@ConversationsEngine@@QAE_JVQString@@@Z @ 3 NONAME ; long long ConversationsEngine::getConversationIdFromAddress(class QString)
+	?deleteAllDraftMessages@ConversationsEngine@@QAEXXZ @ 4 NONAME ; void ConversationsEngine::deleteAllDraftMessages(void)
+	?metaObject@ConversationsEngine@@UBEPBUQMetaObject@@XZ @ 5 NONAME ; struct QMetaObject const * ConversationsEngine::metaObject(void) const
+	??1ConversationsEngine@@UAE@XZ @ 6 NONAME ; ConversationsEngine::~ConversationsEngine(void)
+	?markAsReadAndGetType@ConversationsEngine@@QAEXHAAH0@Z @ 7 NONAME ; void ConversationsEngine::markAsReadAndGetType(int, int &, int &)
+	?deleteConversations@ConversationsEngine@@QAE_N_J@Z @ 8 NONAME ; bool ConversationsEngine::deleteConversations(long long)
+	?trUtf8@ConversationsEngine@@SA?AVQString@@PBD0@Z @ 9 NONAME ; class QString ConversationsEngine::trUtf8(char const *, char const *)
+	?qt_metacast@ConversationsEngine@@UAEPAXPBD@Z @ 10 NONAME ; void * ConversationsEngine::qt_metacast(char const *)
+	?emitConversationListModelPopulated@ConversationsEngine@@QAEXXZ @ 11 NONAME ; void ConversationsEngine::emitConversationListModelPopulated(void)
+	?getDraftsModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 12 NONAME ; class QStandardItemModel * ConversationsEngine::getDraftsModel(void)
+	?emitOpenConversationViewIdUpdate@ConversationsEngine@@QAEXH@Z @ 13 NONAME ; void ConversationsEngine::emitOpenConversationViewIdUpdate(int)
+	?trUtf8@ConversationsEngine@@SA?AVQString@@PBD0H@Z @ 14 NONAME ; class QString ConversationsEngine::trUtf8(char const *, char const *, int)
+	?tr@ConversationsEngine@@SA?AVQString@@PBD0H@Z @ 15 NONAME ; class QString ConversationsEngine::tr(char const *, char const *, int)
+	?conversationModelUpdated@ConversationsEngine@@IAEXXZ @ 16 NONAME ; void ConversationsEngine::conversationModelUpdated(void)
+	?getStaticMetaObject@ConversationsEngine@@SAABUQMetaObject@@XZ @ 17 NONAME ; struct QMetaObject const & ConversationsEngine::getStaticMetaObject(void)
+	?downloadOperationSupported@ConversationsEngine@@QAE_NH@Z @ 18 NONAME ; bool ConversationsEngine::downloadOperationSupported(int)
+	?markMessagesRead@ConversationsEngine@@QAE_NAAV?$QList@H@@@Z @ 19 NONAME ; bool ConversationsEngine::markMessagesRead(class QList<int> &)
+	?conversationModelPopulated@ConversationsEngine@@IAEXXZ @ 20 NONAME ; void ConversationsEngine::conversationModelPopulated(void)
+	?downloadMessage@ConversationsEngine@@QAEHH@Z @ 21 NONAME ; int ConversationsEngine::downloadMessage(int)
+	?getConversationsModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 22 NONAME ; class QStandardItemModel * ConversationsEngine::getConversationsModel(void)
+	?markConversationRead@ConversationsEngine@@QAE_N_J@Z @ 23 NONAME ; bool ConversationsEngine::markConversationRead(long long)
+	?getCurrentConversationId@ConversationsEngine@@QAE_JXZ @ 24 NONAME ; long long ConversationsEngine::getCurrentConversationId(void)
+	??_EConversationsEngine@@UAE@I@Z @ 25 NONAME ; ConversationsEngine::~ConversationsEngine(unsigned int)
+	?getConversationsSummaryModel@ConversationsEngine@@QAEPAVQStandardItemModel@@XZ @ 26 NONAME ; class QStandardItemModel * ConversationsEngine::getConversationsSummaryModel(void)
+	?conversationListModelPopulated@ConversationsEngine@@IAEXXZ @ 27 NONAME ; void ConversationsEngine::conversationListModelPopulated(void)
+	??0ConversationsEngine@@AAE@PAVQObject@@@Z @ 28 NONAME ; ConversationsEngine::ConversationsEngine(class QObject *)
+	?getContactDetails@ConversationsEngine@@QAEX_JAAVQString@@1@Z @ 29 NONAME ; void ConversationsEngine::getContactDetails(long long, class QString &, class QString &)
+	?instance@ConversationsEngine@@SAPAV1@XZ @ 30 NONAME ; class ConversationsEngine * ConversationsEngine::instance(void)
+	?tr@ConversationsEngine@@SA?AVQString@@PBD0@Z @ 31 NONAME ; class QString ConversationsEngine::tr(char const *, char const *)
+	?resendMessage@ConversationsEngine@@QAE_NH@Z @ 32 NONAME ; bool ConversationsEngine::resendMessage(int)
+	?emitConversationModelUpdated@ConversationsEngine@@QAEXXZ @ 33 NONAME ; void ConversationsEngine::emitConversationModelUpdated(void)
+	?getConversations@ConversationsEngine@@QAE_N_J@Z @ 34 NONAME ; bool ConversationsEngine::getConversations(long long)
+	?clearConversations@ConversationsEngine@@QAE_NXZ @ 35 NONAME ; bool ConversationsEngine::clearConversations(void)
+	?getDBHandle@ConversationsEngine@@QAEAAVRSqlDatabase@@AAH@Z @ 36 NONAME ; class RSqlDatabase & ConversationsEngine::getDBHandle(int &)
+	?getMsgSubType@ConversationsEngine@@QAEHH@Z @ 37 NONAME ; int ConversationsEngine::getMsgSubType(int)
+	?getConversationIdFromContactId@ConversationsEngine@@QAE_JH@Z @ 38 NONAME ; long long ConversationsEngine::getConversationIdFromContactId(int)
+	?staticMetaObject@ConversationsEngine@@2UQMetaObject@@B @ 39 NONAME ; struct QMetaObject const ConversationsEngine::staticMetaObject
+	?deleteMessages@ConversationsEngine@@QAEXAAV?$QList@H@@@Z @ 40 NONAME ; void ConversationsEngine::deleteMessages(class QList<int> &)
+	?emitConversationModelPopulated@ConversationsEngine@@QAEXXZ @ 41 NONAME ; void ConversationsEngine::emitConversationModelPopulated(void)
+	?conversationViewEmpty@ConversationsEngine@@IAEXXZ @ 42 NONAME ; void ConversationsEngine::conversationViewEmpty(void)
+	?qt_metacall@ConversationsEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 43 NONAME ; int ConversationsEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
 
--- a/messagingapp/msgui/bwins/conversationviewu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/bwins/conversationviewu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -1,28 +1,29 @@
 EXPORTS
 	?qt_metacast@MsgConversationBaseView@@UAEPAXPBD@Z @ 1 NONAME ; void * MsgConversationBaseView::qt_metacast(char const *)
 	?metaObject@MsgConversationBaseView@@UBEPBUQMetaObject@@XZ @ 2 NONAME ; struct QMetaObject const * MsgConversationBaseView::metaObject(void) const
-	?closeConversationView@MsgConversationBaseView@@QAEXXZ @ 3 NONAME ; void MsgConversationBaseView::closeConversationView(void)
-	?trUtf8@MsgConversationBaseView@@SA?AVQString@@PBD0H@Z @ 4 NONAME ; class QString MsgConversationBaseView::trUtf8(char const *, char const *, int)
-	?handleError@MsgConversationBaseView@@AAEXHABVQString@@@Z @ 5 NONAME ; void MsgConversationBaseView::handleError(int, class QString const &)
-	?tr@MsgConversationBaseView@@SA?AVQString@@PBD0H@Z @ 6 NONAME ; class QString MsgConversationBaseView::tr(char const *, char const *, int)
-	?hideChrome@MsgConversationBaseView@@AAEX_N@Z @ 7 NONAME ; void MsgConversationBaseView::hideChrome(bool)
-	??0MsgConversationBaseView@@QAE@PAVQGraphicsItem@@@Z @ 8 NONAME ; MsgConversationBaseView::MsgConversationBaseView(class QGraphicsItem *)
-	?handleOk@MsgConversationBaseView@@AAEXABVQVariant@@@Z @ 9 NONAME ; void MsgConversationBaseView::handleOk(class QVariant const &)
-	?trUtf8@MsgConversationBaseView@@SA?AVQString@@PBD0@Z @ 10 NONAME ; class QString MsgConversationBaseView::trUtf8(char const *, char const *)
-	?saveContentToDrafts@MsgConversationBaseView@@QAEHXZ @ 11 NONAME ; int MsgConversationBaseView::saveContentToDrafts(void)
-	?setPSCVId@MsgConversationBaseView@@QAEX_N@Z @ 12 NONAME ; void MsgConversationBaseView::setPSCVId(bool)
-	?doDelayedConstruction@MsgConversationBaseView@@AAEXXZ @ 13 NONAME ; void MsgConversationBaseView::doDelayedConstruction(void)
-	?openConversation@MsgConversationBaseView@@QAEX_J@Z @ 14 NONAME ; void MsgConversationBaseView::openConversation(long long)
-	?conversationId@MsgConversationBaseView@@QAE_JXZ @ 15 NONAME ; long long MsgConversationBaseView::conversationId(void)
-	?staticMetaObject@MsgConversationBaseView@@2UQMetaObject@@B @ 16 NONAME ; struct QMetaObject const MsgConversationBaseView::staticMetaObject
-	?conversationViewClosed@MsgConversationBaseView@@IAEXXZ @ 17 NONAME ; void MsgConversationBaseView::conversationViewClosed(void)
-	?initView@MsgConversationBaseView@@AAEXXZ @ 18 NONAME ; void MsgConversationBaseView::initView(void)
-	?markMessagesAsRead@MsgConversationBaseView@@QAEXXZ @ 19 NONAME ; void MsgConversationBaseView::markMessagesAsRead(void)
-	?tr@MsgConversationBaseView@@SA?AVQString@@PBD0@Z @ 20 NONAME ; class QString MsgConversationBaseView::tr(char const *, char const *)
-	?qt_metacall@MsgConversationBaseView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 21 NONAME ; int MsgConversationBaseView::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?getStaticMetaObject@MsgConversationBaseView@@SAABUQMetaObject@@XZ @ 22 NONAME ; struct QMetaObject const & MsgConversationBaseView::getStaticMetaObject(void)
-	??1MsgConversationBaseView@@UAE@XZ @ 23 NONAME ; MsgConversationBaseView::~MsgConversationBaseView(void)
-	?handleViewReady@MsgConversationBaseView@@AAEXXZ @ 24 NONAME ; void MsgConversationBaseView::handleViewReady(void)
-	??_EMsgConversationBaseView@@UAE@I@Z @ 25 NONAME ; MsgConversationBaseView::~MsgConversationBaseView(unsigned int)
-	?clearContent@MsgConversationBaseView@@QAEXXZ @ 26 NONAME ; void MsgConversationBaseView::clearContent(void)
+	?handleConversationIdChange@MsgConversationBaseView@@AAEX_J@Z @ 3 NONAME ; void MsgConversationBaseView::handleConversationIdChange(long long)
+	?closeConversationView@MsgConversationBaseView@@QAEXXZ @ 4 NONAME ; void MsgConversationBaseView::closeConversationView(void)
+	?trUtf8@MsgConversationBaseView@@SA?AVQString@@PBD0H@Z @ 5 NONAME ; class QString MsgConversationBaseView::trUtf8(char const *, char const *, int)
+	?handleError@MsgConversationBaseView@@AAEXHABVQString@@@Z @ 6 NONAME ; void MsgConversationBaseView::handleError(int, class QString const &)
+	?tr@MsgConversationBaseView@@SA?AVQString@@PBD0H@Z @ 7 NONAME ; class QString MsgConversationBaseView::tr(char const *, char const *, int)
+	?hideChrome@MsgConversationBaseView@@AAEX_N@Z @ 8 NONAME ; void MsgConversationBaseView::hideChrome(bool)
+	??0MsgConversationBaseView@@QAE@PAVQGraphicsItem@@@Z @ 9 NONAME ; MsgConversationBaseView::MsgConversationBaseView(class QGraphicsItem *)
+	?handleOk@MsgConversationBaseView@@AAEXABVQVariant@@@Z @ 10 NONAME ; void MsgConversationBaseView::handleOk(class QVariant const &)
+	?trUtf8@MsgConversationBaseView@@SA?AVQString@@PBD0@Z @ 11 NONAME ; class QString MsgConversationBaseView::trUtf8(char const *, char const *)
+	?saveContentToDrafts@MsgConversationBaseView@@QAEHXZ @ 12 NONAME ; int MsgConversationBaseView::saveContentToDrafts(void)
+	?setPSCVId@MsgConversationBaseView@@QAEX_N@Z @ 13 NONAME ; void MsgConversationBaseView::setPSCVId(bool)
+	?doDelayedConstruction@MsgConversationBaseView@@AAEXXZ @ 14 NONAME ; void MsgConversationBaseView::doDelayedConstruction(void)
+	?openConversation@MsgConversationBaseView@@QAEX_J@Z @ 15 NONAME ; void MsgConversationBaseView::openConversation(long long)
+	?conversationId@MsgConversationBaseView@@QAE_JXZ @ 16 NONAME ; long long MsgConversationBaseView::conversationId(void)
+	?staticMetaObject@MsgConversationBaseView@@2UQMetaObject@@B @ 17 NONAME ; struct QMetaObject const MsgConversationBaseView::staticMetaObject
+	?conversationViewClosed@MsgConversationBaseView@@IAEXXZ @ 18 NONAME ; void MsgConversationBaseView::conversationViewClosed(void)
+	?initView@MsgConversationBaseView@@AAEXXZ @ 19 NONAME ; void MsgConversationBaseView::initView(void)
+	?markMessagesAsRead@MsgConversationBaseView@@QAEXXZ @ 20 NONAME ; void MsgConversationBaseView::markMessagesAsRead(void)
+	?tr@MsgConversationBaseView@@SA?AVQString@@PBD0@Z @ 21 NONAME ; class QString MsgConversationBaseView::tr(char const *, char const *)
+	?qt_metacall@MsgConversationBaseView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 22 NONAME ; int MsgConversationBaseView::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?getStaticMetaObject@MsgConversationBaseView@@SAABUQMetaObject@@XZ @ 23 NONAME ; struct QMetaObject const & MsgConversationBaseView::getStaticMetaObject(void)
+	??1MsgConversationBaseView@@UAE@XZ @ 24 NONAME ; MsgConversationBaseView::~MsgConversationBaseView(void)
+	?handleViewReady@MsgConversationBaseView@@AAEXXZ @ 25 NONAME ; void MsgConversationBaseView::handleViewReady(void)
+	??_EMsgConversationBaseView@@UAE@I@Z @ 26 NONAME ; MsgConversationBaseView::~MsgConversationBaseView(unsigned int)
+	?clearContent@MsgConversationBaseView@@QAEXXZ @ 27 NONAME ; void MsgConversationBaseView::clearContent(void)
 
--- a/messagingapp/msgui/bwins/msgaudiofetcheru.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/bwins/msgaudiofetcheru.def	Tue Jul 06 14:12:40 2010 +0300
@@ -11,10 +11,10 @@
 	?trUtf8@MsgAudioFetcherView@@SA?AVQString@@PBD0H@Z @ 10 NONAME ; class QString MsgAudioFetcherView::trUtf8(char const *, char const *, int)
 	?tr@MsgAudioFetcherView@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString MsgAudioFetcherView::tr(char const *, char const *, int)
 	?on_rightAction_triggered@MsgAudioFetcherView@@AAEXXZ @ 12 NONAME ; void MsgAudioFetcherView::on_rightAction_triggered(void)
-	?initToolBar@MsgAudioFetcherView@@AAEXXZ @ 13 NONAME ; void MsgAudioFetcherView::initToolBar(void)
-	?tr@MsgAudioFetcherView@@SA?AVQString@@PBD0@Z @ 14 NONAME ; class QString MsgAudioFetcherView::tr(char const *, char const *)
-	?qt_metacast@MsgAudioFetcherView@@UAEPAXPBD@Z @ 15 NONAME ; void * MsgAudioFetcherView::qt_metacast(char const *)
-	??0MsgAudioFetcherView@@QAE@XZ @ 16 NONAME ; MsgAudioFetcherView::MsgAudioFetcherView(void)
+	??0MsgAudioFetcherView@@QAE@ABV?$QList@VQVariant@@@@@Z @ 13 NONAME ; MsgAudioFetcherView::MsgAudioFetcherView(class QList<class QVariant> const &)
+	?initToolBar@MsgAudioFetcherView@@AAEXXZ @ 14 NONAME ; void MsgAudioFetcherView::initToolBar(void)
+	?tr@MsgAudioFetcherView@@SA?AVQString@@PBD0@Z @ 15 NONAME ; class QString MsgAudioFetcherView::tr(char const *, char const *)
+	?qt_metacast@MsgAudioFetcherView@@UAEPAXPBD@Z @ 16 NONAME ; void * MsgAudioFetcherView::qt_metacast(char const *)
 	?getStaticMetaObject@MsgAudioFetcherView@@SAABUQMetaObject@@XZ @ 17 NONAME ; struct QMetaObject const & MsgAudioFetcherView::getStaticMetaObject(void)
 	?on_leftAction_triggered@MsgAudioFetcherView@@AAEXXZ @ 18 NONAME ; void MsgAudioFetcherView::on_leftAction_triggered(void)
 
--- a/messagingapp/msgui/bwins/unifiededitoru.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/bwins/unifiededitoru.def	Tue Jul 06 14:12:40 2010 +0300
@@ -8,56 +8,56 @@
 	?fetchImages@MsgUnifiedEditorView@@AAEXXZ @ 7 NONAME ; void MsgUnifiedEditorView::fetchImages(void)
 	?packMessage@MsgUnifiedEditorView@@AAEXAAVConvergedMessage@@_N@Z @ 8 NONAME ; void MsgUnifiedEditorView::packMessage(class ConvergedMessage &, bool)
 	?handleViewExtnActivated@MsgUnifiedEditorView@@AAEXPAVHbListWidgetItem@@@Z @ 9 NONAME ; void MsgUnifiedEditorView::handleViewExtnActivated(class HbListWidgetItem *)
-	?sendingOptions@MsgUnifiedEditorView@@AAEXXZ @ 10 NONAME ; void MsgUnifiedEditorView::sendingOptions(void)
-	?addAttachment@MsgUnifiedEditorView@@AAEHABVQString@@@Z @ 11 NONAME ; int MsgUnifiedEditorView::addAttachment(class QString const &)
-	?doDelayedConstruction@MsgUnifiedEditorView@@AAEXXZ @ 12 NONAME ; void MsgUnifiedEditorView::doDelayedConstruction(void)
-	?onContentChanged@MsgUnifiedEditorView@@AAEXXZ @ 13 NONAME ; void MsgUnifiedEditorView::onContentChanged(void)
-	?staticMetaObject@MsgUnifiedEditorView@@2UQMetaObject@@B @ 14 NONAME ; struct QMetaObject const MsgUnifiedEditorView::staticMetaObject
-	?activateInputBlocker@MsgUnifiedEditorView@@AAEXXZ @ 15 NONAME ; void MsgUnifiedEditorView::activateInputBlocker(void)
-	?resizeEvent@MsgUnifiedEditorView@@MAEXPAVQGraphicsSceneResizeEvent@@@Z @ 16 NONAME ; void MsgUnifiedEditorView::resizeEvent(class QGraphicsSceneResizeEvent *)
-	?ScaleImageL@CUniImageProcessor@@QAEXPAVCFbsBitmap@@0H@Z @ 17 NONAME ; void CUniImageProcessor::ScaleImageL(class CFbsBitmap *, class CFbsBitmap *, int)
-	?onDialogSmsSettings@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 18 NONAME ; void MsgUnifiedEditorView::onDialogSmsSettings(class HbAction *)
-	?populateContent@MsgUnifiedEditorView@@QAEXABV?$QList@VQVariant@@@@@Z @ 19 NONAME ; void MsgUnifiedEditorView::populateContent(class QList<class QVariant> const &)
-	?onDialogMmsSettings@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 20 NONAME ; void MsgUnifiedEditorView::onDialogMmsSettings(class HbAction *)
-	?addCcBcc@MsgUnifiedEditorView@@AAEXXZ @ 21 NONAME ; void MsgUnifiedEditorView::addCcBcc(void)
-	?saveContentToDrafts@MsgUnifiedEditorView@@QAEHXZ @ 22 NONAME ; int MsgUnifiedEditorView::saveContentToDrafts(void)
-	?ProcessImageL@CUniImageProcessor@@QAEXAAVRFile@@0AAVTSize@@ABVTDesC8@@HH@Z @ 23 NONAME ; void CUniImageProcessor::ProcessImageL(class RFile &, class RFile &, class TSize &, class TDesC8 const &, int, int)
-	?generateFileName@MsgUnifiedEditorView@@AAE?AVQString@@AAV2@@Z @ 24 NONAME ; class QString MsgUnifiedEditorView::generateFileName(class QString &)
-	?metaObject@MsgUnifiedEditorView@@UBEPBUQMetaObject@@XZ @ 25 NONAME ; struct QMetaObject const * MsgUnifiedEditorView::metaObject(void) const
-	?createVCards@MsgUnifiedEditorView@@AAEHABVQVariant@@AAVQStringList@@@Z @ 26 NONAME ; int MsgUnifiedEditorView::createVCards(class QVariant const &, class QStringList &)
-	?addSubject@MsgUnifiedEditorView@@AAEXXZ @ 27 NONAME ; void MsgUnifiedEditorView::addSubject(void)
-	?createTempFolder@MsgUnifiedEditorView@@AAE_NXZ @ 28 NONAME ; bool MsgUnifiedEditorView::createTempFolder(void)
-	?imagesFetched@MsgUnifiedEditorView@@AAEXABVQVariant@@@Z @ 29 NONAME ; void MsgUnifiedEditorView::imagesFetched(class QVariant const &)
-	?setFocus@MsgUnifiedEditorView@@AAEXPAVMsgUnifiedEditorBaseWidget@@@Z @ 30 NONAME ; void MsgUnifiedEditorView::setFocus(class MsgUnifiedEditorBaseWidget *)
-	?vkbClosed@MsgUnifiedEditorView@@AAEXXZ @ 31 NONAME ; void MsgUnifiedEditorView::vkbClosed(void)
-	?serviceRequestError@MsgUnifiedEditorView@@AAEXHABVQString@@@Z @ 32 NONAME ; void MsgUnifiedEditorView::serviceRequestError(int, class QString const &)
-	?qt_metacast@MsgUnifiedEditorView@@UAEPAXPBD@Z @ 33 NONAME ; void * MsgUnifiedEditorView::qt_metacast(char const *)
-	?removeTempFolder@MsgUnifiedEditorView@@AAEXXZ @ 34 NONAME ; void MsgUnifiedEditorView::removeTempFolder(void)
-	?vkbOpened@MsgUnifiedEditorView@@AAEXXZ @ 35 NONAME ; void MsgUnifiedEditorView::vkbOpened(void)
-	?ScaleImageL@CUniImageProcessor@@QAEXAAVRFile@@AAPAVCFbsBitmap@@1AAVTSize@@H@Z @ 36 NONAME ; void CUniImageProcessor::ScaleImageL(class RFile &, class CFbsBitmap * &, class CFbsBitmap * &, class TSize &, int)
-	?addMenu@MsgUnifiedEditorView@@AAEXXZ @ 37 NONAME ; void MsgUnifiedEditorView::addMenu(void)
-	?enableSendButton@MsgUnifiedEditorView@@AAEX_N@Z @ 38 NONAME ; void MsgUnifiedEditorView::enableSendButton(bool)
-	?initView@MsgUnifiedEditorView@@AAEXXZ @ 39 NONAME ; void MsgUnifiedEditorView::initView(void)
-	??_EMsgUnifiedEditorView@@UAE@I@Z @ 40 NONAME ; MsgUnifiedEditorView::~MsgUnifiedEditorView(unsigned int)
-	??1MsgUnifiedEditorView@@UAE@XZ @ 41 NONAME ; MsgUnifiedEditorView::~MsgUnifiedEditorView(void)
-	?setAttachOptionEnabled@MsgUnifiedEditorView@@AAEXW4TBE_AttachOption@1@_N@Z @ 42 NONAME ; void MsgUnifiedEditorView::setAttachOptionEnabled(enum MsgUnifiedEditorView::TBE_AttachOption, bool)
-	?hideChrome@MsgUnifiedEditorView@@AAEX_N@Z @ 43 NONAME ; void MsgUnifiedEditorView::hideChrome(bool)
-	?trUtf8@MsgUnifiedEditorView@@SA?AVQString@@PBD0@Z @ 44 NONAME ; class QString MsgUnifiedEditorView::trUtf8(char const *, char const *)
-	?tr@MsgUnifiedEditorView@@SA?AVQString@@PBD0@Z @ 45 NONAME ; class QString MsgUnifiedEditorView::tr(char const *, char const *)
-	?ScaleImageL@CUniImageProcessor@@QAEXPAVCFbsBitmap@@AAVRFile@@ABVTSize@@ABVTDesC8@@H@Z @ 46 NONAME ; void CUniImageProcessor::ScaleImageL(class CFbsBitmap *, class RFile &, class TSize const &, class TDesC8 const &, int)
-	?getStaticMetaObject@MsgUnifiedEditorView@@SAABUQMetaObject@@XZ @ 47 NONAME ; struct QMetaObject const & MsgUnifiedEditorView::getStaticMetaObject(void)
-	?tr@MsgUnifiedEditorView@@SA?AVQString@@PBD0H@Z @ 48 NONAME ; class QString MsgUnifiedEditorView::tr(char const *, char const *, int)
-	?send@MsgUnifiedEditorView@@AAEXXZ @ 49 NONAME ; void MsgUnifiedEditorView::send(void)
-	?Reset@CUniImageProcessor@@QAEXXZ @ 50 NONAME ; void CUniImageProcessor::Reset(void)
-	?populateContentIntoEditor@MsgUnifiedEditorView@@AAEXABVConvergedMessage@@_N@Z @ 51 NONAME ; void MsgUnifiedEditorView::populateContentIntoEditor(class ConvergedMessage const &, bool)
-	?openDraftsMessage@MsgUnifiedEditorView@@QAEXABV?$QList@VQVariant@@@@@Z @ 52 NONAME ; void MsgUnifiedEditorView::openDraftsMessage(class QList<class QVariant> const &)
-	?addToolBar@MsgUnifiedEditorView@@AAEXXZ @ 53 NONAME ; void MsgUnifiedEditorView::addToolBar(void)
-	?contactsFetched@MsgUnifiedEditorView@@AAEXABVQVariant@@@Z @ 54 NONAME ; void MsgUnifiedEditorView::contactsFetched(class QVariant const &)
-	?removeAttachmentContainer@MsgUnifiedEditorView@@AAEXXZ @ 55 NONAME ; void MsgUnifiedEditorView::removeAttachmentContainer(void)
-	?trUtf8@MsgUnifiedEditorView@@SA?AVQString@@PBD0H@Z @ 56 NONAME ; class QString MsgUnifiedEditorView::trUtf8(char const *, char const *, int)
-	?onDialogDeleteMsg@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 57 NONAME ; void MsgUnifiedEditorView::onDialogDeleteMsg(class HbAction *)
-	??0MsgUnifiedEditorView@@QAE@PAVQGraphicsItem@@@Z @ 58 NONAME ; MsgUnifiedEditorView::MsgUnifiedEditorView(class QGraphicsItem *)
-	?fetchContacts@MsgUnifiedEditorView@@AAEXXZ @ 59 NONAME ; void MsgUnifiedEditorView::fetchContacts(void)
+	?addAttachment@MsgUnifiedEditorView@@AAEHABVQString@@@Z @ 10 NONAME ; int MsgUnifiedEditorView::addAttachment(class QString const &)
+	?doDelayedConstruction@MsgUnifiedEditorView@@AAEXXZ @ 11 NONAME ; void MsgUnifiedEditorView::doDelayedConstruction(void)
+	?onContentChanged@MsgUnifiedEditorView@@AAEXXZ @ 12 NONAME ; void MsgUnifiedEditorView::onContentChanged(void)
+	?staticMetaObject@MsgUnifiedEditorView@@2UQMetaObject@@B @ 13 NONAME ; struct QMetaObject const MsgUnifiedEditorView::staticMetaObject
+	?activateInputBlocker@MsgUnifiedEditorView@@AAEXXZ @ 14 NONAME ; void MsgUnifiedEditorView::activateInputBlocker(void)
+	?resizeEvent@MsgUnifiedEditorView@@MAEXPAVQGraphicsSceneResizeEvent@@@Z @ 15 NONAME ; void MsgUnifiedEditorView::resizeEvent(class QGraphicsSceneResizeEvent *)
+	?ScaleImageL@CUniImageProcessor@@QAEXPAVCFbsBitmap@@0H@Z @ 16 NONAME ; void CUniImageProcessor::ScaleImageL(class CFbsBitmap *, class CFbsBitmap *, int)
+	?onDialogSmsSettings@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 17 NONAME ; void MsgUnifiedEditorView::onDialogSmsSettings(class HbAction *)
+	?populateContent@MsgUnifiedEditorView@@QAEXABV?$QList@VQVariant@@@@@Z @ 18 NONAME ; void MsgUnifiedEditorView::populateContent(class QList<class QVariant> const &)
+	?onDialogMmsSettings@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 19 NONAME ; void MsgUnifiedEditorView::onDialogMmsSettings(class HbAction *)
+	?addCcBcc@MsgUnifiedEditorView@@AAEXXZ @ 20 NONAME ; void MsgUnifiedEditorView::addCcBcc(void)
+	?saveContentToDrafts@MsgUnifiedEditorView@@QAEHXZ @ 21 NONAME ; int MsgUnifiedEditorView::saveContentToDrafts(void)
+	?ProcessImageL@CUniImageProcessor@@QAEXAAVRFile@@0AAVTSize@@ABVTDesC8@@HH@Z @ 22 NONAME ; void CUniImageProcessor::ProcessImageL(class RFile &, class RFile &, class TSize &, class TDesC8 const &, int, int)
+	?generateFileName@MsgUnifiedEditorView@@AAE?AVQString@@AAV2@@Z @ 23 NONAME ; class QString MsgUnifiedEditorView::generateFileName(class QString &)
+	?metaObject@MsgUnifiedEditorView@@UBEPBUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const * MsgUnifiedEditorView::metaObject(void) const
+	?createVCards@MsgUnifiedEditorView@@AAEHABVQVariant@@AAVQStringList@@@Z @ 25 NONAME ; int MsgUnifiedEditorView::createVCards(class QVariant const &, class QStringList &)
+	?addSubject@MsgUnifiedEditorView@@AAEXXZ @ 26 NONAME ; void MsgUnifiedEditorView::addSubject(void)
+	?createTempFolder@MsgUnifiedEditorView@@AAE_NXZ @ 27 NONAME ; bool MsgUnifiedEditorView::createTempFolder(void)
+	?imagesFetched@MsgUnifiedEditorView@@AAEXABVQVariant@@@Z @ 28 NONAME ; void MsgUnifiedEditorView::imagesFetched(class QVariant const &)
+	?setFocus@MsgUnifiedEditorView@@AAEXPAVMsgUnifiedEditorBaseWidget@@@Z @ 29 NONAME ; void MsgUnifiedEditorView::setFocus(class MsgUnifiedEditorBaseWidget *)
+	?vkbClosed@MsgUnifiedEditorView@@AAEXXZ @ 30 NONAME ; void MsgUnifiedEditorView::vkbClosed(void)
+	?serviceRequestError@MsgUnifiedEditorView@@AAEXHABVQString@@@Z @ 31 NONAME ; void MsgUnifiedEditorView::serviceRequestError(int, class QString const &)
+	?qt_metacast@MsgUnifiedEditorView@@UAEPAXPBD@Z @ 32 NONAME ; void * MsgUnifiedEditorView::qt_metacast(char const *)
+	?removeTempFolder@MsgUnifiedEditorView@@AAEXXZ @ 33 NONAME ; void MsgUnifiedEditorView::removeTempFolder(void)
+	?vkbOpened@MsgUnifiedEditorView@@AAEXXZ @ 34 NONAME ; void MsgUnifiedEditorView::vkbOpened(void)
+	?ScaleImageL@CUniImageProcessor@@QAEXAAVRFile@@AAPAVCFbsBitmap@@1AAVTSize@@H@Z @ 35 NONAME ; void CUniImageProcessor::ScaleImageL(class RFile &, class CFbsBitmap * &, class CFbsBitmap * &, class TSize &, int)
+	?addMenu@MsgUnifiedEditorView@@AAEXXZ @ 36 NONAME ; void MsgUnifiedEditorView::addMenu(void)
+	?enableSendButton@MsgUnifiedEditorView@@AAEX_N@Z @ 37 NONAME ; void MsgUnifiedEditorView::enableSendButton(bool)
+	?initView@MsgUnifiedEditorView@@AAEXXZ @ 38 NONAME ; void MsgUnifiedEditorView::initView(void)
+	??_EMsgUnifiedEditorView@@UAE@I@Z @ 39 NONAME ; MsgUnifiedEditorView::~MsgUnifiedEditorView(unsigned int)
+	??1MsgUnifiedEditorView@@UAE@XZ @ 40 NONAME ; MsgUnifiedEditorView::~MsgUnifiedEditorView(void)
+	?setAttachOptionEnabled@MsgUnifiedEditorView@@AAEXW4TBE_AttachOption@1@_N@Z @ 41 NONAME ; void MsgUnifiedEditorView::setAttachOptionEnabled(enum MsgUnifiedEditorView::TBE_AttachOption, bool)
+	?hideChrome@MsgUnifiedEditorView@@AAEX_N@Z @ 42 NONAME ; void MsgUnifiedEditorView::hideChrome(bool)
+	?trUtf8@MsgUnifiedEditorView@@SA?AVQString@@PBD0@Z @ 43 NONAME ; class QString MsgUnifiedEditorView::trUtf8(char const *, char const *)
+	?tr@MsgUnifiedEditorView@@SA?AVQString@@PBD0@Z @ 44 NONAME ; class QString MsgUnifiedEditorView::tr(char const *, char const *)
+	?ScaleImageL@CUniImageProcessor@@QAEXPAVCFbsBitmap@@AAVRFile@@ABVTSize@@ABVTDesC8@@H@Z @ 45 NONAME ; void CUniImageProcessor::ScaleImageL(class CFbsBitmap *, class RFile &, class TSize const &, class TDesC8 const &, int)
+	?getStaticMetaObject@MsgUnifiedEditorView@@SAABUQMetaObject@@XZ @ 46 NONAME ; struct QMetaObject const & MsgUnifiedEditorView::getStaticMetaObject(void)
+	?tr@MsgUnifiedEditorView@@SA?AVQString@@PBD0H@Z @ 47 NONAME ; class QString MsgUnifiedEditorView::tr(char const *, char const *, int)
+	?send@MsgUnifiedEditorView@@AAEXXZ @ 48 NONAME ; void MsgUnifiedEditorView::send(void)
+	?Reset@CUniImageProcessor@@QAEXXZ @ 49 NONAME ; void CUniImageProcessor::Reset(void)
+	?populateContentIntoEditor@MsgUnifiedEditorView@@AAEXABVConvergedMessage@@_N@Z @ 50 NONAME ; void MsgUnifiedEditorView::populateContentIntoEditor(class ConvergedMessage const &, bool)
+	?openDraftsMessage@MsgUnifiedEditorView@@QAEXABV?$QList@VQVariant@@@@@Z @ 51 NONAME ; void MsgUnifiedEditorView::openDraftsMessage(class QList<class QVariant> const &)
+	?addToolBar@MsgUnifiedEditorView@@AAEXXZ @ 52 NONAME ; void MsgUnifiedEditorView::addToolBar(void)
+	?contactsFetched@MsgUnifiedEditorView@@AAEXABVQVariant@@@Z @ 53 NONAME ; void MsgUnifiedEditorView::contactsFetched(class QVariant const &)
+	?removeAttachmentContainer@MsgUnifiedEditorView@@AAEXXZ @ 54 NONAME ; void MsgUnifiedEditorView::removeAttachmentContainer(void)
+	?trUtf8@MsgUnifiedEditorView@@SA?AVQString@@PBD0H@Z @ 55 NONAME ; class QString MsgUnifiedEditorView::trUtf8(char const *, char const *, int)
+	?onDialogDeleteMsg@MsgUnifiedEditorView@@AAEXPAVHbAction@@@Z @ 56 NONAME ; void MsgUnifiedEditorView::onDialogDeleteMsg(class HbAction *)
+	??0MsgUnifiedEditorView@@QAE@PAVQGraphicsItem@@@Z @ 57 NONAME ; MsgUnifiedEditorView::MsgUnifiedEditorView(class QGraphicsItem *)
+	?fetchContacts@MsgUnifiedEditorView@@AAEXXZ @ 58 NONAME ; void MsgUnifiedEditorView::fetchContacts(void)
+	?formatAddresses@MsgUnifiedEditorView@@AAEXAAV?$QList@PAVConvergedMessageAddress@@@@@Z @ 59 NONAME ; void MsgUnifiedEditorView::formatAddresses(class QList<class ConvergedMessageAddress *> &)
 	?deleteMessage@MsgUnifiedEditorView@@AAEXXZ @ 60 NONAME ; void MsgUnifiedEditorView::deleteMessage(void)
 	?addAttachments@MsgUnifiedEditorView@@AAEXVQStringList@@@Z @ 61 NONAME ; void MsgUnifiedEditorView::addAttachments(class QStringList)
 	?deactivateInputBlocker@MsgUnifiedEditorView@@AAEXXZ @ 62 NONAME ; void MsgUnifiedEditorView::deactivateInputBlocker(void)
--- a/messagingapp/msgui/conversationview/conversationview.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/conversationview.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -30,11 +30,9 @@
 INCLUDEPATH += ../appengine/inc
 INCLUDEPATH += ../../smartmessaging/ringbc/inc
 INCLUDEPATH += ../../msgsettings/settingsview/inc
+INCLUDEPATH += ../../msgutils/unidatamodel/univcaldataplugin/inc
 
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-INCLUDEPATH += /ext/mw/qthighway/inc
-INCLUDEPATH += /ext/mw/qtextensions/qtmobileextensions/include
-INCLUDEPATH += ../../msgutils/unidatamodel/univcaldataplugin/inc
 
 CONFIG += hb
 HB += hbfeedback
--- a/messagingapp/msgui/conversationview/inc/msgcontactcardwidget.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/inc/msgcontactcardwidget.h	Tue Jul 06 14:12:40 2010 +0300
@@ -84,6 +84,13 @@
      */
     void clearContent();
 
+signals:
+
+    /**
+     *
+     */
+    void conversationIdChanged(qint64 convId);
+
 protected:
 
     /**
@@ -113,9 +120,14 @@
 private slots:
 
     /**
-     * show longpress menu for attachment object
+     * show longp tap.
      */
-    void handleLongPress(const QPointF &position);
+    void handleLongTap(const QPointF &position);
+    
+    /**
+     * handles short tap.
+     */
+    void handleShortTap(const QPointF &position);
 
     /**
      * Slot for handling valid returns from the framework.
--- a/messagingapp/msgui/conversationview/inc/msgconversationbaseview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/inc/msgconversationbaseview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -130,6 +130,11 @@
      */
     void handleViewReady();
 
+    /**
+     *
+     */
+    void handleConversationIdChange(qint64 convId);
+
 signals:
     /**
      * Signal emitted when the conversation view is closed.
--- a/messagingapp/msgui/conversationview/inc/msgconversationview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/inc/msgconversationview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -114,11 +114,6 @@
      */
     void onOrientationAboutToBeChanged();
     
-    /**
-     * This slot is called when the view is successfully added to main window
-     */
-    void onViewReady();
-    
 private:
 
     /**
@@ -132,6 +127,11 @@
     void setupMenu();
 
     /**
+     * Triggers model to fetch more conversations.
+     */
+    void fetchMoreConversations();
+
+    /**
      * Populates ConvergedMessage for sending.
      * @param ConvergedMessage to be populated
      * @see ConvergedMessage::MessageType
@@ -211,6 +211,11 @@
      * data
      */
     void refreshView();
+
+    /**
+     * This slot is called when the view is successfully added to main window
+     */
+    void onViewReady();
     
 private slots:
 
@@ -218,6 +223,8 @@
      * Utility method to scroll the list to show the bottom most item
      */
     void scrollToBottom();
+    
+    void onConversationViewEmpty();
 
     /**
      * Handler for long tap of a list item.
@@ -420,15 +427,25 @@
     HbStaticVkbHost* mVkbHost;
     
     /**
+     * variable holding the visible model index
+     */
+    QModelIndex mVisibleIndex;
+    
+    /**
      * Flag to check it vkb is open.
      */
     bool mVkbopened;
-
+    
     /**
-     * variable holding the visible model index
+     * Flag is set when model is populated.
+     * @see signal conversationModelPopulated()
      */
-    QModelIndex mVisibleIndex;
-
+    bool mModelPopulated;
+    
+    /**
+     * Flag is set when 
+     */
+    bool mViewReady;
 };
 
 #endif // MSG_CONVERSATION_VIEW_H
--- a/messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.css	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.css	Tue Jul 06 14:12:40 2010 +0300
@@ -49,9 +49,23 @@
   bottom:var(hb-param-margin-gene-middle-vertical);
   text-height:var(hb-param-text-height-secondary);
   font-variant:primary;
-  text-align:left;
   text-line-count-min:1;
-  text-line-count-max:100;
+  text-line-count-max:30;
+}
+
+MsgConversationWidget[isMMS="true"]::bodyText
+{
+	top:-var(hb-param-margin-gene-middle-vertical);
+}
+
+MsgConversationWidget[hasImage="true"]::bodyText:landscape
+{
+	left:-var(hb-param-margin-gene-middle-horizontal);
+}
+
+MsgConversationWidget[hasAudio="true"]::bodyText:landscape
+{
+	left:-var(hb-param-margin-gene-middle-horizontal);
 }
 
 /********************************** SUBJECT ***********************************/
@@ -71,7 +85,7 @@
 
 MsgConversationWidget[isMMS="false"]::subject
 {
-  text-line-count-max:100;
+  text-line-count-max:30;
   text-height:var(hb-param-text-height-secondary);
 }
 
@@ -112,18 +126,9 @@
 
 /******************************** IMAGE / PREVIEW *****************************/
 
-MsgConversationWidget::preview:portrait
+MsgConversationWidget::preview
 {
   left:-var(hb-param-margin-gene-left);
-  right:1.0un;
-  bottom:var(hb-param-margin-gene-middle-vertical);
-  /*aspect-ratio:keep;*/
-  /*max-width:var(bubble_width);*/
-  /*max-width:41.36un;
-  max-height:31.02un;*/
-  /*max-height:var(bubble_height);*/
-  /*min-width:16un;
-  min-height:12un;*/
   size-policy:fixed fixed;
   aspect-ratio:ignore;
 }
@@ -133,11 +138,6 @@
   left:-var(hb-param-margin-gene-left);
   top:-var(hb-param-margin-gene-top);
   bottom:var(hb-param-margin-gene-bottom);
-  /*aspect-ratio:keep;
-  max-width:41.36un;
-  max-height:31.02un;
-  min-width:16un;
-  min-height:12un;*/
   size-policy:fixed fixed;
   aspect-ratio:ignore;
 }
@@ -156,28 +156,32 @@
   text-line-count-min:1;
 }
 
+MsgConversationWidget[hasImage="true"]::timeStamp:landscape
+{
+  left:-var(hb-param-margin-gene-middle-horizontal);
+}
+
+MsgConversationWidget[hasAudio="true"]::timeStamp:landscape
+{
+  left:-var(hb-param-margin-gene-middle-horizontal);
+}
+
 /******************************* OVERLAY PLAY ICON ****************************/
 
 MsgConversationWidget::playIcon
 {
   zvalue:1;
+  left:-var(hb-param-margin-gene-middle-horizontal);
   aspect-ratio:ignore;
   size-policy:fixed fixed;
-  pref-width:var(hb-param-graphic-size-primary-medium);
-  pref-height:var(hb-param-graphic-size-primary-medium);
+  pref-width:var(hb-param-graphic-size-primary-small);
+  pref-height:var(hb-param-graphic-size-primary-small);
 }
 
-/******************************** AUDIO ICON **********************************/
-
-MsgConversationWidget[hasAudio="true"]::audioIcon
+MsgConversationWidget::playIcon:landscape
 {
   top:-var(hb-param-margin-gene-top);
-  left:-var(hb-param-margin-gene-left);
-  bottom:var(hb-param-margin-gene-middle-vertical);
-  aspect-ratio:ignore;
-  size-policy:fixed fixed;
-  pref-width:var(hb-param-graphic-size-primary-large);
-  pref-height:var(hb-param-graphic-size-primary-large);
 }
 
+
 /* EOF */
\ No newline at end of file
--- a/messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.widgetml	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/resources/layouts/msgconversationwidget.widgetml	Tue Jul 06 14:12:40 2010 +0300
@@ -2,8 +2,7 @@
 
   <layout name="layout-msg-portrait" type="mesh">
 
-    <meshitem src="subject" srcEdge="TOP" dst="" dstEdge="TOP" />
-    <meshitem src="subject" srcEdge="BOTTOM" dst="preview" dstEdge="TOP" />
+    <meshitem src="subject" srcEdge="TOP" dst="" dstEdge="TOP" />   
     <meshitem src="subject" srcEdge="LEFT" dst="" dstEdge="LEFT" />
     <meshitem src="subject" srcEdge="RIGHT" dst="priority" dstEdge="LEFT"  spacer="rightSpacer"  />
 
@@ -13,13 +12,14 @@
     <meshitem src="attachment" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     <meshitem src="attachment" srcEdge="CENTERV" dst="subject" dstEdge="CENTERV" />
 
-    <meshitem src="preview" srcEdge="BOTTOM" dst="bodyText" dstEdge="TOP" />
-    <meshitem src="preview" srcEdge="CENTERH" dst="" dstEdge="CENTERH"/>
+    <meshitem src="preview" srcEdge="TOP" dst="subject" dstEdge="BOTTOM" />
+    <meshitem src="preview" srcEdge="LEFT" dst="" dstEdge="LEFT" />
 
+    <meshitem src="bodyText" srcEdge="TOP" dst="preview" dstEdge="BOTTOM" />
     <meshitem src="bodyText" srcEdge="LEFT" dst="" dstEdge="LEFT" />
     <meshitem src="bodyText" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
-    <meshitem src="bodyText" srcEdge="BOTTOM" dst="timeStamp" dstEdge="TOP" />
 
+    <meshitem src="timeStamp" srcEdge="TOP" dst="bodyText" dstEdge="BOTTOM" />
     <meshitem src="timeStamp" srcEdge="LEFT" dst="" dstEdge="LEFT" />
     <meshitem src="timeStamp" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     <meshitem src="timeStamp" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
@@ -33,8 +33,8 @@
     <meshitem src="bubble" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="bubble" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
 
-    <meshitem src="playIcon" srcEdge="CENTERV" dst="preview" dstEdge="CENTERV" />
-    <meshitem src="playIcon" srcEdge="CENTERH" dst="preview" dstEdge="CENTERH" />
+    <meshitem src="playIcon" srcEdge="TOP" dst="subject" dstEdge="BOTTOM"/>
+    <meshitem src="playIcon" srcEdge="LEFT" dst="preview" dstEdge="RIGHT" />
 
   </layout>
 
@@ -43,9 +43,8 @@
     <meshitem src="preview" srcEdge="TOP" dst="" dstEdge="TOP" />
     <meshitem src="preview" srcEdge="LEFT" dst="" dstEdge="LEFT" />
 
-    <meshitem src="subject" srcEdge="TOP" dst="" dstEdge="TOP" />
-    <meshitem src="subject" srcEdge="BOTTOM" dst="bodyText" dstEdge="TOP" />
-    <meshitem src="subject" srcEdge="LEFT" dst="preview" dstEdge="RIGHT" />
+    <meshitem src="subject" srcEdge="TOP" dst="" dstEdge="TOP" />    
+    <meshitem src="subject" srcEdge="LEFT" dst="playIcon" dstEdge="RIGHT" />
     <meshitem src="subject" srcEdge="RIGHT" dst="priority" dstEdge="LEFT" />
 
     <meshitem src="priority" srcEdge="RIGHT" dst="attachment" dstEdge="LEFT" />
@@ -54,11 +53,12 @@
     <meshitem src="attachment" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     <meshitem src="attachment" srcEdge="CENTERV" dst="subject" dstEdge="CENTERV" />
 
-    <meshitem src="bodyText" srcEdge="LEFT" dst="preview" dstEdge="RIGHT" />
+    <meshitem src="bodyText" srcEdge="TOP" dst="subject" dstEdge="BOTTOM" />
+    <meshitem src="bodyText" srcEdge="LEFT" dst="playIcon" dstEdge="RIGHT" />
     <meshitem src="bodyText" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
-    <meshitem src="bodyText" srcEdge="BOTTOM" dst="timeStamp" dstEdge="TOP" />
-
-    <meshitem src="timeStamp" srcEdge="LEFT" dst="preview" dstEdge="RIGHT" />
+ 
+    <meshitem src="timeStamp" srcEdge="TOP" dst="bodyText" dstEdge="BOTTOM" />
+    <meshitem src="timeStamp" srcEdge="LEFT" dst="playIcon" dstEdge="RIGHT" />
     <meshitem src="timeStamp" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     <meshitem src="timeStamp" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM"/>
 
@@ -71,8 +71,8 @@
     <meshitem src="bubble" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="bubble" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
 
-    <meshitem src="playIcon" srcEdge="CENTERV" dst="preview" dstEdge="CENTERV" />
-    <meshitem src="playIcon" srcEdge="CENTERH" dst="preview" dstEdge="CENTERH" />
+    <meshitem src="playIcon" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="playIcon" srcEdge="LEFT" dst="preview" dstEdge="RIGHT" />
 
   </layout>
 
--- a/messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -51,7 +51,7 @@
 
 // LOCALIZATION CONSTANTS
 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
-#define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info")
+#define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
 
@@ -146,7 +146,13 @@
     QModelIndex index = msgModel->index(rowCnt-1, 0);
     ConvergedMessageAddress* address = new ConvergedMessageAddress(
         index.data(ConversationAddress).toString());
-    address->setAlias(mAddress);
+    QString displayname;
+    QString addr;
+    ConversationsEngine::instance()->getContactDetails(
+            ConversationsEngine::instance()->getCurrentConversationId(),
+            displayname,
+            addr);
+    address->setAlias(displayname);
     addresses.append(address);
     return addresses;
 }
@@ -237,7 +243,7 @@
             if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) {
                 // Handle longtap.
                 setPressed(false);
-                handleLongPress(tapGesture->scenePosition());
+                handleLongTap(tapGesture->scenePosition());
             }
             break;
         }
@@ -247,7 +253,7 @@
             if (HbTapGesture::Tap == tapGesture->tapStyleHint()) {
                 // Handle short tap.
                 setPressed(false);
-                openContactInfo();
+                handleShortTap(tapGesture->scenePosition());
             }
             break;
         }
@@ -282,10 +288,10 @@
 }
 
 //---------------------------------------------------------------
-// MsgContactCardWidget::handleLongPress
+// MsgContactCardWidget::handleLongTap
 // @see header file
 //---------------------------------------------------------------
-void MsgContactCardWidget::handleLongPress(const QPointF &position)
+void MsgContactCardWidget::handleLongTap(const QPointF &position)
 {
     // Check if events need to be ignored/accepted
     if (mIgnoreEvents) {
@@ -296,34 +302,57 @@
         HbMenu* contextMenu = new HbMenu();
         contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
         contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
-        contextMenu->setPreferredPos(position);
-
-        contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
-        contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
+        contextMenu->setPreferredPos(position);   
 
         //If contact doesn't exist in phonebook then add another menu item "Save to Contacts"
         int contactId = resolveContactId(mContactNumber);
         if (contactId < 0) {
             contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts()));
         }
+        else{
+            contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
+        }
+        contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
 
         contextMenu->show();
     }
 }
 
 //---------------------------------------------------------------
+// MsgContactCardWidget::handleShortTap
+// @see header
+//---------------------------------------------------------------
+void MsgContactCardWidget::handleShortTap(const QPointF &position)
+{
+    this->ungrabGesture(Qt::TapGesture);
+    
+    // Check if events need to be ignored/accepted
+    if (mIgnoreEvents) {
+        return;
+    }
+    
+    int contactId = resolveContactId(mContactNumber);
+    if(contactId > 0)
+    {
+        //resolved contact open contact card.
+        openContactInfo();
+    }
+    else
+    {
+        //unresolved contact show longpress options menu.
+        handleLongTap(position);
+    }
+    
+    //fire timer to regrab gesture after some delay.
+    QTimer::singleShot(300,this,SLOT(regrabGesture()));    
+}
+
+//---------------------------------------------------------------
 // MsgContactCardWidget::openContactInfo
 // @see header
 //---------------------------------------------------------------
 void MsgContactCardWidget::openContactInfo()
 {
-    this->ungrabGesture(Qt::TapGesture);
-    
-    // Check if events need to be ignored/accepted
-    if (mIgnoreEvents) {
-        return;
-    }
-
     QString operation;
     QList<QVariant> args;
     if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
@@ -356,13 +385,13 @@
         connect(request, SIGNAL(requestError(const QVariant&)), this,
             SLOT(handleError(const QVariant&)));
 
+        //disbale subscritption for the CV events
+        ConversationsEngine::instance()->disableRegisterationForCVEvents();
+                
         request->setArguments(args);
         request->send();
         delete request;
     }
-    
-    //fire timer to regrab gesture after some delay.
-    QTimer::singleShot(300,this,SLOT(regrabGesture()));
 }
 
 //---------------------------------------------------------------
@@ -404,6 +433,7 @@
 //---------------------------------------------------------------
 void MsgContactCardWidget::addToContacts()
 {
+    openContactInfo();
 }
 
 //---------------------------------------------------------------
@@ -424,7 +454,16 @@
         if (!avatarDetails.isEmpty()) {
             mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString());
         }
-    }
+	}
+	
+	// Get the new conversation id.
+    qint64 convId = ConversationsEngine::instance()->getConversationIdFromAddress(
+                mContactNumber);
+    emit conversationIdChanged(convId);
+            
+    ConversationsEngine::instance(
+                    )->emitOpenConversationViewIdUpdate(convId);
+    
 }
 
 //---------------------------------------------------------------
@@ -434,7 +473,14 @@
 void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage)
 {
     Q_UNUSED(errorMessage)
-    Q_UNUSED(errorCode)
+    Q_UNUSED(errorCode)    
+    
+    //unblock the cv events in case of contacts save error
+    ConversationsEngine::instance(
+                        )->emitOpenConversationViewIdUpdate(
+                                ConversationsEngine::instance(
+                                        )->getCurrentConversationId(
+                                                ));
 }
 
 //---------------------------------------------------------------
--- a/messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -43,6 +43,7 @@
 QTM_USE_NAMESPACE
 
 const int INVALID_MSGID = -1;
+const int INVALID_CONVID = -1;
 
 // LOCALIZATION
 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
@@ -102,6 +103,8 @@
     mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN);
 
     mMainLayout->addItem(mContactCard);
+    connect(mContactCard, SIGNAL(conversationIdChanged(qint64)), this,
+        SLOT(handleConversationIdChange(qint64)));
 
     /**
      * Create conversation view and connect to proper signals.
@@ -224,7 +227,21 @@
 //---------------------------------------------------------------	
 void MsgConversationBaseView::handleViewReady()
 {
-    ConversationsEngine::instance()->fetchMoreConversations();
+    mConversationView->onViewReady();
+}
+
+//---------------------------------------------------------------
+// MsgConversationBaseView::handleConversationIdChange
+//
+//---------------------------------------------------------------
+void MsgConversationBaseView::handleConversationIdChange(qint64 convId)
+{
+    if (INVALID_CONVID != convId && mConversationId != convId) {
+	
+        mConversationId = convId;        
+        // publsih conversation id
+        mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId);       
+    }
 }
 
 //---------------------------------------------------------------
--- a/messagingapp/msgui/conversationview/src/msgconversationview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgconversationview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -67,9 +67,6 @@
 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
 #define LOC_COMMON_SEND  hbTrId("txt_common_button_send") 
 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
-#define LOC_BUTTON_OK hbTrId("txt_common_button_ok")
 
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
@@ -85,7 +82,7 @@
 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dialog_message_sending_failed")
 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
-#define LOC_CONTACT_SAVED hbTrId("txt_messaging_dpopinfo_contact_saved")
+
 
 const int INVALID_MSGID = -1;
 const int INVALID_CONVID = -1;
@@ -105,15 +102,26 @@
     mContactCardWidget(contactCardWidget),
     mSendUtil(NULL),
     mVkbHost(NULL),
+    mVisibleIndex(),
     mVkbopened(false),
-    mVisibleIndex()
+    mModelPopulated(false),
+    mViewReady(false)
 {
-    connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(onViewReady()));
     //create send utils
     mSendUtil = new MsgSendUtil(this);
     //initialize view
     setupView();
     setupMenu();
+    
+    connect(ConversationsEngine::instance(), 
+                     SIGNAL(conversationModelUpdated()),
+                     this, 
+                     SLOT(scrollToBottom()));
+
+    connect(ConversationsEngine::instance(), 
+                         SIGNAL(conversationViewEmpty()),
+                         this, 
+                         SLOT(onConversationViewEmpty()));
 }
 
 //---------------------------------------------------------------
@@ -209,6 +217,18 @@
 }
 
 //---------------------------------------------------------------
+// MsgConversationView::fetchMoreConversations
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::fetchMoreConversations()
+{
+    if (mViewReady && mModelPopulated) {
+        ConversationsEngine::instance()->fetchMoreConversations();
+        mViewReady = mModelPopulated = false;
+    }
+}
+
+//---------------------------------------------------------------
 // MsgConversationView::refreshView()
 // @see header file
 //---------------------------------------------------------------
@@ -242,6 +262,14 @@
             mMessageModel->index(rowCnt - 1, 0));
 }
 
+void MsgConversationView::onConversationViewEmpty()
+{
+    QVariantList param;
+    param << MsgBaseView::CLV; // target view
+    param << MsgBaseView::CV; // source view
+    emit switchView(param);
+}
+
 //---------------------------------------------------------------
 // MsgConversationView::longPressed
 // @see header file
@@ -334,8 +362,6 @@
         return;
         }
     if( (sendingState == ConvergedMessage::SentState ) ||
-        (sendingState == ConvergedMessage::Resend ) ||
-        (sendingState == ConvergedMessage::Failed ) ||
         (direction == ConvergedMessage::Incoming))
     {
         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
@@ -478,7 +504,9 @@
     deactivateInputBlocker();
     if( sendResult == KErrNotFound)
     {
-    HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, SLOT(onDialogSettingsLaunch(HbAction*)), LOC_BUTTON_OK, LOC_BUTTON_CANCEL);
+    HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this,
+                           SLOT(onDialogSettingsLaunch(HbAction*)), 
+                           HbMessageBox::Ok | HbMessageBox::Cancel);
     }
 }
 
@@ -586,8 +614,22 @@
 {
     // Launch Audio fetcher view
     QVariantList params;
+    QByteArray dataArray;
+    QDataStream messageStream
+    (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
+
+    ConvergedMessage message;
+    message.setBodyText(mEditorWidget->content());
+    // add address from contact-card to to-field
+    ConvergedMessageAddress address;
+    address.setAlias(mContactCardWidget->address().at(0)->alias());
+    address.setAddress(mContactCardWidget->address().at(0)->address());
+    message.addToRecipient(address);
+    message.serialize(messageStream);
+
     params << MsgBaseView::AUDIOFETCHER; // target view
     params << MsgBaseView::CV; // source view
+    params << dataArray;
     emit switchView(params);
 }
 
@@ -711,8 +753,7 @@
 void MsgConversationView::deleteItem()
     {
     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
-                             LOC_BUTTON_DELETE,
-                             LOC_BUTTON_CANCEL);
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 //---------------------------------------------------------------
@@ -788,11 +829,11 @@
     qint32 messageId = index.data(ConvergedMsgId).toLongLong();
 
     QList<QVariant> args;
-    QString serviceName("com.nokia.services.btmsgdispservices.displaymsg");
+    QString serviceName("com.nokia.services.btmsgdispservices");
     QString operation("displaymsg(int)");
     XQAiwRequest* request;
     XQApplicationManager appManager;
-    request = appManager.create(serviceName, "displaymsg", operation, true); // embedded
+    request = appManager.create(serviceName, "displaymsg", operation, false); // embedded
     
     if ( request == NULL )
         {
@@ -800,6 +841,7 @@
         }
 
     args << QVariant(messageId);
+    request->setSynchronous(true);
     
     request->setArguments(args);
     request->send();
@@ -859,7 +901,8 @@
         if (ConvergedMessage::RingingTone == messageSubType)
         {
             HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
-                    SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL);
+                                   SLOT(onDialogSaveTone(HbAction*)), 
+                                   HbMessageBox::Save | HbMessageBox::Cancel);
             return;
         }
         else if(ConvergedMessage::Provisioning == messageSubType)
@@ -881,7 +924,7 @@
             bool result = MsgContactsUtil::launchVCardViewer(filepath);
             if(result)
             {
-                HbNotificationDialog::launchDialog(LOC_CONTACT_SAVED);
+                
                 int messageId = index.data(ConvergedMsgId).toInt();
                 QList<int> msgIdList;
                 if(index.data(UnReadStatus).toInt())
@@ -901,6 +944,13 @@
     else if (ConvergedMessage::BT == messageType)
     {
         launchBtDisplayService(index);
+        QList<int> msgIdList;
+        if(index.data(UnReadStatus).toInt())
+            {
+            msgIdList.clear();
+            msgIdList << messageId;
+            ConversationsEngine::instance()->markMessagesRead(msgIdList);
+            }
         return;
     }
     else if(ConvergedMessage::MmsNotification == messageType)
@@ -918,9 +968,9 @@
         else
         {
             //TODO: use logical str name
-            HbMessageBox::question("Download Message?",this,SLOT(onDialogDownLoadMsg(HbAction*)),
-                LOC_COMMON_DOWNLOAD,
-                LOC_BUTTON_CANCEL);
+            HbMessageBox::question("Download Message?",this,
+                                   SLOT(onDialogDownLoadMsg(HbAction*)),
+                                   HbMessageBox::Yes | HbMessageBox::Cancel);
             return;
         }
     }
@@ -937,33 +987,15 @@
     int location = index.data(MessageLocation).toInt();
     int sendingState = index.data(SendingState).toInt();
     
-    //If message is in Sending state or is Scheduled to be sent later,
+    //If message is in any other state other than 'Sent'
     //do not open the message
-    if(sendingState == ConvergedMessage::Suspended ||
-            sendingState == ConvergedMessage::Scheduled ||
-            sendingState == ConvergedMessage::Sending ||
-            sendingState == ConvergedMessage::Waiting)
+    if(direction == ConvergedMessage::Outgoing 
+            && sendingState != ConvergedMessage::SentState )
+           
     {
         return;
     }
 
-    //TODO: sendingState check should be removed once msg
-    // movement lock issue is resolved from mw
-    if( !((location == ConvergedMessage::Inbox) ||
-        (location == ConvergedMessage::Sent) ||
-        (sendingState == ConvergedMessage::SentState)||
-        (sendingState == ConvergedMessage::Failed) ||
-        (sendingState == ConvergedMessage::Resend)))
-    {// do not launch viewer, show a note
-        HbNotificationDialog* dlg = new HbNotificationDialog();
-        dlg->setFocusPolicy(Qt::NoFocus);
-        QString text(tr("Message Locked"));
-        dlg->setText(text);
-        dlg->setDismissPolicy(HbPopup::TapAnywhere);
-        dlg->setAttribute(Qt::WA_DeleteOnClose, true);
-        dlg->show();
-        return;
-	}
    
     
     // contact Id
@@ -1063,7 +1095,14 @@
             {
                 ConvergedMessageAddress* address = new ConvergedMessageAddress;
                 address->setAlias(contactList[i].mDisplayName);
-                address->setAddress(contactList[i].mPhoneNumber);
+                if(!contactList[i].mPhoneNumber.isEmpty())
+                {
+                    address->setAddress(contactList[i].mPhoneNumber);
+                }
+                else
+                {
+                    address->setAddress(contactList[i].mEmailAddress);
+                }
                 addresses.append(address);
             }
             message.addToRecipients(addresses);
@@ -1095,16 +1134,13 @@
 // @see header file
 //---------------------------------------------------------------
 void MsgConversationView::populateConversationsView()
-{
-    bool b = connect(ConversationsEngine::instance(), 
-                     SIGNAL(conversationModelUpdated()),
-                     this, 
-                     SLOT(scrollToBottom()));
-
+{    
+    mModelPopulated = true;
     mConversationList->setModel(mMessageModel);
     
     refreshView();
     scrollToBottom();
+    fetchMoreConversations();
 }
 
 //---------------------------------------------------------------
@@ -1359,8 +1395,11 @@
 //---------------------------------------------------------------
 void MsgConversationView::onViewReady()
 {
+    mViewReady = true;
     //Disconnect list View's signals, for avoiding execution of the default implementaion
     disconnect(mainWindow(), SIGNAL(aboutToChangeOrientation()), mConversationList, 0);
     disconnect(mainWindow(), SIGNAL(orientationChanged(Qt: rientation)), mConversationList, 0);
+    
+   fetchMoreConversations();
 }
 // EOF
--- a/messagingapp/msgui/conversationview/src/msgconversationviewitem.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgconversationviewitem.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -27,7 +27,7 @@
 #include <HbIconAnimationManager>
 #include <HbIconAnimator>
 #include <ccsdefs.h>
-#include <hbinstance>
+#include <HbInstance>
 
 // USER INCLUDES
 #include "msgconversationwidget.h"
@@ -43,8 +43,8 @@
 const QString ANIMATION_ICON_NAME("qtg_anim_loading");
 const QString VCARD_ICON("qtg_large_mycard");
 const QString IMAGE_ICON("qtg_small_image");
-const QString CORRUPTED_ICON("qtg_large_corrupted");
-const QString MSG_VIDEO_ICON("qtg_large_video_player");
+const QString CORRUPTED_ICON("qtg_small_corrupted");
+const QString MSG_VIDEO_ICON("qtg_small_video");
 
 // LOCALIZATION
 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone")
@@ -296,7 +296,6 @@
             HbIcon previewIcon;
             if (msgProperty & EPreviewProtectedImage)
               {
-                // TODO: Change to official icon.
                 previewIcon = HbIcon(IMAGE_ICON);
               }
             else if (msgProperty & EPreviewCorruptedImage)
@@ -316,21 +315,32 @@
         if (hasVideo)
           {
             mConversation->setVideo(true);
+            HbIcon videoPreviewIcon;
+            if (msgProperty & EPreviewProtectedVideo)
+              {
+                videoPreviewIcon = HbIcon(MSG_VIDEO_ICON);
+              }
+            else if (msgProperty & EPreviewCorruptedVideo)
+              {
+                videoPreviewIcon = HbIcon(CORRUPTED_ICON);
+              }
+            else
+              {
+                videoPreviewIcon = HbIcon(MSG_VIDEO_ICON);
+              }
+            mConversation->setPreviewIcon(videoPreviewIcon);
           }
-
-        bool hasAudio = (msgProperty & EPreviewAudio) ? true : false;
+        bool hasAudio = (msgProperty & EPreviewAudio) ? true : false;              
         if (hasAudio)
           {
             mConversation->setAudio(true);
-            // Protected content is also set as corrupted hence first check protected.
             if (msgProperty & EPreviewProtectedAudio)
               {
                 mConversation->displayAudioIcon();
               }
             else if (msgProperty & EPreviewCorruptedAudio)
               {
-                // TODO: Change to official icon.
-                mConversation->displayAudioIcon(CORRUPTED_ICON);
+				mConversation->displayAudioIcon(CORRUPTED_ICON);
               }
             else
               {
--- a/messagingapp/msgui/conversationview/src/msgconversationwidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgconversationwidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -33,7 +33,7 @@
 #include <QCoreApplication>
 #include <HbEvent>
 #include <HbMainWindow>
-#include <hbinstance>
+#include <HbInstance>
 
 #include "debugtraces.h"
 
@@ -44,8 +44,7 @@
 const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high");
 const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low");
 const QString MSG_ATTACH_ICON("qtg_small_attachment");
-const QString MSG_AUDIO_ICON("qtg_large_music_player");
-const QString MSG_AUDIO_PLAY_ICON("qtg_large_music_player");
+const QString MSG_AUDIO_PLAY_ICON("qtg_small_sound");
 
 
 // Frames
@@ -123,7 +122,6 @@
     mBodyTextItem->setTextWrapping(Hb::TextWordWrap);
     HbStyle::setItemName(mBodyTextItem, "bodyText");
     mPreviewIconItem = new HbIconItem(this);
-    mPreviewIconItem->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
     HbStyle::setItemName(mPreviewIconItem, "preview");
     mPriorityIconItem = new HbIconItem(this);            
     HbStyle::setItemName(mPriorityIconItem, "priority");
@@ -289,7 +287,7 @@
             if(iconPath.isEmpty())
             {
                qreal iconSize = 0;
-               style()->parameter("hb-param-graphic-size-primary-large",iconSize);
+               style()->parameter("hb-param-graphic-size-primary-small",iconSize);
                HbIcon icon(MSG_AUDIO_PLAY_ICON);
                icon.setHeight(iconSize);
                icon.setWidth(iconSize);
@@ -565,15 +563,7 @@
     }
     else
     {
-        if(mSendingState == Sending || mSendingState == Pending || 
-           mSendingState == Unknown || mSendingState == Failed)
-        {
-            mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_HIGHLIGHT_FR);
-        }
-        else
-        {
             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_NORMAL_FR);
-        }
     }
 }
 
--- a/messagingapp/msgui/conversationview/src/msgeditorwidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgeditorwidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -46,8 +46,6 @@
 const QString SEND_BUTTON_DISABLED("qtg_fr_input_btn_function_disabled");
 
 #define LOC_SMS_CHAR_LIMIT_REACHED hbTrId("txt_messaging_dialog_sms_character_count_exceeded")
-#define LOC_DIALOG_OK hbTrId("txt_common_button_ok")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here")
 
   
@@ -255,9 +253,8 @@
     mSmsCharLimitReached = false;
     
     HbMessageBox::question(LOC_SMS_CHAR_LIMIT_REACHED,
-        this,SLOT(onSmsCharLimitReached(HbAction*)),
-        LOC_DIALOG_OK,
-        LOC_BUTTON_CANCEL);
+                           this,SLOT(onSmsCharLimitReached(HbAction*)),
+                           HbMessageBox::Ok | HbMessageBox::Cancel);
 
 
 }
@@ -360,7 +357,6 @@
 MsgEditor::MsgEditor(QGraphicsItem *parent)
 :HbLineEdit(parent)
     {
-     this->setSmileysEnabled(true);
      this->setPlaceholderText(LOC_HINT_TEXT);
     }
 
--- a/messagingapp/msgui/eabi/appengineu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/eabi/appengineu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -39,4 +39,9 @@
 	_ZNK19ConversationsEngine10metaObjectEv @ 38 NONAME
 	_ZTI19ConversationsEngine @ 39 NONAME
 	_ZTV19ConversationsEngine @ 40 NONAME
+	_ZN19ConversationsEngine28conversationListEntryDeletedEi @ 41 NONAME
+	_ZN19ConversationsEngine37emitConversationListModelEntryDeletedEi @ 42 NONAME
+	_ZN19ConversationsEngine21conversationViewEmptyEv @ 43 NONAME
+	_ZN19ConversationsEngine31disableRegisterationForCVEventsEv @ 44 NONAME
+	_ZN19ConversationsEngine32emitOpenConversationViewIdUpdateEi @ 45 NONAME
 
--- a/messagingapp/msgui/eabi/conversationviewu.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/eabi/conversationviewu.def	Tue Jul 06 14:12:40 2010 +0300
@@ -14,19 +14,20 @@
 	_ZN23MsgConversationBaseView21closeConversationViewEv @ 13 NONAME
 	_ZN23MsgConversationBaseView21doDelayedConstructionEv @ 14 NONAME
 	_ZN23MsgConversationBaseView22conversationViewClosedEv @ 15 NONAME
-	_ZN23MsgConversationBaseView8handleOkERK8QVariant @ 16 NONAME
-	_ZN23MsgConversationBaseView8initViewEv @ 17 NONAME
-	_ZN23MsgConversationBaseView9setPSCVIdEb @ 18 NONAME
-	_ZN23MsgConversationBaseViewC1EP13QGraphicsItem @ 19 NONAME
-	_ZN23MsgConversationBaseViewC2EP13QGraphicsItem @ 20 NONAME
-	_ZN23MsgConversationBaseViewD0Ev @ 21 NONAME
-	_ZN23MsgConversationBaseViewD1Ev @ 22 NONAME
-	_ZN23MsgConversationBaseViewD2Ev @ 23 NONAME
-	_ZNK23MsgConversationBaseView10metaObjectEv @ 24 NONAME
-	_ZTI23MsgConversationBaseView @ 25 NONAME
-	_ZTV23MsgConversationBaseView @ 26 NONAME
-	_ZThn16_N23MsgConversationBaseViewD0Ev @ 27 NONAME
-	_ZThn16_N23MsgConversationBaseViewD1Ev @ 28 NONAME
-	_ZThn8_N23MsgConversationBaseViewD0Ev @ 29 NONAME
-	_ZThn8_N23MsgConversationBaseViewD1Ev @ 30 NONAME
+	_ZN23MsgConversationBaseView26handleConversationIdChangeEx @ 16 NONAME
+	_ZN23MsgConversationBaseView8handleOkERK8QVariant @ 17 NONAME
+	_ZN23MsgConversationBaseView8initViewEv @ 18 NONAME
+	_ZN23MsgConversationBaseView9setPSCVIdEb @ 19 NONAME
+	_ZN23MsgConversationBaseViewC1EP13QGraphicsItem @ 20 NONAME
+	_ZN23MsgConversationBaseViewC2EP13QGraphicsItem @ 21 NONAME
+	_ZN23MsgConversationBaseViewD0Ev @ 22 NONAME
+	_ZN23MsgConversationBaseViewD1Ev @ 23 NONAME
+	_ZN23MsgConversationBaseViewD2Ev @ 24 NONAME
+	_ZNK23MsgConversationBaseView10metaObjectEv @ 25 NONAME
+	_ZTI23MsgConversationBaseView @ 26 NONAME
+	_ZTV23MsgConversationBaseView @ 27 NONAME
+	_ZThn16_N23MsgConversationBaseViewD0Ev @ 28 NONAME
+	_ZThn16_N23MsgConversationBaseViewD1Ev @ 29 NONAME
+	_ZThn8_N23MsgConversationBaseViewD0Ev @ 30 NONAME
+	_ZThn8_N23MsgConversationBaseViewD1Ev @ 31 NONAME
 
--- a/messagingapp/msgui/eabi/msgaudiofetcheru.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/eabi/msgaudiofetcheru.def	Tue Jul 06 14:12:40 2010 +0300
@@ -9,8 +9,8 @@
 	_ZN19MsgAudioFetcherView19removeToolBarActionEv @ 8 NONAME
 	_ZN19MsgAudioFetcherView23on_leftAction_triggeredEv @ 9 NONAME
 	_ZN19MsgAudioFetcherView24on_rightAction_triggeredEv @ 10 NONAME
-	_ZN19MsgAudioFetcherViewC1Ev @ 11 NONAME
-	_ZN19MsgAudioFetcherViewC2Ev @ 12 NONAME
+	_ZN19MsgAudioFetcherViewC1ERK5QListI8QVariantE @ 11 NONAME
+	_ZN19MsgAudioFetcherViewC2ERK5QListI8QVariantE @ 12 NONAME
 	_ZN19MsgAudioFetcherViewD0Ev @ 13 NONAME
 	_ZN19MsgAudioFetcherViewD1Ev @ 14 NONAME
 	_ZN19MsgAudioFetcherViewD2Ev @ 15 NONAME
--- a/messagingapp/msgui/eabi/unifiededitoru.def	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/eabi/unifiededitoru.def	Tue Jul 06 14:12:40 2010 +0300
@@ -23,8 +23,8 @@
 	_ZN20MsgUnifiedEditorView14addAttachmentsE11QStringList @ 22 NONAME
 	_ZN20MsgUnifiedEditorView14changePriorityEv @ 23 NONAME
 	_ZN20MsgUnifiedEditorView14forwardMessageER18ConvergedMessageIdN16ConvergedMessage11MessageTypeE @ 24 NONAME
-	_ZN20MsgUnifiedEditorView14sendingOptionsEv @ 25 NONAME
-	_ZN20MsgUnifiedEditorView15contactsFetchedERK8QVariant @ 26 NONAME
+	_ZN20MsgUnifiedEditorView15contactsFetchedERK8QVariant @ 25 NONAME
+	_ZN20MsgUnifiedEditorView15formatAddressesER5QListIP23ConvergedMessageAddressE @ 26 NONAME
 	_ZN20MsgUnifiedEditorView15populateContentERK5QListI8QVariantE @ 27 NONAME
 	_ZN20MsgUnifiedEditorView16createTempFolderEv @ 28 NONAME
 	_ZN20MsgUnifiedEditorView16enableSendButtonEb @ 29 NONAME
--- a/messagingapp/msgui/inc/msgbaseview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/inc/msgbaseview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -70,6 +70,10 @@
      */
     void switchView(const QVariantList& data);
     
+    /**
+     * Forceful close of conversation view
+     */
+    void closeOpenConversationView();
 
 };
 
--- a/messagingapp/msgui/msgapp/inc/msglistview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/inc/msglistview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -117,6 +117,13 @@
      */
     void onDialogDeleteMsg(HbAction* action);
     
+	/**
+	 * This slot is called when appengine emits the partialdeleteconversationlist event.
+	 * This performs grab of the HbAbstractviewitem on which delete was called.
+	 * @param conversation id of the item.
+	 */
+    void enableListitem( int conversationId );
+	    
 private:
 
     /**
--- a/messagingapp/msgui/msgapp/msgapp.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/msgapp.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -17,8 +17,6 @@
 TEMPLATE = app
 TARGET = messaging101
 
-ICON = resources/icons/qtg_large_message.svg
-
 DEPENDPATH += . inc src ../inc
 INCLUDEPATH += .
 INCLUDEPATH += ../inc
@@ -29,17 +27,21 @@
 INCLUDEPATH += ../conversationview/inc
 INCLUDEPATH += ../unifiedviewer/inc
 INCLUDEPATH += ../../msgsettings/settingsview/inc
+INCLUDEPATH += ../../smartmessaging/ringbc/inc
+
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-INCLUDEPATH += /ext/mw/qtextensions/qtmobileextensions/include
-INCLUDEPATH += ../../smartmessaging/ringbc/inc
 
 CONFIG += hb service
 
 QT += sql
 
-TARGET.UID3 = 0x2001FE79
-TARGET.CAPABILITY = All -TCB
-TARGET.EPOCHEAPSIZE = 0x20000 0x1000000
+symbian {
+   TARGET.UID3 = 0x2001FE79
+   TARGET.CAPABILITY = All -TCB
+   TARGET.EPOCSTACKSIZE = 0x14000
+   TARGET.EPOCHEAPSIZE = 0x20000 0x1000000
+   SKINICON = qtg_large_message
+}
   
 # Platforms
 SYMBIAN_PLATFORMS = WINSCW ARMV5
--- a/messagingapp/msgui/msgapp/resources/icons/qtg_large_message.svg	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg baseProfile="tiny" height="98" viewBox="0 0 98 98" width="98" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-<g>
-<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_1_" x1="48.9995" x2="48.9995" y1="23.8706" y2="73.753">
-<stop offset="0" style="stop-color:#FEEFA7"/>
-<stop offset="0.5091" style="stop-color:#FFC501"/>
-<stop offset="1" style="stop-color:#F6A800"/>
-</linearGradient>
-<polygon fill="url(#SVGID_1_)" points="84,74.5 14,74.5 14,23.5 49.579,24.5 84,23.5 "/>
-<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_2_" x1="48.9995" x2="48.9995" y1="23.627" y2="74.8003">
-<stop offset="0" style="stop-color:#F7AC00"/>
-<stop offset="0.3394" style="stop-color:#FFF8DB"/>
-<stop offset="1" style="stop-color:#FFE066"/>
-</linearGradient>
-<path d="M83.23,24.275v49.449H14.77V24.275H83.23 M84,23.5l-35.249,0.42L14,23.5v51h70V23.5L84,23.5z" fill="url(#SVGID_2_)"/>
-<polygon fill="#FBAB13" fill-opacity="0.3" points="14,73.637 84,73.637 84,72.645 48.999,41.91 14,72.645 " stroke-opacity="0.3"/>
-<polygon fill="#F18800" fill-opacity="0.3" points="14,74.5 84,74.5 84,73.504 48.999,42.773 14,73.504 " stroke-opacity="0.3"/>
-<linearGradient gradientTransform="matrix(-1 0 0 -1 -1118.3896 -657.6523)" gradientUnits="userSpaceOnUse" id="SVGID_3_" x1="-1167.3896" x2="-1167.3896" y1="-701.0981" y2="-731.9614">
-<stop offset="0" style="stop-color:#F98A00"/>
-<stop offset="0.7273" style="stop-color:#FCBC3C"/>
-<stop offset="1" style="stop-color:#FFE36A"/>
-</linearGradient>
-<polygon fill="url(#SVGID_3_)" points="84,74.475 48.999,43.611 14,74.475 "/>
-<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_4_" x1="48.9995" x2="48.9995" y1="43.374" y2="75.3424">
-<stop offset="0" style="stop-color:#FFF1B5"/>
-<stop offset="1" style="stop-color:#FFE066"/>
-</linearGradient>
-<polygon fill="url(#SVGID_4_)" points="84,74.475 48.999,43.611 14,74.475 48.999,44.705 "/>
-<polygon fill="#F18800" fill-opacity="0.3" points="49.07,24.5 14,23.5 48.999,59.771 84,23.5 " stroke-opacity="0.3"/>
-<polygon fill="#C26D00" fill-opacity="0.4" points="49.007,24.5 14,23.5 48.999,57.863 84,23.5 " stroke-opacity="0.4"/>
-<polygon fill="#AB6100" fill-opacity="0.4" points="48.879,24.371 14,23.5 48.999,56.252 84,23.5 " stroke-opacity="0.4"/>
-<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_5_" x1="49.0005" x2="49.0005" y1="52.7031" y2="21.5113">
-<stop offset="0" style="stop-color:#FFDA33"/>
-<stop offset="0.25" style="stop-color:#FFE692"/>
-<stop offset="1" style="stop-color:#FFFBF8"/>
-</linearGradient>
-<polygon fill="url(#SVGID_5_)" points="14,23.5 48.999,54.363 84,23.5 "/>
-<rect fill="none" height="98" width="98"/>
-</g>
-</svg>
--- a/messagingapp/msgui/msgapp/src/draftslistview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/draftslistview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -66,8 +66,6 @@
 // Confirmation note
 #define LOC_DELETE_MESSAGE        hbTrId("txt_messaging_dialog_delete_message")
 #define LOC_DELETE_ALL_DRAFTS     hbTrId("txt_messaging_dialog_delate_all_drafts")
-#define LOC_BUTTON_DELETE         hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL         hbTrId("txt_common_button_cancel")
 
 //---------------------------------------------------------------
 // DraftsListView::DraftsListView
@@ -122,6 +120,7 @@
         viewAction->setIcon(HbIcon(SORT_ICON));
 
         mViewExtnList = new HbListWidget();
+        mViewExtnList->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
         mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS);
         mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS);
 
@@ -230,8 +229,8 @@
     }
 
     HbMessageBox::question(LOC_DELETE_MESSAGE,
-        this,SLOT(onDialogDeleteMsg(HbAction*)),
-        LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
+                           this,SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 
 }
 
@@ -242,9 +241,8 @@
 void DraftsListView::deleteAllDraftMessage()
 {
     HbMessageBox::question(LOC_DELETE_ALL_DRAFTS,
-        this,SLOT(onDialogDeleteAllMessages(HbAction*)),
-        LOC_BUTTON_DELETE,
-        LOC_BUTTON_CANCEL);
+                           this,SLOT(onDialogDeleteAllMessages(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 //------------------------------------------------------------------------------
--- a/messagingapp/msgui/msgapp/src/main.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/main.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -102,12 +102,11 @@
     QString locale = QLocale::system().name();
     QString path = "z:/resource/qt/translations/";
     QTranslator translator;
-    //QTranslator translator_comm;
-    //translator.load(path + QString("messaging_") + locale);
-    //translator_comm.load(path + QString("common_") + locale);
-    translator.load( "messaging_en_GB", ":/translations" );
+    QTranslator translator_comm;
+    translator.load(path + QString("messaging_") + locale);
+    translator_comm.load(path + QString("common_") + locale);
     app.installTranslator(&translator);
-    //app.installTranslator(&translator_comm);
+    app.installTranslator(&translator_comm);
 
     app.setApplicationName(LOC_TITLE);
     
--- a/messagingapp/msgui/msgapp/src/msglistview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/msglistview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -60,10 +60,7 @@
 #define LOC_OPEN hbTrId("txt_common_menu_open")
 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
 #define LOC_DELETE_CONVERSATION hbTrId("txt_messaging_menu_delete_conversation")
-#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info")
-
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
+#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
 
 //main menu
 #define LOC_SETTINGS    hbTrId("txt_messaging_opt_settings")
@@ -81,27 +78,28 @@
 //---------------------------------------------------------------
 MsgListView::MsgListView(QGraphicsItem *parent) :
     MsgBaseView(parent)
-{
+    {
     //These changes are needed for splash implementation to avoid flicker
-    setupToolBar();    
+    setupToolBar();
     setupMenu();
 
     // Create parent layout.
     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
     mMainLayout->setContentsMargins(0, 0, 0, 0);
     mMainLayout->setSpacing(0);
-    
+
     // Create view heading.
     HbGroupBox *viewHeading = new HbGroupBox();
     viewHeading->setHeading(LOC_VIEW_HEADING);
-    
+
     // Add view heading widget to main layout.
     mMainLayout->addItem(viewHeading);
 
     this->setLayout(mMainLayout);
 
-    connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
-}
+    connect(this->mainWindow(), SIGNAL(viewReady()), this,
+            SLOT(doDelayedConstruction()));
+    }
 
 //---------------------------------------------------------------
 // MsgListView::~MsgListView
@@ -230,8 +228,8 @@
 #endif
     //confirmation dialog.
     HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION,
-                                this,SLOT(onDialogDeleteMsg(HbAction*)),
-                                LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);    
+                           this,SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);    
 #ifdef _DEBUG_TRACES_	
     qDebug() << " Leaving MsgConversationView::deleteItem";
 #endif
@@ -242,7 +240,7 @@
 // @see header
 //---------------------------------------------------------------
 void MsgListView::setupListView()
-{
+    {
     // Register the custorm css path.
     HbStyleLoader::registerFilePath(":/clv");
 
@@ -252,34 +250,29 @@
 
     mMsgList->setLayoutName("custom");
     mMsgList->setItemRecycling(true);
-    mMsgList->setUniformItemSizes(true);   
+    mMsgList->setUniformItemSizes(true);
 
     MsgListViewItem *prototype = new MsgListViewItem(this);
     mMsgList->setItemPrototype(prototype);
-
-    // Set proxy model
-    QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this);
-    proxyModel->setDynamicSortFilter(true);
-    proxyModel->setSourceModel(ConversationsEngine::instance()->getConversationsSummaryModel());
-    proxyModel->setSortRole(TimeStamp);
-    proxyModel->sort(0, Qt::DescendingOrder);
-
-    mMsgList->setModel(proxyModel);
-
-    connect(ConversationsEngine::instance(), SIGNAL(conversationListModelPopulated()),
-            this, SLOT(populateListView()));
-
+    mMsgList->setModel(ConversationsEngine::instance()->getConversationsSummaryModel());
+    
     // Single tap list item
-    connect(mMsgList, SIGNAL(activated(const QModelIndex&)),
-            this, SLOT(openConversation(const QModelIndex&)));
+    connect(mMsgList, SIGNAL(activated(const QModelIndex&)), this,
+            SLOT(openConversation(const QModelIndex&)));
 
     // Long tap list item
-    connect(mMsgList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)),
-            this, SLOT(longPressed(HbAbstractViewItem*, const QPointF&)));
+    connect(mMsgList,
+            SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), this,
+            SLOT(longPressed(HbAbstractViewItem*, const QPointF&)));
+
+    // enable tap after delete is completed
+    connect(ConversationsEngine::instance(),
+            SIGNAL(conversationListEntryDeleted( int )), this,
+            SLOT(enableListitem( int )));
 
     // Add list view to main layout.
     mMainLayout->addItem(mMsgList);
-}
+    }
 
 //---------------------------------------------------------------
 // MsgListView::addMenu
@@ -308,6 +301,7 @@
     viewAction->setIcon(HbIcon(SORT_ICON));
 
     mViewExtnList = new HbListWidget();
+    mViewExtnList->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
     mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS);
     mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS);
 
@@ -422,17 +416,46 @@
 // @see header
 //---------------------------------------------------------------
 void MsgListView::onDialogDeleteMsg(HbAction* action)
-{
+    {
     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
-    if (action == dlg->actions().at(0)) {
-        QModelIndex index = mMsgList->currentIndex();
-        if(index.isValid())
+    if (action == dlg->actions().at(0))
         {
+        QModelIndex index = mMsgList->currentIndex();
+        if (index.isValid())
+            {
+            HbAbstractViewItem *item = mMsgList->currentViewItem();
+            item->ungrabGesture(Qt::TapGesture);
             qint64 conversationId = index.data(ConversationId).toLongLong();
-                    ConversationsEngine::instance()->deleteConversations(conversationId);    
+
+            ConversationsEngine::instance()->deleteConversations(
+                    conversationId);
+
+            }
+
         }
-        
     }
-}
+
+//---------------------------------------------------------------
+// MsgListView::enableListitem
+// @see header
+//---------------------------------------------------------------
+void MsgListView::enableListitem(int conversationId)
+    {
+    QAbstractItemModel* proxyModel = mMsgList->model();
+    QModelIndexList indexList = proxyModel->match(proxyModel->index(0, 0),
+            ConversationId, conversationId, 1, Qt::MatchExactly);
+    HbAbstractViewItem* item = NULL;
+    int count = indexList.count();
+	// only item is expected to be the result of the above match function
+    if (1 == count)
+        {
+        item = mMsgList->itemByIndex(indexList[0]);
+        if (item)
+            {
+            item->grabGesture(Qt::TapGesture);
+            }
+        }
+
+    }
 
 //EOF
--- a/messagingapp/msgui/msgapp/src/msglistviewitem.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/msglistviewitem.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -25,6 +25,8 @@
 #include <HbTextItem>
 #include <HbFrameItem>
 #include <HbIconItem>
+#include <QCoreApplication>
+#include <HbEvent>
 
 #include "msgcommondefines.h"
 #include "conversationsengine.h"
@@ -93,15 +95,7 @@
     {
         QString displayName = modelIndex().data(DisplayName).toString();
         QString contactAddress = modelIndex().data(ConversationAddress).toString();
-
-        if (displayName.isEmpty())
-        {
-            contactName.append(contactAddress);
-        }
-        else
-        {
-            contactName.append(displayName);
-        }        
+        contactName.append(displayName);
     }
     mAddressLabelItem->setText(contactName);
 
@@ -117,6 +111,8 @@
             mUnReadMsg = true;
             mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName(NEW_ITEM_FRAME);
             repolish();
+            // Needed for colour group changes to be visible
+            QCoreApplication::postEvent(this, new HbEvent(HbEvent::ThemeChanged));  
         }       
     }
     else
@@ -127,6 +123,8 @@
             mUnReadMsg = false;  
             mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName(QString());
             repolish();
+            // Needed for colour group changes to be visible
+            QCoreApplication::postEvent(this, new HbEvent(HbEvent::ThemeChanged));  
         }
     }
 
--- a/messagingapp/msgui/msgapp/src/msgviewmanager.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/msgviewmanager.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -44,11 +44,8 @@
 #include "msgaudiofetcherview.h"
 
 // LOCALIZATION
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
-#define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
 
 const qint64 NULL_CONVERSATIONID = -1;
 
@@ -114,6 +111,8 @@
 
     case MsgBaseView::CV:
     {
+	    mConversationId = -1; //reset the conversation view id since its closed
+		
         //Save content to drafts before switching to clv
         mConversationView->saveContentToDrafts();
 
@@ -198,9 +197,18 @@
         }
         else {
             QVariantList param;
-            param << MsgBaseView::CV;
-            param << MsgBaseView::UNIVIEWER;
-            param << mConversationId;
+            if (mConversationId != -1)
+                {
+                    //this means CV is till open then just open the fresh CV
+                    param << MsgBaseView::CV;
+                    param << MsgBaseView::UNIVIEWER;
+                    param << mConversationView->conversationId();
+                }
+                else
+                {
+                    param << MsgBaseView::CLV;
+                    param << MsgBaseView::UNIVIEWER;
+                }
             switchView(param);
 
         }
@@ -216,7 +224,7 @@
     }
     case MsgBaseView::AUDIOFETCHER:
     {
-        // switch to CV.
+        // switch back to previous view
         QVariantList param;
         param << mPreviousView;
         param << MsgBaseView::AUDIOFETCHER;
@@ -225,6 +233,7 @@
             param << mConversationId;
         }
         switchView(param);
+        break;
     }
     default:
     {
@@ -476,8 +485,6 @@
 
 void MsgViewManager::switchToClv(const QVariantList& data)
 {
-    //switch to CLV.
-    mCurrentView = MsgBaseView::CLV;
     mPreviousView = data.at(1).toInt();
 
     // delete case from viewer service
@@ -486,6 +493,21 @@
         HbApplication::quit();
     }
 
+    // this is the case when viewer/editor is opened and contacts update takes
+    // place resulting in CV close, the view should directly come to CLV 
+    // bypassing the CV
+    if ((mCurrentView == MsgBaseView::UNIVIEWER 
+            && mPreviousView != MsgBaseView::UNIVIEWER)
+            || (mCurrentView == MsgBaseView::UNIEDITOR
+                    && mPreviousView != MsgBaseView::UNIEDITOR))
+    {
+        //dont do anything
+        //wait for the back from viewer/editor
+        //and reset the open CV id
+        mConversationId = -1;
+        return;
+    }
+    
     //delete UniEditor
     if (mUniEditor)
     {
@@ -504,8 +526,12 @@
         mConversationView->saveContentToDrafts();
         //clearing content of cv.
         mConversationView->clearContent();
+        //reset the open CV id
+        mConversationId = -1;
     }
-
+    
+    //switch to CLV.
+    mCurrentView = MsgBaseView::CLV;
     if (!mListView) {
         mListView = new MsgListView();
         mListView->setNavigationAction(mBackAction);
@@ -639,7 +665,10 @@
     }
 
     mCurrentView = MsgBaseView::UNIEDITOR;
-    mPreviousView = data.at(1).toInt();
+    if(MsgBaseView::AUDIOFETCHER != data.at(1).toInt())
+    {
+        mPreviousView = data.at(1).toInt();
+    }
 
     // delete Audio Fetcher view
     if(mAudioFetcherView)
@@ -838,9 +867,9 @@
     default:
     {
         // for un supported message show delete option
-        HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
-            LOC_BUTTON_DELETE,
-            LOC_BUTTON_CANCEL);
+        HbMessageBox::question(LOC_DELETE_MESSAGE,this,
+                               SLOT(onDialogDeleteMsg(HbAction*)),
+                               HbMessageBox::Delete | HbMessageBox::Cancel);
         break;
     }
     }
@@ -876,7 +905,8 @@
 {
     mMessageId = msgId;
     HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
-        SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL);
+                           SLOT(onDialogSaveTone(HbAction*)), 
+                           HbMessageBox::Save | HbMessageBox::Cancel);
 }
 
 // ----------------------------------------------------------------------------
@@ -1020,8 +1050,7 @@
 void MsgViewManager::switchToAudioFetcher(const QVariantList& data)
     {
     /**
-     * Audio Fetcher is tried to open again before exiting
-     * opened editor.
+     * Audio Fetcher is tried to open again
      */
     if(mAudioFetcherView)
         {
@@ -1031,8 +1060,12 @@
     //switch to Audio Fetcher view
     mCurrentView = MsgBaseView::AUDIOFETCHER;
     mPreviousView = data.at(1).toInt();
-
-    mAudioFetcherView = new MsgAudioFetcherView();
+    QVariantList editorData;
+    // i=2 because view manager consumed first two args
+    for (int i = 2; i < data.length(); i++) {
+        editorData << data.at(i);
+    }
+    mAudioFetcherView = new MsgAudioFetcherView(editorData);
     mAudioFetcherView->setNavigationAction(mBackAction);
     connect(mAudioFetcherView, SIGNAL(switchView(const QVariantList&)), this,
             SLOT(switchView(const QVariantList&)));
@@ -1119,4 +1152,6 @@
                                                          count);
 
         return localId;
-    }
\ No newline at end of file
+    }
+
+//EOF
--- a/messagingapp/msgui/msgaudiofetcher/inc/msgaudiofetcherview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgaudiofetcher/inc/msgaudiofetcherview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -31,6 +31,7 @@
 
 // USER INCLUDES
 #include "msgbaseview.h"
+#include "convergedmessage.h"
 
 // FORWARD DECLARATIONS
 class MsgAudioFetcherWidget;
@@ -48,7 +49,7 @@
     /**
      * Constructor
      */
-    explicit MsgAudioFetcherView();
+    explicit MsgAudioFetcherView(const QVariantList& data);
 
     /**
      * Destructor
@@ -101,6 +102,12 @@
      * Toolbar's right action
      */
     HbAction *mToolBarRightAction;
+    
+    /**
+     * Converged Message object
+     * owned
+     */
+    ConvergedMessage* message;
 };
 
 #endif /* MSGAUDIOFETCHERVIEW_H */
--- a/messagingapp/msgui/msgaudiofetcher/src/msgaudiofetcherview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msgaudiofetcher/src/msgaudiofetcherview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -25,8 +25,16 @@
 #include "msgaudiofetcherwidget.h"
 #include "convergedmessage.h"
 
-MsgAudioFetcherView::MsgAudioFetcherView()
+MsgAudioFetcherView::MsgAudioFetcherView(const QVariantList& data) :
+message(NULL)
 {
+    message = new ConvergedMessage;
+    if(data.length() > 0)
+    {
+        QByteArray dataArray = data.at(0).toByteArray();
+        QDataStream stream(&dataArray, QIODevice::ReadOnly);
+        message->deserialize(stream);
+    }
     initToolBar();
     initMainWidget();
     QMetaObject::connectSlotsByName(this);
@@ -34,6 +42,11 @@
 
 MsgAudioFetcherView::~MsgAudioFetcherView()
 {
+    if(message != NULL)
+    {
+        delete message;
+        message = NULL;
+    }
     removeToolBarAction();
 }
 
@@ -84,15 +97,14 @@
     QDataStream messageStream
     (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
 
-    ConvergedMessage message;
     QString filepath(mWidget->getCurrentItemPath());
     ConvergedMessageAttachment* attachment =
             new ConvergedMessageAttachment(filepath);
     ConvergedMessageAttachmentList attachmentList;
     attachmentList.append(attachment);
-    message.addAttachments(attachmentList);
+    message->addAttachments(attachmentList);
     
-    message.serialize(messageStream);
+    message->serialize(messageStream);
     params << MsgBaseView::UNIEDITOR;
     params << MsgBaseView::AUDIOFETCHER;
     params << dataArray;
--- a/messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -135,7 +135,9 @@
                 }
                 else if (showNote)
                 {
-                    HbMessageBox::question(INSERT_QUERY_CONFRM, this, SLOT(onDialogInsertMedia(HbAction*)));
+                    HbMessageBox::question(INSERT_QUERY_CONFRM, this,
+                                           SLOT(onDialogInsertMedia(HbAction*)),
+                                           HbMessageBox::Yes | HbMessageBox::No);
                 }
                 else
                 {
@@ -181,10 +183,10 @@
     UniDataModelLoader* pluginLoader = new UniDataModelLoader();
     UniDataModelPluginInterface* pluginInterface =
             pluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
-    pluginInterface->setMessageId(messageId);
+    int error = pluginInterface->setMessageId(messageId);
 
-    //Check if slide count is greater than 1
-    if (pluginInterface->slideCount() > 1)
+    //Check if invalid id and slide count is greater than 1
+    if ( (error != KErrNone) || pluginInterface->slideCount() > 1)
     {
         delete pluginLoader;
         return false;
@@ -193,6 +195,7 @@
     //Check if message size is inside max mms composition limits
     if (pluginInterface->messageSize() > iMaxMmsSize)
     {
+        delete pluginLoader;
         return false;
     }
 
@@ -218,7 +221,6 @@
     if (!retValue)
     {
         delete pluginLoader;
-
         return false;
     }
 
@@ -240,7 +242,6 @@
         }
 
     delete pluginLoader;
-
     return retValue;
 }
 
--- a/messagingapp/msgui/unifiededitor/inc/msgunieditorbody.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/inc/msgunieditorbody.h	Tue Jul 06 14:12:40 2010 +0300
@@ -103,6 +103,13 @@
      */
     void EditorOperationEvent( TUniEditorProcessImageOperationEvent aEvent,
                                TFileName aFileName );
+    /**
+	 * Function which tells whether the image resize process is in progress
+	 */
+    bool isImageResizing()
+        {
+        return mIsImageResizing;
+        }
 
 public slots:
     /**
@@ -331,6 +338,12 @@
      * boolean specifying a draft message
      */
     bool mDraftMessage ;
+    
+    /*
+     * Flag to indicate the state of image resizing process. 
+	 * true - resize in progress. false - resize is not underway.
+     */
+    bool mIsImageResizing;
 };
 
 #endif //MSG_UNIFIED_EDITOR_BODY_H
--- a/messagingapp/msgui/unifiededitor/inc/msgunieditormonitor.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/inc/msgunieditormonitor.h	Tue Jul 06 14:12:40 2010 +0300
@@ -105,6 +105,13 @@
      */
     void handleContentChange();
 
+signals:
+    /**
+     * Emitted when composed message can be sent.
+     * @param enable true if send is possible else false.
+     */
+    void enableSend(bool enable);
+
 private:
     /**
      * setter method to initialize content
@@ -157,6 +164,11 @@
      */
     bool otherMMSCriteriaMet();
 
+    /**
+     * Checks if composed message can be sent and emits a signal.
+     */
+    void updateSend();
+
 private:
 
     /**
--- a/messagingapp/msgui/unifiededitor/inc/msgunieditorview.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/inc/msgunieditorview.h	Tue Jul 06 14:12:40 2010 +0300
@@ -184,6 +184,13 @@
     void setAttachOptionEnabled(MsgUnifiedEditorView::TBE_AttachOption opt,
             bool enable);
 
+    /**
+     * Addresses are all ok. Now parse not allowed chars away 
+	 * before giving it to MTM
+	 * @param addresses, list of ConvergedMessageAddress
+     */
+    void formatAddresses(ConvergedMessageAddressList& addresses);
+    
 private slots:
 
     /**
@@ -207,11 +214,6 @@
     void changePriority();
 
     /**
-     * slot for different sending options.
-     */
-    void sendingOptions();
-
-    /**
      * slot to current delete message.
      */
     void deleteMessage();
--- a/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -20,7 +20,6 @@
 #include <HbTextItem>
 #include <HbPushButton>
 #include <HbAction>
-#include <hbinputeditorinterface.h>
 #include <hbmessagebox.h>
 #include <cntservicescontact.h>
 #include <xqaiwrequest.h>
@@ -39,7 +38,6 @@
 #include "UniEditorGenUtils.h"
 
 const QString PBK_ICON("qtg_mono_contacts");
-const QString SEND_ICON("qtg_mono_send");
 const QString REPLACEMENT_STR("; ");
 const QString COMMA_SEPERATOR(",");
 
@@ -80,13 +78,8 @@
     connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
             this, SLOT(onContentsChanged(const QString&)));
 
-    // add "Send" action in VKB
-    HbEditorInterface editorInterface(mAddressEdit);
     mAddressEdit->setInputMethodHints(Qt::ImhPreferNumbers);
-    HbAction *sendAction = new HbAction(HbIcon(SEND_ICON), QString(),this);
-    connect(sendAction, SIGNAL(triggered()),this, SIGNAL(sendMessage()));
-    editorInterface.addAction(sendAction);
-    }
+}
 
 MsgUnifiedEditorAddress::~MsgUnifiedEditorAddress()
 {
@@ -98,7 +91,7 @@
 void MsgUnifiedEditorAddress::fetchContacts()
 {
     mLaunchBtn->blockSignals(true);
-    
+
     QList<QVariant> args;
     QString serviceName("com.nokia.services.phonebookservices");
     QString operation("fetch(QString,QString,QString)");
@@ -121,7 +114,7 @@
     request->setArguments(args);
     request->send();
     delete request;
-    
+
     //unblock click signal after some delay.
     QTimer::singleShot(250,this,SLOT(unblockSignals()));
 }
@@ -137,7 +130,14 @@
     {
         ConvergedMessageAddress* address =
                 new ConvergedMessageAddress();
-        address->setAddress(contactList[i].mPhoneNumber);
+        if(!contactList[i].mPhoneNumber.isEmpty())
+        {
+            address->setAddress(contactList[i].mPhoneNumber);
+        }
+        else
+        {
+            address->setAddress(contactList[i].mEmailAddress);
+        }
         address->setAlias(contactList[i].mDisplayName);
         addrlist << address;
     }
@@ -202,6 +202,12 @@
 
 void MsgUnifiedEditorAddress::setAddresses(ConvergedMessageAddressList addrlist)
 {
+    // avoid processing if no info available
+    if(addrlist.count() == 0)
+    {
+        return;
+    }
+
     // ensure flags are reset before starting the addr addition
     mAboutToExceedMaxSmsRecipients = false;
     mAboutToExceedMaxMmsRecipients = false;
@@ -233,7 +239,7 @@
         {
         bool isValid = false;
         isValid = checkValidAddress(addrlist.at(i)->address());
-        if(!isValid) 
+        if(!isValid)
            {
             invalidCount ++;
             // append the comma till last but one contact.
@@ -243,7 +249,7 @@
                 invalidContacts.append(COMMA_SEPERATOR);
                 }
             invalidContacts.append(addrlist.at(i)->alias());
-           }  
+           }
        else
            {
            mAddressMap.insertMulti(addrlist[i]->address(), addrlist[i]->alias());
@@ -256,14 +262,13 @@
               mAddressEdit->setText(addrlist[i]->address(), false);
               }
            }
-     
        }
     if(invalidCount)
         {
         QString invalidStr;
         (invalidCount == 1)?(invalidStr = QString(LOC_INVALID_RECIPIENT_NOT_ADDED)) :(invalidStr = QString(LOC_INVALID_RECIPIENTS_NOT_ADDED));
         // append line seperator
-         invalidStr.append("<br>"); 
+         invalidStr.append("<br>");
          invalidStr.append(invalidContacts);
          HbMessageBox::information(invalidStr);
         }
@@ -356,7 +361,8 @@
     dlg->setTimeout(HbPopup::NoTimeout);
 
     dlg->setText(LOC_SMS_RECIPIENT_LIMIT_REACHED);
-
+    
+    dlg->clearActions();
     HbAction* okAction = new HbAction(LOC_DIALOG_OK,dlg);
     dlg->addAction(okAction);
 
@@ -367,7 +373,6 @@
     // reconnect to get back updates
     connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
             this, SLOT(onContentsChanged(const QString&)));
-    emit contentChanged();
 }
 
 void MsgUnifiedEditorAddress::syncDeletionsToMap()
@@ -386,6 +391,18 @@
         }
         else
         {
+            // ensure that the matched contact is removed from the
+            // address's list
+            int matchedIndex = addrList.indexOf(i.value());
+            if(matchedIndex == -1)
+            {
+                matchedIndex = addrList.indexOf(i.key());
+            }
+            if(matchedIndex != -1)
+            {
+                addrList.removeAt(matchedIndex);
+            }
+            // now go to next index in map
             ++i;
         }
     }
@@ -483,6 +500,7 @@
     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
     if (action == dlg->actions().at(0)) {
         // accept new content, update prev-buffer
+        emit contentChanged();
         mPrevBuffer = mAddressEdit->content();
     }
     else {
@@ -529,7 +547,7 @@
             }
         }
     }
-   
+
     return isValid;
 }
 // ----------------------------------------------------------------------------
@@ -539,20 +557,23 @@
 bool MsgUnifiedEditorAddress::checkValidAddress(const QString& addr)
     {
     bool isValid = false;
+    
+    HBufC *tempAddr = XQConversions::qStringToS60Desc(addr);
+    	
     // 1. perform number validation
     isValid = CommonPhoneParser::IsValidPhoneNumber(
-            *XQConversions::qStringToS60Desc(addr),
+            *tempAddr,
             CommonPhoneParser::ESMSNumber );
 
     // 2. if number validity fails, then perform email addr validation
     UniEditorGenUtils* genUtils = new UniEditorGenUtils;
-    if( !isValid &&
-        ( MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms) )
+    if(!isValid)
         { // additional check for MMS only
         isValid = genUtils->IsValidEmailAddress(
-                    *XQConversions::qStringToS60Desc(addr) );
+                    *tempAddr );
         } 
     delete genUtils;
+    delete tempAddr;
     return isValid;
     }
 
--- a/messagingapp/msgui/unifiededitor/src/msgunieditorbody.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorbody.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -22,7 +22,6 @@
 #include <HbFrameDrawer>
 #include <HbIconItem>
 #include <HbAction>
-#include <hbinputeditorinterface.h>
 #include <HbMainWindow>
 #include <HbDeviceProfile>
 #include <QImageReader>
@@ -58,7 +57,6 @@
 
 // Constants
 const QString BACKGROUND_FRAME("qtg_fr_btn_normal");
-const QString SEND_ICON("qtg_mono_send");
 
 const int KShowCounterLimit = 10;
 const int BYTES_TO_KBYTES_FACTOR = 1024; 
@@ -108,20 +106,14 @@
 mMediaResolver(0),
 mImageInfo(0),
 mProcessingWidget(0),
-mDraftMessage(false)
+mDraftMessage(false),
+mIsImageResizing(false)
 {
     mTextEdit = new HbTextEdit(this);
-    mTextEdit->setSmileysEnabled(true);
     mTextEdit->setPlaceholderText(LOC_HINT_TEXT);
     HbStyle::setItemName(mTextEdit,"textEdit");
     connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged()));
 
-    // add "Send" action in VKB
-    HbEditorInterface editorInterface(mTextEdit);
-    HbAction *sendAction = new HbAction(HbIcon(SEND_ICON), QString(),this);
-    connect(sendAction, SIGNAL(triggered()),this, SIGNAL(sendMessage()));
-    editorInterface.addAction(sendAction);
-
     mMmsConformanceCheck = new MmsConformanceCheck;
     
     mCharCounter = new HbTextItem(this);
@@ -178,69 +170,82 @@
     return mTextEdit->toPlainText();
 }
 
-void MsgUnifiedEditorBody::setImage(QString& imagefile , bool draftMessage)
-{
+void MsgUnifiedEditorBody::setImage(QString& imagefile, bool draftMessage)
+    {
+    // do nothing if filepath is empty
+    if (imagefile.isEmpty())
+        {
+        return;
+        }
+
     mDraftMessage = draftMessage;
     if (!mImageInfo)
-     {
+        {
         setImage(true);
-        
+
         mImageFile = imagefile;
         if (mPixmapItem)
-        {
+            {
             mPixmapItem->setParent(NULL);
             delete mPixmapItem;
             mPixmapItem = NULL;
             mImageSize = 0;
-        }
+            }
 
         int error = KErrNone;
-        
-        if( !mProcessImageOperation )
-        {
-        TRAP(error,mProcessImageOperation = 
-            CUniEditorProcessImageOperation::NewL(*this));
-        }
-        if( !mMediaResolver && error == KErrNone )
-        {
-        TRAP(error,mMediaResolver = CMsgMediaResolver::NewL());
-        }
+        if (!mDraftMessage)
+            {
+        // if image is in draft, no need to resize it because it is resized already
+            if (!mProcessImageOperation)
+                {
+                TRAP(error,mProcessImageOperation =
+                        CUniEditorProcessImageOperation::NewL(*this));
+                }
+            if (!mMediaResolver && error == KErrNone)
+                {
+                TRAP(error,mMediaResolver = CMsgMediaResolver::NewL());
+                }
 
-        if( error == KErrNone)
-        {
-            mMediaResolver->SetCharacterSetRecognition(EFalse);
-            HBufC *name = XQConversions::qStringToS60Desc(imagefile);
-            RFile file;
-            TRAP(error, file = mMediaResolver->FileHandleL(*name));
-            if(error == KErrNone)
-            {
-                TRAP(error,mImageInfo = static_cast<CMsgImageInfo*>
-                (mMediaResolver->CreateMediaInfoL(file)));
+            if (error == KErrNone)
+                {
+                mMediaResolver->SetCharacterSetRecognition(EFalse);
+                HBufC *name = XQConversions::qStringToS60Desc(imagefile);
+                RFile file;
+                TRAP(error, file = mMediaResolver->FileHandleL(*name));
                 if (error == KErrNone)
-                {
-                    TRAP(error, mMediaResolver->ParseInfoDetailsL(
-                            mImageInfo, file));
+                    {
+                    TRAP(error,mImageInfo = static_cast<CMsgImageInfo*>
+                            (mMediaResolver->CreateMediaInfoL(file)));
+                    if (error == KErrNone)
+                        {
+                        TRAP(error, mMediaResolver->ParseInfoDetailsL(
+                                        mImageInfo, file));
+                        }
+                    file.Close();
+                    }
+                delete name;
                 }
-                file.Close();
             }
-            delete name;
-        }
-
-        if (error == KErrNone)
-        {
+        if (error == KErrNone && !mDraftMessage)
+            {
             mSavedImageFile = imagefile;
             startResizeAnimation();
+            mIsImageResizing = true;
             mProcessImageOperation->Process(mImageInfo);
-        }
+            }
         else
-        {
-            delete mImageInfo;
-            mImageInfo = NULL;
+            {
+            if (mImageInfo)
+                {
+                delete mImageInfo;
+                mImageInfo = NULL;
+                }
             mSavedImageFile.clear();
             handleSetImage();
+            }
+
         }
     }
-}
 
 void MsgUnifiedEditorBody::handleSetImage()
 {   
@@ -275,14 +280,17 @@
     this->repolish();
 
     // emit signal to indicate addition of image
-    if(!mDraftMessage)
-    {
-        emit contentChanged();
-    }
+    emit contentChanged();
 }
 
 void MsgUnifiedEditorBody::setAudio(QString& audiofile)
 {
+    // do nothing if filepath is empty
+    if(audiofile.isEmpty())
+    {
+        return;
+    }
+
     //check for insert conformance
     if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(audiofile))
         return;
@@ -328,7 +336,10 @@
 
 void MsgUnifiedEditorBody::setText(QString& text)
 {
-	mTextEdit->setPlainText(text);
+    if(!text.isEmpty())
+    {    
+        mTextEdit->setPlainText(text);
+    }
 }
 
 const QStringList MsgUnifiedEditorBody::mediaContent()
@@ -448,7 +459,6 @@
                 mPixmapItem->setPos(currPos);
             }
             mPixmapItem->show();
-            emit enableSendButton(true);
             }
             
             if(mProcessingWidget)
@@ -628,8 +638,6 @@
 void MsgUnifiedEditorBody::EditorOperationEvent(
     TUniEditorProcessImageOperationEvent aEvent, TFileName aFileName)
 {
-    stopResizeAnimation();
-    
     delete mImageInfo;
     mImageInfo = NULL;
 
@@ -643,8 +651,13 @@
         mImageFile = mSavedImageFile;
     }
     mSavedImageFile.clear();
+
+   // image resize is complete. reset the image resize flag
+    mIsImageResizing = false;
     //handle the processed image from ProcessImage Operation
     handleSetImage();
+    
+    stopResizeAnimation();
 }
 
 void MsgUnifiedEditorBody::startResizeAnimation()
@@ -665,6 +678,7 @@
     processingLayout->addItem(processingText);
     
     HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget);
+    animationItem->setAlignment(Qt::AlignHCenter);
     processingLayout->addItem(animationItem);
     
     HbIconAnimator& iconAnimator = animationItem->animator();
--- a/messagingapp/msgui/unifiededitor/src/msgunieditormonitor.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditormonitor.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -117,6 +117,7 @@
 
     HbWidget* senderWidget = qobject_cast<HbWidget*>(sender());
     updateMsgInfo(senderWidget);
+    updateSend();
 }
 
 //---------------------------------------------------------------
@@ -329,4 +330,21 @@
     return false;
 }
 
+//---------------------------------------------------------------
+// MsgUnifiedEditorMonitor::updateSend
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorMonitor::updateSend()
+{
+    if (mMsgCurrAddressCount > 0 && (mSubjectSize + mBodySize + mContainerSize) > 0 && !view()->mBody->isImageResizing())
+    {
+        emit enableSend(true);
+    }
+    else
+    {
+        emit enableSend(false);
+    }
+}
+
+
 //EOF
--- a/messagingapp/msgui/unifiededitor/src/msgunieditorprocessimageoperation.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorprocessimageoperation.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -525,7 +525,8 @@
     if( largeImageQuery && iMmsCreationMode == EMmsCreationModeWarning)
     {
         HbMessageBox::question(LOC_LARGE_IMAGE_NOTE, this,
-            SLOT(onDialogLargeImage(HbAction*))); 
+                               SLOT(onDialogLargeImage(HbAction*)),
+                               HbMessageBox::Yes | HbMessageBox::No); 
     }
     else
     {
--- a/messagingapp/msgui/unifiededitor/src/msgunieditorsubject.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorsubject.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -151,7 +151,10 @@
 
 void MsgUnifiedEditorSubject::setText(const QString& text)
 {
-    mSubjectEdit->setText(text);
+    if(!text.isEmpty())
+    {
+        mSubjectEdit->setText(text);
+    }
 }
 
 void MsgUnifiedEditorSubject::setFocus()
--- a/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -49,7 +49,7 @@
 #include <qcontactmanager.h>
 #include <qversitcontactexporter.h>
 #include <cntservicescontact.h>
-
+#include <commonphoneparser.h>      // Common phone number validity checker
 
 // USER INCLUDES
 #include "debugtraces.h"
@@ -94,26 +94,23 @@
 //options menu.
 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
-#define LOC_PRIORITY        hbTrId("txt_messaging_setlabel_priority")
-#define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options")
+#define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
 #define LOC_DELETE_MESSAGE  hbTrId("txt_messaging_opt_delete_message")
 
 //priority sub menu
-#define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high")
-#define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal")
-#define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low")
+#define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
+#define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
+#define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
 
 //group box
 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
+#define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
 
 //saved to draft note
 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
 
 //delete confermation
 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
-#define LOC_BUTTON_DELETE       hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL       hbTrId("txt_common_button_cancel")
-#define LOC_DIALOG_OK           hbTrId("txt_common_button_ok")
 
 // attachment addition failure note
 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
@@ -202,7 +199,8 @@
     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
     mMainLayout->setSpacing(vItemSpacing);
 
-    mMsgMonitor = new MsgUnifiedEditorMonitor(this);    
+    mMsgMonitor = new MsgUnifiedEditorMonitor(this);
+    connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool)));
 
     mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
     
@@ -255,7 +253,6 @@
     HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
     lowPriorityAction->setData(ConvergedMessage::Low);
 
-    HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS);
     HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
 
     connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
@@ -263,7 +260,6 @@
     connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
     connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
     connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
-    connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions()));
     connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
 
     setMenu(mainMenu);
@@ -562,6 +558,7 @@
     attachAction->setIcon(HbIcon(ATTACH_ICON));
     
     mTBExtnContentWidget = new HbListWidget();
+    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
     mTBExtnContentWidget->addItem(LOC_PHOTO);
     mTBExtnContentWidget->addItem(LOC_SOUND);
     mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
@@ -579,7 +576,7 @@
 
     //Add Action to the toolbar and show toolbar
     mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
-
+    mSendAction->setDisabled(true);
 
     setToolBar(toolBar);
 }
@@ -659,7 +656,7 @@
     groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
     
     groupBox->setContentWidget(groupWidget);
-    groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
+    groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
     mMainLayout->insertItem(1,groupBox);
     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
     
@@ -692,13 +689,16 @@
     {
         if(!state)
         {
-           groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1));
+           groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
         }
         else
         {
             int addrCount = mCcField->addressCount();
             addrCount += mBccField->addressCount();
-            groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));
+            if(addrCount > 0)
+            {
+                groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));    
+            }
         }
     }
 }
@@ -718,14 +718,11 @@
     mSubjectField->setPriority(priority);
 }
 
-void MsgUnifiedEditorView::sendingOptions()
-{
-}
-
 void MsgUnifiedEditorView::deleteMessage()
 {
-    HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
-                                            LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL);
+    HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,
+                           SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 void MsgUnifiedEditorView::removeAttachmentContainer()
@@ -758,6 +755,12 @@
 
 int MsgUnifiedEditorView::addAttachment(const QString& filepath)
 {
+    // do nothing if filepath is empty
+    if(filepath.isEmpty())
+    {
+        return MsgAttachmentContainer::EAddSuccess;
+    }
+
     if(!mAttachmentContainer)
     {
         mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
@@ -916,16 +919,14 @@
             if (messageType == ConvergedMessage::Sms)
             {
                 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
-                    this,SLOT(onDialogSmsSettings(HbAction*)),
-                                                 LOC_DIALOG_OK,
-                                                 LOC_BUTTON_CANCEL);
+                                       this,SLOT(onDialogSmsSettings(HbAction*)),
+                                       HbMessageBox::Ok | HbMessageBox::Cancel);
             }
             else
             {
                 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
-                    this,SLOT(onDialogMmsSettings(HbAction*)),                             
-                                                 LOC_DIALOG_OK,
-                                                 LOC_BUTTON_CANCEL);
+                                       this,SLOT(onDialogMmsSettings(HbAction*)),                             
+                                       HbMessageBox::Ok | HbMessageBox::Cancel);
             }
         }
     }
@@ -942,7 +943,13 @@
             mToField->addresses(removeDuplicates);
     ConvergedMessageAddressList ccAddresses;
     ConvergedMessageAddressList bccAddresses;
-
+    
+	//Don't format the addresses for save to drfats case
+	if(!isSave)
+	{
+       formatAddresses(addresses);
+    }
+	
     msg.addToRecipients(addresses);
     msg.setBodyText(mBody->text());
     msg.setDirection(ConvergedMessage::Outgoing);
@@ -1001,10 +1008,20 @@
 
         if(ccAddresses.count()>0)
         {
+		//Don't format the addresses for save to drfats case
+	    if(!isSave)
+	    {
+           formatAddresses(ccAddresses);
+        }        
         msg.addCcRecipients(ccAddresses);
         }
         if(bccAddresses.count()>0)
         {
+		//Don't format the addresses for save to drfats case
+	    if(!isSave)
+	    {
+           formatAddresses(bccAddresses);        
+		}
         msg.addBccRecipients(bccAddresses);
         }
         if(mSubjectField)
@@ -1660,4 +1677,32 @@
         }
     }
 
+// ----------------------------------------------------------------------------
+// MsgUnifiedEditorView::formatAddresses
+// @see header
+// ----------------------------------------------------------------------------
+void MsgUnifiedEditorView::formatAddresses(
+        ConvergedMessageAddressList& addresses)
+{       
+
+    for(int i=0; i < addresses.count() ;i++ )
+    {
+        QString addr = addresses[i]->address();
+        
+        HBufC *tempAddr = XQConversions::qStringToS60Desc(addr);     
+            
+        TPtr ptr = tempAddr->Des();
+                    
+         // Note: This is just to parse spaces etc away from phonenumbers.
+         //       Ignore EFalse returned for email addresses.   
+        CommonPhoneParser::ParsePhoneNumber(ptr , 
+                                            CommonPhoneParser::ESMSNumber );        
+       
+        addr = XQConversions::s60DescToQString(tempAddr->Des()); 
+        
+        addresses[i]->setAddress(addr);
+        
+        delete tempAddr;                                                       
+    }       
+}
 //EOF
--- a/messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h	Tue Jul 06 14:12:40 2010 +0300
@@ -56,8 +56,9 @@
     /**
      * short tap handler.
      * @param anchor anchor at cursor position.
+     * @param pos tapping position
      */
-    void shortTapAction(QString anchor);    
+    void handleShortTap(QString anchor,const QPointF& pos);    
     
     /**
      * Helper method to highlight find item on tap.
--- a/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -48,8 +48,6 @@
 
 //LOCALIZED CONSTANTS
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 
 //----------------------------------------------------------------------------
 // UnifiedViewer::UnifiedViewer
@@ -238,9 +236,9 @@
 //---------------------------------------------------------------
 void UnifiedViewer::handleDeleteAction()
 {
-    HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
-                                         LOC_BUTTON_DELETE, 
-                                         LOC_BUTTON_CANCEL);
+    HbMessageBox::question(LOC_DELETE_MESSAGE,this,
+                           SLOT(onDialogDeleteMsg(HbAction*)),
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 //---------------------------------------------------------------
--- a/messagingapp/msgui/unifiedviewer/src/univieweraddresswidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univieweraddresswidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -446,6 +446,16 @@
                 QContactPhoneNumber::DefinitionName,
                 QContactPhoneNumber::FieldNumber);
 
+        // if contact is unresolved on phone number field
+        // then, try resolving it on email address field
+        if(contactId <= 0)
+        {
+            contactId = MsgContactHandler::resolveContactDisplayName(
+                data,
+                QContactEmailAddress::DefinitionName,
+                QContactEmailAddress::FieldEmailAddress);
+        }
+
         if(contactId > 0)
         {
             //open contact card
--- a/messagingapp/msgui/unifiedviewer/src/univiewerheadercontainer.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewerheadercontainer.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -48,9 +48,6 @@
 {
     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
 
-    HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
-    this->setBackgroundItem(bgItem, -2.0);
-
     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
     mMainLayout->setSpacing(0);
     mMainLayout->setContentsMargins(0, 0, 0, 0);
@@ -68,16 +65,31 @@
 
     // Separator
     mSeparator = new HbFrameItem(DIVIDER_FRAME, HbFrameDrawer::OnePiece, this);
-    mSeparator->setMaximumHeight(1);
+    mSeparator->setMinimumHeight(2.0);
+    mSeparator->frameDrawer().fillWholeRect();
     mSeparator->hide();
 
     // Viewer Details widget
     mViewerDetails = new UniViewerDetailsWidget(this);
 
+    // This widget is created to apply background for header & details.
+    HbWidget *headerContainer = new HbWidget(this);
+
+    QGraphicsLinearLayout *headerLayout = new QGraphicsLinearLayout(Qt::Vertical, headerContainer);
+    headerLayout->setSpacing(0);
+    headerLayout->setContentsMargins(0, 0, 0, 0);
+
+    HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
+    headerContainer->setBackgroundItem(bgItem, -2.0);
+
     //Add address group box and insert into layout
-    mMainLayout->addItem(mHeaderGroupBox);
-    mMainLayout->addItem(mSeparator);
-    mMainLayout->addItem(mViewerDetails);
+    headerLayout->addItem(mHeaderGroupBox);
+    headerLayout->addItem(mSeparator);
+    headerLayout->addItem(mViewerDetails);
+
+    headerContainer->setLayout(headerLayout);
+
+    mMainLayout->addItem(headerContainer);
 
     this->setLayout(mMainLayout);
 }
@@ -117,9 +129,11 @@
     // Expand address group box for outgoing messages.
     if (mViewFeeder->isIncoming()) {
         mHeaderGroupBox->setCollapsed(true);
+        addressBoxToggled(true);
     }
     else {
         mHeaderGroupBox->setCollapsed(false);
+        addressBoxToggled(false);
     }
 }
 
@@ -268,3 +282,5 @@
 {
     (state) ? mSeparator->hide() : mSeparator->show();
 }
+
+// EOF
--- a/messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -37,7 +37,7 @@
 const QString PIXMAP_ICON("qtg_small_image");
 const QString CORRUPTED_PIXMAP_ICON("qtg_large_corrupted");
 const QString VIDEO_MIMETYPE("video");
-const QString MSG_VIDEO_ICON("qtg_large_video_player");
+const QString MSG_VIDEO_ICON("qtg_small_video");
 
 //---------------------------------------------------------------
 // UniViewerPixmapWidget::UniViewerPixmapWidget
@@ -217,9 +217,7 @@
     if (!error) {
         this->setIcon(HbIcon(pixmap));
         this->hide();
-        // calling the sizeint forcefully as thumbnailReady is a async call
-        // by the time this call has come sizeint would have already been calculated.
-        this->parentWidget()->resize(-1, -1);
+        this->updateGeometry();
     }
 }
 // EOF
--- a/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -38,11 +38,11 @@
 //consts
 
 //regexp
-const QString NUMBER_PATTERN("(\\(|\\+|\\d)((?:\\d{2,})((?:[\\s-/.\\)\\()])*(?:(\\d+|\\))))*)|((\\*#)(?:\\d+(\\*|#)(?:\\d+#)?))");
+const QString NUMBER_PATTERN("(\\(?(\\+|\\d))((?:\\d)((?:[\\s-/.\\)\\(])*(?:(\\d+|\\))))*(?:\\d?|\\)))|((\\*#)(?:\\d+(\\*|#)(?:\\d+#)?))");
 
 const QString EMAIL_PATTERN("[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?");
 
-const QString URL_PATTERN("(((ht|f|rt)(tp|sp)(s?)\\:\\/\\/)|(www|wap)(?:\\.))(([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&amp;%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&amp;%\\$#_=~]*))+");
+const QString URL_PATTERN("(((ht|f|rt)(tp|sp)(s?)\\:\\/\\/)|(www|wap)(?:\\.))(([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&amp;%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&amp;%\\$#_=~]*))+[a-zA-Z0-9/]");
 
 //rules
 const QString NUMBER_RULE("NUMBER_RULE");
@@ -50,7 +50,7 @@
 const QString URL_RULE("URL_RULE");
 
 //localization
-#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info")
+#define LOC_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
 #define LOC_CALL              hbTrId("txt_common_menu_call_verb")
 #define LOC_SEND_MESSAGE      hbTrId("txt_common_menu_send_message")
 #define LOC_SAVE_TO_CONTACTS  hbTrId("txt_common_menu_save_to_contacts")
@@ -67,7 +67,6 @@
 {
     this->setReadOnly(true);
     this->setScrollable(false);
-    this->setSmileysEnabled(true);
     this->setCursorVisibility(Hb::TextCursorHidden);
     this->setFlag(QGraphicsItem::ItemIsFocusable,false);
     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -211,7 +210,7 @@
                     //do short tap action.
                     if (!anchor.isEmpty() && !this->textCursor().hasSelection())
                     {
-                        shortTapAction(anchor);
+                        handleShortTap(anchor,tap->scenePosition());
                     }
                 }
                 break;
@@ -244,8 +243,23 @@
 {
     HbAction* action = NULL;
 
-    action = contextMenu->addAction(LOC_OPEN_CONTACT_INFO, this, SLOT(openContactInfo()));
-    action->setData(data);
+    QString number = data;
+    number.remove(NUMBER_RULE);
+    int contactId = MsgContactHandler::resolveContactDisplayName(
+                                 number, 
+                                 QContactPhoneNumber::DefinitionName,
+                                 QContactPhoneNumber::FieldNumber); 
+    
+    if(contactId > 0)
+    {
+        action = contextMenu->addAction(LOC_CONTACT_INFO, this, SLOT(openContactInfo()));
+        action->setData(data);
+    }
+    else
+    {
+        action = contextMenu->addAction(LOC_SAVE_TO_CONTACTS, this, SLOT(saveToContacts()));
+        action->setData(data);  
+    }
 
     action = contextMenu->addAction(LOC_CALL, this, SLOT(call()));
     action->setData(data);
@@ -253,9 +267,6 @@
     action = contextMenu->addAction(LOC_SEND_MESSAGE, this, SLOT(sendMessage()));
     action->setData(data);
 
-    action = contextMenu->addAction(LOC_SAVE_TO_CONTACTS, this, SLOT(saveToContacts()));
-    action->setData(data);
-
     action = contextMenu->addAction(LOC_COPY, this, SLOT(copyToClipboard()));
     action->setData(data);
 }
@@ -267,7 +278,7 @@
     action = contextMenu->addAction(LOC_CREATE_EMAIL, this, SLOT(createEmail()));
     action->setData(data);
     
-    action = contextMenu->addAction(LOC_OPEN_CONTACT_INFO, this, SLOT(openContactInfo()));
+    action = contextMenu->addAction(LOC_CONTACT_INFO, this, SLOT(openContactInfo()));
     action->setData(data);
 
     action = contextMenu->addAction(LOC_SAVE_TO_CONTACTS, this, SLOT(saveToContacts()));
@@ -291,15 +302,40 @@
     action->setData(data);
 }
 
-void UniViewerTextItem::shortTapAction(QString anchor)
+void UniViewerTextItem::handleShortTap(QString anchor,const QPointF& pos)
 {
     HbAction action;
     action.setData(anchor);
 
     if(anchor.contains(NUMBER_RULE))
     {
-        //open vcard template.
-        connect(&action,SIGNAL(triggered()),this,SLOT(openContactInfo()));
+        QString data = anchor;
+        data.remove(NUMBER_RULE);
+        int contactId = MsgContactHandler::resolveContactDisplayName(
+                                     data, 
+                                     QContactPhoneNumber::DefinitionName,
+                                     QContactPhoneNumber::FieldNumber);        
+       
+        if(contactId > 0 )
+        {
+            //if resolved conatct open contact card 
+            connect(&action,SIGNAL(triggered()),this,SLOT(openContactInfo()));
+        }
+        else
+        {
+            //unresolved contact show popup.  
+            highlightText(true);
+
+            HbMenu* contextMenu = new HbMenu();
+            contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
+            contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
+            contextMenu->setPreferredPos(pos); 
+            connect(contextMenu,SIGNAL(aboutToClose()),this,SLOT(menuClosed()));
+            
+            addNumberMenu(contextMenu,anchor);
+            
+            contextMenu->show();
+        }
     }
     else if(anchor.contains(EMAIL_RULE))
     {
@@ -534,7 +570,7 @@
 
 void UniViewerTextItem::saveToContacts()
 {
-    //handler for save to contacts.
+     openContactInfo();
 }
 
 void UniViewerTextItem::onServiceRequestCompleted()
--- a/messagingapp/msgui/unifiedviewer/src/univiewslidewidget.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewslidewidget.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -105,8 +105,7 @@
     if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) {
         QString slideString;
         if (mViewFeeder->slideCount() > 1) {
-            slideString = QString(LOC_SLIDE_COUNTER).arg(mSlideNumber + 1).arg(
-                mViewFeeder->slideCount());
+            slideString = (LOC_SLIDE_COUNTER).arg(mSlideNumber + 1).arg(mViewFeeder->slideCount());
         }
         mBody->setSlideContents(mViewFeeder->slideContent(mSlideNumber), slideString);
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsreadfile.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSREADFILE_H
+#define MMSREADFILE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include <f32file.h>
+#include <msvstd.h>
+
+// forward references
+class CMmsAttaStructure;
+class CMmsHeaders;
+class CEikonEnv;
+class CMmsClientMtm;
+
+// Out-of-range value for any MMS header with assigned number
+// Used in coverage tests to get coverage for "default" branches
+// in "case" statements.
+const TInt KMmsTestIllegalValue = 255;
+
+//
+// TEST KEY WORDS
+// Extended to include all MMS headers to allow generation of arbitrary PDUs
+// Content type header cannot be separately defined,
+// it will always be "multipat/mixed" or "multipart/related"
+_LIT8( KTestEndOfFile,          "EOF" );
+_LIT8( KTestNewMessage,         "MESSAGE BEGIN" );
+//------------------------------------------------
+_LIT8( KTestMessageType,        "MESSAGE-TYPE" ); //X-Mms-Message-Type
+_LIT8( KTestDate,               "DATE" ); // Date
+_LIT8( KTestFrom,               "FROM" ); // From
+_LIT8( KTestTo,                 "TO" ); // To
+_LIT8( KTestCc,                 "CC" ); // Cc
+_LIT8( KTestBcc,                "BCC" ); // Bcc
+_LIT8( KTestSubject,            "SUBJECT" ); // Subject
+_LIT8( KTestExpiryRel,          "EXPIRY-REL" ); // X-Mms-Expiry, relative
+_LIT8( KTestExpiryAbs,          "EXPIRY-ABS" ); // X-Mms-Expiry, absolute
+_LIT8( KTestDeliveryTimeRel,    "DELIVERY-TIME-REL" ); // X-Mms-Delivery-Time, relative
+_LIT8( KTestDeliveryTimeAbs,    "DELIVERY-TIME-ABS" ); // X-Mms-Delivery-Time, absolute
+_LIT8( KTestPriority,           "PRIORITY" ); // X-Mms-Priority
+_LIT8( KTestSenderVisibility,   "SENDER-VISIBILITY" ); // X-Mms-Sender-Visibility
+_LIT8( KTestDeliveryReport,     "DELIVERY-REPORT" ); // X-Mms-Delivery-Report
+_LIT8( KTestReadReply,          "READ-REPLY" ); // X-Mms-Read-Report
+// ---------------------------------------------------
+_LIT8( KTestNewAttachment,      "ATTACHMENT" );
+_LIT8( KTestAttachmentType,     "ATTACHMENTTYPE" );
+_LIT8( KTestAttachmentName,     "ATTACHMENTNAME" );
+_LIT8( KTestAttachmentContLoc,  "ATTACHMENTCONTLOC" );
+_LIT8( KTestAttachmentCharset,  "ATTACHMENTCHARSET" );
+_LIT8( KTestAttachmentCid,      "ATTACHMENTCID" );
+_LIT8( KTestAttachmentRoot,     "ATTACHMENTROOT" );
+// content-type and x-type parameters for attachments
+// should appear in name-value pairs.
+// Test program is not responsible for verifying illegal scripts
+_LIT8( KTestAttContTypeParamName, "ContTypeParamName" );
+_LIT8( KTestAttContTypeParamValue, "ContTypeParamValue" );
+_LIT8( KTestAttXTypeParamName, "X-TypeParamName" );
+_LIT8( KTestAttXTypeParamValue, "X-TypeParamValue" );
+// -----------------------------------------------------
+_LIT8( KTestMessageClass,       "MESSAGE-CLASS" ); // X-Mms-Message-Class
+_LIT8( KTestDelivRepSendAllow,  "DELIV-REP-SEND-ALLOW" ); // X-Mms-Report-Allowed
+_LIT8( KTestAcceptAdvertis,     "ACCEPT-ADVERTISEMENTS" );
+_LIT8( KTestRetryCount,         "RETRY-COUNT" );
+_LIT8( KTestRetryInterval,      "RETRY-INTERVAL" );
+// -------------------------------------------------
+_LIT8( KTestAlias,				"ALIAS" );
+_LIT8( KTestFromAlias,			"FROMALIAS" );
+_LIT8( KTestToAlias,			"TOALIAS" );
+_LIT8( KTestCcAlias,			"CCALIAS" );
+_LIT8( KTestBccAlias,			"BCCALIAS" );
+// -------------------------------------------------
+// more Message headers to allow testing all possible PDUs and
+// MMS 1.1 headers
+_LIT8( KTestReplyCharging,      "REPLY-CHARGING" ); // X-Mms-Reply-Charging
+_LIT8( KTestReplyChargAbs,      "REPLY-CHARG-DEADLINE-ABS" ); // X-Mms-Reply-Charging, absolute
+_LIT8( KTestReplyChargRel,      "REPLY-CHARG-DEADLINE-REL" ); // X-Mms-Reply-Charging, relative
+_LIT8( KTestReplyChargSize,     "REPLY-CHARG-SIZE" ); // X-Mms-Reply-Charging-Size (octets)
+_LIT8( KTestReplyChargID,       "REPLY-CHARGING-ID" ); // X-Mms-Reply-Charging-ID
+_LIT8( KTestTID,                "TID" );
+_LIT8( KTestContentLocation,    "CONTLOC" ); // X-Mms-Content-Location
+// The following three must appear as triplets.
+// index must be first, address and date may appear in any order
+_LIT8( KTestPreviouslySentIndex, "PREVIOUSINDEX" ); // forwarded count for X-Mms-PreviouslySent headers
+_LIT8( KTestPreviouslySentBy,    "PREV-SENT-BY" ); // X-Mms-Previously-Sent-By
+_LIT8( KTestPreviouslySentDate,  "PREV-SENT-DATE" ); // X-Mms-Previously-Sent-Date
+//---
+_LIT8( KTestMessageId,           "MESSAGE-ID" ); // Message-ID
+_LIT8( KTestMessageSize,         "MESSAGE-SIZE" ); // X-Mms-Message-Size (octets)
+_LIT8( KTestVersion,             "MMS-VERSION" ); // X-MMS-Version (hex:, 10 = 1.0, 11 = 1.1 etc. )
+_LIT8( KTestReadStatus,          "READ-STATUS" ); // X-Mms-Read-Status
+_LIT8( KTestResponseStatus,      "RESPONSE-STATUS" ); // X-Mms-Response-Status
+_LIT8( KTestResponseText,        "RESPONSE-TEXT" ); // X-Mms-Response-Text
+_LIT8( KTestRetrieveStatus,      "RETRIEVE-STATUS" ); // X-Mms-Retrieve-Status
+_LIT8( KTestRetrieveText,        "RETRIEVE-TEXT" ); // X-Mms-Retrieve-Text
+_LIT8( KTestStatus,              "STATUS" ); // X-Mms-Status
+// -------------------------------------------------
+// MMS 1.2 headers
+_LIT8( KTestAttribute,          "ATTRIBUTE" ); // X-Mms-Attribute
+// The value should be one of the following:
+// BCC, CC, CONTENT, CONTENT-TYPE, DATE, DELIVERY-REPORT, DELIVERY-TIME-ABS,
+// EXPIRY-ABS, FROM, MESSAGE-CLASS, MESSAGE-ID, MESSAGE-SIZE, PRIORITY,
+// READ-REPLY, SUBJECT, TO, REPLY-CHARGING, REPLY-CHARGING-ID,
+// REPLY-CHARG-DEADLINE-ABS, REPLY-CHARG-SIZE, PREV-SENT-BY,
+// PREV-SENT-DATE, ADDITIONAL-HEADERS
+_LIT8( KTestDistributionIndicator,  "DISTRIBUTION-INDICATOR" ); // X-Mms-Distribution-Indicator
+_LIT8( KTestLimit,              "LIMIT" ); // X-Mms-Limit
+_LIT8( KTestMessageQuota,       "MESSAGE-QUOTA" ); // X-Mms-Mbox-Quota, message number
+_LIT8( KTestSizeQuota,          "SIZE-QUOTA" ); // X-Mms-Mbox-Quota, size quota
+_LIT8( KTestMessageTotal,       "MESSAGE-TOTAL" ); // X-Mms-Mbox-Totals, message number
+_LIT8( KTestSizeTotal,          "SIZE-TOTAL" ); // X-Mms-Mbox-Totals, total size
+_LIT8( KTestMessageCount,       "MESSAGE-COUNT" ); // X-Mms-Message-Count
+_LIT8( KTestAddKeyword,         "ADD-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestRemoveKeyword,      "REMOVE-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestFilterKeyword,      "FILTER-KEYWORD" ); // X-Mms-MM-FLags
+_LIT8( KTestMMState,            "MESSAGE-STATE" ); // X-Mms-MM-State
+_LIT8( KTestQuota,              "QUOTA" ); // X-Mms-Quotas
+_LIT8( KTestStart,              "START" ); // X-Mms-Start
+_LIT8( KTestStore,              "STORE" ); // X-Mms-Store
+_LIT8( KTestStored,             "STORED" ); // X-Mms-Stored
+_LIT8( KTestStoreStatus,        "STORE-STATUS" ); // X-Mms-Store-Status
+_LIT8( KTestStoreStatusText,    "STORE-STATUS-TEXT" ); // X-Mms-Store-Status-Text
+_LIT8( KTestTotals,             "TOTALS" ); // X-Mms-Totals
+// Delete confirmation header structure
+// This consists of index, content location, response status and response status text.
+// All three values are not always necessary for each index, but at least content-location
+// and response status should be present.
+// The index retains its value until a new index is encountered.
+_LIT8( KTestDeleteInfoIndex,    "DELETESTATUSINDEX" ); // index for next delete info fields
+// This header must precede content-location, response-status and response-text fields
+// in a delete confirmation. Index retains its value until a new index is encountered.
+
+// Element descriptor header not implemented
+
+// Application id headers
+// These will officially be supported in MMS encapsulation version 1.3
+// Java has non-standard support even earlier
+
+_LIT8( KTestApplicId,            "APPLIC-ID" ); // X-Mms-Applic-ID
+_LIT8( KTestReplyApplicId,       "REPLY-APPLIC-ID" ); // X-Mms-Reply-Applic-ID
+_LIT8( KTestApplicInfo,          "AUX-APPLIC-INFO" ); // X-Mms-Aux-Applic-Info
+
+// Since Encapsulation 1.3
+_LIT8( KTestContentClass,        "CONTENT-CLASS" ); // X-Mms-Content-Class
+_LIT8( KTestDrmContent,          "DRM-CONTENT" ); // X-Mms-DRM-Content
+_LIT8( KTestAdaptationAllowed,   "ADAPTATION-ALLOWED" ); // X-Mms-Adaptation-Allowed
+_LIT8( KTestRecommendedRetrievalMode, "REC-RETRIEVAL-MODE" ); // X-Mms-Recommended-Retrieval-Mode
+_LIT8( KTestRecRetrievalModeText, "REC-RETR-MODE-TEXT" ); // X-Mms-Recommended-Retrieval-Mode-Text
+_LIT8( KTestReplaceId,           "REPLACE-ID" ); // X-Mms-Replace-ID
+_LIT8( KTestStatusText,          "STATUS-TEXT" ); // X-Mms-Status-Text
+_LIT8( KTestCancelId,            "CANCEL-ID" ); // X-Mms-Cancel-ID
+_LIT8( KTestCancelStatus,        "CANCEL-STATUS" ); // X-Mms-Cancel-Status
+
+// DATA TYPES
+#define aSet            1
+#define aReset          0
+#define PartCount      100
+#define MaxAttaCount   10
+#define DefaultBufLen 256
+#define MaxRecipients   5
+
+// status returned by ReadRow
+enum TTestReadStatus
+    {
+    ETestUnknown,
+    ETestNewMessage,
+    ETestNewAttachment,
+    ETestEof,    // End of file
+    ETestMessageType,
+    ETestDate,
+    ETestFrom,
+    ETestTo,
+    ETestCc,
+    ETestBcc,
+	ETestAlias,
+	ETestFromAlias,
+	ETestToAlias,
+	ETestCcAlias,
+	ETestBccAlias,
+    ETestSubject,
+    ETestExpiryRel,
+    ETestExpiryAbs,
+    ETestDeliveryTimeRel,
+    ETestDeliveryTimeAbs,
+    ETestPriority,
+    ETestSenderVisibility,
+    ETestDeliveryReport,
+    ETestReadReply,
+    ETestAttachmentType,
+//    ETestAttachmentName,
+    ETestAttachmentCharset,
+    ETestAttachmentCid,
+	ETestAttachmentRoot,
+    ETestSettings,
+    ETestMessageClass,
+    ETestDelivReportSendAllow,
+    ETestSingleMessageClass,
+    ETestReplyCharging,
+    ETestReplyChargAbs,
+    ETestReplyChargRel,
+    ETestReplyChargSize,
+    ETestReplyChargID,
+    ETestTID,
+    ETestContentLocation,
+    ETestPreviouslySentIndex,
+    ETestPreviouslySentBy,
+    ETestPreviouslySentDate,
+    ETestMessageId,
+    ETestMessageSize,
+    ETestVersion,
+    ETestReadStatus,
+    ETestResponseStatus,
+    ETestResponseText,
+    ETestRetrieveStatus,
+    ETestRetrieveText,
+    ETestStatus,
+    ETestAttribute,
+    ETestDistributionIndicator,
+    ETestLimit,
+    ETestMessageQuota,
+    ETestSizeQuota,
+    ETestMessageTotal,
+    ETestSizeTotal,
+    ETestMessageCount,
+    ETestAddKeyword,
+    ETestRemoveKeyword,
+    ETestFilterKeyword,
+    ETestMMState,
+    ETestQuota,
+    ETestStart,
+    ETestStore,
+    ETestStored,
+    ETestStoreStatus,
+    ETestStoreStatusText,
+    ETestTotals,
+    ETestDeleteInfoIndex,
+    ETestApplicId,
+    ETestReplyApplicId,
+    ETestApplicInfo,
+    ETestContentClass,
+    ETestDrmContent,
+    ETestAdaptationAllowed,
+    ETestRecommendedRetrievalMode,
+    ETestRecRetrievalModeText,
+    ETestReplaceId,
+    ETestStatusText,
+    ETestCancelId,
+    ETestCancelStatus,
+    ETestAttaRecommendedName,
+    ETestAttachmentContLoc,
+    ETestAttContTypeParamName,
+    ETestAttContTypeParamValue,
+    ETestAttXTypeParamName,
+    ETestAttXTypeParamValue
+
+    };
+
+// VALUE KEYWORDS
+_LIT( KPersonal,      "Personal" );
+_LIT( KAdvertisement, "Advertisement" );
+_LIT( KInformational, "Informational" );
+_LIT( KAuto,          "Auto" );
+_LIT( KLow,    "Low" );
+_LIT( KNormal, "Normal" );
+_LIT( KHigh,   "High" );
+_LIT( KHide,   "Hide" );
+_LIT( KShow,   "Show" );
+_LIT( KYes,    "Yes" );
+_LIT( KNo,     "No" );
+_LIT( KOn,     "On" );
+_LIT( KOff,     "Off" );
+_LIT( KDeferred, "Deferred" );
+_LIT( KExpired,  "Expired" );
+_LIT( KRetrieved, "Retrieved" );
+_LIT( KRejected, "Rejected" );
+_LIT( KUnrecognized, "Unrecognized" );
+_LIT( KIndeterminate, "Indeterminate" );
+_LIT( KForwarded, "Forwarded" );
+_LIT( KUnreachable, "Unreachable" );
+_LIT( KDraft, "Draft");
+_LIT( KSent, "Sent" );
+_LIT( KNew, "New" );
+// X-Mms-Message-Type
+_LIT( KSendReq, "SendReq" );
+_LIT( KSendConf, "SendConf" );
+_LIT( KNotifInd, "NotifInd" );
+_LIT( KNotifResp, "NotifResp" );
+_LIT( KRetrConf, "RetrConf" );
+_LIT( KAckInd, "AckInd" );
+_LIT( KDelInd, "DelInd" );
+_LIT( KReadReqInd, "ReadReqInd" );
+_LIT( KReadOrigInd, "ReadOrigInd" );
+_LIT( KForwardRec, "ForwardReq" );
+_LIT( KForwardConf, "ForwardConf" );
+_LIT( KMBoxStoreReq, "MBoxStoreReq" );
+_LIT( KMBoxStoreConf, "MBoxStoreConf" );
+_LIT( KMBoxViewReq, "MBoxViewReq" );
+_LIT( KMBoxViewConf, "MBoxViewConf" );
+_LIT( KMBoxUploadReq, "MBoxUploadReq" );
+_LIT( KMBoxUploadConf, "MBoxUploadConf" );
+_LIT( KMBoxDeleteReq, "MBoxDeleteReq" );
+_LIT( KMBoxDeleteConf, "MBoxDeleteConf" );
+_LIT( KMBoxDescr, "MBoxDescr" );
+_LIT( KDeleteReq, "DeleteReq" );
+_LIT( KDeleteConf, "DeleteConf" );
+_LIT( KCancelReq, "CancelReq" );
+_LIT( KCancelResp, "CancelConf" );
+// X-Mms-Read-Status
+_LIT( KRead, "Read" );
+_LIT( KDelNotRead, "DeletedNotRead" );
+// X-Mms-Reply-Charging
+_LIT( KRequested, "Requested" );
+_LIT( KReqTextOnly, "ReqTextOnly" );
+_LIT( KAccepted, "Accepted" );
+_LIT( KAccTextOnly, "AccTextOnly" );
+// X-Mms-Cancel-Status (only receival of request, not actual cancellation)
+_LIT( KCancelSuccessful, "CancelSuccess" );
+_LIT( KCancelCorrupted, "CancelCorrupted" );
+// X-Mms-Content-Class
+_LIT( KText, "Text" );
+_LIT( KImageBasic, "ImageBasic" );
+_LIT( KImageRich, "ImageRich" );
+_LIT( KVideoBasic, "VideoBasic" );
+_LIT( KVideoRich, "VideoRich" );
+_LIT( KMegaPixel, "MegaPixel" );
+_LIT( KContentBasic, "ContentBasic" );
+_LIT( KContentRich, "ContentRich" );
+// X-Mms-Recommended-Retrieval-Mode
+_LIT( KManual, "Manual" );
+
+//X-Mms-ResponseStatus
+// legacy values
+_LIT( KOk, "OK" );
+_LIT( KErrUnspecified, "Unspecified" );
+_LIT( KErrServiceDenied, "ServiceDenied" );
+_LIT( KErrMessageFormatCorrupt, "FormatCorrupt" );
+_LIT( KErrAddressUnresolved, "AddressUnresolved" );
+_LIT( KErrMessageNotFound, "MessageNotFound" );
+_LIT( KErrNetworkProblem, "NetworkProblem" );
+_LIT( KErrContentNotAccepted, "ContentNotAccepted" );
+_LIT( KErrUnsupportedMessage, "UnsupportedMessage" );
+// values since 1.1 (and 1.2)
+_LIT( KErrTransient, "TransientFailure" );
+_LIT( KErrTransientAddressUnresolved, "TransientAddressUnresolved" );
+_LIT( KErrTransientNotFound, "TransientMessageNotFound" );
+_LIT( KErrTransientNetworkproblem, "TransientNetworkProblem" );
+_LIT( KErrTransientPartialSuccess, "PartialSuccess" );
+_LIT( KErrPermanent, "PermanentFailure" );
+_LIT( KErrPermanentServiceDenied, "PermanentServiceDenied" );
+_LIT( KErrPermanentMessageFormatCorrupt, "PermanentFormatCorrupt" );
+_LIT( KErrPermanentAddressUnresolved, "PermanentAddressUnresolved" );
+_LIT( KErrPermanentNotFound, "PermanentMessageNotFound" );
+_LIT( KErrPermanentContentNotAccepted, "PermanentContentNotAccepted" );
+_LIT( KErrReplyChargingLimitNotMet, "ReplyChargingLimitNotMet" );
+_LIT( KErrReplyChargingRequestNotAccepted, "ReplyChargingRequestNotAccepted" );
+_LIT( KErrReplyChargingForwardingDenied, "ReplyChargingForwardingDenied" );
+_LIT( KErrReplyChargingNotSupported, "ReplyChargingNotSupported" );
+_LIT( KErrAddressHidingNotSupported, "AddressHidingNotSupported" );
+_LIT( KErrPermanentLackOfPrepaid, "PermanentLackOfPrepaid" );
+//X-Mms-RetrieveStatus (one extra value)
+_LIT( KErrRetrieveContentUnsupported, "PermanentContentUnsupported" );
+//X-Mms-Store-Status (one extra value)
+_LIT( KErrMMBoxFull, "MMBoxFull" );
+
+_LIT8( KTestContent,  "Content" ); // For attribute list only
+_LIT8( KTestAdditionalHeaders,  "ADDITIONAL-HEADERS" ); // For attribute list only
+_LIT8( KTestDeliveryTime,       "DELIVERY-TIME"); // for attribute list only
+_LIT8( KTestExpiry,             "EXPIRY"); // for attribute list only
+_LIT8( KTestReplyCharg,         "REPLY-CHARG-DEADLINE" ); // for attribute list only
+_LIT8( KTestContentType,        "CONTENT-TYPE" );  // for attribute list only
+
+/**
+*  CMmsReadFile
+*/
+NONSHARABLE_CLASS( CMmsReadFile ):public CBase
+    {
+    public:  // Constructors and destructor
+
+        static CMmsReadFile* NewL(RFs& aFs, RFileReadStream& aReadStream ); // Two-phased constructor.
+        virtual ~CMmsReadFile(); // Destructor
+
+    public: // New functions
+
+        TInt CompleteTestL(TInt aMessageCounter, CMmsHeaders& aMmsHeaders);
+        TTestReadStatus ReadRowL();
+        void CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders );
+		TInt FindAlias(TPtrC alias);
+		void SetAttaStructure( TBool aOldAttaStructure = EFalse );
+
+    protected:  // Functions from base classes
+
+    private:
+
+        CMmsReadFile(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL( RFs& aFs, RFileReadStream& aReadStream );
+        void Reset();
+
+    public: // data
+        TInt                            iMessageType;
+
+
+    private:     // Data
+
+        RFs                             iFs;
+        RFileReadStream*                iReader;
+        TBuf<DefaultBufLen>             iValueBuffer;
+        CDesCArray*     iAliasArray;    // aliases
+        HBufC8*         iByteBuffer;
+        TTime                           iDate;
+        CArrayPtrFlat<CMmsAttaStructure>* iAttaStructures;
+        TInt                            iAttaCount;
+		TInt							iAttaRoot;
+		TInt							iAliasCount;
+        TInt                            iNextMessageType;
+        TParse                          iParse;
+        TFileName                       iFilename;
+
+    protected:  // Data
+    private:    // Data
+
+        // CArrayFixFlat <TestMessage>* iMessages;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+    };
+
+
+NONSHARABLE_CLASS( CMmsAttaStructure ):public CBase
+    {
+    public:  // Constructors and destructor
+        static CMmsAttaStructure* NewL(); // Two-phased constructor.
+        virtual ~CMmsAttaStructure(); // Destructor
+    private:
+        CMmsAttaStructure(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL();
+
+    public:     // Data
+        HBufC8*         iAtta;
+        HBufC8*         iAttaName; // content location
+        HBufC8*         iAttaType;
+        HBufC8*         iAttaCid;
+        TInt            iAttaCharset;
+        HBufC*          iAttaRecommendedName; // recommended filename
+       	CDesC8ArrayFlat* iContentTypeParams;  // zero or more "parameter"
+    	CDesC8ArrayFlat* iXTypeParams;        // zero or more X-Type "parameters"
+
+    };
+
+
+#endif      // MMSREADFILE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTBED_H
+#define MMSTESTBED_H
+
+#ifdef BUILD_MMSTESTBED_DLL
+#define MMSTESTBED_EXPORT Q_DECL_EXPORT
+#else
+#define MMSTESTBED_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <QString>
+
+#include <msvids.h>  //for consts like KMsvNullIndexEntryIdValue
+#include <MSVAPI.H>
+#include <MTCLREG.H>
+#include <mmsclient.h>
+//#include <mmsservercommon.h>
+
+class CTestUiTimer;
+class CMsvSession;
+class CMmsClientMtm;
+class CMmsSettings;
+class CMmsHeaders;
+class CLogEvent;
+class CLogViewEvent;
+class CLogFilter;
+class CLogClient;
+
+class MMSTESTBED_EXPORT MmsTestBed : public QObject, public MMsvSessionObserver
+    {
+    Q_OBJECT
+
+public:
+    /**
+     *
+     */
+    MmsTestBed();
+    ~MmsTestBed();
+    void setConnectionLocal(bool value);
+    void fromOutboxToMmsc();
+    void fromMmscToInbox();
+    /**
+     * cleanup MMS service
+     */
+    void cleanupAndCreateNewService();
+    void deleteNotifications();
+    void restoreFactorySettings();
+    void setFetchingState( TMmsReceivingMode aState );
+    void sendFromFile();
+    void sendOneByOne();
+    void sendNotifications();
+    void copyDrafts();
+    void garbageCollection(TUint32 aReason = 0x00000001); //0x00000001 == KMmsReasonBoot
+    void messageVariation();
+    void cancelSendScheduling();
+    void scheduledSend(TMsvId aBoxId, TInt aDelay = 5);
+    void deleteSendSchedule();
+    void cancelFetchScheduling();
+    void fetchForced(TInt aDelay = 5);
+    void deleteFetchSchedule();
+    void doAFetchCycle();
+    void createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry);
+    void cleanOutbox();
+    void cleanInbox();
+    void cleanSent();
+    void cleanDrafts();
+    void cleanAll();
+    void reply();
+    void replyToAll();
+    void forward();
+    void sendReadReport(); // send a read report
+    int fromOutboxToMmscWithMemoryFailure(); // returns memory failure count
+    int fromMmscToInboxWithMemoryFailure(); // returns memory failure count
+    void sendViaClient();
+    void scheduledFetch(TInt aDelay = 5);
+    void fetchForcedImmediate();
+    void getEventType();
+    void addEventType();
+    void deleteEventType();
+    void cleanLog();
+    void setOnline(bool value);
+    void generateDeliveryReport( CMmsHeaders* aMmsHeaders );
+    void sendDeliveryReport();
+
+signals:
+    void entryCreatedInDraft(long int id);
+    void entryMovedToOutbox(long int id);
+    void entryMovedToSent(long int id);
+    void entryCreatedInInbox(long int id);
+
+protected:
+    /**
+     * From MMsvSessionObserver
+     */
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+            TAny* aArg2, TAny* aArg3);
+
+private:
+    void findDefaultL();
+    void createMmsService();
+    void cleanup();
+    void deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry);
+    void testFile(TFileName& aFilePath, TInt aCommand = 0, TMsvId aBox = KMsvGlobalOutBoxIndexEntryId);
+    void addMMBoxDescriptions();
+    void encodeMessageFromDrafts();
+    TMsvId findMMSFolder();
+    bool checkLogClient();
+    int getLogEntries();
+
+private:
+    //data
+    CTestUiTimer* iTimer;
+    CMsvOperationActiveSchedulerWait* iWait;
+    CMsvSession* iSession;
+    CClientMtmRegistry* iClientMtmRegistry;
+    CMmsClientMtm* iMmsClient;
+    CMmsSettings* iSettings;
+    CMmsHeaders* iMmsHeaders;
+    TMsvId iServiceId;
+    TMsvId iDefaultServiceId;
+    TMsvSessionEvent iEvent;
+    RFs iFs;
+    TFileName iFilename;
+    TFileName iCurrentFile;
+    TFileName iCurrentPath;
+    TParse iParse;     // parse buffer as member to save stack space
+    CBufFlat* iEncodeBuffer;
+    CMsvEntrySelection* iMsvEntrySelection;
+    CLogEvent* iLogEvent;
+    CLogClient* iLogClient;
+    CLogViewEvent* iLogView;
+    CLogFilter* iLogFilter;
+    };
+
+#endif // MMSTESTBED_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.hrh	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <bldvariant.hrh>
+
+
+#ifndef MMSTESTBED_HRH
+#define MMSTESTBED_HRH
+
+enum
+{
+    EAppMainOk = 1,
+    EAppMainCancel,
+    //
+    EMenufrmCmdCascadeTest,
+    ECleanup,
+    ECleanOutbox,
+    ESaveSettings,
+    ELoadSettings,
+    ECleanInbox,
+    EShowIn,
+    EShowOut,
+    EOutToMMSC,
+    EMMSCToIn,
+    ESendScheduled,
+    EReceiveScheduled,
+    EShowSent,
+    ECleanSent,
+    EStartMyNotifier,
+    EGetEventType,
+    EAddEventType,
+    EDeleteEventType,
+    EViewLog,
+    ECleanLog,
+    EShowWapAccessPoints,
+    ESelectWapAccessPoint,
+    EShowConnectionMode,
+    EShowIAP,
+    EConnectToIAP,
+    EDeleteSendSchedule,
+    EDeleteReceiveSchedule,
+    EDeleteNotifications,
+    ERestoreFactorySettings,
+    ECreateFromFile,
+    EShowNotifications,
+    ESendDeliveryReport,
+    EShowDrafts,
+    ECleanDrafts,
+    ECleanAll,
+    EFetchingDeferred,
+    EFetchingOn,
+    ESendFromFile,
+    ESwitchToLocal,
+    ESwitchToGlobal,
+    EDecodeLoggingOn,
+    EDecodeLoggingOff,
+    EBinaryDumpOn,
+    EBinaryDumpOff,
+    ESendNotification,
+    ECreateToInbox,
+    ECreateToSentItems,
+    ESendFromDrafts,
+    EFindMMSFolder,
+    ESendOneByOne,
+    ECreateToDrafts,
+    ESendViaClient,
+    ESendMemFail,
+    EFetchMemFail,
+    EReceiveForced,
+    ECreateHeadersFromFile,
+    ESwitchToOffline,
+    ESwitchToOnline,
+    ECopyDrafts,
+    ECreateNotification,
+    EReply,
+    EReplyToAll,
+    EForward,
+    EFetchingManual,
+    EFirstBoot,
+    ENoFirstBoot,
+    EFindNetworkStatus,
+    ESendReadReport,
+    ECreateMMBoxViewConf,
+    EGetMMBoxView,
+    ECleanMMBox,
+    EShowMMBox
+};
+
+#define 	ETestLabel1 1
+#define 	ETestLabel2 2
+#define 	ETestLabel3 3
+#define 	ETestLabel4 4
+
+#define     EServiceList 2
+
+
+enum TTestBedDlgCtrlIds
+	{
+	ETestEditField = 1
+	};
+
+enum TEditServiceControls
+	{
+	EFolderLabel = 1,
+    EEditUri
+//	EEditServiceFolder,
+//	ENameLabel,
+//	EEditServiceName,
+//	ENumberLabel,
+//	EEditServiceNumber
+	};
+
+enum
+	{
+	EFsViewDialogId = 1
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsteststaticutils.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTSTATICUTILS_H
+#define MMSTESTSTATICUTILS_H
+
+#include <e32std.h>
+#include <msvstd.h>
+#include <badesca.h>
+
+#include "mmsconst.h"
+
+class RFs;
+class CMsvSession;
+class CMmsEncode;
+class CMmsHeaders;
+
+#ifdef __WINS__
+_LIT( KRootPath, "c:\\" );
+#else
+// This is removable disk.
+// drive letter should not be hard coded, must be investigated further
+// We use c: for a while for the tests (to be cahnged later)
+_LIT( KRootPath, "c:\\" );
+//_LIT( KRootPath, "e:\\" );
+#endif
+
+// directory where mmbox descriptions are created
+_LIT( KMmsMMBoxDescriptionDirectory, "C:\\mmsmmboxdescriptions\\");
+// directory where created headers are dumped
+_LIT( KMmsDumpDirectory, "C:\\mmsdump\\");
+// content type of MMS PDUs
+_LIT8( KMmsMimeType, "application/vnd.wap.mms-message" );
+
+_LIT( KWild, "*" );
+
+
+/**
+ *  joined array structure
+ *
+ */
+NONSHARABLE_CLASS( TMmsJoinedArrays ): public MDesCArray
+    {
+public:
+    TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2);
+    TInt MdcaCount() const;
+    TPtrC16 MdcaPoint(TInt aIndex) const;
+private:
+    CDesCArray* const & iArray1;
+    CDesCArray* const & iArray2;
+    };
+
+/**
+ *  static utility functions
+ *
+ */
+class TMmsTestUtils
+    {
+
+public:
+
+    /**
+     *
+     */
+    TMmsTestUtils();
+
+    /**
+     * read phone number for sending messages
+     *
+     * @param aFileName full path for filename
+     * @param aFs file system handle
+     * @return allocated pointer containing the name
+     *     The caller must delete the pointer when no longer needed
+     */
+    static HBufC* ReadContactFromFileL( TDesC& aFileName, RFs& aFs );
+
+    static void DecodeLoggingOnL();
+    static void DecodeLoggingOffL();
+    static void BinaryDumpOnL();
+    static void BinaryDumpOffL();
+
+    /**
+     * Clean all temporary directories used in local mode.
+     * Does not delete the directories, only the contents
+     *
+     * @param aFs file system handle
+     */
+    static void CleanDirectoryL( RFs& aFs );
+
+    /**
+     * Dump a binary message
+     *
+     * @param aBuffer buffer containing the binary message
+     * @param aFilename full path of the directory whenre the dump goes
+     * @param aParse reference to parser (to save stack space)
+     * @param aFs file system handle
+     */
+    static void Dump(
+        CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs );
+
+    /**
+     * Delete all MMS messages and notifications from a given folder
+     *
+     * @param aBoxId folder id
+     * @param aSession Messaging server session
+     */
+    static void CleanBoxL(TMsvId aBoxId, CMsvSession& aSession);
+
+    /**
+     * turn on logging messages sent to email addresses
+     */
+    static void EmailLoggingOnL();
+
+    /**
+     * turn off logging messages sent to email addresses
+     */
+    static void EmailLoggingOffL();
+
+    /**
+     * load list of children into selection and return count
+     *
+     * @param aBoxId folder id
+     * @param aMsvEntrySelection reference to a pointer that will contain the list of child ids
+     *     caller is responsible of deleting the pointer afterwards.
+     *     Pointer may be NULL at entry, and a new pointer will be allocated
+     * @param aSession messge server session
+     * @param aMessageType child MTM type, default is multimedia message
+     * @return number of entries in selection
+     */
+    static TInt CountChildrenL(
+        TMsvId aBoxId,
+        CMsvEntrySelection*& aMsvEntrySelection,
+        CMsvSession& aSession,
+        TUid aMessageType = KUidMsgTypeMultimedia);
+
+    /**
+     * Create a folder entry
+     *
+     * @param aSession messge server session
+     * @param aParentFolder the parent folder
+     * @param aFolderName name of the folder
+     * @param aFolderId will contain the if of the new folder if creation was successful
+     */
+    static void CreateFolderEntryL(
+        CMsvSession& aSession,
+        TMsvId aParentFolder,
+        const TDesC& aFolderName,
+        TMsvId& aFolderId );
+
+    /**
+    * Create an MMS notification from data in buffer
+    * @param aNotificationFolder mms notification folder (target folder)
+    * @param aServiceId id of MMS service
+    * @param aEncodeBuffer buffer that contains the data
+    * @param aSession message server session
+    * @return id of the created notification
+    */
+    static TMsvId CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession );
+
+    /**
+    * Encode an MMS notification into buffer
+    * @param aUrl url of the notification for local messages a filepath
+    * @param aSize size of the message
+    * @param aMmsHeaders MMS headers structure for creating the notification
+    * @param aMmsEncoder reference to CMmsEncode class
+    * @param aEncodeBuffer flat buffer that will contain the encoded notification
+    */
+    static void FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer );
+
+
+    static TBool IsDrive(const TDesC& aFileName);
+    static TBool IsDir(const TDesC& aFileName, RFs& aFs);
+    static TBool IsFile(const TDesC& aFileName, RFs& aFs);
+
+
+private:
+
+    };
+
+
+#endif // MMSTESTSTATICUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestuitimer.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef C_TESTUITIMER_H
+#define C_TESTUITIMER_H
+
+
+#include <e32base.h>
+
+#define KPeriod 10000 // period of timer
+
+/**
+ *  timer for test programs
+ */
+NONSHARABLE_CLASS( CTestUiTimer ): public CTimer
+    {
+public:
+
+    static CTestUiTimer* NewL();
+    virtual  ~CTestUiTimer();
+
+    void RunL();
+    void DoCancel();
+    void ConstructL();
+    void IssueRequest();
+    void TimeoutOperation(CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds);
+
+private:
+    CTestUiTimer();
+
+public:
+    TTimeIntervalMicroSeconds32 period;
+
+private: // data
+    CActive* iObject;
+    };
+
+#endif // C_TESTUITIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/mmstestbed.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,76 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+QT += testlib
+QT -= gui
+
+TEMPLATE = lib
+
+TARGET = mmstestbed
+
+INCLUDEPATH += .
+INCLUDEPATH += inc
+INCLUDEPATH += ../../inc
+INCLUDEPATH += ../../../../../mmsengine/inc
+INCLUDEPATH += ../../../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../mmsengine/mmshttptransport/inc
+INCLUDEPATH += ../../../../../mmsengine/mmsmessage/inc
+INCLUDEPATH += ../../../../../mmsengine/mmsconninit/inc
+INCLUDEPATH += ../../../../../mmsengine/mmsserver/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+DEFINES += BUILD_MMSTESTBED_DLL
+
+SOURCES += src/mmstestbed.cpp \
+           src/mmsteststaticutils.cpp \
+           src/mmsreadfile.cpp \
+           src/mmstestuitimer.cpp
+
+HEADERS += inc/mmstestbed.h \
+           inc/mmsteststaticutils.h \
+           inc/mmsreadfile.h \
+           inc/mmstestuitimer.h \
+           inc/mmstestbed.hrh
+
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+
+symbian {
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000
+    TARGET.EPOCALLOWDLLDATA = 1 
+	}
+
+# Build.inf rules
+BLD_INF_RULES.prj_exports += \
+     "$${LITERAL_HASH}include <platform_paths.hrh>"
+
+LIBS += -lmsgs \
+        -lmmsmessage \
+        -lmmsconninit \
+        -lmmscodec \
+        -lmmsserversettings \
+        -lcentralrepository \
+        -lapparc \
+        -lbafl \
+        -lefsrv \
+        -lesock \
+        -lestor \
+        -leuser \
+        -llogcli \
+        -llogwrap \
+        -lapgrfx \
+        -lapmime
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsreadfile.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,1799 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <badesca.h>
+#include    <e32def.h>
+#include    <s32file.h>
+#include    <msvids.h>
+#include    <mtmdef.h>
+//#include    <eikenv.h>
+#include    <apgcli.h>
+#include    <CMsvMimeHeaders.h>
+#include    <AknNoteWrappers.h>
+
+#include    <mmsservercommon.h>
+#include    "mmsconst.h"
+#include    "mmsclient.h"
+#include    "mmsheaders.h"
+#include    "mmsreadfile.h"
+#include    "mmsmmboxviewheaders.h"
+#include    "mmsmmboxmessageheaders.h"
+#include    "mmsmmboxflags.h"
+#include    "mmssettings.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMmsGranularity = 8;
+_LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsReadFile::CMmsReadFile()
+    {
+    // all member variables in a class derived from CBase
+    // are automatically set to 0.
+    }
+
+
+//
+void CMmsReadFile::ConstructL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    // iRowBuffer = HBufC8::NewMaxL( 500 ); // Max row length!!!!
+    iFs = aFs;
+    iReader = &aReadStream;
+    iByteBuffer = HBufC8::NewL( DefaultBufLen );
+    iAliasArray = new ( ELeave ) CDesCArrayFlat( KMmsGranularity );
+    iAttaStructures = new ( ELeave ) CArrayPtrFlat<CMmsAttaStructure>( KMmsGranularity );
+    Reset();
+    }
+
+// Two-phased constructor.
+CMmsReadFile* CMmsReadFile::NewL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    CMmsReadFile* self = new ( ELeave ) CMmsReadFile();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFs, aReadStream );
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// Destructor
+CMmsReadFile::~CMmsReadFile()
+    {
+    Reset(); // resets and destroys all array data
+    if (iAliasArray != NULL) iAliasArray->Reset();
+    delete iByteBuffer;
+    delete iAliasArray;
+    delete iAttaStructures;
+    }
+
+void CMmsReadFile::Reset()
+    {
+    // reset all arrays
+    if (iAttaStructures != NULL) iAttaStructures->ResetAndDestroy();
+    iAttaCount = 0;
+    iAttaRoot = 0;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CompleteTest
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::CompleteTestL( TInt aMessageCounter, CMmsHeaders& aMmsHeaders )
+{
+    Reset(); // new message
+
+    TUint32 val;
+    TUint   limit = 1000000;
+    TUint   sizeLimit = 1000 * 1024; //max message size 1000 kB!
+    TUint   allLimit = 999999;
+    TInt    error;
+    TRadix  radix = EDecimal;
+    TLex16  lex;
+    TTestReadStatus readStatus = ETestUnknown;
+    CMmsAttaStructure* oneAtta = NULL;
+	TInt    index;
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    TTime date;
+    TInt order = 0;
+    TInt16 shortInteger = 0;
+
+    //iso luuppi, joka kiertää ja lukee kunnes EOF tule vastaan
+    //Big Loop, which passes around and read until the EOF
+
+    iMessageType = iNextMessageType;
+    while(readStatus != ETestEof)
+        {
+        readStatus = ReadRowL();
+        if ( readStatus ==  ETestEof )
+            {
+            return(-1);
+            }
+        if ( readStatus == ETestUnknown )
+            {
+            // A line containing only comments, or an unknown tag
+            // As using the scripts to test settings is no longer supported,
+            // any old keywords used to test CMmsSettings class are ignored
+            continue;
+            }
+        if( readStatus == ETestNewMessage )
+            {
+            iNextMessageType = readStatus;
+            if(aMessageCounter++)
+                {
+                return(NULL);
+                }
+            else
+                {
+                iMessageType = iNextMessageType;
+                continue;
+                }
+            }
+        if ( iMessageType == ETestNewMessage)
+            {
+            switch(readStatus)
+                {
+                case ETestFrom:
+                    aMmsHeaders.SetSenderL( iValueBuffer );
+                    break;
+                case ETestFromAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.SetSenderL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ) );
+	    				}
+                    break;
+                case ETestTo:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientTo );
+                    break;
+                case ETestToAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsTo );
+						}
+                    break;
+                case ETestCc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientCc );
+                    break;
+                case ETestCcAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsCc );
+						}
+                    break;
+                case ETestBcc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientBcc );
+                    break;
+                case ETestBccAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsBcc );
+						}
+                    break;
+                case ETestSubject:
+                    aMmsHeaders.SetSubjectL( iValueBuffer );
+                    break;
+                case ETestExpiryRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetExpiryInterval( val );
+                        }
+                    break;
+                case ETestExpiryAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    // expiry date in seconds from 1.1.1970.
+                    aMmsHeaders.SetExpiryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDeliveryTimeRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetDeliveryTimeInterval( val );
+                        }
+                    break;
+                case ETestDeliveryTimeAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDeliveryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDate:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDate( (interval.Int64())/1000000 );
+                case ETestPriority:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KLow)) == 0)
+                        {
+                        val = EMmsPriorityLow;
+                        }
+                    else if ((iValueBuffer.CompareF(KNormal)) == 0)
+                        {
+                        val = EMmsPriorityNormal;
+                        }
+                    else if ((iValueBuffer.CompareF(KHigh)) == 0)
+                        {
+                        val = EMmsPriorityHigh;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessagePriority( val );
+                    break;
+                case ETestSenderVisibility:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KHide)) == 0)
+                        {
+                        val = EMmsSenderVisibilityHide;
+                        }
+                    else if ((iValueBuffer.CompareF(KShow)) == 0)
+                        {
+                        val = EMmsSenderVisibilityShow;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetSenderVisibility( val );
+                    break;
+                case ETestDeliveryReport:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDeliveryReport( val );
+                    break;
+                case ETestDelivReportSendAllow:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReportAllowed( val );
+                    break;
+
+                case ETestReadReply:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadReply( val );
+                    break;
+                case ETestNewAttachment:
+                    oneAtta = CMmsAttaStructure::NewL();
+                    iAttaStructures->AppendL(oneAtta);
+                    oneAtta->iAtta->Des().Copy( iValueBuffer );
+                    iAttaCount++;
+                    break;
+                case ETestAttachmentType:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaType->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentContLoc:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttaRecommendedName:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaRecommendedName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentCharset:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        if (oneAtta != NULL)
+                            {
+                            oneAtta->iAttaCharset = val;
+                            }
+                        }
+                    break;
+                case ETestAttachmentCid:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaCid->Des().Copy(iValueBuffer);
+                        }
+                    break;
+                case ETestAttContTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttContTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttachmentRoot:
+                    iAttaRoot = iAttaCount;
+                    break;
+                case ETestAlias:
+                    // all aliases are global even if they appear
+                    // in the middle of a message
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+                case ETestMessageClass: // should be handled!
+                    val = EMmsClassPersonal;
+                    if ((iValueBuffer.CompareF(KPersonal)) == 0)
+                        {
+                        val = EMmsClassPersonal;
+                        }
+                    else if ((iValueBuffer.CompareF(KAdvertisement)) == 0)
+                        {
+                        val = EMmsClassAdvertisement;
+                        }
+                    else if ((iValueBuffer.CompareF(KInformational)) == 0)
+                        {
+                        val = EMmsClassInformational;
+                        }
+                    else if ((iValueBuffer.CompareF(KAuto)) == 0)
+                        {
+                        val = EMmsClassAuto;
+                        }
+                    else
+                        {
+                        val = (TMmsMessageClass)KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageClass( val );
+                    break;
+                case ETestReplyCharging:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRequested)) == 0)
+                        {
+                        val = KMmsReplyChargingRequested;
+                        }
+                    else if ((iValueBuffer.CompareF(KReqTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingRequestedTextOnly;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccepted)) == 0)
+                        {
+                        val = KMmsReplyChargingAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingAcceptedTextOnly;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReplyCharging( val );
+                    break;
+                case ETestReplyChargAbs:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.SetReplyChargingDate( (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestReplyChargRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingInterval( val );
+                        }
+                    break;
+                case ETestReplyChargSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingSize( val );
+                        }
+                    break;
+                case ETestReplyChargID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplyChargingIdL( iByteBuffer->Des() );
+                    break;
+                case ETestTID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetTidL( iByteBuffer->Des() );
+                    break;
+                case ETestContentLocation:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteReq )
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().ContentLocationList().AppendL( iByteBuffer->Des() );
+                        }
+                    else if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteContentLocationL( order, iByteBuffer->Des() );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetContentLocationL( iByteBuffer->Des() );
+                        }
+                    break;
+                case ETestPreviouslySentIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+                case ETestPreviouslySentBy:
+                    aMmsHeaders.InsertPreviouslySentByL( order, iValueBuffer );
+                    break;
+                case ETestPreviouslySentDate:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.InsertPreviouslySentDateL( order, (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestMessageId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetMessageIdL( iByteBuffer->Des() );
+                    break;
+                case ETestMessageSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMessageSize( val );
+                        }
+                    break;
+                case ETestVersion:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,EHex,limit);
+                    shortInteger = TInt16( val );
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMmsVersion( shortInteger );
+                        }
+                    break;
+                case ETestReadStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRead)) == 0)
+                        {
+                        val = KMmsReadStatusRead;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelNotRead)) == 0)
+                        {
+                        val = KMmsReadStatusDeletedWithoutBeingRead;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadStatus( val );
+                    break;
+                case ETestResponseStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnspecified)) == 0)
+                        {
+                        val = KMmsErrorUnspecified;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageNotFound)) == 0)
+                        {
+                        val = KMmsErrorMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrNetworkProblem)) == 0)
+                        {
+                        val = KMmsErrorNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorNoContentAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnsupportedMessage)) == 0)
+                        {
+                        val = KMmsErrorUnsupportedMessage;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorTransientSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorPermanentSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentContentNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingLimitNotMet)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingLimitationsNotMet;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingRequestNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingRequestNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingForwardingDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingForwardingDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingNotSupported;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientPartialSuccess)) == 0)
+                        {
+                        val = KMmsErrorTransientPartialSuccess;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressHidingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentAddressHidingNotSupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteStatusL( order, val );
+                        }
+                    else
+                        {
+                         aMmsHeaders.SetResponseStatus( val );
+                        }
+                    break;
+                case ETestResponseText:
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteResponseTextL( order, iValueBuffer );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetResponseTextL( iValueBuffer );
+                        }
+                    break;
+                case ETestRetrieveStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrRetrieveContentUnsupported)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentContentUnsupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetResponseStatus( val );
+                    break;
+                case ETestRetrieveText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDeferred)) == 0)
+                        {
+                        val = KMmsMessageStatusDeferred;
+                        }
+                    else if ((iValueBuffer.CompareF(KExpired)) == 0)
+                        {
+                        val = KMmsMessageStatusExpired;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsMessageStatusRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KRejected)) == 0)
+                        {
+                        val = KMmsMessageStatusRejected;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnrecognized)) == 0)
+                        {
+                        val = KMmsMessageStatusUnrecognized;
+                        }
+                    else if ((iValueBuffer.CompareF(KIndeterminate)) == 0)
+                        {
+                        val = KMmsMessageStatusIndeterminate;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsMessageStatusForwarded;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnreachable)) == 0)
+                        {
+                        val = KMmsMessageStatusUnreachable;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetStatus( val );
+                    break;
+                case ETestMessageType:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KSendReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KSendConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifInd)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotificationInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifResp)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotifyRespInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMRetrieveConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KAckInd)) == 0)
+                        {
+                        val = KMmsMessageTypeAcknowledgeInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelInd)) == 0)
+                        {
+                        val = KMmsMessageTypeDeliveryInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadReqInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadRecInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadOrigInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadOrigInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardRec)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardConf)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDescr)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDescr;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelReq)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelResp)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelConf;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageType( val );
+                    break;
+                case ETestAttribute:
+                    val = 0;
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ((iByteBuffer->Des().CompareF(KTestBcc)) == 0)
+                        {
+                        val = KMmsAssignedBcc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestCc)) == 0)
+                        {
+                        val = KMmsAssignedCc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContent)) == 0)
+                        {
+                        val = KMmsAssignedContent;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContentType)) == 0)
+                        {
+                        val = KMmsAssignedContentType;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDate)) == 0)
+                        {
+                        val = KMmsAssignedDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryReport)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryReport;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryTime)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryTime;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestExpiry)) == 0)
+                        {
+                        val = KMmsAssignedExpiry;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestFrom)) == 0)
+                        {
+                        val = KMmsAssignedFrom;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageClass)) == 0)
+                        {
+                        val = KMmsAssignedMessageClass;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageId)) == 0)
+                        {
+                        val = KMmsAssignedMessageId;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageSize)) == 0)
+                        {
+                        val = KMmsAssignedMessageSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPriority)) == 0)
+                        {
+                        val = KMmsAssignedPriority;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReadReply)) == 0)
+                        {
+                        val = KMmsAssignedReadReply;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestSubject)) == 0)
+                        {
+                        val = KMmsAssignedSubject;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestTo)) == 0)
+                        {
+                        val = KMmsAssignedTo;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharging)) == 0)
+                        {
+                        val = KMmsAssignedReplyCharging;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargID)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingID;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharg)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingDeadline;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargSize)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentBy)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentBy;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentDate)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestAdditionalHeaders)) == 0)
+                        {
+                        val = KMmsAssignedAdditionalHeaders;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().AttributeArray().InsertInOrder(val);
+                    break;
+                case ETestDistributionIndicator:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDistributionIndicator( val );
+                    break;
+                case ETestLimit:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if( error == KErrNone )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(val);
+                        }
+                    break;
+                case ETestMessageQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(val);
+                        }
+                    break;
+                case ETestSizeQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(val);
+                        }
+                    break;
+                case ETestMessageTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(val);
+                        }
+                    break;
+                case ETestSizeTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(val);
+                        }
+                    break;
+                case ETestMessageCount:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(val);
+                        }
+                    break;
+                case ETestAddKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsAddToken, iValueBuffer);
+                    break;
+                case ETestRemoveKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsRemoveToken, iValueBuffer);
+                    break;
+                case ETestFilterKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsFilterToken, iValueBuffer);
+                    break;
+                case ETestMMState:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDraft)) == 0)
+                        {
+                        val = KMmsDraft;
+                        }
+                    else if ((iValueBuffer.CompareF(KSent)) == 0)
+                        {
+                        val = KMmsSent;
+                        }
+                    else if ((iValueBuffer.CompareF(KNew)) == 0)
+                        {
+                        val = KMmsNew;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsForwarded;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().MMStateArray().InsertInOrder( val );
+                        }
+                    else
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().SetMMState( val );
+                        }
+                    break;
+                case ETestQuota:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsQuotas( val );
+                    break;
+                case ETestStart:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsStart(val);
+                        }
+                    break;
+                case ETestStore:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStore( val );
+                    break;
+                case ETestStored:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStored( val );
+                    break;
+                case ETestStoreStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMMBoxFull)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMmboxFull;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatus( val );
+                    break;
+                case ETestStoreStatusText:
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatusTextL( iValueBuffer );
+                    break;
+                case ETestTotals:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsTotals( val );
+                    break;
+
+                case ETestDeleteInfoIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+
+                case ETestApplicId:
+                    aMmsHeaders.SetApplicIdL( iValueBuffer );
+                    break;
+                case ETestReplyApplicId:
+                    aMmsHeaders.SetReplyApplicIdL( iValueBuffer );
+                    break;
+                case ETestApplicInfo:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetAuxApplicInfoL( iByteBuffer->Des() );
+                    break;
+                case ETestContentClass:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KText)) == 0)
+                        {
+                        val = KMmsContentClassText;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageBasic)) == 0)
+                        {
+                        val = KMmsContentClassImageBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageRich)) == 0)
+                        {
+                        val = KMmsContentClassImageRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoBasic)) == 0)
+                        {
+                        val = KMmsContentClassVideoBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoRich)) == 0)
+                        {
+                        val = KMmsContentClassVideoRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KMegaPixel)) == 0)
+                        {
+                        val = KMmsContentClassMegaPixel;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentBasic)) == 0)
+                        {
+                        val = KMmsContentClassContentBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentRich)) == 0)
+                        {
+                        val = KMmsContentClassContentRich;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetContentClass( val );
+                    break;
+                case ETestDrmContent:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDrmContent( val );
+                    break;
+                case ETestAdaptationAllowed:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetAdaptationAllowed( val );
+                    break;
+                case ETestRecommendedRetrievalMode:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KManual)) == 0)
+                        {
+                        val = KMmsRecommendedRetrievalModeManual;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetRecommendedRetrievalMode( val );
+                    break;
+                case ETestRecRetrievalModeText:
+                    aMmsHeaders.SetRecommendedRetrievalModeTextL( iValueBuffer );
+                    break;
+                case ETestReplaceId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestStatusText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestCancelId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestCancelStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KCancelSuccessful)) == 0)
+                        {
+                        val = KMmsCancelRequestSuccessfullyReceived;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelCorrupted)) == 0)
+                        {
+                        val = KMmsCancelRequestCorrupted;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetCancelStatus( val );
+                    break;
+                default:
+                    break;
+                }
+            }
+            else
+            {
+            switch(readStatus)
+                {
+                case ETestAlias:
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+
+                default:
+                    break;
+                }
+
+            }
+        }
+    return(-1);
+}
+
+// ---------------------------------------------------------
+// CMmsReadFile()::ReadRowL
+// ---------------------------------------------------------
+//
+TTestReadStatus CMmsReadFile::ReadRowL()
+    {
+
+        TBuf8<DefaultBufLen> RowBuffer;
+        TBuf8<32> KeyBuffer;
+
+        // READ ONE ROW AND DROP CR+LF FROM THE END OF LINE
+        TChar delim( 10 );
+        iReader->ReadL( RowBuffer, delim);
+        TInt length = RowBuffer.Length();
+        if ( RowBuffer.Length() < 2 )
+            {
+            return ETestEof;
+            }
+        RowBuffer.Delete(length - 2,2);
+
+        // DROP POSSIBLE COMMENT OUT
+        TInt pos = RowBuffer.Locate( ';' );
+		if ( pos >= 0 ) RowBuffer.Delete( pos, length-pos-2 );
+
+        if ( RowBuffer.Length() == 0 )
+            {
+            // the line contained only comment
+            return ETestUnknown;
+            }
+
+        // First split the row (:)
+        pos = RowBuffer.Locate( ':' );
+        if (pos > 0)
+        {
+            TPtrC8 p = RowBuffer.Mid( pos+1 );
+            length = p.Length();
+            iValueBuffer.Zero();
+            for (TInt i=0; i < length; ++i)
+                {
+                iValueBuffer.Append(p[i]);
+                }
+            iValueBuffer.Trim();
+            TPtrC8 pp = RowBuffer.Left(pos);
+            KeyBuffer.CopyUC(pp);
+            KeyBuffer.Trim();
+        }
+        // TRY TO FIND CORRECT TAG
+        if ((KeyBuffer.CompareF(KTestNewMessage)) == 0) return(ETestNewMessage);
+        if ((KeyBuffer.CompareF(KTestMessageType)) == 0) return ETestMessageType;
+        if ((KeyBuffer.CompareF(KTestDate)) == 0) return ETestDate;
+        if ((KeyBuffer.CompareF(KTestFrom)) == 0) return ETestFrom;
+        if ((KeyBuffer.CompareF(KTestTo)) == 0) return ETestTo;
+        if ((KeyBuffer.CompareF(KTestCc)) == 0) return ETestCc;
+        if ((KeyBuffer.CompareF(KTestBcc)) == 0) return ETestBcc;
+        if ((KeyBuffer.CompareF(KTestSubject)) == 0) return ETestSubject;
+        if ((KeyBuffer.CompareF(KTestExpiryRel)) == 0) return ETestExpiryRel;
+        if ((KeyBuffer.CompareF(KTestExpiryAbs)) == 0) return ETestExpiryAbs;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeRel)) == 0) return ETestDeliveryTimeRel;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeAbs)) == 0) return ETestDeliveryTimeAbs;
+        if ((KeyBuffer.CompareF(KTestPriority)) == 0) return ETestPriority;
+        if ((KeyBuffer.CompareF(KTestSenderVisibility)) == 0) return ETestSenderVisibility;
+        if ((KeyBuffer.CompareF(KTestDeliveryReport)) == 0) return ETestDeliveryReport;
+        if ((KeyBuffer.CompareF(KTestReadReply)) == 0) return ETestReadReply;
+        if ((KeyBuffer.CompareF(KTestNewAttachment)) == 0) return ETestNewAttachment;
+        if ((KeyBuffer.CompareF(KTestAttachmentName)) == 0) return ETestAttaRecommendedName;
+        if ((KeyBuffer.CompareF(KTestAttachmentContLoc)) == 0) return ETestAttachmentContLoc;
+        if ((KeyBuffer.CompareF(KTestAttachmentType)) == 0) return ETestAttachmentType;
+        if ((KeyBuffer.CompareF(KTestAttachmentCharset)) == 0) return ETestAttachmentCharset;
+        if ((KeyBuffer.CompareF(KTestAttachmentCid)) == 0) return ETestAttachmentCid;
+        if ((KeyBuffer.CompareF(KTestAttachmentRoot)) == 0) return ETestAttachmentRoot;
+        if ((KeyBuffer.CompareF(KTestEndOfFile)) == 0) return ETestEof;
+        if ((KeyBuffer.CompareF(KTestMessageClass)) == 0) return ETestMessageClass;
+        if ((KeyBuffer.CompareF(KTestDelivRepSendAllow)) == 0) return ETestDelivReportSendAllow;
+        if ((KeyBuffer.CompareF(KTestAlias)) == 0 ) return ETestAlias;
+        if ((KeyBuffer.CompareF(KTestFromAlias)) == 0 ) return ETestFromAlias;
+        if ((KeyBuffer.CompareF(KTestToAlias)) == 0 ) return ETestToAlias;
+        if ((KeyBuffer.CompareF(KTestCcAlias)) == 0 ) return ETestCcAlias;
+        if ((KeyBuffer.CompareF(KTestBccAlias)) == 0 ) return ETestBccAlias;
+        if ((KeyBuffer.CompareF(KTestReplyCharging)) == 0 ) return ETestReplyCharging;
+        if ((KeyBuffer.CompareF(KTestReplyChargAbs)) == 0 ) return ETestReplyChargAbs;
+        if ((KeyBuffer.CompareF(KTestReplyChargRel)) == 0 ) return ETestReplyChargRel;
+        if ((KeyBuffer.CompareF(KTestReplyChargSize)) == 0 ) return ETestReplyChargSize;
+        if ((KeyBuffer.CompareF(KTestReplyChargID)) == 0 ) return ETestReplyChargID;
+        if ((KeyBuffer.CompareF(KTestTID)) == 0 ) return ETestTID;
+        if ((KeyBuffer.CompareF(KTestContentLocation)) == 0 ) return ETestContentLocation;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentIndex)) == 0 ) return ETestPreviouslySentIndex;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentBy)) == 0 ) return ETestPreviouslySentBy;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentDate)) == 0 ) return ETestPreviouslySentDate;
+        if ((KeyBuffer.CompareF(KTestMessageId)) == 0 ) return ETestMessageId;
+        if ((KeyBuffer.CompareF(KTestMessageSize)) == 0 ) return ETestMessageSize;
+        if ((KeyBuffer.CompareF(KTestVersion)) == 0 ) return ETestVersion;
+        if ((KeyBuffer.CompareF(KTestReadStatus)) == 0 ) return ETestReadStatus;
+        if ((KeyBuffer.CompareF(KTestResponseStatus)) == 0 ) return ETestResponseStatus;
+        if ((KeyBuffer.CompareF(KTestResponseText)) == 0 ) return ETestResponseText;
+        if ((KeyBuffer.CompareF(KTestRetrieveStatus)) == 0 ) return ETestRetrieveStatus;
+        if ((KeyBuffer.CompareF(KTestRetrieveText)) == 0 ) return ETestRetrieveText;
+        if ((KeyBuffer.CompareF(KTestStatus)) == 0 ) return ETestStatus;
+        if ((KeyBuffer.CompareF(KTestAttribute)) == 0 ) return ETestAttribute;
+        if ((KeyBuffer.CompareF(KTestDistributionIndicator)) == 0 ) return ETestDistributionIndicator;
+        if ((KeyBuffer.CompareF(KTestLimit)) == 0 ) return ETestLimit;
+        if ((KeyBuffer.CompareF(KTestMessageQuota)) == 0 ) return ETestMessageQuota;
+        if ((KeyBuffer.CompareF(KTestSizeQuota)) == 0 ) return ETestSizeQuota;
+        if ((KeyBuffer.CompareF(KTestMessageTotal)) == 0 ) return ETestMessageTotal;
+        if ((KeyBuffer.CompareF(KTestSizeTotal)) == 0 ) return ETestSizeTotal;
+        if ((KeyBuffer.CompareF(KTestMessageCount)) == 0 ) return ETestMessageCount;
+        if ((KeyBuffer.CompareF(KTestAddKeyword)) == 0 ) return ETestAddKeyword;
+        if ((KeyBuffer.CompareF(KTestRemoveKeyword)) == 0 ) return ETestRemoveKeyword;
+        if ((KeyBuffer.CompareF(KTestFilterKeyword)) == 0 ) return ETestFilterKeyword;
+        if ((KeyBuffer.CompareF(KTestMMState)) == 0 ) return ETestMMState;
+        if ((KeyBuffer.CompareF(KTestQuota)) == 0 ) return ETestQuota;
+        if ((KeyBuffer.CompareF(KTestStart)) == 0 ) return ETestStart;
+        if ((KeyBuffer.CompareF(KTestStore)) == 0 ) return ETestStore;
+        if ((KeyBuffer.CompareF(KTestStored)) == 0 ) return ETestStored;
+        if ((KeyBuffer.CompareF(KTestStoreStatus)) == 0 ) return ETestStoreStatus;
+        if ((KeyBuffer.CompareF(KTestStoreStatusText)) == 0 ) return ETestStoreStatusText;
+        if ((KeyBuffer.CompareF(KTestTotals)) == 0 ) return ETestTotals;
+        if ((KeyBuffer.CompareF(KTestDeleteInfoIndex)) == 0 ) return ETestDeleteInfoIndex;
+        if ((KeyBuffer.CompareF(KTestApplicId)) == 0 ) return ETestApplicId;
+        if ((KeyBuffer.CompareF(KTestReplyApplicId)) == 0 ) return ETestReplyApplicId;
+        if ((KeyBuffer.CompareF(KTestApplicInfo)) == 0 ) return ETestApplicInfo;
+        if ((KeyBuffer.CompareF(KTestContentClass)) == 0 ) return ETestContentClass;
+        if ((KeyBuffer.CompareF(KTestDrmContent)) == 0 ) return ETestDrmContent;
+        if ((KeyBuffer.CompareF(KTestAdaptationAllowed)) == 0 ) return ETestAdaptationAllowed;
+        if ((KeyBuffer.CompareF(KTestRecommendedRetrievalMode)) == 0 ) return ETestRecommendedRetrievalMode;
+        if ((KeyBuffer.CompareF(KTestRecRetrievalModeText)) == 0 ) return ETestRecRetrievalModeText;
+        if ((KeyBuffer.CompareF(KTestReplaceId)) == 0 ) return ETestReplaceId;
+        if ((KeyBuffer.CompareF(KTestStatusText)) == 0 ) return ETestStatusText;
+        if ((KeyBuffer.CompareF(KTestCancelId)) == 0 ) return ETestCancelId;
+        if ((KeyBuffer.CompareF(KTestCancelStatus)) == 0 ) return ETestCancelStatus;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamName)) == 0 ) return ETestAttContTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamValue)) == 0 ) return ETestAttContTypeParamValue;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamName)) == 0 ) return ETestAttXTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamValue)) == 0 ) return ETestAttXTypeParamValue;
+        return ETestUnknown;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CreateMessageL
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+void CMmsReadFile::CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders )
+    {
+
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+
+    TInt      i;
+    TInt error = KErrNone;
+    RFile attaFile;
+    _LIT8(KLeftAngle, "<");
+    _LIT8(KRightAngle, ">");
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+
+    CMsvStore* store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    aMmsHeaders->StoreL(*store);
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    aMmsClient->LoadMessageL(); // read store is needed to do this
+
+    store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    CMsvAttachment* attaInfo = NULL;
+    TMsvAttachmentId attaId = 0;
+
+    for ( i=0; i < iAttaStructures->Count(); ++i)
+        {
+        attaId = KMsvNullIndexEntryId;
+        iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+
+        error = attaFile.Open( iFs, iFilename, EFileShareReadersOnly | EFileRead );
+        User::LeaveIfError( error );
+
+		CleanupClosePushL(attaFile);
+
+		CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+		CleanupStack::PushL( mimeHeaders );
+		TPtrC8 contentType = iAttaStructures->At(i)->iAttaType->Des();
+
+        TDataRecognitionResult result;
+        result.Reset(); // make sure that it is cleared
+
+        if(iAttaStructures->At(i)->iAttaCid->Length())
+            {
+            TPtr8 attaCID = iAttaStructures->At(i)->iAttaCid->Des();
+            if (attaCID.Find(KLeftAngle) == 0 &&
+                attaCID.Find(KRightAngle) == attaCID.Length()-1 )
+                {
+                // remove angle brackets from cid
+                attaCID = attaCID.Mid(1,attaCID.Length()-2);
+                }
+            mimeHeaders->SetContentIdL(attaCID);
+            }
+
+        if (iAttaStructures->At(i)->iAttaCharset)
+            {
+            mimeHeaders->SetMimeCharset(iAttaStructures->At(i)->iAttaCharset);
+            }
+
+        if (iAttaStructures->At(i)->iAttaName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaName->Des());
+            }
+        iParse.Set( iFilename, NULL, NULL );
+        iFilename.Copy( iParse.NameAndExt() );
+
+        mimeHeaders->SetContentLocationL( iFilename );
+
+		// if Mime type has not been set, use RapaRecognizer
+		if ( iAttaStructures->At(i)->iAttaType->Length() == 0 && iFilename.Length() > 0)
+		    {
+		    // TO BE IMPLEMENTED
+
+            RApaLsSession lsSession;
+
+            if ( lsSession.Connect() == KErrNone )
+                {
+                CleanupClosePushL( lsSession );
+
+                iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+                if ( lsSession.RecognizeData( iFilename, TPtrC8(), result ) == KErrNone )
+                    {
+                    // Check confidence level. Recognization must be at least
+                    // "EProbable". We don't accept the result if it is "EPossible"
+                    // or "EUnlikely" or "ENotRecognized"!
+
+                    if ( result.iConfidence < CApaDataRecognizerType::EProbable )
+                        {
+                        result.Reset(); // clear buffer and try again with longer buffer
+                        }
+
+                    TPtrC8 mimeBuf8 = result.iDataType.Des8();
+
+                    if ( mimeBuf8.Length() == 0 )
+                        {
+                        // Open file buffer and try again..
+
+                        TInt bufSize = 0;
+                        (void)lsSession.GetMaxDataBufSize( bufSize ); // ignore errors
+                        if ( bufSize <= 0 )
+                            {
+                            bufSize = 30;
+                            }
+                        HBufC8* buf = HBufC8::NewLC( bufSize );
+                        TPtr8 des = buf->Des();
+
+                        RFile file;
+                        TInt err=file.Open( iFs, iFilename, EFileShareReadersOnly );
+                        if ( err == KErrNone )
+                            {
+                            err = file.Read( des );
+                            file.Close();
+                            if ( err == KErrNone )
+                                {
+                                if ( ( lsSession.RecognizeData( iFilename, des, result ) ) == KErrNone )
+                                    {
+                                    mimeBuf8.Set( result.iDataType.Des8() );
+                                    }
+                                }
+
+                            }
+                        CleanupStack::PopAndDestroy(); // buf
+                        }
+                    if ( mimeBuf8.Length() > 0 &&
+                        result.iConfidence >= CApaDataRecognizerType::EProbable )
+                        {
+                        contentType.Set( result.iDataType.Des8() );
+                        }
+                    }
+                CleanupStack::PopAndDestroy(1); // lssession
+                }
+		    }
+
+        if ( contentType.Length() > 0 )
+            {
+            TInt position = contentType.Find( KMmsSlash8 );
+            if ( position >= 0 )
+                {
+                mimeHeaders->SetContentTypeL( contentType.Left( position ) );
+                }
+            if ( position < contentType.Length() - 1 )
+                {
+                mimeHeaders->SetContentSubTypeL( contentType.Mid( position + 1 ) );
+                }
+//          CreateAttachment2L sets the content type to attaInfo
+//            attaInfo->SetMimeTypeL( contentType );
+            }
+
+        if (iAttaStructures->At(i)->iAttaRecommendedName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaRecommendedName->Des());
+            iParse.Set( iFilename, NULL, NULL );
+            iFilename.Copy( iParse.NameAndExt() );
+            mimeHeaders->SetSuggestedFilenameL( iFilename );
+            }
+
+        TInt j = 0;
+        for ( j = 0; j < iAttaStructures->At(i)->iContentTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->ContentTypeParams().AppendL( iAttaStructures->At(i)->iContentTypeParams->MdcaPoint( j ) );
+            }
+        for ( j = 0; j < iAttaStructures->At(i)->iXTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->XTypeParams().AppendL( iAttaStructures->At(i)->iXTypeParams->MdcaPoint( j ) );
+            }
+
+        attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
+        // attaInfo does not go onto cleaunpstack because ownership will
+        // be transferred to attachment manager.
+
+        aMmsClient->CreateAttachment2L(
+            *store,
+            attaFile,
+            contentType,
+            *mimeHeaders,
+            attaInfo,
+            attaId);
+        attaInfo = NULL; // ownership transferred
+
+        CleanupStack::PopAndDestroy(); // mimeHeaders
+        CleanupStack::PopAndDestroy(); // attaFile.Close()
+
+        if ( iAttaRoot > 0 && iAttaRoot == ( i + 1 ) )
+            {
+            aMmsClient->SetMessageRootL( attaId );
+            }
+        }
+
+    store->CommitL();
+    CleanupStack::PopAndDestroy(); // store
+
+    // This frees all memory and resets all values
+    Reset();
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+    }
+
+
+// ---------------------------------------------------------
+// CMmsReadFile()::FindAlias
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::FindAlias( TPtrC aAlias )
+    {
+	TBuf<DefaultBufLen> abuf;
+	for( TInt i=0; i < iAliasCount; ++i )
+	    {
+		abuf.Copy( iAliasArray->MdcaPoint(i) );
+		abuf.SetLength( abuf.Locate('=') );
+		if( ( abuf.CompareF( aAlias ) ) == 0 ) return( i );
+	    }
+	return( -1 );
+    }
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsAttaStructure::CMmsAttaStructure()
+    {
+    iAtta = NULL;
+    iAttaType = NULL;
+    iAttaName = NULL;
+    iAttaCid = NULL;
+    iAttaRecommendedName = NULL;
+    }
+
+
+//
+void CMmsAttaStructure::ConstructL()
+    {
+    iAtta = HBufC8::NewL(DefaultBufLen);
+    iAttaType = HBufC8::NewL(DefaultBufLen);
+    iAttaName = HBufC8::NewL(DefaultBufLen);
+    iAttaCid = HBufC8::NewL(DefaultBufLen);
+    iAttaRecommendedName = HBufC::NewL(DefaultBufLen);
+    iAttaCharset = 0;
+   	iXTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+   	iContentTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+
+    }
+
+// Two-phased constructor.
+CMmsAttaStructure* CMmsAttaStructure::NewL()
+    {
+    CMmsAttaStructure* self = new ( ELeave ) CMmsAttaStructure;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// Destructor
+CMmsAttaStructure::~CMmsAttaStructure()
+    {
+    delete iAtta;
+    delete iAttaName;
+    delete iAttaType;
+    delete iAttaCid;
+    delete iAttaRecommendedName;
+    if ( iContentTypeParams )
+        {
+    	iContentTypeParams->Reset();
+        }
+  	delete iContentTypeParams;
+    if ( iXTypeParams )
+        {
+      	iXTypeParams->Reset();
+        }
+	delete iXTypeParams;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestbed.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,2357 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <mtmdef.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <mmsheaders.h>
+#include <mmscmds.h>
+#include <mmsencode.h>
+#include <mmscliententry.h>
+#include <logwrap.h>
+#include <logcli.h>
+#include <logview.h>
+#include "mmssettings.h"  //use mmssettings.h instead of cmmssettings.h
+#include "mmstestbed.h"
+#include "mmsreadfile.h"
+#include "mmstestuitimer.h"
+#include "mmsteststaticutils.h"
+#include "mmstestbed.hrh"
+
+//constants
+_LIT( KMmsSender, "0601234567" );
+
+MmsTestBed::MmsTestBed()
+    {
+    //start the timer
+    iTimer = CTestUiTimer::NewL();
+    iTimer->Cancel();
+
+    iWait = CMsvOperationActiveSchedulerWait::NewLC();
+    // don't leave iWait on cleanup stack
+    CleanupStack::Pop();
+
+    //open msvsession
+    iSession = CMsvSession::OpenSyncL(*this);
+    //create client registry
+    iClientMtmRegistry = CClientMtmRegistry::NewL(*iSession);
+    //create client mtm
+    iMmsClient = (CMmsClientMtm *) iClientMtmRegistry->NewMtmL(
+            KUidMsgTypeMultimedia);
+
+    User::LeaveIfError( iFs.Connect() );
+    iFs.SetSessionPath( KRootPath );
+    iSettings = CMmsSettings::NewL();
+    iMmsHeaders = CMmsHeaders::NewL(iSettings->MmsVersion());
+    findDefaultL();
+    iServiceId = iDefaultServiceId;
+
+    //validate the settings
+    iSettings->ValidateSettings();
+
+    iLogEvent = CLogEvent::NewL();
+    iLogEvent->SetEventType(KLogMmsEventTypeUid);
+    iLogClient = NULL; // we test soon if this is available
+    iLogView = NULL; // needs log client
+    if ( checkLogClient() )
+        {
+        // first we generate a general view of all events
+        // we'll set the filter when we update the view
+        iLogView = CLogViewEvent::NewL( *iLogClient );
+        }
+    iLogFilter = CLogFilter::NewL();
+    // we try to filter MMS events
+    iLogFilter->SetEventType(KLogMmsEventTypeUid);
+    }
+
+MmsTestBed::~MmsTestBed()
+    {
+    delete iLogView;
+    delete iLogFilter;
+    delete iLogClient;
+    delete iLogEvent;
+    delete iSettings;
+    delete iMmsHeaders;
+    if(iTimer)
+    {
+        iTimer->Cancel();
+        delete iTimer;
+    }
+    //delete iMsvEntrySelection;
+    delete iMmsClient;
+    delete iClientMtmRegistry;
+    //delete iClientMtmRegistry;
+    delete iSession;
+    delete iWait;
+    }
+
+void MmsTestBed::setConnectionLocal(bool value)
+    {
+    //value = true for global off, local on
+    //value = false for global on, local off
+    iSettings->LoadSettingsL();
+    iSettings->SetLocalMode( value );
+    iSettings->SaveSettingsL();
+    }
+
+void MmsTestBed::fromOutboxToMmsc()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    // Get List of services
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL(
+            KUidMsgTypeMultimedia);
+    CleanupStack::PushL(selection);
+
+    // Change state to "KMsvSendStateUnknown" in case the entry has been suspended earlier
+    for (TInt i = 0; i < selection->Count(); ++i)
+        {
+        cEntry->SetEntryL(selection->At(i));
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly(EFalse);
+        entry.SetSendingState(KMsvSendStateUnknown);
+        cEntry->ChangeL(entry);
+        }
+
+    selection->InsertL(0, iServiceId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iSession->TransferCommandL(*selection, EMmsSend, paramPack,
+            iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    CleanupStack::PopAndDestroy(); //cEntry
+    }
+
+void MmsTestBed::fromMmscToInbox()
+    {
+    CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+    CleanupStack::PushL(msvEntrySelection);
+
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        msvEntrySelection->InsertL(0, iServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iMmsClient->InvokeAsyncFunctionL(EMmsReceive, *msvEntrySelection,
+            paramPack, iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to receive, return status %d"),iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); //msvEntrySelection
+    }
+
+void MmsTestBed::findDefaultL()
+    {
+    iSettings->LoadSettingsL();
+    iDefaultServiceId = iSettings->Service();
+    }
+
+void MmsTestBed::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+        TAny* aArg2, TAny* /*aArg3*/)
+    {
+    iEvent = aEvent;
+    if (aEvent == EMsvGeneralError)
+        {
+        return;
+        }
+    TMsvId parentId = KMsvNullIndexEntryId;
+    if (aArg2 != NULL)
+        {
+        parentId = *(TMsvId*) aArg2;
+        }
+
+    CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+    TMsvEntry tEntry;
+    TMsvId service;
+    TInt error = KErrNone;
+    error = iSession->GetEntry(selection->At(0), service, tEntry);
+
+    CMsvEntry* cEntry = NULL;
+    switch (aEvent)
+        {
+        case EMsvEntriesCreated:
+            {
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+                // emit signal for new entry into INBOX
+                emit entryCreatedInInbox(tEntry.Id());
+                }
+            else if (parentId == KMsvDraftEntryIdValue)
+                {
+                // emit signal for new entry into Draft
+                emit entryCreatedInDraft(tEntry.Id());
+                }
+            else if (parentId == iServiceId)
+                {
+                // emit signal for new Entry into SERVICE
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        case EMsvEntriesChanged:
+            {
+            TMsvId id;
+            CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+            if (selection == NULL)
+                {
+                // no selection, cannot handle
+                return;
+                }
+            id = selection->At(0);
+            //DEBUG Entry changed"));
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+/*
+                cEntry = iSession->GetEntryL( parentId );
+                CleanupStack::PushL( cEntry );
+                TRAPD (error, cEntry->SetEntryL( id ));
+                if ( error != KErrNone )
+                    {
+                    CleanupStack::PopAndDestroy(); // cEntry
+                    return;
+                    }
+                TMsvEntry tEntry = cEntry->Entry();
+                if ( tEntry.Visible() )
+                    {
+                    // generate fake delivery report
+                    CMsvStore* store = cEntry->ReadStoreL();
+                    CleanupStack::PushL( store );
+                    CMmsHeaders* mmsHeaders = CMmsHeaders::NewL( iSettings->MmsVersion() );
+                    CleanupStack::PushL( mmsHeaders );
+                    mmsHeaders->RestoreL( *store );
+                    iEncodeBuffer->ResizeL( 0 );
+                    generateDeliveryReport( mmsHeaders );
+                    CleanupStack::PopAndDestroy( 2 ); // mmsHeaders, store
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+*/
+                }
+            }
+            break;
+        case EMsvEntriesDeleted:
+            {
+            //emit signal for entry deleted
+            }
+            break;
+        case EMsvEntriesMoved:
+            {
+            if (parentId == KMsvGlobalOutBoxIndexEntryIdValue)
+                {
+                // entry moved to outbox
+                emit entryMovedToOutbox(tEntry.Id());
+                }
+            else if (parentId == KMsvSentEntryIdValue)
+                {
+                // entry moved to sent folder
+                emit entryMovedToSent(tEntry.Id());
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+void MmsTestBed::createMmsService()
+    {
+    CMmsSettings * settings = CMmsSettings::NewL();
+    CleanupStack::PushL( settings );
+    settings->CreateNewServiceL( *iSession );
+    CleanupStack::PopAndDestroy(); // settings
+    return;
+    }
+
+void MmsTestBed::cleanup()
+    {
+    TMsvId entryToBeKilled;
+    // Get access to root index
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    entryToBeKilled = iSettings->Service();
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    while (entryToBeKilled != KMsvNullIndexEntryId)
+        {
+        // delete child of root entry
+        deleteEntry(entryToBeKilled, *cEntry);
+        entryToBeKilled = iSettings->Service();
+        }
+
+    CleanupStack::PopAndDestroy(); // cEntry
+    // We deleted everything!
+    iDefaultServiceId = KMsvNullIndexEntryId;
+    iServiceId = KMsvNullIndexEntryId;
+    }
+
+void MmsTestBed::deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry)
+    {
+    aClientEntry.DeleteL(aEntryId);
+    }
+
+void MmsTestBed::cleanupAndCreateNewService()
+    {
+    cleanup();
+    // all old service entries have been destroyed, create a new one
+    createMmsService();
+    }
+
+void MmsTestBed::testFile(TFileName& aFilePath, TInt aCommand /* = 0 */, TMsvId aBox /* = KMsvGlobalOutBoxIndexEntryId */ )
+    {
+    // update settings in mmsclient
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    RFileReadStream readStream;
+    readStream.PushL();
+//    TMsvId id = KMsvNullIndexEntryId;
+    CBufFlat* encodeBuffer = NULL;
+    CMmsEncode* encoder = NULL;
+
+    // Open the file
+    TInt err = readStream.Open(iFs, aFilePath, EFileShareReadersOnly );
+    if (err != KErrNone) User::Leave( err );
+
+    TInt   retCode = 0;
+    CMmsReadFile* readFile = NULL;
+    readFile = CMmsReadFile::NewL( iFs, readStream );
+    CleanupStack::PushL( readFile );
+
+    TInt messageCounter = 0;
+    CMsvEntry* cEntry = NULL;
+
+    while(!retCode)
+        {
+        // READ MESSAGE TO BUFFERS
+        iMmsHeaders->Reset(iSettings);
+        // put in some message type just for fun (testing...)
+        iMmsHeaders->SetMessageType( KMmsMessageTypeForwardReq );
+        retCode = readFile->CompleteTestL( messageCounter++, *iMmsHeaders );
+        if(readFile->iMessageType == ETestNewMessage)
+            {
+            // CREATE MESSAGE ENTRY
+            switch ( aCommand )
+                {
+                case ECreateToInbox:
+                case ECreateNotification:
+                    cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+                    break;
+                case ECreateToSentItems:
+                    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+                    break;
+                case ECreateToDrafts:
+                    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                    break;
+                case ECreateHeadersFromFile:
+                    // here we just encode headers, no message entry
+                    // the entry is fake.
+                    break;
+                case ECreateMMBoxViewConf:
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // entry is not created for the description items
+                        // they become attachments
+                        cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                        }
+                    break;
+                default:
+                    cEntry = iSession->GetEntryL(aBox);
+                    break;
+                }
+
+            // if we are just playing with headers we have no entry
+            if ( aCommand != ECreateHeadersFromFile && aCommand != ECreateMMBoxViewConf )
+                {
+                CleanupStack::PushL(cEntry);
+                iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                // CREATE MESSAGE
+                iMmsClient->CreateMessageL(iServiceId);
+                }
+            else if ( aCommand == ECreateMMBoxViewConf )
+                {
+                if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                    {
+                    CleanupStack::PushL(cEntry);
+                    iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                    // CREATE MESSAGE
+                    iMmsClient->CreateMessageL(iServiceId);
+                    }
+                else
+                    {
+                    encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                    CleanupStack::PushL( encodeBuffer );
+                    encoder = CMmsEncode::NewL( iFs );
+                    CleanupStack::PushL( encoder );
+
+                    // encode headers to a binary file
+                    encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                    iFilename = KMmsMMBoxDescriptionDirectory;
+                    TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                    CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                    encodeBuffer = NULL;
+                    encoder = NULL;
+                    }
+                }
+            else
+                {
+                encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                CleanupStack::PushL( encodeBuffer );
+                encoder = CMmsEncode::NewL( iFs );
+                CleanupStack::PushL( encoder );
+
+                // encode headers to a binary file
+                encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                iFilename = KMmsDumpDirectory;
+                TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                encodeBuffer = NULL;
+                encoder = NULL;
+                }
+            }
+
+        if ( aCommand != ECreateHeadersFromFile &&
+            ( aCommand != ECreateMMBoxViewConf || iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) )
+            {
+            if(readFile->iMessageType == ETestSettings)
+                {
+                TMsvId ServiceId = iMmsClient->DefaultServiceL();
+                iMmsClient->RestoreSettingsL();
+                iSettings->CopyL( iMmsClient->MmsSettings() );
+                }
+
+            TMemoryInfoV1Buf memory;
+            UserHal::MemoryInfo( memory );
+            TInt available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory before CreateMessageL %d"), available );
+
+            TRAP (err, readFile->CreateMessageL(iMmsClient, iMmsHeaders));
+
+            available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory after CreateMessageL %d"), available );
+
+            if(readFile->iMessageType == ETestNewMessage)
+                {
+                TMsvEntry tEntry = iMmsClient->Entry().Entry();
+                TMsvId id = tEntry.Id();
+                if ( err == KErrNone )
+                    {
+                    // SAVE MESSAGE
+                    iMmsClient->SaveMessageL();
+
+                    // If we are creating a MMBox View confirmation,
+                    // we add all binary files from KMmsMMBoxDirectory
+                    // as attachments.
+
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        addMMBoxDescriptions();
+                        }
+
+                    // reload the entry in case mms client put something into it
+                    // MESSAGE MUST BE SET VISIBLE
+                    tEntry = iMmsClient->Entry().Entry();
+                    if ( iMmsClient->MessageClass() == EMmsClassAdvertisement )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageAdvertisement;
+                        }
+                    else if ( iMmsClient->MessageClass() == EMmsClassInformational )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageInformational;
+                        }
+                    tEntry.iMtmData1 &= ~KMmsMessageMobileTerminated;
+
+                    // Test: Set all as editor oriented - except notifications!
+                    if ( aCommand == ECreateNotification )
+                        {
+                        tEntry.iMtm = KUidMsgMMSNotification;
+                        }
+                    else
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageEditorOriented;
+                        }
+                    if ( aCommand == ECreateToInbox )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageMobileTerminated;
+                        tEntry.SetReadOnly( ETrue );
+                        tEntry.SetNew( ETrue );
+                        tEntry.SetUnread( ETrue );
+                        }
+                    else if ( aCommand == ECreateToSentItems )
+                        {
+                        tEntry.SetReadOnly( ETrue );
+                        }
+                    tEntry.SetVisible( ETrue );
+                    tEntry.SetInPreparation( EFalse );
+                    TTime now;
+                    now.UniversalTime();
+                    tEntry.iDate = now;
+                    TMsvId entryId = tEntry.Id();
+                    iMmsClient->Entry().ChangeL( tEntry );
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // Encode to the directory that is used to fetch MMBox view
+                        iFilename.Copy( KMmsMMBoxDirectory );
+                        encodeMessageFromDrafts();
+                        cEntry->SetEntryL( KMsvDraftEntryId );
+                        cEntry->DeleteL( entryId );
+                        }
+                    }
+                else
+                    {
+                    //TMmsLogger::Log(_L("CreateMessageL left with error %d"), err );
+                    iSession->RemoveEntry(id);
+                    err = KErrNone; // clear error
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+                cEntry = NULL;
+                }
+            if(readFile->iMessageType == ETestSettings)
+                {
+                iMmsClient->SetSettingsL( *iSettings );
+                iMmsClient->StoreSettingsL();
+                }
+        }
+    }
+
+    CleanupStack::PopAndDestroy(); //readFile
+
+    readStream.Close();
+    readStream.Pop();
+
+    /*
+    iMmsClient->SwitchCurrentEntryL(id);
+    */
+    }
+
+void MmsTestBed::addMMBoxDescriptions()
+    {
+    // add the contents of KMmsMMBoxDescriptionDirectory as attachments
+    CDir* fileList = NULL;
+    TInt i = 0;  // general counter
+    TInt error = KErrNone;
+    iCurrentPath = KMmsMMBoxDescriptionDirectory;
+
+    iFs.SetSessionPath(iCurrentPath);
+
+    TFindFile finder( iFs );
+    error = finder.FindWildByPath( KWild, NULL, fileList );
+    CleanupStack::PushL( fileList );
+    TInt fileCounter = 0;
+
+    if ( error == KErrNone )
+        {
+        fileCounter = fileList->Count();
+        }
+
+    TEntry entry;
+
+    if ( error == KErrNone )
+        {
+        for ( i = 0; i < fileCounter; ++i )
+            {
+            // Reset inactivity timer to keep viewServer from crashing
+            User::ResetInactivityTime();
+            entry = (*fileList)[i]; // name is entry.iName
+            iFilename.Copy( iCurrentPath );
+            iFilename.Append( entry.iName );
+            TPtrC ptr;
+            ptr.Set( iFilename );
+            iWait->iStatus = KErrNone;
+            iMmsClient->AddAttachmentL( ptr, KMmsMimeType, 0, iWait->iStatus );
+
+            iWait->Start();
+            // The descriptions are cleared after being used
+            iFs.Delete( ptr);
+            }
+        }
+
+    iMmsClient->SaveMessageL(); // just in case somthing must be updated
+    CleanupStack::PopAndDestroy(); // fileList
+    fileList = NULL;
+    }
+
+void MmsTestBed::encodeMessageFromDrafts()
+    {
+    CMmsEncode* encoder = CMmsEncode::NewL( iFs );
+    CleanupStack::PushL( encoder );
+    // encode a message iMmsClientPoints to
+    iMmsClient->LoadMessageL();
+    CMsvStore* store = iMmsClient->Entry().ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy(); // store
+    store = NULL;
+    iWait->iStatus = KErrNone;
+
+// caller sets the directory
+//    iFilename = KMmsMessageDumpDirectory;
+
+    CMmsClientEntry* entryWrapper = CMmsClientEntry::NewL( iFs, iMmsClient->Entry(), iServiceId );
+    CleanupStack::PushL( entryWrapper );
+    iEncodeBuffer->ResizeL(0);
+    encoder->StartL( *entryWrapper, *iMmsHeaders, *iEncodeBuffer, iWait->iStatus );
+    iWait->Start();
+    if ( iWait->iStatus == KErrNone )
+        {
+        TMmsTestUtils::Dump( *iEncodeBuffer, iFilename, iParse, iFs );
+        }
+    iEncodeBuffer->ResizeL(0);
+    CleanupStack::PopAndDestroy(); // entryWrapper
+    CleanupStack::PopAndDestroy(); // encoder
+    }
+
+void MmsTestBed::deleteNotifications()
+    {
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    if ( mmsFolderId != KMsvNullIndexEntryId )
+        {
+        cEntry->SetEntryL(mmsFolderId);
+
+        // show invisible entries
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+        CleanupStack::PushL(msvEntrySelection);
+
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        // These cannot be deleted unless we have the a server mtm
+        // corresponding to this mtm type.
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgMMSNotification );
+        CleanupStack::PushL(msvEntrySelection);
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    }
+
+TMsvId MmsTestBed::findMMSFolder()
+    {
+    return iSettings->NotificationFolder();
+    }
+
+void MmsTestBed::restoreFactorySettings()
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+    // do not reset access point
+    TInt accessPoint = iSettings->AccessPoint( 0 );
+    iSettings->RestoreFactorySettingsL( iMmsClient->Session(), EMmsFactorySettingsLevelDeep );
+    TInt count = iSettings->AccessPointCount();
+    TInt i = 0;
+    for ( i = count - 1; i >= 0; --i )
+        {
+        iSettings->DeleteAccessPointL( i );
+        }
+    // restore the original access point
+    if ( accessPoint > 0 )
+        {
+        // a negative access point is an error (most likely "KErrNotFound")
+        iSettings->AddAccessPointL( accessPoint, 0 );
+        }
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::setFetchingState( TMmsReceivingMode aState )
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    iSettings->SetReceivingModeHome( aState );
+
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::sendFromFile()
+    {
+    CMsvOperation * op = NULL;
+
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    CleanupStack::PushL( selection );
+
+    TRAPD (error, op = iMmsClient->SendL(*selection, iWait->iStatus));
+    if ( error != KErrNone )
+        {
+        CleanupStack::PopAndDestroy(); // selection
+        delete op;
+        return;
+        }
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(2); // op, selection
+    }
+
+void MmsTestBed::sendOneByOne()
+    {
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL( selection );
+
+    CMsvEntrySelection* shortSelection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( shortSelection );
+
+    TInt i;
+
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        shortSelection->Reset();
+        shortSelection->AppendL( selection->At( i ) );
+
+        CMsvOperation * op = NULL;
+
+        TTime now;
+        now.UniversalTime();
+
+        TRAPD (error, op = iMmsClient->SendL(*shortSelection, iWait->iStatus, now ));
+        if ( error != KErrNone )
+            {
+            delete op;
+            CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+            return;
+            }
+        CleanupStack::PushL(op);
+        iWait->Start();
+
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // op
+
+        }
+    CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+    }
+
+void MmsTestBed::sendNotifications()
+    {
+    // Only send one notification!!
+
+    TInt error = KErrNone;
+
+    if (! TMmsTestUtils::IsFile(iCurrentFile, iFs) )
+        {
+        //Not a file
+        return;
+        }
+    TMsvId mmsFolder = findMMSFolder();
+
+    TEntry entry;
+
+
+    // now I think we have a filename
+    TEntry orgEntry;
+    TUint size = 0;
+    error = iFs.Entry( iCurrentFile, orgEntry );
+    size = orgEntry.iSize;
+
+    //TMmsLogger::Log(_L("- notification %S "), &iCurrentFile);
+    if ( size == 0 )
+        {
+        //empty file
+        //TMmsLogger::Log(_L("- empty file"));
+        return;
+        }
+
+    if ( iEncodeBuffer == NULL )
+        {
+        iEncodeBuffer = CBufFlat::NewL( size );
+        }
+    else
+        {
+        iEncodeBuffer->ResizeL( 0 );
+        iEncodeBuffer->ResizeL( size );
+        }
+
+    RFile inFile;
+    error = inFile.Open( iFs, iCurrentFile, EFileShareReadersOnly );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+    if ( error == KErrNone )
+        {
+        error = inFile.Read( ptr, size );
+        inFile.Close();
+        }
+    else
+       {
+       //Error
+       //TMmsLogger::Log(_L("- can't read file"));
+       return;
+       }
+
+    TUint8 byte;
+    TUint position = 0;
+    TUint32 uintvar = 0;
+
+    if ( size > 2 )
+        {
+        iEncodeBuffer->Read( 1, &byte, 1 );
+        if ( byte == 6 ) // PUSH PDU
+            {
+            // try to find out length of header
+            position = 2;
+            iEncodeBuffer->Read( position, &byte, 1);
+
+            while ( byte & 0x80  && position < size )
+                {
+                uintvar += ( byte & 0x7f );
+                uintvar <<= 7;
+                position++;
+                iEncodeBuffer->Read( position, &byte, 1 );
+                }
+
+            // add last byte without shift
+            uintvar += byte;
+            position++;
+           }
+        }
+
+    position += uintvar;
+
+    if ( position < size )
+        {
+        ptr = iEncodeBuffer->Ptr( position );
+        size = ptr.Length();
+        }
+
+    if ( size == 0 )
+        {
+        //no MMS stuff
+        //TMmsLogger::Log(_L("- no MMS stuff"));
+        return;
+        }
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    User::After(1000000);
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::copyDrafts()
+    {
+    CMsvEntry* cEntry = NULL;
+// Copies contents of sent folder to drafts for retrying sending.
+
+    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    TMsvLocalOperationProgress progress;
+    cEntry->CopyL( *selection, KMsvDraftEntryId, progress );
+
+    TInt i = 0;
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        cEntry->SetEntryL( selection->At( i ) );
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly( EFalse );
+        cEntry->ChangeL( entry );
+        }
+
+    CleanupStack::PopAndDestroy(2); // selection, cEntry
+    }
+
+void MmsTestBed::garbageCollection(TUint32 aReason)
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    TMMSGarbageCollectionParameters parameters; // initialized to zero
+    parameters.iReasonFlags = aReason;
+    TMMSGarbageCollectionParametersBuf paramPack( parameters );
+    op = iSession->TransferCommandL(
+        *selection, EMmsGarbageCollection, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::messageVariation()
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsMessageGeneration, TPtrC8(), iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::cancelSendScheduling()
+    {
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    scheduledSend(KMsvGlobalOutBoxIndexEntryIdValue, 10000); // long delay so that we have time to cancel
+    deleteSendSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy();
+    }
+
+void MmsTestBed::scheduledSend(TMsvId aBoxId, TInt aDelay /* = 5 */)
+    {
+    CMsvEntry* cEntry = NULL;
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(aBoxId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+//    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledSend,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::deleteSendSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::cancelFetchScheduling()
+    {
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+
+    // Wait until notification has arrived - may take a while in global mode
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) == 0
+        && i < 2000 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+
+    fetchForced( 10000 ); // delay to allow cancelling
+    deleteFetchSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(mmsFolder);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::fetchForced(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::deleteFetchSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+    cEntry = iSession->GetEntryL( mmsFolderId );
+    CleanupStack::PushL(cEntry);
+    // Get all notifications
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::doAFetchCycle()
+    {
+    // Sends a message from iCurrentFile and lets it come back
+    TMsvId mmsFolder = findMMSFolder();
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+    // fetching will start automatically
+
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( KMsvGlobalInBoxIndexEntryId, iMsvEntrySelection, *iSession ) == 0
+         && i < 2000
+         && TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) > 0 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+    }
+
+bool MmsTestBed::checkLogClient()
+    {
+    if ( iLogClient == NULL )
+        {
+        TRAP_IGNORE( iLogClient = CLogClient::NewL( iFs ) );
+        }
+    return ( iLogClient != NULL );
+    }
+
+int MmsTestBed::getLogEntries()
+    {
+    TInt count = 0;
+    if ( !iLogView )
+        {
+        return 0;
+        }
+
+    if ( iLogView->SetFilterL( *iLogFilter, iWait->iStatus ) )
+        {
+        // should complete with KErrNone
+        iWait->Start();
+        if ( iWait->iStatus.Int() == KErrNone )
+            {
+            count = iLogView->CountL();
+            }
+        }
+    return count;
+    }
+
+void MmsTestBed::createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry)
+    {
+    CMsvOperation*  opert = aClientEntry.CreateL(aNewEntry, iWait->iStatus);
+    iWait->Start();
+    if (!opert->iStatus.Int()==KErrNone)
+        {
+        // what should we do? panic?
+        }
+
+    TPckgBuf<TMsvLocalOperationProgress> package;
+    package.Copy(opert->ProgressL());
+    *(TMsvId*)&aNewEntry = package().iId;
+
+    delete opert; opert=NULL;
+    }
+
+void MmsTestBed::cleanOutbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalOutBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanInbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanSent()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvSentEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanDrafts()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvDraftEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanAll()
+    {
+    cleanInbox();
+    cleanOutbox();
+    cleanSent();
+    cleanDrafts();
+    TMmsTestUtils::CleanBoxL( iSettings->MMBoxFolder(), *iSession );
+    deleteNotifications();
+    }
+
+void MmsTestBed::reply()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::replyToAll()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply to all, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::forward()
+    {
+    // The first message from inbox is forwarded
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient | KMsvMessagePartAttachments;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ForwardL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create forward, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                iMmsClient->SwitchCurrentEntryL( newEntry );
+                // Add a sender: 0601234567
+                iMmsClient->LoadMessageL();
+                iMmsClient->SetSenderL( KMmsSender );
+                iMmsClient->SaveMessageL();
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::sendReadReport()
+    {
+    // TURN READ REPORTS ON (until available from menu)
+    iSettings->LoadSettingsL();
+    iSettings->SetReadReplyReportSendingAllowed( ETrue );
+    iSettings->SaveSettingsL();
+    iMmsClient->RestoreSettingsL();
+
+
+    // Read report is sent for the first message in inbox
+    CMsvEntry* cEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+
+    if ( iMsvEntrySelection->Count() == 0 )
+        {
+        return;
+        }
+    TMsvId originalEntry = iMsvEntrySelection->At( 0 );
+
+    // new test using Client MTM
+    CMsvOperation * op = NULL;
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+    // Try sending the read report to current entry
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+/*
+    cEntry->SetEntryL( originalEntry );
+    iMmsHeaders->Reset();
+    CMsvStore* store = cEntry->ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+    HBufC8* messageId = HBufC8::NewL( iMmsHeaders->MessageId().Length() );
+    CleanupStack::PushL( messageId );
+    messageId->Des().Copy( iMmsHeaders->MessageId() );
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    iMmsClient->LoadMessageL();
+
+    iMmsHeaders->Reset();
+    iMmsHeaders->SetMessageType( KMmsMessageTypeReadRecInd );
+    // Message id cannot be accessed via MMS Client MTM!
+
+    iMmsHeaders->SetMessageIdL( messageId->Des() );
+    CleanupStack::PopAndDestroy( messageId );
+
+    iMmsHeaders->AddTypedAddresseeL( iMmsClient->Sender(), EMsvRecipientTo );
+    // sender must be insert-address-token because we don't know our number
+    TTime now;
+    now.UniversalTime();
+
+    _LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+    interval = now.MicroSecondsFrom( y1970 );
+    // date in iMmsHeaders() in seconds from 1.1.1970.
+    iMmsHeaders->SetDate( (interval.Int64() ) / KMmsMillion );
+    iMmsHeaders->SetReadStatus( KMmsReadStatusRead );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = FindMMSFolderL();
+
+    cEntry->SetEntryL( mmsFolderId );
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = iDefaultServiceId;
+    entry.iMtmData1 = KMmsMessageReadRecInd;
+    cEntry->CreateL( entry );
+    TMsvId entryId = entry.Id();
+
+    cEntry->SetEntryL( entryId );
+
+    store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->StoreL( *store );
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, entryId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    op = iSession->TransferCommandL(*selection,EMmsScheduledReadReport,paramPack,iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    CleanupStack::PopAndDestroy( selection );
+*/
+    CleanupStack::PopAndDestroy( cEntry );
+    }
+
+int MmsTestBed::fromOutboxToMmscWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt messageCount = 0;
+    TInt failureCount = 0;
+    do {
+        CMsvEntry* cEntry = NULL;
+
+        // Get List of services
+        cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+        CleanupStack::PushL(cEntry);
+        // Get all mms messages of outbox
+        CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        CleanupStack::PushL( selection );
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        selection->InsertL(0, iServiceId);
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iSession->TransferCommandL(*selection,EMmsSend,paramPack,iWait->iStatus));
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // selection
+        CleanupStack::PopAndDestroy(); // cEntry
+        selection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( KMsvGlobalOutBoxIndexEntryIdValue );
+        CleanupStack::PushL(cEntry);
+        selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = selection->Count();
+        delete selection;
+        selection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    return failureCount;
+    }
+
+int MmsTestBed::fromMmscToInboxWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt failureCount = 0;
+    TInt messageCount = 0;
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    do {
+        // Inbox must be cleaned if failure makes message to be fetched more than once.
+        // should not happen, but this test is quite stressful, and perfect result
+        // cannot be guaranteed.
+        // What is expected:
+        // 1. Program does not crash
+        // 2. After sufficient number of retries the message is fetched and notification deleted.
+        TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+        CMsvEntry* cEntry = NULL;
+        CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+        CleanupStack::PushL(msvEntrySelection);
+
+        cEntry = iSession->GetEntryL(iServiceId);
+        CleanupStack::PushL(cEntry);
+
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        // if we have a selected service, insert it into selection
+        if (iServiceId != KMsvNullIndexEntryId)
+            {
+            msvEntrySelection->InsertL(0, iServiceId);
+            }
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iMmsClient->InvokeAsyncFunctionL(
+            EMmsReceiveForced,
+            *msvEntrySelection,
+            paramPack,
+            iWait->iStatus) );
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to receive, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // msvEntrySelection
+        CleanupStack::PopAndDestroy(); // cEntry
+        msvEntrySelection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( mmsFolderId );
+        CleanupStack::PushL(cEntry);
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = msvEntrySelection->Count();
+        delete msvEntrySelection;
+        msvEntrySelection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    if ( error != KErrNoMemory && error != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Memory failure loop ended with %d"), error);
+        }
+    return failureCount;
+    }
+
+void MmsTestBed::sendViaClient()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    CMsvOperation * op = NULL;
+    TTime now;
+    now.UniversalTime();
+    op = iMmsClient->SendL( *selection, iWait->iStatus, now );
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::scheduledFetch(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceive,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::fetchForcedImmediate()
+    {
+    TCommandParameters parameters;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::getEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    iLogClient->GetEventType( *eventType, iWait->iStatus );
+
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::addEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    eventType->SetDescription(_L("Multimedia Message") );
+    eventType->SetLoggingEnabled( ETrue );
+
+//    iWait->iStatus = KRequestPending;
+    iLogClient->AddEventType( *eventType, iWait->iStatus );
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::deleteEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+//    iWait->iStatus = KRequestPending;
+    iLogClient->DeleteEventType( iLogEvent->EventType(), iWait->iStatus );
+    iWait->Start();
+    }
+
+void MmsTestBed::cleanLog()
+    {
+    TInt count = 0;
+
+    count = getLogEntries();
+
+    TInt i;
+    for ( i = 0; i < count; ++i )
+        {
+        // when a view is created, it will be positioned on the first event
+//        iWait->iStatus = KRequestPending;
+        iLogClient->DeleteEvent(iLogView->Event().Id(), iWait->iStatus);
+        iWait->Start();
+
+        if ( iLogView->NextL( iWait->iStatus ) )
+            {
+            // should complete with KErrNone
+            iWait->Start();
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                // could not get next event!
+                break;
+                }
+            }
+        else
+            {
+            break; // no more events!
+            }
+        }
+    }
+
+void MmsTestBed::setOnline(bool value)
+    {
+    //value = true for online mode
+    //value = false for offline mode
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KCRUidCoreApplicationUIs ) );
+    if( retval == KErrNone )
+        {
+        repository->Set( KCoreAppUIsNetworkConnectionAllowed, value );
+        delete repository;
+        }
+    }
+
+void MmsTestBed::generateDeliveryReport( CMmsHeaders* aMmsHeaders )
+    {
+    iEncodeBuffer->ResizeL( 1024 );
+
+    TInt position = 0;
+
+    // encode message type
+    iEncodeBuffer->Write( position, &KMmsAssignedMessageType, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageTypeDeliveryInd, 1 );
+    position++;
+
+    // version
+    iEncodeBuffer->Write( position, &KMmsAssignedMmsVersion, 1 );
+    position++;
+
+    TUint8 version = aMmsHeaders->MmsVersion() | 0x80; // current version as short integer
+    iEncodeBuffer->Write( position, &version, 1 );
+    position++;
+
+    // message id from the headers
+    // At least once MMSC did not send us the message id!
+    // if message id is missing, we cannot match the entry!
+    // This only a fake. Real delivery reports should always
+    // contain the message id.
+    if ( aMmsHeaders->MessageId().Length() > 0 )
+        {
+        iEncodeBuffer->Write( position, &KMmsAssignedMessageId, 1 );
+        position++;
+        iEncodeBuffer->Write( position, &(aMmsHeaders->MessageId()[0]), aMmsHeaders->MessageId().Length() );
+        position += aMmsHeaders->MessageId().Length();
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // To is taken from the headers
+    iEncodeBuffer->Write( position, &KMmsAssignedTo, 1 );
+    position++;
+
+    TPtrC recipient;
+    if ( aMmsHeaders->ToRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->ToRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->ToRecipients()[0] );
+        }
+    else if( aMmsHeaders->CcRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->CcRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->CcRecipients()[0] );
+        }
+    else if( aMmsHeaders->BccRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->BccRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->BccRecipients()[0] );
+        }
+    else
+        {
+        recipient.Set( _L("Jasso-Kissa@jii.fi") );
+        }
+
+    TMmsAddressType addressType = EMmsAddressTypeUnknown;
+
+    if ( recipient.Find( KMiuMau ) != KErrNotFound )
+        {
+        addressType = EMmsAddressTypeEmail;
+        }
+    else
+        {
+        addressType = EMmsAddressTypeMobile;
+        }
+
+    TUint8 character;
+    TInt i;
+    if ( addressType == EMmsAddressTypeEmail )
+        {
+        // email address - ASCII ONLY - THIS IS JUST A TEST!
+
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+
+        }
+    else
+        {
+        // must be a phone number
+        // We expect for now that the format is correct as is
+        // All legal characters present in a phone number are ASCII
+
+        TInt i;
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, KMmsPlmn, KMmsPlmnLength );
+        position += KMmsPlmnLength;
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // date
+    iEncodeBuffer->Write( position, &KMmsAssignedDate, 1 );
+    position++;
+
+    TLocale locale;
+    locale.Refresh();
+    TInt64 UtcDate;
+    TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
+
+    TTime now;
+    now.UniversalTime();
+    UtcDate = ( now.MicroSecondsFrom( TTime( KMmsYear1970String ) ).Int64() ) / 1000000 ;
+
+    UtcDate -= universalTimeOffset.Int();
+
+    if ( locale.QueryHomeHasDaylightSavingOn() )
+        {
+        TTimeIntervalSeconds daylightSaving( 60 * 60 );
+        UtcDate -= daylightSaving.Int();
+        }
+
+    TUint8 len; // number of bytes we will need
+    len = 0;
+    TUint8 array[8];
+
+    TInt64 temp = UtcDate;
+
+    for (i = 7; i >= 0; --i)
+        {
+        array[i] = TInt8( ( I64INT( temp ) ) & 0xFF );
+        I64LSR( temp, 8 );
+        }
+
+    len = 8;
+    i = 0;
+    while( ( array[i]== 0 ) && ( i < 8 ) )
+        {
+        i++;
+        len--;
+        }
+
+    // a zero should be coded as short integer.
+    // However, if there is a valid reason to code a zero as a long integer,
+    // we allow it. The caller should know what he is doing.
+    if ( len == 0 )
+        {
+        len = 1;
+        }
+    // write short length
+    iEncodeBuffer->Write( position, &len, 1 );
+    position++;
+    // write as many bytes as were non-zero
+    iEncodeBuffer->Write( position, &(array[8 - len] ), len );
+    position+= len;
+    // status
+    iEncodeBuffer->Write( position, &KMmsAssignedStatus, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageStatusRetrieved, 1 );
+    position++;
+    // DONE!!!
+    iEncodeBuffer->ResizeL( position );
+    return;
+    }
+
+void MmsTestBed::sendDeliveryReport()
+    {
+    if ( iEncodeBuffer->Size() == 0 )
+        {
+        //No delivery report
+        return;
+        }
+
+
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+//    iWait->iStatus = KRequestPending;
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsteststaticutils.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <f32file.h>
+#include <centralrepository.h>
+#include <apparc.h>
+#include <msvapi.h>
+#include <msvids.h>
+
+#include "mmsteststaticutils.h"
+#include "mmsconst.h"
+#include "MmsEnginePrivateCRKeys.h"
+#include "mmssettings.h"
+#include "mmsheaders.h"
+#include "mmsservercommon.h"
+#include "mmsencode.h"
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsJoinedArrays::TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2)
+: iArray1(aArray1), iArray2(aArray2)
+    {
+    }
+
+TInt TMmsJoinedArrays::MdcaCount() const
+    {
+    TInt count=0;
+    if (iArray1)
+        count += iArray1->MdcaCount();
+    if (iArray2)
+        count += iArray2->MdcaCount();
+    return count;
+    }
+
+TPtrC16 TMmsJoinedArrays::MdcaPoint(TInt aIndex) const
+    {
+    if (iArray1)
+        {
+        if (aIndex < iArray1->MdcaCount())
+            return iArray1->MdcaPoint(aIndex);
+        else
+            aIndex -= iArray1->MdcaCount();
+        }
+    return iArray2->MdcaPoint(aIndex);
+    }
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsTestUtils::TMmsTestUtils()
+    {
+
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+HBufC* TMmsTestUtils::ReadContactFromFileL( TDesC& aFileName, RFs& aFs )
+    {
+    RFile file;
+    TInt error = KErrNone;
+
+    TInt textBufferSize = 256;
+    HBufC* textBuffer = HBufC::NewL( textBufferSize );
+    TPtr textPtr = textBuffer->Des();
+    TFileText textFile;
+
+    error = file.Open( aFs, aFileName,
+            EFileRead|EFileShareReadersOnly );
+
+    if ( error == KErrNone )
+        {
+        textFile.Set( file );
+        error = textFile.Seek( ESeekStart );
+        }
+
+    if ( error == KErrNone )
+        {
+        error = textFile.Read( textPtr );
+        }
+
+    file.Close();
+
+    if ( textBuffer->Des().Find( &KMmsByteOrderMark, 1 ) == 0 )
+        {
+        textBuffer->Des().Copy( textBuffer->Des().Mid( 1 ) );
+        }
+
+    return textBuffer;
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOnL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOffL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanDirectoryL( RFs& aFs )
+    {
+    // Delete the files in the directory
+    CFileMan* fileMan = CFileMan::NewL( aFs );
+    CleanupStack::PushL( fileMan );
+    fileMan->RmDir( KMmsDefaultLocalModeDir );
+    fileMan->RmDir( KMmsMMBoxDirectory );
+    fileMan->RmDir( KMmsMMBoxDescriptionDirectory );
+    CleanupStack::PopAndDestroy(); // fileManager
+    // we don't want to throw these away!
+    aFs.MkDirAll( KMmsDefaultLocalModeDir );
+    aFs.MkDirAll( KMmsMMBoxDirectory );
+    aFs.MkDirAll( KMmsMMBoxDescriptionDirectory );
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::Dump( CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs )
+    {
+    TInt error = KErrNone;
+    aFs.MkDirAll( aFilename );
+    TUint att;
+    if ( aFs.Att( aFilename, att ) == KErrNone )
+        {
+        _LIT( KRelated, "dump.mms");
+        aParse.Set( aFilename, &KRelated, NULL );
+        aFilename = aParse.FullName();
+        error = CApaApplication::GenerateFileName( aFs, aFilename );
+        if ( error == KErrNone )
+            {
+            RFile file;
+            error = file.Create( aFs, aFilename, EFileWrite | EFileShareExclusive );
+            // for message id generation
+            aParse.Set( aFilename, NULL, NULL );
+            if ( error == KErrNone )
+                {
+                // the data is supposed to be in the encode buffer
+                TPtr8 ptr = aBuffer.Ptr( 0 );
+                file.Write( ptr );
+                file.Flush();
+                }
+
+            // done - close files
+            file.Close();
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanBoxL(TMsvId aBoxId, CMsvSession& aSession)
+    {
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    // show invisible entries
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL(msvEntrySelection);
+
+    CMsvEntrySelection* selection = NULL;
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    selection = cEntry->ChildrenWithMtmL(KUidMsgMMSNotification);
+    CleanupStack::PushL( selection );
+    if ( selection->Count() > 0 )
+        {
+        msvEntrySelection->AppendL( selection->Back( 0 ), selection->Count() );
+        }
+    CleanupStack::PopAndDestroy(); // selection
+
+    int i;
+    for (i = 0; i < msvEntrySelection->Count(); ++i)
+        {
+        CMsvEntry* entry = aSession.GetEntryL( msvEntrySelection->At(i) );
+        CleanupStack::PushL( entry );
+        TMsvEntry tEntry = entry->Entry();
+        tEntry.SetReadOnly(EFalse);
+        entry->ChangeL(tEntry);
+        cEntry->DeleteL( msvEntrySelection->At(i) );
+        CleanupStack::PopAndDestroy( entry );
+        }
+
+    CleanupStack::PopAndDestroy(msvEntrySelection);
+    CleanupStack::PopAndDestroy(cEntry);
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 1;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 0;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TInt TMmsTestUtils::CountChildrenL(TMsvId aBoxId, CMsvEntrySelection*& aMsvEntrySelection, CMsvSession& aSession, TUid aMessageType )
+    {
+    CMsvEntry* cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    if (aMsvEntrySelection != NULL)
+        {
+        delete aMsvEntrySelection;
+        aMsvEntrySelection = NULL;
+        }
+    aMsvEntrySelection = cEntry->ChildrenWithMtmL(aMessageType);
+    CleanupStack::PopAndDestroy(); // cEntry
+    return aMsvEntrySelection->Count();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CreateFolderEntryL
+//
+// -----------------------------------------------------------------------------
+//
+void TMmsTestUtils::CreateFolderEntryL(
+    CMsvSession& aSession,
+    TMsvId aParentFolder,
+    const TDesC& aFolderName,
+    TMsvId& aFolderId )
+    {
+    aFolderId = KMsvNullIndexEntryId;
+    CMsvEntry* cEntry = aSession.GetEntryL( aParentFolder );
+    CleanupStack::PushL( cEntry );
+
+    // Create a new folder.
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvFolderEntry;
+    entry.iMtm = KUidMsvLocalServiceMtm;
+    entry.iDetails.Set( aFolderName );
+    entry.SetVisible( EFalse );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    cEntry->CreateL( entry );
+    aFolderId = entry.Id();
+    CleanupStack::PopAndDestroy( cEntry );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TMsvId TMmsTestUtils::CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession )
+    {
+    TMsvId entryId = KMsvNullIndexEntryId;
+    if ( aNotificationFolder == KMsvNullIndexEntryId )
+        {
+        // no folder no entry
+        return entryId;
+        }
+
+    CMsvEntry* cEntry = aSession.GetEntryL( aNotificationFolder );
+    CleanupStack::PushL(cEntry);
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    // If we want to put data here, InPreparation must be set to true first
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = aServiceId;
+    entry.iMtmData2 = KMmsNotificationBinary;
+    cEntry->CreateL( entry );
+    entryId = entry.Id();
+
+    //
+    // Stream
+    // 1) length of the data as 32 bit integer
+    // 2) pushed message data
+    // into created entry's stream
+    //
+    cEntry->SetEntryL( entryId );
+    CMsvStore* store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );   // ***
+    RMsvWriteStream outs;
+    outs.AssignLC( *store, KUidBinaryNotificationStream ); // ***
+    TPtrC8 ptr = aEncodeBuffer->Ptr( 0 );
+    outs.WriteUint32L( ptr.Length() );
+    outs.WriteL( ptr );
+    outs.CommitL();
+    outs.Close();
+    store->CommitL();
+
+    CleanupStack::PopAndDestroy( &outs ); // close outs
+    CleanupStack::PopAndDestroy( store );
+    CleanupStack::PopAndDestroy( cEntry );
+
+    return entryId;
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer )
+    {
+    // for test purposes aUrl will contain the filename.
+
+    // Reset sets the default encapsulation version
+    // The default version has been set from MmsSettings in NewL
+    aMmsHeaders.Reset();
+
+    // construct the notification into iMmsHeaders, and call encode
+
+    aMmsHeaders.SetMessageType( KMmsMessageTypeMNotificationInd );
+
+    TTime currentTime;
+    currentTime.UniversalTime();
+    currentTime.Int64();
+
+    TPtrC8 tid;
+    TBufC8<KMMSMAXTIDLENGTH> target;
+    TInt random = 0;
+
+    // we don't generate a true random TID: We generate the
+    // TID from the URL so that if we generate a notification
+    // twice from the same file, we get the same TID and the
+    // same URL. This way we can test the pruning function in
+    // server MTM
+
+    TInt i;
+    for ( i = 0; i < aUrl.Length(); ++i )
+        {
+        random += aUrl[ i ];
+        }
+
+    target.Des().Num( random );
+    tid.Set( target.Des() );
+    aMmsHeaders.SetTidL( tid );
+
+    aMmsHeaders.SetMessageClass( EMmsClassPersonal );
+    aMmsHeaders.SetMessageSize( aSize );
+    const TInt KTenHours = 10 * 60 * 60; // 10 hours relative expiry
+    aMmsHeaders.SetExpiryInterval( KTenHours );
+    aMmsHeaders.SetContentLocationL( aUrl );
+
+    aMmsEncoder.EncodeHeadersL( aMmsHeaders, *aEncodeBuffer );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsFile(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a file?
+    if (IsDrive(aFileName))
+        return EFalse;
+    return !(IsDir(aFileName, aFs));
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDir(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a directory?
+    TEntry entry;
+    TInt err = aFs.Entry(aFileName, entry);
+    if (err)
+        return EFalse;
+    else
+        return entry.IsDir();
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDrive(const TDesC& aFileName)
+    {
+    //horrible little function to figure if the path is just a drive
+    TBool retVal = EFalse;
+    if (aFileName.Length()==3) //eg "c:\"
+        {
+        if ((aFileName[1] == ':')  && (aFileName[2] == '\\'))
+            retVal=ETrue;
+        }
+    else if (aFileName.Length()==2) //eg "c:"
+        {
+        if (aFileName[1] == ':')
+            retVal=ETrue;
+        }
+    return retVal;
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestuitimer.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include "mmstestuitimer.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::CTestUiTimer(): CTimer( 5 )
+    {
+    period = KPeriod;
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer* CTestUiTimer::NewL()
+    {
+    CTestUiTimer* self = new(ELeave) CTestUiTimer();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::~CTestUiTimer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::IssueRequest()
+    {
+    // No operation to cancel if this function is called
+    iObject = NULL;
+    After(period);
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::TimeoutOperation( CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds )
+    {
+    iObject = aObject;
+    TTimeIntervalMicroSeconds32 timeout = aTimeoutInSeconds.Int() * 1000000;
+    After( timeout );
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    if ( iObject )
+        {
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::RunL()
+    {
+    if ( iObject )
+        {
+        // If we timeout while holding an active object, we cancel it
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    else
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: Main test class declaration for ConvergedMessageUtils
+ */
+
+#ifndef TEST_MMS_PLUGIN_H
+#define TEST_MMS_PLUGIN_H
+
+#ifdef BUILD_TEST_DLL
+#define TEST_EXPORT Q_DECL_EXPORT
+#else
+#define TEST_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <QSignalSpy>
+#include <e32const.h>
+
+//Forward Declarations
+class UniEditorMmsPlugin;
+class ConvergedMessage;
+class MmsTestBed;
+
+//Main Tets Class Declaration
+class TEST_EXPORT TestConvergedMessageUtils: public QObject
+    {
+    Q_OBJECT
+
+private slots:
+    
+    /**
+	 * Initialises the whole Test
+	 **/  
+    void initTestCase();//called before the first testfunction is executed.
+    
+    /**
+	 * Initialises each Test Case
+	 **/  
+    void init();//called before each testfunction is executed.
+        
+    /**
+	 * Creates a MMS messsage
+	 **/  
+	void createMMS();
+	
+	/**
+	 * Tests the MMS message
+	 **/  
+	void testMMS();
+	
+	/**
+	 * Test Methods of ConvergedMessageId which were not part of the tests above
+	 **/ 
+	void testConvergedMessageIdUnusedMethods();
+	
+
+	/**
+	 * Test Methods of ConvergedMessageAttachment which were not part of the tests above
+	 **/
+	void testConvergedMessageAttachmentUnusedMethods();
+	
+	/**
+	 * Cleans up each Test Case
+	 **/ 
+	void cleanup();//called after every testfunction.
+	
+	/**
+	 * Cleans up the whole Test Case
+	 **/  
+    void cleanupTestCase();//called after the last testfunction was executed.
+
+private: //Data
+    
+    /**
+	 * msgPlugin - MMS Message Plug-in
+	 **/  	
+	UniEditorMmsPlugin* msgPlugin;
+	
+	/**
+	 * mmstestbed - MMS Message Simulator
+	 **/  	
+	MmsTestBed* mmstestbed;
+	
+	/**
+	 * spy_draft - Signal Spy for Draft Folder
+	 **/  	
+	QSignalSpy* spy_draft;
+	
+	/**
+	 * mmsMsgId - The MMS message Id
+	 **/  	
+	long int mmsMsgId;
+	};
+#endif //TEST_MMS_PLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.ini	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: Input data Set File for TestConvergedMessageUtils test cases
+ */
+
+const char TEST_MSG_BODY[]        = "TestTextE_1_2";
+const char TEST_MSG_SUBJECT[]     = "Message Subject";
+const char TEST_SENDER[]			= "+919860479112";
+const char TEST_ATTACHMENT[]		= "c:\\sample.txt";
+const char TEST_CC[]			= "DummyCCAddress";
+const char TEST_BCC[]			= "DummyBCCAddress";
+const char TEST_ALIAS[]			= "DummySenderAlias";
+
+//out put directory for test results.
+QString OUTPUTDIRECTORY = "c:/logs/TestConvergedMessageUtils";
+//o/p directory for data to be written on temp file.
+QString TEMPDIR = "c:/logs/TestConvergedMessageUtils/testdata";
+//test result O/P file name.
+QString RESULTFILE = "c:/logs/TestConvergedMessageUtils/result_%1.txt";
+// folder named UID3 of msgapptestsuite inside private folder.
+const QString PRIVATE_DIR("C:/private/E39cd515");
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/src/testconvergedmessageutils.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: Main test class definition for ConvergedMessageUtils
+ */
+
+#include <QtTest/QtTest>
+#include <QTimer>
+#include <QSignalSpy>
+#include "debugtraces.h"
+#include "testconvergedmessageutils.h"
+#include "convergedmessage.h"
+#include "convergedmessageid.h"
+#include "unieditormmsplugin.h"
+#include "mmstestbed.h"
+#include "testconvergedmessageutils.ini"
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::initTestCase
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::initTestCase()
+{
+	//register user defined object to meta system.
+	qRegisterMetaType<long int> ("long int");
+		
+	//Verify MmsTestBed Instance. 
+	mmstestbed = new MmsTestBed;
+	QVERIFY(mmstestbed != NULL);
+	
+	//Instantiate UniEditorMmsPlugin and verify if it is correctly Instantited. 
+	msgPlugin = new UniEditorMmsPlugin();
+	QVERIFY(msgPlugin != NULL);
+	
+	//set up signalspy to listen to signals emitted by mmstestbed
+	spy_draft = new QSignalSpy(mmstestbed, SIGNAL(entryCreatedInDraft(long int)));
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::init
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::init()
+{
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::createMMS
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::createMMS()
+{
+    //Create a Converged Message instance. 
+    QString subject  = TEST_MSG_SUBJECT;
+    
+    qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
+	
+	QString sender(TEST_SENDER);
+	ConvergedMessageAddress address(sender);
+	ConvergedMessageAttachmentList attachmentList;    
+
+	//Add a text attachment to attachment list. 
+	QString attachmentPath = TEST_ATTACHMENT;
+	ConvergedMessageAttachment* attachment = 
+		new ConvergedMessageAttachment(attachmentPath, ConvergedMessageAttachment::EAttachment);
+	
+	attachmentList.append(attachment);
+	
+	//Instantiate a Converged Message object and set service a MMS
+	ConvergedMessage msg;
+	
+	msg.setMessageType(ConvergedMessage::Mms);
+	
+	//Set Subject
+	msg.setSubject(subject);
+	
+	//Set Timestamp and verify
+	msg.setTimeStamp(timeStamp);
+	QVERIFY(timeStamp == msg.timeStamp());
+	
+	//Set Alias to an address
+	address.setAlias(QString (TEST_ALIAS));
+	
+	//Set recipient. 
+	msg.addToRecipient(address);
+	
+	//Add attachments' list
+	msg.addAttachments(attachmentList);
+	msg.setPriority(ConvergedMessage::Normal);
+	
+	//Adding CC Address
+	QString ccAddress(TEST_CC);
+	ConvergedMessageAddress ccAdd(ccAddress);
+	msg.addCcRecipient(ccAdd);
+	
+	//Adding BCC Address
+	QString bccAddress(TEST_BCC);
+	ConvergedMessageAddress bccAdd(bccAddress);
+	msg.addBccRecipient(bccAdd);
+	
+	//Adding From Address
+	QString recipientAddress(TEST_SENDER);
+	ConvergedMessageAddress recipientAdd(recipientAddress);
+	msg.addFromRecipient(recipientAdd);
+	
+	//Set Body Text and verify
+	msg.setBodyText(QString(TEST_MSG_BODY));
+	QVERIFY(msg.bodyText().compare(QString(TEST_MSG_BODY)) == 0);
+	
+	//Removing Body Text as MMS messages do not contain Body Text
+	msg.setBodyText(QString(NULL));
+	
+	//Set Property and Verify
+	msg.setProperty(ConvergedMessage::Attachment);
+	msg.setProperty(ConvergedMessage::Unread);
+	QVERIFY(msg.properties() == ConvergedMessage::Attachment | ConvergedMessage::Unread);
+	QVERIFY(msg.hasAttachment() == true);
+	QVERIFY(msg.isUnread() == true);
+			
+	//Set Location
+	msg.setLocation(ConvergedMessage::Draft);
+	
+	//Set Sending State and Verify
+	msg.setSendingState(ConvergedMessage::Waiting);
+	QVERIFY(msg.sendingState() == ConvergedMessage::Waiting);
+	
+	//Set Direction
+	msg.setDirection(ConvergedMessage::Outgoing);
+	
+	//Set Priority
+	msg.setPriority(ConvergedMessage::Normal);
+	
+	//Set Sub Type and verify
+	msg.setMessageSubType(ConvergedMessage::NokiaService);
+	QVERIFY(msg.messageSubType() == ConvergedMessage::NokiaService);
+	
+	//Create another Converged Message
+	ConvergedMessage msgCopyFirst(msg);
+	ConvergedMessage msgCopySecond(*(msg.id()));//by Id
+	QCOMPARE(msgCopySecond.id()->getId(), msg.id()->getId());//Verify if the copy was as expected
+	
+	//Create a Converged Message with serializing and deserializing and verify
+	QFile file("c:\\test.txt");
+	file.open(QIODevice::WriteOnly);
+	QDataStream out(&file);   // Serialize the data into the file
+	msg.serialize(out);   // Serialize a string
+	file.close();
+ 
+	file.open(QIODevice::ReadOnly);
+	QDataStream in(&file);    // read the data serialized from the file
+	
+	ConvergedMessage msgCopyThird;//Third Copy of the Actual Message
+	msgCopyThird.deserialize(in);
+	file.close();
+	
+	//Verify the 3rd Copy with the Original Copy
+	QVERIFY(msgCopyThird.id()->getId() == msg.id()->getId());
+	QCOMPARE(msgCopyThird.subject(), msg.subject());
+	QVERIFY(msgCopyThird.messageType() == msg.messageType());
+	
+	//Get a valid MMS message ID and verify that it is valid.
+	mmsMsgId = msgPlugin->convertTo(&msgCopyFirst);
+	QVERIFY(mmsMsgId != -1);
+	QDEBUG_WRITE("MMS Successfully Sent to Dratfs Folder");
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::testMMS
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::testMMS()
+{
+	long int mmsDraftMsgId;
+	
+	//check if draft-folder signal was received...this means message was created in draft 
+	if( 1 <= spy_draft->count())
+	{
+		//compare the msgid and verify with the ID given by MMS plugin 
+		void * temp = const_cast<void*>(spy_draft->at(0).at(0).data());
+		mmsDraftMsgId = *reinterpret_cast< long int(*)>(temp);
+		QVERIFY(mmsDraftMsgId == mmsMsgId);
+		
+		//Validate the MMS message with all the values set before. 
+		ConvergedMessage* draftMsg = msgPlugin->convertFrom(mmsDraftMsgId);
+		QVERIFY(draftMsg->subject().compare(QString(TEST_MSG_SUBJECT)) == 0);
+		QVERIFY(draftMsg->messageType() == ConvergedMessage::Mms);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->toAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_ALIAS).contains(draftMsg->toAddressList()[0]->alias(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_CC).contains(draftMsg->ccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_BCC).contains(draftMsg->bccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->fromAddress()->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(draftMsg->attachments().count() == 1);
+		QVERIFY(draftMsg->attachments()[0]->attachmentType() == ConvergedMessageAttachment::EAttachment);
+		QVERIFY(draftMsg->attachments()[0]->filePath().contains(QString(TEST_ATTACHMENT).mid(QString(TEST_ATTACHMENT).indexOf(QString("Sample.txt"), 0, Qt::CaseInsensitive)), Qt::CaseInsensitive) == true);
+		QVERIFY(draftMsg->location() == ConvergedMessage::Draft);
+		QVERIFY(draftMsg->priority() == ConvergedMessage::Normal);
+		QVERIFY(draftMsg->direction() == ConvergedMessage::Outgoing);
+		QDEBUG_WRITE("MMS Successfully Verified at Drafts Folder");
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to create message in Draft");
+	}
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::testConvergedMessageIdUnusedMethods
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::testConvergedMessageIdUnusedMethods()
+{
+	//Create a copy of ConvergedMessageId object from another object
+	ConvergedMessageId msgId1;
+	msgId1.setId(0x646);
+	
+	//Verify if the two objects match
+	ConvergedMessageId msgId3;
+	msgId3 = msgId1;
+	QVERIFY(msgId3 == msgId1);
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::testConvergedMessageAttachmentUnusedMethods
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::testConvergedMessageAttachmentUnusedMethods()
+{
+	//Set Attachment File Path and Type and Verify
+	ConvergedMessageAttachment msgAttachment;
+	msgAttachment.setFilePath(QString(TEST_ATTACHMENT));
+	QCOMPARE(msgAttachment.filePath(), QString(TEST_ATTACHMENT));
+	msgAttachment.setAttachmentType(ConvergedMessageAttachment::EAttachment);
+	QVERIFY(msgAttachment.attachmentType() == ConvergedMessageAttachment::EAttachment);
+	
+	//Second Copy with same Contents
+	ConvergedMessageAttachment msgAttachmentCopy;
+	msgAttachmentCopy.setFilePath(QString(TEST_ATTACHMENT));
+	msgAttachmentCopy.setAttachmentType(ConvergedMessageAttachment::EAttachment);
+	
+	//Verify if they are same
+	QVERIFY(msgAttachmentCopy == msgAttachment);
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::cleanup
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::cleanup()
+{
+}
+
+//---------------------------------------------------------------
+// TestConvergedMessageUtils::cleanupTestCase
+//---------------------------------------------------------------
+void TestConvergedMessageUtils::cleanupTestCase()
+{
+	//Cleanup
+	mmstestbed->cleanAll();//Clean All messages from varios Folders
+	delete spy_draft;//Signal for Draft Folder
+	delete msgPlugin;//MMS Plugin
+	delete mmstestbed;//MMS Testbed
+}
+
+//---------------------------------------------------------------
+// getObject
+// factory method to create objects.
+//---------------------------------------------------------------
+QObject* getObject(QString className)
+{
+    if(className == "TestConvergedMessageUtils" )
+    {
+        return new TestConvergedMessageUtils;
+    }
+ 	else
+	{
+		return 0;
+	}
+}
+
+//---------------------------------------------------------------
+// createOutPutDirectory
+// creating o/p directory.
+//---------------------------------------------------------------
+void createOutPutDirectory()
+    {
+    QDir dir;
+    //o/p dir
+    dir.mkdir(OUTPUTDIRECTORY);
+    //tmp dir
+    dir.mkdir(TEMPDIR);
+    // dir inside private folder.
+    dir.mkdir(PRIVATE_DIR);
+    }
+
+//---------------------------------------------------------------
+// main
+// main entry point
+//---------------------------------------------------------------
+int main(int argc, char *argv[])
+    { 
+    int ret = -1;
+    QCoreApplication app(argc, argv);    
+    
+    //creating output directory.
+    createOutPutDirectory();
+    
+    //the configuration file.
+    QFile data("c:/testconvergedmessageutils.cfg");
+
+    if (data.open(QFile::ReadOnly)) 
+        {
+        QTextStream in(&data);
+        while(!in.atEnd())
+            {
+            QStringList args;
+            QString appName = argv[0];
+            args << appName;
+
+            QString option  = "-o";
+            args << option;
+
+            QString outFile = RESULTFILE;
+            QString name = in.readLine();
+            outFile = outFile.arg(name);
+            args << outFile;
+
+            QObject* tc = getObject(name);
+
+            if(tc)
+                {
+                ret =  QTest::qExec(tc, args); 
+                delete tc;
+                }
+            }
+        }    
+    data.close();
+    return ret;
+    }
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.cfg	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,1 @@
+TestConvergedMessageUtils
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pl	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,182 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Test Case Report Generation file for ConvergedMessageUtils
+#
+#!/usr/bin/perl -w
+use warnings;
+use strict;
+
+my $TOTALCASES 		= 0;
+my $TOTALPASSED 	= 0;
+my $TOTALRUN 			= 0;
+my $TOTALFAILED 	= 0;
+my $TOTALSKIPPED 	= 0;
+
+sub parse_line
+{
+	my $line = $_[0];
+	my @parts = split (" ", $line);
+	my $passed  = $parts[1];
+	my $failed  = $parts[3];
+	my $skipped = $parts[5];
+	
+	my $total = $passed + $failed + $skipped;
+	my $passrate = $passed * 100 / $total;
+	my $passrateround = sprintf("%.0f",$passrate);
+	my $runrate = ($total - $skipped)*100/$total;
+	my $runrateround = sprintf("%.0f",$runrate);
+	
+	$TOTALCASES += $total;
+	$TOTALPASSED += $passed;
+	$TOTALRUN += ($total - $skipped);
+	$TOTALFAILED += $failed;
+	$TOTALSKIPPED  += $skipped;
+	
+	printf MYFILE "<td>\n";
+	printf MYFILE "$passed\n";
+	printf MYFILE "</td>\n";
+	
+	if($failed > 0)
+	{
+	printf MYFILE "<td style=\"font-weight:bold;color:red\">\n";
+	printf MYFILE "$failed\n";
+	printf MYFILE "</td>\n";
+	}
+	else
+	{
+	printf MYFILE "<td>\n";
+	printf MYFILE "$failed\n";
+	printf MYFILE "</td>\n";	
+	}
+
+	printf MYFILE "<td>\n";
+	printf MYFILE "$skipped\n";
+	printf MYFILE "</td>\n";
+
+	printf MYFILE "<td>\n";
+	printf MYFILE "$total\n";
+	printf MYFILE "</td>\n";
+	 
+	printf MYFILE "<td>\n";
+	printf MYFILE ("$passrateround %%\n");
+	printf MYFILE "</td>\n";
+
+	printf MYFILE "<td>\n";
+	printf MYFILE "$runrateround %%\n";
+	printf MYFILE "</td>\n";
+	
+	
+}
+
+sub parse_file
+	{
+		my $pattern = "Totals";
+		my $file = $_[0];
+		open (FILE,$file);
+	
+		while (my $line= <FILE>)
+		{
+			chomp ($line);
+		if ($line =~ m/$pattern/)
+			{				
+			parse_line $line;
+			}
+		}
+		close(FILE);
+	}
+
+
+sub generate_report
+	{
+		open (MYFILE, '>/epoc32/winscw/c/logs/TestConvergedMessageUtils/report.html');
+		printf MYFILE "<html>\n"; 
+		printf MYFILE "<body>\n";
+		printf MYFILE "<head>\n"; 
+		printf MYFILE "<title>ConvergedMessageUtils Test Reports</title>"; 
+		printf MYFILE "</head>\n";
+		printf MYFILE "<h2 align = center>ConvergedMessageUtils Test Report</h2>\n";
+		printf MYFILE "<table border = 2 cellpadding = 10 align = center>\n";
+		printf MYFILE "<tr style = \" background-color:lavender \">\n";
+		printf MYFILE "<th>Module</th>\n";
+		printf MYFILE "<th style = color:green>Passed</th>\n";
+		printf MYFILE "<th style = color:red>Failed</th>\n";
+		printf MYFILE "<th style = color:chocolate>Skipped</th>\n";
+		printf MYFILE "<th>Total Cases</th>\n";
+		printf MYFILE "<th>Pass Rate</th>\n";
+		printf MYFILE "<th>Run Rate</th>\n";
+		printf MYFILE "</tr>\n";
+		
+		
+		my @files = </epoc32/winscw/c/logs/TestConvergedMessageUtils/*.txt>;
+		foreach my $file (@files) 
+		{	
+			my @splitedpath = split("/",$file);
+			my $filename = $splitedpath[-1];	
+			my $length = length($filename);
+		  my $name = substr($filename,11,$length-15);
+		  printf MYFILE "<tr>\n";
+		  printf MYFILE "<td>\n";
+		  printf MYFILE "<a HREF=$filename style = text-decoration:none><b>$name</b></a>\n";
+		  printf MYFILE "</td>\n";
+		  
+		  parse_file $file;
+		  
+		  printf MYFILE "</tr>\n";
+		}
+		
+		printf MYFILE "<tr style= \"font-weight:bold; color:white; background-color:gray\">\n";
+		printf MYFILE "<td>\n";
+		printf MYFILE "<b>Overall</b>\n";
+		printf MYFILE "</td>\n";
+		
+		
+		printf MYFILE "<td>\n";
+		printf MYFILE "$TOTALPASSED\n";
+		printf MYFILE "</td>\n";
+		
+		printf MYFILE "<td>\n";
+		printf MYFILE "$TOTALFAILED\n";
+		printf MYFILE "</td>\n";
+		
+		printf MYFILE "<td>\n";
+		printf MYFILE "$TOTALSKIPPED\n";
+		printf MYFILE "</td>\n";
+		
+		printf MYFILE "<td>\n";
+		printf MYFILE "$TOTALCASES\n";
+		printf MYFILE "</td>\n";
+		
+		my $passrate = $TOTALPASSED*100/$TOTALCASES;
+		my $passrateround = sprintf("%.0f",$passrate);
+		printf MYFILE "<td>\n";
+		printf MYFILE "$passrateround%%\n";
+		printf MYFILE "</td>\n";
+		
+		my $runrate = ($TOTALCASES - $TOTALSKIPPED)*100/$TOTALCASES;
+		my $runrateround = sprintf("%.0f",$runrate);
+		printf MYFILE "<td>\n";
+		printf MYFILE "$runrateround%%\n";
+		printf MYFILE "</td>\n";
+		
+		printf MYFILE "</tr>\n";
+		
+		printf MYFILE "</table>\n";
+	  printf MYFILE "</body>\n"; 
+		printf MYFILE "</html>\n";
+			
+		close (MYFILE);
+	}
+
+
+generate_report;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,103 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Test Case Project Definition for ConvergedMessageUtils
+#
+
+QT += testlib
+QT -= gui
+
+TEMPLATE = app
+TARGET = testconvergedmessageutils
+
+
+INCLUDEPATH += ./inc
+INCLUDEPATH += ../../inc
+INCLUDEPATH += ../mmstestbed/inc
+INCLUDEPATH += ../../../../../inc
+INCLUDEPATH += ../../../s60qconversions/inc
+INCLUDEPATH += ../../../unidatautils/unidatamodel/inc
+INCLUDEPATH += ../../../../../../../mw/hb/include/hbcore
+INCLUDEPATH += ../../../unieditorutils/editorgenutils/inc
+INCLUDEPATH += ../../../unieditorutils/unieditorplugins/unieditormmsplugin/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+DEFINES += BUILD_TEST_DLL
+CONFIG += hb plugin
+
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+
+SOURCES += \
+  ./src/testconvergedmessageutils.cpp \
+  ../../../unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin.cpp \
+  ../../../unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp  
+
+# Input
+HEADERS += \
+  ./inc/testconvergedmessageutils.h \
+  ../../../unieditorutils/unieditorplugins/unieditormmsplugin/inc/unieditormmsplugin.h \
+  ../../../unieditorutils/unieditorplugins/unieditormmsplugin/inc/unieditormmsplugin_p.h 
+   
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+    symbian {
+    TARGET.CAPABILITY = All -TCB -DRM
+    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000
+    BLD_INF_RULES.prj_exports += "testconvergedmessageutils.cfg c:/testconvergedmessageutils.cfg"
+    BLD_INF_RULES.prj_exports += "testconvergedmessageutils.pl c:/testconvergedmessageutils.pl"
+	}
+	
+LIBS += -leuser \
+    -lconvergedmessageutils \
+    -ls60qconversions \
+    -lMsgMedia \
+    -leditorgenutils \
+    -lcone \
+    -leikcoctl \
+    -leikcore \
+    -leikdlg \
+    -lmsgs \
+    -letext \
+    -lgsmu \
+    -lmmsgenutils \
+    -lefsrv \
+    -lestor \
+    -lsmcm \
+    -lCommonEngine \
+    -lbafl \
+    -lCdlEngine \
+    -lFeatMgr \
+    -lapmime \
+    -lapgrfx \
+    -lcharconv \
+    -lInetProtUtil \
+		-lsmildtd \  
+		-lxmldom \
+  	-lxmlparser \
+  	-lcone \
+  	-lQtCore \
+  	-letel \
+  	-lcommdb \
+  	-lcommsdat \
+  	-letelmm \
+  	-lunidatamodelloader \
+  	-lunidatamodel \
+  	-lavkon \
+  	-leikcoctl \
+  	-leikctl \
+  	-lform \
+  	-luiklaf\ 
+  	-lmmstestbed \
+        -lmmsmessage \ 
+	-lmmsserversettings \
+	-lxqutils
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/convergedmessageutils/tsrc/tsrc.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Project Definiton File for both MMSTestBed and TestConvergedMessageUtils 
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS += mmstestbed/mmstestbed.pro 
+SUBDIRS += testconvergedmessageutils/testconvergedmessageutils.pro 
+
+CONFIG += ordered
\ No newline at end of file
--- a/messagingapp/msgutils/unidatautils/unidatamodel/src/UniDataUtils.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unidatautils/unidatamodel/src/UniDataUtils.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -36,7 +36,7 @@
 #include <StringLoader.h>           // for StringLoader (load and foramt strings from resources)
 #include <CommonContentPolicy.h>
 
-#include <UniDataModel.rsg>           // Viewer/Editor Mimetype strings
+#include <unidatamodel.rsg>           // Viewer/Editor Mimetype strings
 
 #include "UniModelConst.h"
 #include "UniDataUtils.h"
--- a/messagingapp/msgutils/unidatautils/unidatamodel/src/UniObjectList.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unidatautils/unidatamodel/src/UniObjectList.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -323,7 +323,7 @@
     TUriParser8 parser;
 	if( !url8bit )
         {
-		return;
+		return NULL;
 		}
 
     if( aUrl.MatchF( KContentIdString ) == 0 )
--- a/messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilModel.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilModel.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -59,7 +59,7 @@
 
 
 // MsgDataUTILS
-#include <UniDataModel.rsg>         // Viewer/Editor Mimetype strings
+#include <unidatamodel.rsg>         // Viewer/Editor Mimetype strings
 #include "UniModelConst.h"              // Definitions and enums
 #include "UniDataUtils.h"
 #include "UniSmilSlide.h"
--- a/messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilParams.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unidatautils/unidatamodel/src/UniSmilParams.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -25,7 +25,7 @@
 #include <bautils.h>
 #include <data_caging_path_literals.hrh>
 
-#include <UniDataModel.rsg>
+#include <unidatamodel.rsg>
 
 #include "UniSmil.hrh"
 #include "UniSmilParams.h"
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -276,10 +276,14 @@
             {
                 QString textContent;
                 QFile file(slideContentList.at(i)->path());
-                file.open(QIODevice::ReadOnly);
-                textContent = file.readAll();
-                aMessage.setBodyText(textContent);
-                file.close();
+                if (file.open(QIODevice::ReadOnly)) {
+                    textContent = file.readAll();
+                    aMessage.setBodyText(textContent);
+                    file.close();
+                }
+                else {
+                    return;
+                }
             }
             else
             {
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/bwins/test_mms_pluginu.def	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-EXPORTS
-	qt_plugin_instance @ 1 NONAME
-	qt_plugin_query_verification_data @ 2 NONAME
-	?createMMSMessageWithAttachmentAndSend@TestMmsPlugin@@AAEXH@Z @ 3 NONAME ; void TestMmsPlugin::createMMSMessageWithAttachmentAndSend(int)
-	?validateMsg@TestMmsPlugin@@AAEXABVConvergedMessage@@ABVQString@@@Z @ 4 NONAME ; void TestMmsPlugin::validateMsg(class ConvergedMessage const &, class QString const &)
-	?tr@TestMmsPlugin@@SA?AVQString@@PBD0@Z @ 5 NONAME ; class QString TestMmsPlugin::tr(char const *, char const *)
-	?getStaticMetaObject@TestMmsPlugin@@SAABUQMetaObject@@XZ @ 6 NONAME ; struct QMetaObject const & TestMmsPlugin::getStaticMetaObject(void)
-	?cleanupTestCase@TestMmsPlugin@@AAEXXZ @ 7 NONAME ; void TestMmsPlugin::cleanupTestCase(void)
-	?testReceived@TestMmsPlugin@@AAEXH@Z @ 8 NONAME ; void TestMmsPlugin::testReceived(int)
-	?qt_metacast@TestMmsPlugin@@UAEPAXPBD@Z @ 9 NONAME ; void * TestMmsPlugin::qt_metacast(char const *)
-	?qt_metacall@TestMmsPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int TestMmsPlugin::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?trUtf8@TestMmsPlugin@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString TestMmsPlugin::trUtf8(char const *, char const *, int)
-	?staticMetaObject@TestMmsPlugin@@2UQMetaObject@@B @ 12 NONAME ; struct QMetaObject const TestMmsPlugin::staticMetaObject
-	?init@TestMmsPlugin@@AAEXXZ @ 13 NONAME ; void TestMmsPlugin::init(void)
-	?testSendMMS@TestMmsPlugin@@AAEXXZ @ 14 NONAME ; void TestMmsPlugin::testSendMMS(void)
-	?trUtf8@TestMmsPlugin@@SA?AVQString@@PBD0@Z @ 15 NONAME ; class QString TestMmsPlugin::trUtf8(char const *, char const *)
-	?tr@TestMmsPlugin@@SA?AVQString@@PBD0H@Z @ 16 NONAME ; class QString TestMmsPlugin::tr(char const *, char const *, int)
-	?createMMSMessageWithSmilTextAndImageAttachmentAndSend@TestMmsPlugin@@AAEXXZ @ 17 NONAME ; void TestMmsPlugin::createMMSMessageWithSmilTextAndImageAttachmentAndSend(void)
-	?cleanup@TestMmsPlugin@@AAEXXZ @ 18 NONAME ; void TestMmsPlugin::cleanup(void)
-	?initTestCase@TestMmsPlugin@@AAEXXZ @ 19 NONAME ; void TestMmsPlugin::initTestCase(void)
-	?testMmsReceived@TestMmsPlugin@@AAEXXZ @ 20 NONAME ; void TestMmsPlugin::testMmsReceived(void)
-	?metaObject@TestMmsPlugin@@UBEPBUQMetaObject@@XZ @ 21 NONAME ; struct QMetaObject const * TestMmsPlugin::metaObject(void) const
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmsreadfile.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSREADFILE_H
+#define MMSREADFILE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include <f32file.h>
+#include <msvstd.h>
+
+// forward references
+class CMmsAttaStructure;
+class CMmsHeaders;
+class CEikonEnv;
+class CMmsClientMtm;
+
+// Out-of-range value for any MMS header with assigned number
+// Used in coverage tests to get coverage for "default" branches
+// in "case" statements.
+const TInt KMmsTestIllegalValue = 255;
+
+//
+// TEST KEY WORDS
+// Extended to include all MMS headers to allow generation of arbitrary PDUs
+// Content type header cannot be separately defined,
+// it will always be "multipat/mixed" or "multipart/related"
+_LIT8( KTestEndOfFile,          "EOF" );
+_LIT8( KTestNewMessage,         "MESSAGE BEGIN" );
+//------------------------------------------------
+_LIT8( KTestMessageType,        "MESSAGE-TYPE" ); //X-Mms-Message-Type
+_LIT8( KTestDate,               "DATE" ); // Date
+_LIT8( KTestFrom,               "FROM" ); // From
+_LIT8( KTestTo,                 "TO" ); // To
+_LIT8( KTestCc,                 "CC" ); // Cc
+_LIT8( KTestBcc,                "BCC" ); // Bcc
+_LIT8( KTestSubject,            "SUBJECT" ); // Subject
+_LIT8( KTestExpiryRel,          "EXPIRY-REL" ); // X-Mms-Expiry, relative
+_LIT8( KTestExpiryAbs,          "EXPIRY-ABS" ); // X-Mms-Expiry, absolute
+_LIT8( KTestDeliveryTimeRel,    "DELIVERY-TIME-REL" ); // X-Mms-Delivery-Time, relative
+_LIT8( KTestDeliveryTimeAbs,    "DELIVERY-TIME-ABS" ); // X-Mms-Delivery-Time, absolute
+_LIT8( KTestPriority,           "PRIORITY" ); // X-Mms-Priority
+_LIT8( KTestSenderVisibility,   "SENDER-VISIBILITY" ); // X-Mms-Sender-Visibility
+_LIT8( KTestDeliveryReport,     "DELIVERY-REPORT" ); // X-Mms-Delivery-Report
+_LIT8( KTestReadReply,          "READ-REPLY" ); // X-Mms-Read-Report
+// ---------------------------------------------------
+_LIT8( KTestNewAttachment,      "ATTACHMENT" );
+_LIT8( KTestAttachmentType,     "ATTACHMENTTYPE" );
+_LIT8( KTestAttachmentName,     "ATTACHMENTNAME" );
+_LIT8( KTestAttachmentContLoc,  "ATTACHMENTCONTLOC" );
+_LIT8( KTestAttachmentCharset,  "ATTACHMENTCHARSET" );
+_LIT8( KTestAttachmentCid,      "ATTACHMENTCID" );
+_LIT8( KTestAttachmentRoot,     "ATTACHMENTROOT" );
+// content-type and x-type parameters for attachments
+// should appear in name-value pairs.
+// Test program is not responsible for verifying illegal scripts
+_LIT8( KTestAttContTypeParamName, "ContTypeParamName" );
+_LIT8( KTestAttContTypeParamValue, "ContTypeParamValue" );
+_LIT8( KTestAttXTypeParamName, "X-TypeParamName" );
+_LIT8( KTestAttXTypeParamValue, "X-TypeParamValue" );
+// -----------------------------------------------------
+_LIT8( KTestMessageClass,       "MESSAGE-CLASS" ); // X-Mms-Message-Class
+_LIT8( KTestDelivRepSendAllow,  "DELIV-REP-SEND-ALLOW" ); // X-Mms-Report-Allowed
+_LIT8( KTestAcceptAdvertis,     "ACCEPT-ADVERTISEMENTS" );
+_LIT8( KTestRetryCount,         "RETRY-COUNT" );
+_LIT8( KTestRetryInterval,      "RETRY-INTERVAL" );
+// -------------------------------------------------
+_LIT8( KTestAlias,				"ALIAS" );
+_LIT8( KTestFromAlias,			"FROMALIAS" );
+_LIT8( KTestToAlias,			"TOALIAS" );
+_LIT8( KTestCcAlias,			"CCALIAS" );
+_LIT8( KTestBccAlias,			"BCCALIAS" );
+// -------------------------------------------------
+// more Message headers to allow testing all possible PDUs and
+// MMS 1.1 headers
+_LIT8( KTestReplyCharging,      "REPLY-CHARGING" ); // X-Mms-Reply-Charging
+_LIT8( KTestReplyChargAbs,      "REPLY-CHARG-DEADLINE-ABS" ); // X-Mms-Reply-Charging, absolute
+_LIT8( KTestReplyChargRel,      "REPLY-CHARG-DEADLINE-REL" ); // X-Mms-Reply-Charging, relative
+_LIT8( KTestReplyChargSize,     "REPLY-CHARG-SIZE" ); // X-Mms-Reply-Charging-Size (octets)
+_LIT8( KTestReplyChargID,       "REPLY-CHARGING-ID" ); // X-Mms-Reply-Charging-ID
+_LIT8( KTestTID,                "TID" );
+_LIT8( KTestContentLocation,    "CONTLOC" ); // X-Mms-Content-Location
+// The following three must appear as triplets.
+// index must be first, address and date may appear in any order
+_LIT8( KTestPreviouslySentIndex, "PREVIOUSINDEX" ); // forwarded count for X-Mms-PreviouslySent headers
+_LIT8( KTestPreviouslySentBy,    "PREV-SENT-BY" ); // X-Mms-Previously-Sent-By
+_LIT8( KTestPreviouslySentDate,  "PREV-SENT-DATE" ); // X-Mms-Previously-Sent-Date
+//---
+_LIT8( KTestMessageId,           "MESSAGE-ID" ); // Message-ID
+_LIT8( KTestMessageSize,         "MESSAGE-SIZE" ); // X-Mms-Message-Size (octets)
+_LIT8( KTestVersion,             "MMS-VERSION" ); // X-MMS-Version (hex:, 10 = 1.0, 11 = 1.1 etc. )
+_LIT8( KTestReadStatus,          "READ-STATUS" ); // X-Mms-Read-Status
+_LIT8( KTestResponseStatus,      "RESPONSE-STATUS" ); // X-Mms-Response-Status
+_LIT8( KTestResponseText,        "RESPONSE-TEXT" ); // X-Mms-Response-Text
+_LIT8( KTestRetrieveStatus,      "RETRIEVE-STATUS" ); // X-Mms-Retrieve-Status
+_LIT8( KTestRetrieveText,        "RETRIEVE-TEXT" ); // X-Mms-Retrieve-Text
+_LIT8( KTestStatus,              "STATUS" ); // X-Mms-Status
+// -------------------------------------------------
+// MMS 1.2 headers
+_LIT8( KTestAttribute,          "ATTRIBUTE" ); // X-Mms-Attribute
+// The value should be one of the following:
+// BCC, CC, CONTENT, CONTENT-TYPE, DATE, DELIVERY-REPORT, DELIVERY-TIME-ABS,
+// EXPIRY-ABS, FROM, MESSAGE-CLASS, MESSAGE-ID, MESSAGE-SIZE, PRIORITY,
+// READ-REPLY, SUBJECT, TO, REPLY-CHARGING, REPLY-CHARGING-ID,
+// REPLY-CHARG-DEADLINE-ABS, REPLY-CHARG-SIZE, PREV-SENT-BY,
+// PREV-SENT-DATE, ADDITIONAL-HEADERS
+_LIT8( KTestDistributionIndicator,  "DISTRIBUTION-INDICATOR" ); // X-Mms-Distribution-Indicator
+_LIT8( KTestLimit,              "LIMIT" ); // X-Mms-Limit
+_LIT8( KTestMessageQuota,       "MESSAGE-QUOTA" ); // X-Mms-Mbox-Quota, message number
+_LIT8( KTestSizeQuota,          "SIZE-QUOTA" ); // X-Mms-Mbox-Quota, size quota
+_LIT8( KTestMessageTotal,       "MESSAGE-TOTAL" ); // X-Mms-Mbox-Totals, message number
+_LIT8( KTestSizeTotal,          "SIZE-TOTAL" ); // X-Mms-Mbox-Totals, total size
+_LIT8( KTestMessageCount,       "MESSAGE-COUNT" ); // X-Mms-Message-Count
+_LIT8( KTestAddKeyword,         "ADD-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestRemoveKeyword,      "REMOVE-KEYWORD" ); // X-Mms-MM-Flags
+_LIT8( KTestFilterKeyword,      "FILTER-KEYWORD" ); // X-Mms-MM-FLags
+_LIT8( KTestMMState,            "MESSAGE-STATE" ); // X-Mms-MM-State
+_LIT8( KTestQuota,              "QUOTA" ); // X-Mms-Quotas
+_LIT8( KTestStart,              "START" ); // X-Mms-Start
+_LIT8( KTestStore,              "STORE" ); // X-Mms-Store
+_LIT8( KTestStored,             "STORED" ); // X-Mms-Stored
+_LIT8( KTestStoreStatus,        "STORE-STATUS" ); // X-Mms-Store-Status
+_LIT8( KTestStoreStatusText,    "STORE-STATUS-TEXT" ); // X-Mms-Store-Status-Text
+_LIT8( KTestTotals,             "TOTALS" ); // X-Mms-Totals
+// Delete confirmation header structure
+// This consists of index, content location, response status and response status text.
+// All three values are not always necessary for each index, but at least content-location
+// and response status should be present.
+// The index retains its value until a new index is encountered.
+_LIT8( KTestDeleteInfoIndex,    "DELETESTATUSINDEX" ); // index for next delete info fields
+// This header must precede content-location, response-status and response-text fields
+// in a delete confirmation. Index retains its value until a new index is encountered.
+
+// Element descriptor header not implemented
+
+// Application id headers
+// These will officially be supported in MMS encapsulation version 1.3
+// Java has non-standard support even earlier
+
+_LIT8( KTestApplicId,            "APPLIC-ID" ); // X-Mms-Applic-ID
+_LIT8( KTestReplyApplicId,       "REPLY-APPLIC-ID" ); // X-Mms-Reply-Applic-ID
+_LIT8( KTestApplicInfo,          "AUX-APPLIC-INFO" ); // X-Mms-Aux-Applic-Info
+
+// Since Encapsulation 1.3
+_LIT8( KTestContentClass,        "CONTENT-CLASS" ); // X-Mms-Content-Class
+_LIT8( KTestDrmContent,          "DRM-CONTENT" ); // X-Mms-DRM-Content
+_LIT8( KTestAdaptationAllowed,   "ADAPTATION-ALLOWED" ); // X-Mms-Adaptation-Allowed
+_LIT8( KTestRecommendedRetrievalMode, "REC-RETRIEVAL-MODE" ); // X-Mms-Recommended-Retrieval-Mode
+_LIT8( KTestRecRetrievalModeText, "REC-RETR-MODE-TEXT" ); // X-Mms-Recommended-Retrieval-Mode-Text
+_LIT8( KTestReplaceId,           "REPLACE-ID" ); // X-Mms-Replace-ID
+_LIT8( KTestStatusText,          "STATUS-TEXT" ); // X-Mms-Status-Text
+_LIT8( KTestCancelId,            "CANCEL-ID" ); // X-Mms-Cancel-ID
+_LIT8( KTestCancelStatus,        "CANCEL-STATUS" ); // X-Mms-Cancel-Status
+
+// DATA TYPES
+#define aSet            1
+#define aReset          0
+#define PartCount      100
+#define MaxAttaCount   10
+#define DefaultBufLen 256
+#define MaxRecipients   5
+
+// status returned by ReadRow
+enum TTestReadStatus
+    {
+    ETestUnknown,
+    ETestNewMessage,
+    ETestNewAttachment,
+    ETestEof,    // End of file
+    ETestMessageType,
+    ETestDate,
+    ETestFrom,
+    ETestTo,
+    ETestCc,
+    ETestBcc,
+	ETestAlias,
+	ETestFromAlias,
+	ETestToAlias,
+	ETestCcAlias,
+	ETestBccAlias,
+    ETestSubject,
+    ETestExpiryRel,
+    ETestExpiryAbs,
+    ETestDeliveryTimeRel,
+    ETestDeliveryTimeAbs,
+    ETestPriority,
+    ETestSenderVisibility,
+    ETestDeliveryReport,
+    ETestReadReply,
+    ETestAttachmentType,
+//    ETestAttachmentName,
+    ETestAttachmentCharset,
+    ETestAttachmentCid,
+	ETestAttachmentRoot,
+    ETestSettings,
+    ETestMessageClass,
+    ETestDelivReportSendAllow,
+    ETestSingleMessageClass,
+    ETestReplyCharging,
+    ETestReplyChargAbs,
+    ETestReplyChargRel,
+    ETestReplyChargSize,
+    ETestReplyChargID,
+    ETestTID,
+    ETestContentLocation,
+    ETestPreviouslySentIndex,
+    ETestPreviouslySentBy,
+    ETestPreviouslySentDate,
+    ETestMessageId,
+    ETestMessageSize,
+    ETestVersion,
+    ETestReadStatus,
+    ETestResponseStatus,
+    ETestResponseText,
+    ETestRetrieveStatus,
+    ETestRetrieveText,
+    ETestStatus,
+    ETestAttribute,
+    ETestDistributionIndicator,
+    ETestLimit,
+    ETestMessageQuota,
+    ETestSizeQuota,
+    ETestMessageTotal,
+    ETestSizeTotal,
+    ETestMessageCount,
+    ETestAddKeyword,
+    ETestRemoveKeyword,
+    ETestFilterKeyword,
+    ETestMMState,
+    ETestQuota,
+    ETestStart,
+    ETestStore,
+    ETestStored,
+    ETestStoreStatus,
+    ETestStoreStatusText,
+    ETestTotals,
+    ETestDeleteInfoIndex,
+    ETestApplicId,
+    ETestReplyApplicId,
+    ETestApplicInfo,
+    ETestContentClass,
+    ETestDrmContent,
+    ETestAdaptationAllowed,
+    ETestRecommendedRetrievalMode,
+    ETestRecRetrievalModeText,
+    ETestReplaceId,
+    ETestStatusText,
+    ETestCancelId,
+    ETestCancelStatus,
+    ETestAttaRecommendedName,
+    ETestAttachmentContLoc,
+    ETestAttContTypeParamName,
+    ETestAttContTypeParamValue,
+    ETestAttXTypeParamName,
+    ETestAttXTypeParamValue
+
+    };
+
+// VALUE KEYWORDS
+_LIT( KPersonal,      "Personal" );
+_LIT( KAdvertisement, "Advertisement" );
+_LIT( KInformational, "Informational" );
+_LIT( KAuto,          "Auto" );
+_LIT( KLow,    "Low" );
+_LIT( KNormal, "Normal" );
+_LIT( KHigh,   "High" );
+_LIT( KHide,   "Hide" );
+_LIT( KShow,   "Show" );
+_LIT( KYes,    "Yes" );
+_LIT( KNo,     "No" );
+_LIT( KOn,     "On" );
+_LIT( KOff,     "Off" );
+_LIT( KDeferred, "Deferred" );
+_LIT( KExpired,  "Expired" );
+_LIT( KRetrieved, "Retrieved" );
+_LIT( KRejected, "Rejected" );
+_LIT( KUnrecognized, "Unrecognized" );
+_LIT( KIndeterminate, "Indeterminate" );
+_LIT( KForwarded, "Forwarded" );
+_LIT( KUnreachable, "Unreachable" );
+_LIT( KDraft, "Draft");
+_LIT( KSent, "Sent" );
+_LIT( KNew, "New" );
+// X-Mms-Message-Type
+_LIT( KSendReq, "SendReq" );
+_LIT( KSendConf, "SendConf" );
+_LIT( KNotifInd, "NotifInd" );
+_LIT( KNotifResp, "NotifResp" );
+_LIT( KRetrConf, "RetrConf" );
+_LIT( KAckInd, "AckInd" );
+_LIT( KDelInd, "DelInd" );
+_LIT( KReadReqInd, "ReadReqInd" );
+_LIT( KReadOrigInd, "ReadOrigInd" );
+_LIT( KForwardRec, "ForwardReq" );
+_LIT( KForwardConf, "ForwardConf" );
+_LIT( KMBoxStoreReq, "MBoxStoreReq" );
+_LIT( KMBoxStoreConf, "MBoxStoreConf" );
+_LIT( KMBoxViewReq, "MBoxViewReq" );
+_LIT( KMBoxViewConf, "MBoxViewConf" );
+_LIT( KMBoxUploadReq, "MBoxUploadReq" );
+_LIT( KMBoxUploadConf, "MBoxUploadConf" );
+_LIT( KMBoxDeleteReq, "MBoxDeleteReq" );
+_LIT( KMBoxDeleteConf, "MBoxDeleteConf" );
+_LIT( KMBoxDescr, "MBoxDescr" );
+_LIT( KDeleteReq, "DeleteReq" );
+_LIT( KDeleteConf, "DeleteConf" );
+_LIT( KCancelReq, "CancelReq" );
+_LIT( KCancelResp, "CancelConf" );
+// X-Mms-Read-Status
+_LIT( KRead, "Read" );
+_LIT( KDelNotRead, "DeletedNotRead" );
+// X-Mms-Reply-Charging
+_LIT( KRequested, "Requested" );
+_LIT( KReqTextOnly, "ReqTextOnly" );
+_LIT( KAccepted, "Accepted" );
+_LIT( KAccTextOnly, "AccTextOnly" );
+// X-Mms-Cancel-Status (only receival of request, not actual cancellation)
+_LIT( KCancelSuccessful, "CancelSuccess" );
+_LIT( KCancelCorrupted, "CancelCorrupted" );
+// X-Mms-Content-Class
+_LIT( KText, "Text" );
+_LIT( KImageBasic, "ImageBasic" );
+_LIT( KImageRich, "ImageRich" );
+_LIT( KVideoBasic, "VideoBasic" );
+_LIT( KVideoRich, "VideoRich" );
+_LIT( KMegaPixel, "MegaPixel" );
+_LIT( KContentBasic, "ContentBasic" );
+_LIT( KContentRich, "ContentRich" );
+// X-Mms-Recommended-Retrieval-Mode
+_LIT( KManual, "Manual" );
+
+//X-Mms-ResponseStatus
+// legacy values
+_LIT( KOk, "OK" );
+_LIT( KErrUnspecified, "Unspecified" );
+_LIT( KErrServiceDenied, "ServiceDenied" );
+_LIT( KErrMessageFormatCorrupt, "FormatCorrupt" );
+_LIT( KErrAddressUnresolved, "AddressUnresolved" );
+_LIT( KErrMessageNotFound, "MessageNotFound" );
+_LIT( KErrNetworkProblem, "NetworkProblem" );
+_LIT( KErrContentNotAccepted, "ContentNotAccepted" );
+_LIT( KErrUnsupportedMessage, "UnsupportedMessage" );
+// values since 1.1 (and 1.2)
+_LIT( KErrTransient, "TransientFailure" );
+_LIT( KErrTransientAddressUnresolved, "TransientAddressUnresolved" );
+_LIT( KErrTransientNotFound, "TransientMessageNotFound" );
+_LIT( KErrTransientNetworkproblem, "TransientNetworkProblem" );
+_LIT( KErrTransientPartialSuccess, "PartialSuccess" );
+_LIT( KErrPermanent, "PermanentFailure" );
+_LIT( KErrPermanentServiceDenied, "PermanentServiceDenied" );
+_LIT( KErrPermanentMessageFormatCorrupt, "PermanentFormatCorrupt" );
+_LIT( KErrPermanentAddressUnresolved, "PermanentAddressUnresolved" );
+_LIT( KErrPermanentNotFound, "PermanentMessageNotFound" );
+_LIT( KErrPermanentContentNotAccepted, "PermanentContentNotAccepted" );
+_LIT( KErrReplyChargingLimitNotMet, "ReplyChargingLimitNotMet" );
+_LIT( KErrReplyChargingRequestNotAccepted, "ReplyChargingRequestNotAccepted" );
+_LIT( KErrReplyChargingForwardingDenied, "ReplyChargingForwardingDenied" );
+_LIT( KErrReplyChargingNotSupported, "ReplyChargingNotSupported" );
+_LIT( KErrAddressHidingNotSupported, "AddressHidingNotSupported" );
+_LIT( KErrPermanentLackOfPrepaid, "PermanentLackOfPrepaid" );
+//X-Mms-RetrieveStatus (one extra value)
+_LIT( KErrRetrieveContentUnsupported, "PermanentContentUnsupported" );
+//X-Mms-Store-Status (one extra value)
+_LIT( KErrMMBoxFull, "MMBoxFull" );
+
+_LIT8( KTestContent,  "Content" ); // For attribute list only
+_LIT8( KTestAdditionalHeaders,  "ADDITIONAL-HEADERS" ); // For attribute list only
+_LIT8( KTestDeliveryTime,       "DELIVERY-TIME"); // for attribute list only
+_LIT8( KTestExpiry,             "EXPIRY"); // for attribute list only
+_LIT8( KTestReplyCharg,         "REPLY-CHARG-DEADLINE" ); // for attribute list only
+_LIT8( KTestContentType,        "CONTENT-TYPE" );  // for attribute list only
+
+/**
+*  CMmsReadFile
+*/
+NONSHARABLE_CLASS( CMmsReadFile ):public CBase
+    {
+    public:  // Constructors and destructor
+
+        static CMmsReadFile* NewL(RFs& aFs, RFileReadStream& aReadStream ); // Two-phased constructor.
+        virtual ~CMmsReadFile(); // Destructor
+
+    public: // New functions
+
+        TInt CompleteTestL(TInt aMessageCounter, CMmsHeaders& aMmsHeaders);
+        TTestReadStatus ReadRowL();
+        void CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders );
+		TInt FindAlias(TPtrC alias);
+		void SetAttaStructure( TBool aOldAttaStructure = EFalse );
+
+    protected:  // Functions from base classes
+
+    private:
+
+        CMmsReadFile(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL( RFs& aFs, RFileReadStream& aReadStream );
+        void Reset();
+
+    public: // data
+        TInt                            iMessageType;
+
+
+    private:     // Data
+
+        RFs                             iFs;
+        RFileReadStream*                iReader;
+        TBuf<DefaultBufLen>             iValueBuffer;
+        CDesCArray*     iAliasArray;    // aliases
+        HBufC8*         iByteBuffer;
+        TTime                           iDate;
+        CArrayPtrFlat<CMmsAttaStructure>* iAttaStructures;
+        TInt                            iAttaCount;
+		TInt							iAttaRoot;
+		TInt							iAliasCount;
+        TInt                            iNextMessageType;
+        TParse                          iParse;
+        TFileName                       iFilename;
+
+    protected:  // Data
+    private:    // Data
+
+        // CArrayFixFlat <TestMessage>* iMessages;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+    };
+
+
+NONSHARABLE_CLASS( CMmsAttaStructure ):public CBase
+    {
+    public:  // Constructors and destructor
+        static CMmsAttaStructure* NewL(); // Two-phased constructor.
+        virtual ~CMmsAttaStructure(); // Destructor
+    private:
+        CMmsAttaStructure(); // C++ default constructor.
+        // By default constructor is private.
+        void ConstructL();
+
+    public:     // Data
+        HBufC8*         iAtta;
+        HBufC8*         iAttaName; // content location
+        HBufC8*         iAttaType;
+        HBufC8*         iAttaCid;
+        TInt            iAttaCharset;
+        HBufC*          iAttaRecommendedName; // recommended filename
+       	CDesC8ArrayFlat* iContentTypeParams;  // zero or more "parameter"
+    	CDesC8ArrayFlat* iXTypeParams;        // zero or more X-Type "parameters"
+
+    };
+
+
+#endif      // MMSREADFILE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestbed.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTBED_H
+#define MMSTESTBED_H
+
+#ifdef BUILD_MMSTESTBED_DLL
+#define MMSTESTBED_EXPORT Q_DECL_EXPORT
+#else
+#define MMSTESTBED_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <QString>
+
+#include <msvids.h>  //for consts like KMsvNullIndexEntryIdValue
+#include <MSVAPI.H>
+#include <MTCLREG.H>
+#include <mmsclient.h>
+//#include <mmsservercommon.h>
+
+class CTestUiTimer;
+class CMsvSession;
+class CMmsClientMtm;
+class CMmsSettings;
+class CMmsHeaders;
+class CLogEvent;
+class CLogViewEvent;
+class CLogFilter;
+class CLogClient;
+
+class MMSTESTBED_EXPORT MmsTestBed : public QObject, public MMsvSessionObserver
+    {
+    Q_OBJECT
+
+public:
+    /**
+     *
+     */
+    MmsTestBed();
+    ~MmsTestBed();
+    void setConnectionLocal(bool value);
+    void fromOutboxToMmsc();
+    void fromMmscToInbox();
+    /**
+     * cleanup MMS service
+     */
+    void cleanupAndCreateNewService();
+    void deleteNotifications();
+    void restoreFactorySettings();
+    void setFetchingState( TMmsReceivingMode aState );
+    void sendFromFile();
+    void sendOneByOne();
+    void sendNotifications();
+    void copyDrafts();
+    void garbageCollection(TUint32 aReason = 0x00000001); //0x00000001 == KMmsReasonBoot
+    void messageVariation();
+    void cancelSendScheduling();
+    void scheduledSend(TMsvId aBoxId, TInt aDelay = 5);
+    void deleteSendSchedule();
+    void cancelFetchScheduling();
+    void fetchForced(TInt aDelay = 5);
+    void deleteFetchSchedule();
+    void doAFetchCycle();
+    void createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry);
+    void cleanOutbox();
+    void cleanInbox();
+    void cleanSent();
+    void cleanDrafts();
+    void cleanAll();
+    void reply();
+    void replyToAll();
+    void forward();
+    void sendReadReport(); // send a read report
+    int fromOutboxToMmscWithMemoryFailure(); // returns memory failure count
+    int fromMmscToInboxWithMemoryFailure(); // returns memory failure count
+    void sendViaClient();
+    void scheduledFetch(TInt aDelay = 5);
+    void fetchForcedImmediate();
+    void getEventType();
+    void addEventType();
+    void deleteEventType();
+    void cleanLog();
+    void setOnline(bool value);
+    void generateDeliveryReport( CMmsHeaders* aMmsHeaders );
+    void sendDeliveryReport();
+
+signals:
+    void entryCreatedInDraft(long int id);
+    void entryMovedToOutbox(long int id);
+    void entryMovedToSent(long int id);
+    void entryCreatedInInbox(long int id);
+
+protected:
+    /**
+     * From MMsvSessionObserver
+     */
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+            TAny* aArg2, TAny* aArg3);
+
+private:
+    void findDefaultL();
+    void createMmsService();
+    void cleanup();
+    void deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry);
+    void testFile(TFileName& aFilePath, TInt aCommand = 0, TMsvId aBox = KMsvGlobalOutBoxIndexEntryId);
+    void addMMBoxDescriptions();
+    void encodeMessageFromDrafts();
+    TMsvId findMMSFolder();
+    bool checkLogClient();
+    int getLogEntries();
+
+private:
+    //data
+    CTestUiTimer* iTimer;
+    CMsvOperationActiveSchedulerWait* iWait;
+    CMsvSession* iSession;
+    CClientMtmRegistry* iClientMtmRegistry;
+    CMmsClientMtm* iMmsClient;
+    CMmsSettings* iSettings;
+    CMmsHeaders* iMmsHeaders;
+    TMsvId iServiceId;
+    TMsvId iDefaultServiceId;
+    TMsvSessionEvent iEvent;
+    RFs iFs;
+    TFileName iFilename;
+    TFileName iCurrentFile;
+    TFileName iCurrentPath;
+    TParse iParse;     // parse buffer as member to save stack space
+    CBufFlat* iEncodeBuffer;
+    CMsvEntrySelection* iMsvEntrySelection;
+    CLogEvent* iLogEvent;
+    CLogClient* iLogClient;
+    CLogViewEvent* iLogView;
+    CLogFilter* iLogFilter;
+    };
+
+#endif // MMSTESTBED_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestbed.hrh	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <bldvariant.hrh>
+
+
+#ifndef MMSTESTBED_HRH
+#define MMSTESTBED_HRH
+
+enum
+{
+    EAppMainOk = 1,
+    EAppMainCancel,
+    //
+    EMenufrmCmdCascadeTest,
+    ECleanup,
+    ECleanOutbox,
+    ESaveSettings,
+    ELoadSettings,
+    ECleanInbox,
+    EShowIn,
+    EShowOut,
+    EOutToMMSC,
+    EMMSCToIn,
+    ESendScheduled,
+    EReceiveScheduled,
+    EShowSent,
+    ECleanSent,
+    EStartMyNotifier,
+    EGetEventType,
+    EAddEventType,
+    EDeleteEventType,
+    EViewLog,
+    ECleanLog,
+    EShowWapAccessPoints,
+    ESelectWapAccessPoint,
+    EShowConnectionMode,
+    EShowIAP,
+    EConnectToIAP,
+    EDeleteSendSchedule,
+    EDeleteReceiveSchedule,
+    EDeleteNotifications,
+    ERestoreFactorySettings,
+    ECreateFromFile,
+    EShowNotifications,
+    ESendDeliveryReport,
+    EShowDrafts,
+    ECleanDrafts,
+    ECleanAll,
+    EFetchingDeferred,
+    EFetchingOn,
+    ESendFromFile,
+    ESwitchToLocal,
+    ESwitchToGlobal,
+    EDecodeLoggingOn,
+    EDecodeLoggingOff,
+    EBinaryDumpOn,
+    EBinaryDumpOff,
+    ESendNotification,
+    ECreateToInbox,
+    ECreateToSentItems,
+    ESendFromDrafts,
+    EFindMMSFolder,
+    ESendOneByOne,
+    ECreateToDrafts,
+    ESendViaClient,
+    ESendMemFail,
+    EFetchMemFail,
+    EReceiveForced,
+    ECreateHeadersFromFile,
+    ESwitchToOffline,
+    ESwitchToOnline,
+    ECopyDrafts,
+    ECreateNotification,
+    EReply,
+    EReplyToAll,
+    EForward,
+    EFetchingManual,
+    EFirstBoot,
+    ENoFirstBoot,
+    EFindNetworkStatus,
+    ESendReadReport,
+    ECreateMMBoxViewConf,
+    EGetMMBoxView,
+    ECleanMMBox,
+    EShowMMBox
+};
+
+#define 	ETestLabel1 1
+#define 	ETestLabel2 2
+#define 	ETestLabel3 3
+#define 	ETestLabel4 4
+
+#define     EServiceList 2
+
+
+enum TTestBedDlgCtrlIds
+	{
+	ETestEditField = 1
+	};
+
+enum TEditServiceControls
+	{
+	EFolderLabel = 1,
+    EEditUri
+//	EEditServiceFolder,
+//	ENameLabel,
+//	EEditServiceName,
+//	ENumberLabel,
+//	EEditServiceNumber
+	};
+
+enum
+	{
+	EFsViewDialogId = 1
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmsteststaticutils.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef MMSTESTSTATICUTILS_H
+#define MMSTESTSTATICUTILS_H
+
+#include <e32std.h>
+#include <msvstd.h>
+#include <badesca.h>
+
+#include "mmsconst.h"
+
+class RFs;
+class CMsvSession;
+class CMmsEncode;
+class CMmsHeaders;
+
+#ifdef __WINS__
+_LIT( KRootPath, "c:\\" );
+#else
+// This is removable disk.
+// drive letter should not be hard coded, must be investigated further
+// We use c: for a while for the tests (to be cahnged later)
+_LIT( KRootPath, "c:\\" );
+//_LIT( KRootPath, "e:\\" );
+#endif
+
+// directory where mmbox descriptions are created
+_LIT( KMmsMMBoxDescriptionDirectory, "C:\\mmsmmboxdescriptions\\");
+// directory where created headers are dumped
+_LIT( KMmsDumpDirectory, "C:\\mmsdump\\");
+// content type of MMS PDUs
+_LIT8( KMmsMimeType, "application/vnd.wap.mms-message" );
+
+_LIT( KWild, "*" );
+
+
+/**
+ *  joined array structure
+ *
+ */
+NONSHARABLE_CLASS( TMmsJoinedArrays ): public MDesCArray
+    {
+public:
+    TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2);
+    TInt MdcaCount() const;
+    TPtrC16 MdcaPoint(TInt aIndex) const;
+private:
+    CDesCArray* const & iArray1;
+    CDesCArray* const & iArray2;
+    };
+
+/**
+ *  static utility functions
+ *
+ */
+class TMmsTestUtils
+    {
+
+public:
+
+    /**
+     *
+     */
+    TMmsTestUtils();
+
+    /**
+     * read phone number for sending messages
+     *
+     * @param aFileName full path for filename
+     * @param aFs file system handle
+     * @return allocated pointer containing the name
+     *     The caller must delete the pointer when no longer needed
+     */
+    static HBufC* ReadContactFromFileL( TDesC& aFileName, RFs& aFs );
+
+    static void DecodeLoggingOnL();
+    static void DecodeLoggingOffL();
+    static void BinaryDumpOnL();
+    static void BinaryDumpOffL();
+
+    /**
+     * Clean all temporary directories used in local mode.
+     * Does not delete the directories, only the contents
+     *
+     * @param aFs file system handle
+     */
+    static void CleanDirectoryL( RFs& aFs );
+
+    /**
+     * Dump a binary message
+     *
+     * @param aBuffer buffer containing the binary message
+     * @param aFilename full path of the directory whenre the dump goes
+     * @param aParse reference to parser (to save stack space)
+     * @param aFs file system handle
+     */
+    static void Dump(
+        CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs );
+
+    /**
+     * Delete all MMS messages and notifications from a given folder
+     *
+     * @param aBoxId folder id
+     * @param aSession Messaging server session
+     */
+    static void CleanBoxL(TMsvId aBoxId, CMsvSession& aSession);
+
+    /**
+     * turn on logging messages sent to email addresses
+     */
+    static void EmailLoggingOnL();
+
+    /**
+     * turn off logging messages sent to email addresses
+     */
+    static void EmailLoggingOffL();
+
+    /**
+     * load list of children into selection and return count
+     *
+     * @param aBoxId folder id
+     * @param aMsvEntrySelection reference to a pointer that will contain the list of child ids
+     *     caller is responsible of deleting the pointer afterwards.
+     *     Pointer may be NULL at entry, and a new pointer will be allocated
+     * @param aSession messge server session
+     * @param aMessageType child MTM type, default is multimedia message
+     * @return number of entries in selection
+     */
+    static TInt CountChildrenL(
+        TMsvId aBoxId,
+        CMsvEntrySelection*& aMsvEntrySelection,
+        CMsvSession& aSession,
+        TUid aMessageType = KUidMsgTypeMultimedia);
+
+    /**
+     * Create a folder entry
+     *
+     * @param aSession messge server session
+     * @param aParentFolder the parent folder
+     * @param aFolderName name of the folder
+     * @param aFolderId will contain the if of the new folder if creation was successful
+     */
+    static void CreateFolderEntryL(
+        CMsvSession& aSession,
+        TMsvId aParentFolder,
+        const TDesC& aFolderName,
+        TMsvId& aFolderId );
+
+    /**
+    * Create an MMS notification from data in buffer
+    * @param aNotificationFolder mms notification folder (target folder)
+    * @param aServiceId id of MMS service
+    * @param aEncodeBuffer buffer that contains the data
+    * @param aSession message server session
+    * @return id of the created notification
+    */
+    static TMsvId CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession );
+
+    /**
+    * Encode an MMS notification into buffer
+    * @param aUrl url of the notification for local messages a filepath
+    * @param aSize size of the message
+    * @param aMmsHeaders MMS headers structure for creating the notification
+    * @param aMmsEncoder reference to CMmsEncode class
+    * @param aEncodeBuffer flat buffer that will contain the encoded notification
+    */
+    static void FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer );
+
+
+    static TBool IsDrive(const TDesC& aFileName);
+    static TBool IsDir(const TDesC& aFileName, RFs& aFs);
+    static TBool IsFile(const TDesC& aFileName, RFs& aFs);
+
+
+private:
+
+    };
+
+
+#endif // MMSTESTSTATICUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/inc/mmstestuitimer.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#ifndef C_TESTUITIMER_H
+#define C_TESTUITIMER_H
+
+
+#include <e32base.h>
+
+#define KPeriod 10000 // period of timer
+
+/**
+ *  timer for test programs
+ */
+NONSHARABLE_CLASS( CTestUiTimer ): public CTimer
+    {
+public:
+
+    static CTestUiTimer* NewL();
+    virtual  ~CTestUiTimer();
+
+    void RunL();
+    void DoCancel();
+    void ConstructL();
+    void IssueRequest();
+    void TimeoutOperation(CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds);
+
+private:
+    CTestUiTimer();
+
+public:
+    TTimeIntervalMicroSeconds32 period;
+
+private: // data
+    CActive* iObject;
+    };
+
+#endif // C_TESTUITIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/mmstestbed.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,77 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+QT += testlib
+QT -= gui
+
+TEMPLATE = lib
+
+TARGET = mmstestbed
+
+INCLUDEPATH += .
+INCLUDEPATH += inc
+INCLUDEPATH += ../../inc
+INCLUDEPATH += ../../../../../../../mmsengine/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmshttptransport/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsmessage/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsconninit/inc
+#INCLUDEPATH += ../../../mmsengine/mmscodec/inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsserver/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+DEFINES += BUILD_MMSTESTBED_DLL
+
+SOURCES += src/mmstestbed.cpp \
+           src/mmsteststaticutils.cpp \
+           src/mmsreadfile.cpp \
+           src/mmstestuitimer.cpp
+
+HEADERS += inc/mmstestbed.h \
+           inc/mmsteststaticutils.h \
+           inc/mmsreadfile.h \
+           inc/mmstestuitimer.h \
+           inc/mmstestbed.hrh
+
+SYMBIAN_PLATFORMS = WINSCW ARMV5
+
+symbian {
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.EPOCSTACKSIZE = 0x8000
+    TARGET.EPOCHEAPSIZE = 0x1000 0x1F00000
+    TARGET.EPOCALLOWDLLDATA = 1 
+	}
+
+# Build.inf rules
+BLD_INF_RULES.prj_exports += \
+     "$${LITERAL_HASH}include <platform_paths.hrh>"
+
+LIBS += -lmsgs \
+        -lmmsmessage \
+        -lmmsconninit \
+        -lmmscodec \
+        -lmmsserversettings \
+        -lcentralrepository \
+        -lapparc \
+        -lbafl \
+        -lefsrv \
+        -lesock \
+        -lestor \
+        -leuser \
+        -llogcli \
+        -llogwrap \
+        -lapgrfx \
+        -lapmime
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmsreadfile.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,1799 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <badesca.h>
+#include    <e32def.h>
+#include    <s32file.h>
+#include    <msvids.h>
+#include    <mtmdef.h>
+//#include    <eikenv.h>
+#include    <apgcli.h>
+#include    <CMsvMimeHeaders.h>
+#include    <AknNoteWrappers.h>
+
+#include    <mmsservercommon.h>
+#include    "mmsconst.h"
+#include    "mmsclient.h"
+#include    "mmsheaders.h"
+#include    "mmsreadfile.h"
+#include    "mmsmmboxviewheaders.h"
+#include    "mmsmmboxmessageheaders.h"
+#include    "mmsmmboxflags.h"
+#include    "mmssettings.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMmsGranularity = 8;
+_LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsReadFile::CMmsReadFile()
+    {
+    // all member variables in a class derived from CBase
+    // are automatically set to 0.
+    }
+
+
+//
+void CMmsReadFile::ConstructL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    // iRowBuffer = HBufC8::NewMaxL( 500 ); // Max row length!!!!
+    iFs = aFs;
+    iReader = &aReadStream;
+    iByteBuffer = HBufC8::NewL( DefaultBufLen );
+    iAliasArray = new ( ELeave ) CDesCArrayFlat( KMmsGranularity );
+    iAttaStructures = new ( ELeave ) CArrayPtrFlat<CMmsAttaStructure>( KMmsGranularity );
+    Reset();
+    }
+
+// Two-phased constructor.
+CMmsReadFile* CMmsReadFile::NewL(RFs& aFs, RFileReadStream& aReadStream )
+    {
+    CMmsReadFile* self = new ( ELeave ) CMmsReadFile();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFs, aReadStream );
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// Destructor
+CMmsReadFile::~CMmsReadFile()
+    {
+    Reset(); // resets and destroys all array data
+    if (iAliasArray != NULL) iAliasArray->Reset();
+    delete iByteBuffer;
+    delete iAliasArray;
+    delete iAttaStructures;
+    }
+
+void CMmsReadFile::Reset()
+    {
+    // reset all arrays
+    if (iAttaStructures != NULL) iAttaStructures->ResetAndDestroy();
+    iAttaCount = 0;
+    iAttaRoot = 0;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CompleteTest
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::CompleteTestL( TInt aMessageCounter, CMmsHeaders& aMmsHeaders )
+{
+    Reset(); // new message
+
+    TUint32 val;
+    TUint   limit = 1000000;
+    TUint   sizeLimit = 1000 * 1024; //max message size 1000 kB!
+    TUint   allLimit = 999999;
+    TInt    error;
+    TRadix  radix = EDecimal;
+    TLex16  lex;
+    TTestReadStatus readStatus = ETestUnknown;
+    CMmsAttaStructure* oneAtta = NULL;
+	TInt    index;
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    TTime date;
+    TInt order = 0;
+    TInt16 shortInteger = 0;
+
+    //iso luuppi, joka kiertää ja lukee kunnes EOF tule vastaan
+    //Big Loop, which passes around and read until the EOF
+
+    iMessageType = iNextMessageType;
+    while(readStatus != ETestEof)
+        {
+        readStatus = ReadRowL();
+        if ( readStatus ==  ETestEof )
+            {
+            return(-1);
+            }
+        if ( readStatus == ETestUnknown )
+            {
+            // A line containing only comments, or an unknown tag
+            // As using the scripts to test settings is no longer supported,
+            // any old keywords used to test CMmsSettings class are ignored
+            continue;
+            }
+        if( readStatus == ETestNewMessage )
+            {
+            iNextMessageType = readStatus;
+            if(aMessageCounter++)
+                {
+                return(NULL);
+                }
+            else
+                {
+                iMessageType = iNextMessageType;
+                continue;
+                }
+            }
+        if ( iMessageType == ETestNewMessage)
+            {
+            switch(readStatus)
+                {
+                case ETestFrom:
+                    aMmsHeaders.SetSenderL( iValueBuffer );
+                    break;
+                case ETestFromAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.SetSenderL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ) );
+	    				}
+                    break;
+                case ETestTo:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientTo );
+                    break;
+                case ETestToAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsTo );
+						}
+                    break;
+                case ETestCc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientCc );
+                    break;
+                case ETestCcAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsCc );
+						}
+                    break;
+                case ETestBcc:
+                    aMmsHeaders.AddTypedAddresseeL( iValueBuffer, EMsvRecipientBcc );
+                    break;
+                case ETestBccAlias:
+					index = FindAlias(iValueBuffer);
+					if(index >= 0)
+    					{
+                        aMmsHeaders.AddTypedAddresseeL( iAliasArray->MdcaPoint(index).Mid(iAliasArray->MdcaPoint(index).Locate('=') + 1 ), EMmsBcc );
+						}
+                    break;
+                case ETestSubject:
+                    aMmsHeaders.SetSubjectL( iValueBuffer );
+                    break;
+                case ETestExpiryRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetExpiryInterval( val );
+                        }
+                    break;
+                case ETestExpiryAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    // expiry date in seconds from 1.1.1970.
+                    aMmsHeaders.SetExpiryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDeliveryTimeRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetDeliveryTimeInterval( val );
+                        }
+                    break;
+                case ETestDeliveryTimeAbs:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDeliveryDate( (interval.Int64())/1000000 );
+                    break;
+                case ETestDate:
+                    error = iDate.Set(iValueBuffer);
+                    interval = iDate.MicroSecondsFrom( y1970 );
+                    aMmsHeaders.SetDate( (interval.Int64())/1000000 );
+                case ETestPriority:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KLow)) == 0)
+                        {
+                        val = EMmsPriorityLow;
+                        }
+                    else if ((iValueBuffer.CompareF(KNormal)) == 0)
+                        {
+                        val = EMmsPriorityNormal;
+                        }
+                    else if ((iValueBuffer.CompareF(KHigh)) == 0)
+                        {
+                        val = EMmsPriorityHigh;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessagePriority( val );
+                    break;
+                case ETestSenderVisibility:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KHide)) == 0)
+                        {
+                        val = EMmsSenderVisibilityHide;
+                        }
+                    else if ((iValueBuffer.CompareF(KShow)) == 0)
+                        {
+                        val = EMmsSenderVisibilityShow;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetSenderVisibility( val );
+                    break;
+                case ETestDeliveryReport:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDeliveryReport( val );
+                    break;
+                case ETestDelivReportSendAllow:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReportAllowed( val );
+                    break;
+
+                case ETestReadReply:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = EMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = EMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadReply( val );
+                    break;
+                case ETestNewAttachment:
+                    oneAtta = CMmsAttaStructure::NewL();
+                    iAttaStructures->AppendL(oneAtta);
+                    oneAtta->iAtta->Des().Copy( iValueBuffer );
+                    iAttaCount++;
+                    break;
+                case ETestAttachmentType:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaType->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentContLoc:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttaRecommendedName:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaRecommendedName->Des().Copy( iValueBuffer );
+                        }
+                    break;
+                case ETestAttachmentCharset:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        if (oneAtta != NULL)
+                            {
+                            oneAtta->iAttaCharset = val;
+                            }
+                        }
+                    break;
+                case ETestAttachmentCid:
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iAttaCid->Des().Copy(iValueBuffer);
+                        }
+                    break;
+                case ETestAttContTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttContTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iContentTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamName:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttXTypeParamValue:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if (oneAtta != NULL)
+                        {
+                        oneAtta->iXTypeParams->AppendL(iByteBuffer->Des());
+                        }
+                    break;
+                case ETestAttachmentRoot:
+                    iAttaRoot = iAttaCount;
+                    break;
+                case ETestAlias:
+                    // all aliases are global even if they appear
+                    // in the middle of a message
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+                case ETestMessageClass: // should be handled!
+                    val = EMmsClassPersonal;
+                    if ((iValueBuffer.CompareF(KPersonal)) == 0)
+                        {
+                        val = EMmsClassPersonal;
+                        }
+                    else if ((iValueBuffer.CompareF(KAdvertisement)) == 0)
+                        {
+                        val = EMmsClassAdvertisement;
+                        }
+                    else if ((iValueBuffer.CompareF(KInformational)) == 0)
+                        {
+                        val = EMmsClassInformational;
+                        }
+                    else if ((iValueBuffer.CompareF(KAuto)) == 0)
+                        {
+                        val = EMmsClassAuto;
+                        }
+                    else
+                        {
+                        val = (TMmsMessageClass)KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageClass( val );
+                    break;
+                case ETestReplyCharging:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRequested)) == 0)
+                        {
+                        val = KMmsReplyChargingRequested;
+                        }
+                    else if ((iValueBuffer.CompareF(KReqTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingRequestedTextOnly;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccepted)) == 0)
+                        {
+                        val = KMmsReplyChargingAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KAccTextOnly)) == 0)
+                        {
+                        val = KMmsReplyChargingAcceptedTextOnly;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReplyCharging( val );
+                    break;
+                case ETestReplyChargAbs:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.SetReplyChargingDate( (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestReplyChargRel:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingInterval( val );
+                        }
+                    break;
+                case ETestReplyChargSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetReplyChargingSize( val );
+                        }
+                    break;
+                case ETestReplyChargID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplyChargingIdL( iByteBuffer->Des() );
+                    break;
+                case ETestTID:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetTidL( iByteBuffer->Des() );
+                    break;
+                case ETestContentLocation:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteReq )
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().ContentLocationList().AppendL( iByteBuffer->Des() );
+                        }
+                    else if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteContentLocationL( order, iByteBuffer->Des() );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetContentLocationL( iByteBuffer->Des() );
+                        }
+                    break;
+                case ETestPreviouslySentIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+                case ETestPreviouslySentBy:
+                    aMmsHeaders.InsertPreviouslySentByL( order, iValueBuffer );
+                    break;
+                case ETestPreviouslySentDate:
+                    error = date.Set(iValueBuffer);
+                    if ( error == KErrNone )
+                        {
+                        interval = date.MicroSecondsFrom( y1970 );
+                        aMmsHeaders.InsertPreviouslySentDateL( order, (interval.Int64())/1000000 );
+                        }
+                    break;
+                case ETestMessageId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetMessageIdL( iByteBuffer->Des() );
+                    break;
+                case ETestMessageSize:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,sizeLimit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMessageSize( val );
+                        }
+                    break;
+                case ETestVersion:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,EHex,limit);
+                    shortInteger = TInt16( val );
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.SetMmsVersion( shortInteger );
+                        }
+                    break;
+                case ETestReadStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KRead)) == 0)
+                        {
+                        val = KMmsReadStatusRead;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelNotRead)) == 0)
+                        {
+                        val = KMmsReadStatusDeletedWithoutBeingRead;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetReadStatus( val );
+                    break;
+                case ETestResponseStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnspecified)) == 0)
+                        {
+                        val = KMmsErrorUnspecified;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMessageNotFound)) == 0)
+                        {
+                        val = KMmsErrorMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrNetworkProblem)) == 0)
+                        {
+                        val = KMmsErrorNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorNoContentAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrUnsupportedMessage)) == 0)
+                        {
+                        val = KMmsErrorUnsupportedMessage;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorTransientSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentAddressUnresolved)) == 0)
+                        {
+                        val = KMmsErrorPermanentSendingAddressUnresolved;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentContentNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentContentNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingLimitNotMet)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingLimitationsNotMet;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingRequestNotAccepted)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingRequestNotAccepted;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingForwardingDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingForwardingDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrReplyChargingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentReplyChargingNotSupported;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientPartialSuccess)) == 0)
+                        {
+                        val = KMmsErrorTransientPartialSuccess;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrAddressHidingNotSupported)) == 0)
+                        {
+                        val = KMmsErrorPermanentAddressHidingNotSupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteStatusL( order, val );
+                        }
+                    else
+                        {
+                         aMmsHeaders.SetResponseStatus( val );
+                        }
+                    break;
+                case ETestResponseText:
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMBoxDeleteConf )
+                        {
+                        aMmsHeaders.InsertDeleteResponseTextL( order, iValueBuffer );
+                        }
+                    else
+                        {
+                        aMmsHeaders.SetResponseTextL( iValueBuffer );
+                        }
+                    break;
+                case ETestRetrieveStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorReceiveTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrRetrieveContentUnsupported)) == 0)
+                        {
+                        val = KMmsErrorReceivePermanentContentUnsupported;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetResponseStatus( val );
+                    break;
+                case ETestRetrieveText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDeferred)) == 0)
+                        {
+                        val = KMmsMessageStatusDeferred;
+                        }
+                    else if ((iValueBuffer.CompareF(KExpired)) == 0)
+                        {
+                        val = KMmsMessageStatusExpired;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsMessageStatusRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KRejected)) == 0)
+                        {
+                        val = KMmsMessageStatusRejected;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnrecognized)) == 0)
+                        {
+                        val = KMmsMessageStatusUnrecognized;
+                        }
+                    else if ((iValueBuffer.CompareF(KIndeterminate)) == 0)
+                        {
+                        val = KMmsMessageStatusIndeterminate;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsMessageStatusForwarded;
+                        }
+                    else if ((iValueBuffer.CompareF(KUnreachable)) == 0)
+                        {
+                        val = KMmsMessageStatusUnreachable;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetStatus( val );
+                    break;
+                case ETestMessageType:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KSendReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KSendConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMSendConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifInd)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotificationInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KNotifResp)) == 0)
+                        {
+                        val = KMmsMessageTypeMNotifyRespInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMRetrieveConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KAckInd)) == 0)
+                        {
+                        val = KMmsMessageTypeAcknowledgeInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KDelInd)) == 0)
+                        {
+                        val = KMmsMessageTypeDeliveryInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadReqInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadRecInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KReadOrigInd)) == 0)
+                        {
+                        val = KMmsMessageTypeReadOrigInd;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardRec)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwardConf)) == 0)
+                        {
+                        val = KMmsMessageTypeForwardConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxStoreConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxStoreConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxViewConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMboxViewConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxUploadConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxUploadConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KMBoxDescr)) == 0)
+                        {
+                        val = KMmsMessageTypeMBoxDescr;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteReq)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KDeleteConf)) == 0)
+                        {
+                        val = KMmsMessageTypeDeleteConf;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelReq)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelReq;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelResp)) == 0)
+                        {
+                        val = KMmsMessageTypeCancelConf;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetMessageType( val );
+                    break;
+                case ETestAttribute:
+                    val = 0;
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    if ((iByteBuffer->Des().CompareF(KTestBcc)) == 0)
+                        {
+                        val = KMmsAssignedBcc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestCc)) == 0)
+                        {
+                        val = KMmsAssignedCc;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContent)) == 0)
+                        {
+                        val = KMmsAssignedContent;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestContentType)) == 0)
+                        {
+                        val = KMmsAssignedContentType;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDate)) == 0)
+                        {
+                        val = KMmsAssignedDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryReport)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryReport;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestDeliveryTime)) == 0)
+                        {
+                        val = KMmsAssignedDeliveryTime;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestExpiry)) == 0)
+                        {
+                        val = KMmsAssignedExpiry;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestFrom)) == 0)
+                        {
+                        val = KMmsAssignedFrom;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageClass)) == 0)
+                        {
+                        val = KMmsAssignedMessageClass;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageId)) == 0)
+                        {
+                        val = KMmsAssignedMessageId;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestMessageSize)) == 0)
+                        {
+                        val = KMmsAssignedMessageSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPriority)) == 0)
+                        {
+                        val = KMmsAssignedPriority;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReadReply)) == 0)
+                        {
+                        val = KMmsAssignedReadReply;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestSubject)) == 0)
+                        {
+                        val = KMmsAssignedSubject;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestTo)) == 0)
+                        {
+                        val = KMmsAssignedTo;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharging)) == 0)
+                        {
+                        val = KMmsAssignedReplyCharging;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargID)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingID;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyCharg)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingDeadline;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestReplyChargSize)) == 0)
+                        {
+                        val = KMmsAssignedReplyChargingSize;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentBy)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentBy;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestPreviouslySentDate)) == 0)
+                        {
+                        val = KMmsAssignedPreviouslySentDate;
+                        }
+                    else if ((iByteBuffer->Des().CompareF(KTestAdditionalHeaders)) == 0)
+                        {
+                        val = KMmsAssignedAdditionalHeaders;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().AttributeArray().InsertInOrder(val);
+                    break;
+                case ETestDistributionIndicator:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDistributionIndicator( val );
+                    break;
+                case ETestLimit:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if( error == KErrNone )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsLimit(val);
+                        }
+                    break;
+                case ETestMessageQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaNumber(val);
+                        }
+                    break;
+                case ETestSizeQuota:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxQuotaSize(val);
+                        }
+                    break;
+                case ETestMessageTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalNumber(val);
+                        }
+                    break;
+                case ETestSizeTotal:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMMBoxTotalSize(val);
+                        }
+                    break;
+                case ETestMessageCount:
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(KMaxTUint32);
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if ( val > allLimit )
+                        {
+                        val = KMaxTUint32; // this is too hard to type, more than 999999 means "all"
+                        }
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsMessageCount(val);
+                        }
+                    break;
+                case ETestAddKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsAddToken, iValueBuffer);
+                    break;
+                case ETestRemoveKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsRemoveToken, iValueBuffer);
+                    break;
+                case ETestFilterKeyword:
+                    aMmsHeaders.MMBoxMessageHeadersL().AppendKeywordItemL(KMmsFilterToken, iValueBuffer);
+                    break;
+                case ETestMMState:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KDraft)) == 0)
+                        {
+                        val = KMmsDraft;
+                        }
+                    else if ((iValueBuffer.CompareF(KSent)) == 0)
+                        {
+                        val = KMmsSent;
+                        }
+                    else if ((iValueBuffer.CompareF(KNew)) == 0)
+                        {
+                        val = KMmsNew;
+                        }
+                    else if ((iValueBuffer.CompareF(KRetrieved)) == 0)
+                        {
+                        val = KMmsRetrieved;
+                        }
+                    else if ((iValueBuffer.CompareF(KForwarded)) == 0)
+                        {
+                        val = KMmsForwarded;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    if ( aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewReq ||
+                        aMmsHeaders.MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().MMStateArray().InsertInOrder( val );
+                        }
+                    else
+                        {
+                        aMmsHeaders.MMBoxMessageHeadersL().SetMMState( val );
+                        }
+                    break;
+                case ETestQuota:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsQuotas( val );
+                    break;
+                case ETestStart:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    if (error == KErrNone)
+                        {
+                        aMmsHeaders.MMBoxViewHeadersL().SetMmsStart(val);
+                        }
+                    break;
+                case ETestStore:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStore( val );
+                    break;
+                case ETestStored:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStored( val );
+                    break;
+                case ETestStoreStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KOk)) == 0)
+                        {
+                        val = KMmsStatusOk;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransient)) == 0)
+                        {
+                        val = KMmsErrorTransientFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrTransientNetworkproblem)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusTransientNetworkProblem;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanent)) == 0)
+                        {
+                        val = KMmsErrorPermanentFailure;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentServiceDenied)) == 0)
+                        {
+                        val = KMmsErrorPermanentServiceDenied;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentMessageFormatCorrupt)) == 0)
+                        {
+                        val = KMmsErrorPermanentMessageFormatCorrupt;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrPermanentNotFound)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMessageNotFound;
+                        }
+                    else if ((iValueBuffer.CompareF(KErrMMBoxFull)) == 0)
+                        {
+                        val = KMmsErrorStoreStatusPermanentMmboxFull;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatus( val );
+                    break;
+                case ETestStoreStatusText:
+                    aMmsHeaders.MMBoxMessageHeadersL().SetMmsStoreStatusTextL( iValueBuffer );
+                    break;
+                case ETestTotals:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.MMBoxViewHeadersL().SetMmsTotals( val );
+                    break;
+
+                case ETestDeleteInfoIndex:
+                    lex.Assign(iValueBuffer);
+                    error = lex.Val(val,radix,limit);
+                    order = val;
+                    break;
+
+                case ETestApplicId:
+                    aMmsHeaders.SetApplicIdL( iValueBuffer );
+                    break;
+                case ETestReplyApplicId:
+                    aMmsHeaders.SetReplyApplicIdL( iValueBuffer );
+                    break;
+                case ETestApplicInfo:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetAuxApplicInfoL( iByteBuffer->Des() );
+                    break;
+                case ETestContentClass:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KText)) == 0)
+                        {
+                        val = KMmsContentClassText;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageBasic)) == 0)
+                        {
+                        val = KMmsContentClassImageBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KImageRich)) == 0)
+                        {
+                        val = KMmsContentClassImageRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoBasic)) == 0)
+                        {
+                        val = KMmsContentClassVideoBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KVideoRich)) == 0)
+                        {
+                        val = KMmsContentClassVideoRich;
+                        }
+                    else if ((iValueBuffer.CompareF(KMegaPixel)) == 0)
+                        {
+                        val = KMmsContentClassMegaPixel;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentBasic)) == 0)
+                        {
+                        val = KMmsContentClassContentBasic;
+                        }
+                    else if ((iValueBuffer.CompareF(KContentRich)) == 0)
+                        {
+                        val = KMmsContentClassContentRich;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetContentClass( val );
+                    break;
+                case ETestDrmContent:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetDrmContent( val );
+                    break;
+                case ETestAdaptationAllowed:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KYes)) == 0)
+                        {
+                        val = KMmsYes;
+                        }
+                    else if ((iValueBuffer.CompareF(KNo)) == 0)
+                        {
+                        val = KMmsNo;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetAdaptationAllowed( val );
+                    break;
+                case ETestRecommendedRetrievalMode:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KManual)) == 0)
+                        {
+                        val = KMmsRecommendedRetrievalModeManual;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetRecommendedRetrievalMode( val );
+                    break;
+                case ETestRecRetrievalModeText:
+                    aMmsHeaders.SetRecommendedRetrievalModeTextL( iValueBuffer );
+                    break;
+                case ETestReplaceId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestStatusText:
+                    aMmsHeaders.SetResponseTextL( iValueBuffer );
+                    break;
+                case ETestCancelId:
+                    iByteBuffer->Des().Copy( iValueBuffer );
+                    aMmsHeaders.SetReplaceCancelIdL( iByteBuffer->Des() );
+                    break;
+                case ETestCancelStatus:
+                    val = 0;
+                    if ((iValueBuffer.CompareF(KCancelSuccessful)) == 0)
+                        {
+                        val = KMmsCancelRequestSuccessfullyReceived;
+                        }
+                    else if ((iValueBuffer.CompareF(KCancelCorrupted)) == 0)
+                        {
+                        val = KMmsCancelRequestCorrupted;
+                        }
+                    else
+                        {
+                        val = KMmsTestIllegalValue;
+                        }
+                    aMmsHeaders.SetCancelStatus( val );
+                    break;
+                default:
+                    break;
+                }
+            }
+            else
+            {
+            switch(readStatus)
+                {
+                case ETestAlias:
+                    iAliasArray->AppendL( iValueBuffer );
+                    iAliasCount++;
+				    break;
+
+                default:
+                    break;
+                }
+
+            }
+        }
+    return(-1);
+}
+
+// ---------------------------------------------------------
+// CMmsReadFile()::ReadRowL
+// ---------------------------------------------------------
+//
+TTestReadStatus CMmsReadFile::ReadRowL()
+    {
+
+        TBuf8<DefaultBufLen> RowBuffer;
+        TBuf8<32> KeyBuffer;
+
+        // READ ONE ROW AND DROP CR+LF FROM THE END OF LINE
+        TChar delim( 10 );
+        iReader->ReadL( RowBuffer, delim);
+        TInt length = RowBuffer.Length();
+        if ( RowBuffer.Length() < 2 )
+            {
+            return ETestEof;
+            }
+        RowBuffer.Delete(length - 2,2);
+
+        // DROP POSSIBLE COMMENT OUT
+        TInt pos = RowBuffer.Locate( ';' );
+		if ( pos >= 0 ) RowBuffer.Delete( pos, length-pos-2 );
+
+        if ( RowBuffer.Length() == 0 )
+            {
+            // the line contained only comment
+            return ETestUnknown;
+            }
+
+        // First split the row (:)
+        pos = RowBuffer.Locate( ':' );
+        if (pos > 0)
+        {
+            TPtrC8 p = RowBuffer.Mid( pos+1 );
+            length = p.Length();
+            iValueBuffer.Zero();
+            for (TInt i=0; i < length; ++i)
+                {
+                iValueBuffer.Append(p[i]);
+                }
+            iValueBuffer.Trim();
+            TPtrC8 pp = RowBuffer.Left(pos);
+            KeyBuffer.CopyUC(pp);
+            KeyBuffer.Trim();
+        }
+        // TRY TO FIND CORRECT TAG
+        if ((KeyBuffer.CompareF(KTestNewMessage)) == 0) return(ETestNewMessage);
+        if ((KeyBuffer.CompareF(KTestMessageType)) == 0) return ETestMessageType;
+        if ((KeyBuffer.CompareF(KTestDate)) == 0) return ETestDate;
+        if ((KeyBuffer.CompareF(KTestFrom)) == 0) return ETestFrom;
+        if ((KeyBuffer.CompareF(KTestTo)) == 0) return ETestTo;
+        if ((KeyBuffer.CompareF(KTestCc)) == 0) return ETestCc;
+        if ((KeyBuffer.CompareF(KTestBcc)) == 0) return ETestBcc;
+        if ((KeyBuffer.CompareF(KTestSubject)) == 0) return ETestSubject;
+        if ((KeyBuffer.CompareF(KTestExpiryRel)) == 0) return ETestExpiryRel;
+        if ((KeyBuffer.CompareF(KTestExpiryAbs)) == 0) return ETestExpiryAbs;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeRel)) == 0) return ETestDeliveryTimeRel;
+        if ((KeyBuffer.CompareF(KTestDeliveryTimeAbs)) == 0) return ETestDeliveryTimeAbs;
+        if ((KeyBuffer.CompareF(KTestPriority)) == 0) return ETestPriority;
+        if ((KeyBuffer.CompareF(KTestSenderVisibility)) == 0) return ETestSenderVisibility;
+        if ((KeyBuffer.CompareF(KTestDeliveryReport)) == 0) return ETestDeliveryReport;
+        if ((KeyBuffer.CompareF(KTestReadReply)) == 0) return ETestReadReply;
+        if ((KeyBuffer.CompareF(KTestNewAttachment)) == 0) return ETestNewAttachment;
+        if ((KeyBuffer.CompareF(KTestAttachmentName)) == 0) return ETestAttaRecommendedName;
+        if ((KeyBuffer.CompareF(KTestAttachmentContLoc)) == 0) return ETestAttachmentContLoc;
+        if ((KeyBuffer.CompareF(KTestAttachmentType)) == 0) return ETestAttachmentType;
+        if ((KeyBuffer.CompareF(KTestAttachmentCharset)) == 0) return ETestAttachmentCharset;
+        if ((KeyBuffer.CompareF(KTestAttachmentCid)) == 0) return ETestAttachmentCid;
+        if ((KeyBuffer.CompareF(KTestAttachmentRoot)) == 0) return ETestAttachmentRoot;
+        if ((KeyBuffer.CompareF(KTestEndOfFile)) == 0) return ETestEof;
+        if ((KeyBuffer.CompareF(KTestMessageClass)) == 0) return ETestMessageClass;
+        if ((KeyBuffer.CompareF(KTestDelivRepSendAllow)) == 0) return ETestDelivReportSendAllow;
+        if ((KeyBuffer.CompareF(KTestAlias)) == 0 ) return ETestAlias;
+        if ((KeyBuffer.CompareF(KTestFromAlias)) == 0 ) return ETestFromAlias;
+        if ((KeyBuffer.CompareF(KTestToAlias)) == 0 ) return ETestToAlias;
+        if ((KeyBuffer.CompareF(KTestCcAlias)) == 0 ) return ETestCcAlias;
+        if ((KeyBuffer.CompareF(KTestBccAlias)) == 0 ) return ETestBccAlias;
+        if ((KeyBuffer.CompareF(KTestReplyCharging)) == 0 ) return ETestReplyCharging;
+        if ((KeyBuffer.CompareF(KTestReplyChargAbs)) == 0 ) return ETestReplyChargAbs;
+        if ((KeyBuffer.CompareF(KTestReplyChargRel)) == 0 ) return ETestReplyChargRel;
+        if ((KeyBuffer.CompareF(KTestReplyChargSize)) == 0 ) return ETestReplyChargSize;
+        if ((KeyBuffer.CompareF(KTestReplyChargID)) == 0 ) return ETestReplyChargID;
+        if ((KeyBuffer.CompareF(KTestTID)) == 0 ) return ETestTID;
+        if ((KeyBuffer.CompareF(KTestContentLocation)) == 0 ) return ETestContentLocation;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentIndex)) == 0 ) return ETestPreviouslySentIndex;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentBy)) == 0 ) return ETestPreviouslySentBy;
+        if ((KeyBuffer.CompareF(KTestPreviouslySentDate)) == 0 ) return ETestPreviouslySentDate;
+        if ((KeyBuffer.CompareF(KTestMessageId)) == 0 ) return ETestMessageId;
+        if ((KeyBuffer.CompareF(KTestMessageSize)) == 0 ) return ETestMessageSize;
+        if ((KeyBuffer.CompareF(KTestVersion)) == 0 ) return ETestVersion;
+        if ((KeyBuffer.CompareF(KTestReadStatus)) == 0 ) return ETestReadStatus;
+        if ((KeyBuffer.CompareF(KTestResponseStatus)) == 0 ) return ETestResponseStatus;
+        if ((KeyBuffer.CompareF(KTestResponseText)) == 0 ) return ETestResponseText;
+        if ((KeyBuffer.CompareF(KTestRetrieveStatus)) == 0 ) return ETestRetrieveStatus;
+        if ((KeyBuffer.CompareF(KTestRetrieveText)) == 0 ) return ETestRetrieveText;
+        if ((KeyBuffer.CompareF(KTestStatus)) == 0 ) return ETestStatus;
+        if ((KeyBuffer.CompareF(KTestAttribute)) == 0 ) return ETestAttribute;
+        if ((KeyBuffer.CompareF(KTestDistributionIndicator)) == 0 ) return ETestDistributionIndicator;
+        if ((KeyBuffer.CompareF(KTestLimit)) == 0 ) return ETestLimit;
+        if ((KeyBuffer.CompareF(KTestMessageQuota)) == 0 ) return ETestMessageQuota;
+        if ((KeyBuffer.CompareF(KTestSizeQuota)) == 0 ) return ETestSizeQuota;
+        if ((KeyBuffer.CompareF(KTestMessageTotal)) == 0 ) return ETestMessageTotal;
+        if ((KeyBuffer.CompareF(KTestSizeTotal)) == 0 ) return ETestSizeTotal;
+        if ((KeyBuffer.CompareF(KTestMessageCount)) == 0 ) return ETestMessageCount;
+        if ((KeyBuffer.CompareF(KTestAddKeyword)) == 0 ) return ETestAddKeyword;
+        if ((KeyBuffer.CompareF(KTestRemoveKeyword)) == 0 ) return ETestRemoveKeyword;
+        if ((KeyBuffer.CompareF(KTestFilterKeyword)) == 0 ) return ETestFilterKeyword;
+        if ((KeyBuffer.CompareF(KTestMMState)) == 0 ) return ETestMMState;
+        if ((KeyBuffer.CompareF(KTestQuota)) == 0 ) return ETestQuota;
+        if ((KeyBuffer.CompareF(KTestStart)) == 0 ) return ETestStart;
+        if ((KeyBuffer.CompareF(KTestStore)) == 0 ) return ETestStore;
+        if ((KeyBuffer.CompareF(KTestStored)) == 0 ) return ETestStored;
+        if ((KeyBuffer.CompareF(KTestStoreStatus)) == 0 ) return ETestStoreStatus;
+        if ((KeyBuffer.CompareF(KTestStoreStatusText)) == 0 ) return ETestStoreStatusText;
+        if ((KeyBuffer.CompareF(KTestTotals)) == 0 ) return ETestTotals;
+        if ((KeyBuffer.CompareF(KTestDeleteInfoIndex)) == 0 ) return ETestDeleteInfoIndex;
+        if ((KeyBuffer.CompareF(KTestApplicId)) == 0 ) return ETestApplicId;
+        if ((KeyBuffer.CompareF(KTestReplyApplicId)) == 0 ) return ETestReplyApplicId;
+        if ((KeyBuffer.CompareF(KTestApplicInfo)) == 0 ) return ETestApplicInfo;
+        if ((KeyBuffer.CompareF(KTestContentClass)) == 0 ) return ETestContentClass;
+        if ((KeyBuffer.CompareF(KTestDrmContent)) == 0 ) return ETestDrmContent;
+        if ((KeyBuffer.CompareF(KTestAdaptationAllowed)) == 0 ) return ETestAdaptationAllowed;
+        if ((KeyBuffer.CompareF(KTestRecommendedRetrievalMode)) == 0 ) return ETestRecommendedRetrievalMode;
+        if ((KeyBuffer.CompareF(KTestRecRetrievalModeText)) == 0 ) return ETestRecRetrievalModeText;
+        if ((KeyBuffer.CompareF(KTestReplaceId)) == 0 ) return ETestReplaceId;
+        if ((KeyBuffer.CompareF(KTestStatusText)) == 0 ) return ETestStatusText;
+        if ((KeyBuffer.CompareF(KTestCancelId)) == 0 ) return ETestCancelId;
+        if ((KeyBuffer.CompareF(KTestCancelStatus)) == 0 ) return ETestCancelStatus;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamName)) == 0 ) return ETestAttContTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttContTypeParamValue)) == 0 ) return ETestAttContTypeParamValue;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamName)) == 0 ) return ETestAttXTypeParamName;
+        if ((KeyBuffer.CompareF(KTestAttXTypeParamValue)) == 0 ) return ETestAttXTypeParamValue;
+        return ETestUnknown;
+    }
+
+// ---------------------------------------------------------
+// CMmsReadFile()::CreateMessageL
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+void CMmsReadFile::CreateMessageL( CMmsClientMtm* aMmsClient, CMmsHeaders* aMmsHeaders )
+    {
+
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+
+    TInt      i;
+    TInt error = KErrNone;
+    RFile attaFile;
+    _LIT8(KLeftAngle, "<");
+    _LIT8(KRightAngle, ">");
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+
+    CMsvStore* store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    aMmsHeaders->StoreL(*store);
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    aMmsClient->LoadMessageL(); // read store is needed to do this
+
+    store = aMmsClient->Entry().EditStoreL();
+    CleanupStack::PushL(store);
+    CMsvAttachment* attaInfo = NULL;
+    TMsvAttachmentId attaId = 0;
+
+    for ( i=0; i < iAttaStructures->Count(); ++i)
+        {
+        attaId = KMsvNullIndexEntryId;
+        iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+
+        error = attaFile.Open( iFs, iFilename, EFileShareReadersOnly | EFileRead );
+        User::LeaveIfError( error );
+
+		CleanupClosePushL(attaFile);
+
+		CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+		CleanupStack::PushL( mimeHeaders );
+		TPtrC8 contentType = iAttaStructures->At(i)->iAttaType->Des();
+
+        TDataRecognitionResult result;
+        result.Reset(); // make sure that it is cleared
+
+        if(iAttaStructures->At(i)->iAttaCid->Length())
+            {
+            TPtr8 attaCID = iAttaStructures->At(i)->iAttaCid->Des();
+            if (attaCID.Find(KLeftAngle) == 0 &&
+                attaCID.Find(KRightAngle) == attaCID.Length()-1 )
+                {
+                // remove angle brackets from cid
+                attaCID = attaCID.Mid(1,attaCID.Length()-2);
+                }
+            mimeHeaders->SetContentIdL(attaCID);
+            }
+
+        if (iAttaStructures->At(i)->iAttaCharset)
+            {
+            mimeHeaders->SetMimeCharset(iAttaStructures->At(i)->iAttaCharset);
+            }
+
+        if (iAttaStructures->At(i)->iAttaName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaName->Des());
+            }
+        iParse.Set( iFilename, NULL, NULL );
+        iFilename.Copy( iParse.NameAndExt() );
+
+        mimeHeaders->SetContentLocationL( iFilename );
+
+		// if Mime type has not been set, use RapaRecognizer
+		if ( iAttaStructures->At(i)->iAttaType->Length() == 0 && iFilename.Length() > 0)
+		    {
+		    // TO BE IMPLEMENTED
+
+            RApaLsSession lsSession;
+
+            if ( lsSession.Connect() == KErrNone )
+                {
+                CleanupClosePushL( lsSession );
+
+                iFilename.Copy(iAttaStructures->At(i)->iAtta->Des());
+                if ( lsSession.RecognizeData( iFilename, TPtrC8(), result ) == KErrNone )
+                    {
+                    // Check confidence level. Recognization must be at least
+                    // "EProbable". We don't accept the result if it is "EPossible"
+                    // or "EUnlikely" or "ENotRecognized"!
+
+                    if ( result.iConfidence < CApaDataRecognizerType::EProbable )
+                        {
+                        result.Reset(); // clear buffer and try again with longer buffer
+                        }
+
+                    TPtrC8 mimeBuf8 = result.iDataType.Des8();
+
+                    if ( mimeBuf8.Length() == 0 )
+                        {
+                        // Open file buffer and try again..
+
+                        TInt bufSize = 0;
+                        (void)lsSession.GetMaxDataBufSize( bufSize ); // ignore errors
+                        if ( bufSize <= 0 )
+                            {
+                            bufSize = 30;
+                            }
+                        HBufC8* buf = HBufC8::NewLC( bufSize );
+                        TPtr8 des = buf->Des();
+
+                        RFile file;
+                        TInt err=file.Open( iFs, iFilename, EFileShareReadersOnly );
+                        if ( err == KErrNone )
+                            {
+                            err = file.Read( des );
+                            file.Close();
+                            if ( err == KErrNone )
+                                {
+                                if ( ( lsSession.RecognizeData( iFilename, des, result ) ) == KErrNone )
+                                    {
+                                    mimeBuf8.Set( result.iDataType.Des8() );
+                                    }
+                                }
+
+                            }
+                        CleanupStack::PopAndDestroy(); // buf
+                        }
+                    if ( mimeBuf8.Length() > 0 &&
+                        result.iConfidence >= CApaDataRecognizerType::EProbable )
+                        {
+                        contentType.Set( result.iDataType.Des8() );
+                        }
+                    }
+                CleanupStack::PopAndDestroy(1); // lssession
+                }
+		    }
+
+        if ( contentType.Length() > 0 )
+            {
+            TInt position = contentType.Find( KMmsSlash8 );
+            if ( position >= 0 )
+                {
+                mimeHeaders->SetContentTypeL( contentType.Left( position ) );
+                }
+            if ( position < contentType.Length() - 1 )
+                {
+                mimeHeaders->SetContentSubTypeL( contentType.Mid( position + 1 ) );
+                }
+//          CreateAttachment2L sets the content type to attaInfo
+//            attaInfo->SetMimeTypeL( contentType );
+            }
+
+        if (iAttaStructures->At(i)->iAttaRecommendedName->Length())
+            {
+            iFilename.Copy(iAttaStructures->At(i)->iAttaRecommendedName->Des());
+            iParse.Set( iFilename, NULL, NULL );
+            iFilename.Copy( iParse.NameAndExt() );
+            mimeHeaders->SetSuggestedFilenameL( iFilename );
+            }
+
+        TInt j = 0;
+        for ( j = 0; j < iAttaStructures->At(i)->iContentTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->ContentTypeParams().AppendL( iAttaStructures->At(i)->iContentTypeParams->MdcaPoint( j ) );
+            }
+        for ( j = 0; j < iAttaStructures->At(i)->iXTypeParams->MdcaCount(); ++j )
+            {
+            mimeHeaders->XTypeParams().AppendL( iAttaStructures->At(i)->iXTypeParams->MdcaPoint( j ) );
+            }
+
+        attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
+        // attaInfo does not go onto cleaunpstack because ownership will
+        // be transferred to attachment manager.
+
+        aMmsClient->CreateAttachment2L(
+            *store,
+            attaFile,
+            contentType,
+            *mimeHeaders,
+            attaInfo,
+            attaId);
+        attaInfo = NULL; // ownership transferred
+
+        CleanupStack::PopAndDestroy(); // mimeHeaders
+        CleanupStack::PopAndDestroy(); // attaFile.Close()
+
+        if ( iAttaRoot > 0 && iAttaRoot == ( i + 1 ) )
+            {
+            aMmsClient->SetMessageRootL( attaId );
+            }
+        }
+
+    store->CommitL();
+    CleanupStack::PopAndDestroy(); // store
+
+    // This frees all memory and resets all values
+    Reset();
+    // Reset inactivity timer to keem viewServer from crashing
+    User::ResetInactivityTime();
+    }
+
+
+// ---------------------------------------------------------
+// CMmsReadFile()::FindAlias
+// program build a message from given parts
+// ---------------------------------------------------------
+//
+TInt CMmsReadFile::FindAlias( TPtrC aAlias )
+    {
+	TBuf<DefaultBufLen> abuf;
+	for( TInt i=0; i < iAliasCount; ++i )
+	    {
+		abuf.Copy( iAliasArray->MdcaPoint(i) );
+		abuf.SetLength( abuf.Locate('=') );
+		if( ( abuf.CompareF( aAlias ) ) == 0 ) return( i );
+	    }
+	return( -1 );
+    }
+
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CMmsAttaStructure::CMmsAttaStructure()
+    {
+    iAtta = NULL;
+    iAttaType = NULL;
+    iAttaName = NULL;
+    iAttaCid = NULL;
+    iAttaRecommendedName = NULL;
+    }
+
+
+//
+void CMmsAttaStructure::ConstructL()
+    {
+    iAtta = HBufC8::NewL(DefaultBufLen);
+    iAttaType = HBufC8::NewL(DefaultBufLen);
+    iAttaName = HBufC8::NewL(DefaultBufLen);
+    iAttaCid = HBufC8::NewL(DefaultBufLen);
+    iAttaRecommendedName = HBufC::NewL(DefaultBufLen);
+    iAttaCharset = 0;
+   	iXTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+   	iContentTypeParams  = new(ELeave) CDesC8ArrayFlat(4);
+
+    }
+
+// Two-phased constructor.
+CMmsAttaStructure* CMmsAttaStructure::NewL()
+    {
+    CMmsAttaStructure* self = new ( ELeave ) CMmsAttaStructure;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// Destructor
+CMmsAttaStructure::~CMmsAttaStructure()
+    {
+    delete iAtta;
+    delete iAttaName;
+    delete iAttaType;
+    delete iAttaCid;
+    delete iAttaRecommendedName;
+    if ( iContentTypeParams )
+        {
+    	iContentTypeParams->Reset();
+        }
+  	delete iContentTypeParams;
+    if ( iXTypeParams )
+        {
+      	iXTypeParams->Reset();
+        }
+	delete iXTypeParams;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmstestbed.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,2357 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <mtmdef.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <mmsheaders.h>
+#include <mmscmds.h>
+#include <mmsencode.h>
+#include <mmscliententry.h>
+#include <logwrap.h>
+#include <logcli.h>
+#include <logview.h>
+#include "mmssettings.h"  //use mmssettings.h instead of cmmssettings.h
+#include "mmstestbed.h"
+#include "mmsreadfile.h"
+#include "mmstestuitimer.h"
+#include "mmsteststaticutils.h"
+#include "mmstestbed.hrh"
+
+//constants
+_LIT( KMmsSender, "0601234567" );
+
+MmsTestBed::MmsTestBed()
+    {
+    //start the timer
+    iTimer = CTestUiTimer::NewL();
+    iTimer->Cancel();
+
+    iWait = CMsvOperationActiveSchedulerWait::NewLC();
+    // don't leave iWait on cleanup stack
+    CleanupStack::Pop();
+
+    //open msvsession
+    iSession = CMsvSession::OpenSyncL(*this);
+    //create client registry
+    iClientMtmRegistry = CClientMtmRegistry::NewL(*iSession);
+    //create client mtm
+    iMmsClient = (CMmsClientMtm *) iClientMtmRegistry->NewMtmL(
+            KUidMsgTypeMultimedia);
+
+    User::LeaveIfError( iFs.Connect() );
+    iFs.SetSessionPath( KRootPath );
+    iSettings = CMmsSettings::NewL();
+    iMmsHeaders = CMmsHeaders::NewL(iSettings->MmsVersion());
+    findDefaultL();
+    iServiceId = iDefaultServiceId;
+
+    //validate the settings
+    iSettings->ValidateSettings();
+
+    iLogEvent = CLogEvent::NewL();
+    iLogEvent->SetEventType(KLogMmsEventTypeUid);
+    iLogClient = NULL; // we test soon if this is available
+    iLogView = NULL; // needs log client
+    if ( checkLogClient() )
+        {
+        // first we generate a general view of all events
+        // we'll set the filter when we update the view
+        iLogView = CLogViewEvent::NewL( *iLogClient );
+        }
+    iLogFilter = CLogFilter::NewL();
+    // we try to filter MMS events
+    iLogFilter->SetEventType(KLogMmsEventTypeUid);
+    }
+
+MmsTestBed::~MmsTestBed()
+    {
+    delete iLogView;
+    delete iLogFilter;
+    delete iLogClient;
+    delete iLogEvent;
+    delete iSettings;
+    delete iMmsHeaders;
+    if(iTimer)
+    {
+        iTimer->Cancel();
+        delete iTimer;
+    }
+    //delete iMsvEntrySelection;
+    delete iMmsClient;
+    delete iClientMtmRegistry;
+    //delete iClientMtmRegistry;
+    delete iSession;
+    delete iWait;
+    }
+
+void MmsTestBed::setConnectionLocal(bool value)
+    {
+    //value = true for global off, local on
+    //value = false for global on, local off
+    iSettings->LoadSettingsL();
+    iSettings->SetLocalMode( value );
+    iSettings->SaveSettingsL();
+    }
+
+void MmsTestBed::fromOutboxToMmsc()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    // Get List of services
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL(
+            KUidMsgTypeMultimedia);
+    CleanupStack::PushL(selection);
+
+    // Change state to "KMsvSendStateUnknown" in case the entry has been suspended earlier
+    for (TInt i = 0; i < selection->Count(); ++i)
+        {
+        cEntry->SetEntryL(selection->At(i));
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly(EFalse);
+        entry.SetSendingState(KMsvSendStateUnknown);
+        cEntry->ChangeL(entry);
+        }
+
+    selection->InsertL(0, iServiceId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iSession->TransferCommandL(*selection, EMmsSend, paramPack,
+            iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    CleanupStack::PopAndDestroy(); //cEntry
+    }
+
+void MmsTestBed::fromMmscToInbox()
+    {
+    CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+    CleanupStack::PushL(msvEntrySelection);
+
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        msvEntrySelection->InsertL(0, iServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack(parameters);
+
+    op = iMmsClient->InvokeAsyncFunctionL(EMmsReceive, *msvEntrySelection,
+            paramPack, iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending)
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if (iWait->iStatus.Int() != KErrNone)
+        {
+        //DEBUG(_L("Testbed tried to receive, return status %d"),iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); //msvEntrySelection
+    }
+
+void MmsTestBed::findDefaultL()
+    {
+    iSettings->LoadSettingsL();
+    iDefaultServiceId = iSettings->Service();
+    }
+
+void MmsTestBed::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
+        TAny* aArg2, TAny* /*aArg3*/)
+    {
+    iEvent = aEvent;
+    if (aEvent == EMsvGeneralError)
+        {
+        return;
+        }
+    TMsvId parentId = KMsvNullIndexEntryId;
+    if (aArg2 != NULL)
+        {
+        parentId = *(TMsvId*) aArg2;
+        }
+
+    CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+    TMsvEntry tEntry;
+    TMsvId service;
+    TInt error = KErrNone;
+    error = iSession->GetEntry(selection->At(0), service, tEntry);
+
+    CMsvEntry* cEntry = NULL;
+    switch (aEvent)
+        {
+        case EMsvEntriesCreated:
+            {
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+                // emit signal for new entry into INBOX
+                emit entryCreatedInInbox(tEntry.Id());
+                }
+            else if (parentId == KMsvDraftEntryIdValue)
+                {
+                // emit signal for new entry into Draft
+                emit entryCreatedInDraft(tEntry.Id());
+                }
+            else if (parentId == iServiceId)
+                {
+                // emit signal for new Entry into SERVICE
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        case EMsvEntriesChanged:
+            {
+            TMsvId id;
+            CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1;
+            if (selection == NULL)
+                {
+                // no selection, cannot handle
+                return;
+                }
+            id = selection->At(0);
+            //DEBUG Entry changed"));
+            if (parentId == KMsvGlobalInBoxIndexEntryIdValue)
+                {
+/*
+                cEntry = iSession->GetEntryL( parentId );
+                CleanupStack::PushL( cEntry );
+                TRAPD (error, cEntry->SetEntryL( id ));
+                if ( error != KErrNone )
+                    {
+                    CleanupStack::PopAndDestroy(); // cEntry
+                    return;
+                    }
+                TMsvEntry tEntry = cEntry->Entry();
+                if ( tEntry.Visible() )
+                    {
+                    // generate fake delivery report
+                    CMsvStore* store = cEntry->ReadStoreL();
+                    CleanupStack::PushL( store );
+                    CMmsHeaders* mmsHeaders = CMmsHeaders::NewL( iSettings->MmsVersion() );
+                    CleanupStack::PushL( mmsHeaders );
+                    mmsHeaders->RestoreL( *store );
+                    iEncodeBuffer->ResizeL( 0 );
+                    generateDeliveryReport( mmsHeaders );
+                    CleanupStack::PopAndDestroy( 2 ); // mmsHeaders, store
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+*/
+                }
+            }
+            break;
+        case EMsvEntriesDeleted:
+            {
+            //emit signal for entry deleted
+            }
+            break;
+        case EMsvEntriesMoved:
+            {
+            if (parentId == KMsvGlobalOutBoxIndexEntryIdValue)
+                {
+                // entry moved to outbox
+                emit entryMovedToOutbox(tEntry.Id());
+                }
+            else if (parentId == KMsvSentEntryIdValue)
+                {
+                // entry moved to sent folder
+                emit entryMovedToSent(tEntry.Id());
+                }
+            else
+                {
+                // do nothing
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+void MmsTestBed::createMmsService()
+    {
+    CMmsSettings * settings = CMmsSettings::NewL();
+    CleanupStack::PushL( settings );
+    settings->CreateNewServiceL( *iSession );
+    CleanupStack::PopAndDestroy(); // settings
+    return;
+    }
+
+void MmsTestBed::cleanup()
+    {
+    TMsvId entryToBeKilled;
+    // Get access to root index
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    entryToBeKilled = iSettings->Service();
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    while (entryToBeKilled != KMsvNullIndexEntryId)
+        {
+        // delete child of root entry
+        deleteEntry(entryToBeKilled, *cEntry);
+        entryToBeKilled = iSettings->Service();
+        }
+
+    CleanupStack::PopAndDestroy(); // cEntry
+    // We deleted everything!
+    iDefaultServiceId = KMsvNullIndexEntryId;
+    iServiceId = KMsvNullIndexEntryId;
+    }
+
+void MmsTestBed::deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry)
+    {
+    aClientEntry.DeleteL(aEntryId);
+    }
+
+void MmsTestBed::cleanupAndCreateNewService()
+    {
+    cleanup();
+    // all old service entries have been destroyed, create a new one
+    createMmsService();
+    }
+
+void MmsTestBed::testFile(TFileName& aFilePath, TInt aCommand /* = 0 */, TMsvId aBox /* = KMsvGlobalOutBoxIndexEntryId */ )
+    {
+    // update settings in mmsclient
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    RFileReadStream readStream;
+    readStream.PushL();
+//    TMsvId id = KMsvNullIndexEntryId;
+    CBufFlat* encodeBuffer = NULL;
+    CMmsEncode* encoder = NULL;
+
+    // Open the file
+    TInt err = readStream.Open(iFs, aFilePath, EFileShareReadersOnly );
+    if (err != KErrNone) User::Leave( err );
+
+    TInt   retCode = 0;
+    CMmsReadFile* readFile = NULL;
+    readFile = CMmsReadFile::NewL( iFs, readStream );
+    CleanupStack::PushL( readFile );
+
+    TInt messageCounter = 0;
+    CMsvEntry* cEntry = NULL;
+
+    while(!retCode)
+        {
+        // READ MESSAGE TO BUFFERS
+        iMmsHeaders->Reset(iSettings);
+        // put in some message type just for fun (testing...)
+        iMmsHeaders->SetMessageType( KMmsMessageTypeForwardReq );
+        retCode = readFile->CompleteTestL( messageCounter++, *iMmsHeaders );
+        if(readFile->iMessageType == ETestNewMessage)
+            {
+            // CREATE MESSAGE ENTRY
+            switch ( aCommand )
+                {
+                case ECreateToInbox:
+                case ECreateNotification:
+                    cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+                    break;
+                case ECreateToSentItems:
+                    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+                    break;
+                case ECreateToDrafts:
+                    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                    break;
+                case ECreateHeadersFromFile:
+                    // here we just encode headers, no message entry
+                    // the entry is fake.
+                    break;
+                case ECreateMMBoxViewConf:
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // entry is not created for the description items
+                        // they become attachments
+                        cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+                        }
+                    break;
+                default:
+                    cEntry = iSession->GetEntryL(aBox);
+                    break;
+                }
+
+            // if we are just playing with headers we have no entry
+            if ( aCommand != ECreateHeadersFromFile && aCommand != ECreateMMBoxViewConf )
+                {
+                CleanupStack::PushL(cEntry);
+                iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                // CREATE MESSAGE
+                iMmsClient->CreateMessageL(iServiceId);
+                }
+            else if ( aCommand == ECreateMMBoxViewConf )
+                {
+                if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                    {
+                    CleanupStack::PushL(cEntry);
+                    iMmsClient->SwitchCurrentEntryL(cEntry->EntryId());
+
+                    // CREATE MESSAGE
+                    iMmsClient->CreateMessageL(iServiceId);
+                    }
+                else
+                    {
+                    encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                    CleanupStack::PushL( encodeBuffer );
+                    encoder = CMmsEncode::NewL( iFs );
+                    CleanupStack::PushL( encoder );
+
+                    // encode headers to a binary file
+                    encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                    iFilename = KMmsMMBoxDescriptionDirectory;
+                    TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                    CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                    encodeBuffer = NULL;
+                    encoder = NULL;
+                    }
+                }
+            else
+                {
+                encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty
+                CleanupStack::PushL( encodeBuffer );
+                encoder = CMmsEncode::NewL( iFs );
+                CleanupStack::PushL( encoder );
+
+                // encode headers to a binary file
+                encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer );
+
+                iFilename = KMmsDumpDirectory;
+                TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs );
+
+                CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder
+                encodeBuffer = NULL;
+                encoder = NULL;
+                }
+            }
+
+        if ( aCommand != ECreateHeadersFromFile &&
+            ( aCommand != ECreateMMBoxViewConf || iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) )
+            {
+            if(readFile->iMessageType == ETestSettings)
+                {
+                TMsvId ServiceId = iMmsClient->DefaultServiceL();
+                iMmsClient->RestoreSettingsL();
+                iSettings->CopyL( iMmsClient->MmsSettings() );
+                }
+
+            TMemoryInfoV1Buf memory;
+            UserHal::MemoryInfo( memory );
+            TInt available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory before CreateMessageL %d"), available );
+
+            TRAP (err, readFile->CreateMessageL(iMmsClient, iMmsHeaders));
+
+            available = memory().iFreeRamInBytes;
+//            TMmsLogger::Log(_L("Free memory after CreateMessageL %d"), available );
+
+            if(readFile->iMessageType == ETestNewMessage)
+                {
+                TMsvEntry tEntry = iMmsClient->Entry().Entry();
+                TMsvId id = tEntry.Id();
+                if ( err == KErrNone )
+                    {
+                    // SAVE MESSAGE
+                    iMmsClient->SaveMessageL();
+
+                    // If we are creating a MMBox View confirmation,
+                    // we add all binary files from KMmsMMBoxDirectory
+                    // as attachments.
+
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        addMMBoxDescriptions();
+                        }
+
+                    // reload the entry in case mms client put something into it
+                    // MESSAGE MUST BE SET VISIBLE
+                    tEntry = iMmsClient->Entry().Entry();
+                    if ( iMmsClient->MessageClass() == EMmsClassAdvertisement )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageAdvertisement;
+                        }
+                    else if ( iMmsClient->MessageClass() == EMmsClassInformational )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageInformational;
+                        }
+                    tEntry.iMtmData1 &= ~KMmsMessageMobileTerminated;
+
+                    // Test: Set all as editor oriented - except notifications!
+                    if ( aCommand == ECreateNotification )
+                        {
+                        tEntry.iMtm = KUidMsgMMSNotification;
+                        }
+                    else
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageEditorOriented;
+                        }
+                    if ( aCommand == ECreateToInbox )
+                        {
+                        tEntry.iMtmData1 |= KMmsMessageMobileTerminated;
+                        tEntry.SetReadOnly( ETrue );
+                        tEntry.SetNew( ETrue );
+                        tEntry.SetUnread( ETrue );
+                        }
+                    else if ( aCommand == ECreateToSentItems )
+                        {
+                        tEntry.SetReadOnly( ETrue );
+                        }
+                    tEntry.SetVisible( ETrue );
+                    tEntry.SetInPreparation( EFalse );
+                    TTime now;
+                    now.UniversalTime();
+                    tEntry.iDate = now;
+                    TMsvId entryId = tEntry.Id();
+                    iMmsClient->Entry().ChangeL( tEntry );
+                    if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf )
+                        {
+                        // Encode to the directory that is used to fetch MMBox view
+                        iFilename.Copy( KMmsMMBoxDirectory );
+                        encodeMessageFromDrafts();
+                        cEntry->SetEntryL( KMsvDraftEntryId );
+                        cEntry->DeleteL( entryId );
+                        }
+                    }
+                else
+                    {
+                    //TMmsLogger::Log(_L("CreateMessageL left with error %d"), err );
+                    iSession->RemoveEntry(id);
+                    err = KErrNone; // clear error
+                    }
+                CleanupStack::PopAndDestroy(); // cEntry
+                cEntry = NULL;
+                }
+            if(readFile->iMessageType == ETestSettings)
+                {
+                iMmsClient->SetSettingsL( *iSettings );
+                iMmsClient->StoreSettingsL();
+                }
+        }
+    }
+
+    CleanupStack::PopAndDestroy(); //readFile
+
+    readStream.Close();
+    readStream.Pop();
+
+    /*
+    iMmsClient->SwitchCurrentEntryL(id);
+    */
+    }
+
+void MmsTestBed::addMMBoxDescriptions()
+    {
+    // add the contents of KMmsMMBoxDescriptionDirectory as attachments
+    CDir* fileList = NULL;
+    TInt i = 0;  // general counter
+    TInt error = KErrNone;
+    iCurrentPath = KMmsMMBoxDescriptionDirectory;
+
+    iFs.SetSessionPath(iCurrentPath);
+
+    TFindFile finder( iFs );
+    error = finder.FindWildByPath( KWild, NULL, fileList );
+    CleanupStack::PushL( fileList );
+    TInt fileCounter = 0;
+
+    if ( error == KErrNone )
+        {
+        fileCounter = fileList->Count();
+        }
+
+    TEntry entry;
+
+    if ( error == KErrNone )
+        {
+        for ( i = 0; i < fileCounter; ++i )
+            {
+            // Reset inactivity timer to keep viewServer from crashing
+            User::ResetInactivityTime();
+            entry = (*fileList)[i]; // name is entry.iName
+            iFilename.Copy( iCurrentPath );
+            iFilename.Append( entry.iName );
+            TPtrC ptr;
+            ptr.Set( iFilename );
+            iWait->iStatus = KErrNone;
+            iMmsClient->AddAttachmentL( ptr, KMmsMimeType, 0, iWait->iStatus );
+
+            iWait->Start();
+            // The descriptions are cleared after being used
+            iFs.Delete( ptr);
+            }
+        }
+
+    iMmsClient->SaveMessageL(); // just in case somthing must be updated
+    CleanupStack::PopAndDestroy(); // fileList
+    fileList = NULL;
+    }
+
+void MmsTestBed::encodeMessageFromDrafts()
+    {
+    CMmsEncode* encoder = CMmsEncode::NewL( iFs );
+    CleanupStack::PushL( encoder );
+    // encode a message iMmsClientPoints to
+    iMmsClient->LoadMessageL();
+    CMsvStore* store = iMmsClient->Entry().ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy(); // store
+    store = NULL;
+    iWait->iStatus = KErrNone;
+
+// caller sets the directory
+//    iFilename = KMmsMessageDumpDirectory;
+
+    CMmsClientEntry* entryWrapper = CMmsClientEntry::NewL( iFs, iMmsClient->Entry(), iServiceId );
+    CleanupStack::PushL( entryWrapper );
+    iEncodeBuffer->ResizeL(0);
+    encoder->StartL( *entryWrapper, *iMmsHeaders, *iEncodeBuffer, iWait->iStatus );
+    iWait->Start();
+    if ( iWait->iStatus == KErrNone )
+        {
+        TMmsTestUtils::Dump( *iEncodeBuffer, iFilename, iParse, iFs );
+        }
+    iEncodeBuffer->ResizeL(0);
+    CleanupStack::PopAndDestroy(); // entryWrapper
+    CleanupStack::PopAndDestroy(); // encoder
+    }
+
+void MmsTestBed::deleteNotifications()
+    {
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+
+    if ( mmsFolderId != KMsvNullIndexEntryId )
+        {
+        cEntry->SetEntryL(mmsFolderId);
+
+        // show invisible entries
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+        CleanupStack::PushL(msvEntrySelection);
+
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        // These cannot be deleted unless we have the a server mtm
+        // corresponding to this mtm type.
+        cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgMMSNotification );
+        CleanupStack::PushL(msvEntrySelection);
+
+        if (msvEntrySelection->Count() > 0)
+            {
+            CMsvOperation* op = iSession->TransferCommandL(
+                *msvEntrySelection,
+                EMmsDeleteEntries,
+                paramPack,
+                iWait->iStatus);
+            CleanupStack::PushL(op);
+            iWait->Start();
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        CleanupStack::PopAndDestroy(); //msvEntrySelection
+
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    }
+
+TMsvId MmsTestBed::findMMSFolder()
+    {
+    return iSettings->NotificationFolder();
+    }
+
+void MmsTestBed::restoreFactorySettings()
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+    // do not reset access point
+    TInt accessPoint = iSettings->AccessPoint( 0 );
+    iSettings->RestoreFactorySettingsL( iMmsClient->Session(), EMmsFactorySettingsLevelDeep );
+    TInt count = iSettings->AccessPointCount();
+    TInt i = 0;
+    for ( i = count - 1; i >= 0; --i )
+        {
+        iSettings->DeleteAccessPointL( i );
+        }
+    // restore the original access point
+    if ( accessPoint > 0 )
+        {
+        // a negative access point is an error (most likely "KErrNotFound")
+        iSettings->AddAccessPointL( accessPoint, 0 );
+        }
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::setFetchingState( TMmsReceivingMode aState )
+    {
+    iMmsClient->RestoreSettingsL();
+    iSettings->CopyL( iMmsClient->MmsSettings() );
+
+    iSettings->SetReceivingModeHome( aState );
+
+    iMmsClient->SetSettingsL( *iSettings );
+    iMmsClient->StoreSettingsL();
+    }
+
+void MmsTestBed::sendFromFile()
+    {
+    CMsvOperation * op = NULL;
+
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    CleanupStack::PushL( selection );
+
+    TRAPD (error, op = iMmsClient->SendL(*selection, iWait->iStatus));
+    if ( error != KErrNone )
+        {
+        CleanupStack::PopAndDestroy(); // selection
+        delete op;
+        return;
+        }
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(2); // op, selection
+    }
+
+void MmsTestBed::sendOneByOne()
+    {
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    CleanupStack::PushL( cEntry );
+
+    CMsvEntrySelection* selection = NULL;
+    selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL( selection );
+
+    CMsvEntrySelection* shortSelection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( shortSelection );
+
+    TInt i;
+
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        shortSelection->Reset();
+        shortSelection->AppendL( selection->At( i ) );
+
+        CMsvOperation * op = NULL;
+
+        TTime now;
+        now.UniversalTime();
+
+        TRAPD (error, op = iMmsClient->SendL(*shortSelection, iWait->iStatus, now ));
+        if ( error != KErrNone )
+            {
+            delete op;
+            CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+            return;
+            }
+        CleanupStack::PushL(op);
+        iWait->Start();
+
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // op
+
+        }
+    CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection
+    }
+
+void MmsTestBed::sendNotifications()
+    {
+    // Only send one notification!!
+
+    TInt error = KErrNone;
+
+    if (! TMmsTestUtils::IsFile(iCurrentFile, iFs) )
+        {
+        //Not a file
+        return;
+        }
+    TMsvId mmsFolder = findMMSFolder();
+
+    TEntry entry;
+
+
+    // now I think we have a filename
+    TEntry orgEntry;
+    TUint size = 0;
+    error = iFs.Entry( iCurrentFile, orgEntry );
+    size = orgEntry.iSize;
+
+    //TMmsLogger::Log(_L("- notification %S "), &iCurrentFile);
+    if ( size == 0 )
+        {
+        //empty file
+        //TMmsLogger::Log(_L("- empty file"));
+        return;
+        }
+
+    if ( iEncodeBuffer == NULL )
+        {
+        iEncodeBuffer = CBufFlat::NewL( size );
+        }
+    else
+        {
+        iEncodeBuffer->ResizeL( 0 );
+        iEncodeBuffer->ResizeL( size );
+        }
+
+    RFile inFile;
+    error = inFile.Open( iFs, iCurrentFile, EFileShareReadersOnly );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+    if ( error == KErrNone )
+        {
+        error = inFile.Read( ptr, size );
+        inFile.Close();
+        }
+    else
+       {
+       //Error
+       //TMmsLogger::Log(_L("- can't read file"));
+       return;
+       }
+
+    TUint8 byte;
+    TUint position = 0;
+    TUint32 uintvar = 0;
+
+    if ( size > 2 )
+        {
+        iEncodeBuffer->Read( 1, &byte, 1 );
+        if ( byte == 6 ) // PUSH PDU
+            {
+            // try to find out length of header
+            position = 2;
+            iEncodeBuffer->Read( position, &byte, 1);
+
+            while ( byte & 0x80  && position < size )
+                {
+                uintvar += ( byte & 0x7f );
+                uintvar <<= 7;
+                position++;
+                iEncodeBuffer->Read( position, &byte, 1 );
+                }
+
+            // add last byte without shift
+            uintvar += byte;
+            position++;
+           }
+        }
+
+    position += uintvar;
+
+    if ( position < size )
+        {
+        ptr = iEncodeBuffer->Ptr( position );
+        size = ptr.Length();
+        }
+
+    if ( size == 0 )
+        {
+        //no MMS stuff
+        //TMmsLogger::Log(_L("- no MMS stuff"));
+        return;
+        }
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    User::After(1000000);
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::copyDrafts()
+    {
+    CMsvEntry* cEntry = NULL;
+// Copies contents of sent folder to drafts for retrying sending.
+
+    cEntry = iSession->GetEntryL(KMsvSentEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    TMsvLocalOperationProgress progress;
+    cEntry->CopyL( *selection, KMsvDraftEntryId, progress );
+
+    TInt i = 0;
+    for ( i = 0; i < selection->Count(); ++i )
+        {
+        cEntry->SetEntryL( selection->At( i ) );
+        TMsvEntry entry = cEntry->Entry();
+        entry.SetReadOnly( EFalse );
+        cEntry->ChangeL( entry );
+        }
+
+    CleanupStack::PopAndDestroy(2); // selection, cEntry
+    }
+
+void MmsTestBed::garbageCollection(TUint32 aReason)
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    TMMSGarbageCollectionParameters parameters; // initialized to zero
+    parameters.iReasonFlags = aReason;
+    TMMSGarbageCollectionParametersBuf paramPack( parameters );
+    op = iSession->TransferCommandL(
+        *selection, EMmsGarbageCollection, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::messageVariation()
+    {
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+
+    op = iSession->TransferCommandL(
+        *selection, EMmsMessageGeneration, TPtrC8(), iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::cancelSendScheduling()
+    {
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    scheduledSend(KMsvGlobalOutBoxIndexEntryIdValue, 10000); // long delay so that we have time to cancel
+    deleteSendSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy();
+    }
+
+void MmsTestBed::scheduledSend(TMsvId aBoxId, TInt aDelay /* = 5 */)
+    {
+    CMsvEntry* cEntry = NULL;
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(aBoxId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+//    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledSend,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::deleteSendSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages of outbox
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::cancelFetchScheduling()
+    {
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntry* cEntry = NULL;
+    setFetchingState( EMmsReceivingPostpone );
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+
+    // Wait until notification has arrived - may take a while in global mode
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) == 0
+        && i < 2000 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+
+    fetchForced( 10000 ); // delay to allow cancelling
+    deleteFetchSchedule();
+
+    cEntry = iSession->GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(mmsFolder);
+    if (iMsvEntrySelection != NULL)
+        {
+        delete iMsvEntrySelection;
+        iMsvEntrySelection = NULL;
+        }
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::fetchForced(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::deleteFetchSchedule()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+    cEntry = iSession->GetEntryL( mmsFolderId );
+    CleanupStack::PushL(cEntry);
+    // Get all notifications
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, iDefaultServiceId);
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsDeleteSchedule,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::doAFetchCycle()
+    {
+    // Sends a message from iCurrentFile and lets it come back
+    TMsvId mmsFolder = findMMSFolder();
+    testFile( iCurrentFile );
+    fromOutboxToMmsc(); // immediate send (EMmsSend)
+    // fetching will start automatically
+
+    TInt i = 0;
+    while ( TMmsTestUtils::CountChildrenL( KMsvGlobalInBoxIndexEntryId, iMsvEntrySelection, *iSession ) == 0
+         && i < 2000
+         && TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) > 0 )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        i++;
+        if ( (i/100) * 100 == i )
+            {
+            //TMmsLogger::Log(_L("%d:th wait cycle"), i );
+            }
+        CActiveScheduler::Start();
+        }
+    iTimer->Cancel();
+    }
+
+bool MmsTestBed::checkLogClient()
+    {
+    if ( iLogClient == NULL )
+        {
+        TRAP_IGNORE( iLogClient = CLogClient::NewL( iFs ) );
+        }
+    return ( iLogClient != NULL );
+    }
+
+int MmsTestBed::getLogEntries()
+    {
+    TInt count = 0;
+    if ( !iLogView )
+        {
+        return 0;
+        }
+
+    if ( iLogView->SetFilterL( *iLogFilter, iWait->iStatus ) )
+        {
+        // should complete with KErrNone
+        iWait->Start();
+        if ( iWait->iStatus.Int() == KErrNone )
+            {
+            count = iLogView->CountL();
+            }
+        }
+    return count;
+    }
+
+void MmsTestBed::createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry)
+    {
+    CMsvOperation*  opert = aClientEntry.CreateL(aNewEntry, iWait->iStatus);
+    iWait->Start();
+    if (!opert->iStatus.Int()==KErrNone)
+        {
+        // what should we do? panic?
+        }
+
+    TPckgBuf<TMsvLocalOperationProgress> package;
+    package.Copy(opert->ProgressL());
+    *(TMsvId*)&aNewEntry = package().iId;
+
+    delete opert; opert=NULL;
+    }
+
+void MmsTestBed::cleanOutbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalOutBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanInbox()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanSent()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvSentEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanDrafts()
+    {
+    TMmsTestUtils::CleanBoxL(KMsvDraftEntryId, *iSession);
+    }
+
+void MmsTestBed::cleanAll()
+    {
+    cleanInbox();
+    cleanOutbox();
+    cleanSent();
+    cleanDrafts();
+    TMmsTestUtils::CleanBoxL( iSettings->MMBoxFolder(), *iSession );
+    deleteNotifications();
+    }
+
+void MmsTestBed::reply()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::replyToAll()
+    {
+    // The first message from inbox is replied to
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create reply to all, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::forward()
+    {
+    // The first message from inbox is forwarded
+    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+
+    if ( iMsvEntrySelection->Count() > 0 )
+        {
+        TMsvId originalEntry = iMsvEntrySelection->At(0);
+        iMmsClient->SwitchCurrentEntryL( originalEntry );
+        TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription |
+            KMsvMessagePartRecipient | KMsvMessagePartAttachments;
+        CMsvOperation * op = NULL;
+        op = iMmsClient->ForwardL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus);
+        CleanupStack::PushL(op);
+        iWait->Start();
+        while (iWait->iStatus.Int() == KRequestPending )
+            {
+            if (!iTimer->IsActive())
+                {
+                iTimer->IssueRequest();
+                }
+            CActiveScheduler::Start();
+            }
+
+        iTimer->Cancel();
+        if ( iWait->iStatus.Int() != KErrNone )
+            {
+            //TMmsLogger::Log(_L("Create forward, return status %d"), iWait->iStatus.Int());
+            }
+        else
+            {
+            TMsvId newEntry = KMsvNullIndexEntryId;
+            TPckgBuf<TMsvId> package;
+            package.Copy(op->ProgressL());
+            newEntry = package();
+            if ( newEntry != KMsvNullIndexEntryId )
+                {
+                iMmsClient->SwitchCurrentEntryL( newEntry );
+                // Add a sender: 0601234567
+                iMmsClient->LoadMessageL();
+                iMmsClient->SetSenderL( KMmsSender );
+                iMmsClient->SaveMessageL();
+                cEntry->SetEntryL( newEntry );
+                TMsvEntry entry = cEntry->Entry();
+                entry.SetInPreparation( EFalse );
+                entry.SetVisible( ETrue );
+                cEntry->ChangeL(entry);
+                }
+            }
+        CleanupStack::PopAndDestroy(); // op
+        }
+    CleanupStack::PopAndDestroy(); // cEntry
+    }
+
+void MmsTestBed::sendReadReport()
+    {
+    // TURN READ REPORTS ON (until available from menu)
+    iSettings->LoadSettingsL();
+    iSettings->SetReadReplyReportSendingAllowed( ETrue );
+    iSettings->SaveSettingsL();
+    iMmsClient->RestoreSettingsL();
+
+
+    // Read report is sent for the first message in inbox
+    CMsvEntry* cEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
+    CleanupStack::PushL(cEntry);
+    delete iMsvEntrySelection;
+    iMsvEntrySelection = NULL;
+    iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+
+    if ( iMsvEntrySelection->Count() == 0 )
+        {
+        return;
+        }
+    TMsvId originalEntry = iMsvEntrySelection->At( 0 );
+
+    // new test using Client MTM
+    CMsvOperation * op = NULL;
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+    // Try sending the read report to current entry
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy( op );
+    op = NULL;
+
+/*
+    cEntry->SetEntryL( originalEntry );
+    iMmsHeaders->Reset();
+    CMsvStore* store = cEntry->ReadStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->RestoreL( *store );
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+    HBufC8* messageId = HBufC8::NewL( iMmsHeaders->MessageId().Length() );
+    CleanupStack::PushL( messageId );
+    messageId->Des().Copy( iMmsHeaders->MessageId() );
+
+    iMmsClient->SwitchCurrentEntryL( originalEntry );
+    iMmsClient->LoadMessageL();
+
+    iMmsHeaders->Reset();
+    iMmsHeaders->SetMessageType( KMmsMessageTypeReadRecInd );
+    // Message id cannot be accessed via MMS Client MTM!
+
+    iMmsHeaders->SetMessageIdL( messageId->Des() );
+    CleanupStack::PopAndDestroy( messageId );
+
+    iMmsHeaders->AddTypedAddresseeL( iMmsClient->Sender(), EMsvRecipientTo );
+    // sender must be insert-address-token because we don't know our number
+    TTime now;
+    now.UniversalTime();
+
+    _LIT( K1970, "19700000:000000.000000" );    // 1-Jan 1970 0:00:00
+
+    TTime y1970( K1970 );
+    TTimeIntervalMicroSeconds interval;
+    // we can't use "seconds from" as it only returns a
+    // 32 bit signed integer. If fails in 2038.
+    // "microseconds from" returns a 64 bit signed integer
+    interval = now.MicroSecondsFrom( y1970 );
+    // date in iMmsHeaders() in seconds from 1.1.1970.
+    iMmsHeaders->SetDate( (interval.Int64() ) / KMmsMillion );
+    iMmsHeaders->SetReadStatus( KMmsReadStatusRead );
+
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = FindMMSFolderL();
+
+    cEntry->SetEntryL( mmsFolderId );
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = iDefaultServiceId;
+    entry.iMtmData1 = KMmsMessageReadRecInd;
+    cEntry->CreateL( entry );
+    TMsvId entryId = entry.Id();
+
+    cEntry->SetEntryL( entryId );
+
+    store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );
+    iMmsHeaders->StoreL( *store );
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    store = NULL;
+
+    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->InsertL(0, entryId);
+
+    CMsvOperation * op = NULL;
+    TCommandParameters parameters; // initialized to zero
+    TCommandParametersBuf paramPack( parameters );
+
+    op = iSession->TransferCommandL(*selection,EMmsScheduledReadReport,paramPack,iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    if ( iWait->iStatus.Int() != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int());
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy( op );
+    CleanupStack::PopAndDestroy( selection );
+*/
+    CleanupStack::PopAndDestroy( cEntry );
+    }
+
+int MmsTestBed::fromOutboxToMmscWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt messageCount = 0;
+    TInt failureCount = 0;
+    do {
+        CMsvEntry* cEntry = NULL;
+
+        // Get List of services
+        cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue);
+        CleanupStack::PushL(cEntry);
+        // Get all mms messages of outbox
+        CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        CleanupStack::PushL( selection );
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        selection->InsertL(0, iServiceId);
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iSession->TransferCommandL(*selection,EMmsSend,paramPack,iWait->iStatus));
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // selection
+        CleanupStack::PopAndDestroy(); // cEntry
+        selection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( KMsvGlobalOutBoxIndexEntryIdValue );
+        CleanupStack::PushL(cEntry);
+        selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = selection->Count();
+        delete selection;
+        selection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    return failureCount;
+    }
+
+int MmsTestBed::fromMmscToInboxWithMemoryFailure()
+    {
+    TInt error = KErrNone;
+    TInt failureCount = 0;
+    TInt messageCount = 0;
+    TMsvId mmsFolderId = KMsvNullIndexEntryId;
+    mmsFolderId = findMMSFolder();
+
+    do {
+        // Inbox must be cleaned if failure makes message to be fetched more than once.
+        // should not happen, but this test is quite stressful, and perfect result
+        // cannot be guaranteed.
+        // What is expected:
+        // 1. Program does not crash
+        // 2. After sufficient number of retries the message is fetched and notification deleted.
+        TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession);
+        CMsvEntry* cEntry = NULL;
+        CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection;
+        CleanupStack::PushL(msvEntrySelection);
+
+        cEntry = iSession->GetEntryL(iServiceId);
+        CleanupStack::PushL(cEntry);
+
+        failureCount++;
+        // These are failures that fail in Message server.
+        if ( failureCount >= 63 && failureCount <= 64 )
+            {
+            failureCount = 65;
+            }
+        cEntry->SetEntryL( iServiceId );
+
+        TMsvEntry entry = cEntry->Entry();
+        entry.iMtmData3 &= 0x0000000FF;
+        entry.iMtmData3 |= failureCount << 8;
+        cEntry->ChangeL( entry );
+
+        // if we have a selected service, insert it into selection
+        if (iServiceId != KMsvNullIndexEntryId)
+            {
+            msvEntrySelection->InsertL(0, iServiceId);
+            }
+
+        CMsvOperation * op = NULL;
+        TCommandParameters parameters; // initialized to zero
+        TCommandParametersBuf paramPack( parameters );
+
+        TRAP (error, op = iMmsClient->InvokeAsyncFunctionL(
+            EMmsReceiveForced,
+            *msvEntrySelection,
+            paramPack,
+            iWait->iStatus) );
+
+        if ( error == KErrNone )
+            {
+            CleanupStack::PushL(op);
+            iWait->Start();
+
+            while (iWait->iStatus.Int() == KRequestPending )
+                {
+                if (!iTimer->IsActive())
+                    {
+                    iTimer->IssueRequest();
+                    }
+                CActiveScheduler::Start();
+                }
+
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                error = iWait->iStatus.Int();
+                if ( iWait->iStatus.Int() != KErrNoMemory )
+                    {
+                    //TMmsLogger::Log(_L("Testbed tried to receive, return status %d"), iWait->iStatus.Int());
+                    }
+                }
+
+            CleanupStack::PopAndDestroy(); // op
+            }
+
+        iTimer->Cancel();
+        CleanupStack::PopAndDestroy(); // msvEntrySelection
+        CleanupStack::PopAndDestroy(); // cEntry
+        msvEntrySelection = NULL;
+        cEntry = NULL;
+        cEntry = iSession->GetEntryL( mmsFolderId );
+        CleanupStack::PushL(cEntry);
+        msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+        messageCount = msvEntrySelection->Count();
+        delete msvEntrySelection;
+        msvEntrySelection = 0;
+        CleanupStack::PopAndDestroy(); //cEntry
+        }
+    while ( error == KErrNoMemory || messageCount > 0 );
+    if ( error != KErrNoMemory && error != KErrNone )
+        {
+        //TMmsLogger::Log(_L("Memory failure loop ended with %d"), error);
+        }
+    return failureCount;
+    }
+
+void MmsTestBed::sendViaClient()
+    {
+    CMsvEntry* cEntry = NULL;
+
+    cEntry = iSession->GetEntryL(KMsvDraftEntryId);
+    CleanupStack::PushL(cEntry);
+    // Get all mms messages in drafts
+    CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia );
+    CleanupStack::PushL( selection );
+
+    CMsvOperation * op = NULL;
+    TTime now;
+    now.UniversalTime();
+    op = iMmsClient->SendL( *selection, iWait->iStatus, now );
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(2); // cEntry, selection
+    }
+
+void MmsTestBed::scheduledFetch(TInt aDelay /* = 5 */)
+    {
+    TCommandParameters parameters;
+    parameters.iInitialDelay = aDelay;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsScheduledReceive,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::fetchForcedImmediate()
+    {
+    TCommandParameters parameters;
+    TCommandParametersBuf paramPack( parameters );
+
+    CMsvEntrySelection* selection = new CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    // if we have a selected service, insert it into selection
+    if (iServiceId != KMsvNullIndexEntryId)
+        {
+        selection->InsertL(0, iServiceId);
+        }
+    else
+        {
+        selection->InsertL(0, iDefaultServiceId);
+        }
+
+
+    CMsvOperation * op = NULL;
+    op = iMmsClient->InvokeAsyncFunctionL(
+        EMmsReceiveForced,
+        *selection,
+        paramPack,
+        iWait->iStatus);
+
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
+void MmsTestBed::getEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    iLogClient->GetEventType( *eventType, iWait->iStatus );
+
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::addEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+
+    CLogEventType* eventType = CLogEventType::NewL();
+    CleanupStack::PushL( eventType );
+    eventType->SetUid(iLogEvent->EventType());
+    eventType->SetDescription(_L("Multimedia Message") );
+    eventType->SetLoggingEnabled( ETrue );
+
+//    iWait->iStatus = KRequestPending;
+    iLogClient->AddEventType( *eventType, iWait->iStatus );
+    iWait->Start();
+    CleanupStack::PopAndDestroy(); // eventType
+    }
+
+void MmsTestBed::deleteEventType()
+    {
+    if ( !checkLogClient() )
+        {
+        return; // not available
+        }
+//    iWait->iStatus = KRequestPending;
+    iLogClient->DeleteEventType( iLogEvent->EventType(), iWait->iStatus );
+    iWait->Start();
+    }
+
+void MmsTestBed::cleanLog()
+    {
+    TInt count = 0;
+
+    count = getLogEntries();
+
+    TInt i;
+    for ( i = 0; i < count; ++i )
+        {
+        // when a view is created, it will be positioned on the first event
+//        iWait->iStatus = KRequestPending;
+        iLogClient->DeleteEvent(iLogView->Event().Id(), iWait->iStatus);
+        iWait->Start();
+
+        if ( iLogView->NextL( iWait->iStatus ) )
+            {
+            // should complete with KErrNone
+            iWait->Start();
+            if ( iWait->iStatus.Int() != KErrNone )
+                {
+                // could not get next event!
+                break;
+                }
+            }
+        else
+            {
+            break; // no more events!
+            }
+        }
+    }
+
+void MmsTestBed::setOnline(bool value)
+    {
+    //value = true for online mode
+    //value = false for offline mode
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KCRUidCoreApplicationUIs ) );
+    if( retval == KErrNone )
+        {
+        repository->Set( KCoreAppUIsNetworkConnectionAllowed, value );
+        delete repository;
+        }
+    }
+
+void MmsTestBed::generateDeliveryReport( CMmsHeaders* aMmsHeaders )
+    {
+    iEncodeBuffer->ResizeL( 1024 );
+
+    TInt position = 0;
+
+    // encode message type
+    iEncodeBuffer->Write( position, &KMmsAssignedMessageType, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageTypeDeliveryInd, 1 );
+    position++;
+
+    // version
+    iEncodeBuffer->Write( position, &KMmsAssignedMmsVersion, 1 );
+    position++;
+
+    TUint8 version = aMmsHeaders->MmsVersion() | 0x80; // current version as short integer
+    iEncodeBuffer->Write( position, &version, 1 );
+    position++;
+
+    // message id from the headers
+    // At least once MMSC did not send us the message id!
+    // if message id is missing, we cannot match the entry!
+    // This only a fake. Real delivery reports should always
+    // contain the message id.
+    if ( aMmsHeaders->MessageId().Length() > 0 )
+        {
+        iEncodeBuffer->Write( position, &KMmsAssignedMessageId, 1 );
+        position++;
+        iEncodeBuffer->Write( position, &(aMmsHeaders->MessageId()[0]), aMmsHeaders->MessageId().Length() );
+        position += aMmsHeaders->MessageId().Length();
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // To is taken from the headers
+    iEncodeBuffer->Write( position, &KMmsAssignedTo, 1 );
+    position++;
+
+    TPtrC recipient;
+    if ( aMmsHeaders->ToRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->ToRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->ToRecipients()[0] );
+        }
+    else if( aMmsHeaders->CcRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->CcRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->CcRecipients()[0] );
+        }
+    else if( aMmsHeaders->BccRecipients().MdcaCount() > 0 &&
+        aMmsHeaders->BccRecipients()[0].Length() > 0 )
+        {
+        recipient.Set( aMmsHeaders->BccRecipients()[0] );
+        }
+    else
+        {
+        recipient.Set( _L("Jasso-Kissa@jii.fi") );
+        }
+
+    TMmsAddressType addressType = EMmsAddressTypeUnknown;
+
+    if ( recipient.Find( KMiuMau ) != KErrNotFound )
+        {
+        addressType = EMmsAddressTypeEmail;
+        }
+    else
+        {
+        addressType = EMmsAddressTypeMobile;
+        }
+
+    TUint8 character;
+    TInt i;
+    if ( addressType == EMmsAddressTypeEmail )
+        {
+        // email address - ASCII ONLY - THIS IS JUST A TEST!
+
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+
+        }
+    else
+        {
+        // must be a phone number
+        // We expect for now that the format is correct as is
+        // All legal characters present in a phone number are ASCII
+
+        TInt i;
+        for ( i = 0; i < recipient.Length(); ++i )
+            {
+            character = TUint8( recipient[i] & 0xff );
+            iEncodeBuffer->Write( position, &character, 1 );
+            position++;
+            }
+        iEncodeBuffer->Write( position, KMmsPlmn, KMmsPlmnLength );
+        position += KMmsPlmnLength;
+        iEncodeBuffer->Write( position, &KMmsNull, 1 );
+        position++;
+        }
+
+    // date
+    iEncodeBuffer->Write( position, &KMmsAssignedDate, 1 );
+    position++;
+
+    TLocale locale;
+    locale.Refresh();
+    TInt64 UtcDate;
+    TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
+
+    TTime now;
+    now.UniversalTime();
+    UtcDate = ( now.MicroSecondsFrom( TTime( KMmsYear1970String ) ).Int64() ) / 1000000 ;
+
+    UtcDate -= universalTimeOffset.Int();
+
+    if ( locale.QueryHomeHasDaylightSavingOn() )
+        {
+        TTimeIntervalSeconds daylightSaving( 60 * 60 );
+        UtcDate -= daylightSaving.Int();
+        }
+
+    TUint8 len; // number of bytes we will need
+    len = 0;
+    TUint8 array[8];
+
+    TInt64 temp = UtcDate;
+
+    for (i = 7; i >= 0; --i)
+        {
+        array[i] = TInt8( ( I64INT( temp ) ) & 0xFF );
+        I64LSR( temp, 8 );
+        }
+
+    len = 8;
+    i = 0;
+    while( ( array[i]== 0 ) && ( i < 8 ) )
+        {
+        i++;
+        len--;
+        }
+
+    // a zero should be coded as short integer.
+    // However, if there is a valid reason to code a zero as a long integer,
+    // we allow it. The caller should know what he is doing.
+    if ( len == 0 )
+        {
+        len = 1;
+        }
+    // write short length
+    iEncodeBuffer->Write( position, &len, 1 );
+    position++;
+    // write as many bytes as were non-zero
+    iEncodeBuffer->Write( position, &(array[8 - len] ), len );
+    position+= len;
+    // status
+    iEncodeBuffer->Write( position, &KMmsAssignedStatus, 1 );
+    position++;
+    iEncodeBuffer->Write( position, &KMmsMessageStatusRetrieved, 1 );
+    position++;
+    // DONE!!!
+    iEncodeBuffer->ResizeL( position );
+    return;
+    }
+
+void MmsTestBed::sendDeliveryReport()
+    {
+    if ( iEncodeBuffer->Size() == 0 )
+        {
+        //No delivery report
+        return;
+        }
+
+
+    TMsvId mmsFolder = findMMSFolder();
+    CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+
+    TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession );
+    TPtr8 ptr = iEncodeBuffer->Ptr( 0 );
+
+    // Now we have streamed our data into this entry.
+    // Now we have an entry that says: local service, MMS MTM
+
+    if ( entryId != KMsvNullIndexEntryId )
+        {
+        selection->AppendL( entryId );
+        }
+    else
+        {
+        selection->AppendL( iDefaultServiceId );
+        }
+
+    TWatcherParameters parameters; // initialized to zero
+    parameters.iWatcherId = RThread().Id();
+    parameters.iDataPointer = &ptr;
+    TWatcherParametersBuf paramPack( parameters );
+
+    CMsvOperation * op = NULL;
+
+//    iWait->iStatus = KRequestPending;
+    op = iSession->TransferCommandL(
+        *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus );
+    CleanupStack::PushL(op);
+    iWait->Start();
+
+    while (iWait->iStatus.Int() == KRequestPending )
+        {
+        if (!iTimer->IsActive())
+            {
+            iTimer->IssueRequest();
+            }
+        CActiveScheduler::Start();
+        }
+
+    iTimer->Cancel();
+
+    CleanupStack::PopAndDestroy(); // op
+    CleanupStack::PopAndDestroy(); // selection
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmsteststaticutils.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include <f32file.h>
+#include <centralrepository.h>
+#include <apparc.h>
+#include <msvapi.h>
+#include <msvids.h>
+
+#include "mmsteststaticutils.h"
+#include "mmsconst.h"
+#include "MmsEnginePrivateCRKeys.h"
+#include "mmssettings.h"
+#include "mmsheaders.h"
+#include "mmsservercommon.h"
+#include "mmsencode.h"
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsJoinedArrays::TMmsJoinedArrays(CDesCArray* const & aArray1, CDesCArray* const & aArray2)
+: iArray1(aArray1), iArray2(aArray2)
+    {
+    }
+
+TInt TMmsJoinedArrays::MdcaCount() const
+    {
+    TInt count=0;
+    if (iArray1)
+        count += iArray1->MdcaCount();
+    if (iArray2)
+        count += iArray2->MdcaCount();
+    return count;
+    }
+
+TPtrC16 TMmsJoinedArrays::MdcaPoint(TInt aIndex) const
+    {
+    if (iArray1)
+        {
+        if (aIndex < iArray1->MdcaCount())
+            return iArray1->MdcaPoint(aIndex);
+        else
+            aIndex -= iArray1->MdcaCount();
+        }
+    return iArray2->MdcaPoint(aIndex);
+    }
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TMmsTestUtils::TMmsTestUtils()
+    {
+
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+HBufC* TMmsTestUtils::ReadContactFromFileL( TDesC& aFileName, RFs& aFs )
+    {
+    RFile file;
+    TInt error = KErrNone;
+
+    TInt textBufferSize = 256;
+    HBufC* textBuffer = HBufC::NewL( textBufferSize );
+    TPtr textPtr = textBuffer->Des();
+    TFileText textFile;
+
+    error = file.Open( aFs, aFileName,
+            EFileRead|EFileShareReadersOnly );
+
+    if ( error == KErrNone )
+        {
+        textFile.Set( file );
+        error = textFile.Seek( ESeekStart );
+        }
+
+    if ( error == KErrNone )
+        {
+        error = textFile.Read( textPtr );
+        }
+
+    file.Close();
+
+    if ( textBuffer->Des().Find( &KMmsByteOrderMark, 1 ) == 0 )
+        {
+        textBuffer->Des().Copy( textBuffer->Des().Mid( 1 ) );
+        }
+
+    return textBuffer;
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOnL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off detailed logging while decoding a message
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::DecodeLoggingOffL()
+    {
+    // CenRep for decodelogging
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineDecodeLog, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 1;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off binary dump of incoming messages
+//----------------------------------------------------------------------------------------
+//
+void TMmsTestUtils::BinaryDumpOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) );
+    if( retval == KErrNone )
+        {
+        // Best effort - if cannot access repository, no can do
+        TInt temp = 0;
+        repository->Set( KMmsEngineBinaryDump, temp );
+        delete repository;
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanDirectoryL( RFs& aFs )
+    {
+    // Delete the files in the directory
+    CFileMan* fileMan = CFileMan::NewL( aFs );
+    CleanupStack::PushL( fileMan );
+    fileMan->RmDir( KMmsDefaultLocalModeDir );
+    fileMan->RmDir( KMmsMMBoxDirectory );
+    fileMan->RmDir( KMmsMMBoxDescriptionDirectory );
+    CleanupStack::PopAndDestroy(); // fileManager
+    // we don't want to throw these away!
+    aFs.MkDirAll( KMmsDefaultLocalModeDir );
+    aFs.MkDirAll( KMmsMMBoxDirectory );
+    aFs.MkDirAll( KMmsMMBoxDescriptionDirectory );
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::Dump( CBufFlat& aBuffer, TFileName& aFilename, TParse& aParse, RFs& aFs )
+    {
+    TInt error = KErrNone;
+    aFs.MkDirAll( aFilename );
+    TUint att;
+    if ( aFs.Att( aFilename, att ) == KErrNone )
+        {
+        _LIT( KRelated, "dump.mms");
+        aParse.Set( aFilename, &KRelated, NULL );
+        aFilename = aParse.FullName();
+        error = CApaApplication::GenerateFileName( aFs, aFilename );
+        if ( error == KErrNone )
+            {
+            RFile file;
+            error = file.Create( aFs, aFilename, EFileWrite | EFileShareExclusive );
+            // for message id generation
+            aParse.Set( aFilename, NULL, NULL );
+            if ( error == KErrNone )
+                {
+                // the data is supposed to be in the encode buffer
+                TPtr8 ptr = aBuffer.Ptr( 0 );
+                file.Write( ptr );
+                file.Flush();
+                }
+
+            // done - close files
+            file.Close();
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void TMmsTestUtils::CleanBoxL(TMsvId aBoxId, CMsvSession& aSession)
+    {
+    CMsvEntry* cEntry = NULL;
+    // delete all messages from the specified box
+    cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    // show invisible entries
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
+    CleanupStack::PushL(msvEntrySelection);
+
+    CMsvEntrySelection* selection = NULL;
+    cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
+    selection = cEntry->ChildrenWithMtmL(KUidMsgMMSNotification);
+    CleanupStack::PushL( selection );
+    if ( selection->Count() > 0 )
+        {
+        msvEntrySelection->AppendL( selection->Back( 0 ), selection->Count() );
+        }
+    CleanupStack::PopAndDestroy(); // selection
+
+    int i;
+    for (i = 0; i < msvEntrySelection->Count(); ++i)
+        {
+        CMsvEntry* entry = aSession.GetEntryL( msvEntrySelection->At(i) );
+        CleanupStack::PushL( entry );
+        TMsvEntry tEntry = entry->Entry();
+        tEntry.SetReadOnly(EFalse);
+        entry->ChangeL(tEntry);
+        cEntry->DeleteL( msvEntrySelection->At(i) );
+        CleanupStack::PopAndDestroy( entry );
+        }
+
+    CleanupStack::PopAndDestroy(msvEntrySelection);
+    CleanupStack::PopAndDestroy(cEntry);
+    }
+
+//----------------------------------------------------------------------------------------
+// turn on logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOnL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 1;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+// turn off logging email recipients
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::EmailLoggingOffL()
+    {
+    // CenRep for binarydump setting
+    CRepository* repository = NULL;
+    TInt retval = KErrNone;
+    TRAP( retval, repository = CRepository::NewL( KUidMmsServerMtm ) ); // ***
+    if( retval == KErrNone )
+        {
+        TInt temp = 0;
+        repository->Set( KMmsEngineLogEmailRecipients, temp );
+        delete repository;
+        }
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TInt TMmsTestUtils::CountChildrenL(TMsvId aBoxId, CMsvEntrySelection*& aMsvEntrySelection, CMsvSession& aSession, TUid aMessageType )
+    {
+    CMsvEntry* cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
+    CleanupStack::PushL(cEntry);
+    cEntry->SetEntryL(aBoxId);
+    if (aMsvEntrySelection != NULL)
+        {
+        delete aMsvEntrySelection;
+        aMsvEntrySelection = NULL;
+        }
+    aMsvEntrySelection = cEntry->ChildrenWithMtmL(aMessageType);
+    CleanupStack::PopAndDestroy(); // cEntry
+    return aMsvEntrySelection->Count();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CreateFolderEntryL
+//
+// -----------------------------------------------------------------------------
+//
+void TMmsTestUtils::CreateFolderEntryL(
+    CMsvSession& aSession,
+    TMsvId aParentFolder,
+    const TDesC& aFolderName,
+    TMsvId& aFolderId )
+    {
+    aFolderId = KMsvNullIndexEntryId;
+    CMsvEntry* cEntry = aSession.GetEntryL( aParentFolder );
+    CleanupStack::PushL( cEntry );
+
+    // Create a new folder.
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvFolderEntry;
+    entry.iMtm = KUidMsvLocalServiceMtm;
+    entry.iDetails.Set( aFolderName );
+    entry.SetVisible( EFalse );
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    cEntry->CreateL( entry );
+    aFolderId = entry.Id();
+    CleanupStack::PopAndDestroy( cEntry );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TMsvId TMmsTestUtils::CreateNotificationEntryL(
+        TMsvId aNotificationFolder,
+        TMsvId aServiceId,
+        CBufFlat* aEncodeBuffer,
+        CMsvSession& aSession )
+    {
+    TMsvId entryId = KMsvNullIndexEntryId;
+    if ( aNotificationFolder == KMsvNullIndexEntryId )
+        {
+        // no folder no entry
+        return entryId;
+        }
+
+    CMsvEntry* cEntry = aSession.GetEntryL( aNotificationFolder );
+    CleanupStack::PushL(cEntry);
+
+    TMsvEntry entry;
+    entry.iType = KUidMsvMessageEntry;
+    entry.iMtm = KUidMsgTypeMultimedia;
+    entry.SetVisible( ETrue );
+    // If we want to put data here, InPreparation must be set to true first
+    entry.SetInPreparation( EFalse );
+    entry.iServiceId = KMsvLocalServiceIndexEntryId;
+    entry.iRelatedId = aServiceId;
+    entry.iMtmData2 = KMmsNotificationBinary;
+    cEntry->CreateL( entry );
+    entryId = entry.Id();
+
+    //
+    // Stream
+    // 1) length of the data as 32 bit integer
+    // 2) pushed message data
+    // into created entry's stream
+    //
+    cEntry->SetEntryL( entryId );
+    CMsvStore* store = cEntry->EditStoreL();
+    CleanupStack::PushL( store );   // ***
+    RMsvWriteStream outs;
+    outs.AssignLC( *store, KUidBinaryNotificationStream ); // ***
+    TPtrC8 ptr = aEncodeBuffer->Ptr( 0 );
+    outs.WriteUint32L( ptr.Length() );
+    outs.WriteL( ptr );
+    outs.CommitL();
+    outs.Close();
+    store->CommitL();
+
+    CleanupStack::PopAndDestroy( &outs ); // close outs
+    CleanupStack::PopAndDestroy( store );
+    CleanupStack::PopAndDestroy( cEntry );
+
+    return entryId;
+
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+void TMmsTestUtils::FormNotification(
+        TDesC8& aUrl,
+        TInt aSize,
+        CMmsHeaders& aMmsHeaders,
+        CMmsEncode& aMmsEncoder,
+        CBufFlat* aEncodeBuffer )
+    {
+    // for test purposes aUrl will contain the filename.
+
+    // Reset sets the default encapsulation version
+    // The default version has been set from MmsSettings in NewL
+    aMmsHeaders.Reset();
+
+    // construct the notification into iMmsHeaders, and call encode
+
+    aMmsHeaders.SetMessageType( KMmsMessageTypeMNotificationInd );
+
+    TTime currentTime;
+    currentTime.UniversalTime();
+    currentTime.Int64();
+
+    TPtrC8 tid;
+    TBufC8<KMMSMAXTIDLENGTH> target;
+    TInt random = 0;
+
+    // we don't generate a true random TID: We generate the
+    // TID from the URL so that if we generate a notification
+    // twice from the same file, we get the same TID and the
+    // same URL. This way we can test the pruning function in
+    // server MTM
+
+    TInt i;
+    for ( i = 0; i < aUrl.Length(); ++i )
+        {
+        random += aUrl[ i ];
+        }
+
+    target.Des().Num( random );
+    tid.Set( target.Des() );
+    aMmsHeaders.SetTidL( tid );
+
+    aMmsHeaders.SetMessageClass( EMmsClassPersonal );
+    aMmsHeaders.SetMessageSize( aSize );
+    const TInt KTenHours = 10 * 60 * 60; // 10 hours relative expiry
+    aMmsHeaders.SetExpiryInterval( KTenHours );
+    aMmsHeaders.SetContentLocationL( aUrl );
+
+    aMmsEncoder.EncodeHeadersL( aMmsHeaders, *aEncodeBuffer );
+
+    }
+
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsFile(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a file?
+    if (IsDrive(aFileName))
+        return EFalse;
+    return !(IsDir(aFileName, aFs));
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDir(const TDesC& aFileName, RFs& aFs)
+    {
+    //Is the name a directory?
+    TEntry entry;
+    TInt err = aFs.Entry(aFileName, entry);
+    if (err)
+        return EFalse;
+    else
+        return entry.IsDir();
+    }
+
+//----------------------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------------------
+TBool TMmsTestUtils::IsDrive(const TDesC& aFileName)
+    {
+    //horrible little function to figure if the path is just a drive
+    TBool retVal = EFalse;
+    if (aFileName.Length()==3) //eg "c:\"
+        {
+        if ((aFileName[1] == ':')  && (aFileName[2] == '\\'))
+            retVal=ETrue;
+        }
+    else if (aFileName.Length()==2) //eg "c:"
+        {
+        if (aFileName[1] == ':')
+            retVal=ETrue;
+        }
+    return retVal;
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/mmstestbed/src/mmstestuitimer.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ */
+
+#include "mmstestuitimer.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::CTestUiTimer(): CTimer( 5 )
+    {
+    period = KPeriod;
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer* CTestUiTimer::NewL()
+    {
+    CTestUiTimer* self = new(ELeave) CTestUiTimer();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUiTimer::~CTestUiTimer()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::IssueRequest()
+    {
+    // No operation to cancel if this function is called
+    iObject = NULL;
+    After(period);
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::TimeoutOperation( CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds )
+    {
+    iObject = aObject;
+    TTimeIntervalMicroSeconds32 timeout = aTimeoutInSeconds.Int() * 1000000;
+    After( timeout );
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    if ( iObject )
+        {
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUiTimer::RunL()
+    {
+    if ( iObject )
+        {
+        // If we timeout while holding an active object, we cancel it
+        iObject->Cancel();
+        iObject = NULL;
+        }
+    else
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/inc/testmmsplugin.h	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: Main test class declaration for MMS Plugin
+ */
+
+#ifndef TEST_MMS_PLUGIN_H
+#define TEST_MMS_PLUGIN_H
+
+#ifdef BUILD_TEST_DLL
+#define TEST_EXPORT Q_DECL_EXPORT
+#else
+#define TEST_EXPORT Q_DECL_IMPORT
+#endif
+
+#include <QObject>
+#include <QSignalSpy>
+#include <e32const.h>
+
+//Forward Declarations
+class UniEditorMmsPlugin;
+class ConvergedMessage;
+class MmsTestBed;
+
+//Class Declaration: TestMmsPlugin
+class TEST_EXPORT TestMmsPlugin: public QObject
+    {
+    Q_OBJECT
+
+private slots:
+    
+    /**
+	 * Initialises the whole Test
+	 **/  
+   	void initTestCase();//called before the first testfunction is executed.
+    
+    /**
+	 * Initialises each Test Case
+	 **/  
+    void init();//called before each testfunction is executed.
+    
+   	 /**
+	 * Creates a MMS messsage with a text attachment
+	 **/  
+	void createMMSWithTextAttachment();
+	
+	/**
+	 * Tests the MMS message with a text attachment
+	 **/  
+	void testMMSWithTextAttachment();
+	
+	/**
+	 * Sends the MMS message with a text attachment
+	 **/  
+	void sendMMSWithTextAttachment();
+	
+	/**
+	 * Tests that the MMS message is sent successfully
+	 **/  
+	void testSentMMSWithTextAttachment();
+	
+	/**
+	 * Creates a MMS messsage with a text and an Image attachments
+	 **/  
+	void createMMSWithTextAndImageAttachment();
+	
+	/**
+	 * Tests the MMS message with a text and an Image attachments
+	 **/  
+	void testMMSWithTextAndImageAttachment();
+	
+	/**
+	 * Sends the MMS message with a text and an Image attachments
+	 **/  
+	void sendMMSWithTextAndImageAttachment();
+	
+	/**
+	 * Tests that the MMS message is sent successfully
+	 **/  
+	void testSentMMSWithTextAndImageAttachment();
+	
+	/**
+	 * Cleans up each Test Case
+	 **/  	
+	void cleanup();
+	
+	/**
+	 * Cleans up the whole Test Case
+	 **/  	
+    void cleanupTestCase();
+
+private: // Data
+    
+    /**
+	 * msgPlugin - MMS Message Plug-in
+	 **/  	
+    UniEditorMmsPlugin* msgPlugin;
+    
+    /**
+	 * mmstestbed - MMS Message Simulator
+	 **/  	
+    MmsTestBed* mmstestbed;
+    
+    /**
+	 * spy_draft - Signal Spy for Draft Folder
+	 **/  	
+	QSignalSpy* spy_draft;
+	
+	/**
+	 * spy_outbox - Signal Spy for Outbox Folder
+	 **/  	
+	QSignalSpy* spy_outbox;
+	
+	/**
+	 * spy_sent - Signal Spy for Sent Folder
+	 **/  	
+	QSignalSpy* spy_sent;
+	
+	/**
+	 * spy_inbox - Signal Spy for Inbox Folder
+	 **/  	
+	QSignalSpy* spy_inbox;
+	
+	/**
+	 * mmsMsgId - The MMS message Id
+	 **/  	
+	long int mmsMsgId;
+    };
+#endif //TEST_MMS_PLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/inc/testmmsplugin.ini	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,9 @@
+//this file is used to provide predefined set of input data.
+
+//eg.
+const char TEST_MSG_SUBJECT[]     = "Message Subject";
+const char TEST_SENDER[]			= "DummySender<+919860479112>";
+const char TEST_ATTACHMENT4[]		= "c:\\SmileyFace.gif";
+const char TEST_ATTACHMENT5[]		= "c:\\sample.txt";
+const char TEST_CC[]			= "DummyCCAddress<+919860479113>";
+const char TEST_BCC[]			= "DummyBCCAddress<+919860479114>";
\ No newline at end of file
Binary file messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/mms.rsc has changed
Binary file messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/not.rsc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/src/testmmsplugin.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description: : Main test class definition for MMS Plugin
+ */
+
+#include <QtTest/QtTest>
+#include <QTimer>
+#include <QSignalSpy>
+#include "debugtraces.h"
+#include "testmmsplugin.h"
+#include "convergedmessage.h"
+#include "convergedmessageid.h"
+#include "unieditormmsplugin.h"
+#include "mmstestbed.h"
+#include "testmmsplugin.ini"
+
+//---------------------------------------------------------------
+// TestMmsPlugin::initTestCase
+//---------------------------------------------------------------
+void TestMmsPlugin::initTestCase()
+{
+	//Instantiate UniEditorMmsPlugin and verify if it is correctly Instantited. 
+	msgPlugin = new UniEditorMmsPlugin();
+	QVERIFY(msgPlugin != NULL);
+	
+	//Verify if MMS service is Validated. 
+    QCOMPARE(msgPlugin->validateService(), 1);
+    QCOMPARE(msgPlugin->isServiceValid(), 1);
+    msgPlugin->setEncodingSettings(ETrue, ESmsEncodingNone, -1);
+    QString str("Hello");
+    TInt numOfRemainingChars = 1;
+    TInt numOfPDUs = 1;
+    TBool unicodeMode = ETrue;
+    TSmsEncoding smsEncoding = ESmsEncodingNone;
+    QVERIFY(msgPlugin->getNumPDUs(str, numOfRemainingChars, numOfPDUs, unicodeMode, smsEncoding) == true);
+    
+    //Verify MmsTestBed Instance. 
+    mmstestbed = new MmsTestBed;
+	QVERIFY(mmstestbed != NULL);
+	
+	//register user defined object to meta system.
+	qRegisterMetaType<long int> ("long int");
+	
+	//set up signalspy to listen to signals emitted by mmstestbed
+	spy_draft = new QSignalSpy(mmstestbed, SIGNAL(entryCreatedInDraft(long int)));
+	spy_outbox = new QSignalSpy(mmstestbed, SIGNAL(entryMovedToOutbox(long int)));
+	spy_sent  = new QSignalSpy(mmstestbed, SIGNAL(entryMovedToSent(long int)));
+	spy_inbox = new QSignalSpy(mmstestbed, SIGNAL(entryCreatedInInbox(long int)));
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::init
+//---------------------------------------------------------------
+void TestMmsPlugin::init()
+{
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::createMMSWithTextAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::createMMSWithTextAttachment()
+{
+    //Create a Converged Message instance. 
+    QString subject  = TEST_MSG_SUBJECT;
+	qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
+	
+	QString sender(TEST_SENDER);
+	ConvergedMessageAddress address(sender);
+	ConvergedMessageAttachmentList attachmentList;    
+
+	//Add a text attachment to attachment list. 
+	QString attachmentPath = TEST_ATTACHMENT5;
+	ConvergedMessageAttachment* attachment = 
+		new ConvergedMessageAttachment(attachmentPath, ConvergedMessageAttachment::EAttachment);
+	
+	attachmentList.append(attachment);
+	
+	//Instantiate a Converged Message object and set service a MMS
+	ConvergedMessage msg;
+	msg.setMessageType(ConvergedMessage::Mms);
+	
+	//Set Subject
+	msg.setSubject(subject);
+	
+	msg.setTimeStamp(timeStamp);
+	
+	//Set recipient. 
+	msg.addToRecipient(address);
+	
+	//Add attachments' list
+	msg.addAttachments(attachmentList);
+	msg.setPriority(ConvergedMessage::Normal);
+	
+	//Adding CC Address
+	QString ccAddress(TEST_CC);
+	ConvergedMessageAddress ccAdd(ccAddress);
+	msg.addCcRecipient(ccAdd);
+	
+	//Adding BCC Address
+	QString bccAddress(TEST_BCC);
+	ConvergedMessageAddress bccAdd(bccAddress);
+	msg.addBccRecipient(bccAdd);
+	
+	//Adding From Address
+	QString recipientAddress(TEST_SENDER);
+	ConvergedMessageAddress recipientAdd(recipientAddress);
+	msg.addFromRecipient(recipientAdd);
+	
+	//start send and prepare to test send-success or fail
+	mmstestbed->cleanAll();
+	mmstestbed->setConnectionLocal(true);
+	
+	//Get a valid MMS message ID and verify that it is valid.
+	mmsMsgId = msgPlugin->convertTo(&msg);
+	QVERIFY(mmsMsgId != -1);
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testMMSWithTextAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::testMMSWithTextAttachment()
+{
+	long int mmsDraftMsgId;
+	
+	//check if draft-folder signal was received...this means message was created in draft 
+	if( 1 <= spy_draft->count())
+	{
+		//compare the msgid and verify with the ID given by MMS plugin 
+		void * temp = const_cast<void*>(spy_draft->at(0).at(0).data());
+		mmsDraftMsgId = *reinterpret_cast< long int(*)>(temp);
+		QVERIFY(mmsDraftMsgId == mmsMsgId);
+		
+		//Validate the MMS message with all the values set before. 
+		ConvergedMessage* draftMsg = msgPlugin->convertFrom(mmsDraftMsgId);
+		QVERIFY(draftMsg->subject().compare(QString(TEST_MSG_SUBJECT)) == 0);
+		QVERIFY(draftMsg->messageType() == ConvergedMessage::Mms);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->toAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_CC).contains(draftMsg->ccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_BCC).contains(draftMsg->bccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->fromAddress()->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(draftMsg->attachments().count() == 1);
+		QVERIFY(draftMsg->attachments()[0]->attachmentType() == ConvergedMessageAttachment::EAttachment);
+		QVERIFY(draftMsg->attachments()[0]->filePath().contains(QString(TEST_ATTACHMENT5).mid(QString(TEST_ATTACHMENT5).indexOf(QString("Sample.txt"), 0, Qt::CaseInsensitive)), Qt::CaseInsensitive) == true);
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to create message in Draft");
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+	}
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::sendMMSWithTextAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::sendMMSWithTextAttachment()
+{
+	//Send the MMS message and verify if it was sent successfully. 
+	bool sent = msgPlugin->send(mmsMsgId);
+	QVERIFY(sent == true);
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testSentMMSWithTextAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::testSentMMSWithTextAttachment()
+{
+	QTest::qWait(10000);  //to ensure path completion
+	
+	//check if outbox-folder signal was received...this means message was moved to outbox for send    
+	if( 1 <= spy_outbox->count())
+	{
+		//compare the msgid
+		void * temp = const_cast<void*>(spy_outbox->at(0).at(0).data());
+		long int outboxId = *reinterpret_cast< long int(*)>(temp);
+		QCOMPARE(outboxId, mmsMsgId);
+		
+		//push the message from outbox to mmsc(sent folder)
+		mmstestbed->fromOutboxToMmsc();
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Outbox");
+		
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+		return;
+	}
+
+	//check if sent-folder signal was received....this means message was successfully sent scheduled.
+	if( 1 <= spy_sent->count())
+	{
+		//check for send-path
+		void * temp = const_cast<void*>(spy_sent->at(0).at(0).data());
+		long int sentmsgid = *reinterpret_cast< long int(*)>(temp);
+		QCOMPARE(sentmsgid, mmsMsgId);
+		
+		//issue a fetch request on the sent message, to test the receive path
+		mmstestbed->fromMmscToInbox();
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Sent folder");
+	
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+		return;
+	}
+	
+	//check if inbox-folder signal was received....this means message was successfully received at the inbox folder.
+	if( spy_inbox->count() <= 0)
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Inbox folder");
+		
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+	}
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::createMMSWithTextAndImageAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::createMMSWithTextAndImageAttachment()
+{
+    //Create a Converged Message instance. 
+    QString subject  = TEST_MSG_SUBJECT;
+	qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
+	
+	QString sender(TEST_SENDER);
+	ConvergedMessageAddress address(sender);
+	ConvergedMessageAttachmentList attachmentList;    
+
+	//Add a text attachment to attachment list. 
+	QString attachmentPath1 = TEST_ATTACHMENT5;
+	ConvergedMessageAttachment* attachment = 
+		new ConvergedMessageAttachment(attachmentPath1, ConvergedMessageAttachment::EInline);
+	
+	//Add an image attachment to attachment list. 
+	QString attachmentPath2 = TEST_ATTACHMENT4;
+    ConvergedMessageAttachment* attachmentImage = 
+        new ConvergedMessageAttachment(attachmentPath2, ConvergedMessageAttachment::EAttachment);
+    
+    attachmentList.append(attachment);
+    attachmentList.append(attachmentImage);
+    
+    //Instantiate a Converged Message object and set service a MMS
+	ConvergedMessage msg;
+	msg.setMessageType(ConvergedMessage::Mms);
+	msg.setSubject(subject);
+	msg.setTimeStamp(timeStamp);
+	msg.addToRecipient(address);
+	
+	//Add attachments' list
+	msg.addAttachments(attachmentList);
+	msg.setPriority(ConvergedMessage::Normal);
+	
+	//Adding CC Address
+	QString ccAddress(TEST_CC);
+	ConvergedMessageAddress ccAdd(ccAddress);
+	msg.addCcRecipient(ccAdd);
+	
+	//Adding BCC Address
+	QString bccAddress(TEST_BCC);
+	ConvergedMessageAddress bccAdd(bccAddress);
+	msg.addBccRecipient(bccAdd);
+	
+	//Adding From Address
+	QString recipientAddress(TEST_SENDER);
+	ConvergedMessageAddress recipientAdd(recipientAddress);
+	msg.addFromRecipient(recipientAdd);
+	
+	//start send and prepare to test send-success or fail
+	mmstestbed->cleanAll();
+	mmstestbed->setConnectionLocal(true);
+	
+	//Get a valid MMS message ID and verify that it is valid.
+	mmsMsgId = msgPlugin->convertTo(&msg);
+	QVERIFY(mmsMsgId != -1);
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testMMSWithTextAndImageAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::testMMSWithTextAndImageAttachment()
+{
+	long int mmsDraftMsgId;
+	
+	//check if draft-folder signal was received...this means message was created in draft 
+	if( 1 <= spy_draft->count())
+	{
+		//compare the msgid and verify with the ID given by MMS plugin 
+		void * temp = const_cast<void*>(spy_draft->at(1).at(0).data());
+		mmsDraftMsgId = *reinterpret_cast< long int(*)>(temp);
+		QVERIFY(mmsDraftMsgId == mmsMsgId);
+		
+		//Validate the MMS message with all the values set before. 
+		ConvergedMessage* draftMsg = msgPlugin->convertFrom(mmsDraftMsgId);
+		QVERIFY(draftMsg->subject().compare(QString(TEST_MSG_SUBJECT)) == 0);
+		QVERIFY(draftMsg->messageType() == ConvergedMessage::Mms);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->toAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_CC).contains(draftMsg->ccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_BCC).contains(draftMsg->bccAddressList()[0]->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(QString(TEST_SENDER).contains(draftMsg->fromAddress()->address(), Qt::CaseInsensitive) == true);
+		QVERIFY(draftMsg->attachments().count() == 1);
+		QVERIFY(draftMsg->attachments()[0]->attachmentType() == ConvergedMessageAttachment::EAttachment);
+		QVERIFY(draftMsg->attachments()[0]->filePath().contains(QString(TEST_ATTACHMENT4).mid(QString(TEST_ATTACHMENT4).indexOf(QString("SmileyFace.gif"), 0, Qt::CaseInsensitive)), Qt::CaseInsensitive) == true);	
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to create message in Draft");
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+	}
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::sendMMSWithTextAndImageAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::sendMMSWithTextAndImageAttachment()
+{
+	//Send the MMS message and verify if it was sent successfully. 
+	bool sent = msgPlugin->send(mmsMsgId);
+	QVERIFY(sent == true);
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::testSentMMSWithTextAndImageAttachment
+//---------------------------------------------------------------
+void TestMmsPlugin::testSentMMSWithTextAndImageAttachment()
+{
+	QTest::qWait(10000);  //to ensure path completion
+	
+	//check if outbox-folder signal was received...this means message was moved to outbox for send    
+	if( 1 <= spy_outbox->count())
+	{
+		//compare the msgid
+		void * temp = const_cast<void*>(spy_outbox->at(1).at(0).data());
+		long int outboxId = *reinterpret_cast< long int(*)>(temp);
+		QCOMPARE(outboxId, mmsMsgId);
+		
+		//push the message from outbox to mmsc(sent folder)
+		mmstestbed->fromOutboxToMmsc();
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Outbox");
+		
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+		return;
+	}
+
+	//check if sent-folder signal was received....this means message was successfully sent scheduled.
+	if( 1 <= spy_sent->count())
+	{
+		//check for send-path
+		void * temp = const_cast<void*>(spy_sent->at(1).at(0).data());
+		long int sentmsgid = *reinterpret_cast< long int(*)>(temp);
+		QCOMPARE(sentmsgid, mmsMsgId);
+		
+		//issue a fetch request on the sent message, to test the receive path
+		mmstestbed->fromMmscToInbox();
+	}
+	else
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Sent folder");
+	
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+		return;
+	}
+	
+	//check if inbox-folder signal was received....this means message was successfully received at the inbox folder.
+	if( spy_inbox->count() <= 0)
+	{
+		QFAIL("testSendReceiveMMS: Failed to move message to Inbox folder");
+		
+		//reset connection to 'global on, local off'
+		mmstestbed->setConnectionLocal(false);
+	}
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::cleanup
+//---------------------------------------------------------------
+void TestMmsPlugin::cleanup()
+{
+}
+
+//---------------------------------------------------------------
+// TestMmsPlugin::cleanupTestCase
+//---------------------------------------------------------------
+void TestMmsPlugin::cleanupTestCase()
+{
+	//Cleanup
+	delete spy_draft;//Signal for Draft Folder
+	delete spy_outbox;//Signal for Outbox Folder
+	delete spy_sent;//Signal for Sent Folder
+	delete spy_inbox;//Signal for inbox Folder
+    delete msgPlugin;//MMS Plugin
+    delete mmstestbed;//MMS Testbed
+}
+
+//End of File
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- * 
- * Description:
- */
-
-#include "testmmsplugin.h"
-#include <QtTest/QtTest>
-#include "debugtraces.h"
-
-#include <QTimer>
-#include <QSignalSpy>
-
-#include "convergedmessage.h"
-#include "TestMsg.h"
-#include "convergedmessageid.h"
-#include "unieditormmsplugin.h"
-#include "messageserviceaction.h"
-//---------------------------------------------------------------
-// TestMmsPlugin::initTestCase
-//---------------------------------------------------------------
-void TestMmsPlugin::initTestCase()
-{
-    msgPlugin = new UniEditorMmsPlugin();
-    QVERIFY(msgPlugin != 0);
-    smsId = -1;
-    mmsId = -1;
-}
-
-//---------------------------------------------------------------
-// TestMmsPlugin::cleanupTestCase
-//---------------------------------------------------------------
-void TestMmsPlugin::cleanupTestCase()
-{
-    delete msgPlugin;
-}
-
-//---------------------------------------------------------------
-// TestMmsPlugin::init
-//---------------------------------------------------------------
-
-void TestMmsPlugin::init()
-{
-}
-
-//---------------------------------------------------------------
-// TestMmsPlugin::cleanup
-//---------------------------------------------------------------
-void TestMmsPlugin::cleanup()
-{
-}
-
-//---------------------------------------------------------------
-// TestMmsPlugin::testSendMMS
-//---------------------------------------------------------------
-
-void TestMmsPlugin::testSendMMS()
-{
-
-    //register user defined object to meta system.
-    qRegisterMetaType<ConvergedMessage*> ("ConvergedMessage*");
-    
-
-    createMMSMessageWithAttachmentAndSend();
-     //wait for the response to complete 
-     //as sending a message goes through different stages
-     
-    //Create a smil attachment with image and text
-    createMMSMessageWithSmilTextAndImageAttachmentAndSend();
-   
-    //Create MMS with Normal priority
-    createMMSMessageWithAttachmentAndSend(ETrue);
-}
-
-
-void TestMmsPlugin::createMMSMessageWithSmilTextAndImageAttachmentAndSend()
-    {
-    QString service = TEST_SERVICE_NAME_MMS;
-    QString bodyText = TEST_MSG_BODY;
-    QString subject  = TEST_MSG_SUBJECT;
-    qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
-    
-    QString sender(TEST_SENDER);
-    ConvergedMessageAddress address(sender);
-    ConvergedMessageAttachmentList attachmentList;
-  
-    ConvergedMessageAttachment* attachmentImage = 
-        new ConvergedMessageAttachment(TEST_ATTACHMENT4, ConvergedMessageAttachment::EAttachment);
-    attachmentList.append(attachmentImage);
-    
-    ConvergedMessageAttachment* attachmenttext = 
-            new ConvergedMessageAttachment(TEST_ATTACHMENT5, ConvergedMessageAttachment::EAttachment);
-    attachmentList.append(attachmenttext);
-    
-    ConvergedMessageAttachment* attachmentSmil = 
-                new ConvergedMessageAttachment(TEST_ATTACHMENT3, ConvergedMessageAttachment::ESmil);
-    attachmentList.append(attachmentSmil);
-     
-    
-    
-    ConvergedMessage msg;
-    msg.setMessageType(ConvergedMessage::Mms);
-    msg.setSubject(subject);
-    msg.setTimeStamp(timeStamp);
-    msg.addToRecipient(address);
-    msg.addAttachments(attachmentList);
-    msg.setPriority(ConvergedMessage::Low);
-    
-    long int id = msgPlugin->convertTo(&msg);
-    msgPlugin->send(id);
-
-    }
-
-
-//---------------------------------------------------------------
-// TestMmsPlugin::testMmsReceived
-//---------------------------------------------------------------
-void TestMmsPlugin::testMmsReceived()
-{
-    testReceived(msgPlugin->messageType());  
-    QTest::qWait(5000);
-}
-
-/*
- * Creates a Smil file with only a text document as attachment
- */
- 
-void TestMmsPlugin::createMMSMessageWithAttachmentAndSend(TBool priority)
-    {
-    QString service = TEST_SERVICE_NAME_MMS;
-    QString bodyText = TEST_MSG_BODY;
-    QString subject  = TEST_MSG_SUBJECT;
-    qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
-    
-    QString sender(TEST_SENDER);
-    ConvergedMessageAddress address(sender);
-    ConvergedMessageAttachmentList attachmentList;    
-
-   
-    ConvergedMessageAttachment* attachment2 = 
-            new ConvergedMessageAttachment(TEST_ATTACHMENT2, ConvergedMessageAttachment::ESmil);
-    
-    ConvergedMessageAttachment* attachment = 
-        new ConvergedMessageAttachment(TEST_ATTACHMENT, ConvergedMessageAttachment::EAttachment);
-   
-    attachmentList.append(attachment);
-    
-    attachmentList.append(attachment2);
-    
-    ConvergedMessage msg;
-    msg.setMessageType(ConvergedMessage::Mms);
-    msg.setSubject(subject);
-    msg.setTimeStamp(timeStamp);
-    msg.addToRecipient(address);
-    msg.addAttachments(attachmentList);
-    if(priority == EFalse)
-        {
-        msg.setPriority(ConvergedMessage::Normal);
-        }
-    else
-        {
-        msg.setPriority(ConvergedMessage::High);
-        }
-    
-    //Adding alias
-    ConvergedMessageAddress address1;
-    address1.setAlias(QString(TEST_MSG_RECIEPIENT));
-    msg.addToRecipient(address1);
-    
-    //Adding CC Address
-    QString ccAddress(TEST_CC);
-    ConvergedMessageAddress ccAdd(ccAddress);
-    msg.addCcRecipient(ccAdd);
-    
-    //Adding BCC Address
-    QString bccAddress(TEST_BCC);
-    ConvergedMessageAddress bccAdd(bccAddress);
-    msg.addBccRecipient(bccAdd);
-    
-    long int id = msgPlugin->convertTo(&msg);
-    msgPlugin->send(id);
-    }
-    	
-//---------------------------------------------------------------
-// TestMmsPlugin::testReceived
-//---------------------------------------------------------------
-void TestMmsPlugin::testReceived(int type)
-{
-MessageServiceAction* messageAction = new MessageServiceAction(this);    
-    QVERIFY(messageAction != 0);
-
-    //register user defined object to meta system.
-    qRegisterMetaType<ConvergedMessage*>("ConvergedMessage*");
-
-    //signal spy.
-    //listen to added event
-    QSignalSpy spyAdd( messageAction,
-            SIGNAL(messageAdded(ConvergedMessage*, QString)));
-    //signal spy.
-    //listen to updated event
-        QSignalSpy spyUpdate( messageAction,
-                SIGNAL(messageUpdated(ConvergedMessage*, QString)));
-    //will force stub_clientmanager to emit messageUpdated.
-    messageAction->registerForNotification();
-    //register user defined object to meta system.
-
-    // wait for the response to come
-    QTest::qWait(5000);
-
-    //check signals
-    int countAdd = -1;
-    countAdd = spyAdd.count();
-
-    ConvergedMessage* message = 0;
-    QString serviceId("");
-    
-    if (countAdd)
-    {
-        //verify added event
-        void * temp = const_cast<void*> (spyAdd.at(0).at(0).data());
-        message = *reinterpret_cast<ConvergedMessage*(*)> (temp);
-        serviceId = spyAdd.at(0).at(1).toString();
-        QVERIFY(message != 0);
-        validateMsg(*message, serviceId);
-    }
-
-    int countUpdate = -1;
-    countUpdate = spyUpdate.count();
-    message = 0;
-
-    for (int i = countUpdate; i > 0; --i)
-    {
-        //verify updated event
-        void * temp = const_cast<void*> (spyUpdate.at(i-1).at(0).data());
-        message = *reinterpret_cast<ConvergedMessage*(*)> (temp);
-        if (ConvergedMessage::Inbox == message->location())
-        {
-            serviceId = spyUpdate.at(i-1).at(1).toString();
-            break;
-        }
-    }
-    if (message)
-    {
-        validateMsg(*message, serviceId);
-    }
-    delete message;
-}
-
-//---------------------------------------------------------------
-// TestMmsPlugin::validateMsg
-//---------------------------------------------------------------
-void TestMmsPlugin::validateMsg(const ConvergedMessage& message,
-                                const QString& serviceId)
-{
-#ifdef _DEBUG_TRACES_
-		qDebug() << "....message received.....";
-#endif
-
-    //process incoming messages
-    if (message.location() == ConvergedMessage::Inbox)
-    {
-        int msgId;
-        if (message.id())
-        {
-            msgId = message.id()->getId();
-        }
-        ConvergedMessageAddressList array = message.toAddressList();
-        if (array.count() > 0)
-        {
-            if (array[0])
-                QCOMPARE(array[0]->address(),QString(TEST_MSG_FROM1));
-        }
-        ConvergedMessageAddress *fromAddr = message.fromAddress();
-        if (fromAddr)
-        {
-            QCOMPARE(fromAddr->address(),QString(TEST_MSG_FROM1));
-        }
-
-        QCOMPARE(serviceId,QString(TEST_SERVICE_ID));
-
-        if (message.messageType() == ConvergedMessage::Mms)
-        {
-            mmsId = msgId;
-            QCOMPARE(message.subject(), QString(TEST_MSG_SUBJECT));
-        }
-        else if (message.messageType() == ConvergedMessage::Sms)
-        {
-            smsId = msgId;
-            QCOMPARE(message.bodyText(), QString(TEST_MSG_BODY));
-        }
-    }
-    else if (message.location() == ConvergedMessage::Sent)
-    {
-        ConvergedMessageAddressList array = message.toAddressList();
-        if (array.count() > 0)
-        {
-            if (array[0])
-                QCOMPARE(array[0]->address(),QString(TEST_SENDER));
-        }
-
-   //     QCOMPARE(serviceId,QString(TEST_SERVICE_ID));
-
-        if (message.messageType() == ConvergedMessage::Mms)
-        {
-            QCOMPARE(message.subject(), QString(TEST_MSG_SUBJECT));
-        }
-        else if (message.messageType() == ConvergedMessage::Sms)
-        {
-            QCOMPARE(message.bodyText(), QString(TEST_MSG_BODY));
-        }
-    }
-}
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.h	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- * 
- * Description:
- */
-
-#ifndef TEST_MMS_PLUGIN_H
-#define TEST_MMS_PLUGIN_H
-
-#ifdef BUILD_TEST_DLL
-#define TEST_EXPORT Q_DECL_EXPORT
-#else
-#define TEST_EXPORT Q_DECL_IMPORT
-#endif
-
-#include <QObject>
-#include <e32const.h>
-
-class UniEditorMmsPlugin;
-class ConvergedMessage;
-
-class TEST_EXPORT TestMmsPlugin: public QObject
-    {
-    Q_OBJECT
-
-private slots:
-    //called by frame work.
-    void initTestCase();//called before the first testfunction is executed.
-    void cleanupTestCase();//called after the last testfunction was executed.
-    void init();//called before each testfunction is executed.
-    void cleanup();//called after every testfunction.
-
-    //test cases.
-    void testSendMMS(); //test sending mms
-    void testMmsReceived(); // test receiving mms    
-
-private:
-    void testReceived(int type);
-    void validateMsg(const ConvergedMessage& message, const QString& serviceId);
-    void createMMSMessageWithAttachmentAndSend(TBool priority = EFalse);
-    void createMMSMessageWithSmilTextAndImageAttachmentAndSend();
-private:
-    UniEditorMmsPlugin* msgPlugin;
-    int smsId;
-    int mmsId;
-    };
-#endif //TEST_MMS_PLUGIN_H
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.ini	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-//this file is used to provide predefined set of input data.
-
-//eg.
-const char TEST_SERVICE_SMS[]     = "SMS";
-const char TEST_SERVICE_ID[]      = "messaging.mserver";
-const char TEST_SERVICE_SMS_ID[]  = "messaging.mserver.sms";
-const char TEST_SERVICE_MMS_ID[]  = "messaging.mserver.mms";
-const char TEST_SERVICE_MMS[]     = "MMS";
-const char TEST_MSG_BODY[]        = "TestTextE_1_2";
-const char TEST_MSG_RECIEPIENT[]  = "Javaid Nabi<+919741596546>";
-const char TEST_MSG_FROM1[]       = "+44111111111";
-const char SERVICE_CENTER_01[]    = "+447802000332";
-const char SERVICE_CENTER_02[]    = "+919845087001";
-const char TEST_MSG_ALIAS1[]      = "Javaid Nabi";
-const char TEST_MSG_FROM2[]       = "9797979797";
-const char TEST_MSG_ALIAS2[]      = "Rajesh Batchu";
-const char TEST_MSG_SUBJECT[]     = "Message Subject";
-const char TEST_SERVICE_NAME_MMS[] 	= "messaging.mserver.testservice.MMS";
-const char TEST_SENDER[]			= "DummySender";
-const char TEST_ATTACHMENT[]		= "c:/sample.txt";
-const char TEST_ATTACHMENT2[]		= "c:/HelloWorld.smil";
-const char TEST_ATTACHMENT3[]		= "c:/ImageFile.smil";
-const char TEST_ATTACHMENT4[]		= "c:/SmileyFace.gif";
-const char TEST_ATTACHMENT5[]		= "c:/testfile.txt";
-const char TEST_MSG_TO3[]       = "SS<+44111111111>";
-const char TEST_CC[]			= "DummyCCAddress";
-const char TEST_BCC[]			= "DummyBCCAddress";
\ No newline at end of file
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.pro	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmmsplugin.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -20,24 +20,31 @@
 TEMPLATE = lib
 TARGET = test-mms-plugin
 
-
-INCLUDEPATH += .
-INCLUDEPATH += ../../../../../../inc
-INCLUDEPATH += ../../../../unieditorutils/inc
+INCLUDEPATH += ./inc
+INCLUDEPATH += ../../../../../../../inc
+INCLUDEPATH += ../../../../../unidatautils/unidatamodels/inc
+INCLUDEPATH += ../../../../../s60qconversions/inc
+INCLUDEPATH += ../../../../editorgenutils/inc
+INCLUDEPATH += ../../../../../../../inc
+INCLUDEPATH += ../../../../../../../mmsengine/mmsmessage/inc 
+INCLUDEPATH += ../../../../../../../mmsengine/inc
+INCLUDEPATH += ../../../../../unidatautils/unidatamodel/inc
+INCLUDEPATH += ../mmstestbed/inc
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
 DEFINES += BUILD_TEST_DLL
 
+CONFIG += hb plugin
+
 SOURCES += \
-  testmmsplugin.cpp \
+  ./src/testmmsplugin.cpp \
   ../../src/unieditormmsplugin.cpp \
   ../../src/unieditormmsplugin_p.cpp  
          
 
 # Input
 HEADERS += \
-  testmmsplugin.h \
-  testmsg.h \
+  ./inc/testmmsplugin.h \
   ../../inc/unieditormmsplugin.h \
   ../../inc/unieditormmsplugin_p.h 
                
@@ -50,18 +57,9 @@
     TARGET.EPOCALLOWDLLDATA = 1
 	}
     
-defBlock = \      
-	  "$${LITERAL_HASH}if defined(EABI)" \
-	  "DEFFILE  ../eabi/test_mms_plugin.def" \
-             "$${LITERAL_HASH}else" \
-             "DEFFILE  ../bwins/test_mms_plugin.def" \
-             "$${LITERAL_HASH}endif"
-	
-MMP_RULES += defBlock
-    
  LIBS += -leuser \
     -lconvergedmessageutils \
-    -lxqutils \
+    -ls60qconversions \
     -lMsgMedia \
     -leditorgenutils \
     -lcone \
@@ -92,6 +90,14 @@
   	-lcommdb \
   	-lcommsdat \
   	-letelmm \
-  	-lgenericclient \
-  	-lunidatamodelloader
-  	
+  	-lunidatamodelloader \
+  	-lunidatamodel \
+  	-lavkon \
+  	-leikcoctl \
+  	-leikctl \
+  	-lform \
+  	-luiklaf\ 
+  	-lmmstestbed \
+	-lmmsmessage \ 
+	-lmmsserversettings \
+	-lxqutils 
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/testmmsgplugin/testmsg.h	Wed Jun 23 18:09:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,600 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- * 
- * Description:
- */
-
-#ifndef TEST_MSG_H
-#define TEST_MSG_H
-//Headers 
-#include <e32svr.h>
-#include <SMUTHDR.H>
-#include <msvapi.h>
-#include <smut.h>
-#include <msvstd.h>
-#include <rsendas.h>
-#include <rsendasmessage.h>
-#include <SMSCLNT.H>
-#include <csmsaccount.h> 
-//#include <MTMStore.h>
-#include <mtclreg.h>
-#include <mtclbase.h>
-#include <txtrich.h> 				// CRichText
-#include <msvids.h>            // for Message type IDs
-#include <mmsclient.h>       // for CMmsClientMtm
-#include <CMsvMimeHeaders.h>        //Attachemt mimeheader
-#include <MMsvAttachmentManager.h>  //Attachment manager
-#include <MMsvAttachmentManagerSync.h>
-#include <f32file.h>                //parse
-#include <utf.h>
-
-#include <e32base.h>
-#include <e32property.h>
-#include <simtsy.h>
-#include <etelmm.h>
-#include <es_ini.h>
-#include <commsdattypesv1_1.h>
-#include <commsdat.h>
-
-#include <Qtdebug>
-#include <xqconversions.h>
-#include "testmmsplugin.ini"
-
-using namespace CommsDat;
-
-const TInt KMsvTestUidPhonePwrValue = 0x100052C5;
-enum TMsvTestPhoneStatus
-    {
-    EMsvTestPhoneOff = 0,
-    EMsvTestPhoneOn
-    };
-
-class TestMsg : public MMsvSessionObserver
-{
-public:
-
-    TestMsg();
-    ~TestMsg();
-
-    void createSCSettings();
-
-    void createSMS();
-    void createMMS();
-
-    void deleteMessage(int msgId);
-
-    void initSimTsyL();
-
-public: //MMsvSessionObserver
-
-    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2,
-                             TAny* aArg3);
-
-private:
-
-    void initL();
-    void createSMSL(TMsvId aFolderId, TBool aUnReadFlag);
-    void createMMSL(TMsvId aFolderId, TBool aUnReadFlag);
-    void initializeSimTsyL(TInt aTestNumber, HBufC* aTsyName);
-
-private:
-
-    CMsvSession* iSession;
-    CClientMtmRegistry* iMtmRegistry;
-    CSmsClientMtm *smsClientMtm;
-};
-
-//---------------------------------------------------------------
-// TestMsg::TestMsg
-//---------------------------------------------------------------
-TestMsg::TestMsg()
-{
-    int err;
-    TRAP(err,initL());
-    #ifdef _DEBUG_TRACES_
-qDebug() << "Error in initialization:" << err;
-#endif
-
-}
-
-//---------------------------------------------------------------
-// TestMsg::TestMsg
-//---------------------------------------------------------------
-TestMsg::~TestMsg()
-{
-    if(smsClientMtm)
-    {
-        delete smsClientMtm;
-        smsClientMtm = NULL;
-    }
-    
-    if (iMtmRegistry)
-    {
-        delete iMtmRegistry;
-        iMtmRegistry = NULL;
-    }
-
-    if (iSession)
-    {
-        delete iSession;
-        iSession = NULL;
-    }
-}
-
-//---------------------------------------------------------------
-// TestMsg::createSCSettings
-//---------------------------------------------------------------
-void TestMsg::createSCSettings()
-{
-    smsClientMtm = static_cast<CSmsClientMtm*> (iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
-
-    TMsvSelectionOrdering ordering;
-
-    CMsvEntry* root = CMsvEntry::NewL(smsClientMtm->Session(),
-                                      KMsvRootIndexEntryId,
-                                      ordering);
-
-    CSmsAccount* smsAccount = CSmsAccount::NewLC();
-
-    CSmsSettings* settings = CSmsSettings::NewL();
-    CleanupStack::PushL(settings);
-    smsAccount->LoadSettingsL(*settings);
-
-    TMsvEntry entry;
-    entry.iMtm = KUidMsgTypeSMS;
-    entry.iType = KUidMsvServiceEntry;
-    entry.SetReadOnly(EFalse);
-    entry.SetVisible(EFalse);
-    entry.iDate.UniversalTime();
-    entry.iDetails.Set(_L("Nokiatest"));
-
-    root->SetEntryL(KMsvRootIndexEntryId);
-    root->CreateL(entry);
-
-    QString serviceCenter01(SERVICE_CENTER_01);
-    QString serviceCenter02(SERVICE_CENTER_02);
-    HBufC* sC01 = XQConversions::qStringToS60Desc(serviceCenter01);
-    HBufC* sC02 = XQConversions::qStringToS60Desc(serviceCenter02);
-    CleanupStack::PushL(sC01);
-    CleanupStack::PushL(sC02);
-    settings->AddServiceCenterL(_L("Nokia"), *sC01);
-    settings->AddServiceCenterL(_L("Nokia"), *sC02);
-    CleanupStack::PopAndDestroy(sC02);
-    CleanupStack::PopAndDestroy(sC01);
-    settings->SetDefaultServiceCenter(1);
-    settings->SetValidityPeriod(ESmsVPWeek);
-    settings->SetReplyQuoted(ETrue);
-    settings->SetRejectDuplicate(ETrue);
-    settings->SetDelivery(ESmsDeliveryImmediately);
-    settings->SetDeliveryReport(EFalse);
-    settings->SetReplyPath(EFalse);
-    settings->SetMessageConversion(ESmsConvPIDNone);
-    settings->SetCanConcatenate(ETrue);
-    settings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
-    settings->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger);
-    settings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible);
-    settings->SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible);
-    settings->SetSmsBearer(CSmsSettings::ESmsBearerCircuitPreferred);
-    settings->SetCommDbAction(CSmsSettings::ENone);
-    settings->SetSmsBearerAction(CSmsSettings::ENone);
-    smsAccount->SaveSettingsL(*settings);
-
-    CleanupStack::PopAndDestroy(settings);
-    CleanupStack::PopAndDestroy(smsAccount);
-}
-
-//---------------------------------------------------------------
-// TestMsg::createSMS
-//---------------------------------------------------------------
-void TestMsg::createSMS()
-{
-    int err;
-    TRAP(err,createSMSL(KMsvGlobalInBoxIndexEntryId,ETrue));
-    #ifdef _DEBUG_TRACES_
-qDebug() << "Error in creating SMS:" << err;
-#endif
-
-}
-
-//---------------------------------------------------------------
-// TestMsg::createMMS
-//---------------------------------------------------------------
-void TestMsg::createMMS()
-{
-    int err;
-    TRAP(err,createMMSL(KMsvGlobalInBoxIndexEntryId,ETrue));
-    #ifdef _DEBUG_TRACES_
-qDebug() << "Error in creating MMS:" << err;
-#endif
-
-}
-
-//---------------------------------------------------------------
-// TestMsg::initL
-//---------------------------------------------------------------
-void TestMsg::initL()
-{
-    iSession = CMsvSession::OpenSyncL(*this);
-    iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
-}
-
-//---------------------------------------------------------------
-// TestMsg::createSMSL
-//---------------------------------------------------------------
-void TestMsg::createSMSL(TMsvId aFolderId, TBool aUnReadFlag)
-{
-    CSmsClientMtm *smsClientMtm =
-            static_cast<CSmsClientMtm*> (iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
-    CleanupStack::PushL(smsClientMtm);
-    //Create entry from this index entry
-
-    smsClientMtm->SwitchCurrentEntryL(aFolderId);
-    smsClientMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
-    TMsvEntry indexEntry = smsClientMtm->Entry().Entry();
-    indexEntry.SetInPreparation(ETrue);
-    indexEntry.iMtm = KUidMsgTypeSMS;
-    indexEntry.iType = KUidMsvMessageEntry;
-    indexEntry.iServiceId = smsClientMtm->ServiceId();
-    indexEntry.iDate.HomeTime();
-    //AddBody
-    QString body(TEST_MSG_BODY);
-
-    HBufC* bodyText = XQConversions::qStringToS60Desc(body);
-    if (bodyText)
-    {
-        CleanupStack::PushL(bodyText);
-        CRichText & body = smsClientMtm->Body();
-        body.Reset();
-        body.InsertL(0, *bodyText);
-
-        TBuf<32> buf;
-        buf.Copy(bodyText->Left(32));
-        indexEntry.iDescription.Set(buf);
-
-        CleanupStack::PopAndDestroy(bodyText);
-    }
-
-    // Add addressee
-    //Add Address
-    QString recipient(TEST_MSG_FROM1);
-    // convert from QString to HBufC 
-    HBufC* addr = XQConversions::qStringToS60Desc(recipient);
-    if (addr)
-    {
-        CleanupStack::PushL(addr);
-        TBuf<32> name;
-        name.Copy(addr->Left(32));
-        indexEntry.iDetails.Set(name);
-
-        if (aFolderId == KMsvDraftEntryId || aFolderId
-                == KMsvGlobalOutBoxIndexEntryId)
-        {
-            smsClientMtm->AddAddresseeL(*addr, TPtrC());
-            indexEntry.SetSendingState(KMsvSendStateWaiting);
-        }
-        else if (aFolderId == KMsvSentEntryId || aFolderId
-                == KMsvGlobalInBoxIndexEntryId)
-        {
-            CSmsHeader& smsHeader = smsClientMtm->SmsHeader();
-            smsHeader.SetFromAddressL(*addr);
-        }
-        CleanupStack::PopAndDestroy(addr);
-    }
-
-    // final fine tuning
-    indexEntry.SetAttachment(EFalse);
-    indexEntry.SetVisible(ETrue);
-    indexEntry.SetInPreparation(EFalse);
-
-    if (aFolderId == KMsvGlobalInBoxIndexEntryId)
-    {
-        if (aUnReadFlag)
-        {
-            indexEntry.SetUnread(ETrue);
-        }
-        indexEntry.SetNew(ETrue);
-    }
-    indexEntry.SetComplete(ETrue);
-    smsClientMtm->Entry().ChangeL(indexEntry);
-    smsClientMtm->SaveMessageL();
-
-    CleanupStack::PopAndDestroy(smsClientMtm);
-}
-
-//---------------------------------------------------------------
-// TestMsg::createMMSL
-//---------------------------------------------------------------
-void TestMsg::createMMSL(TMsvId aFolderId, TBool aUnReadFlag)
-{
-    CMmsClientMtm
-            *mmsClientMtm =
-                    static_cast<CMmsClientMtm*>
-    (iMtmRegistry->NewMtmL(KUidMsgTypeMultimedia));
-    CleanupStack::PushL(mmsClientMtm);
-    //Create entry from this index entry
-
-    mmsClientMtm->SwitchCurrentEntryL(aFolderId);
-    mmsClientMtm->CreateMessageL(mmsClientMtm->DefaultServiceL());
-
-    TMsvEntry indexEntry = mmsClientMtm->Entry().Entry();
-    indexEntry.SetInPreparation(ETrue);
-    indexEntry.iMtm = KUidMsgTypeMultimedia;
-    indexEntry.iType = KUidMsvMessageEntry;
-    indexEntry.iServiceId = mmsClientMtm->DefaultServiceL();
-    indexEntry.iDate.HomeTime();
-
-    //Subject
-    QString subject(TEST_MSG_SUBJECT);
-
-    HBufC* sub = XQConversions::qStringToS60Desc(subject);
-    if (sub)
-    {
-        CleanupStack::PushL(sub);
-
-        TBuf<32> buf;
-        buf.Copy(sub->Left(32));
-        indexEntry.iDescription.Set(buf);
-
-        mmsClientMtm->SetSubjectL(*sub);
-        CleanupStack::PopAndDestroy(sub);
-    }
-
-    // Add addressee
-    //Add Address
-    QString recipient(TEST_MSG_FROM1);
-    // convert from QString to HBufC 
-    HBufC* addr = XQConversions::qStringToS60Desc(recipient);
-    if (addr)
-    {
-        CleanupStack::PushL(addr);
-        TBuf<32> name;
-        name.Copy(addr->Left(32));
-        indexEntry.iDetails.Set(name);
-
-        if (aFolderId == KMsvDraftEntryId || aFolderId
-                == KMsvGlobalOutBoxIndexEntryId)
-        {
-            mmsClientMtm->AddAddresseeL(*addr);
-            indexEntry.SetSendingState(KMsvSendStateWaiting);
-        }
-        else if (aFolderId == KMsvSentEntryId || aFolderId
-                == KMsvGlobalInBoxIndexEntryId)
-        {
-            mmsClientMtm->SetSenderL(*addr);
-            mmsClientMtm->AddAddresseeL(*addr);
-        }
-        CleanupStack::PopAndDestroy(addr);
-    }
-
-    // final fine tuning
-    indexEntry.SetVisible(ETrue);
-    indexEntry.SetInPreparation(EFalse);
-
-    if (aFolderId == KMsvGlobalInBoxIndexEntryId)
-    {
-        if (aUnReadFlag)
-        {
-            indexEntry.SetUnread(ETrue);
-        }
-        indexEntry.SetNew(ETrue);
-    }
-
-    //body text
-    QString bodyText(TEST_MSG_BODY);
-    HBufC* text = XQConversions::qStringToS60Desc(bodyText);
-    if (text)
-    {
-        CleanupStack::PushL(text);
-
-        //we may need some conversion of text here
-        const TInt KMmsMaxBytesPerCharacter = 4;
-        HBufC8* buffer = HBufC8::NewL( text->Length() * KMmsMaxBytesPerCharacter );
-        CleanupStack::PushL( buffer );
-        TPtr8 buf8 = buffer->Des();
-
-        // get an access to the message store
-        CMsvStore* store = mmsClientMtm->Entry().EditStoreL();
-        CleanupStack::PushL(store);
-
-        CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
-        CleanupStack::PushL( mimeHeaders );
-
-        CMsvAttachment* attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
-        CleanupStack::PushL( attaInfo );
-
-        TPtrC8 contentType;
-        contentType.Set( KMmsTextPlain );
-
-        TInt position = contentType.Find( KMmsSlash8 );
-        mimeHeaders->SetContentTypeL( contentType.Left( position ) );
-        mimeHeaders->SetContentSubTypeL( contentType.Mid( position + 1 ) );
-        attaInfo->SetMimeTypeL( contentType );
-        attaInfo->SetAttachmentNameL( _L("body.txt") );
-
-        mimeHeaders->SetMimeCharset( KMmsUtf8 );
-        mimeHeaders->SetSuggestedFilenameL( _L("body.txt") );
-
-        // if conversion fails, something is really seriously wrong
-        TInt error = CnvUtfConverter::ConvertFromUnicodeToUtf8( buf8, *text );
-
-        attaInfo->SetSize( buf8.Length() );
-        mimeHeaders->StoreL( *attaInfo ); // Mime headers are streamed into atta info
-
-        MMsvAttachmentManagerSync& attaManSync = store->AttachmentManagerExtensionsL();
-        RFile textFile;
-
-        attaManSync.CreateAttachmentL( _L("body.txt"), textFile, attaInfo );
-        CleanupStack::Pop( attaInfo ); //ownership was transferred.
-
-        CleanupClosePushL( textFile );
-
-        //get attachement id, we need it incase of failure
-        TMsvAttachmentId attachmentId = attaInfo->Id();
-        // Now our file handle is open for writing
-        if ( buf8.Length()> 0 )
-        {
-            textFile.Write( buf8 );
-            error = textFile.Flush();
-        }
-        // we must always close
-        CleanupStack::PopAndDestroy( &textFile ); // close textFile
-        CleanupStack::PopAndDestroy( mimeHeaders );
-
-        store->CommitL();
-        CleanupStack::PopAndDestroy(store);
-        CleanupStack::PopAndDestroy( buffer );
-        CleanupStack::PopAndDestroy(text);
-    }
-
-    indexEntry.SetComplete(ETrue);
-    mmsClientMtm->Entry().ChangeL(indexEntry);
-    mmsClientMtm->SaveMessageL();
-
-    // cleanup    
-    CleanupStack::PopAndDestroy(mmsClientMtm);
-}
-
-void TestMsg::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/,
-                                  TAny* /*aArg2*/, TAny* /*aArg3*/)
-{
-}
-
-void TestMsg::deleteMessage(int msgId)
-{
-    CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
-    CleanupStack::PushL(cEntry);
-
-    CMsvEntry* entry = iSession->GetEntryL(msgId);
-    CleanupStack::PushL(entry);
-
-    TMsvEntry tEntry = entry->Entry();
-    tEntry.SetReadOnly(EFalse);
-    entry->ChangeL(tEntry);
-
-    cEntry->DeleteL(msgId);
-    CleanupStack::PopAndDestroy(entry);
-    CleanupStack::PopAndDestroy(cEntry);
-
-}
-
-void TestMsg::initSimTsyL()
-{
-    _LIT(KDefaultTsyName, "SIM");
-    TPtrC defaultTsyName(KDefaultTsyName);
-    HBufC* defaultTsyNameBuf = defaultTsyName.AllocLC();
-    TInt testNumber = 0;
-
-    initializeSimTsyL(testNumber, defaultTsyNameBuf);
-
-    CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion());
-    CleanupStack::PushL(dbSession);
-
-    CMDBRecordLink<CCDModemBearerRecord>
-            *modemBearerRecordSet = new (ELeave) CMDBRecordLink<
-                    CCDModemBearerRecord> (KCDTIdGlobalSettingsRecord
-                    | KCDTIdModemPhoneServicesSMS);
-    CleanupStack::PushL(modemBearerRecordSet);
-
-    modemBearerRecordSet->SetRecordId(1);
-    //Load field container with data from database
-    TRAPD(err, modemBearerRecordSet->LoadL(*dbSession));
-    CCDModemBearerRecord
-            *modemRecord =
-                    static_cast<CCDModemBearerRecord*>
-    (CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
-    CleanupStack::PushL(modemRecord);
-
-    /*!
-     * Set the record ID to that previously read from
-     * CCDGlobalSettingsRecord.iModemForPhoneServicesAndSMS
-     */
-    modemRecord->SetRecordId(*modemBearerRecordSet);
-
-    //Load record container with data from database
-    modemRecord->LoadL(*dbSession);
-
-    modemRecord->iTsyName.SetMaxLengthL(defaultTsyNameBuf->Des().Length());
-    modemRecord->iTsyName = defaultTsyNameBuf->Des();
-    modemRecord->ModifyL(*dbSession);
-
-    CleanupStack::PopAndDestroy(4);
-}
-
-void TestMsg::initializeSimTsyL(TInt aTestNumber, HBufC* aTsyName)
-{
-    //Initialize TSY using the System Agent
-    TInt testState;
-    if (KErrNone != RProperty::Get(KUidPSSimTsyCategory,
-                                   KPSSimTsyTestNumber,
-                                   testState))
-    {
-        User::LeaveIfError(RProperty::Define(KUidPSSimTsyCategory,
-                                             KPSSimTsyTestNumber,
-                                             RProperty::EInt));
-    }
-
-    User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory,
-                                      KPSSimTsyTestNumber,
-                                      aTestNumber));
-    if (KErrNone != RProperty::Get(KUidSystemCategory,
-                                   KMsvTestUidPhonePwrValue,
-                                   testState))
-    {
-        User::LeaveIfError(RProperty::Define(KUidSystemCategory,
-                                             KMsvTestUidPhonePwrValue,
-                                             RProperty::EInt));
-    }
-    User::LeaveIfError(RProperty::Set(KUidSystemCategory,
-                                      KMsvTestUidPhonePwrValue,
-                                      EMsvTestPhoneOn));
-
-    User::LeaveIfError(RProperty::Get(KUidPSSimTsyCategory,
-                                      KPSSimTsyTestNumber,
-                                      aTestNumber));
-
-    RTelServer etelServer;
-    TInt err = etelServer.Connect();
-
-    if (err != KErrNone)
-    {
-        return;
-    }
-    User::LeaveIfError(etelServer.LoadPhoneModule(aTsyName->Des()));
-
-    /*!
-     * Find the phone corresponding to this TSY and open a number of
-     * handles on it
-     */
-    TInt numPhones;
-    User::LeaveIfError(etelServer.EnumeratePhones(numPhones));
-    TBool found = EFalse;
-
-    RMobilePhone iPhone;
-    while (!found && numPhones--)
-    {
-        TName phoneTsy;
-        User::LeaveIfError(etelServer.GetTsyName(numPhones, phoneTsy));
-        if (phoneTsy.CompareF(aTsyName->Des()) == KErrNone)
-        {
-            found = ETrue;
-            RTelServer::TPhoneInfo info;
-            User::LeaveIfError(etelServer.GetPhoneInfo(numPhones, info));
-            CleanupClosePushL(iPhone);
-            User::LeaveIfError(iPhone.Open(etelServer, info.iName));
-            User::LeaveIfError(iPhone.Initialise());
-            CleanupStack::PopAndDestroy(&iPhone);
-        }
-    }
-}
-
-#endif //TEST_MSG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/tsrc/tsrc.pro	Tue Jul 06 14:12:40 2010 +0300
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS += mmstestbed/mmstestbed.pro 
+SUBDIRS += testmmsgplugin/testmmsplugin.pro
+
+CONFIG += ordered
\ No newline at end of file
--- a/messagingapp/shareui/inc/shareuiprivate.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/shareui/inc/shareuiprivate.h	Tue Jul 06 14:12:40 2010 +0300
@@ -125,6 +125,11 @@
      */
     void itemActivated(QModelIndex index);
     
+    /**
+     * Reset internal data structures
+     */
+    void reset();
+    
 private:
     /**
      * Fetch the action associated with a specified interface descriptor.
@@ -185,12 +190,7 @@
      * Show notes
      */
     void showNote(QString text);
-    
-    /**
-     * Reset internal data structures
-     */
-    void reset();
-    
+
 private:
     /**
      * List of files to be sent.
--- a/messagingapp/shareui/src/shareuiprivate.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingapp/shareui/src/shareuiprivate.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -69,7 +69,6 @@
  */
 ShareUiPrivate::~ShareUiPrivate()
     {
-    reset();
     }
 
 /**
@@ -80,6 +79,10 @@
     mFileList.clear();
 
     mIndexActionMap.clear();
+    foreach(XQAiwRequest* request,mAiwRequestList)
+    {
+        delete request;
+    }
     mAiwRequestList.clear();
 
     }
@@ -125,6 +128,7 @@
     if ( fileList.count() != filteredFileList.count() )
         {
         showNote(LOC_PROTECTED_CONTENT);      
+        return true;
         }
     
     // Only protected content
@@ -205,9 +209,10 @@
     mSharePopup->setAttribute( Qt::WA_DeleteOnClose, true );
     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
     heading->setAlignment(Qt::AlignCenter);
-    mSharePopup->setDismissPolicy(HbDialog::NoDismiss);
+    mSharePopup->setDismissPolicy(HbDialog::TapAnywhere);
     mSharePopup->setHeadingWidget(heading);
     mSharePopup->setFrameType(HbDialog::Strong);
+    connect(mSharePopup, SIGNAL(aboutToClose()), this, SLOT(reset()));
         
     // Content widget
     mContentListView = new HbListView(mSharePopup);
@@ -268,6 +273,7 @@
  */
 void ShareUiPrivate::onTriggered(void)
     {
+    
     XQAiwRequest* request = 0;
     request = qobject_cast<XQAiwRequest*>(sender());
     if(request)
@@ -284,9 +290,19 @@
  * Slot for handling valid returns from the framework.
  */
 void ShareUiPrivate::handleOk(const QVariant& result)
-    {
+{
     Q_UNUSED(result)
+         
+    XQAiwRequest* request = 0;
+    request = qobject_cast<XQAiwRequest*>(sender());
+    if(request)
+    {
+       disconnect(request, 
+               SIGNAL(requestError(int,const QString&)), 
+               this, 
+               SLOT(handleError(int,const QString&)));
     }
+}
 
 /**
  * Slot for handling errors from the framework.
@@ -315,7 +331,8 @@
         {
         action->setEnabled(true);
         action->activate(HbAction::Trigger);
-        }    
+        } 
+    
     mSharePopup->close();
     }
 
--- a/messagingappbase/msgmedia/src/MsgMediaResolver.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingappbase/msgmedia/src/MsgMediaResolver.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -43,7 +43,7 @@
 #include <MessagingVariant.hrh>
 
 // Resources
-#include <MsgMimeToMediaMapping.rsg>
+#include <msgmimetomediamapping.rsg>
 
 #include "MsgMedia.hrh"
 #include "MsgMediaResolver.h"
--- a/messagingappbase/msgmedia/src/MsgVideoInfo.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/messagingappbase/msgmedia/src/MsgVideoInfo.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -122,11 +122,6 @@
 // -----------------------------------------------------------------------------
 void CMsgVideoInfo::ResolveVideoInfoL( RFile& aFile )
     {
-    CCoeEnv* env = CCoeEnv::Static();
-    if ( !env )
-        {
-        User::Leave( KErrNotSupported );
-        }
 
     CHXMetaDataUtility* dataUtil = CHXMetaDataUtility::NewL();
     
Binary file mmsengine/conf/mmsengine.confml has changed
--- a/mmsengine/mmscodec/src/mmsencode.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/mmsengine/mmscodec/src/mmsencode.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -22,6 +22,7 @@
 
 // INCLUDE FILES
 #include    <e32std.h>
+#include    <e32hal.h>
 #include    <apparc.h>
 #include    <s32mem.h>
 #include    <msventry.h>
--- a/mmsengine/mmsserversettings/src/mmssettings.cpp	Wed Jun 23 18:09:17 2010 +0300
+++ b/mmsengine/mmsserversettings/src/mmssettings.cpp	Tue Jul 06 14:12:40 2010 +0300
@@ -138,7 +138,7 @@
     iApplicationFolderId =    KMsvNullIndexEntryId;
     iAccesspointArray.Reset();
     iReceivingModeHome =      EMmsReceivingAutomatic;
-    iReceivingModeForeign =   EMmsReceivingManual;
+    iReceivingModeForeign =   EMmsReceivingAutomatic;
     iAcceptPersonal =         ETrue;
     iAcceptAdvertisement =    ETrue;
     iAcceptInformational =    ETrue;
--- a/msg_plat/conversation_services_client_api/inc/ccsrequesthandler.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/msg_plat/conversation_services_client_api/inc/ccsrequesthandler.h	Tue Jul 06 14:12:40 2010 +0300
@@ -309,6 +309,8 @@
      */
     IMPORT_C CCsClientConversation* GetConversationFromMessageIdL ( TInt aMessageId );
     
+    IMPORT_C CCsClientConversation* GetConversationFromConversationIdL( TInt aConversationId );
+
 protected: // Functions from base classes
 
     /**
@@ -388,6 +390,12 @@
      * Handles delete conversation list event.
      */
     void HandleDeleteConversationList (HBufC8* aResultsBuffer); 
+    
+	/**
+	 * HandlePartialDeleteConversationList
+	 * Handles partial delete of conversation event.
+	 */
+    void HandlePartialDeleteConversationList(HBufC8* aResultsBuffer);
 
     /**
      * HandleModifyConversationList.
--- a/msg_plat/conversation_services_client_api/inc/mcsconversationlistchangeobserver.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/msg_plat/conversation_services_client_api/inc/mcsconversationlistchangeobserver.h	Tue Jul 06 14:12:40 2010 +0300
@@ -59,6 +59,13 @@
     virtual void DeleteConversationList(
             const CCsClientConversation& aClientConversation) = 0;
 
+	/**
+	 * PartialDeleteConversationList
+	 * This is for handling of partial delete of conversation event
+	 * generated from the server
+	 */
+    virtual void PartialDeleteConversationList(
+            const CCsClientConversation& aClientConversation) = 0;
     /**  
      * ModifyConversationList
      * This is for handling modify conversation asynchronusly
--- a/msg_plat/conversation_services_client_api/inc/rcssession.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/msg_plat/conversation_services_client_api/inc/rcssession.h	Tue Jul 06 14:12:40 2010 +0300
@@ -248,6 +248,8 @@
      */
     void GetConversationFromMessageIdL(TInt aMessageId, TPtr8 aResultsBuffer);
     
+    void GetConversationFromConversationIdL(TInt aConversationId, TPtr8 aResultsBuffer);
+
     /**
      * MarkConversationReadL.
      * This function sends the request to conversation server
--- a/msg_plat/conversation_services_utilities_api/inc/ccsdefs.h	Wed Jun 23 18:09:17 2010 +0300
+++ b/msg_plat/conversation_services_utilities_api/inc/ccsdefs.h	Tue Jul 06 14:12:40 2010 +0300
@@ -81,6 +81,7 @@
 const TUint32 KConversationCachingEventError     = 0x00000100;
 const TUint32 KConversationEventListRefresh      = 0x00000200;
 const TUint32 KConversationEventRefresh          = 0x00000400;
+const TUint32 KConversationListEventPartialDelete = 0x00000800;
 
 //-----------------------------------------------------------------------------
 // Conversation Server caching status codes
@@ -120,7 +121,9 @@
      EGetConversationId,
      EGetConversationIdFromAddress,
      EGetConversationFromMessageId,
-     EUserMarkReadConversation
+     EUserMarkReadConversation,
+     EGetConversationFromConversationId,
+     EGetConversationFromConversationIdComplete
 };
 
 //-----------------------------------------------------------------------------
@@ -137,6 +140,7 @@
     EModifyConversationListEvent,
     EAddConversationEvent,
     EDeleteConversationEvent,
+    EPartialDeleteConversationListEvent,
     EModifyConversationEvent,
     ECachingStartedEvent,
     ECachingCompletedEvent,
@@ -316,6 +320,63 @@
     EPreviewMsgProcessed          = 2
 };
 
+/** 
+@publishedAll
+@released
+
+Template class CleanupResetAndDestroy to clean up the array
+of implementation information from the cleanup stack.
+*/
+
+template <class T>
+class CleanupResetAndDestroy
+	{
+public:
+	/**
+	Puts an item on the cleanup stack.
+
+	@param  aRef 
+	        The implementation information to be put on the cleanup stack.
+	*/
+	inline static void PushL(T& aRef);
+	inline static void PushL(T* aPointer);
+private:
+	static void ResetAndDestroy(TAny *aPtr);
+	static void ResetAndDestroyDelete(TAny *aPtr);
+	};
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef);
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T* aPointer);
+
+template <class T>
+inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
+	{CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));}
+
+template <class T>
+inline void CleanupResetAndDestroy<T>::PushL(T* aPointer)
+    {CleanupStack::PushL(TCleanupItem(&ResetAndDestroyDelete,aPointer));}
+
+template <class T>
+void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
+	{(STATIC_CAST(T*,aPtr))->ResetAndDestroy();}
+
+template <class T>
+void CleanupResetAndDestroy<T>::ResetAndDestroyDelete(TAny *aPtr)
+    {
+    (STATIC_CAST(T*,aPtr))->ResetAndDestroy();
+    delete (STATIC_CAST(T*,aPtr));
+    }
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef)
+	{CleanupResetAndDestroy<T>::PushL(aRef);}
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T* aPointer)
+    {CleanupResetAndDestroy<T>::PushL(aPointer);}
+	
 #endif // __C_CSSERVER_DEFS_H__
 
 // End of file
--- a/msg_plat/messaging_media_resolver_api/inc/MsgMediaInfo.inl	Wed Jun 23 18:09:17 2010 +0300
+++ b/msg_plat/messaging_media_resolver_api/inc/MsgMediaInfo.inl	Tue Jul 06 14:12:40 2010 +0300
@@ -23,9 +23,16 @@
 //
 inline TPtrC CMsgMediaInfo::FullFilePath() const
     {
-    return iFullFilePath
-        ? iFullFilePath->Des()
-        : KNullDesC();
+    
+    if(iFullFilePath)
+        {
+        return iFullFilePath->Des();
+        }
+    else
+        {
+        return KNullDesC();
+        }
+    
     }
 
 // -----------------------------------------------------------------------------