zeroconf/zeroconfsharing/zeroconfclient.cpp
author guru.kini@nokia.com
Wed, 21 Jul 2010 14:28:48 +0530
changeset 21 ff5174af067c
permissions -rw-r--r--
ZeroConf Sharing Application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     1
/*
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     3
* All rights reserved.
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     8
*
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
     9
* Initial Contributors:
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    11
*
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    12
* Contributors:
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    13
*
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    14
* Description: 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    15
*
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    16
*/
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    17
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    18
#include "zeroconfclient.h"
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    19
#include "e32math.h"
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    20
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    21
#include <in_sock.h>
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    22
#include <ecom/ecom.h>
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    23
const TUint KPublishTierId = 0x2001DC8A;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    24
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    25
CZeroconfClient* CZeroconfClient::NewL(MPnPObserver* aObserver)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    26
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    27
	CZeroconfClient* self = CZeroconfClient::NewLC(aObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    28
	CleanupStack::Pop(self);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    29
	return self;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    30
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    31
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    32
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    33
CZeroconfClient* CZeroconfClient::NewLC(MPnPObserver* aObserver)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    34
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    35
	CZeroconfClient* self = new (ELeave) CZeroconfClient(aObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    36
	CleanupStack::PushL(self);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    37
	self->ConstructL();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    38
	return self;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    39
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    40
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    41
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    42
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    43
void CZeroconfClient::ConnectL()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    44
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    45
  
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    46
    GetBTName();    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    47
    TInt openStatus1 = iServicePublish.Open(KPublishTierId);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    48
    const TUint KTestTierId = 536924288;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    49
    TInt openStatus = iControlPoint.Open(KTestTierId);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    50
	//
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    51
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    52
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    53
CZeroconfClient::~CZeroconfClient()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    54
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    55
	iServicePublish.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    56
	iControlPoint.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    57
	iBTName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    58
	REComSession::FinalClose();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    59
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    60
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    61
CZeroconfClient::CZeroconfClient(MPnPObserver* aObserver)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    62
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    63
	iMdnsObserver = aObserver;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    64
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    65
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    66
void CZeroconfClient::ConstructL()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    67
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    68
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    69
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    70
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    71
void CZeroconfClient::GetBTName()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    72
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    73
    iBTName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    74
    TInt rand = Math::Random()%100;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    75
    iBTName.Num(rand);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    76
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    77
    }
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    78
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    79
void CZeroconfClient::PublishMyService(const TDesC8& aBaseUrl,const TDesC8& aFileList,const TDesC8& aIconName)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    80
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    81
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    82
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    83
        //CleanupClosePushL( pnpBundle );
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    84
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    85
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    86
    RParameterFamily ptrFamily = pnpBundle.CreateFamilyL (EMdnsPtrParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    87
        //Srv Record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    88
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    89
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    90
        //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    91
    RBuf8 serviceName;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    92
    serviceName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    93
    serviceName.Append(_L8("DeviceService"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    94
    serviceName.Append(iBTName.Collapse());
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    95
    serviceName.Append(_L8("._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    96
    srvParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    97
    srvParam->SetTargetL(_L8("2IND50001.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    98
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
    99
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   100
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   101
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   102
    CMDnsPtrParamSet* ptrParam = CMDnsPtrParamSet::NewL(ptrFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   103
    ptrParam->SetInstanceNameL(_L8("_daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   104
    ptrParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   105
        //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   106
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   107
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   108
    txtParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   109
    RBuf8 baseUrl,fileUrl,iconUrl;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   110
   
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   111
    //data3 contains the base ip addr
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   112
    baseUrl.Create(KMaxPath);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   113
    fileUrl.Create(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   114
    iconUrl.Create(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   115
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   116
    //data4 contains the filelist name
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   117
    baseUrl.Append(_L8("BaseUrl = "));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   118
    baseUrl.Append(aBaseUrl);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   119
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   120
    fileUrl.Append(_L8("FileUrl = "));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   121
    fileUrl.Append(aFileList);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   122
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   123
    iconUrl.Append(_L8("IconUrl = "));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   124
    iconUrl.Append(aIconName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   125
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   126
    txtParam->AppendTxtData(baseUrl);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   127
    txtParam->AppendTxtData(fileUrl);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   128
    txtParam->AppendTxtData(iconUrl);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   129
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   130
    iServicePublish.Publish(pnpBundle);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   131
    pnpBundle.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   132
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   133
    baseUrl.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   134
    fileUrl.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   135
    iconUrl.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   136
    serviceName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   137
    }
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   138
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   139
void CZeroconfClient::PublishNowPlayingServiceL(TDes& aTitleBuf)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   140
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   141
    TInt openStatus1 = iMusicPublish.Open(KPublishTierId);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   142
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   143
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   144
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   145
    CleanupClosePushL( pnpBundle );
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   146
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   147
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   148
    //Srv Record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   149
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   150
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   151
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   152
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   153
    //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   154
    RBuf8 serviceName;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   155
    serviceName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   156
    serviceName.Append(_L8("MusicService"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   157
    serviceName.Append(iBTName.Collapse());
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   158
    serviceName.Append(_L8("._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   159
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   160
    srvParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   161
    srvParam->SetTargetL(_L8("2IND04990.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   162
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   163
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   164
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   165
    //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   166
    RBuf8 data;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   167
    TUint KMaxLength(255);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   168
    data.CreateL(_L8("Now playing = "),KMaxLength);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   169
    data.Append(aTitleBuf.Collapse());  
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   170
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   171
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   172
    txtParam->SetDomainNameL(serviceName); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   173
    txtParam->AppendTxtData(data);  
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   174
    iServicePublish.Publish(pnpBundle); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   175
    data.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   176
    serviceName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   177
    CleanupStack::PopAndDestroy(1);//pnpBundle
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   178
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   179
    }     
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   180
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   181
void CZeroconfClient::UpdateNowPlayingServiceL(TDes& aTitleBuf)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   182
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   183
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   184
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   185
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   186
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   187
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   188
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   189
    //update Publish 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   190
    //pnpBundle.ClearAllParameters(RParameterFamily::ERequested);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   191
    RParameterFamily publishFamily = pnpBundle.CreateFamilyL (EMdnsPublishParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   192
    CMDnsPublishParamSet* publishParam = CMDnsPublishParamSet::NewL(publishFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   193
    publishParam->SetPublishUpdate(ETrue);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   194
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   195
    //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   196
    RBuf8 serviceName;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   197
    serviceName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   198
    serviceName.Append(_L8("MusicService"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   199
    serviceName.Append(iBTName.Collapse());
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   200
    serviceName.Append(_L8("._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   201
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   202
    srvParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   203
    srvParam->SetTargetL(_L8("2IND04990.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   204
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   205
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   206
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   207
    //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   208
    RBuf8 data;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   209
    TUint KMaxLength(255);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   210
    data.CreateL(_L8("Now playing = "),KMaxLength);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   211
    data.Append(aTitleBuf.Collapse());   
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   212
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   213
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   214
    txtParam->SetDomainNameL(serviceName); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   215
    txtParam->AppendTxtData(data);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   216
    iServicePublish.Publish(pnpBundle); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   217
    data.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   218
    serviceName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   219
    pnpBundle.Close();        
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   220
    }
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   221
void CZeroconfClient::PublishCurrentStatusServiceL(const TDesC8& aStatus)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   222
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   223
    TInt openStatus1 = iStatusPublish.Open(KPublishTierId);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   224
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   225
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   226
    CleanupClosePushL( pnpBundle );
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   227
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   228
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   229
    //Srv Record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   230
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   231
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   232
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   233
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   234
    //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   235
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   236
    RBuf8 serviceName;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   237
    serviceName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   238
    serviceName.Append(_L8("StatusService"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   239
    serviceName.Append(iBTName.Collapse());
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   240
    serviceName.Append(_L8("._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   241
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   242
    srvParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   243
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   244
    srvParam->SetTargetL(_L8("2IND04990.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   245
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   246
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   247
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   248
    //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   249
    RBuf8 data;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   250
    TUint KMaxLength(255);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   251
    data.CreateL(_L8("Status = "),KMaxLength);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   252
    data.Append(aStatus);  
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   253
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   254
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   255
    txtParam->SetDomainNameL(serviceName); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   256
    txtParam->AppendTxtData(data);  
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   257
    iServicePublish.Publish(pnpBundle); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   258
    data.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   259
    serviceName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   260
    CleanupStack::PopAndDestroy(1);//pnpBundle
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   261
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   262
    }     
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   263
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   264
void CZeroconfClient::UpdateCurrentStatusServiceL(const TDesC8& aStatus)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   265
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   266
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   267
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   268
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   269
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   270
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   271
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   272
    //update Publish 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   273
    //pnpBundle.ClearAllParameters(RParameterFamily::ERequested);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   274
    RParameterFamily publishFamily = pnpBundle.CreateFamilyL (EMdnsPublishParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   275
    CMDnsPublishParamSet* publishParam = CMDnsPublishParamSet::NewL(publishFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   276
    publishParam->SetPublishUpdate(ETrue);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   277
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   278
    //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   279
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   280
    RBuf8 serviceName;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   281
    serviceName.CreateL(KMaxFileName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   282
    serviceName.Append(_L8("StatusService"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   283
    serviceName.Append(iBTName.Collapse());
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   284
    serviceName.Append(_L8("._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   285
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   286
    srvParam->SetDomainNameL(serviceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   287
    srvParam->SetTargetL(_L8("2IND04990.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   288
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   289
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   290
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   291
    //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   292
    RBuf8 data;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   293
    TUint KMaxLength(255);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   294
    data.CreateL(_L8("Status = "),KMaxLength);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   295
    data.Append(aStatus);   
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   296
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   297
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   298
    txtParam->SetDomainNameL(serviceName); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   299
    txtParam->AppendTxtData(data);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   300
    iServicePublish.Publish(pnpBundle); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   301
    data.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   302
    serviceName.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   303
    pnpBundle.Close();        
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   304
    }
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   305
void CZeroconfClient::PublishService()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   306
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   307
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   308
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   309
    //CleanupClosePushL( pnpBundle );
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   310
    RParameterFamily srvFamily = pnpBundle.CreateFamilyL (EMdnsSrvParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   311
    RParameterFamily txtFamily = pnpBundle.CreateFamilyL (EMdnsTxtParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   312
    //Srv Record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   313
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   314
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   315
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   316
    CMDnsSrvParamSet* srvParam = CMDnsSrvParamSet::NewL(srvFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   317
    //CleanupStack::PushL(srvParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   318
    srvParam->SetDomainNameL(_L8("xyz._daap._tcp.local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   319
    srvParam->SetTargetL(_L8("2IND04990.Local"));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   320
    srvParam->SetPriority(2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   321
    srvParam->SetWeight(100);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   322
    srvParam->SetPort(80);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   323
    //Txt record
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   324
    CMDnsTxtParamSet* txtParam = CMDnsTxtParamSet::NewL(txtFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   325
    //CleanupStack::PushL(txtParam);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   326
    txtParam->SetDomainNameL(_L8("xyz._daap._tcp.local")); 
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   327
    RBuf8 data1,data2;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   328
    data1.Create(_L8("vadan = ct "));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   329
    data2.Create(_L8("prakash  = sharma "));
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   330
    txtParam->AppendTxtData(data1);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   331
    txtParam->AppendTxtData(data2);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   332
    iServicePublish.Publish(pnpBundle);	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   333
    pnpBundle.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   334
    data1.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   335
    data2.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   336
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   337
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   338
void CZeroconfClient::WriteServices()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   339
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   340
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   341
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   342
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   343
    RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EMdnsRegisterNotifyParamset);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   344
    CMDnsRegisterNotifyParamSet* registerParam = CMDnsRegisterNotifyParamSet::NewL(pnpFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   345
    _LIT8(KInstance,"_daap._tcp.local");
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   346
    registerParam->SetInstanceNameL(KInstance);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   347
    iControlPoint.RegisterNotify(pnpBundle);	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   348
    pnpBundle.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   349
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   350
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   351
void CZeroconfClient::WriteServiceTypes()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   352
	{
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   353
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   354
	_LIT8(KInstance,"");
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   355
    _LIT8(KServiceType,"_daap.");
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   356
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   357
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   358
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   359
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   360
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   361
    RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EMDnsDiscoverRequestParamSet);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   362
    CMDnsQueryRequestParamSet* queryParam = CMDnsQueryRequestParamSet::NewL(pnpFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   363
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   364
    queryParam->SetInstanceNameL(KInstance);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   365
    queryParam->SetQueryTypeL(EDnsQType_Any);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   366
    queryParam->SetProtocol(1);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   367
    queryParam->SetServiceTypeL(KServiceType);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   368
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   369
    User::After(5000000);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   370
    iControlPoint.Discover(pnpBundle);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   371
    pnpBundle.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   372
	
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   373
	}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   374
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   375
void CZeroconfClient::GetService(const TDesC8& aInstanceName,TDnsType aType)
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   376
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   377
    _LIT8(KServiceType,"_daap.");
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   378
    RPnPParameterBundle pnpBundle;
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   379
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   380
    pnpBundle.Open ();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   381
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   382
    pnpBundle.SetPnPObserver((MPnPObserver*)iMdnsObserver);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   383
    RParameterFamily pnpFamily = pnpBundle.CreateFamilyL (EMDnsDiscoverRequestParamSet);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   384
    CMDnsQueryRequestParamSet* queryParam = CMDnsQueryRequestParamSet::NewL(pnpFamily);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   385
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   386
    queryParam->SetInstanceNameL(aInstanceName);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   387
    queryParam->SetQueryTypeL(aType);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   388
    queryParam->SetProtocol(1);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   389
    queryParam->SetServiceTypeL(KServiceType);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   390
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   391
    
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   392
    iControlPoint.Discover(pnpBundle);
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   393
    pnpBundle.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   394
    }
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   395
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   396
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   397
void CZeroconfClient::SearchService()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   398
	{}
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   399
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   400
void CZeroconfClient::UnPublishServices()
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   401
    {
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   402
        iServicePublish.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   403
        iMusicPublish.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   404
        iStatusPublish.Close();
ff5174af067c ZeroConf Sharing Application
guru.kini@nokia.com
parents:
diff changeset
   405
    }