searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp
changeset 17 7d8c8d8f5eab
parent 12 993ab30e92fc
child 20 68cdadcf169e
--- a/searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp	Tue Jul 06 14:17:22 2010 +0300
+++ b/searchui/stateproviders/searchstateprovider/src/searchprogressivestate.cpp	Wed Aug 18 09:49:49 2010 +0300
@@ -16,18 +16,17 @@
  */
 #include "searchprogressivestate.h"
 #include "indevicehandler.h"
-#include <qcpixdocument.h>
-#include <qcpixdocumentfield.h>
+#include "searchuiloader.h"
+#include <cpixdocument.h>
+#include <cpixdocumentfield.h>
 #include <hbmainwindow.h>
 #include <hbview.h>
 #include <hblabel.h>
 #include <hbicon.h>
 #include <hbmenu.h>
 #include <hbinstance.h>
-#include <hbdocumentloader.h>
 #include <hbsearchpanel.h>
 #include <hbaction.h>
-#include <hbframebackground.h>
 #include <hbapplication.h>
 #include <qsortfilterproxymodel.h>
 #include <AknsUtils.h>
@@ -53,80 +52,39 @@
 #include <hblistwidgetitem.h>
 #include <hbabstractviewitem.h>
 #include <hblistviewitem.h>
+#include <hbactivitymanager.h>
 #define hbApp qobject_cast<HbApplication*>(qApp)
-const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
-const char *TOC_VIEW = "tocView";
-const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
-const char *TUT_LIST_VIEW = "listView";
-const int totalcategories = 10;
+const int totalcategories_normalreason = 10;
+const int totalcategories_activityreasonreason = 13;
+const int intial_iteration = 3;
+const int batch_iteration = 20;
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::SearchProgressiveState
 // ---------------------------------------------------------------------------
 SearchProgressiveState::SearchProgressiveState(QState *parent) :
     QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL),
-            mDocumentLoader(NULL), mSearchHandler(NULL), mNotesEditor(0),
-            mAiwMgr(0), mRequest(0)
+            mSearchHandler(NULL), mNotesEditor(0), mAiwMgr(0), mRequest(0)
     {
+    mUiLoader = SearchUiLoader::instance();
 
     mMainWindow = hbInstance->allMainWindows().at(0);
 
     mAiwMgr = new XQApplicationManager;
 
-    mDocumentLoader = new HbDocumentLoader();
-    bool ok = false;
-    mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok);
-
-    QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW);
-    Q_ASSERT_X(ok && (widget != 0), "TOC_VIEW", "invalid view");
-
-    mView = qobject_cast<HbView*> (widget);
-    if (mView)
-        {
-        mView->setTitle(hbTrId("txt_search_title_search"));
-        }
-
-    mListView = qobject_cast<HbListWidget *> (mDocumentLoader->findWidget(
-            TUT_LIST_VIEW));
-    Q_ASSERT_X(ok && (mListView != 0), "TUT_LIST_VIEW", "invalid viewocML file");
+    mView = mUiLoader->View();
+    mListView = mUiLoader->ListWidget();
+    mSearchPanel = mUiLoader->SearchPanel();
 
-    if (mListView)
-        {
-        HbAbstractViewItem *prototype = mListView->itemPrototypes().first();
-        HbFrameBackground frame;
-        frame.setFrameGraphicsName("qtg_fr_list_normal");
-        frame.setFrameType(HbFrameDrawer::NinePieces);
-        prototype->setDefaultFrame(frame);
+    HbStyle style;
+    qreal x;
+    style.parameter("hb-param-graphic-size-primary-large", x);
+    QSizeF size(x, x);
+    mListViewIconSize = size.toSize();
 
-        HbListViewItem *prototypeListView = qobject_cast<HbListViewItem *> (
-                prototype);
-        prototypeListView->setGraphicsSize(HbListViewItem::LargeIcon);
-        if (prototypeListView)
-            {
-            HbStyle style;
-            qreal x;
-            style.parameter("hb-param-graphic-size-primary-large", x);
-            QSizeF size(x, x);
-            mListViewIconSize = size.toSize();
-            prototypeListView->setTextFormat(Qt::RichText);
-            }
-
-        HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations =
-                HbAbstractItemView::All;
-        noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear;
-        noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear;
-        mListView->setEnabledAnimations(noCreationAndRemovalAnimations);
-        }
-
-    mSearchPanel = qobject_cast<HbSearchPanel *> (
-            mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET));
     if (mSearchPanel)
         {
-        mSearchPanel->setSearchOptionsEnabled(true);
-
         mSearchPanel->setPlaceholderText(hbTrId(
                 "txt_search_dialog_search_device"));
-
-        mSearchPanel->setCancelEnabled(false);
         mSearchPanel->setFocus();
         }
 
@@ -143,24 +101,12 @@
     mResultparser = 0;
     loadSettings = true;
 
