sdkcreationmw/sdkruntimes/MIDP/DebugAgent/src/JavaDebugAgentDriver.h
author rajpuroh
Mon, 08 Mar 2010 12:09:11 +0530
changeset 0 b26acd06ea60
permissions -rw-r--r--
First Contribution of SDK components
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#ifndef __JAVA_DEBUG_AGENT_DRIVER_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#define __JAVA_DEBUG_AGENT_DRIVER_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include <es_sock.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#include "Driver.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
#include "JavaDebugAgentKeepAlive.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
class CTcpServer;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
class CTcpServerHandler;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
class MJavaDebugAgentLog;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
class MJavaDebugAgentObserver;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
class CJavaDebugAgentConnector;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
class CJavaDebugAgentDriver : public CDriver
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
public:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    enum TState {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
        EIdle,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
        EConnecting,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
        EListening,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
        EConnected,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
        EDisconnected,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
        EDeleted
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
    };
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
private:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
    RFs iFs;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
    RSocketServ iSocketServ;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
    CAgentEngine* iEngine;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
    CTcpServer* iServer;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
    CAsyncCallBack* iAsyncCleanup;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
    RPointerArray<CTcpServerHandler> iHandlers;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
    RPointerArray<CTcpServerHandler> iDeadHandlers;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
    RPointerArray<CJavaDebugAgentKeepAlive> iKeepAliveList;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
    MJavaDebugAgentLog* iLog;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
    MJavaDebugAgentObserver* iObserver;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    CJavaDebugAgentConnector* iConnector;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
    TInt iApId;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
    TInt iKeepAlivePeriod; // in milliseconds
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
    TState iState;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
public:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
    static CJavaDebugAgentDriver* NewLC(MJavaDebugAgentLog* aLog);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
    static CJavaDebugAgentDriver* NewL(MJavaDebugAgentLog* aLog);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    ~CJavaDebugAgentDriver();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    void StartListeningL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
    void ConnectL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
    void SetObserver(MJavaDebugAgentObserver* aObserver);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
    MJavaDebugAgentLog* Log();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
    RSocketServ& SocketServ();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
    TState State() const;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
    // Access to parameters not defined in the base class
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
    TInt ApId() const;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
    TInt KeepAlivePeriod() const;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
    void SetApId(TInt aApId);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    void SetKeepAlivePeriod(TInt aMilliSeconds);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
    // Notification from CJavaDebugAgentConnector
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
    void ConnectionFailed();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
    // CDriver
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
    virtual void InitL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
    virtual void Log(const TDesC& aString);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
    virtual void Message(const TDesC& aString);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
    virtual RFs& Fs();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
    virtual CAgentEngine* Engine();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
    virtual void Shutdown();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
    virtual void SettingsChange();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
    // Notifications from CTcpServerHandler
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
    virtual void ClientConnected(CTcpServerHandler* aHandler);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
	virtual void ClientDisconnected(CTcpServerHandler* aHandler);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
private:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
    void ConstructL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
    CJavaDebugAgentDriver(MJavaDebugAgentLog* aLog);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
    TBool CheckIfIdle() const;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
    void SetState(TState aState);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
    void InitKeepAliveL(const TSockAddr* aRemoteAddr);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
    void DeleteConnector();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
    static TInt AsyncCleanup(TAny* aThis);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
// Observer interface
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
class MJavaDebugAgentObserver
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
public:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
    virtual void StateChanged(CJavaDebugAgentDriver::TState aState) = 0;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
// INLINE METHODS
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
inline MJavaDebugAgentLog* CJavaDebugAgentDriver::Log()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
    { return iLog; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
inline RSocketServ& CJavaDebugAgentDriver::SocketServ()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
    { return iSocketServ; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
inline TInt CJavaDebugAgentDriver::ApId() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
    { return iApId; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
inline TInt CJavaDebugAgentDriver::KeepAlivePeriod() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
    { return iKeepAlivePeriod; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
inline void CJavaDebugAgentDriver::SetApId(TInt aApId)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
    { iApId = aApId; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
inline void CJavaDebugAgentDriver::SetKeepAlivePeriod(TInt aMilliSeconds)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
    { iKeepAlivePeriod = aMilliSeconds; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
inline void CJavaDebugAgentDriver::SetObserver(MJavaDebugAgentObserver* aObserver)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
    { iObserver = aObserver; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
inline CJavaDebugAgentDriver::TState CJavaDebugAgentDriver::State() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
    { return iState; }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
#endif // __JAVA_DEBUG_AGENT_DRIVER_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
 * Local Variables:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
 * mode: c++
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
 * c-basic-offset: 4
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
 * indent-tabs-mode: nil
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
 * End:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
 */