|
1 // wsp_resolver.h |
|
2 // |
|
3 // Copyright (c) 2002 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #ifndef __WSP_RESOLVER_H__ |
|
14 #define __WSP_RESOLVER_H__ |
|
15 |
|
16 #include <es_sock.h> |
|
17 #include <es_prot.h> |
|
18 #include "wsp_subsession.h" |
|
19 |
|
20 |
|
21 class RWin32Factory; |
|
22 class TInetAddr; |
|
23 |
|
24 |
|
25 class RWin32Resolver : public RWin32SubSession |
|
26 { |
|
27 public: |
|
28 RWin32Resolver(); |
|
29 TInt Open(RWin32Factory& aFactory); |
|
30 void Close(); |
|
31 TInt GetByName(TNameRecord& aName, TRequestStatus& aStatus); |
|
32 TInt GetByAddress(TNameRecord& aName, TRequestStatus& aStatus); |
|
33 void Cancel(); |
|
34 private: |
|
35 TPtr8 iNameRecordPckg; |
|
36 }; |
|
37 |
|
38 |
|
39 class CWin32Resolver : public CWin32SubSession |
|
40 { |
|
41 public: |
|
42 enum TOppCode |
|
43 { |
|
44 EGetByName, |
|
45 EGetByAddress, |
|
46 ECancel |
|
47 }; |
|
48 public: |
|
49 static CWin32Resolver* NewL(CWin32Scheduler& aScheduler); |
|
50 virtual ~CWin32Resolver(); |
|
51 private: // From CWin32ActiveObject. |
|
52 virtual void Run(); |
|
53 private: // From CWin32SubSession. |
|
54 virtual void ServiceL(TWin32Message& aMessage); |
|
55 private: |
|
56 CWin32Resolver(CWin32Scheduler& aScheduler); |
|
57 void ConstructL(); |
|
58 void Cancel(); |
|
59 void CreateWorkerThread(); |
|
60 private: // Methods used by the worker thread. |
|
61 static TInt WorkerThreadStart(TAny* aPtr); |
|
62 void GetByName(); |
|
63 void GetByAddress(); |
|
64 private: |
|
65 TWin32Message* iMessage; |
|
66 RThread iWorkerThread; // Synchronous name lookup calls are run in their own thread. |
|
67 // This is because the asychronous versions use window messages rather event object, and so can't fit into this framework. |
|
68 TInt iError; |
|
69 TInt64 iRandSeed; |
|
70 }; |
|
71 |
|
72 |
|
73 class MWin32ResolverObserver |
|
74 { |
|
75 public: |
|
76 virtual void HandleWin32ResolverCompletion(TInt aError) = 0; |
|
77 }; |
|
78 |
|
79 |
|
80 class CWin32ResolverWrapper : public CActive |
|
81 { |
|
82 public: |
|
83 static CWin32ResolverWrapper* NewL(MWin32ResolverObserver& aObserver, RWin32Factory& aWin32Factory); |
|
84 ~CWin32ResolverWrapper(); |
|
85 TInt GetByName(TNameRecord& aName); |
|
86 TInt GetByAddress(TNameRecord& aName); |
|
87 private: // From CActive. |
|
88 virtual void DoCancel(); |
|
89 virtual void RunL(); |
|
90 virtual TInt RunError(TInt aError); |
|
91 public: |
|
92 CWin32ResolverWrapper(MWin32ResolverObserver& aObserver); |
|
93 void ConstructL(RWin32Factory& aWin32Factory); |
|
94 private: |
|
95 MWin32ResolverObserver& iObserver; |
|
96 RWin32Resolver iWin32Resolver; |
|
97 }; |
|
98 |
|
99 |
|
100 class CWinSockResolver : public CHostResolvProvdBase, public MWin32ResolverObserver |
|
101 { |
|
102 public: |
|
103 static CWinSockResolver* NewL(RWin32Factory& aFactory); |
|
104 virtual ~CWinSockResolver(); |
|
105 private: // From CResolverProvdBase. |
|
106 virtual void CancelCurrentOperation(); |
|
107 private: // From CHostResolvProvdBase. |
|
108 virtual void GetByName(TNameRecord& aName); |
|
109 virtual void GetByAddress(TNameRecord& aName); |
|
110 virtual void SetHostName(TDes& aNameBuf); |
|
111 virtual void GetHostName(TDes& aNameBuf); |
|
112 private: // From MWin32ResolverObserver. |
|
113 virtual void HandleWin32ResolverCompletion(TInt aError); |
|
114 private: |
|
115 CWinSockResolver(); |
|
116 void ConstructL(RWin32Factory& aFactory); |
|
117 private: |
|
118 CWin32ResolverWrapper* iResolverWrapper; |
|
119 }; |
|
120 |
|
121 |
|
122 #endif // __WSP_RESOLVER_H__ |