zeroconf/server/inc/mdnsserver.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 // mdnsserver.h
       
    15 // 
       
    16 //
       
    17 /**
       
    18 @file
       
    19 @internalTechnology
       
    20 */
       
    21 
       
    22 #ifndef __MDNSSERVER_H__
       
    23 #define __MDNSSERVER_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <es_sock.h>
       
    27 #include <in_sock.h>
       
    28 #include <e32property.h>
       
    29 #include <mdns/dnsconstants.h>
       
    30 
       
    31 #include "cinternalmessagequeue.h"
       
    32 #include "mmessagehandler.h"
       
    33 #include "mdnsdebug.h"
       
    34 
       
    35 //class TMessageType;
       
    36 class CMessageHandler;
       
    37 class CMDNSProbeManager;
       
    38 class CMDNSCacheConsistencyMgr;
       
    39 // zeroconf messages policy - all NetworkService
       
    40 
       
    41 const TUint zeroconfRangeCount = 1;
       
    42 const TInt zeroconfRanges[zeroconfRangeCount] = 
       
    43 	{
       
    44 	0
       
    45 	};
       
    46 
       
    47 const TUint8 zeroconfElementsIndex[zeroconfRangeCount] = 
       
    48 	{
       
    49 	0
       
    50 	};
       
    51 
       
    52 const CPolicyServer::TPolicyElement zeroconfElements[] = 
       
    53 	{
       
    54 	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices), CPolicyServer::EFailClient}
       
    55 	};
       
    56 
       
    57 const CPolicyServer::TPolicy zeroconfPolicy =
       
    58 	{
       
    59 	CPolicyServer::EAlwaysPass,
       
    60 	zeroconfRangeCount,                   
       
    61 	zeroconfRanges,
       
    62 	zeroconfElementsIndex,
       
    63 	zeroconfElements,
       
    64 	};
       
    65 
       
    66 // The zeroconf server class
       
    67 
       
    68 class CSocketHandler;
       
    69 class CShutdownTimer;
       
    70 
       
    71 class CMdnsServer : public CPolicyServer,public MMessageHandler
       
    72 	{
       
    73 public:
       
    74 	static CMdnsServer* NewL();
       
    75 	static CMdnsServer* NewLC();
       
    76 	
       
    77 	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    78 
       
    79 	TInt NewSession();
       
    80 	void DropSession();
       
    81 	void BeginShutdownL();
       
    82 	void JoinMulticastGroupL(TInetAddr& aMulticastAddr);
       
    83 	RSocket& Socket();
       
    84 	CMessageHandler& MessageHandler()const;
       
    85 	void NotifyClientQuery(TInt aClientHandle);
       
    86 	void NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId);
       
    87 	~CMdnsServer();
       
    88 	TDesC8& HostName()const;
       
    89 	void SetHostNameL(const TDesC8& aName);
       
    90 	void SetStateHostProbing(TBool aProbing);
       
    91 	void SetPublishingService(TBool aFlag);
       
    92 	TBool IsHostProbing()const;
       
    93 	TBool IsPublishingService() const;
       
    94 	void ProcessQueuedMessage(const RMessage2& aMessage, const TMessageType aType,TInt aSessionId);
       
    95 	void NotifyNewServiceL(const RArray<RBuf8>& aName);
       
    96 	CInternalMessageQueue* MessageQueue();
       
    97     //From MMessageHandler
       
    98     void OnPacketSendL(TInt aError);        
       
    99 
       
   100 	
       
   101 private:
       
   102     TInt GetLocalHost ( TSockAddr& aAddr );
       
   103 	CMdnsServer();
       
   104 	void ConstructL();
       
   105 	
       
   106 	
       
   107 	
       
   108 private:
       
   109 	RSocketServ iSockServ;
       
   110 	RConnection iConnection;
       
   111 	RSocket iSocket;
       
   112 
       
   113 	CShutdownTimer* iShutdownTimer;
       
   114 	CMessageHandler* iMessageHandler;
       
   115 	CInternalMessageQueue* iInternalMessageQueue;
       
   116 	CMDNSCacheConsistencyMgr* iCacheConsistencyMgr;
       
   117 	TInt iConnectionCount;
       
   118 	TInt iSessionIdCounter;
       
   119 	TBool iShutdownInProgress;
       
   120 	CMDNSProbeManager* iProbeManager;
       
   121 	RBuf8 iHostName;
       
   122 	TBool iData;
       
   123 	TBool iIsHostProbing;
       
   124 	TBool iIsPublishing;
       
   125 	/**
       
   126 	    *FLOGGER debug trace member variable.
       
   127 	    */
       
   128 	    __FLOG_DECLARATION_MEMBER_MUTABLE;
       
   129 	};
       
   130 
       
   131 #endif /* __MDNSSERVER_H__ */