-    //Icon creation in array
-    RArray<TUid> appUid;
-    appUid.Append(TUid::Uid(0x20022EF9));//contact
-    appUid.Append(TUid::Uid(0x10207C62));//audio
-    appUid.Append(TUid::Uid(0x200211FE));//video 
-    appUid.Append(TUid::Uid(0x20000A14));//image 
-    appUid.Append(TUid::Uid(0x2001FE79));//msg
-    appUid.Append(TUid::Uid(0x200255BA));//email 
-    appUid.Append(TUid::Uid(0x10005901));//calender
-    appUid.Append(TUid::Uid(0x20029F80));//notes
-    //appUid.Append(TUid::Uid(0x20022F35));//application
-    appUid.Append(TUid::Uid(0x10008D39));//bookmark
-    appUid.Append(TUid::Uid(0x2002BCC0));//files
+    if (hbApp)
+        {
+        connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)),
+                this, SLOT(activityRequested(QString)));
+        }
 
-    for (int i = 0; i < appUid.Count(); i++)
-        {
-        TRAP_IGNORE(mIconArray.append(getAppIconFromAppIdL(appUid[i])));
-        }
 #ifdef OST_TRACE_COMPILER_IN_USE 
     //start() the timers to avoid worrying abt having to start()/restart() later
     m_categorySearchApiTime.start();
@@ -188,6 +134,13 @@
         }
 
     mOnlineQueryAvailable = false;
+    //Prepare the icons,listen of theme change    
+    connect(hbInstance->theme(), SIGNAL(changeFinished()), this,
+            SLOT(slotPrepareResultIcons()));
+    slotPrepareResultIcons();
+
+    // creating the handler if it is not prepared, useful when user try to create before 
+    mValidateHandlerCreation = false;
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::~SearchProgressiveState
@@ -198,10 +151,6 @@
         {
         delete mAiwMgr;
         }
-    if (mDocumentLoader)
-        {
-        delete mDocumentLoader;
-        }
     for (int i = 0; i < mSearchHandlerList.count(); i++)
         {
         delete mSearchHandlerList.at(i);
@@ -211,70 +160,22 @@
         mNotespluginLoader->unload();
         delete mNotespluginLoader;
         }
+    SearchUiLoader::deleteinstance();
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::constructHandlers
 // ---------------------------------------------------------------------------
 void SearchProgressiveState::constructHandlers()
     {
-    InDeviceHandler* handler = NULL;
-    for (int i = 0; i < totalcategories; i++)
+    int categories = totalcategories_normalreason;
+
+    if (hbApp && hbApp->activateReason() == Hb::ActivationReasonActivity)
         {
-        handler = new InDeviceHandler();
-        switch (i)
-            {
-            case 0:
-                {
-                handler->setCategory("");
-                break;
-                }
-            case 1:
-                {
-                handler->setCategory("contact");
-                break;
-                }
-            case 2:
-                {
-                handler->setCategory("media");
-                break;
-                }
-            case 3:
-                {
-                handler->setCategory("msg");
-                break;
-                }
-            case 4:
-                {
-                handler->setCategory("msg email");
-                break;
-                }
-            case 5:
-                {
-                handler->setCategory("calendar");
-                break;
-                }
-            case 6:
-                {
-                handler->setCategory("notes");
-                break;
-                }
-            case 7:
-                {
-                handler->setCategory("applications");
-                break;
-                }
-            case 8:
-                {
-                handler->setCategory("file");
-                break;
-                }
-            case 9:
-                {
-                handler->setCategory("bookmark");
-                break;
-                }
-            }
-        mSearchHandlerList.append(handler);
+        categories = totalcategories_activityreasonreason;
+        }
+    for (int i = 0; i < categories; i++)
+        {
+        mSearchHandlerList.append(constructHandlers(i));
         }
     }
 // ---------------------------------------------------------------------------
@@ -284,8 +185,19 @@
     {
     //  WMS_LOG << "::onEntry";
     QState::onEntry(event);
+
+    mStateStatus = true;// used for conditional execution for the slots that are connected as transitions
+    if (mSearchPanel)
+        {
+        mSearchPanel->setPlaceholderText(hbTrId(
+                "txt_search_dialog_search_device"));
+        mSearchPanel->setProgressive(true);
+        }
+    if (mListView)
+        {
+        mListView->setVisible(true);
+        }
     activateSignals();
-
     // If this is not the current view, we're getting back from plugin view  
     if (mMainWindow)
         {
@@ -297,6 +209,7 @@
         }
     if (loadSettings)
         {
+        // to get the intial settings form delimeter  
         emit switchProToSettingsState();
         loadSettings = false;
         }
@@ -313,6 +226,7 @@
 void SearchProgressiveState::onExit(QEvent *event)
     {
     QState::onExit(event);
+    mStateStatus = false;
     deActivateSignals();
     }
 // ---------------------------------------------------------------------------
@@ -326,8 +240,12 @@
                 SIGNAL(handleAsyncSearchResult(int,int)), this,
                 SLOT(onAsyncSearchComplete(int,int)));
         connect(mSearchHandlerList.at(i),
-                SIGNAL(handleDocument(int,QCPixDocument*)), this,
-                SLOT(onGetDocumentComplete(int,QCPixDocument*)));
+                SIGNAL(handleDocument(int,CpixDocument*)), this,
+                SLOT(onGetDocumentComplete(int,CpixDocument*)));
+        connect(mSearchHandlerList.at(i),
+                SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
+                SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
+
         }
     if (mListView)
         {
@@ -341,9 +259,7 @@
         connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this,
                 SLOT(setSettings()));
         }
-
     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(viewReady()));
