1 // Copyright (c) 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 // |
|
15 |
|
16 |
|
17 #include "DNSSuffixHostResolver.h" |
|
18 |
|
19 |
|
20 #include <in_sock.h> |
|
21 |
|
22 |
|
23 CDNSSuffixHostResolver::CDNSSuffixHostResolver(MCallBackHandler& aCallback,RSocketServ& aSockServ,RConnection& aConn) : |
|
24 CActive(EPriorityStandard), iCallBack(aCallback),iSockServ(aSockServ), iConn(aConn) |
|
25 { |
|
26 } |
|
27 |
|
28 CDNSSuffixHostResolver* CDNSSuffixHostResolver::NewLC(MCallBackHandler& aCallback,RSocketServ& aSockServ,RConnection& aConn) |
|
29 { |
|
30 CDNSSuffixHostResolver* self = new (ELeave) CDNSSuffixHostResolver(aCallback,aSockServ,aConn); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CDNSSuffixHostResolver* CDNSSuffixHostResolver::NewL(MCallBackHandler& aCallback,RSocketServ& aSockServ,RConnection& aConn) |
|
37 { |
|
38 CDNSSuffixHostResolver* self = CDNSSuffixHostResolver::NewLC(aCallback,aSockServ,aConn); |
|
39 CleanupStack::Pop(); // self; |
|
40 return self; |
|
41 } |
|
42 |
|
43 void CDNSSuffixHostResolver::ConstructL() |
|
44 { |
|
45 CActiveScheduler::Add(this); // Add to scheduler |
|
46 |
|
47 if (iConn.SubSessionHandle() != 0) |
|
48 { |
|
49 // Explicit resolver |
|
50 iResolver.Open(iSockServ,KAfInet, KProtocolInetUdp, iConn); |
|
51 } |
|
52 else |
|
53 { |
|
54 // Implicit resolver |
|
55 iResolver.Open(iSockServ,KAfInet, KProtocolInetUdp); |
|
56 } |
|
57 } |
|
58 |
|
59 |
|
60 CDNSSuffixHostResolver::~CDNSSuffixHostResolver() |
|
61 { |
|
62 Cancel(); // Cancel any request, if outstanding |
|
63 |
|
64 if (iResolver.SubSessionHandle()) |
|
65 iResolver.Close(); |
|
66 } |
|
67 |
|
68 void CDNSSuffixHostResolver::DoCancel() |
|
69 { |
|
70 iResolver.Cancel(); |
|
71 } |
|
72 |
|
73 TInt CDNSSuffixHostResolver::ResolveL(const TDesC& aHostName) |
|
74 { |
|
75 iResolver.GetByName(aHostName,iEntry,iStatus); |
|
76 SetActive(); |
|
77 return KErrNone; |
|
78 } |
|
79 |
|
80 |
|
81 void CDNSSuffixHostResolver::RunL() |
|
82 { |
|
83 if (&iCallBack) |
|
84 iCallBack.HandleCallBackL(iStatus.Int()); |
|
85 } |
|
86 |
|
87 |
|
88 TInt CDNSSuffixHostResolver::RunError(TInt aError) |
|
89 { |
|
90 return aError; |
|
91 } |
|
92 |
|
93 // End of file |
|