|
1 // Copyright (c) 2004-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 // Name : CSIPSRVNaptrDomain.cpp |
|
15 // Part of : ServerResolver |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "sipstrings.h" |
|
22 #include "sipstrconsts.h" |
|
23 #include "CSIPSRVNaptrDomain.h" |
|
24 #include "CSIPA_AAAAOrigDomain.h" |
|
25 #include "CSIPA_AAAASRVDomain.h" |
|
26 #include "CSIPQueryBase.h" |
|
27 #include "CSIPQuerySrv.h" |
|
28 #include "MSIPServerQuery.h" |
|
29 #include "CSIPQueryData.h" |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CSIPSRVNaptrDomain::CSIPSRVNaptrDomain |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CSIPSRVNaptrDomain::CSIPSRVNaptrDomain( MSIPServerQuery& aServerQuery ) |
|
36 :CSIPQueryConditionBase(), iServerQuery ( aServerQuery ) |
|
37 { |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CSIPSRVNaptrDomain::ConstructL |
|
42 // ---------------------------------------------------------------------------- |
|
43 // |
|
44 void CSIPSRVNaptrDomain::ConstructL( CSIPQueryBase* aNaptrQuery ) |
|
45 { |
|
46 iQueryBase = CSIPQuerySrv::NewL( iServerQuery.QueryData().Target(), |
|
47 iServerQuery.QueryData().IsSipsUri() ); |
|
48 iQueryNaptr = aNaptrQuery; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CSIPSRVNaptrDomain::NewL |
|
53 // ---------------------------------------------------------------------------- |
|
54 // |
|
55 CSIPSRVNaptrDomain* CSIPSRVNaptrDomain::NewL( MSIPServerQuery& aServerQuery, |
|
56 CSIPQueryBase* aNaptrQuery ) |
|
57 { |
|
58 CSIPSRVNaptrDomain* self = new ( ELeave ) CSIPSRVNaptrDomain( aServerQuery ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL( aNaptrQuery ); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CSIPSRVNaptrDomain::~CSIPSRVNaptrDomain |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CSIPSRVNaptrDomain::~CSIPSRVNaptrDomain() |
|
70 { |
|
71 delete iQueryBase; |
|
72 delete iQueryNaptr; |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CSIPSRVNaptrDomain::QueryBase |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CSIPQueryBase& CSIPSRVNaptrDomain::QueryBase() |
|
80 { |
|
81 return *iQueryBase; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CSIPSRVNaptrDomain::HandleQueryResultL |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 CSIPQueryConditionBase* CSIPSRVNaptrDomain::HandleQueryResultL( TInt aStatus ) |
|
89 { |
|
90 if ( aStatus == KErrNone ) |
|
91 { |
|
92 iQueryBase->HandleQueryResultL( iServerQuery.QueryData().Resolver() ); |
|
93 if ( iQueryBase->ArrayCount() != 0 ) |
|
94 { |
|
95 iServerQuery.QueryData().SetPort( iQueryBase->ResultPortL() ); |
|
96 //protocol has already been chosen |
|
97 iServerQuery.QueryData().SetTargetL( iQueryBase->ResultTargetL() ); |
|
98 |
|
99 CSIPQueryConditionBase* conditionbase = CSIPA_AAAASRVDomain::NewL( |
|
100 iServerQuery, |
|
101 iQueryNaptr, |
|
102 iQueryBase ); |
|
103 iQueryNaptr = NULL;//ownership is transferred |
|
104 iQueryBase = NULL;//ownership is transferred |
|
105 return conditionbase; |
|
106 } |
|
107 } |
|
108 iQueryNaptr->RemoveElementL( 0 ); |
|
109 if ( iQueryNaptr->ArrayCount() == 0 ) |
|
110 { |
|
111 if (iServerQuery.QueryData().IsSipsUri()) |
|
112 { |
|
113 iServerQuery.QueryData().SetPort( KSIPsDefaultPort ); |
|
114 iServerQuery.QueryData().SetProtocol( |
|
115 SIPStrings::StringF( SipStrConsts::ETLS ) ); |
|
116 } |
|
117 else |
|
118 { |
|
119 iServerQuery.QueryData().SetPort( KSIPDefaultPort ); |
|
120 iServerQuery.QueryData().SetProtocol( |
|
121 SIPStrings::StringF( SipStrConsts::EUDP ) ); |
|
122 } |
|
123 |
|
124 iServerQuery.QueryData().SetTargetL( |
|
125 iServerQuery.QueryData().OriginalTarget() ); |
|
126 //original target |
|
127 return ( CSIPA_AAAAOrigDomain::NewL( iServerQuery ) ); |
|
128 } |
|
129 else |
|
130 { |
|
131 iServerQuery.QueryData().SetProtocol( iQueryNaptr->ResultProtocolL() ); |
|
132 iServerQuery.QueryData().SetTargetL( iQueryNaptr->ResultTargetL() ); |
|
133 iQueryBase->SetTargetL( iServerQuery.QueryData().Target() ); |
|
134 return this; |
|
135 } |
|
136 } |
|
137 |
|
138 |
|
139 |