logsui/logsengine/logssymbianos/src/logsstatebase.cpp
changeset 14 f27aebe284bb
equal deleted inserted replaced
11:64a47b97e1e1 14:f27aebe284bb
       
     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 // INCLUDE FILES
       
    19 #include "logsstatebase.h"
       
    20 #include "logsstatebasecontext.h"
       
    21 #include "logslogger.h"
       
    22 #include <logview.h>
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 // ----------------------------------------------------------------------------
       
    27 // LogsStateBase::LogsStateBase
       
    28 // ----------------------------------------------------------------------------
       
    29 //
       
    30 LogsStateBase::LogsStateBase(
       
    31     LogsStateBaseContext& context) 
       
    32  : mBaseContext(context),
       
    33    mNextState(0)
       
    34 {
       
    35 }
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // LogsStateBase::~LogsStateBase
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 LogsStateBase::~LogsStateBase()
       
    42 {
       
    43 
       
    44 }
       
    45 
       
    46 // ----------------------------------------------------------------------------
       
    47 // LogsReaderStateFiltering::setNextState
       
    48 // ----------------------------------------------------------------------------
       
    49 //
       
    50 void LogsStateBase::setNextState(LogsStateBase& nextState)
       
    51 {
       
    52     mNextState = &nextState;
       
    53 }
       
    54 
       
    55 // ----------------------------------------------------------------------------
       
    56 // LogsReaderStateFiltering::enterNextStateL
       
    57 // ----------------------------------------------------------------------------
       
    58 //
       
    59 bool LogsStateBase::enterNextStateL()
       
    60 {
       
    61     if ( mNextState ){
       
    62         mBaseContext.setCurrentState(*mNextState);
       
    63         return mNextState->enterL();
       
    64     }
       
    65     return false;
       
    66 }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // LogsStateBase::enterL
       
    70 // ----------------------------------------------------------------------------
       
    71 //
       
    72 bool LogsStateBase::enterL()
       
    73 {
       
    74     return false;
       
    75 }
       
    76 
       
    77 // ----------------------------------------------------------------------------
       
    78 // LogsStateBase::continueL
       
    79 // ----------------------------------------------------------------------------
       
    80 //
       
    81 bool LogsStateBase::continueL()
       
    82 {
       
    83     return false;
       
    84 }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // LogsStateBase::viewCount
       
    88 // ----------------------------------------------------------------------------
       
    89 //
       
    90 int LogsStateBase::viewCountL() const
       
    91     {
       
    92     return mBaseContext.logView().CountL();
       
    93     }
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // LogsStateBase::event
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 CLogEvent& LogsStateBase::event() const
       
   100     {
       
   101     //The RVCT compiler provides warnings "type qualifier on return type is meaningless"
       
   102     //for functions that return const values. In order to avoid these numerous warnings and 
       
   103     //const cascading, the CLogEvent is const_casted here.
       
   104     return const_cast<CLogEvent&>( mBaseContext.logView().Event() );
       
   105     }
       
   106 
       
   107 // ----------------------------------------------------------------------------
       
   108 // LogsStateBase::duplicatesL
       
   109 // ----------------------------------------------------------------------------
       
   110 //
       
   111 bool LogsStateBase::duplicatesL(const CLogFilter* aFilter){
       
   112     bool gettingDuplicates( false );
       
   113     if ( mBaseContext.isRecentView() ){
       
   114         if ( aFilter ){
       
   115             gettingDuplicates = 
       
   116                 static_cast<CLogViewRecent&>( mBaseContext.logView() ).DuplicatesL( 
       
   117                     mBaseContext.duplicatesView(), *aFilter, mBaseContext.reqStatus() ); 
       
   118         } else {
       
   119             gettingDuplicates = 
       
   120                 static_cast<CLogViewRecent&>( mBaseContext.logView() ).DuplicatesL( 
       
   121                     mBaseContext.duplicatesView(), mBaseContext.reqStatus() ); 
       
   122         }
       
   123     }
       
   124     return gettingDuplicates;
       
   125 }
       
   126 
       
   127 
       
   128 // ----------------------------------------------------------------------------
       
   129 // LogsStateSearchingEvent::LogsStateSearchingEvent
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 LogsStateSearchingEvent::LogsStateSearchingEvent(
       
   133     LogsStateBaseContext& context ) 
       
   134   : LogsStateBase(context)
       
   135 {
       
   136 }
       
   137 
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // LogsStateSearchingEvent::enterL
       
   141 // ----------------------------------------------------------------------------
       
   142 //
       
   143 bool LogsStateSearchingEvent::enterL()
       
   144 {
       
   145     LOGS_QDEBUG( "logs [ENG] -> LogsStateSearchingEvent::enterL" );
       
   146     if ( viewCountL() > 0 && mBaseContext.logView().FirstL( mBaseContext.reqStatus() ) ){
       
   147         return true;
       
   148     }    
       
   149     return enterNextStateL();    
       
   150 }
       
   151 
       
   152 
       
   153 // ----------------------------------------------------------------------------
       
   154 // LogsStateSearchingEvent::continueL
       
   155 // ----------------------------------------------------------------------------
       
   156 //
       
   157 bool LogsStateSearchingEvent::continueL()
       
   158 {
       
   159     LOGS_QDEBUG( "logs [ENG] -> LogsStateSearchingEvent::continueL" );
       
   160     int& index = mBaseContext.index();
       
   161     if ( event().Id() != mBaseContext.currentEventId() ) {
       
   162         index++;            
       
   163         if ( index < viewCountL() ){
       
   164             return mBaseContext.logView().NextL( mBaseContext.reqStatus() );
       
   165         }
       
   166     }
       
   167     
       
   168     return enterNextStateL();
       
   169 }