|
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 // cpnpservicediscovery.cpp |
|
15 // |
|
16 // |
|
17 //System include |
|
18 #include <connpref.h> |
|
19 |
|
20 //User include |
|
21 #include "CMDnsServiceDiscoveryImpl.h" |
|
22 #include "pnp/mpnpobserver.h" |
|
23 __FLOG_STMT(_LIT8(KComponent,"CMDnsServiceDiscoveryImpl");) |
|
24 /* |
|
25 * Constructor. |
|
26 */ |
|
27 CMDnsServiceDiscoveryImpl::CMDnsServiceDiscoveryImpl () |
|
28 { |
|
29 } |
|
30 /* |
|
31 * Two phase constructor |
|
32 */ |
|
33 CMDnsServiceDiscoveryImpl* CMDnsServiceDiscoveryImpl::NewL() |
|
34 { |
|
35 CMDnsServiceDiscoveryImpl* self = new (ELeave) CMDnsServiceDiscoveryImpl; |
|
36 return self; |
|
37 } |
|
38 |
|
39 /* |
|
40 * Destructor |
|
41 */ |
|
42 CMDnsServiceDiscoveryImpl::~CMDnsServiceDiscoveryImpl () |
|
43 { |
|
44 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
45 iMdns.Close(); |
|
46 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
47 __FLOG_CLOSE; |
|
48 } |
|
49 |
|
50 /* |
|
51 * Explicitly start the connection |
|
52 * Read the iap using RConnection and send the same to the RMdns. |
|
53 * @param aTierId implementation uid of the plugin |
|
54 */ |
|
55 TInt CMDnsServiceDiscoveryImpl::Construct( TUint aTierId ) |
|
56 { |
|
57 __FLOG_OPEN(KMDNSSubsystem, KComponent); |
|
58 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
59 RSocketServ sockServ; |
|
60 RConnection connection; |
|
61 User::LeaveIfError(sockServ.Connect()); |
|
62 User::LeaveIfError(connection.Open(sockServ)); |
|
63 |
|
64 // start a connection, and grab the IAP ID |
|
65 User::LeaveIfError(connection.Start()); |
|
66 |
|
67 TUint32 iap ; |
|
68 _LIT(KCommdbIapSetting, "IAP\\Id"); |
|
69 User::LeaveIfError(connection.GetIntSetting(KCommdbIapSetting, iap)); |
|
70 iMdns.Open(iap); |
|
71 connection.Close(); |
|
72 sockServ.Close(); |
|
73 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
74 return KErrNone; |
|
75 } |
|
76 |
|
77 /* |
|
78 * Any query request will be handled by this. |
|
79 * @param aServiceInfo parameter bundle which contains the query. |
|
80 */ |
|
81 void CMDnsServiceDiscoveryImpl::Discover ( const RPnPParameterBundle& aServiceInfo ) |
|
82 { |
|
83 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
84 TRAPD( err, DiscoverL( aServiceInfo )); |
|
85 if(err != KErrNone ) |
|
86 aServiceInfo.PnPObserver()->OnPnPError(err); |
|
87 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
88 } |
|
89 |
|
90 /* |
|
91 * Any query request will be handled by this. |
|
92 * @param aServiceInfo parameter bundle which contains the query. |
|
93 */ |
|
94 void CMDnsServiceDiscoveryImpl::DiscoverL ( const RPnPParameterBundle& aServiceInfo ) |
|
95 { |
|
96 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
97 iMdns.QueryL(aServiceInfo); |
|
98 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
99 } |
|
100 |
|
101 /* |
|
102 * Not supported in ZeroConf. |
|
103 */ |
|
104 void CMDnsServiceDiscoveryImpl::Describe( const RPnPParameterBundle& aServiceInfo ) |
|
105 { |
|
106 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
107 TRAPD( err, DescribeL( aServiceInfo )); |
|
108 if(err != KErrNone ) |
|
109 aServiceInfo.PnPObserver()->OnPnPError(err); |
|
110 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
111 } |
|
112 |
|
113 /* |
|
114 * Not supported in ZeroConf. |
|
115 */ |
|
116 void CMDnsServiceDiscoveryImpl::DescribeL ( const RPnPParameterBundle& /*aServiceInfo*/ ) |
|
117 { |
|
118 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
119 User::Leave(KErrNotSupported); |
|
120 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
121 } |
|
122 /* |
|
123 * Not supported in ZeroConf. |
|
124 */ |
|
125 void CMDnsServiceDiscoveryImpl::Subscribe ( const RPnPParameterBundle& aServiceInfo ) |
|
126 { |
|
127 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
128 TRAPD( err, SubscribeL( aServiceInfo )); |
|
129 if(err != KErrNone ) |
|
130 aServiceInfo.PnPObserver()->OnPnPError(err); |
|
131 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
132 } |
|
133 |
|
134 /* |
|
135 * Not supported in ZeroConf. |
|
136 */ |
|
137 void CMDnsServiceDiscoveryImpl::SubscribeL ( const RPnPParameterBundle& /* aServiceInfo*/ ) |
|
138 { |
|
139 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
140 User::Leave(KErrNotSupported); |
|
141 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
142 } |
|
143 /* |
|
144 * Client intersted in any new service to be notified, will call this. |
|
145 * @param aServiceInfo parameter bundle which contains the ptr domain name client is intersted in. |
|
146 */ |
|
147 void CMDnsServiceDiscoveryImpl::RegisterNotify( const RPnPParameterBundle& aServiceInfo )//done |
|
148 { |
|
149 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
150 TRAPD( err, RegisterNotifyL( aServiceInfo )); |
|
151 if(err != KErrNone ) |
|
152 aServiceInfo.PnPObserver()->OnPnPError(err); |
|
153 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
154 } |
|
155 // Used to register for advertisements of specific service type |
|
156 void CMDnsServiceDiscoveryImpl::RegisterNotifyL ( const RPnPParameterBundle& aServiceInfo )//done |
|
157 { |
|
158 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
159 iMdns.WaitForNotificationL(aServiceInfo); |
|
160 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
161 } |
|
162 |
|
163 /* Used to cancel previous requests of services. */ |
|
164 void CMDnsServiceDiscoveryImpl::Cancel ( const RPnPParameterBundle& aServiceInfo )//done |
|
165 { |
|
166 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
167 //Ignore the error. |
|
168 TRAP_IGNORE(iMdns.Cancel(aServiceInfo)); |
|
169 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
170 } |
|
171 |
|
172 |
|
173 /* |
|
174 * Not supported in ZeroConf. |
|
175 */ |
|
176 CControlChannelBase* CMDnsServiceDiscoveryImpl::InitiateControlL (const TDesC8& /*aUri*/ ) |
|
177 { |
|
178 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry")); |
|
179 __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit")); |
|
180 return NULL; |
|
181 } |
|
182 |