-
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::deActivateSignals
@@ -356,8 +272,11 @@
                 SIGNAL(handleAsyncSearchResult(int,int)), this,
                 SLOT(onAsyncSearchComplete(int,int)));
         disconnect(mSearchHandlerList.at(i),
-                SIGNAL(handleDocument(int,QCPixDocument*)), this,
-                SLOT(onGetDocumentComplete(int,QCPixDocument*)));
+                SIGNAL(handleDocument(int,CpixDocument*)), this,
+                SLOT(onGetDocumentComplete(int,CpixDocument*)));
+        disconnect(mSearchHandlerList.at(i),
+                SIGNAL(handleBatchDocument(int,int,CpixDocument**)), this,
+                SLOT(onGetBatchDocumentComplete(int,int,CpixDocument**)));
         }
     if (mListView)
         {
@@ -404,185 +323,56 @@
 // SearchProgressiveState::onGetDocumentComplete
 // ---------------------------------------------------------------------------
 void SearchProgressiveState::onGetDocumentComplete(int aError,
-        QCPixDocument* aDoc)
+        CpixDocument* aDoc)
     {
-    PERF_CAT_GETDOC_TIME_ACCUMULATE
-    if (aDoc == NULL || aError != 0)
+    if (aError)
         return;
-    QStringList liststr;
-    QString secondrow = aDoc->excerpt();
-    QString firstrow;
-    HbListWidgetItem* listitem = new HbListWidgetItem();
-
-    if (aDoc->baseAppClass().contains("contact"))
-        {
-        QStringList docsList = filterDoc(aDoc, "GivenName", "FamilyName");
-        if (docsList.value(0, "").length())
-            {
-            firstrow.append(docsList.at(0));
-            }
-        if (docsList.value(1, "").length())
-            {
-            if (firstrow.length())
-                firstrow.append(" ");
-            firstrow.append(docsList.at(1));
-            }
-        if (firstrow.length() == 0)
-            {
-            firstrow = hbTrId("txt_phob_dblist_unnamed");
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(0), Qt::DecorationRole);
-        }
-    else if (aDoc->baseAppClass().contains("audio"))
-        {
-        QStringList audioList = filterDoc(aDoc, "Title", "MediaId");
-        if (audioList.value(0, "").length())
-            {
-            firstrow.append(audioList.at(0));
-            }
-        if (firstrow.length() == 0)
-            {
-            firstrow = hbTrId("txt_mus_dblist_val_unknown4");
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(1), Qt::DecorationRole);
-        if (audioList.value(1, "").length())
-            {
-            listitem->setData(audioList.at(1), Qt::UserRole + 2);
-            }
-        }
-    else if (aDoc->baseAppClass().contains("video"))
-        {
-        QStringList videoList = filterDoc(aDoc, "Title", "MediaId", "Name");
-        if (videoList.value(0, "").length())
-            {
-            firstrow.append(videoList.at(0));
-            }
-        if (firstrow.length() == 0 && videoList.value(2, "").length())
-            {
-            firstrow.append(videoList.at(2));
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(2), Qt::DecorationRole);
-        if (videoList.value(1, "").length())
-            {
-            listitem->setData(videoList.at(1), Qt::UserRole + 2);
-            }
-        }
-    else if (aDoc->baseAppClass().contains("image"))
-        {
-        QStringList imageList = filterDoc(aDoc, "Name", "MediaId");
-        if (imageList.value(0, "").length())
-            {
-            firstrow.append(imageList.at(0));
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(3), Qt::DecorationRole);
-        if (imageList.value(1, "").length())
-            {
-            listitem->setData(imageList.at(1), Qt::UserRole + 2);
-            }
-        }
-    else if (aDoc->baseAppClass().contains("msg email"))
-        {
-        qDebug() << "searchui:on Get doc email";
-        QStringList emailList = filterDoc(aDoc, "Sender", "MailBoxId",
-                "FolderId");
-
-        qDebug() << "searchui:recipients" << emailList.at(0) << emailList.at(
-                1) << emailList.at(2);
-        firstrow.append(emailList.at(0));
-        listitem->setData(emailList.at(1), Qt::UserRole + 2);
-        listitem->setData(emailList.at(2), Qt::UserRole + 3);
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(5), Qt::DecorationRole);
-        }
-    else if (aDoc->baseAppClass().contains("msg"))
-        {
-        QStringList msgList = filterDoc(aDoc, "Subject", "Body");
-        if (msgList.value(0, "").length())
-            {
-            firstrow.append(msgList.at(0));
-            }
-        else
-            {
-            if (msgList.value(1, "").length())
-                firstrow.append(msgList.at(1));
-            }
-        if (firstrow.length() == 0)
-            {
-            firstrow = " ";// space if subject and body are missing
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(4), Qt::DecorationRole);
-        } 
-    else if (aDoc->baseAppClass().contains("calendar"))
-        {
-        firstrow.append(filterDoc(aDoc, "Summary"));
-        if (firstrow.length() == 0)
-            {
-            firstrow = hbTrId("txt_calendar_preview_unnamed");
-            }
-
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(6), Qt::DecorationRole);
-        }
-    else if (aDoc->baseAppClass().contains("notes"))
-        {
-        firstrow.append(filterDoc(aDoc, "Memo"));
-        if (firstrow.length() == 0)
-            {
-            firstrow = hbTrId("txt_notes_dblist_unnamed");
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(7), Qt::DecorationRole);
-        }
-    else if (aDoc->baseAppClass().contains("applications"))
-        {
-        firstrow.append(filterDoc(aDoc, "Name"));
-        liststr << firstrow;
-        bool ok;
-        TRAP_IGNORE(listitem->setData(getAppIconFromAppIdL(TUid::Uid(aDoc->docId().toInt(
-                                                &ok, 16))), Qt::DecorationRole));
-        }
-    else if (aDoc->baseAppClass().contains("bookmark"))
-        {
-        firstrow.append(filterDoc(aDoc, "Name"));
-        if (firstrow.length() == 0)
-            {
-            firstrow = "UnKnown";
-            }
-        liststr << firstrow << secondrow;
-        listitem->setData(secondrow, Qt::UserRole + 2);
-        listitem->setData(mIconArray.at(8), Qt::DecorationRole);
-        }
-    else if (aDoc->baseAppClass().contains("file"))
-        {
-        firstrow.append(filterDoc(aDoc, "Name"));
-        if (firstrow.length() == 0)
-            firstrow = aDoc->baseAppClass();
-        liststr << firstrow << secondrow;
-        listitem->setData(mIconArray.at(9), Qt::DecorationRole);
-        }
-    listitem->setText(firstrow);
-    listitem->setSecondaryText(secondrow);
-    listitem->setData(aDoc->docId(), Qt::UserRole);
-    listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1);
-    mListView->addItem(listitem);
-
+    parseDocument(aDoc);
     mResultparser++;
     if (mResultparser < mResultcount)
         {
         PERF_CAT_GETDOC_TIME_RESTART
-        mSearchHandler->getDocumentAsyncAtIndex(mResultparser);
+        if (mResultparser < intial_iteration)
+            {
+            mSearchHandler->getDocumentAsyncAtIndex(mResultparser);
+            }
+        else
+            {
+            mSearchHandler->getBatchDocumentAsyncAtIndex(mResultparser,
+                    batch_iteration);
+            }
         }
     else
         {
         PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG
         searchOnCategory(mSearchString);
         }
