datacommsserver/esockserver/inc/ss_metaconnprov.h
changeset 0 dfb7c4ff071f
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 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef SYMBIAN_SS_METACONNPROV_H
       
    23 #define SYMBIAN_SS_METACONNPROV_H
       
    24 
       
    25 #define SYMBIAN_NETWORKING_UPS
       
    26 
       
    27 #include <comms-infras/ss_commsprov.h>
       
    28 #include <comms-infras/ss_mmcommsprov.h>
       
    29 #include <comms-infras/es_availability.h>
       
    30 #include <comms-infras/ss_tiermanager.h>
       
    31 #include <comms-infras/ss_nodemessages_mcpr.h>
       
    32 #include <ss_fact.h>
       
    33 
       
    34 class CESockIniData;
       
    35 
       
    36 #ifdef SYMBIAN_NETWORKING_UPS
       
    37 namespace CommsDat
       
    38 	{
       
    39 	class CMDBSession;
       
    40 	class CCDAccessPointRecord;
       
    41 	}
       
    42 #endif
       
    43 
       
    44 namespace ESock
       
    45 {
       
    46 
       
    47 const TInt KMetaConnectionFactoryInterfaceUid = 0x10274546;
       
    48 
       
    49 //
       
    50 //RNodeAvailabilityProviderInterface
       
    51 class RNodeAvailabilityProviderInterface : public Messages::RNodeInterface
       
    52 	{
       
    53 public:
       
    54 	void SetAvailabilityStatus(const TAvailabilityStatus& aAvailabilityStatus)
       
    55 		{
       
    56 		iAvailabilityStatus = aAvailabilityStatus;
       
    57 		}
       
    58 
       
    59 	const TAvailabilityStatus& AvailabilityStatus() const
       
    60 		{
       
    61 		return iAvailabilityStatus;
       
    62 		}
       
    63 
       
    64 protected:
       
    65     TAvailabilityStatus iAvailabilityStatus;
       
    66 	};
       
    67 
       
    68 //
       
    69 //RMetaServiceProviderInterface
       
    70 class RMetaServiceProviderInterface : public RNodeAvailabilityProviderInterface
       
    71 	{
       
    72 public:
       
    73 	RMetaServiceProviderInterface(const TProviderInfo& aProviderInfo)
       
    74 	:	iProviderInfo(aProviderInfo)
       
    75 		{
       
    76 		}
       
    77 
       
    78 	const TProviderInfo& ProviderInfo() const
       
    79 	    {
       
    80 	    return iProviderInfo;
       
    81 	    }
       
    82 
       
    83 protected:
       
    84     TProviderInfo iProviderInfo;
       
    85 	};
       
    86 
       
    87 
       
    88 //
       
    89 //CMetaConnectionProviderBase
       
    90 class TSelectionPrefs;
       
    91 class CMetaConnectionProviderFactoryBase;
       
    92 class CMetaConnectionProviderBase : public CMMCommsProviderBase, public TCFMcpr
       
    93 /** Base class for a meta connection provider.
       
    94 */
       
    95 	{
       
    96 #ifdef __X86GCC__
       
    97  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
    98  	// functions to do the cast.
       
    99 	friend CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject);
       
   100 	friend const CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject);
       
   101     friend CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(Messages::ANode* aNode);
       
   102     friend CMetaConnectionProviderBase& __x86gcc_meta_connection_provider_base_cast(Messages::ANode& aNode);
       
   103 #elif !defined(__GCCXML__)
       
   104 	friend CMetaConnectionProviderBase* Messages::mnode_cast<CMetaConnectionProviderBase>(Messages::ANode* aNode);
       
   105 	friend CMetaConnectionProviderBase& Messages::mnode_cast<CMetaConnectionProviderBase>(Messages::ANode& aNode);
       
   106 #endif
       
   107 
       
   108 public:
       
   109 	IMPORT_C const TProviderInfo& ProviderInfo() const;
       
   110 	IMPORT_C void SetProviderInfo(const TProviderInfo& aConnectionInfo);
       
   111 	IMPORT_C void ConstructL();
       
   112 
       
   113 	IMPORT_C RMetaServiceProviderInterface* FindServiceProvider(TUint aAccessPoint);
       
   114 
       
   115 	IMPORT_C void SetTierManagerL(CTierManagerBase* aTierManager);
       
   116 
       
   117 	/**
       
   118 	  Destruction blocking exists to ensure that a provider will not delete itself while it is still in use.
       
   119 	  This scenario occurs when FindOrCreate finds a mcpr which is just about to delete itself (because it
       
   120 	  has lost all clients). If this blocking semaphore didn't exist, it would be possible for a deleted
       
   121 	  mcpr to be passed to the control client, causing a panic.
       
   122 	 */
       
   123 	inline TBool BlockingDestroy();
       
   124 	/**
       
   125 	   Increment blocking destroy semaphore. This should occur immediately after the the selector has found the
       
   126 	   provider, generally in the FindOrCreateProviderL method of the selector. */
       
   127 	inline void IncrementBlockingDestroy();
       
   128 	/**
       
   129 	   Decrement blocking destroy semaphore. Occurs when a client joins the provider. Never decrements past zero.
       
   130 	*/
       
   131 	inline void DecrementBlockingDestroy();
       
   132 
       
   133 	/**
       
   134 	   Meta providers (unlike other providers) are allowed to have write access to their AccessPointConfig
       
   135 	   structure provided they know how to do it safely.
       
   136 	*/
       
   137 	inline RMetaExtensionContainerC& AccessPointConfig();
       
   138 
       
   139 	inline CTierManagerBase* GetTierManager() const;
       
   140 	
       
   141 protected:
       
   142 	IMPORT_C CMetaConnectionProviderBase(CMetaConnectionProviderFactoryBase& aFactory,
       
   143                                          const TProviderInfo& aProviderInfo,
       
   144                                          const MeshMachine::TNodeActivityMap& aActivityMap);
       
   145 	IMPORT_C virtual Messages::RNodeInterface* NewClientInterfaceL(const Messages::TClientType& aClientType, TAny* aClientInfo = NULL);
       
   146 	IMPORT_C virtual ~CMetaConnectionProviderBase();
       
   147 
       
   148 #ifdef SYMBIAN_NETWORKING_UPS
       
   149 	IMPORT_C virtual void ShowAccessPointRecordL(CommsDat::CMDBSession* aSession, CommsDat::CCDAccessPointRecord* aApRec);
       
   150 #endif //SYMBIAN_NETWORKING_UPS
       
   151 
       
   152 	void SetAccessPointConfigL();
       
   153 
       
   154 protected:
       
   155 	TProviderInfo iProviderInfo;
       
   156 	TInt iBlockingDestroy;
       
   157 	CTierManagerBase* iTierManager;
       
   158 	};
       
   159 
       
   160 void CMetaConnectionProviderBase::IncrementBlockingDestroy()
       
   161 	{
       
   162 	++iBlockingDestroy;
       
   163 	}
       
   164 
       
   165 void CMetaConnectionProviderBase::DecrementBlockingDestroy()
       
   166 	{
       
   167 	if (iBlockingDestroy > 0)
       
   168 		--iBlockingDestroy;
       
   169 	}
       
   170 
       
   171 TBool CMetaConnectionProviderBase::BlockingDestroy()
       
   172 	{
       
   173 	return (iBlockingDestroy > 0);
       
   174 	}
       
   175 
       
   176 RMetaExtensionContainerC& CMetaConnectionProviderBase::AccessPointConfig()
       
   177 	{
       
   178 	return CCommsProviderBase::AccessPointConfig();
       
   179 	}
       
   180 
       
   181 CTierManagerBase* CMetaConnectionProviderBase::GetTierManager() const
       
   182 	{
       
   183 	return iTierManager;
       
   184 	}
       
   185 
       
   186 //
       
   187 class CMetaConnectionFactoryContainer;
       
   188 
       
   189 //
       
   190 //Factories - base
       
   191 class CMetaConnectionProviderFactoryBase : public CCommsFactoryBase
       
   192 /** Base class for all meta connection provider factories. Specifies the interface
       
   193     that all meta connection provider factories must implement. It also provides the
       
   194 	ECOM framework (via CCommsFactoryBase) to load meta connection provider factories
       
   195 	from other Dynamic Linked Libraries.
       
   196 */
       
   197 	{
       
   198 public:
       
   199 	IMPORT_C virtual ~CMetaConnectionProviderFactoryBase();
       
   200 
       
   201 protected:
       
   202 	IMPORT_C CMetaConnectionProviderFactoryBase(TUid aFactoryUid, CMetaConnectionFactoryContainer& aParentContainer);
       
   203 	/** Override this to create a new instance of CMetaConnectionProviderBase
       
   204 
       
   205 	@return Pointer to the newly created provider
       
   206 	@exception Leaves in out of memory conditions */
       
   207 	IMPORT_C virtual ACommsFactoryNodeId* DoCreateObjectL(TFactoryQueryBase& aQuery);
       
   208 
       
   209 	IMPORT_C void DoPostCreationL(ACommsFactoryNodeId* aObject,TFactoryQueryBase& aQuery);
       
   210 	};
       
   211 
       
   212 #ifdef __X86GCC__
       
   213  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   214  	// functions to do the cast...
       
   215 
       
   216 	enum
       
   217 		{
       
   218 		EX86GCCMetaConnectionFactoryContainer = 2
       
   219 		};
       
   220 
       
   221 	inline CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(Messages::ANode* aNode)
       
   222     	{
       
   223 	    return static_cast<CMetaConnectionProviderBase*>(aNode);
       
   224     	}
       
   225 
       
   226 	inline CMetaConnectionProviderBase& __x86gcc_meta_connection_provider_base_cast(Messages::ANode& aNode)
       
   227     	{
       
   228 	    return static_cast<CMetaConnectionProviderBase&>(aNode);
       
   229     	}
       
   230 
       
   231 	inline CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(Factories::AFactoryObject* aFactoryObject)
       
   232     	{
       
   233 	    return EX86GCCMetaConnectionFactoryContainer == static_cast<CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   234 	    	static_cast<CMetaConnectionProviderBase*>(aFactoryObject) : NULL;
       
   235     	}
       
   236 
       
   237 	inline const CMetaConnectionProviderBase* __x86gcc_meta_connection_provider_base_cast(const Factories::AFactoryObject* aFactoryObject)
       
   238     	{
       
   239 	    return EX86GCCMetaConnectionFactoryContainer == static_cast<CCommsFactoryContainer&>(aFactoryObject->Factory().ParentContainer()).iId?
       
   240 	    	static_cast<const CMetaConnectionProviderBase*>(aFactoryObject) : NULL;
       
   241     	}
       
   242 #endif
       
   243 } //namespace ESock
       
   244 
       
   245 
       
   246 #ifdef __X86GCC__
       
   247 	namespace Messages
       
   248 	{
       
   249  	// gcc-mingw does not support declaring friends from different namespaces so we define proxy
       
   250  	// functions to do the cast.
       
   251 	template <>
       
   252 	inline ESock::CMetaConnectionProviderBase* mnode_cast<ESock::CMetaConnectionProviderBase>(Messages::ANode* aNode)
       
   253 		{
       
   254 		return ESock::__x86gcc_meta_connection_provider_base_cast(aNode);
       
   255 		}
       
   256 
       
   257 	template <>
       
   258 	inline ESock::CMetaConnectionProviderBase& mnode_cast<ESock::CMetaConnectionProviderBase>(Messages::ANode& aNode)
       
   259 		{
       
   260 		return ESock::__x86gcc_meta_connection_provider_base_cast(aNode);
       
   261 		}
       
   262 	}
       
   263 #endif
       
   264 
       
   265 #endif //SYMBIAN_SS_METACONNPROV_H
       
   266 
       
   267