zeroconf/server/inc/cmessagehandler.h
changeset 14 da856f45b798
equal deleted inserted replaced
12:78fbd574edf4 14:da856f45b798
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // cmessagehandler.h
       
    15 // 
       
    16 //
       
    17 /**
       
    18 @file
       
    19 @internalTechnology
       
    20 */
       
    21 
       
    22 #ifndef __CMESSAGEHANDLER_H__
       
    23 #define __CMESSAGEHANDLER_H__
       
    24 
       
    25 //System include
       
    26 #include <e32base.h>
       
    27 #include <es_sock.h>
       
    28 #include <mdns/mdnscachemgr.h>
       
    29 #include <mdns/cdnsmessage.h>
       
    30 #include <mdns/cdnsresourcedata.h>
       
    31 #include <mdns/dnsconstants.h>
       
    32 
       
    33 //user include
       
    34 #include "cmdnscachemanager.h"
       
    35 #include "msockethandlerobserver.h"
       
    36 #include "csockethandler.h"
       
    37 #include "csendmessagequeue.h"
       
    38 #include "mdnsserver.h"
       
    39 #include "mmessagehandler.h"
       
    40 #include "mdnsdebug.h"
       
    41 
       
    42 //
       
    43 _LIT8(KTcpProtocolType, "_tcp.");
       
    44 _LIT8(KUdpProtocolType, "_udp.");
       
    45 _LIT8(KLocalTld, "local");
       
    46 //
       
    47 class CBaseHandler;
       
    48 class CQueryHandler;
       
    49 class CResponseHandler;
       
    50 class CAdvertizeHandler;
       
    51 
       
    52 	
       
    53 /**
       
    54 
       
    55 Derives from the abstract class MSocketHandlerObserver 
       
    56 This instance of this will be owned by the bonjour server.
       
    57 This holds an instance of 
       
    58 1.iRecieveSocket Pointer to CSocketHandler which continously reads packet from the mdns port .
       
    59 2.iOperationHandler Pointer to CBaseHandler ,
       
    60 3.iSendMessageQueue Pointer to CSendMessageQueue Any resonse ,query or advertizig packet to be sent ,should be added to send message queue.
       
    61 4.iServer Used to notify server on any new service arrival.
       
    62 5.iDnsCache pointer to dnscache 
       
    63 
       
    64 */
       
    65 class CMessageHandler : public CBase, public MSocketHandlerObserver
       
    66 	{
       
    67 	
       
    68 	public:
       
    69 		static CMessageHandler* NewL(CMdnsServer& aServer);
       
    70 		MDNSCacheMgr& DnsCache()const;
       
    71 		//Derived from MSocketHandlerObserver
       
    72 		virtual void OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt length ) ;
       
    73 		virtual void OnError(TInt aError);
       
    74 		~CMessageHandler();
       
    75 		void ServiceClientQueryL(CDnsMessage* aMessage,TInt aHandle);
       
    76 		CSendMessageQueue& MessageQueue()const;
       
    77 		void NotifyClientQuery(TInt aClientHandle);
       
    78 		void NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId);
       
    79 		void SendQueryL(CDnsMessage* aMessage, MMessageHandler& aObserver);
       
    80 		void AdvertizePacketL(const RPointerArray<CDnsResourceData> aData, TInt aSessionId ,TBool aIsUpdate=EFalse);
       
    81 		void SetStateHostProbing(TBool aProbing);
       
    82 		void NotifyNewServiceL(const RArray<RBuf8>& aName);
       
    83 		CMdnsServer& Server();
       
    84 	private:
       
    85 		CMessageHandler(CMdnsServer& aServer);
       
    86 		void ConstructL();
       
    87 		
       
    88 		void HandleIncomingPacketL(TDesC8& aData, const TSockAddr& aAddr, TInt length);
       
    89 		CBaseHandler& GetHandlerL(CDnsMessage& aMessage);
       
    90 		
       
    91 	private:
       
    92 		CSocketHandler* iRecieveSocket;
       
    93 		CQueryHandler* iQueryHandler;
       
    94 		CResponseHandler* iResponseHandler;
       
    95 		CAdvertizeHandler* iAdvertizeHandler;
       
    96 		CSendMessageQueue* iSendMessageQueue;
       
    97 		CMdnsServer& iServer;
       
    98 		HBufC8* iPacket;
       
    99 		MDNSCacheMgr* iDnsCache;	
       
   100 		CBaseHandler* iDummyhandler;
       
   101 		/**
       
   102 		    *FLOGGER debug trace member variable.
       
   103 		    */
       
   104 		    __FLOG_DECLARATION_MEMBER_MUTABLE;
       
   105 	};
       
   106 
       
   107 #endif