zeroconf/server/src/csendmessagequeue.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
// csendmessagequeue.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
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    22
#include "f32file.h" 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    23
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    24
#include "cmessagehandler.h"
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    25
#include "csendmessagequeue.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 aDnsMessage Dns message to be sent 
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    30
@param aUnicast True if it is a unicast response
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    31
@param aAddr address to which the packet to be send
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    32
@return CSendMessageData object
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    33
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    34
CSendMessageData* CSendMessageData::NewL(CDnsMessage* aDnsMessage, TBool aUnicast,TSockAddr aAddr,MMessageHandler& aCallback)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    35
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    36
	CSendMessageData* self = new(ELeave)CSendMessageData(aDnsMessage,aUnicast,aAddr,aCallback);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    37
	CleanupStack::PushL(self);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    38
	self->ConstructL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    39
	CleanupStack::Pop();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    40
	return self;	
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
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    43
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    44
Constant function which returns the reference to the Dns message object it wraps
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    45
@return constant reference to dnsmessage object
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
const CDnsMessage& CSendMessageData::GetDnsMessage()const
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    48
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    49
	__FLOG(_L8("CSendMessageData::GetDnsMessage - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    50
	return const_cast<CDnsMessage&> (*iMessage);	
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
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
Constant function which returns the address of the data to be sent
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    55
@return Constant reference to the address
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    56
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    57
const TSockAddr& CSendMessageData::GetSockAddress()const
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
	__FLOG(_L8("CSendMessageData::GetSockAddress - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    60
	return iSockAddr;	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    61
	}
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    64
Constant function which returns true if the message is unicast
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    65
@return True if message is unicast
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    66
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    67
const TBool& CSendMessageData::IsUnicast()const
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
	__FLOG(_L8("CSendMessageData::IsUnicast - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    70
	return iUnicast;	
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    73
Destructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    74
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    75
CSendMessageData::~CSendMessageData()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    76
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    77
	__FLOG(_L8("CSendMessageData::~CSendMessageData - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    78
	delete iMessage;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    79
	__FLOG(_L8("CSendMessageData::~CSendMessageData - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    80
	__FLOG_CLOSE;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    81
	}
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    84
Two phase constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    85
@param aDnsMessage DnsMessage to be send
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    86
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    87
void CSendMessageData::ConstructL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    88
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    89
	__FLOG_OPEN(KMDNSSubsystem, KComponent);	
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
Constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    94
@param aUnicast True if it is a unicast response
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    95
@param aAddr Address to which the data to be sent
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    96
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    97
CSendMessageData::CSendMessageData(CDnsMessage* aDnsMessage,TBool aUnicast,TSockAddr aAddr,MMessageHandler& aCallback):iMessage(aDnsMessage),iUnicast(aUnicast),iSockAddr(aAddr),iCallback(aCallback)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    98
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
    99
	
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
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   102
MMessageHandler& CSendMessageData::Callback()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   103
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   104
	__FLOG(_L8("CSendMessageData::Callback - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   105
	return iCallback;	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   106
	}
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
Two phase Constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   109
@param aSocket reference to the RSocket
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   110
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   111
CSendMessageQueue* CSendMessageQueue::NewL(RSocket& aSocket)
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
	CSendMessageQueue* self = new (ELeave)CSendMessageQueue();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   114
	CleanupStack::PushL(self);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   115
	self->ConstructL(aSocket);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   116
	CleanupStack::Pop(self);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   117
	return self;		
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
Constructor
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
CSendMessageQueue::CSendMessageQueue():CTimer(EPriorityStandard)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   124
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   125
	CActiveScheduler::Add(this);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   126
	}
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   129
Function derived from MSocketHandler Observer.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   130
This method will be called on succesfull sending of the packet.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   131
*/
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   132
void CSendMessageQueue::OnCompletionL(TDesC8& /*aData*/, const TSockAddr& /*aAddr*/, TInt /*aLength*/)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   133
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   134
	__FLOG(_L8("CSendMessageQueue::OnCompletionL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   135
	if(iSendMessageData)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   136
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   137
		iIsSocketActive = EFalse;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   138
		iSendMessageData->Callback().OnPacketSendL(KErrNone);	
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
	delete iSendMessageData;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   141
	iSendMessageData = NULL;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   142
	if(iMessageQueue.Count() > 0 && !IsActive() )
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   143
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   144
		StartTransmit();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   145
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   146
	__FLOG(_L8("CSendMessageQueue::OnCompletionL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   147
	}
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
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   150
Function derived from MSocketHandler Observer.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   151
This method will be called on error in  sending the packet.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   152
*/	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   153
void CSendMessageQueue::OnError(TInt aError)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   154
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   155
	__FLOG(_L8("CSendMessageQueue::OnError - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   156
	if(iSendMessageData)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   157
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   158
		iSendMessageData->Callback().OnPacketSendL(aError);	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   159
		}	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   160
	__FLOG(_L8("CSendMessageQueue::OnError - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   161
	}
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   164
Destructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   165
*/	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   166
CSendMessageQueue::~CSendMessageQueue()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   167
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   168
	__FLOG(_L8("CSendMessageQueue::~CSendMessageQueue - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   169
	delete iSendSocket;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   170
	delete iSendMessageData;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   171
	iMessageQueue.ResetAndDestroy();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   172
	iMessageQueue.Close();	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   173
	iOutput.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   174
	__FLOG(_L8("CSendMessageQueue::~CSendMessageQueue - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   175
	__FLOG_CLOSE;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   176
	}
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   179
Two phase constructor
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   180
@param refernce to RSocket
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
void CSendMessageQueue::ConstructL(RSocket& aSocket)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   183
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   184
	__FLOG(_L8("CSendMessageQueue::ConstructL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   185
	iSendSocket = CSocketHandler::NewL(aSocket, *this, ESocketSend);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   186
	CTimer::ConstructL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   187
	iIsSocketActive = EFalse;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   188
	__FLOG(_L8("CSendMessageQueue::ConstructL - Exit"));
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
/**
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   192
Derived from CActive
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   193
*/	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   194
void CSendMessageQueue::RunL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   195
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   196
	__FLOG(_L8("CSendMessageQueue::RunL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   197
	if (MessageReady())
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
		iSendMessageData = NextDnsMessageL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   200
		CleanupStack::PushL(iSendMessageData);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   201
		const CDnsMessage& dnsMessage = iSendMessageData->GetDnsMessage();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   202
		// close the previously allocated memory.  
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   203
		iOutput.Close();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   204
		//composes the message from the Dnsmessage object .
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   205
		CDnsMessageComposerParser* comPos = CDnsMessageComposerParser::NewL();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   206
		CleanupStack::PushL(comPos);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   207
		comPos->CreateMessageL(iOutput, iSendMessageData->GetDnsMessage());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   208
		TSocketHandlerParams param(ESocketSendTo,&iOutput,&(iSendMessageData->GetSockAddress()));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   209
		iSendSocket->Activate(param);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   210
		iIsSocketActive = ETrue;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   211
		CleanupStack::PopAndDestroy();//comPos
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   212
		CleanupStack::Pop();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   213
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   214
	__FLOG(_L8("CSendMessageQueue::RunL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   215
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   216
/*
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   217
 * Nothing to do.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   218
 */
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   219
void CSendMessageQueue::DoCancel()
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
	__FLOG(_L8("CSendMessageQueue::DoCancel - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   222
	}
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
void CSendMessageQueue::QueueDnsMessageL(const CSendMessageData& aMessageData)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   225
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   226
	__FLOG(_L8("CSendMessageQueue::QueueDnsMessageL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   227
	if (aMessageData.IsUnicast())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   228
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   229
		// Unicast replies are to be given higher priority .
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   230
		// Insert the  unicast response in the queue.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   231
		TInt count(iMessageQueue.Count());
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   232
		TInt index(0);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   233
		for (; index < count; ++index)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   234
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   235
			if (!iMessageQueue[index]->IsUnicast())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   236
				{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   237
				break;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   238
				}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   239
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   240
		iMessageQueue.InsertL(&aMessageData, index);
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
		iNextTransmit.HomeTime();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   243
		Cancel();
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
	else
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   246
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   247
		// Queue the packet
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   248
		iMessageQueue.AppendL(&aMessageData);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   249
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   250
	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   251
	// kick the transmit limiter, so we're sure the message will be sent
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   252
	if(!iIsSocketActive)
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
	    NextTransmitTime(iNextTransmit);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   255
	    }
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   256
	__FLOG(_L8("CSendMessageQueue::QueueDnsMessageL - Exit"));	
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   257
	}
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
void CSendMessageQueue::NextTransmitTime(TTime aTime)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   260
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   261
	__FLOG(_L8("CSendMessageQueue::NextTransmitTime - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   262
	// if we aren't already active, set the next TX time
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   263
	if (!IsActive())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   264
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   265
		TTime now;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   266
		now.HomeTime();
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
		if (aTime > now)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   269
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   270
			At(aTime);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   271
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   272
		else
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   273
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   274
			StartTransmit();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   275
			}
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
	__FLOG(_L8("CSendMessageQueue::NextTransmitTime - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   278
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   279
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   280
void CSendMessageQueue::StartTransmit()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   281
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   282
	__FLOG(_L8("CSendMessageQueue::StartTransmit - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   283
	SetActive();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   284
	TRequestStatus *status = &iStatus;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   285
	User::RequestComplete(status,KErrNone);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   286
	__FLOG(_L8("CSendMessageQueue::StartTransmit - Exit"));
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
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   289
CSendMessageData* CSendMessageQueue::NextDnsMessageL()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   290
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   291
	__FLOG(_L8("CSendMessageQueue::NextDnsMessageL - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   292
	if (0 == iMessageQueue.Count())
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
		User::Leave(KErrNotReady);
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
	CSendMessageData* ret = iMessageQueue[0];
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   298
	iMessageQueue.Remove(0);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   299
	// calculate the next possible transmit time.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   300
	iNextTransmit.HomeTime();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   301
	TInt delay = 20 + (Math::Rand(iRandomSeed) % 100);
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   302
	iNextTransmit += TTimeIntervalMicroSeconds(delay * 1000);  
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   303
	__FLOG(_L8("CSendMessageQueue::NextDnsMessageL - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   304
	return ret;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   305
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   306
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   307
TBool CSendMessageQueue::MessageReady()
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   308
	{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   309
	__FLOG(_L8("CSendMessageQueue::MessageReady - Entry"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   310
	TBool ready = EFalse;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   311
	if (0 != iMessageQueue.Count())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   312
		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   313
		if (iMessageQueue[0]->IsUnicast())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   314
			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   315
			// unicast messages go out straight away.
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   316
			ready = ETrue;
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
		else
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
		 	TTime now;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   321
		 	now.HomeTime();
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   322
		 	if (!IsActive())
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   323
		 		{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   324
		 		if (now >= iNextTransmit)
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   325
		 			{
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   326
		 			ready = ETrue;
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
		 		else
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
					NextTransmitTime(iNextTransmit);		 		
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   331
		 			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   332
		 		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   333
			}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   334
		}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   335
	__FLOG(_L8("CSendMessageQueue::MessageReady - Exit"));
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   336
	return ready;
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   337
	}
da856f45b798 Committing ZeroConf for 10.1 to the FCL.
guru.kini@nokia.com
parents:
diff changeset
   338