+    }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::onGetDocumentComplete
+// ---------------------------------------------------------------------------
+void SearchProgressiveState::onGetBatchDocumentComplete(int aError,
+        int aCount, CpixDocument** aDoc)
+    {
+    if (aError)
+        return;
+    for (int i = 0; i < aCount; i++)
+        {
+        parseDocument(aDoc[i]);
+        }
     delete aDoc;
+    mResultparser += aCount;
+    if (mResultparser < mResultcount)
+        {
+        PERF_CAT_GETDOC_TIME_RESTART
+        mSearchHandler->getBatchDocumentAsyncAtIndex(mResultparser,
+                batch_iteration);
+        }
+    else
+        {
+        PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG
+        searchOnCategory(mSearchString);
+        }
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::getSettingCategory
@@ -597,7 +387,8 @@
 void SearchProgressiveState::openResultitem(HbListWidgetItem * item)
     {
     if (item == NULL)
-        return;PERF_RESULT_ITEM_LAUNCH_TIME_RESTART
+        return;
+    PERF_RESULT_ITEM_LAUNCH_TIME_RESTART
     QList<QVariant> args;
     bool t;
     mRequest = NULL;
@@ -605,7 +396,7 @@
         {
         PERF_RESULT_ITEM_FOR_LAUNCHING("contact")
         mRequest = mAiwMgr->create("com.nokia.services.phonebookservices",
-                "Fetch", "open(int)", false);
+                "Fetch", "open(int)", true);
 
         int uid = (item->data(Qt::UserRole)).toInt(&t);
         args << uid;
@@ -614,7 +405,7 @@
         {
         PERF_RESULT_ITEM_FOR_LAUNCHING("bookmark")
         QDesktopServices::openUrl(item->data(Qt::UserRole + 2).toString());
-PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG        ("")
+        PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
 
         }
     else if (item->data(Qt::UserRole + 1).toString().contains("calendar"))
@@ -622,10 +413,10 @@
         QDir pluginDir = QDir(QString("z:/resource/qt/plugins/calendar"));
         QPluginLoader *calAgandaViewerPluginLoader = new QPluginLoader(
                 pluginDir.absoluteFilePath(QString(
-                                "agendaeventviewerplugin.qtplugin")));
+                        "agendaeventviewerplugin.qtplugin")));
 
         calAgandaViewerPluginInstance = qobject_cast<
-        EventViewerPluginInterface *> (
+                EventViewerPluginInterface *> (
                 calAgandaViewerPluginLoader->instance());
 
         connect(calAgandaViewerPluginInstance, SIGNAL(viewingCompleted()),
@@ -638,7 +429,7 @@
     else if (item->data(Qt::UserRole + 1).toString().contains("applications"))
         {
         PERF_RESULT_ITEM_FOR_LAUNCHING("applications")
-        TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toInt(&t, 16))));
+        TRAP_IGNORE(LaunchApplicationL(TUid::Uid((item->data(Qt::UserRole)).toString().toUInt(&t, 16))));
         PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG("")
         }
     else if (item->data(Qt::UserRole + 1).toString().contains("file"))
@@ -646,7 +437,7 @@
         PERF_RESULT_ITEM_FOR_LAUNCHING("file")
         QString uid = item->data(Qt::UserRole).toString();
         QFile file(uid);
