# HG changeset patch # User hgs # Date 1277835167 -19800 # Node ID 4e4b6adb1024e6459967c7f91b990a7887496b4a # Parent 518b245aa84c36b5129a423f35d1ae0b339e9125 201025_01 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgappfw/msghistory/tsrc/tsrc.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgappfw/msghistory/tsrc/tsrc.pro Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h --- a/messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgservices/msgserviceapp/inc/msgserviceviewmanager.h Tue Jun 29 23:42:47 2010 +0530 @@ -103,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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h --- a/messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgservices/msgserviceapp/inc/msgstorehandler.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp --- a/messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -344,7 +344,7 @@ case ConvergedMessage::Mms: case ConvergedMessage::MmsNotification: { - handleSmsMmsMsg(msgId); + handleSmsMmsMsg(msgId,msgType); break; } case ConvergedMessage::BioMsg: @@ -377,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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp --- a/messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgservices/msgserviceapp/src/msgstorehandler.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/appengine/src/conversationsmodel.cpp --- a/messagingapp/msgui/appengine/src/conversationsmodel.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/appengine/src/conversationsmodel.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -515,8 +515,8 @@ //populate from data plugins if (!isEntryInDb || err != KErrNone) { - int id = iMmsDataPlugin->setMessageId(entry.EntryId()); - if(id <= 0) + int error = iMmsDataPlugin->setMessageId(entry.EntryId()); + if(error != KErrNone) { // skip all return; diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/bwins/unifiededitoru.def --- a/messagingapp/msgui/bwins/unifiededitoru.def Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/bwins/unifiededitoru.def Tue Jun 29 23:42:47 2010 +0530 @@ -57,7 +57,8 @@ ?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) - ?deleteMessage@MsgUnifiedEditorView@@AAEXXZ @ 59 NONAME ; void MsgUnifiedEditorView::deleteMessage(void) - ?addAttachments@MsgUnifiedEditorView@@AAEXVQStringList@@@Z @ 60 NONAME ; void MsgUnifiedEditorView::addAttachments(class QStringList) - ?deactivateInputBlocker@MsgUnifiedEditorView@@AAEXXZ @ 61 NONAME ; void MsgUnifiedEditorView::deactivateInputBlocker(void) + ?formatAddresses@MsgUnifiedEditorView@@AAEXAAV?$QList@PAVConvergedMessageAddress@@@@@Z @ 59 NONAME ; void MsgUnifiedEditorView::formatAddresses(class QList &) + ?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) diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/conversationview/inc/msgconversationview.h --- a/messagingapp/msgui/conversationview/inc/msgconversationview.h Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/conversationview/inc/msgconversationview.h Tue Jun 29 23:42:47 2010 +0530 @@ -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: @@ -422,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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp --- a/messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -227,7 +227,7 @@ //--------------------------------------------------------------- void MsgConversationBaseView::handleViewReady() { - ConversationsEngine::instance()->fetchMoreConversations(); + mConversationView->onViewReady(); } //--------------------------------------------------------------- diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/conversationview/src/msgconversationview.cpp --- a/messagingapp/msgui/conversationview/src/msgconversationview.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/conversationview/src/msgconversationview.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -102,10 +102,11 @@ 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 @@ -216,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 //--------------------------------------------------------------- @@ -820,7 +833,7 @@ 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 ) { @@ -828,6 +841,7 @@ } args << QVariant(messageId); + request->setSynchronous(true); request->setArguments(args); request->send(); @@ -1121,10 +1135,12 @@ //--------------------------------------------------------------- void MsgConversationView::populateConversationsView() { + mModelPopulated = true; mConversationList->setModel(mMessageModel); refreshView(); scrollToBottom(); + fetchMoreConversations(); } //--------------------------------------------------------------- @@ -1379,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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/eabi/unifiededitoru.def --- a/messagingapp/msgui/eabi/unifiededitoru.def Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/eabi/unifiededitoru.def Tue Jun 29 23:42:47 2010 +0530 @@ -24,45 +24,46 @@ _ZN20MsgUnifiedEditorView14changePriorityEv @ 23 NONAME _ZN20MsgUnifiedEditorView14forwardMessageER18ConvergedMessageIdN16ConvergedMessage11MessageTypeE @ 24 NONAME _ZN20MsgUnifiedEditorView15contactsFetchedERK8QVariant @ 25 NONAME - _ZN20MsgUnifiedEditorView15populateContentERK5QListI8QVariantE @ 26 NONAME - _ZN20MsgUnifiedEditorView16createTempFolderEv @ 27 NONAME - _ZN20MsgUnifiedEditorView16enableSendButtonEb @ 28 NONAME - _ZN20MsgUnifiedEditorView16generateFileNameER7QString @ 29 NONAME - _ZN20MsgUnifiedEditorView16onContentChangedEv @ 30 NONAME - _ZN20MsgUnifiedEditorView16removeTempFolderEv @ 31 NONAME - _ZN20MsgUnifiedEditorView16staticMetaObjectE @ 32 NONAME DATA 16 - _ZN20MsgUnifiedEditorView17onDialogDeleteMsgEP8HbAction @ 33 NONAME - _ZN20MsgUnifiedEditorView17openDraftsMessageERK5QListI8QVariantE @ 34 NONAME - _ZN20MsgUnifiedEditorView19getStaticMetaObjectEv @ 35 NONAME - _ZN20MsgUnifiedEditorView19onDialogMmsSettingsEP8HbAction @ 36 NONAME - _ZN20MsgUnifiedEditorView19onDialogSmsSettingsEP8HbAction @ 37 NONAME - _ZN20MsgUnifiedEditorView19saveContentToDraftsEv @ 38 NONAME - _ZN20MsgUnifiedEditorView19serviceRequestErrorEiRK7QString @ 39 NONAME - _ZN20MsgUnifiedEditorView20activateInputBlockerEv @ 40 NONAME - _ZN20MsgUnifiedEditorView21doDelayedConstructionEv @ 41 NONAME - _ZN20MsgUnifiedEditorView22deactivateInputBlockerEv @ 42 NONAME - _ZN20MsgUnifiedEditorView22setAttachOptionEnabledENS_16TBE_AttachOptionEb @ 43 NONAME - _ZN20MsgUnifiedEditorView23handleViewExtnActivatedEP16HbListWidgetItem @ 44 NONAME - _ZN20MsgUnifiedEditorView25populateContentIntoEditorERK16ConvergedMessageb @ 45 NONAME - _ZN20MsgUnifiedEditorView25removeAttachmentContainerEv @ 46 NONAME - _ZN20MsgUnifiedEditorView25updateOtherRecipientCountEb @ 47 NONAME - _ZN20MsgUnifiedEditorView4sendEv @ 48 NONAME - _ZN20MsgUnifiedEditorView7addMenuEv @ 49 NONAME - _ZN20MsgUnifiedEditorView8addCcBccEv @ 50 NONAME - _ZN20MsgUnifiedEditorView8initViewEv @ 51 NONAME - _ZN20MsgUnifiedEditorView8setFocusEP26MsgUnifiedEditorBaseWidget @ 52 NONAME - _ZN20MsgUnifiedEditorView9vkbClosedEv @ 53 NONAME - _ZN20MsgUnifiedEditorView9vkbOpenedEv @ 54 NONAME - _ZN20MsgUnifiedEditorViewC1EP13QGraphicsItem @ 55 NONAME - _ZN20MsgUnifiedEditorViewC2EP13QGraphicsItem @ 56 NONAME - _ZN20MsgUnifiedEditorViewD0Ev @ 57 NONAME - _ZN20MsgUnifiedEditorViewD1Ev @ 58 NONAME - _ZN20MsgUnifiedEditorViewD2Ev @ 59 NONAME - _ZNK20MsgUnifiedEditorView10metaObjectEv @ 60 NONAME - _ZTI20MsgUnifiedEditorView @ 61 NONAME - _ZTV20MsgUnifiedEditorView @ 62 NONAME - _ZThn16_N20MsgUnifiedEditorViewD0Ev @ 63 NONAME - _ZThn16_N20MsgUnifiedEditorViewD1Ev @ 64 NONAME - _ZThn8_N20MsgUnifiedEditorViewD0Ev @ 65 NONAME - _ZThn8_N20MsgUnifiedEditorViewD1Ev @ 66 NONAME + _ZN20MsgUnifiedEditorView15formatAddressesER5QListIP23ConvergedMessageAddressE @ 26 NONAME + _ZN20MsgUnifiedEditorView15populateContentERK5QListI8QVariantE @ 27 NONAME + _ZN20MsgUnifiedEditorView16createTempFolderEv @ 28 NONAME + _ZN20MsgUnifiedEditorView16enableSendButtonEb @ 29 NONAME + _ZN20MsgUnifiedEditorView16generateFileNameER7QString @ 30 NONAME + _ZN20MsgUnifiedEditorView16onContentChangedEv @ 31 NONAME + _ZN20MsgUnifiedEditorView16removeTempFolderEv @ 32 NONAME + _ZN20MsgUnifiedEditorView16staticMetaObjectE @ 33 NONAME DATA 16 + _ZN20MsgUnifiedEditorView17onDialogDeleteMsgEP8HbAction @ 34 NONAME + _ZN20MsgUnifiedEditorView17openDraftsMessageERK5QListI8QVariantE @ 35 NONAME + _ZN20MsgUnifiedEditorView19getStaticMetaObjectEv @ 36 NONAME + _ZN20MsgUnifiedEditorView19onDialogMmsSettingsEP8HbAction @ 37 NONAME + _ZN20MsgUnifiedEditorView19onDialogSmsSettingsEP8HbAction @ 38 NONAME + _ZN20MsgUnifiedEditorView19saveContentToDraftsEv @ 39 NONAME + _ZN20MsgUnifiedEditorView19serviceRequestErrorEiRK7QString @ 40 NONAME + _ZN20MsgUnifiedEditorView20activateInputBlockerEv @ 41 NONAME + _ZN20MsgUnifiedEditorView21doDelayedConstructionEv @ 42 NONAME + _ZN20MsgUnifiedEditorView22deactivateInputBlockerEv @ 43 NONAME + _ZN20MsgUnifiedEditorView22setAttachOptionEnabledENS_16TBE_AttachOptionEb @ 44 NONAME + _ZN20MsgUnifiedEditorView23handleViewExtnActivatedEP16HbListWidgetItem @ 45 NONAME + _ZN20MsgUnifiedEditorView25populateContentIntoEditorERK16ConvergedMessageb @ 46 NONAME + _ZN20MsgUnifiedEditorView25removeAttachmentContainerEv @ 47 NONAME + _ZN20MsgUnifiedEditorView25updateOtherRecipientCountEb @ 48 NONAME + _ZN20MsgUnifiedEditorView4sendEv @ 49 NONAME + _ZN20MsgUnifiedEditorView7addMenuEv @ 50 NONAME + _ZN20MsgUnifiedEditorView8addCcBccEv @ 51 NONAME + _ZN20MsgUnifiedEditorView8initViewEv @ 52 NONAME + _ZN20MsgUnifiedEditorView8setFocusEP26MsgUnifiedEditorBaseWidget @ 53 NONAME + _ZN20MsgUnifiedEditorView9vkbClosedEv @ 54 NONAME + _ZN20MsgUnifiedEditorView9vkbOpenedEv @ 55 NONAME + _ZN20MsgUnifiedEditorViewC1EP13QGraphicsItem @ 56 NONAME + _ZN20MsgUnifiedEditorViewC2EP13QGraphicsItem @ 57 NONAME + _ZN20MsgUnifiedEditorViewD0Ev @ 58 NONAME + _ZN20MsgUnifiedEditorViewD1Ev @ 59 NONAME + _ZN20MsgUnifiedEditorViewD2Ev @ 60 NONAME + _ZNK20MsgUnifiedEditorView10metaObjectEv @ 61 NONAME + _ZTI20MsgUnifiedEditorView @ 62 NONAME + _ZTV20MsgUnifiedEditorView @ 63 NONAME + _ZThn16_N20MsgUnifiedEditorViewD0Ev @ 64 NONAME + _ZThn16_N20MsgUnifiedEditorViewD1Ev @ 65 NONAME + _ZThn8_N20MsgUnifiedEditorViewD0Ev @ 66 NONAME + _ZThn8_N20MsgUnifiedEditorViewD1Ev @ 67 NONAME diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/msgapp/src/msglistviewitem.cpp --- a/messagingapp/msgui/msgapp/src/msglistviewitem.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/msgapp/src/msglistviewitem.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "msgcommondefines.h" #include "conversationsengine.h" @@ -109,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 @@ -119,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)); } } diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp --- a/messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/msguiutils/src/mmsconformancecheck.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -183,11 +183,10 @@ UniDataModelLoader* pluginLoader = new UniDataModelLoader(); UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); - int id = pluginInterface->setMessageId(messageId); + int error = pluginInterface->setMessageId(messageId); //Check if invalid id and slide count is greater than 1 - if ( ( id <= 0 ) || - (pluginInterface->slideCount() > 1) ) + if ( (error != KErrNone) || pluginInterface->slideCount() > 1) { delete pluginLoader; return false; diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/unifiededitor/inc/msgunieditorview.h --- a/messagingapp/msgui/unifiededitor/inc/msgunieditorview.h Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/unifiededitor/inc/msgunieditorview.h Tue Jun 29 23:42:47 2010 +0530 @@ -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: /** diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp --- a/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -557,9 +557,12 @@ 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 @@ -567,9 +570,10 @@ if(!isValid) { // additional check for MMS only isValid = genUtils->IsValidEmailAddress( - *XQConversions::qStringToS60Desc(addr) ); - } + *tempAddr ); + } delete genUtils; + delete tempAddr; return isValid; } diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp --- a/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -49,7 +49,7 @@ #include #include #include - +#include // Common phone number validity checker // USER INCLUDES #include "debugtraces.h" @@ -943,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); @@ -1002,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) @@ -1661,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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h --- a/messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h Tue Jun 29 23:42:47 2010 +0530 @@ -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. diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp --- a/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -38,12 +38,11 @@ //consts //regexp -const QString NUMBER_PATTERN("(\\(?(\\+|\\d))((?:\\d)((?:[\\s-/.\\)\\(])*(?:(\\d+|\\))))*(?:\\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\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-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\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*))+[a-zA-Z0-9/]"); //rules const QString NUMBER_RULE("NUMBER_RULE"); @@ -51,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") @@ -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() diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsreadfile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsreadfile.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include +#include + +// 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 iValueBuffer; + CDesCArray* iAliasArray; // aliases + HBufC8* iByteBuffer; + TTime iDate; + CArrayPtrFlat* iAttaStructures; + TInt iAttaCount; + TInt iAttaRoot; + TInt iAliasCount; + TInt iNextMessageType; + TParse iParse; + TFileName iFilename; + + protected: // Data + private: // Data + + // CArrayFixFlat * 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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include + +#include //for consts like KMsvNullIndexEntryIdValue +#include +#include +#include +//#include + +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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestbed.hrh Tue Jun 29 23:42:47 2010 +0530 @@ -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 + + +#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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsteststaticutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmsteststaticutils.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include + +#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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestuitimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/inc/mmstestuitimer.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 + +#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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/mmstestbed.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/mmstestbed.pro Tue Jun 29 23:42:47 2010 +0530 @@ -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 " + +LIBS += -lmsgs \ + -lmmsmessage \ + -lmmsconninit \ + -lmmscodec \ + -lmmsserversettings \ + -lcentralrepository \ + -lapparc \ + -lbafl \ + -lefsrv \ + -lesock \ + -lestor \ + -leuser \ + -llogcli \ + -llogwrap \ + -lapgrfx \ + -lapmime diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsreadfile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsreadfile.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include +#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( 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 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 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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestbed.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestbed.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#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 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 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 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 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 + } + diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsteststaticutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmsteststaticutils.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include +#include +#include + +#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 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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestuitimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/mmstestbed/src/mmstestuitimer.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 ======== + diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.h Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include + +//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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/inc/testconvergedmessageutils.ini Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/src/testconvergedmessageutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/src/testconvergedmessageutils.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -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 +#include +#include +#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"); + + //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(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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.cfg Tue Jun 29 23:42:47 2010 +0530 @@ -0,0 +1,1 @@ +TestConvergedMessageUtils \ No newline at end of file diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pl Tue Jun 29 23:42:47 2010 +0530 @@ -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 "\n"; + printf MYFILE "$passed\n"; + printf MYFILE "\n"; + + if($failed > 0) + { + printf MYFILE "\n"; + printf MYFILE "$failed\n"; + printf MYFILE "\n"; + } + else + { + printf MYFILE "\n"; + printf MYFILE "$failed\n"; + printf MYFILE "\n"; + } + + printf MYFILE "\n"; + printf MYFILE "$skipped\n"; + printf MYFILE "\n"; + + printf MYFILE "\n"; + printf MYFILE "$total\n"; + printf MYFILE "\n"; + + printf MYFILE "\n"; + printf MYFILE ("$passrateround %%\n"); + printf MYFILE "\n"; + + printf MYFILE "\n"; + printf MYFILE "$runrateround %%\n"; + printf MYFILE "\n"; + + +} + +sub parse_file + { + my $pattern = "Totals"; + my $file = $_[0]; + open (FILE,$file); + + while (my $line= ) + { + 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 "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "ConvergedMessageUtils Test Reports"; + printf MYFILE "\n"; + printf MYFILE "

