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 |
// cmdnspnpservicepublisherimpl.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
//User include
|
|
19 |
#include "cmdnspnpservicepublisherimpl.h"
|
|
20 |
__FLOG_STMT(_LIT8(KComponent,"CMDnsServicePublisherImpl");)
|
|
21 |
/*
|
|
22 |
*Default constructor
|
|
23 |
*/
|
|
24 |
CMDnsServicePublisherImpl::CMDnsServicePublisherImpl ()
|
|
25 |
{
|
|
26 |
__FLOG_OPEN(KMDNSSubsystem, KComponent);
|
|
27 |
}
|
|
28 |
|
|
29 |
/*
|
|
30 |
* Two phase constructor
|
|
31 |
*/
|
|
32 |
CMDnsServicePublisherImpl* CMDnsServicePublisherImpl::NewL()
|
|
33 |
{
|
|
34 |
|
|
35 |
return new ( ELeave ) CMDnsServicePublisherImpl;
|
|
36 |
|
|
37 |
}
|
|
38 |
|
|
39 |
/*
|
|
40 |
* Destructor
|
|
41 |
*/
|
|
42 |
CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl ()
|
|
43 |
{
|
|
44 |
__FLOG(_L8("CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl - Entry"));
|
|
45 |
iMdns.Close();
|
|
46 |
__FLOG(_L8("CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl - Exit"));
|
|
47 |
__FLOG_CLOSE;
|
|
48 |
}
|
|
49 |
|
|
50 |
/*
|
|
51 |
* virtual function in the base class CPnPServicePublisherBase
|
|
52 |
* Will be called to construct the object.
|
|
53 |
* Launches the Mdns server if not already and creates a new session.
|
|
54 |
* Graps the Iap and sends the same to server to use .
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
TInt CMDnsServicePublisherImpl::Construct(TUint /*aTierId*/)
|
|
58 |
{
|
|
59 |
__FLOG(_L8("CMDnsServicePublisherImpl::Construct - Entry"));
|
|
60 |
RSocketServ sockServ;
|
|
61 |
RConnection connection;
|
|
62 |
TInt error = sockServ.Connect();
|
|
63 |
error = connection.Open(sockServ);
|
|
64 |
|
|
65 |
// start a connection, and grab the IAP ID
|
|
66 |
error = connection.Start();
|
|
67 |
|
|
68 |
TUint32 iap ;
|
|
69 |
_LIT(KCommdbIapSetting, "IAP\\Id");
|
|
70 |
connection.GetIntSetting(KCommdbIapSetting, iap);
|
|
71 |
iMdns.Open(iap);
|
|
72 |
connection.Close();
|
|
73 |
sockServ.Close();
|
|
74 |
__FLOG(_L8("CMDnsServicePublisherImpl::Construct - Exit"));
|
|
75 |
return error;
|
|
76 |
}
|
|
77 |
|
|
78 |
/*
|
|
79 |
* Publishes the service client sent along with bundle.
|
|
80 |
* any error will be notified back using the Observer inside the bundle.
|
|
81 |
*/
|
|
82 |
void CMDnsServicePublisherImpl::Publish ( const RPnPParameterBundle& aServiceInfo )
|
|
83 |
{
|
|
84 |
__FLOG(_L8("CMDnsServicePublisherImpl::Publish - Entry"));
|
|
85 |
TRAPD(err, PublishL( aServiceInfo ));
|
|
86 |
if(err != KErrNone )
|
|
87 |
aServiceInfo.PnPObserver()->OnPnPError(err);
|
|
88 |
__FLOG(_L8("CMDnsServicePublisherImpl::Publish - Exit"));
|
|
89 |
}
|
|
90 |
|
|
91 |
/*
|
|
92 |
*Leaving function which publish any services client want to .
|
|
93 |
*Might contain the additional text record . If client wish to publish.
|
|
94 |
*@param aServiceInfo RPnpParameterBundle contains the domainName need to be published.
|
|
95 |
*/
|
|
96 |
void CMDnsServicePublisherImpl::PublishL (const RPnPParameterBundle& aServiceInfo )
|
|
97 |
{
|
|
98 |
__FLOG(_L8("CMDnsServicePublisherImpl::PublishL - Entry"));
|
|
99 |
TBool isUpdate = EFalse;
|
|
100 |
HBufC8* data = HBufC8::NewLC(aServiceInfo.Length());
|
|
101 |
TPtr8 buffer = data->Des();
|
|
102 |
aServiceInfo.Store(buffer);
|
|
103 |
RPnPParameterBundle serviceInfo;
|
|
104 |
serviceInfo.CreateL();
|
|
105 |
serviceInfo.Load(buffer);
|
|
106 |
RParameterFamily publishFamily = serviceInfo.FindFamily( EMdnsPublishParamset) ;
|
|
107 |
if(!publishFamily.IsNull() && publishFamily.CountParameterSets()>0)
|
|
108 |
{
|
|
109 |
CMDnsPublishParamSet* publishParamSet = static_cast<CMDnsPublishParamSet*> (publishFamily.GetParameterSetAtIndex ( 0, RParameterFamily::ERequested ));
|
|
110 |
isUpdate = publishParamSet->PublishUpdate();
|
|
111 |
}
|
|
112 |
iMdns.RegisterServiceL(aServiceInfo,isUpdate);
|
|
113 |
serviceInfo.Close();
|
|
114 |
CleanupStack::PopAndDestroy();//data
|
|
115 |
__FLOG(_L8("CMDnsServicePublisherImpl::PublishL - Exit"));
|
|
116 |
}
|
|
117 |
|
|
118 |
/*
|
|
119 |
* Used to request for any notification of the service type client is interested in .
|
|
120 |
* @param aServiceInfo a RPnPParameterBundle which contains the servicetype ,
|
|
121 |
* client is interested in .
|
|
122 |
*/
|
|
123 |
void CMDnsServicePublisherImpl::SendNotify ( const RPnPParameterBundle& aServiceInfo )
|
|
124 |
{
|
|
125 |
__FLOG(_L8("CMDnsServicePublisherImpl::SendNotify - Entry"));
|
|
126 |
TRAPD( err, SendNotifyL( aServiceInfo ));
|
|
127 |
if ( err != KErrNone )
|
|
128 |
aServiceInfo.PnPObserver()->OnPnPError(err);
|
|
129 |
__FLOG(_L8("CMDnsServicePublisherImpl::SendNotify - Exit"));
|
|
130 |
}
|
|
131 |
|
|
132 |
/*
|
|
133 |
*@param aServiceInfo a RPnPParameterBundle which contains the servicetype ,
|
|
134 |
*client is interested in .
|
|
135 |
*/
|
|
136 |
void CMDnsServicePublisherImpl::SendNotifyL ( const RPnPParameterBundle& aServiceInfo )
|
|
137 |
{
|
|
138 |
__FLOG(_L8("CMDnsServicePublisherImpl::SendNotifyL - Entry"));
|
|
139 |
iMdns.RegisterServiceL(aServiceInfo);
|
|
140 |
__FLOG(_L8("CMDnsServicePublisherImpl::SendNotifyL - Exit"));
|
|
141 |
}
|
|
142 |
|
|
143 |
/*
|
|
144 |
* Nothing to do with this .
|
|
145 |
* Might need it in future.
|
|
146 |
*/
|
|
147 |
CControlChannelBase* CMDnsServicePublisherImpl::InitiateControlL ()
|
|
148 |
{
|
|
149 |
__FLOG(_L8("CMDnsServicePublisherImpl::InitiateControlL - Entry"));
|
|
150 |
//Nothing to do .
|
|
151 |
//Not Implemented
|
|
152 |
__FLOG(_L8("CMDnsServicePublisherImpl::InitiateControlL - Exit"));
|
|
153 |
return NULL;
|
|
154 |
}
|
|
155 |
|
|
156 |
|