-        mRequest = mAiwMgr->create(file, false);
+        mRequest = mAiwMgr->create(file, true);
         args << file.fileName();
         }
     else if ((item->data(Qt::UserRole + 1).toString().contains("video"))
@@ -659,14 +450,14 @@
         uid.append(':');
         uid.append(item->data(Qt::UserRole).toString());
         QFile file(uid);
-        mRequest = mAiwMgr->create(file, false);
+        mRequest = mAiwMgr->create(file, true);
         args << file.fileName();
         }
 
     else if (item->data(Qt::UserRole + 1).toString().contains("notes"))
         {
         PERF_RESULT_ITEM_FOR_LAUNCHING("notes")
-        if(mNotesEditor)
+        if (mNotesEditor)
             {
             mNotesEditor->edit(item->data(Qt::UserRole).toInt());
             }
@@ -677,23 +468,24 @@
 
         mRequest = mAiwMgr->create("nmail",
                 "com.nokia.symbian.IEmailMessageView",
-                "viewMessage(QVariant,QVariant,QVariant)", false);
+                "viewMessage(QVariant,QVariant,QVariant)", true);
 
         args << item->data(Qt::UserRole + 2).toULongLong(&t) << item->data(
-                Qt::UserRole + 3).toULongLong(&t) << item->data(Qt::UserRole).toULongLong(&t);
+                Qt::UserRole + 3).toULongLong(&t)
+                << item->data(Qt::UserRole).toULongLong(&t);
         }
     else if (item->data(Qt::UserRole + 1).toString().contains("msg"))
         {
         PERF_RESULT_ITEM_FOR_LAUNCHING("msg")
-        mRequest = mAiwMgr->create("com.nokia.services.hbserviceprovider",
-                "conversationview", "view(int)", false);
+        mRequest = mAiwMgr->create("messaging",
+                "com.nokia.symbian.IMessageView", "view(int)", true);
 
         int uid = (item->data(Qt::UserRole)).toInt(&t);
         args << uid;
         }
