searchui/Searchapplication/src/Search.cpp
changeset 9 4a2987baf8f7
parent 8 2f67eb14d003
child 10 d05738f02936
equal deleted inserted replaced
8:2f67eb14d003 9:4a2987baf8f7
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Search application main class.
       
    15  *
       
    16  */
       
    17 
       
    18 #include "search.h"
       
    19 #include <qstatemachine.h>
       
    20 #include <searchruntimeprovider.h>
       
    21 #include <searchruntime.h>
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Search::Search
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 Search::Search(QObject* aParent) :
       
    28     QObject(aParent), mRuntime(NULL)
       
    29     {
       
    30     SEARCH_FUNC_ENTRY("SEARCH::Search::Search");
       
    31 
       
    32     SearchRuntimeProvider *interface = new SearchRuntimeProvider();
       
    33     mRuntime = interface->createPlugin();
       
    34     if (mRuntime)
       
    35         {
       
    36         mRuntime->setParent(this);
       
    37         connect(mRuntime, SIGNAL(started()), SLOT(handleRuntimeStarted()));
       
    38         connect(mRuntime, SIGNAL(stopped()), SLOT(handleRuntimeStopped()));
       
    39         connect(mRuntime, SIGNAL(faulted()), SLOT(handleRuntimeFaulted()));
       
    40         } 
       
    41 		SEARCH_FUNC_EXIT("SEARCH::Search::Search");
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Search::~Search()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 Search::~Search()
       
    49     {
       
    50     if (mRuntime)
       
    51         {
       
    52         disconnect(mRuntime, SIGNAL(started()), this,
       
    53                 SLOT(handleRuntimeStarted()));
       
    54         disconnect(mRuntime, SIGNAL(stopped()), this,
       
    55                 SLOT(handleRuntimeStopped()));
       
    56         disconnect(mRuntime, SIGNAL(faulted()), this,
       
    57                 SLOT(handleRuntimeFaulted()));
       
    58 
       
    59         delete mRuntime;
       
    60         }
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Search::start()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void Search::start()
       
    68     {
       
    69     SEARCH_FUNC_ENTRY("SEARCH::Search::start");
       
    70 
       
    71     if (mRuntime)
       
    72         {
       
    73         mRuntime->start();
       
    74         }
       
    75     else
       
    76         {
       
    77         emit exit();
       
    78         }
       
    79 
       
    80     SEARCH_FUNC_EXIT("SEARCH::Search::start");
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Search::stop()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void Search::stop()
       
    88     {
       
    89     SEARCH_FUNC_ENTRY("SEARCH::Search::stop");
       
    90     if (mRuntime)
       
    91         {
       
    92         mRuntime->stop();
       
    93         }
       
    94 
       
    95     SEARCH_FUNC_EXIT("SEARCH::Search::stop");
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Search::handleRuntimeStarted()
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void Search::handleRuntimeStarted()
       
   103     {
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Search::handleRuntimeStopped()
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void Search::handleRuntimeStopped()
       
   111     {
       
   112     emit exit();
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // Search::handleRuntimeFaulted()
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void Search::handleRuntimeFaulted()
       
   120     {
       
   121     emit exit();
       
   122     }