logsui/logsengine/logssymbianos/inc/logsreaderstates.h
changeset 0 4a5361db8937
child 9 68f3171a5819
equal deleted inserted replaced
-1:000000000000 0:4a5361db8937
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef LOGSREADERSTATES_H
       
    19 #define LOGSREADERSTATES_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <logclientchangeobserver.h>
       
    24 #include <logviewchangeobserver.h>
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 class LogsReaderStateContext;
       
    28 class LogsEvent;
       
    29 class CLogViewEvent;
       
    30 class CLogFilterList;
       
    31 class CLogFilter;
       
    32 class CLogEvent;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  * Reader state base
       
    38  */
       
    39 class LogsReaderStateBase {
       
    40 
       
    41     friend class UT_LogsReaderStates;
       
    42     friend class UT_LogsReader;
       
    43     
       
    44     public:
       
    45         
       
    46         /**
       
    47          * Destructor
       
    48          */
       
    49         virtual ~LogsReaderStateBase();
       
    50         
       
    51         /**
       
    52          * Set next state to be used once this state has completed.
       
    53          * @param nextState
       
    54          */
       
    55         void setNextState(LogsReaderStateBase& nextState);
       
    56 
       
    57         /**
       
    58          * Enter to the state, may proceed immediately to next state.
       
    59          * @return true if entering started async operation,  false if not
       
    60          */
       
    61         virtual bool enterL();
       
    62         
       
    63         /**
       
    64          * Continue running in the state, may proceed to next state
       
    65          * @return true if continue started async operation,  false if not
       
    66          */
       
    67         virtual bool continueL();
       
    68     
       
    69     protected:
       
    70         
       
    71         /**
       
    72          * Constructor
       
    73          */
       
    74         LogsReaderStateBase(LogsReaderStateContext& context);
       
    75         
       
    76         /**
       
    77          * Proceed to next state if such exists.
       
    78          * @return true if entering started async operation,  false if not 
       
    79          */
       
    80         virtual bool enterNextStateL();
       
    81         
       
    82         /**
       
    83          * Get number of events in view
       
    84          * @return view count
       
    85          */
       
    86         int viewCountL() const;
       
    87         
       
    88         /**
       
    89          * Get current event
       
    90          * @return event
       
    91          */
       
    92         CLogEvent& event() const;
       
    93         
       
    94         /**
       
    95          * Fill dest event with source event data and insert to specified
       
    96          * place in events list.
       
    97          * @param source event 
       
    98          * @param dest event, ownership is transferred
       
    99          * @param index, increased if event was added
       
   100          * @param events, event is possibly added to this list
       
   101          * @return true if dest event was inserted, false if discarded and deleted
       
   102          */
       
   103         bool constructAndInsertEventL(
       
   104                 const CLogEvent& source, LogsEvent* dest, int &eventIndex, QList<LogsEvent*>& events );
       
   105         
       
   106         /**
       
   107          * Fill already used dest event with source event data and insert
       
   108          * to specified place in events list.
       
   109          * @param source event 
       
   110          * @param dest event, ownership is transferred
       
   111          * @param index, increased if event was added
       
   112          * @return true if dest event was inserted, false if discarded and deleted
       
   113          */
       
   114         bool updateAndInsertEventL(
       
   115                 const CLogEvent& source, LogsEvent* dest, int &eventIndex );
       
   116         
       
   117         /**
       
   118          * Reset current events
       
   119          */
       
   120         void resetEvents();
       
   121         
       
   122         /**
       
   123          * Try to find matching event and remove it from
       
   124          * events list.
       
   125          * @param event, symbian log event
       
   126          * @return LogsEvent or 0 if no matching found, ownership is transferred
       
   127          */
       
   128         LogsEvent* takeMatchingEvent(const CLogEvent& event);
       
   129         
       
   130         /**
       
   131          * Finds specified event from the event list. Event not removed from the list.
       
   132          * @param eventId, id of the event to be found
       
   133          * @return pointer to event or 0 if not found
       
   134          */
       
   135         LogsEvent* eventById(int eventId);
       
   136         
       
   137         /**
       
   138          * Try to search duplicates for current event in the view
       
   139          * @param aFilter, filter to be used for searching duplicates
       
   140          * @return true, if duplicates are searched
       
   141          */
       
   142         bool duplicatesL(const CLogFilter* aFilter = 0);
       
   143 
       
   144     protected:   
       
   145         LogsReaderStateContext& mContext;
       
   146         LogsReaderStateBase* mNextState;
       
   147         int mStateIndex;
       
   148 };
       
   149 
       
   150 /**
       
   151  * Initialize reading state
       
   152  */
       
   153 class LogsReaderStateInitReading : public LogsReaderStateBase {
       
   154 
       
   155      friend class UT_LogsReaderStates;
       
   156      
       
   157     public:
       
   158      LogsReaderStateInitReading(LogsReaderStateContext& context);
       
   159         virtual ~LogsReaderStateInitReading(){}
       
   160 
       
   161     public: // From LogsReaderStateBase
       
   162         virtual bool enterL();
       
   163  };
       
   164 
       
   165 /**
       
   166  * Filtering recent state
       
   167  */
       
   168 class LogsReaderStateFiltering : public LogsReaderStateBase {
       
   169 
       
   170      friend class UT_LogsReaderStates;
       
   171      
       
   172     public:
       
   173         LogsReaderStateFiltering(LogsReaderStateContext& context);
       
   174         virtual ~LogsReaderStateFiltering();
       
   175 
       
   176     public: // From LogsReaderStateBase
       
   177         virtual bool enterL();
       
   178         virtual bool continueL();
       
   179     
       
   180     protected:
       
   181         /**
       
   182          * Setting filter for view, derived class may add special filtering
       
   183          * at this stage.
       
   184          */
       
   185         virtual bool setFilterL(CLogFilterList& filterList);
       
   186         
       
   187     protected:
       
   188         CLogFilterList* mFilterList;
       
   189  };
       
   190 
       
   191 /**
       
   192  * Filtering all state
       
   193  */
       
   194 class LogsReaderStateFilteringAll : public LogsReaderStateFiltering {
       
   195 
       
   196      friend class UT_LogsReaderStates;
       
   197      
       
   198     public:
       
   199         LogsReaderStateFilteringAll(LogsReaderStateContext& context);
       
   200         virtual ~LogsReaderStateFilteringAll();
       
   201 
       
   202     protected: // From LogsReaderStateFiltering
       
   203         virtual bool setFilterL(CLogFilterList& filterList);
       
   204  };
       
   205 
       
   206 /**
       
   207  * Reading state
       
   208  */
       
   209 class LogsReaderStateReading : public LogsReaderStateBase {
       
   210 
       
   211     friend class UT_LogsReaderStates;
       
   212     
       
   213     public:
       
   214         LogsReaderStateReading(LogsReaderStateContext& context);
       
   215         virtual ~LogsReaderStateReading();
       
   216 
       
   217     public: // From LogsReaderStateBase
       
   218         virtual bool enterL();
       
   219         virtual bool continueL();
       
   220     
       
   221     protected:
       
   222         bool handleMissedL(LogsEvent& parsedEvent);
       
   223         void updateReadSizeCounter(LogsEvent& event);
       
   224         bool canContinueReadingL(int index) const;     
       
   225         
       
   226     protected:
       
   227         CLogFilter* mDuplicateMissedFilter;
       
   228         bool mCheckingMissed;
       
   229         int mEventIndex;
       
   230         int mReadSizeCounter;
       
   231 };
       
   232 
       
   233 /**
       
   234  * Fill missing information state
       
   235  */
       
   236 class LogsReaderStateFillDetails : public LogsReaderStateBase {
       
   237     public:
       
   238         LogsReaderStateFillDetails(LogsReaderStateContext& context);
       
   239         virtual ~LogsReaderStateFillDetails();
       
   240         
       
   241         /**
       
   242          * Synchronously fills details from phonebook
       
   243          */
       
   244         void fillDetails(); 
       
   245         
       
   246     public: // From LogsReaderStateBase
       
   247         virtual bool enterL();
       
   248 };
       
   249 
       
   250 /**
       
   251  * Completed state
       
   252  */
       
   253 class LogsReaderStateDone : public LogsReaderStateBase {
       
   254     public:
       
   255         LogsReaderStateDone(LogsReaderStateContext& context);
       
   256         virtual ~LogsReaderStateDone();
       
   257         
       
   258     public: // From LogsReaderStateBase
       
   259         virtual bool enterL();
       
   260 };
       
   261 
       
   262 
       
   263 /**
       
   264  * Searching event state
       
   265  */
       
   266 class LogsReaderStateSearchingEvent : public LogsReaderStateBase 
       
   267 {
       
   268     friend class UT_LogsReaderStates;
       
   269     
       
   270     public:
       
   271         LogsReaderStateSearchingEvent(LogsReaderStateContext& context);
       
   272         virtual ~LogsReaderStateSearchingEvent(){}
       
   273 
       
   274     public: // From LogsReaderStateBase
       
   275         virtual bool enterL();
       
   276         virtual bool continueL();
       
   277 };
       
   278 
       
   279 /**
       
   280  * Finding duplicate events state
       
   281  */
       
   282 class LogsReaderStateFindingDuplicates : public LogsReaderStateBase 
       
   283 {
       
   284     friend class UT_LogsReaderStates;
       
   285     
       
   286     public:
       
   287         LogsReaderStateFindingDuplicates(LogsReaderStateContext& context);
       
   288         virtual ~LogsReaderStateFindingDuplicates();
       
   289 
       
   290     public: // From LogsReaderStateBase
       
   291         virtual bool enterL();  
       
   292         virtual bool continueL();
       
   293         
       
   294     protected:
       
   295         CLogFilter* mDuplicateFilter;
       
   296 };
       
   297 
       
   298 /**
       
   299  * Marking duplicate events state
       
   300  */
       
   301 class LogsReaderStateMarkingDuplicates : public LogsReaderStateBase 
       
   302 {
       
   303     friend class UT_LogsReaderStates;
       
   304     
       
   305     public:
       
   306         LogsReaderStateMarkingDuplicates(LogsReaderStateContext& context);
       
   307         virtual ~LogsReaderStateMarkingDuplicates(){}
       
   308 
       
   309     public: // From LogsReaderStateBase
       
   310         virtual bool enterL();
       
   311         virtual bool continueL(); 
       
   312         
       
   313     protected:
       
   314         bool mGettingDuplicates;
       
   315 };
       
   316 
       
   317 /**
       
   318  * Marking duplicate events state
       
   319  */
       
   320 class LogsReaderStateReadingDuplicates : public LogsReaderStateBase 
       
   321 {
       
   322     friend class UT_LogsReaderStates;
       
   323     
       
   324     public:
       
   325         LogsReaderStateReadingDuplicates(LogsReaderStateContext& context);
       
   326         virtual ~LogsReaderStateReadingDuplicates(){}
       
   327 
       
   328     public: // From LogsReaderStateBase
       
   329         virtual bool enterL();   
       
   330         virtual bool continueL();
       
   331 };
       
   332 
       
   333 /**
       
   334  * Modifying done state
       
   335  */
       
   336 class LogsReaderStateModifyingDone : public LogsReaderStateBase 
       
   337 {
       
   338     friend class UT_LogsReaderStates;
       
   339     
       
   340     public:
       
   341         LogsReaderStateModifyingDone(LogsReaderStateContext& context);
       
   342         virtual ~LogsReaderStateModifyingDone(){}
       
   343 
       
   344     public: // From LogsReaderStateBase
       
   345         virtual bool enterL();
       
   346 };
       
   347 
       
   348 /**
       
   349  * Reading duplicates done state
       
   350  */
       
   351 class LogsReaderStateReadingDuplicatesDone : public LogsReaderStateBase 
       
   352 {
       
   353     friend class UT_LogsReaderStates;
       
   354     
       
   355     public:
       
   356         LogsReaderStateReadingDuplicatesDone(LogsReaderStateContext& context);
       
   357         virtual ~LogsReaderStateReadingDuplicatesDone(){}
       
   358 
       
   359     public: // From LogsReaderStateBase
       
   360         virtual bool enterL();
       
   361 };
       
   362 
       
   363 
       
   364 
       
   365 #endif      // LOGSREADERSTATES_H
       
   366 
       
   367 
       
   368 // End of File
       
   369       
       
   370 
       
   371         
       
   372