ConvergedMessageUtils Test Report

\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + + + my @files = ; + 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 "\n"; + printf MYFILE "\n"; + + parse_file $file; + + printf MYFILE "\n"; + } + + printf MYFILE "\n"; + printf MYFILE "\n"; + + + printf MYFILE "\n"; + + printf MYFILE "\n"; + + printf MYFILE "\n"; + + printf MYFILE "\n"; + + my $passrate = $TOTALPASSED*100/$TOTALCASES; + my $passrateround = sprintf("%.0f",$passrate); + printf MYFILE "\n"; + + my $runrate = ($TOTALCASES - $TOTALSKIPPED)*100/$TOTALCASES; + my $runrateround = sprintf("%.0f",$runrate); + printf MYFILE "\n"; + + printf MYFILE "\n"; + + printf MYFILE "
ModulePassedFailedSkippedTotal CasesPass RateRun Rate
\n"; + printf MYFILE "$name\n"; + printf MYFILE "
\n"; + printf MYFILE "Overall\n"; + printf MYFILE "\n"; + printf MYFILE "$TOTALPASSED\n"; + printf MYFILE "\n"; + printf MYFILE "$TOTALFAILED\n"; + printf MYFILE "\n"; + printf MYFILE "$TOTALSKIPPED\n"; + printf MYFILE "\n"; + printf MYFILE "$TOTALCASES\n"; + printf MYFILE "\n"; + printf MYFILE "$passrateround%%\n"; + printf MYFILE "\n"; + printf MYFILE "$runrateround%%\n"; + printf MYFILE "
\n"; + printf MYFILE "\n"; + printf MYFILE "\n"; + + close (MYFILE); + } + + +generate_report; \ No newline at end of file diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pro Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/msgutils/convergedmessageutils/tsrc/tsrc.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgutils/convergedmessageutils/tsrc/tsrc.pro Tue Jun 29 23:42:47 2010 +0530 @@ -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 diff -r 518b245aa84c -r 4e4b6adb1024 messagingapp/shareui/src/shareuiprivate.cpp --- a/messagingapp/shareui/src/shareuiprivate.cpp Fri Jun 25 15:47:40 2010 +0530 +++ b/messagingapp/shareui/src/shareuiprivate.cpp Tue Jun 29 23:42:47 2010 +0530 @@ -209,7 +209,7 @@ 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())); @@ -273,6 +273,7 @@ */ void ShareUiPrivate::onTriggered(void) { + XQAiwRequest* request = 0; request = qobject_cast(sender()); if(request) @@ -289,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(sender()); + if(request) + { + disconnect(request, + SIGNAL(requestError(int,const QString&)), + this, + SLOT(handleError(int,const QString&))); } +} /** * Slot for handling errors from the framework. @@ -320,7 +331,9 @@ { action->setEnabled(true); action->activate(HbAction::Trigger); - } + } + + mSharePopup->close(); }