sdkcreationmw/sdkruntimes/MIDP/DebugAgent/src/JavaDebugAgentKeepAlive.cpp
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
#include <in_sock.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include <ip4_hdr.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include "JavaDebugAgentKeepAlive.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
// CJavaDebugAgentKeepAlive::CReceiver
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
class CJavaDebugAgentKeepAlive::CReceiver : public CActive
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
private:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
    RSocket* iSocket;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
    TSockXfrLength iLength;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
    TBuf8<1> iBuf;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
public:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
    CReceiver(RSocket* aSocket);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
    void Recv();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
    virtual void RunL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    virtual void DoCancel();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
CJavaDebugAgentKeepAlive::CReceiver::CReceiver(RSocket* aSocket) :
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
CActive(EPriorityStandard),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
iSocket(aSocket)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
{ 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
    CActiveScheduler::Add(this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
void CJavaDebugAgentKeepAlive::CReceiver::RunL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
    if (iStatus.Int() == KErrNone) Recv();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
void CJavaDebugAgentKeepAlive::CReceiver::DoCancel()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
    iSocket->CancelRead();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
void CJavaDebugAgentKeepAlive::CReceiver::Recv()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
    SetActive();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
    iStatus = KRequestPending;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    iSocket->RecvOneOrMore(iBuf, 0, iStatus, iLength);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
// CJavaDebugAgentKeepAlive
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
CJavaDebugAgentKeepAlive* 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
CJavaDebugAgentKeepAlive::NewL(RSocketServ* aSocketServ, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
                               const TSockAddr* aAddr,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
                               MJavaDebugAgentLog* aLog,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
                               TInt aPeriod)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
    CJavaDebugAgentKeepAlive* self = NewLC(aSocketServ, aAddr, aLog, aPeriod);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
    CleanupStack::Pop(self);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
    return self;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
CJavaDebugAgentKeepAlive* 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
CJavaDebugAgentKeepAlive::NewLC(RSocketServ* aSocketServ, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
                                const TSockAddr* aAddr,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
                                MJavaDebugAgentLog* aLog,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
                               TInt aPeriod)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
    CJavaDebugAgentKeepAlive* self = new(ELeave)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
        CJavaDebugAgentKeepAlive(aSocketServ, aAddr, aLog, aPeriod);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
    CleanupStack::PushL(self);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
    self->ConstructL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
    return self;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
CJavaDebugAgentKeepAlive::~CJavaDebugAgentKeepAlive()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
    Cancel();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
    delete iReceiver;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
    iSocket.Close();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
    iTimer.Close();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
CJavaDebugAgentKeepAlive::
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
CJavaDebugAgentKeepAlive(RSocketServ* aSocketServ,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
                         const TSockAddr* aAddr,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
                         MJavaDebugAgentLog* aLog,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
                         TInt aPeriodInMilliseconds) :
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
CActive(EPriorityStandard),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
iPeriod(aPeriodInMilliseconds*1000),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
iSocketServ(aSocketServ),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
iAddress(*aAddr),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
iLog(aLog)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
    CActiveScheduler::Add(this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
    iMsg.FillZ(iMsg.MaxLength());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
    iMsg[0] = KInet4ICMP_Echo;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
    iMsg[8] = 'P';
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
    iMsg[9] = 'I';
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
    iMsg[10] = 'N';
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
    iMsg[11] = 'G';
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
void CJavaDebugAgentKeepAlive::ConstructL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
    iReceiver = new(ELeave)CReceiver(&iSocket);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
    User::LeaveIfError(iTimer.CreateLocal());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
    User::LeaveIfError(iSocket.Open(*iSocketServ, KAfInet, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
        KSockDatagram, KProtocolInetIcmp));
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
    SetActive();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
    iStatus = KRequestPending;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
    iState = EConnecting;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
    iSocket.Connect(iAddress, iStatus);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
// CActive
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
void CJavaDebugAgentKeepAlive::RunL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
    TInt err = iStatus.Int();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
    switch (iState)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
    case EConnecting:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
        if (err == KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
            iReceiver->Recv();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
            Ping();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
            iState = EFailed;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
            iLog->LogFormat(_S("KeepAlive connect error %d"),err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
    case ESending:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
        if (err == KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
            Wait();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
            iState = EFailed;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
            iLog->LogFormat(_S("KeepAlive send error %d"),err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
    case EWaiting:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
        if (err == KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
            Ping();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
            iState = EFailed;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
            iLog->LogFormat(_S("KeepAlive wait error %d"),err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
void CJavaDebugAgentKeepAlive::Wait()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
    SetActive();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
    iStatus = KRequestPending;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
    iState = EWaiting;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
    iTimer.After(iStatus,iPeriod);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
void CJavaDebugAgentKeepAlive::Ping()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
    TUint16* ptr16 = ((TUint16*)&iMsg[0]);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
    ptr16[1] = 0;  // checksum
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
    iSeq++;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   185
    iMsg[6] = (TUint8)(iSeq >> 8); // convert to network byte order
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   186
    iMsg[7] = (TUint8)iSeq;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   187
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   188
    // Checksum is calculated in native byte order, and stored natively too
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   189
    TUint16 sum = 0;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   190
    for (TInt i=iMsg.Length()/2-1; i>=0; i--) sum += ptr16[i];
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   191
    ptr16[1] = ~sum;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   192
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   193
    // Send the message
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   194
    SetActive();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   195
    iStatus = KRequestPending;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   196
    iState = ESending;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   197
    iSocket.SendTo(iMsg, iAddress, 0, iStatus);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   198
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   199
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   200
TInt CJavaDebugAgentKeepAlive::RunError(TInt /*aError*/)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   201
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   202
    iState = EFailed;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   203
    return KErrNone;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   204
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   205
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   206
void CJavaDebugAgentKeepAlive::DoCancel()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   207
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   208
    TRequestStatus *status;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   209
    switch (iState)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   210
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   211
    case EConnecting:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   212
        iSocket.CancelConnect();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   213
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   214
    case ESending:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   215
        iSocket.CancelSend();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   216
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   217
    case EWaiting:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   218
        iTimer.Cancel();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   219
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   220
    default:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   221
		status = (&iStatus);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   222
		User::RequestComplete(status, KErrCancel);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   223
        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   224
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   225
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   226
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   227
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   228
 * Local Variables:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   229
 * c-basic-offset: 4
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   230
 * indent-tabs-mode: nil
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   231
 * End:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   232
 */