zeroconf/server/src/cmdnsprobemanager.cpp
author guru.kini@nokia.com
Thu, 24 Jun 2010 19:09:47 +0530
changeset 14 da856f45b798
permissions -rw-r--r--
Committing ZeroConf for 10.1 to the FCL.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     2
// All rights reserved.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     3
// This component and the accompanying materials are made available
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     5
// which accompanies this distribution, and is available
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     7
//
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     8
// Initial Contributors:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    10
//
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    11
// Contributors:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    12
//
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    13
// Description:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    14
// cmdnsprobemanager.cpp
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    15
// 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    16
//
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    17
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    18
@file
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    19
@internalTechnology
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    20
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    21
//User include 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    22
#include "e32math.h" 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    23
#include "cmdnsprobemanager.h"
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    24
//System include
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    25
#include <mdns/ccacheentry.h>
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    26
__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    27
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    28
 * Two phase constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    29
 * @param aCache reference to cache
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    30
 * @param aMessageHandler reference to message handler.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    31
 * @param aAutoresolveEnabled True if name conflict to be handled.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    32
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    33
CMDNSProbeManager* CMDNSProbeManager::NewL(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    34
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    35
	CMDNSProbeManager* self = CMDNSProbeManager::NewLC(aCache,aMessageHandler,aAutoResolveEnabled);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    36
	CleanupStack::Pop(self);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    37
	return self;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    38
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    39
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    40
static void CleanUpCache(TAny* aAny)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    41
    {
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    42
    RPointerArray <CCacheEntry> * records = static_cast < RPointerArray <CCacheEntry>* > (aAny);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    43
    records->ResetAndDestroy();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    44
    records->Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    45
    }
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    46
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    47
 * Two phase constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    48
 * @param aCache reference to cache
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    49
 * @param aMessageHandler reference to message handler.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    50
 * @param aAutoresolveEnabled True if name conflict to be handled.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    51
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    52
CMDNSProbeManager* CMDNSProbeManager::NewLC(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    53
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    54
	CMDNSProbeManager* self = new (ELeave)CMDNSProbeManager(aCache,aMessageHandler,aAutoResolveEnabled);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    55
	CleanupStack::PushL(self);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    56
	self->ConstructL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    57
	return self;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    58
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    59
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    60
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    61
 * Constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    62
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    63
CMDNSProbeManager::CMDNSProbeManager(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    64
:CTimer(CActive::EPriorityStandard),iCache(aCache),iMessageHandler(aMessageHandler),iAutoResolveEnabled(aAutoResolveEnabled)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    65
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    66
	CActiveScheduler::Add(this);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    67
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    68
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    69
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    70
 * Two phase Constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    71
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    72
void CMDNSProbeManager::ConstructL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    73
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    74
	__FLOG_OPEN(KMDNSSubsystem, KComponent);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    75
	CTimer::ConstructL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    76
	iCurrentProbeState = EIdle;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    77
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    78
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    79
 * Destructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    80
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    81
CMDNSProbeManager::~CMDNSProbeManager()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    82
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    83
	__FLOG(_L8("CMDNSProbeManager::~CMDNSProbeManager - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    84
	iName.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    85
	iTarget.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    86
	iProbeName.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    87
	iProbeType.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    88
	__FLOG(_L8("CMDNSProbeManager::~CMDNSProbeManager - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    89
	__FLOG_CLOSE;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    90
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    91
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    92
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    93
 * State machine which probe send announcement and handle conflicts 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    94
 * if autoresolve enabled.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    95
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    96
void CMDNSProbeManager::RunL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    97
	{	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    98
	__FLOG(_L8("CMDNSProbeManager::RunL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    99
	TTime currentTime;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   100
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   101
	if(iCurrentProbeState <= EProbeComplete)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   102
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   103
		if(DefensiveResponseL())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   104
			{		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   105
			iCurrentProbeState = EStart;				
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   106
			if(iAutoResolveEnabled)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   107
				{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   108
				GenerateNonConflictingName();	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   109
				}		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   110
			//	else { }//  to intimate server of failure
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   111
			if(iProbeCounter >= KMaxFailures)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   112
				{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   113
				//If Probe Failure rate is greater then 15 per second, wait for 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   114
				//5 seconds before probing again
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   115
				iProbeCounter = 0;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   116
				After(5*1000*1000);				
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   117
				}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   118
			}		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   119
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   120
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   121
	switch(iCurrentProbeState)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   122
		{		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   123
		case EIdle:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   124
		break;//Do Nothing
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   125
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   126
		case EStart:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   127
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   128
			currentTime.UniversalTime();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   129
			TInt64 randseed = currentTime.Int64();					
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   130
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   131
			//Random time between 0 & 250 ms
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   132
			TInt delay = Math::Rand(randseed) % 250;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   133
			iCurrentProbeState = EProbeFirstUnicast;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   134
			//Convert to microsecond
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   135
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   136
			After(delay*1000);			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   137
			}				
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   138
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   139
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   140
		case EProbeFirstUnicast:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   141
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   142
			SendProbeL(ETrue);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   143
			iCurrentProbeState = EProbeSecondUnicast;							
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   144
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   145
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   146
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   147
		case EProbeSecondUnicast:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   148
			{				
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   149
			SendProbeL(ETrue);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   150
			iCurrentProbeState = EProbeMulticast;										
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   151
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   152
			break;		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   153
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   154
		case EProbeMulticast:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   155
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   156
			SendProbeL(EFalse);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   157
			iCurrentProbeState = EProbeComplete;			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   158
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   159
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   160
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   161
		case EProbeComplete:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   162
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   163
			iCurrentProbeState = EFirstAnnouncement;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   164
			//Probe succeeded ,insert in cache 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   165
			InsertInCache();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   166
			iMessageHandler.Server().SetHostNameL(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   167
			After(KProbeDelay*1000);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   168
			//Some Delay ?? Required or defensive response HAS TO come within 750ms?
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   169
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   170
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   171
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   172
		case EFirstAnnouncement:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   173
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   174
			SendAnnouncementL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   175
			iCurrentProbeState = ESecondAnnouncement;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   176
			//After(1000);// A Millisecond delay: Required??	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   177
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   178
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   179
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   180
		case ESecondAnnouncement:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   181
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   182
			SendAnnouncementL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   183
			iCurrentProbeState = EIdle;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   184
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   185
			break;	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   186
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   187
	__FLOG(_L8("CMDNSProbeManager::RunL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   188
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   189
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   190
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   191
 * Handles any leave from RunL
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   192
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   193
TInt CMDNSProbeManager::RunError(TInt aError)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   194
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   195
	__FLOG(_L8("CMDNSProbeManager::RunError - Entry Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   196
	return aError;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   197
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   198
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   199
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   200
 * Probe host
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   201
 * @param aUnicast True if unicast or else multicast.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   202
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   203
void CMDNSProbeManager::SendProbeL(TBool aUnicast)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   204
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   205
	__FLOG(_L8("CMDNSProbeManager::SendProbeL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   206
	//Construct DNS Message
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   207
	CDnsMessage* message = CDnsMessage::NewL(0,ETrue);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   208
	CleanupStack::PushL(message);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   209
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   210
	//Form the Query/Question part of the message
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   211
	CDnsQuestion* question = CDnsQuestion::NewL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   212
	CleanupStack::PushL(question);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   213
	question->SetNameL(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   214
	question->SetClass(EDnsClass_IN);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   215
	question->SetType(EDnsQType_Any);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   216
	if(aUnicast)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   217
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   218
		question->SetUnicast(ETrue);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   219
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   220
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   221
	//Append the Query to the Message
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   222
	message->AppendQueryL(question);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   223
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   224
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   225
	//Form the Record to be filled in the Authoritative Field of the Query
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   226
	switch(iType)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   227
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   228
	case EDnsType_A:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   229
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   230
		CRdTypeA* addRec = FormAddressRecordL();			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   231
		//Append to the Authoritative Section
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   232
		message->AppendAuthorityL(addRec);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   233
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   234
		break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   235
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   236
	case EDnsType_SRV:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   237
		{							
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   238
		CRdTypeSrv* srvRec = FormServiceRecordL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   239
		//Append to the Authoritative Section
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   240
		message->AppendAuthorityL(srvRec);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   241
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   242
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   243
		break;			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   244
	}		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   245
	//Send the query
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   246
	iMessageHandler.SendQueryL(message,*this);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   247
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   248
	CleanupStack::Pop();//question
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   249
	CleanupStack::Pop();//message
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   250
	__FLOG(_L8("CMDNSProbeManager::SendProbeL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   251
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   252
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   253
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   254
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   255
 * Send an announcement if probing is successfull.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   256
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   257
void CMDNSProbeManager::SendAnnouncementL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   258
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   259
	__FLOG(_L8("CMDNSProbeManager::SendAnnouncementL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   260
	RPointerArray<CCacheEntry> entries;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   261
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   262
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   263
	//An API in Cache Interface that returns a list of all Authoritative records
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   264
	iCache.AuthoritativeEntriesL(entries);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   265
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   266
	for(TInt index =0; index<entries.Count();index++)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   267
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   268
		CCacheEntry* entry = entries[index];
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   269
		//Send Announcements for all the Services we have published, and entered in Cache			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   270
		CDnsMessage* message = CDnsMessage::NewL(0,EFalse);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   271
		CleanupStack::PushL(message);			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   272
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   273
	    TDnsHeader header(message->Header());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   274
	    header.SetAuthoritative(ETrue);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   275
	    message->SetHeader(header);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   276
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   277
		if(entry->AddressRecord())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   278
		    message->AppendAnswerL(entry->AddressRecord()->CloneL());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   279
		if(entry->ServiceRecord())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   280
		    message->AppendAnswerL(entry->ServiceRecord()->CloneL());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   281
		if(entry->PtrRecord())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   282
		    message->AppendAnswerL(entry->PtrRecord()->CloneL());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   283
		if(entry->TxtRecord())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   284
		    message->AppendAnswerL(entry->TxtRecord()->CloneL());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   285
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   286
		//should've been a new API sendresponse
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   287
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   288
		iMessageHandler.SendQueryL(message,*this);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   289
		 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   290
		CleanupStack::Pop();//message
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   291
		entries.ResetAndDestroy();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   292
		entries.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   293
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   294
	__FLOG(_L8("CMDNSProbeManager::SendAnnouncementL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   295
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   296
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   297
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   298
 * Returns ture hostname exists in the cache.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   299
 * True means there is already a record in the network with the same name.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   300
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   301
TBool CMDNSProbeManager::DefensiveResponseL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   302
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   303
	__FLOG(_L8("CMDNSProbeManager::DefensiveResponseL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   304
	TBool probeFailed(EFalse);		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   305
	RPointerArray <CCacheEntry> entries;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   306
	CleanupStack::PushL(TCleanupItem(TCleanupOperation(&CleanUpCache),&entries));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   307
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   308
	_LIT8(KDot,".");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   309
	TBuf8 <KMaxLength> buffer;	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   310
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   311
	buffer.Copy(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   312
	buffer.Append(KDot);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   313
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   314
	iCache.FindServiceL(entries,buffer,EDnsQType_Any);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   315
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   316
	if(entries.Count()>0)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   317
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   318
		probeFailed = ETrue;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   319
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   320
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   321
    CleanupStack::PopAndDestroy();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   322
    entries.ResetAndDestroy();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   323
    entries.Close();	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   324
    __FLOG(_L8("CMDNSProbeManager::DefensiveResponseL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   325
	return probeFailed;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   326
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   327
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   328
TInt CMDNSProbeManager::StartNameProbeL(const TDesC8& aHostName,TInetAddr aAddr)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   329
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   330
	__FLOG(_L8("CMDNSProbeManager::StartNameProbeL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   331
	iName.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   332
	iName.CreateL(aHostName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   333
    iProbeName.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   334
    iProbeName.CreateL(KMaxLength);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   335
    iProbeName.Append(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   336
	iAddr = aAddr;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   337
	iCurrentProbeState =  EStart;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   338
	iType = EDnsType_A; 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   339
    iMessageHandler.SetStateHostProbing(ETrue);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   340
	Schedule();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   341
	__FLOG(_L8("CMDNSProbeManager::StartNameProbeL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   342
	return KErrNone;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   343
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   344
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   345
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   346
 * Start probing the service.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   347
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   348
TInt CMDNSProbeManager::StartServiceProbeL(const TDesC8& aServiceName,const TDesC8& aTargetMachine,TUint16 aPort)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   349
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   350
	__FLOG(_L8("CMDNSProbeManager::StartServiceProbeL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   351
	iName.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   352
	iName.CreateL(aServiceName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   353
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   354
	iTarget.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   355
	iTarget.CreateL(aTargetMachine);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   356
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   357
	iPort = aPort;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   358
	iType = EDnsType_SRV;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   359
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   360
	iCurrentProbeState =  EStart;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   361
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   362
	Schedule();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   363
	__FLOG(_L8("CMDNSProbeManager::StartServiceProbeL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   364
	return KErrNone;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   365
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   366
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   367
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   368
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   369
 * Callback method
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   370
 * Will be notified on successfully sending a packet to the network .
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   371
 * State will be EIdle when an address is successully announced twice.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   372
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   373
void CMDNSProbeManager::OnPacketSendL(TInt /*aError*/)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   374
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   375
	__FLOG(_L8("CMDNSProbeManager::OnPacketSendL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   376
	if( iCurrentProbeState != EIdle)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   377
	    {
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   378
	    After(KProbeDelay*1000);//Give more delay than this
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   379
	    return;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   380
	    }
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   381
	iMessageHandler.SetStateHostProbing(EFalse);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   382
	__FLOG(_L8("CMDNSProbeManager::OnPacketSendL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   383
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   384
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   385
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   386
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   387
 * Create an address record
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   388
 * @return returns an address record created.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   389
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   390
CRdTypeA* CMDNSProbeManager::FormAddressRecordL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   391
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   392
	__FLOG(_L8("CMDNSProbeManager::FormAddressRecordL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   393
	CRdTypeA* addRec = CRdTypeA::NewL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   394
	CleanupStack::PushL(addRec);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   395
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   396
	TInt dataLength(4);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   397
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   398
	addRec->SetNameL(iName);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   399
	addRec->SetType(EDnsType_A);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   400
	addRec->SetClass(EDnsClass_IN);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   401
	addRec->SetFlushBit(EFalse);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   402
	addRec->SetAddr(iAddr);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   403
	addRec->SetTtl(120);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   404
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   405
	CleanupStack::Pop();//addRec
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   406
	__FLOG(_L8("CMDNSProbeManager::FormAddressRecordL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   407
	return addRec;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   408
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   409
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   410
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   411
 * Create a service record
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   412
 * @return retrun the newly created service record.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   413
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   414
CRdTypeSrv* CMDNSProbeManager::FormServiceRecordL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   415
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   416
	__FLOG(_L8("CMDNSProbeManager::FormServiceRecordL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   417
	CRdTypeSrv* srvRec = CRdTypeSrv::NewL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   418
	CleanupStack::PushL(srvRec);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   419
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   420
	srvRec->SetClass(EDnsClass_IN);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   421
	srvRec->SetFlushBit(EFalse);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   422
	srvRec->SetNameL(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   423
	srvRec->SetPort(iPort);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   424
	srvRec->SetPriority(/*Default Priority*/0 );
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   425
	srvRec->SetTargetL(iTarget);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   426
	srvRec->SetTtl(120*60);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   427
	srvRec->SetType(EDnsType_SRV);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   428
	srvRec->SetWeight(/*Default Weight*/ 0);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   429
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   430
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   431
	CleanupStack::Pop();//srvRec
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   432
	__FLOG(_L8("CMDNSProbeManager::FormServiceRecordL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   433
	return srvRec;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   434
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   435
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   436
void CMDNSProbeManager::InsertInCache()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   437
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   438
	__FLOG(_L8("CMDNSProbeManager::InsertInCache - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   439
	TBuf8<KMaxLength> name;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   440
	_LIT8(KDot,".");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   441
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   442
	CDnsResourceData* data = NULL;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   443
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   444
	switch(iType)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   445
		{		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   446
			case EDnsType_A:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   447
			{	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   448
			data = FormAddressRecordL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   449
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   450
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   451
			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   452
			case EDnsType_SRV:
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   453
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   454
			data = FormServiceRecordL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   455
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   456
			break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   457
												
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   458
		}		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   459
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   460
	//Append  a "." at the end of the name
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   461
	name.Copy(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   462
	name.Append(KDot);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   463
	data->SetNameL(name);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   464
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   465
	iCache.UpdateCacheL(*data,ETrue,0/*session Id*/);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   466
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   467
	delete data;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   468
	__FLOG(_L8("CMDNSProbeManager::InsertInCache - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   469
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   470
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   471
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   472
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   473
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   474
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   475
 * If autoresolve enable a non conflict name will be generated using this.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   476
 * @return returns the probecount.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   477
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   478
TInt CMDNSProbeManager::GenerateNonConflictingName()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   479
	{		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   480
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   481
	__FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   482
	_LIT8(KDot,".");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   483
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   484
	if(iProbeCounter)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   485
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   486
		//From 2nd time, chop the last 3 characters
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   487
		iProbeName.SetLength(iProbeName.Length() - 3);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   488
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   489
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   490
	++iProbeCounter;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   491
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   492
	TBuf8 <KMaxLength> newName;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   493
	newName.Append(iProbeName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   494
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   495
	_LIT8(KOpenBrace,"(");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   496
	newName.Append(KOpenBrace);		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   497
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   498
	newName.AppendNum(iProbeCounter);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   499
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   500
	_LIT8(KCloseBrace,")");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   501
	newName.Append(KCloseBrace);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   502
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   503
	iProbeName.Close();	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   504
	iProbeName.Create(KMaxNameLength);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   505
	iProbeName.Append(newName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   506
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   507
	iName.Close();	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   508
	iName.Create(KMaxLength);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   509
	iName.Append(iProbeName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   510
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   511
	iName.Append(KDot);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   512
	iName.Append(iProbeType);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   513
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   514
	__FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   515
	return iProbeCounter;			
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   516
*/	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   517
	//-------------------------------------------------------
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   518
    __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName- Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   519
    _LIT8(KDot,".");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   520
        
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   521
    ++iProbeCounter;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   522
    
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   523
    TBuf8 <KMaxLength> newName;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   524
   
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   525
    iName.Close();  
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   526
    iName.Create(KMaxLength);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   527
    iName.Append(iProbeName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   528
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   529
    TInt pos = iName.Locate('.');
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   530
    _LIT8(KOpenBrace,"(");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   531
    newName.Append(KOpenBrace);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   532
    newName.AppendNum(iProbeCounter);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   533
    _LIT8(KCloseBrace,")");
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   534
    newName.Append(KCloseBrace);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   535
    iName.Insert(pos,newName); 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   536
    //ChangeDomainL(iName);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   537
   
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   538
    __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName- Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   539
    return iProbeCounter;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   540
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   541
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   542
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   543
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   544
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   545
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   546
		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   547
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   548
 * Self complete the request.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   549
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   550
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   551
void CMDNSProbeManager::Schedule()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   552
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   553
	__FLOG(_L8("CMDNSProbeManager::Schedule - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   554
	TRequestStatus* status(&iStatus);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   555
	*status = KRequestPending;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   556
	SetActive();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   557
	User::RequestComplete(status, KErrNone);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   558
	__FLOG(_L8("CMDNSProbeManager::Schedule - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   559
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   560
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   561