simplecm.hxx (07a3d7f1) | simplecm.hxx (fb02ff42) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 17 unchanged lines hidden (view full) --- 26#include <tools/link.hxx> 27#include <tools/string.hxx> 28#include <tools/stream.hxx> 29#include <vos/socket.hxx> 30#include <tools/debug.hxx> 31#include <tools/datetime.hxx> 32 33#include <automation/commdefines.hxx> | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 17 unchanged lines hidden (view full) --- 26#include <tools/link.hxx> 27#include <tools/string.hxx> 28#include <tools/stream.hxx> 29#include <vos/socket.hxx> 30#include <tools/debug.hxx> 31#include <tools/datetime.hxx> 32 33#include <automation/commdefines.hxx> |
34#include <automation/automationdllapi.h> |
|
34 35// CM steht f�r CommunicationManager 36#define CM_UNLIMITED_CONNECTIONS 0xffff 37 38typedef sal_uInt16 CM_NameType; 39#define CM_DOTTED ( (CM_NameType) 01 ) 40#define CM_FQDN ( (CM_NameType) 02 ) 41 --- 58 unchanged lines hidden (view full) --- 100 ClassName * pObj; \ 101public: \ 102PRV_SV_DECL_REF_SIGNATURE(ClassName, Ref) \ 103 inline ClassName##Ref( void * pObjP ){ClassName##Ref ((ClassName *) pObjP);} \ 104*/ 105 106SV_DECL_REF( CommunicationLink ) 107 | 35 36// CM steht f�r CommunicationManager 37#define CM_UNLIMITED_CONNECTIONS 0xffff 38 39typedef sal_uInt16 CM_NameType; 40#define CM_DOTTED ( (CM_NameType) 01 ) 41#define CM_FQDN ( (CM_NameType) 02 ) 42 --- 58 unchanged lines hidden (view full) --- 101 ClassName * pObj; \ 102public: \ 103PRV_SV_DECL_REF_SIGNATURE(ClassName, Ref) \ 104 inline ClassName##Ref( void * pObjP ){ClassName##Ref ((ClassName *) pObjP);} \ 105*/ 106 107SV_DECL_REF( CommunicationLink ) 108 |
108class InfoString : public ByteString | 109class AUTOMATION_DLLPUBLIC InfoString : public ByteString |
109{ 110public: 111 InfoString( ByteString &nMsg, CM_InfoType nIT, CommunicationLink *pCL = NULL ): ByteString( nMsg ), nInfoType( nIT ), pCommLink( pCL ) {;} 112 CM_InfoType GetInfoType(){ return nInfoType; } 113 CommunicationLinkRef GetCommunicationLink(){ return pCommLink; } 114private: 115 CM_InfoType nInfoType; 116 CommunicationLinkRef pCommLink; 117}; 118 119class PacketHandler; 120class CommunicationManager; 121class SingleCommunicationManager; 122class MultiCommunicationManager; 123class CommunicationManagerServerAcceptThread; | 110{ 111public: 112 InfoString( ByteString &nMsg, CM_InfoType nIT, CommunicationLink *pCL = NULL ): ByteString( nMsg ), nInfoType( nIT ), pCommLink( pCL ) {;} 113 CM_InfoType GetInfoType(){ return nInfoType; } 114 CommunicationLinkRef GetCommunicationLink(){ return pCommLink; } 115private: 116 CM_InfoType nInfoType; 117 CommunicationLinkRef pCommLink; 118}; 119 120class PacketHandler; 121class CommunicationManager; 122class SingleCommunicationManager; 123class MultiCommunicationManager; 124class CommunicationManagerServerAcceptThread; |
124class CommunicationLink : public SvRefBase | 125class AUTOMATION_DLLPUBLIC CommunicationLink : public SvRefBase |
125{ 126protected: 127 friend class CommunicationManager; 128 friend class SingleCommunicationManager; 129 friend class MultiCommunicationManager; 130 friend class CommunicationManagerServerAcceptThread; 131 // Darf nicht abger�umt werden zwischen Empfang des Streams und ende des Callbacks 132 --- 84 unchanged lines hidden (view full) --- 217 sal_uLong nSomething; 218#endif 219 220}; 221 222SV_IMPL_REF( CommunicationLink ); 223 224class CommonSocketFunctions; | 126{ 127protected: 128 friend class CommunicationManager; 129 friend class SingleCommunicationManager; 130 friend class MultiCommunicationManager; 131 friend class CommunicationManagerServerAcceptThread; 132 // Darf nicht abger�umt werden zwischen Empfang des Streams und ende des Callbacks 133 --- 84 unchanged lines hidden (view full) --- 218 sal_uLong nSomething; 219#endif 220 221}; 222 223SV_IMPL_REF( CommunicationLink ); 224 225class CommonSocketFunctions; |
225class CommunicationManager | 226class AUTOMATION_DLLPUBLIC CommunicationManager |
226{ 227 friend class CommunicationLink; 228 friend class CommonSocketFunctions; 229public: 230 CommunicationManager( sal_Bool bUseMultiChannel = sal_False ); 231 virtual ~CommunicationManager(); 232 233 virtual sal_Bool StartCommunication()=0; --- 52 unchanged lines hidden (view full) --- 286 Link mlConnectionClosed; 287 Link mlDataReceived; 288 Link mlInfoMsg; 289 CommunicationLinkRef xLastNewLink; 290 291 sal_Bool bIsMultiChannel; 292}; 293 | 227{ 228 friend class CommunicationLink; 229 friend class CommonSocketFunctions; 230public: 231 CommunicationManager( sal_Bool bUseMultiChannel = sal_False ); 232 virtual ~CommunicationManager(); 233 234 virtual sal_Bool StartCommunication()=0; --- 52 unchanged lines hidden (view full) --- 287 Link mlConnectionClosed; 288 Link mlDataReceived; 289 Link mlInfoMsg; 290 CommunicationLinkRef xLastNewLink; 291 292 sal_Bool bIsMultiChannel; 293}; 294 |
294class SingleCommunicationManager : public CommunicationManager | 295class AUTOMATION_DLLPUBLIC SingleCommunicationManager : public CommunicationManager |
295{ 296public: 297 SingleCommunicationManager( sal_Bool bUseMultiChannel = sal_False ); 298 virtual ~SingleCommunicationManager(); 299 virtual sal_Bool StopCommunication(); // H�lt alle CommunicationLinks an 300 virtual sal_Bool IsLinkValid( CommunicationLink* pCL ); 301 virtual sal_uInt16 GetCommunicationLinkCount(); 302 virtual CommunicationLinkRef GetCommunicationLink( sal_uInt16 nNr ); 303 304protected: 305 virtual void CallConnectionOpened( CommunicationLink* pCL ); 306 virtual void CallConnectionClosed( CommunicationLink* pCL ); 307 CommunicationLinkRef xActiveLink; 308 CommunicationLink *pInactiveLink; 309 virtual void DestroyingLink( CommunicationLink *pCL ); // Link tr�gt sich im Destruktor aus 310}; 311 | 296{ 297public: 298 SingleCommunicationManager( sal_Bool bUseMultiChannel = sal_False ); 299 virtual ~SingleCommunicationManager(); 300 virtual sal_Bool StopCommunication(); // H�lt alle CommunicationLinks an 301 virtual sal_Bool IsLinkValid( CommunicationLink* pCL ); 302 virtual sal_uInt16 GetCommunicationLinkCount(); 303 virtual CommunicationLinkRef GetCommunicationLink( sal_uInt16 nNr ); 304 305protected: 306 virtual void CallConnectionOpened( CommunicationLink* pCL ); 307 virtual void CallConnectionClosed( CommunicationLink* pCL ); 308 CommunicationLinkRef xActiveLink; 309 CommunicationLink *pInactiveLink; 310 virtual void DestroyingLink( CommunicationLink *pCL ); // Link tr�gt sich im Destruktor aus 311}; 312 |
312class ICommunicationManagerClient | 313class AUTOMATION_DLLPUBLIC ICommunicationManagerClient |
313{ 314 friend class CommonSocketFunctions; 315protected: 316 virtual sal_Bool RetryConnect() { return sal_False; } // Kann dann eventuell die Applikation starten 317}; 318 319class TCPIO; | 314{ 315 friend class CommonSocketFunctions; 316protected: 317 virtual sal_Bool RetryConnect() { return sal_False; } // Kann dann eventuell die Applikation starten 318}; 319 320class TCPIO; |
320class SimpleCommunicationLinkViaSocket : public CommunicationLink | 321class AUTOMATION_DLLPUBLIC SimpleCommunicationLinkViaSocket : public CommunicationLink |
321{ 322public: 323 virtual sal_Bool IsCommunicationError(); 324 virtual sal_Bool StopCommunication(); 325 326 virtual ByteString GetCommunicationPartner( CM_NameType eType ); 327 virtual ByteString GetMyName( CM_NameType eType ); 328 virtual SvStream* GetBestCommunicationStream(); --- 17 unchanged lines hidden (view full) --- 346 sal_Bool DoReceiveDataStream(); /// Receive DataPacket from Socket 347 virtual sal_Bool SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL); 348 void SetFinalRecieveTimeout(); 349 sal_Bool bIsRequestShutdownPending; 350 virtual void WaitForShutdown()=0; 351 void SetNewPacketAsCurrent(); 352}; 353 | 322{ 323public: 324 virtual sal_Bool IsCommunicationError(); 325 virtual sal_Bool StopCommunication(); 326 327 virtual ByteString GetCommunicationPartner( CM_NameType eType ); 328 virtual ByteString GetMyName( CM_NameType eType ); 329 virtual SvStream* GetBestCommunicationStream(); --- 17 unchanged lines hidden (view full) --- 347 sal_Bool DoReceiveDataStream(); /// Receive DataPacket from Socket 348 virtual sal_Bool SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL); 349 void SetFinalRecieveTimeout(); 350 sal_Bool bIsRequestShutdownPending; 351 virtual void WaitForShutdown()=0; 352 void SetNewPacketAsCurrent(); 353}; 354 |
354class SimpleCommunicationLinkViaSocketWithReceiveCallbacks : public SimpleCommunicationLinkViaSocket | 355class AUTOMATION_DLLPUBLIC SimpleCommunicationLinkViaSocketWithReceiveCallbacks : public SimpleCommunicationLinkViaSocket |
355{ 356public: 357 SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, vos::OStreamSocket *pSocket ); 358 ~SimpleCommunicationLinkViaSocketWithReceiveCallbacks(); 359 virtual sal_Bool ReceiveDataStream(); 360protected: 361 virtual sal_Bool ShutdownCommunication(); /// Really stop the Communication 362 virtual void WaitForShutdown(); 363}; 364 | 356{ 357public: 358 SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, vos::OStreamSocket *pSocket ); 359 ~SimpleCommunicationLinkViaSocketWithReceiveCallbacks(); 360 virtual sal_Bool ReceiveDataStream(); 361protected: 362 virtual sal_Bool ShutdownCommunication(); /// Really stop the Communication 363 virtual void WaitForShutdown(); 364}; 365 |
365class CommonSocketFunctions | 366class AUTOMATION_DLLPUBLIC CommonSocketFunctions |
366{ 367public: 368 sal_Bool DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, sal_uLong nPort ); 369protected: 370 virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS )=0; 371}; 372 | 367{ 368public: 369 sal_Bool DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, sal_uLong nPort ); 370protected: 371 virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS )=0; 372}; 373 |
373class SingleCommunicationManagerClientViaSocket : public SingleCommunicationManager, public ICommunicationManagerClient, CommonSocketFunctions | 374class AUTOMATION_DLLPUBLIC SingleCommunicationManagerClientViaSocket : public SingleCommunicationManager, public ICommunicationManagerClient, CommonSocketFunctions |
374{ 375public: 376 using CommunicationManager::StartCommunication; 377 378 SingleCommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel = sal_False ); 379 SingleCommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel = sal_False ); 380 virtual sal_Bool StartCommunication(){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHostToTalk, nPortToTalk );} 381 virtual sal_Bool StartCommunication( ByteString aHost, sal_uLong nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );} 382private: 383 ByteString aHostToTalk; 384 sal_uLong nPortToTalk; 385protected: 386 virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS ){ return new SimpleCommunicationLinkViaSocketWithReceiveCallbacks( pCM, pCS ); } 387}; 388 389#endif | 375{ 376public: 377 using CommunicationManager::StartCommunication; 378 379 SingleCommunicationManagerClientViaSocket( ByteString aHost, sal_uLong nPort, sal_Bool bUseMultiChannel = sal_False ); 380 SingleCommunicationManagerClientViaSocket( sal_Bool bUseMultiChannel = sal_False ); 381 virtual sal_Bool StartCommunication(){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHostToTalk, nPortToTalk );} 382 virtual sal_Bool StartCommunication( ByteString aHost, sal_uLong nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );} 383private: 384 ByteString aHostToTalk; 385 sal_uLong nPortToTalk; 386protected: 387 virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, vos::OConnectorSocket *pCS ){ return new SimpleCommunicationLinkViaSocketWithReceiveCallbacks( pCM, pCS ); } 388}; 389 390#endif |