-    else if(item->data(Qt::UserRole + 1).toString().contains("links"))
+    else if (item->data(Qt::UserRole + 1).toString().contains("links"))
         {
-        emit launchLink((item->data(Qt::UserRole)).toInt(&t),mOriginalString);
+        emit launchLink((item->data(Qt::UserRole)).toInt(&t), mOriginalString);
         }
     if (mRequest)
         {
@@ -725,7 +517,7 @@
 void SearchProgressiveState::handleOk(const QVariant& var)
     {
     Q_UNUSED(var);
-PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
+    PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::handleError
@@ -782,7 +574,7 @@
 void SearchProgressiveState::searchOnCategory(const QString aKeyword)
     {
 #ifdef OST_TRACE_COMPILER_IN_USE
-    if( mDatabasecount != 0 )
+    if (mDatabasecount != 0)
         {//Search just started.
         PERF_CAT_UI_ENDLOG
         }
@@ -800,6 +592,18 @@
             {
             mSearchHandler = mSearchHandlerList.at(1);
             }
+        else if (mTemplist.at(mDatabasecount).contains("image"))
+            {
+            mSearchHandler = mSearchHandlerList.at(10);
+            }
+        else if (mTemplist.at(mDatabasecount).contains("audio"))
+            {
+            mSearchHandler = mSearchHandlerList.at(11);
+            }
+        else if (mTemplist.at(mDatabasecount).contains("video"))
+            {
+            mSearchHandler = mSearchHandlerList.at(12);
+            }
         else if (mTemplist.at(mDatabasecount).contains("media"))
             {
             mSearchHandler = mSearchHandlerList.at(2);
@@ -834,7 +638,7 @@
             }
         // mSearchHandler->setCategory(mTemplist.at(mDatabasecount));
         mDatabasecount++;
-        if (mSearchHandler->isPrepared())
+        if (mSearchHandler != NULL && mSearchHandler->isPrepared())
             {
             PERF_CAT_API_TIME_RESTART
             mSearchHandler->searchAsync(aKeyword, "_aggregate");
@@ -863,6 +667,26 @@
     {
     PERF_CAT_TOTAL_TIME_RESTART
     mOriginalString = aKeyword.trimmed();
+
+    if (!mValidateHandlerCreation)
+        {
+        for (int i = 0; i < mSearchHandlerList.count(); i++)
+            {
+            /* ignoring bookmark to getrid of unnecesary check as bookmark support is withdrawn
+             * keeping perfomance into consideration, otherwise not  
+             */
+            if (!mSearchHandlerList.at(i)->isPrepared() && (i != 9))
+                {
+                constructHandlers(i);
+                mValidateHandlerCreation = false;
+                }
+            else
+                {
+                mValidateHandlerCreation = true;
+                }
+            }
+        }
+
     for (int i = 0; i < mSearchHandlerList.count(); i++)
         {
         mSearchHandlerList.at(i)->cancelLastSearch();
@@ -875,12 +699,9 @@
         {
         mDatabasecount = 0;
         mLinkindex = 0;
-        //Prefix query
         mSearchString = "$prefix(\"";
         mSearchString += mOriginalString;
         mSearchString += "\")";
-        /*mSearchString = mOriginalString;
-         mSearchString.append('*');*/
         searchOnCategory(mSearchString);
         }
     }
@@ -899,7 +720,7 @@
 // ---------------------------------------------------------------------------
 void SearchProgressiveState::settingsaction(bool avalue)
     {
-    if (avalue)
+    if (avalue && mStateStatus)
         {
         QMapIterator<int, bool> i(mTempSelectedCategory);
         QMapIterator<int, bool> j(mSelectedCategory);
@@ -1046,7 +867,6 @@
         CleanupStack::PopAndDestroy(apaMaskedBitmap);
         }
     CleanupStack::PopAndDestroy(&apaLsSession);
-
     if (icon.isNull() || !(icon.size().isValid()))
         icon = HbIcon("qtg_large_application");
     return icon;
@@ -1059,7 +879,6 @@
     {
     CFbsBitmap *bitamp(0);
     CFbsBitmap *mask(0);
-
     if (AknIconUtils::IsMifFile(fileName))
         {
         // SVG icon
@@ -1072,17 +891,13 @@
         AknIconUtils::CreateIconLC(bitamp, mask, fileName, bitmapIndex,
                 maskIndex);
         }
-
     AknIconUtils::DisableCompression(bitamp);
     AknIconUtils::SetSize(bitamp, TSize(size.width(), size.height()),
             EAspectRatioPreservedAndUnusedSpaceRemoved);
-
     AknIconUtils::DisableCompression(mask);
     AknIconUtils::SetSize(mask, TSize(size.width(), size.height()),
             EAspectRatioPreservedAndUnusedSpaceRemoved);
-
     fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
-
     // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order
     CleanupStack::Pop(2);
     }
@@ -1186,7 +1001,7 @@
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::filterDoc
 // ---------------------------------------------------------------------------
-QString SearchProgressiveState::filterDoc(const QCPixDocument* aDoc,
+QString SearchProgressiveState::filterDoc(const CpixDocument* aDoc,
         const QString& filter)
     {
     for (int i = 0; i < aDoc->fieldCount(); i++)
@@ -1201,7 +1016,7 @@
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::filterDoc
 // ---------------------------------------------------------------------------
-QStringList SearchProgressiveState::filterDoc(const QCPixDocument* aDoc,
+QStringList SearchProgressiveState::filterDoc(const CpixDocument* aDoc,
         const QString& filter1, const QString& filter2,
         const QString& filter3)
     {
@@ -1318,7 +1133,7 @@
         CleanupStack::PopAndDestroy(&appArcSession);
         }
     CleanupStack::PopAndDestroy(&wsSession);
-PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
+    PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::_viewingCompleted
@@ -1327,7 +1142,7 @@
     {
     if (calAgandaViewerPluginInstance)
         calAgandaViewerPluginInstance->deleteLater();
-PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG    ("")
+    PERF_RESULT_ITEM_LAUNCH_TIME_ENDLOG ("")
     }
 // ---------------------------------------------------------------------------
 // SearchProgressiveState::viewReady
@@ -1340,17 +1155,383 @@
             {
             QVariantHash params = hbApp->activateParams();
             QString searchKey = params.value("query").toString();
+            params.remove("query");
+            params.remove("activityname");
+            QList<QVariant> list = params.values();
+            mTemplist.clear();
+            for (int i = 0; i < list.count(); i++)
+                {
+                QString str = list.at(i).toString();
+                if (!str.isNull())
+                    mTemplist.append(str);
+                }
             if (searchKey.length() > 0)
                 mSearchPanel->setCriteria(searchKey);
             }
-        }PERF_APP_LAUNCH_END("SearchAppplication View is ready");
+        }
+    PERF_APP_LAUNCH_END("SearchAppplication View is ready");
+    emit applicationReady();
     }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::slotOnlineQuery
+// ---------------------------------------------------------------------------
 void SearchProgressiveState::slotOnlineQuery(QString str)
     {
-    mOriginalString = str;
-    mOnlineQueryAvailable = true;
+    if (mOriginalString != str)
+        {
+        mOriginalString = str;
+        mOnlineQueryAvailable = true;
+        }
     }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::slotISProvidersIcon
+// ---------------------------------------------------------------------------
 void SearchProgressiveState::slotISProvidersIcon(int id, HbIcon icon)
     {
     mISprovidersIcon.insert(id, icon);
     }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::slotPrepareResultIcons
+// ---------------------------------------------------------------------------
+void SearchProgressiveState::slotPrepareResultIcons()
+    {
+    //Icon creation in array
+    QStringList icons;
+    icons << "qtg_large_phonebook" << "qtg_large_tone" << "qtg_large_video"
+            << "qtg_large_photos" << "qtg_large_message" << "qtg_large_email"
+            << "qtg_large_calendar" << "qtg_large_notes"
+            << "qtg_large_web_link" << "qtg_large_text" << "qtg_large_sisx"
+            << "qtg_large_java" << "qtg_large_flash" << "qtg_large_folder"
+            << "qtg_large_query";
+    mIconArray.clear();
+    for (int i = 0; i < icons.count(); i++)
+        {
+        HbIcon icon(icons.at(i));
+        if (icon.isNull() || !(icon.size().isValid()))
+            icon = HbIcon("qtg_large_application");
+        mIconArray.append(icon);
+        }
+    /*QList<TUid> appUid;
+     appUid.append(TUid::Uid(0x20022EF9));//contact
+     appUid.append(TUid::Uid(0x10207C62));//audio
+     appUid.append(TUid::Uid(0x200211FE));//video 
+     appUid.append(TUid::Uid(0x20000A14));//image 
+     appUid.append(TUid::Uid(0x2001FE79));//msg
+     appUid.append(TUid::Uid(0x200255BA));//email 
+     appUid.append(TUid::Uid(0x10005901));//calender
+     appUid.append(TUid::Uid(0x20029F80));//notes
+     //appUid.Append(TUid::Uid(0x20022F35));//application
+     appUid.append(TUid::Uid(0x10008D39));//bookmark
+     appUid.append(TUid::Uid(0x2002BCC0));//files
+
+     for (int i = 0; i < appUid.count(); i++)
+     {
+     TRAP_IGNORE(mIconArray.append(getAppIconFromAppIdL(appUid.at(i))));
+     }*/
+    }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::activityRequested
+// ---------------------------------------------------------------------------
+void SearchProgressiveState::activityRequested(const QString &name)
+    {
+    /* when search application is launched in normal and then supporting for activity uri
+     * for normal search launching "media" is used instead of "media image","media audio","media video" 
+     */
+    if (mSearchHandlerList.count() != totalcategories_activityreasonreason)
+        {
+        InDeviceHandler* handler = NULL;
+        handler->setCategory("media image");
+        mSearchHandlerList.append(handler);
+        handler->setCategory("media audio");
+        mSearchHandlerList.append(handler);
+        handler->setCategory("media video");
+        mSearchHandlerList.append(handler);
+        }
+    if (name == "SearchDeviceQueryView")
+        {
+        QVariantHash params = hbApp->activateParams();
+        QString searchKey = params.value("query").toString();
+        int i = params.count();
+        params.remove("query");
+        params.remove("activityname");
+        QList<QVariant> list = params.values();
+        int j = list.count();
+        mTemplist.clear();
+        for (int i = 0; i < list.count(); i++)
+            {
+            QString str = list.at(i).toString();
+            if (!str.isNull())
+                mTemplist.append(str);
+            }
+        if (searchKey.length() > 0)
+            mSearchPanel->setCriteria(searchKey);
+        }
+    }
+// ---------------------------------------------------------------------------
+// SearchProgressiveState::parseDocument
+// ---------------------------------------------------------------------------
+void SearchProgressiveState::parseDocument(CpixDocument* aDoc)
+    {
+    PERF_CAT_GETDOC_TIME_ACCUMULATE
+    if (aDoc == NULL)
+        return;
+    QString secondrow = aDoc->excerpt();
+    QString firstrow;
+    HbListWidgetItem* listitem = new HbListWidgetItem();
+
+    if (aDoc->baseAppClass().contains("contact"))
+        {
+        QStringList docsList = filterDoc(aDoc, "GivenName", "FamilyName");
+        if (docsList.value(0, "").length())
+            {
+            firstrow.append(docsList.at(0));
+            }
+        if (docsList.value(1, "").length())
+            {
+            if (firstrow.length())
+                firstrow.append(" ");
+            firstrow.append(docsList.at(1));
+            }
+        if (firstrow.length() == 0)
+            {
+            firstrow = hbTrId("txt_phob_dblist_unnamed");
+            }
+        listitem->setData(mIconArray.at(0), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("audio"))
+        {
+        QStringList audioList = filterDoc(aDoc, "Title", "MediaId");
+        if (audioList.value(0, "").length())
+            {
+            firstrow.append(audioList.at(0));
+            }
+        if (firstrow.length() == 0)
+            {
+            firstrow = hbTrId("txt_mus_dblist_val_unknown4");
+            }
+        listitem->setData(mIconArray.at(1), Qt::DecorationRole);
+        if (audioList.value(1, "").length())
+            {
+            listitem->setData(audioList.at(1), Qt::UserRole + 2);
+            }
+        }
+    else if (aDoc->baseAppClass().contains("video"))
+        {
+        QStringList videoList = filterDoc(aDoc, "Title", "MediaId", "Name");
+        if (videoList.value(0, "").length())
+            {
+            firstrow.append(videoList.at(0));
+            }
+        if (firstrow.length() == 0 && videoList.value(2, "").length())
+            {
+            firstrow.append(videoList.at(2));
+            }
+        listitem->setData(mIconArray.at(2), Qt::DecorationRole);
+        if (videoList.value(1, "").length())
+            {
+            listitem->setData(videoList.at(1), Qt::UserRole + 2);
+            }
+        }
+    else if (aDoc->baseAppClass().contains("image"))
+        {
+        QStringList imageList = filterDoc(aDoc, "Name", "MediaId");
+        if (imageList.value(0, "").length())
+            {
+            firstrow.append(imageList.at(0));
+            }
+        listitem->setData(mIconArray.at(3), Qt::DecorationRole);
+        if (imageList.value(1, "").length())
+            {
+            listitem->setData(imageList.at(1), Qt::UserRole + 2);
+            }
+        }
+    else if (aDoc->baseAppClass().contains("msg email"))
+        {
+        QStringList emailList = filterDoc(aDoc, "Sender", "MailBoxId",
+                "FolderId");
+        firstrow.append(emailList.at(0));
+        listitem->setData(emailList.at(1), Qt::UserRole + 2);
+        listitem->setData(emailList.at(2), Qt::UserRole + 3);
+        listitem->setData(mIconArray.at(5), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("msg"))
+        {
+        QStringList msgList = filterDoc(aDoc, "Folder", "To", "From");
+        if (msgList.value(0).contains("Inbox"))
+            {
+            firstrow.append(msgList.at(2));
+            }
+        else
+            {
+            if (msgList.value(1, "").length())
+                firstrow.append(msgList.at(1));
+            }
+        listitem->setData(mIconArray.at(4), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("calendar"))
+        {
+        firstrow.append(filterDoc(aDoc, "Summary"));
+        if (firstrow.length() == 0)
+            {
+            firstrow = hbTrId("txt_calendar_preview_unnamed");
+            }
+        listitem->setData(mIconArray.at(6), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("notes"))
+        {
+        firstrow.append(filterDoc(aDoc, "Memo"));
+        if (firstrow.length() == 0)
+            {
+            firstrow = hbTrId("txt_notes_dblist_unnamed");
+            }
+        listitem->setData(mIconArray.at(7), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("applications"))
+        {
+        firstrow.append(filterDoc(aDoc, "Name"));
+        bool ok;
+        TRAP_IGNORE(listitem->setData(getAppIconFromAppIdL(TUid::Uid(aDoc->docId().toUInt(
+                                                &ok, 16))), Qt::DecorationRole));
+        }
+    else if (aDoc->baseAppClass().contains("bookmark"))
+        {
+        firstrow.append(filterDoc(aDoc, "Name"));
+        if (firstrow.length() == 0)
+            {
+            firstrow = "UnKnown";
+            }
+        listitem->setData(secondrow, Qt::UserRole + 2);
+        listitem->setData(mIconArray.at(8), Qt::DecorationRole);
+        }
+    else if (aDoc->baseAppClass().contains("file folder"))
+        {
+        bool ok;
+        QStringList fileList = filterDoc(aDoc, "Name", "IsFolder",
+                "Extension");
+        firstrow = fileList.at(0);
+        if (fileList.at(1).toInt(&ok) == 1) // folder result icon map 
+
+            {
+            listitem->setData(mIconArray.at(13), Qt::DecorationRole);
+            }
+        else
+            {
+            if (fileList.at(2).contains("sis", Qt::CaseInsensitive)
+                    || fileList.at(1).contains("sisx", Qt::CaseInsensitive))
+                {
+                listitem->setData(mIconArray.at(10), Qt::DecorationRole);
+                }
+            else if (fileList.at(2).contains("java", Qt::CaseInsensitive)
+                    || fileList.at(2).contains("jar", Qt::CaseInsensitive)
+                    || fileList.at(2).contains("jad", Qt::CaseInsensitive))
+                {
+                listitem->setData(mIconArray.at(11), Qt::DecorationRole);
+                }
+            else if (fileList.at(2).contains("swf", Qt::CaseInsensitive))
+                {
+                listitem->setData(mIconArray.at(12), Qt::DecorationRole);
+                }
+            else
+                {
+                listitem->setData(mIconArray.at(14), Qt::DecorationRole);
+                }
+            }
+        }
+    else if (aDoc->baseAppClass().contains("file"))
+        {
+        QStringList fileList = filterDoc(aDoc, "Name", "Extension");
+        firstrow = fileList.at(0);
+        if (firstrow.length() == 0)
+            firstrow = aDoc->baseAppClass();
+        if (fileList.at(1).contains("txt", Qt::CaseInsensitive))
+            {
+            listitem->setData(mIconArray.at(9), Qt::DecorationRole);
+            }
+        else
+            {
+            listitem->setData(mIconArray.at(14), Qt::DecorationRole);
+            }
+        }
+    listitem->setText(firstrow);
+    listitem->setSecondaryText(secondrow);
+    listitem->setData(aDoc->docId(), Qt::UserRole);
+    listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1);
+    mListView->addItem(listitem);
+
+    delete aDoc;
+    }
+
+InDeviceHandler* SearchProgressiveState::constructHandlers(int mDatabase)
+    {
+    InDeviceHandler* handler = NULL;
+    handler = new InDeviceHandler();
+    switch (mDatabase)
+        {
+        case 0:
+            {
+            handler->setCategory("");
+            break;
+            }
+        case 1:
+            {
+            handler->setCategory("contact");
+            break;
+            }
+        case 2:
+            {
+            handler->setCategory("media");
+            break;
+            }
+        case 3:
+            {
+            handler->setCategory("msg");
+            break;
+            }
+        case 4:
+            {
+            handler->setCategory("msg email");
+            break;
+            }
+        case 5:
+            {
+            handler->setCategory("calendar");
+            break;
+            }
+        case 6:
+            {
+            handler->setCategory("notes");
+            break;
+            }
+        case 7:
+            {
+            handler->setCategory("applications");
+            break;
+            }
+        case 8:
+            {
+            handler->setCategory("file");
+            break;
+            }
+        case 9:
+            {
+            // handler->setCategory("bookmark");
+            break;
+            }
+        case 10:
+            {
+            handler->setCategory("media image");
+            break;
+            }
+        case 11:
+            {
+            handler->setCategory("media audio");
+            break;
+            }
+        case 12:
+            {
+            handler->setCategory("media video");
+            break;
+            }
+        }
+    return handler;
+    }