PECengine/PresenceManager2/SrcSearch/CPEngSearchControl.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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: this class handls search operation
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CPENGSEARCHCONTROL_H
       
    19 #define CPENGSEARCHCONTROL_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Base.h>
       
    23 #include <MPEngNWSessionSlotObserver2.h>
       
    24 
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MPEngSearchTransactionObserver2;
       
    28 class MPEngAdvTransactionStatus2;
       
    29 class CPEngSearchTransaction2;
       
    30 class CPEngSearchCriteria2;
       
    31 class CPEngSearchResultEntry;
       
    32 class CPEngNWSessionSlotID2;
       
    33 class CPEngTransactionStatus;
       
    34 class CPEngNWSessionSlot2;
       
    35 class CPEngSearchSessionHandler;
       
    36 class CPEngSearchHandler;
       
    37 class CPEngSearchTransaction2Imp;
       
    38 
       
    39 
       
    40 
       
    41 /**
       
    42  *
       
    43  *
       
    44  * @lib
       
    45  * @since 3.0
       
    46  */
       
    47 NONSHARABLE_CLASS( CPEngSearchControl ) : public CActive,
       
    48         public MPEngNWSessionSlotObserver2
       
    49     {
       
    50 private: //Enumerations
       
    51 
       
    52     /**
       
    53      * Search controls state enumerations.
       
    54      */
       
    55     enum TPEngSearchState
       
    56         {
       
    57         EPEngSrch_Idle = -1, //Idle state, no operation running
       
    58         EPEngSrch_OpeningCspSession = 1,
       
    59         EPEngSrch_Searching = 2,
       
    60         EPEngSrch_StoppingSearch = 4,
       
    61         EPEngSrch_ClosingCspSession = 5
       
    62         };
       
    63 
       
    64 
       
    65 public:  // Constructors and destructor
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      */
       
    70     static CPEngSearchControl* NewL( TInt aPriority,
       
    71                                      const CPEngNWSessionSlotID2& aNWSessionSlotID,
       
    72                                      const RPointerArray< CPEngSearchCriteria2 >& aCriterias,
       
    73                                      TInt aSearchLimit,
       
    74                                      MPEngSearchTransactionObserver2& aObserver );
       
    75 
       
    76     /**
       
    77      * Destructor.
       
    78      */
       
    79     virtual ~CPEngSearchControl();
       
    80 
       
    81 
       
    82 private:
       
    83 
       
    84     /**
       
    85      * C++ default constructor.
       
    86      */
       
    87     CPEngSearchControl( TInt aPriority,
       
    88                         MPEngSearchTransactionObserver2& aObserver );
       
    89 
       
    90     /**
       
    91      * Symbian OS constructor.
       
    92      */
       
    93     void ConstructL( TInt aPriority,
       
    94                      const CPEngNWSessionSlotID2& aNWSessionSlotID,
       
    95                      const RPointerArray< CPEngSearchCriteria2 >& aCriterias,
       
    96                      TInt aSearchLimit );
       
    97 
       
    98 
       
    99 
       
   100 
       
   101 public: //New services
       
   102 
       
   103 
       
   104     /**
       
   105      *
       
   106      *
       
   107      * @since 3.0
       
   108      */
       
   109     void SetOwner( CPEngSearchTransaction2Imp& aOwner );
       
   110 
       
   111 
       
   112     /**
       
   113      *
       
   114      *
       
   115      * @since 3.0
       
   116      */
       
   117     void Cancel();
       
   118 
       
   119 
       
   120     /**
       
   121      *
       
   122      *
       
   123      * @since 3.0
       
   124      */
       
   125     void IssueSearch();
       
   126 
       
   127 
       
   128     /**
       
   129      *
       
   130      *
       
   131      * @since 3.0
       
   132      */
       
   133     TInt IssueContinueSearchFromNetwork( TInt aContinueIndex );
       
   134 
       
   135 
       
   136     /**
       
   137      *
       
   138      *
       
   139      * @since 3.0
       
   140      */
       
   141     TInt IssueStopSearchFromNetwork();
       
   142 
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 
       
   148 private: //From CActive
       
   149 
       
   150     void DoCancel();
       
   151     void RunL();
       
   152     TInt RunError( TInt aError );
       
   153 
       
   154 private: //From MPEngNWSessionSlotObserver2
       
   155 
       
   156     /**
       
   157      * NWSessionSlot change handler.
       
   158      *
       
   159      * Called by CPEngNWSessionSlotNotifier2 to report NWSessionSlot
       
   160      * changed events. If this method leaves, error code is
       
   161      * reported back to HandleNWSessionSlotError().
       
   162      *
       
   163      * @since 3.0
       
   164      * @param aNotifier The notifier source where notification
       
   165      *        is coming from. No ownership transferred.
       
   166      * @param aEvent The event container.  No ownership transferred.
       
   167      */
       
   168     void HandleNWSessionSlotChangeL(
       
   169         CPEngNWSessionSlotNotifier2& aNotifier,
       
   170         CPEngNWSessionSlotEvent2& aEvent );
       
   171 
       
   172 
       
   173     /**
       
   174      * Notification failure handler.
       
   175      *
       
   176      * @since 3.0
       
   177      * @param aError The error resulting from Presence Engine internal
       
   178      *        change event handling (e.g. out of memory) or
       
   179      *        leave error from HandleNWSessionSlotChangeL().
       
   180      * @param aNotifier The notifier of which event handling failed.
       
   181      *        No ownership transferred.
       
   182      */
       
   183     void HandleNWSessionSlotError(
       
   184         TInt aError,
       
   185         CPEngNWSessionSlotNotifier2& aNotifier );
       
   186 
       
   187 
       
   188 
       
   189 private: //Helpers
       
   190 
       
   191     /**
       
   192      *
       
   193      *
       
   194      * @since 3.0
       
   195      */
       
   196     void AsyncTerminateSearch();
       
   197 
       
   198 
       
   199     /**
       
   200      *
       
   201      *
       
   202      * @since 3.0
       
   203      */
       
   204     void ValidateSearchCriteriasL(
       
   205         const RPointerArray< CPEngSearchCriteria2 >& aCriterias );
       
   206 
       
   207 
       
   208     /**
       
   209      *
       
   210      *
       
   211      * @since 3.0
       
   212      */
       
   213     void DoNotifyObserver( TInt aErr );
       
   214 
       
   215     /**
       
   216      *
       
   217      *
       
   218      * @since 3.0
       
   219      */
       
   220     void HandleStepIssued( TPEngSearchState aState, TInt aErr );
       
   221 
       
   222 
       
   223 
       
   224 private: //Data
       
   225 
       
   226 
       
   227     //REF: The observer
       
   228     MPEngSearchTransactionObserver2&     iObserver;
       
   229 
       
   230     //REF: The owning transaction
       
   231     CPEngSearchTransaction2Imp*     iOwner;
       
   232 
       
   233     //OWN: Result data, transaction status
       
   234     CPEngTransactionStatus*     iTransactionStatus;
       
   235 
       
   236     //OWN: Result data, search result
       
   237     CPEngSearchResultEntry*     iSearchResult;
       
   238 
       
   239     //OWN: Result data, current operation
       
   240     TInt    iTransactionOp;
       
   241 
       
   242     //OWN: Search session handler
       
   243     CPEngSearchSessionHandler*  iSearchSessionHandler;
       
   244 
       
   245     //OWN: Search session handler
       
   246     CPEngSearchHandler*     iSearchHandler;
       
   247 
       
   248     //OWN: Session notifier
       
   249     CPEngNWSessionSlotNotifier2*    iSlotNotifier;
       
   250 
       
   251     //OWN: Cancel ongoing flag
       
   252     TBool   iCancelling;
       
   253 
       
   254     //OWN: Current state
       
   255     TPEngSearchState    iSearchState;
       
   256 
       
   257     //OWN: Delayed error
       
   258     TInt    iDelayedErr;
       
   259 
       
   260     };
       
   261 
       
   262 #endif      //CPENGSEARCHCONTROL_H
       
   263 
       
   264 
       
   265 
       
   266