keepalive/flextimer/test/testflextimer/flextimerservermonitor/src/flextimerservermonitorsession.cpp
author hgs
Mon, 24 May 2010 20:51:35 +0300
changeset 32 5c4486441ae6
permissions -rw-r--r--
201021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:
hgs
parents:
diff changeset
    15
 *      Session implementation for FlexTimerServerMonitor server
hgs
parents:
diff changeset
    16
 *
hgs
parents:
diff changeset
    17
 */
hgs
parents:
diff changeset
    18
/*
hgs
parents:
diff changeset
    19
 * %version: 1 %
hgs
parents:
diff changeset
    20
 */
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
// System include files
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
// User include files go here:
hgs
parents:
diff changeset
    25
#include <rflextimer.h>
hgs
parents:
diff changeset
    26
#include "flextimerservermonitorsession.h"
hgs
parents:
diff changeset
    27
#include "flextimerservermonitorcommon.h"
hgs
parents:
diff changeset
    28
#include "flextimerservermonitorserver.h"
hgs
parents:
diff changeset
    29
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    30
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    31
#include "flextimerservermonitorsessionTraces.h"
hgs
parents:
diff changeset
    32
#endif
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// Constants
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
// ======== MEMBER FUNCTIONS ========
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    39
// Constructor
hgs
parents:
diff changeset
    40
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    41
//
hgs
parents:
diff changeset
    42
CFlexTimerServerMonitorSession::CFlexTimerServerMonitorSession()
hgs
parents:
diff changeset
    43
    {
hgs
parents:
diff changeset
    44
    }
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    47
// Destructor
hgs
parents:
diff changeset
    48
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    49
//
hgs
parents:
diff changeset
    50
CFlexTimerServerMonitorSession::~CFlexTimerServerMonitorSession()
hgs
parents:
diff changeset
    51
    {
hgs
parents:
diff changeset
    52
    }
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    55
// 2nd phase constructor
hgs
parents:
diff changeset
    56
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    57
//
hgs
parents:
diff changeset
    58
void CFlexTimerServerMonitorSession::ConstructL()
hgs
parents:
diff changeset
    59
    {
hgs
parents:
diff changeset
    60
    }
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    63
// Two-phased constructor
hgs
parents:
diff changeset
    64
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    65
//
hgs
parents:
diff changeset
    66
CFlexTimerServerMonitorSession* CFlexTimerServerMonitorSession::NewL()
hgs
parents:
diff changeset
    67
    {
hgs
parents:
diff changeset
    68
    CFlexTimerServerMonitorSession* self =
hgs
parents:
diff changeset
    69
            new (ELeave) CFlexTimerServerMonitorSession();
hgs
parents:
diff changeset
    70
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    71
    self->ConstructL();
hgs
parents:
diff changeset
    72
    CleanupStack::Pop( self );
hgs
parents:
diff changeset
    73
    return self;
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// Handle clients' requests. Due the request implementations are simple
hgs
parents:
diff changeset
    78
// the actions are done in ServiceL and not dispatched to separate functions.
hgs
parents:
diff changeset
    79
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    80
//
hgs
parents:
diff changeset
    81
void CFlexTimerServerMonitorSession::ServiceL( const RMessage2& aMessage )
hgs
parents:
diff changeset
    82
    {
hgs
parents:
diff changeset
    83
    // This ain't the most elegant solution but here we go.
hgs
parents:
diff changeset
    84
    //
hgs
parents:
diff changeset
    85
    // Passing the server's reference as a parameter during session creation 
hgs
parents:
diff changeset
    86
    // would be another solution.
hgs
parents:
diff changeset
    87
    CFlexTimerServerMonitorServer* server = 
hgs
parents:
diff changeset
    88
        static_cast<CFlexTimerServerMonitorServer*>( 
hgs
parents:
diff changeset
    89
            const_cast<CServer2*>( Server() ) );
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
    // Dispatch and execute the client's request
hgs
parents:
diff changeset
    92
    switch ( aMessage.Function() )
hgs
parents:
diff changeset
    93
        {
hgs
parents:
diff changeset
    94
        case EFlexTimerServerMonitorStartMonitoring:
hgs
parents:
diff changeset
    95
            {
hgs
parents:
diff changeset
    96
            aMessage.Complete( server->StartMonitoring() );
hgs
parents:
diff changeset
    97
            break;
hgs
parents:
diff changeset
    98
            }
hgs
parents:
diff changeset
    99
        case EFlexTimerServerMonitorHasServerCrashed:
hgs
parents:
diff changeset
   100
            {
hgs
parents:
diff changeset
   101
            TBool hasCrashed;
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
            TInt ret = server->GetStatus( hasCrashed );
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
            TPckgBuf<TBool> pckg( hasCrashed );
hgs
parents:
diff changeset
   106
            aMessage.WriteL( 0, pckg );
hgs
parents:
diff changeset
   107
            aMessage.Complete( ret );
hgs
parents:
diff changeset
   108
            break;
hgs
parents:
diff changeset
   109
            }
hgs
parents:
diff changeset
   110
        case EFlexTimerServerMonitorStopMonitoring:
hgs
parents:
diff changeset
   111
            {
hgs
parents:
diff changeset
   112
            aMessage.Complete( server->StopMonitoring() );
hgs
parents:
diff changeset
   113
            break;
hgs
parents:
diff changeset
   114
            }
hgs
parents:
diff changeset
   115
        default:
hgs
parents:
diff changeset
   116
            aMessage.Complete( KErrNotSupported );
hgs
parents:
diff changeset
   117
        }
hgs
parents:
diff changeset
   118
    }