diff options
Diffstat (limited to 'automation/inc')
-rw-r--r-- | automation/inc/automation/automation.hxx | 55 | ||||
-rw-r--r-- | automation/inc/automation/commdefines.hxx | 151 | ||||
-rw-r--r-- | automation/inc/automation/commtypes.hxx | 103 | ||||
-rw-r--r-- | automation/inc/automation/communi.hxx | 183 | ||||
-rw-r--r-- | automation/inc/automation/simplecm.hxx | 396 | ||||
-rw-r--r-- | automation/inc/makefile.mk | 51 | ||||
-rw-r--r-- | automation/inc/pch/precompiled_automation.cxx | 32 | ||||
-rw-r--r-- | automation/inc/pch/precompiled_automation.hxx | 35 |
8 files changed, 1006 insertions, 0 deletions
diff --git a/automation/inc/automation/automation.hxx b/automation/inc/automation/automation.hxx new file mode 100644 index 000000000000..87e1502f39ba --- /dev/null +++ b/automation/inc/automation/automation.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: automation.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef AUTOMATION_HXX +#define AUTOMATION_HXX + +class ImplRemoteControl; + +class RemoteControl +{ + ImplRemoteControl* pImpl; +public: + RemoteControl(); + ~RemoteControl(); +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef void ( *pfunc_CreateRemoteControl)(); + typedef void ( *pfunc_DestroyRemoteControl)(); + +#ifdef __cplusplus +} +#endif + +#endif // AUTOMATION_HXX diff --git a/automation/inc/automation/commdefines.hxx b/automation/inc/automation/commdefines.hxx new file mode 100644 index 000000000000..f8f323e3c6e0 --- /dev/null +++ b/automation/inc/automation/commdefines.hxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: commdefines.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/************************************************************************* + * + * ATTENTION + * This file is intended to work inside and outside the StarOffice environment. + * Only adaption of file commtypes.hxx should be necessary. Else it is a bug! + * + ************************************************************************/ + +#include <automation/commtypes.hxx> +#include <osl/endian.h> + +#ifndef MAKEDWORD +#define MAKEDWORD(wl, wh) ((comm_DWORD)((wl) & 0xFFFF) | (((comm_DWORD)(wh) & 0xFFFF) << 16)) +#endif +#ifndef LOWORD +#define LOWORD(d) ((comm_WORD)((comm_DWORD)(d) & 0xFFFF)) +#endif +#ifndef HIWORD +#define HIWORD(d) ((comm_WORD)(((comm_DWORD)(d) >> 16) & 0xFFFF)) +#endif +#ifndef MAKEWORD +#define MAKEWORD(bl, bh) ((comm_WORD)((bl) & 0xFF) | (((comm_WORD)(bh) & 0xFF) << 8)) +#endif +#ifndef LOBYTE +#define LOBYTE(w) ((comm_BYTE)((comm_WORD)(w) & 0xFF)) +#endif +#ifndef HIBYTE +#define HIBYTE(w) ((comm_BYTE)(((comm_WORD)(w) >> 8) & 0xFF)) +#endif +#ifndef MAKEBYTE +#define MAKEBYTE(nl, nh) ((comm_BYTE)(((nl) & 0x0F) | (((nh) & 0x0F) << 4))) +#endif +#ifndef LONIBBLE +#define LONIBBLE(b) ((comm_BYTE)((b) & 0x0F)) +#endif +#ifndef HINIBBLE +#define HINIBBLE(b) ((comm_BYTE)(((b) >> 4) & 0x0F)) +#endif + +#ifndef SWAPWORD +#define SWAPWORD(w) MAKEWORD(HIBYTE(w),LOBYTE(w)) +#endif +#ifndef SWAPDWORD +#define SWAPDWORD(d) MAKEDWORD(SWAPWORD(HIWORD(d)),SWAPWORD(LOWORD(d))) +#endif + +#ifdef OSL_BIGENDIAN +#ifndef NETWORD +#define NETWORD(w) (comm_WORD)(w) +#endif +#ifndef NETDWORD +#define NETDWORD(d) (comm_DWORD)(d) +#endif +#endif // OSL_BIGENDIAN + +#ifdef OSL_LITENDIAN +#ifndef NETWORD +#define NETWORD(w) MAKEWORD(HIBYTE(w),LOBYTE(w)) +#endif +#ifndef NETDWORD +#define NETDWORD(d) MAKEDWORD(NETWORD(HIWORD(d)),NETWORD(LOWORD(d))) +#endif +#endif // OSL_LITENDIAN + +/** + Es gibt zwei arten von Datenpaketen + die erste enthält in den ersten 4 Byte die Längenangabe und in den Darauffolgenden die Daten + Die Längenangabe bezieht sich nur auf die Daten ohne die Längenangabe selbst. + + Die Zweite Art von Datenpaketen enthält Header mit weitere Informationen + wie unten beschrieben. + + Umgeschaltet wird mit dem Boolean bUseMultiChannel im Konstruktor des Managers. +**/ +/** +Defines für Header Typen: + +Allgemeiner Header: + Byte Länge Inhalt + 0..3 4 Länge des Paketes ohne diese 4 Byte + 4 1 Prüfsumme über die Länge. Stimmt sie nicht wird die Verbindung geschlossen + 5..6 2 Länge des Headers ohne diese 2 Byte + 7..8 2 Typ des Headers + +CH_SimpleMultiChannel: + 9..10 2 Channel +CH_Handshake Internal Use ONLY + Keine Weiteren Daten! + +**/ +typedef comm_UINT16 CMProtocol; + +#define CM_PROTOCOL_OLDSTYLE (CMProtocol)0x0001 +#define CM_PROTOCOL_MARS (CMProtocol)0x0001 +#define CM_PROTOCOL_BROADCASTER (CMProtocol)0x0002 +#define CM_PROTOCOL_USER_START (CMProtocol)0x0100 + +typedef comm_USHORT HandshakeType; +typedef comm_USHORT CommunicationOption; + +#define CH_NoHeader 0x0000 +#define CH_SimpleMultiChannel 0x0001 +#define CH_Handshake 0x0002 + +#define CH_REQUEST_HandshakeAlive ((HandshakeType)0x0101) /// Fordert eine Alive Antwort an +#define CH_RESPONSE_HandshakeAlive ((HandshakeType)0x0102) /// Alive Antwort + +/** + Announce supported options: + Client announces available options + Server returns subset of these options (note that the sbset can be the entire set also) +**/ +#define CH_SUPPORT_OPTIONS ((HandshakeType)0x0103) +#define OPT_USE_SHUTDOWN_PROTOCOL ((CommunicationOption)0x0001) + +/// these are for making sure all Data is read prior to shutting sown the link +#define CH_REQUEST_ShutdownLink ((HandshakeType)0x0104) /// Request to Shutdown this link +#define CH_ShutdownLink ((HandshakeType)0x0105) /// Shutdown this link + +#define CH_SetApplication ((HandshakeType)0x0106) /// Set Description of Client + diff --git a/automation/inc/automation/commtypes.hxx b/automation/inc/automation/commtypes.hxx new file mode 100644 index 000000000000..7966aed66d1e --- /dev/null +++ b/automation/inc/automation/commtypes.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: commtypes.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/************************************************************************* + * + * ATTENTION + * This file is intended to supply the types and defines for Environment independent + * building of the packethandler + * Only adaption of this file should be necessary. Else it is a bug! + * Eather including apropriate files or defining the types when not available in the environment + * + ************************************************************************/ + +/** defines al least types + comm_BYTE + comm_WORD; + comm_DWORD; + comm_BOOL + comm_ULONG + comm_USHORT + comm_UINT16 + comm_UINT32 + comm_UniChar +**/ + +#ifndef _COMMTYPES_HXX +#define _COMMTYPES_HXX + +#include <sal/types.h> +typedef sal_Unicode comm_UniChar; + +// this is a trick to be sure the SO types are unknown, so the compiler will yell at us in case we use them +#ifndef _SOLAR_H +#define NO_SOLAR +#endif + +#ifdef NO_SOLAR +#define BYTE BYTE_hidden +#define BOOL BOOL_hidden +#define ULONG ULONG_hidden +#define USHORT USHORT_hidden +#define UINT16 UINT16_hidden +#define UINT32 UINT32_hidden + +#endif + +//#define DBG_ASSERT( cond, text ) +//#define DBG_ERROR( text ) +#include <tools/debug.hxx> + +#include <tools/solar.h> +typedef BYTE comm_BYTE; +typedef BOOL comm_BOOL; +typedef sal_uInt32 comm_ULONG; +typedef sal_uInt16 comm_USHORT; +typedef UINT16 comm_UINT16; +typedef UINT32 comm_UINT32; + +#ifdef NO_SOLAR +#undef BYTE +#undef BOOL +#undef ULONG +#undef USHORT +#undef UINT16 +#undef UINT32 + +#endif + +typedef sal_uInt16 comm_WORD; +typedef sal_uInt32 comm_DWORD; + +class SmartId; +class String; +#define comm_String String + +#endif diff --git a/automation/inc/automation/communi.hxx b/automation/inc/automation/communi.hxx new file mode 100644 index 000000000000..2a7b702e38cb --- /dev/null +++ b/automation/inc/automation/communi.hxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: communi.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _COMMUNI_HXX +#define _COMMUNI_HXX + +#include <svtools/svarray.hxx> +#include <vos/thread.hxx> +#include <vos/mutex.hxx> +#include <vcl/timer.hxx> +#include <automation/simplecm.hxx> + +class SvStream; +class SvMemoryStream; +//class Application; + +class CommunicationManagerServerAcceptThread; +SV_DECL_PTRARR_SORT( CommunicationLinkList, CommunicationLink*, 1, 10 ) + +class MultiCommunicationManager : public CommunicationManager +{ +public: + MultiCommunicationManager( BOOL bUseMultiChannel = FALSE ); + virtual ~MultiCommunicationManager(); + virtual BOOL StopCommunication(); // Hält alle CommunicationLinks an + virtual BOOL IsLinkValid( CommunicationLink* pCL ); + virtual USHORT GetCommunicationLinkCount(); + virtual CommunicationLinkRef GetCommunicationLink( USHORT nNr ); + + void DoQuickShutdown( BOOL bQuickShutdown = TRUE) { bGracefullShutdown = !bQuickShutdown; } + +protected: + virtual void CallConnectionOpened( CommunicationLink* pCL ); + virtual void CallConnectionClosed( CommunicationLink* pCL ); + CommunicationLinkList *ActiveLinks; + CommunicationLinkList *InactiveLinks; /// Hier sind die CommunicationLinks drin, die sich noch nicht selbst abgemeldet haben. + /// allerdings schon ein StopCommunication gekriegt haben, bzw ein ConnectionTerminated + virtual void DestroyingLink( CommunicationLink *pCL ); // Link trägt sich im Destruktor aus + + BOOL bGracefullShutdown; +}; + +class CommunicationManagerServer : public MultiCommunicationManager +{ +public: + CommunicationManagerServer( BOOL bUseMultiChannel = FALSE ):MultiCommunicationManager( bUseMultiChannel ){;} +}; + +class CommunicationManagerClient : public MultiCommunicationManager, public ICommunicationManagerClient +{ +public: + CommunicationManagerClient( BOOL bUseMultiChannel = FALSE ); +}; + +class CommunicationLinkViaSocket : public SimpleCommunicationLinkViaSocket, public NAMESPACE_VOS(OThread) +{ +public: + CommunicationLinkViaSocket( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ); + virtual ~CommunicationLinkViaSocket(); + + virtual BOOL IsCommunicationError(); + virtual BOOL DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE ); + + // Diese sind Virtuelle Links!!!! + virtual long ConnectionClosed( void* = NULL ); + virtual long DataReceived( void* = NULL ); + + virtual BOOL StopCommunication(); + + void SetPutDataReceivedHdl( Link lPutDataReceived ){ mlPutDataReceived = lPutDataReceived; } + Link GetDataReceivedLink () {Link aLink = LINK( this, CommunicationLinkViaSocket, DataReceived ); return aLink;} + DECL_LINK( PutDataReceivedHdl, CommunicationLinkViaSocket* ); + +protected: + virtual void SAL_CALL run(); + + virtual BOOL ShutdownCommunication(); + ULONG nConnectionClosedEventId; + ULONG nDataReceivedEventId; + NAMESPACE_VOS(OMutex) aMConnectionClosed; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist + NAMESPACE_VOS(OMutex) aMDataReceived; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist + virtual void WaitForShutdown(); + + DECL_LINK( ShutdownLink, void* ); + Timer aShutdownTimer; + BOOL bShutdownStarted; + BOOL bDestroying; + Link mlPutDataReceived; +}; + +class CommunicationManagerServerViaSocket : public CommunicationManagerServer +{ + friend class CommunicationManagerServerAcceptThread; +public: + using CommunicationManager::StartCommunication; + + CommunicationManagerServerViaSocket( ULONG nPort, USHORT nMaxCon, BOOL bUseMultiChannel = FALSE ); + virtual ~CommunicationManagerServerViaSocket(); + + virtual BOOL StartCommunication(); + virtual BOOL StopCommunication(); + +protected: + ULONG nPortToListen; + USHORT nMaxConnections; + +private: + CommunicationManagerServerAcceptThread *pAcceptThread; + void AddConnection( CommunicationLink *pNewConnection ); +}; + +class CommunicationManagerServerAcceptThread: public NAMESPACE_VOS(OThread) +{ +public: + CommunicationManagerServerAcceptThread( CommunicationManagerServerViaSocket* pServer, ULONG nPort, USHORT nMaxCon = CM_UNLIMITED_CONNECTIONS ); + virtual ~CommunicationManagerServerAcceptThread(); + CommunicationLinkRef GetNewConnection(){ CommunicationLinkRef xTemp = xmNewConnection; xmNewConnection.Clear(); return xTemp; } + +protected: + virtual void SAL_CALL run(); + +private: + CommunicationManagerServerViaSocket* pMyServer; + NAMESPACE_VOS(OAcceptorSocket) *pAcceptorSocket; + ULONG nPortToListen; + USHORT nMaxConnections; + ULONG nAddConnectionEventId; + NAMESPACE_VOS(OMutex) aMAddConnection; // Notwendig, da Event verarbeitet werden kann bevor Variable gesetzt ist + void CallInfoMsg( InfoString aMsg ){ pMyServer->CallInfoMsg( aMsg ); } + CM_InfoType GetInfoType(){ return pMyServer->GetInfoType(); } + + // Diese beiden werden zum Transport der Connection vom Thread zum Mainthread verwendet. + CommunicationLinkRef xmNewConnection; + DECL_LINK( AddConnection, void* ); +}; + +class CommunicationManagerClientViaSocket : public CommunicationManagerClient, CommonSocketFunctions +{ +public: + using CommunicationManager::StartCommunication; + + CommunicationManagerClientViaSocket( ByteString aHost, ULONG nPort, BOOL bUseMultiChannel = FALSE ); + CommunicationManagerClientViaSocket( BOOL bUseMultiChannel = FALSE ); + virtual ~CommunicationManagerClientViaSocket(); + + virtual BOOL StartCommunication(){ return StartCommunication( aHostToTalk, nPortToTalk );} + virtual BOOL StartCommunication( ByteString aHost, ULONG nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );} + +private: + ByteString aHostToTalk; + ULONG nPortToTalk; +protected: + virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, NAMESPACE_VOS(OConnectorSocket) *pCS ){ return new CommunicationLinkViaSocket( pCM, pCS ); } +}; + +#endif diff --git a/automation/inc/automation/simplecm.hxx b/automation/inc/automation/simplecm.hxx new file mode 100644 index 000000000000..e5d4a45fff14 --- /dev/null +++ b/automation/inc/automation/simplecm.hxx @@ -0,0 +1,396 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: simplecm.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SIMPLECM_HXX +#define _SIMPLECM_HXX + +#include <tools/link.hxx> +#include <tools/string.hxx> +#include <tools/stream.hxx> +#include <vos/socket.hxx> +#include <tools/debug.hxx> +#include <tools/datetime.hxx> + +#include <automation/commdefines.hxx> + +// CM steht für CommunicationManager +#define CM_UNLIMITED_CONNECTIONS 0xffff + +typedef USHORT CM_NameType; +#define CM_DOTTED ( (CM_NameType) 01 ) +#define CM_FQDN ( (CM_NameType) 02 ) + +typedef USHORT CM_InfoType; +// nur eines dieser 3 defines darf verwendet werden +#define CM_NO_TEXT ( (CM_InfoType) 01 ) +#define CM_SHORT_TEXT ( (CM_InfoType) 02 ) +#define CM_VERBOSE_TEXT ( (CM_InfoType) 03 ) + +#define CM_OPEN ( (CM_InfoType) 0x0004 ) +#define CM_CLOSE ( (CM_InfoType) 0x0008 ) +#define CM_RECEIVE ( (CM_InfoType) 0x0010 ) +#define CM_SEND ( (CM_InfoType) 0x0020 ) +#define CM_ERROR ( (CM_InfoType) 0x0040 ) +#define CM_MISC ( (CM_InfoType) 0x0080 ) + +#define CM_USER_1 ( (CM_InfoType) 0x0100 ) +#define CM_USER_2 ( (CM_InfoType) 0x0200 ) +#define CM_USER_3 ( (CM_InfoType) 0x0400 ) +#define CM_USER_4 ( (CM_InfoType) 0x0800 ) + +#define CM_ALL ( CM_OPEN | CM_CLOSE | CM_RECEIVE | CM_SEND | CM_ERROR | CM_MISC ) +#define CM_NONE ( 0 ) + +#define CByteString( constAsciiStr ) ByteString( RTL_CONSTASCII_STRINGPARAM ( constAsciiStr ) ) + +#define INFO_MSG( Short, Long, Type, CLink ) \ +{ \ + if ( (Type & GetInfoType()) > 0 ) \ + { \ + switch ( GetInfoType() & 03 ) \ + { \ + case CM_NO_TEXT: \ + { \ + ByteString aByteString; \ + CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \ + } \ + break; \ + case CM_SHORT_TEXT: \ + { \ + ByteString aByteString( Short ); \ + CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \ + } \ + break; \ + case CM_VERBOSE_TEXT: \ + { \ + ByteString aByteString( Long ); \ + CallInfoMsg( InfoString( aByteString, Type, CLink ) ); \ + } \ + break; \ + default: \ + break; \ + } \ + } \ +}\ + +class CommunicationLink; + +/*#undef PRV_SV_DECL_REF_LOCK +#define PRV_SV_DECL_REF_LOCK(ClassName, Ref) \ +protected: \ + ClassName * pObj; \ +public: \ +PRV_SV_DECL_REF_SIGNATURE(ClassName, Ref) \ + inline ClassName##Ref( void * pObjP ){ClassName##Ref ((ClassName *) pObjP);} \ +*/ + +SV_DECL_REF( CommunicationLink ) + +class InfoString : public ByteString +{ +public: + InfoString( ByteString &nMsg, CM_InfoType nIT, CommunicationLink *pCL = NULL ): ByteString( nMsg ), nInfoType( nIT ), pCommLink( pCL ) {;} + CM_InfoType GetInfoType(){ return nInfoType; } + CommunicationLinkRef GetCommunicationLink(){ return pCommLink; } +private: + CM_InfoType nInfoType; + CommunicationLinkRef pCommLink; +}; + +class PacketHandler; +class CommunicationManager; +class SingleCommunicationManager; +class MultiCommunicationManager; +class CommunicationManagerServerAcceptThread; +class CommunicationLink : public SvRefBase +{ +protected: + friend class CommunicationManager; + friend class SingleCommunicationManager; + friend class MultiCommunicationManager; + friend class CommunicationManagerServerAcceptThread; + // Darf nicht abgeräumt werden zwischen Empfang des Streams und ende des Callbacks + +protected: // so daß nur über Ref gelöscht werden kann + virtual ~CommunicationLink(); + void InvalidateManager() { pMyManager = NULL; } + + PacketHandler* pPacketHandler; + +public: + CommunicationLink( CommunicationManager *pMan ); + + virtual BOOL StopCommunication()=0; + virtual BOOL IsCommunicationError()=0; + CommunicationManager* GetCommunicationManager(){ return pMyManager; } + +// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren + virtual ByteString GetCommunicationPartner( CM_NameType eType )=0; + +// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren + virtual ByteString GetMyName( CM_NameType eType )=0; + +// Liefert einen neuen Stream zum Versenden von Daten. + virtual SvStream* GetBestCommunicationStream()=0; + + /** will call virtual function DoTransferDataStream to do actual work + Purpos is to allow housekeeping + **/ + BOOL TransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE ); + + // Liefert die ID, die vom Sender angegeben wurde. + // Dadurch lassen sich virtuelle Kommunikationen über einen physikalischen Link realisiren. + // Da die Kommunikation zu älteren Versionen kompatibel bleiben muß, muß der Empfänger raten, + // die neue oder die alte verwendet wird, da sich der Kopf eines Auftrages dann ändert. + UINT16 GetProtocol(){ return nServiceProtocol; } + + // Der Stream wird hier übergeben. Der Aufrufer ist für dessen Löschung zuständig + // Die Methode MUSS gerufen werden, da sonst keine weiteren Daten empfangen werden. + SvStream* GetServiceData(){ SvStream *pTemp = pServiceData; pServiceData = NULL; return pTemp; } + + /// Ermöglicht das Auslösen des nächsten Callbacks. Wird auch Implizit gerufen. + void FinishCallback(){ bIsInsideCallback = FALSE; } + + /// Syncrones Empfangen der Daten. Nur für Kommandozeile, sonst leer implementiert + virtual BOOL ReceiveDataStream(){ return FALSE; } + + /// Statistics + DateTime GetStart() { return aStart; } + ULONG GetTotalBytes() { return nTotalBytes; } + DateTime GetLastAccess() { return aLastAccess; } + const ByteString& GetApplication() { return maApplication; } + virtual void SetApplication( const ByteString& aApp ); + +protected: + void CallInfoMsg( InfoString aMsg ); + CM_InfoType GetInfoType(); + CommunicationManager *pMyManager; +// Diese Methoden werden im Main Kontext gerufen und an den Manager weitergereicht. + virtual DECL_LINK( ConnectionClosed, void* = NULL ); + virtual DECL_LINK( DataReceived, void* = NULL ); + + virtual BOOL DoTransferDataStream( SvStream *pDataStream, CMProtocol nProtocol = CM_PROTOCOL_OLDSTYLE ); + + SvStream *pServiceData; + UINT16 nServiceProtocol; + UINT16 nServiceHeaderType; + + /// Verhindert das vorzeitige Auslösen des nächsten Callbacks. + void StartCallback(){ bIsInsideCallback = TRUE; } + BOOL bIsInsideCallback; + + virtual BOOL SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL)=0; + + virtual BOOL ShutdownCommunication() = 0; /// Really stop the Communication + + /// Statistics + DateTime aStart; + ULONG nTotalBytes; + DateTime aLastAccess; + +private: + ByteString maApplication; + +#if OSL_DEBUG_LEVEL > 1 +public: + // misc (debuging) purposes + BOOL bFlag; + ULONG nSomething; +#endif + +}; + +SV_IMPL_REF( CommunicationLink ); + +class CommonSocketFunctions; +class CommunicationManager +{ + friend class CommunicationLink; + friend class CommonSocketFunctions; +public: + CommunicationManager( BOOL bUseMultiChannel = FALSE ); + virtual ~CommunicationManager(); + + virtual BOOL StartCommunication()=0; + virtual BOOL StartCommunication( String aApp, String aParams ); + virtual BOOL StartCommunication( ByteString aHost, ULONG nPort ); + virtual BOOL StopCommunication()=0; // Hält alle CommunicationLinks an + virtual BOOL IsCommunicationRunning() { return bIsCommunicationRunning; } +// virtual BOOL IsCommunicationError(); + +// Der Name oder die IP-Adresse oder sonstwas um den Communikationspartner zu identifizieren + virtual ByteString GetMyName( CM_NameType eType ); + + virtual BOOL IsLinkValid( CommunicationLink* pCL )=0; // Notwendig für call im Destruktor + + virtual USHORT GetCommunicationLinkCount()=0; + virtual CommunicationLinkRef GetCommunicationLink( USHORT nNr )=0; + + // Liefert den letzten neuen Link oder NULL wenn dieser schon wieder geschlossen ist. + CommunicationLinkRef GetLastNewLink() { return xLastNewLink; } + + void SetConnectionOpenedHdl( Link lConnectionOpened ){ mlConnectionOpened = lConnectionOpened; } + void SetConnectionClosedHdl( Link lConnectionClosed ){ mlConnectionClosed = lConnectionClosed; } + void SetDataReceivedHdl( Link lDataReceived ){ mlDataReceived = lDataReceived; } + void SetInfoMsgHdl( Link lInfoMsg ){ mlInfoMsg = lInfoMsg; } + + void SetInfoType( CM_InfoType nIT ){ nInfoType = nIT; } + CM_InfoType GetInfoType(){ return nInfoType; } + + BOOL IsMultiChannel(){ return bIsMultiChannel; } + void SetApplication( const ByteString& aApp, BOOL bRunningLinks = FALSE ); + const ByteString& GetApplication() { return maApplication; } + +protected: + // Diese Methoden werden innerhalb gerufen. Sie erledigen eventuelles Housekeeping + // und rufen dann die entsprechende Methode + virtual void CallConnectionOpened( CommunicationLink* pCL ); + virtual void CallConnectionClosed( CommunicationLink* pCL ); + void CallDataReceived( CommunicationLink* pCL ); + void CallInfoMsg( InfoString aMsg ); + + CM_InfoType nInfoType; + + // Diese Routinen rufen den Link oder sind überladen + virtual void ConnectionOpened( CommunicationLink* pCL ){ mlConnectionOpened.Call( pCL ); } + virtual void ConnectionClosed( CommunicationLink* pCL ){ mlConnectionClosed.Call( pCL ); } + virtual void DataReceived( CommunicationLink* pCL ){ mlDataReceived.Call( pCL ); } + virtual void InfoMsg( InfoString aMsg ){ mlInfoMsg.Call( &aMsg ); } + + BOOL bIsCommunicationRunning; + + virtual void DestroyingLink( CommunicationLink *pCL )=0; // Link trägt sich im Destruktor aus + +private: + ByteString maApplication; + Link mlConnectionOpened; + Link mlConnectionClosed; + Link mlDataReceived; + Link mlInfoMsg; + CommunicationLinkRef xLastNewLink; + + BOOL bIsMultiChannel; +}; + +class SingleCommunicationManager : public CommunicationManager +{ +public: + SingleCommunicationManager( BOOL bUseMultiChannel = FALSE ); + virtual ~SingleCommunicationManager(); + virtual BOOL StopCommunication(); // Hält alle CommunicationLinks an + virtual BOOL IsLinkValid( CommunicationLink* pCL ); + virtual USHORT GetCommunicationLinkCount(); + virtual CommunicationLinkRef GetCommunicationLink( USHORT nNr ); + +protected: + virtual void CallConnectionOpened( CommunicationLink* pCL ); + virtual void CallConnectionClosed( CommunicationLink* pCL ); + CommunicationLinkRef xActiveLink; + CommunicationLink *pInactiveLink; + virtual void DestroyingLink( CommunicationLink *pCL ); // Link trägt sich im Destruktor aus +}; + +class ICommunicationManagerClient +{ + friend class CommonSocketFunctions; +protected: + virtual BOOL RetryConnect() { return FALSE; } // Kann dann eventuell die Applikation starten +}; + +class TCPIO; +class SimpleCommunicationLinkViaSocket : public CommunicationLink +{ +public: + virtual BOOL IsCommunicationError(); + virtual BOOL StopCommunication(); + + virtual ByteString GetCommunicationPartner( CM_NameType eType ); + virtual ByteString GetMyName( CM_NameType eType ); + virtual SvStream* GetBestCommunicationStream(); + virtual void SetApplication( const ByteString& aApp ); + +private: + ByteString aCommunicationPartner; + ByteString aMyName; + + TCPIO* pTCPIO; + NAMESPACE_VOS(OStreamSocket) *pStreamSocket; + +protected: + SimpleCommunicationLinkViaSocket( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ); + virtual ~SimpleCommunicationLinkViaSocket(); + + NAMESPACE_VOS(OStreamSocket)* GetStreamSocket() { return pStreamSocket; } + void SetStreamSocket( NAMESPACE_VOS(OStreamSocket)* pSocket ); + + SvStream *pReceiveStream; + BOOL DoReceiveDataStream(); /// Recieve DataPacket from Socket + virtual BOOL SendHandshake( HandshakeType aHandshakeType, SvStream* pData = NULL); + void SetFinalRecieveTimeout(); + BOOL bIsRequestShutdownPending; + virtual void WaitForShutdown()=0; + void SetNewPacketAsCurrent(); +}; + +class SimpleCommunicationLinkViaSocketWithReceiveCallbacks : public SimpleCommunicationLinkViaSocket +{ +public: + SimpleCommunicationLinkViaSocketWithReceiveCallbacks( CommunicationManager *pMan, NAMESPACE_VOS(OStreamSocket) *pSocket ); + ~SimpleCommunicationLinkViaSocketWithReceiveCallbacks(); + virtual BOOL ReceiveDataStream(); +protected: + virtual BOOL ShutdownCommunication(); /// Really stop the Communication + virtual void WaitForShutdown(); +}; + +class CommonSocketFunctions +{ +public: + BOOL DoStartCommunication( CommunicationManager *pCM, ICommunicationManagerClient *pCMC, ByteString aHost, ULONG nPort ); +protected: + virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, NAMESPACE_VOS(OConnectorSocket) *pCS )=0; +}; + +class SingleCommunicationManagerClientViaSocket : public SingleCommunicationManager, public ICommunicationManagerClient, CommonSocketFunctions +{ +public: + using CommunicationManager::StartCommunication; + + SingleCommunicationManagerClientViaSocket( ByteString aHost, ULONG nPort, BOOL bUseMultiChannel = FALSE ); + SingleCommunicationManagerClientViaSocket( BOOL bUseMultiChannel = FALSE ); + virtual BOOL StartCommunication(){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHostToTalk, nPortToTalk );} + virtual BOOL StartCommunication( ByteString aHost, ULONG nPort ){ return DoStartCommunication( this, (ICommunicationManagerClient*) this, aHost, nPort );} +private: + ByteString aHostToTalk; + ULONG nPortToTalk; +protected: + virtual CommunicationLink *CreateCommunicationLink( CommunicationManager *pCM, NAMESPACE_VOS(OConnectorSocket) *pCS ){ return new SimpleCommunicationLinkViaSocketWithReceiveCallbacks( pCM, pCS ); } +}; + +#endif diff --git a/automation/inc/makefile.mk b/automation/inc/makefile.mk new file mode 100644 index 000000000000..391de82d4216 --- /dev/null +++ b/automation/inc/makefile.mk @@ -0,0 +1,51 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=.. + +PRJNAME=automation +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/automation/inc/pch/precompiled_automation.cxx b/automation/inc/pch/precompiled_automation.cxx new file mode 100644 index 000000000000..3eec04310196 --- /dev/null +++ b/automation/inc/pch/precompiled_automation.cxx @@ -0,0 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: precompiled_automation.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_automation.hxx" + diff --git a/automation/inc/pch/precompiled_automation.hxx b/automation/inc/pch/precompiled_automation.hxx new file mode 100644 index 000000000000..011ac55f673c --- /dev/null +++ b/automation/inc/pch/precompiled_automation.hxx @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: precompiled_automation.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:30.061723 + +#ifdef PRECOMPILED_HEADERS +#endif + |