datacommsserver/esockserver/inc/SS_rslv.H
changeset 0 dfb7c4ff071f
child 24 00c6709d25aa
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 #if !defined(__SS_RSLV_H__)
       
    17 #define __SS_RSLV_H__
       
    18 
       
    19 #define SYMBIAN_NETWORKING_UPS
       
    20 
       
    21 #include <ss_std.h>
       
    22 #include <comms-infras/ss_flowbinders.h>
       
    23 #include "ss_flowrequest.h"
       
    24 
       
    25 #include <comms-infras/ss_nodemessages_dataclient.h>
       
    26 
       
    27 class CSockSession;
       
    28 class CPlayer;
       
    29 
       
    30 class CHostResolvProvdBase;
       
    31 struct TServerProtocolDesc;
       
    32 
       
    33 namespace ESock
       
    34 {
       
    35 
       
    36 class MFlowBinderControl;
       
    37 class MLowerDataSender;
       
    38 class CSubConnectionFlowBase;
       
    39 
       
    40 NONSHARABLE_CLASS(CHostResolver) : public CSockSubSession, public Messages::ASimpleNodeIdBase, public AIPCFlowRequester,
       
    41 								   public MResolverNotify,
       
    42 								   protected MUpperControl //workaround until we have app layer protocols
       
    43 #ifdef SYMBIAN_NETWORKING_UPS
       
    44 								 , private ASockSubSessionPlatsecApiExt
       
    45 #endif
       
    46 /**
       
    47  @internalComponent
       
    48  */
       
    49 	{
       
    50 	friend class ::ProtocolManager;
       
    51 	friend class ::CPlayer; //SetBlockedReq(..)
       
    52 public:
       
    53 	static CHostResolver* NewLC(CProtocolRef* aProtRef, CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
    54     virtual ~CHostResolver();
       
    55 
       
    56 	virtual Den::TSubSessInfo Type() const
       
    57 		{
       
    58 		return TCFSubSessInfo(TCFSubSessInfo::EHostResolver);
       
    59 		}
       
    60 
       
    61 	virtual Messages::RNodeInterface* ServiceProvider() const
       
    62 		{
       
    63 		return NULL;
       
    64 		}
       
    65 	TBool GetFlowAndSCPR(Messages::TNodeId& aFlow, Messages::TNodeId& aSCPR) const;
       
    66 
       
    67 	inline void SetResolver(CHostResolvProvdBase* aResolver);
       
    68 
       
    69     void GetByNameL();
       
    70 	void Next();
       
    71 	void GetByAddressL();
       
    72 	void GetHostName();
       
    73 	void SetHostNameL();
       
    74 	void SetOptionL();
       
    75 
       
    76     void QueryL(void);
       
    77     void QueryGetNext(void);
       
    78 
       
    79 
       
    80 	void Cancel();
       
    81 	void QueryComplete(TInt anError);
       
    82 
       
    83 	inline TUint RequiresOwnerInfo() const;
       
    84 
       
    85 	virtual void ProcessMessageL();
       
    86 
       
    87 	void InitiateDestruction();
       
    88 
       
    89 protected:
       
    90 	void LockToConnectionInfo();
       
    91 	void LockToConnectionInfo(const TDesC8& aConnectionInfo);
       
    92     void SetBlockedReq(const RMessage2& aMsg)
       
    93         {
       
    94         iBlockedReq = aMsg;
       
    95         }
       
    96 protected:
       
    97 
       
    98     //Messages::MNode
       
    99 
       
   100 	virtual void ReceivedL(
       
   101 		const Messages::TRuntimeCtxId& aSender,
       
   102 		const Messages::TNodeId& aRecipient,
       
   103 		Messages::TSignatureBase& aMessage
       
   104 		);
       
   105 
       
   106 #ifdef SYMBIAN_NETWORKING_UPS
       
   107 	// from ASockSubSessionPlatSecApiExt
       
   108 	TInt GetMessage(const RMessage2*& aMessage) const;
       
   109 #endif
       
   110 
       
   111 	//messages
       
   112 	void BindToL(const TCFDataClient::TBindTo& aBindTo);
       
   113 
       
   114 private:
       
   115 	CHostResolver(CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
   116 	void CreateL(CProtocolRef* aProtRef);
       
   117 	inline TUint RequiresConnectionStartup();
       
   118 	void HandleConnectionSetupL();
       
   119 	void FinalCompleteAllBlockedMessages(TInt aResult);
       
   120     HBufC8* GetBuffer(HBufC8* apBuf, TInt aBufLenRequired);
       
   121     TBool   GetQueryRespBuffer(void);
       
   122     TBool   GetQueryBuffer(void);
       
   123 
       
   124 private:
       
   125     //MUpperControl
       
   126     virtual void StartSending();
       
   127 	virtual void Error(TInt aError);
       
   128 
       
   129 #ifdef SYMBIAN_NETWORKING_UPS
       
   130 	void InitialiseFlow(CSubConnectionFlowBase* aFlow);
       
   131 	TInt GetProcessAndThreadId(TProcessId& aProcessId, TThreadId& aThreadId) const;
       
   132 #endif 
       
   133 	void ReadAndSetOptionL();
       
   134 
       
   135 
       
   136 private:
       
   137 	CHostResolvProvdBase* iRSP;
       
   138 	MLowerControl* iLowerControl;
       
   139 	MLowerDataSender* iLowerDataSender;
       
   140 	MFlowBinderControl* iFlowBinderControl;
       
   141 	TBool iBusy : 1;
       
   142 	TBool iAwaitingConnection : 1;
       
   143 	RMessage2 iBlockedReq;
       
   144 	TNameRecord iNameRec;
       
   145 	TInt iCount;
       
   146 	TInt iCurrentOp;
       
   147 	TDblQueLink iInterfaceLink;			// for CInterface::iHostResolvers
       
   148 	TProtocolDesc* iProtocolInfo;
       
   149 
       
   150     HBufC8* ipQryBuf;       //< pointer to the query data buffer heap descriptor
       
   151     HBufC8* ipQryRespBuf;   //< pointer to the query response buffer heap descriptor
       
   152 
       
   153     TPtr8   iPtrQryBuf;     //< Pointer descriptor, associated with ipQryBuf
       
   154     TPtr8   iPtrQryResBuf;  //< Pointer descriptor, associated with ipQryRespBuf
       
   155 
       
   156     };
       
   157 
       
   158 inline void CHostResolver::SetResolver(CHostResolvProvdBase* aResolver)
       
   159 	{iRSP=aResolver;}
       
   160 
       
   161 inline TUint CHostResolver::RequiresConnectionStartup()
       
   162 	{ return iProtocolInfo->iNamingServices & KNSRequiresConnectionStartup; };
       
   163 
       
   164 inline TUint CHostResolver::RequiresOwnerInfo() const
       
   165 	{
       
   166 	return (iProtocolInfo->iServiceInfo & KSIRequiresOwnerInfo);
       
   167 	}
       
   168 
       
   169 // ================================================================================================
       
   170 
       
   171 NONSHARABLE_CLASS(CServiceResolver) : public CSockSubSession, public MResolverNotify
       
   172 /**
       
   173 @internalComponent
       
   174 */
       
   175 	{
       
   176 	friend class ProtocolManager;
       
   177 private:
       
   178 	CServiceResolver(CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
   179 	void CreateL();
       
   180 public:
       
   181 
       
   182 	static CServiceResolver* NewLC(CProtocolRef* aProtRef, CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
   183 	virtual Den::TSubSessInfo Type() const
       
   184 		{
       
   185 		return TCFSubSessInfo(TCFSubSessInfo::EServiceResolver);
       
   186 		}
       
   187 
       
   188 	virtual Messages::RNodeInterface* ServiceProvider() const
       
   189 		{
       
   190 		return NULL;
       
   191 		}
       
   192 
       
   193 	inline void SetResolver(CServiceResolvProvdBase* aResolver);
       
   194 	void GetByNameL();
       
   195 	void GetByNumber();
       
   196 	void RegisterServiceL();
       
   197 	void RemoveServiceL();
       
   198 	virtual ~CServiceResolver();
       
   199 	void Cancel();
       
   200 	void QueryComplete(TInt anError);
       
   201 
       
   202 	virtual void ProcessMessageL();
       
   203 private:
       
   204 	void FinalCompleteAllBlockedMessages(TInt aResult);
       
   205 private:
       
   206 	CServiceResolvProvdBase* iRSP;
       
   207 	RMessage2 iBlockedReq;
       
   208 	TBool iBusy;
       
   209 	TServiceName iNameBuf;
       
   210 	TInt32 iPortNum;
       
   211 	};
       
   212 
       
   213 inline void CServiceResolver::SetResolver(CServiceResolvProvdBase* aResolver)
       
   214 	{iRSP=aResolver;}
       
   215 
       
   216 NONSHARABLE_CLASS(CNetDatabase) : public CSockSubSession, public MResolverNotify
       
   217 /**
       
   218 @internalComponent
       
   219 */
       
   220 	{
       
   221 	friend class ProtocolManager;
       
   222 private:
       
   223 	CNetDatabase(CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
   224 public:
       
   225 	static CNetDatabase* NewLC(CProtocolRef* aProtRef, CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId);
       
   226 	virtual Den::TSubSessInfo Type() const
       
   227 		{
       
   228 		return TCFSubSessInfo(TCFSubSessInfo::ENetDatabase);
       
   229 		}
       
   230 
       
   231 	virtual Messages::RNodeInterface* ServiceProvider() const
       
   232 		{
       
   233 		return NULL;
       
   234 		}
       
   235 
       
   236 	void RequestL();
       
   237 	inline void SetProvd(CNetDBProvdBase* aResolver);
       
   238 	virtual ~CNetDatabase();
       
   239 	void QueryComplete(TInt anError);
       
   240 	void Cancel();
       
   241 
       
   242 	virtual void ProcessMessageL();
       
   243 
       
   244 private:
       
   245 	void FinalCompleteAllBlockedMessages(TInt aResult);
       
   246 private:
       
   247 	CNetDBProvdBase* iRSP;
       
   248 	RMessage2 iBlockedReq;
       
   249 	TBool iBusy;
       
   250 	HBufC8* iBuf;
       
   251 	TPtr8* iBufPtr;
       
   252 	};
       
   253 
       
   254 inline void CNetDatabase::SetProvd(CNetDBProvdBase* aResolver)
       
   255 	{iRSP=aResolver;}
       
   256 
       
   257 } //namespace ESock
       
   258 
       
   259 #endif
       
   260 // __SS_RSLV_H__