14
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// csockethandler.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
/**
|
|
18 |
@file
|
|
19 |
@internalTechnology
|
|
20 |
*/
|
|
21 |
#ifndef __CSOCKETHANDLER_H__
|
|
22 |
#define __CSOCKETHANDLER_H__
|
|
23 |
|
|
24 |
//System include
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <in_sock.h>
|
|
27 |
#include <es_mbuf.h>
|
|
28 |
|
|
29 |
|
|
30 |
//User include
|
|
31 |
#include "msockethandlerobserver.h"
|
|
32 |
#include "mdnsdebug.h"
|
|
33 |
|
|
34 |
/*
|
|
35 |
1. This is an Active Object which can be activated to recieve or
|
|
36 |
send asynchronusly as per the operation list mentioned.An Observer should be
|
|
37 |
provided at the time of construction so as to notify the success or failure of
|
|
38 |
opertion.The client using CSocketHandler should implement the observer class
|
|
39 |
MSOcketHandlerObserver.
|
|
40 |
|
|
41 |
2. Maximum size of the packet this could either send or recieve is KMaxDnsPacketSize = 9216
|
|
42 |
|
|
43 |
3. TSocketHandlerParams-- This is typedef from TIpcArgs ,which can hold an
|
|
44 |
pointer to an array of four variables.
|
|
45 |
a. The first variable it is pointing to should specify the operation(TSocketOPeration).
|
|
46 |
b. Second should provide the packet to be send .
|
|
47 |
c. Third should provide the address to which it should be send.
|
|
48 |
|
|
49 |
|
|
50 |
*/
|
|
51 |
|
|
52 |
const TInt KDefaultFlags = 0;
|
|
53 |
//const TInt KMaxDnsPacketSize = 9216;
|
|
54 |
|
|
55 |
enum TSocketOperation
|
|
56 |
{
|
|
57 |
ESocketIdle,
|
|
58 |
ESocketSend,
|
|
59 |
ESocketSendTo,
|
|
60 |
ESocketRecieve,
|
|
61 |
ESocketRecieveFrom,
|
|
62 |
};
|
|
63 |
|
|
64 |
typedef TIpcArgs TSocketHandlerParams;
|
|
65 |
|
|
66 |
class CSocketHandler : public CActive
|
|
67 |
{
|
|
68 |
public:
|
|
69 |
|
|
70 |
static CSocketHandler* NewL(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation);
|
|
71 |
void Activate ( const TSocketHandlerParams& aParams );
|
|
72 |
~CSocketHandler();
|
|
73 |
|
|
74 |
private:
|
|
75 |
CSocketHandler(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation);
|
|
76 |
void ConstructL();
|
|
77 |
void CompleteSelf ( TInt aError );
|
|
78 |
void CancelCurrent();
|
|
79 |
void NotifyCompletionL( );
|
|
80 |
|
|
81 |
//Derived from CActive
|
|
82 |
void RunL();
|
|
83 |
void DoCancel();
|
|
84 |
TInt RunError(TInt aError);
|
|
85 |
|
|
86 |
private:
|
|
87 |
HBufC8* iPacketBuffer;
|
|
88 |
TPtr8 iPacketPtr;
|
|
89 |
TSockAddr iSockAddr;
|
|
90 |
TSocketOperation iOperation;
|
|
91 |
RSocket& iSocket;
|
|
92 |
MSocketHandlerObserver& iObserver;
|
|
93 |
TSockXfrLength iLength;
|
|
94 |
/**
|
|
95 |
*FLOGGER debug trace member variable.
|
|
96 |
*/
|
|
97 |
__FLOG_DECLARATION_MEMBER_MUTABLE;
|
|
98 |
};
|
|
99 |
|
|
100 |
#endif
|
|
101 |
|