1*0d63794cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0d63794cSAndrew Rist * distributed with this work for additional information 6*0d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0d63794cSAndrew Rist * "License"); you may not use this file except in compliance 9*0d63794cSAndrew Rist * with the License. You may obtain a copy of the License at 10*0d63794cSAndrew Rist * 11*0d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*0d63794cSAndrew Rist * 13*0d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0d63794cSAndrew Rist * software distributed under the License is distributed on an 15*0d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0d63794cSAndrew Rist * KIND, either express or implied. See the License for the 17*0d63794cSAndrew Rist * specific language governing permissions and limitations 18*0d63794cSAndrew Rist * under the License. 19*0d63794cSAndrew Rist * 20*0d63794cSAndrew Rist *************************************************************/ 21*0d63794cSAndrew Rist 22*0d63794cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVP_SALINST_HXX 25cdf0e10cSrcweir #define _SVP_SALINST_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vos/mutex.hxx> 28cdf0e10cSrcweir #include <vos/thread.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <salinst.hxx> 31cdf0e10cSrcweir #include <salwtype.hxx> 32cdf0e10cSrcweir #include <saltimer.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <list> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <time.h> // timeval 37cdf0e10cSrcweir 38cdf0e10cSrcweir #define VIRTUAL_DESKTOP_WIDTH 1024 39cdf0e10cSrcweir #define VIRTUAL_DESKTOP_HEIGHT 768 40cdf0e10cSrcweir #define VIRTUAL_DESKTOP_DEPTH 24 41cdf0e10cSrcweir 42cdf0e10cSrcweir // ------------------------------------------------------------------------- 43cdf0e10cSrcweir // SalYieldMutex 44cdf0e10cSrcweir // ------------------------------------------------------------------------- 45cdf0e10cSrcweir 46cdf0e10cSrcweir class SvpSalYieldMutex : public vos::OMutex 47cdf0e10cSrcweir { 48cdf0e10cSrcweir protected: 49cdf0e10cSrcweir sal_uLong mnCount; 50cdf0e10cSrcweir vos::OThread::TThreadIdentifier mnThreadId; 51cdf0e10cSrcweir 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir SvpSalYieldMutex(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir virtual void acquire(); 56cdf0e10cSrcweir virtual void release(); 57cdf0e10cSrcweir virtual sal_Bool tryToAcquire(); 58cdf0e10cSrcweir GetAcquireCount() const59cdf0e10cSrcweir sal_uLong GetAcquireCount() const { return mnCount; } GetThreadId() const60cdf0e10cSrcweir vos::OThread::TThreadIdentifier GetThreadId() const { return mnThreadId; } 61cdf0e10cSrcweir }; 62cdf0e10cSrcweir 63cdf0e10cSrcweir // --------------- 64cdf0e10cSrcweir // - SalTimer - 65cdf0e10cSrcweir // --------------- 66cdf0e10cSrcweir class SvpSalInstance; 67cdf0e10cSrcweir class SvpSalTimer : public SalTimer 68cdf0e10cSrcweir { 69cdf0e10cSrcweir SvpSalInstance* m_pInstance; 70cdf0e10cSrcweir public: SvpSalTimer(SvpSalInstance * pInstance)71cdf0e10cSrcweir SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {} 72cdf0e10cSrcweir virtual ~SvpSalTimer(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir // overload all pure virtual methods 75cdf0e10cSrcweir virtual void Start( sal_uLong nMS ); 76cdf0e10cSrcweir virtual void Stop(); 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir // --------------- 80cdf0e10cSrcweir // - SalInstance - 81cdf0e10cSrcweir // --------------- 82cdf0e10cSrcweir class SvpSalFrame; 83cdf0e10cSrcweir class SvpSalInstance : public SalInstance 84cdf0e10cSrcweir { 85cdf0e10cSrcweir timeval m_aTimeout; 86cdf0e10cSrcweir sal_uLong m_nTimeoutMS; 87cdf0e10cSrcweir int m_pTimeoutFDS[2]; 88cdf0e10cSrcweir SvpSalYieldMutex m_aYieldMutex; 89cdf0e10cSrcweir 90cdf0e10cSrcweir // internal event queue 91cdf0e10cSrcweir struct SalUserEvent 92cdf0e10cSrcweir { 93cdf0e10cSrcweir const SalFrame* m_pFrame; 94cdf0e10cSrcweir void* m_pData; 95cdf0e10cSrcweir sal_uInt16 m_nEvent; 96cdf0e10cSrcweir SalUserEventSvpSalInstance::SalUserEvent97cdf0e10cSrcweir SalUserEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT ) 98cdf0e10cSrcweir : m_pFrame( pFrame ), 99cdf0e10cSrcweir m_pData( pData ), 100cdf0e10cSrcweir m_nEvent( nEvent ) 101cdf0e10cSrcweir {} 102cdf0e10cSrcweir }; 103cdf0e10cSrcweir 104cdf0e10cSrcweir oslMutex m_aEventGuard; 105cdf0e10cSrcweir std::list< SalUserEvent > m_aUserEvents; 106cdf0e10cSrcweir 107cdf0e10cSrcweir std::list< SalFrame* > m_aFrames; 108cdf0e10cSrcweir 109cdf0e10cSrcweir bool isFrameAlive( const SalFrame* pFrame ) const; 110cdf0e10cSrcweir 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir static SvpSalInstance* s_pDefaultInstance; 113cdf0e10cSrcweir 114cdf0e10cSrcweir SvpSalInstance(); 115cdf0e10cSrcweir virtual ~SvpSalInstance(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir void PostEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent ); 118cdf0e10cSrcweir void CancelEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir void StartTimer( sal_uLong nMS ); 121cdf0e10cSrcweir void StopTimer(); 122cdf0e10cSrcweir void Wakeup(); 123cdf0e10cSrcweir registerFrame(SalFrame * pFrame)124cdf0e10cSrcweir void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); } 125cdf0e10cSrcweir void deregisterFrame( SalFrame* pFrame ); getFrames() const126cdf0e10cSrcweir const std::list< SalFrame* >& getFrames() const { return m_aFrames; } 127cdf0e10cSrcweir 128cdf0e10cSrcweir bool CheckTimeout( bool bExecuteTimers = true ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir // Frame 131cdf0e10cSrcweir virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ); 132cdf0e10cSrcweir virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ); 133cdf0e10cSrcweir virtual void DestroyFrame( SalFrame* pFrame ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir // Object (System Child Window) 136cdf0e10cSrcweir virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ); 137cdf0e10cSrcweir virtual void DestroyObject( SalObject* pObject ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // VirtualDevice 140cdf0e10cSrcweir // nDX and nDY in Pixel 141cdf0e10cSrcweir // nBitCount: 0 == Default(=as window) / 1 == Mono 142cdf0e10cSrcweir // pData allows for using a system dependent graphics or device context 143cdf0e10cSrcweir virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, 144cdf0e10cSrcweir long nDX, long nDY, 145cdf0e10cSrcweir sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ); 146cdf0e10cSrcweir virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir // Printer 149cdf0e10cSrcweir // pSetupData->mpDriverData can be 0 150cdf0e10cSrcweir // pSetupData must be updatet with the current 151cdf0e10cSrcweir // JobSetup 152cdf0e10cSrcweir virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, 153cdf0e10cSrcweir ImplJobSetup* pSetupData ); 154cdf0e10cSrcweir virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ); 155cdf0e10cSrcweir virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ); 156cdf0e10cSrcweir virtual void DestroyPrinter( SalPrinter* pPrinter ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ); 159cdf0e10cSrcweir virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ); 160cdf0e10cSrcweir virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ); 161cdf0e10cSrcweir virtual String GetDefaultPrinter(); 162cdf0e10cSrcweir 163cdf0e10cSrcweir // SalTimer 164cdf0e10cSrcweir virtual SalTimer* CreateSalTimer(); 165cdf0e10cSrcweir // SalI18NImeStatus 166cdf0e10cSrcweir virtual SalI18NImeStatus* CreateI18NImeStatus(); 167cdf0e10cSrcweir // SalSystem 168cdf0e10cSrcweir virtual SalSystem* CreateSalSystem(); 169cdf0e10cSrcweir // SalBitmap 170cdf0e10cSrcweir virtual SalBitmap* CreateSalBitmap(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // YieldMutex 173cdf0e10cSrcweir virtual vos::IMutex* GetYieldMutex(); 174cdf0e10cSrcweir virtual sal_uLong ReleaseYieldMutex(); 175cdf0e10cSrcweir virtual void AcquireYieldMutex( sal_uLong nCount ); 176cdf0e10cSrcweir virtual bool CheckYieldMutex(); 177cdf0e10cSrcweir 178cdf0e10cSrcweir // wait next event and dispatch 179cdf0e10cSrcweir // must returned by UserEvent (SalFrame::PostEvent) 180cdf0e10cSrcweir // and timer 181cdf0e10cSrcweir virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); 182cdf0e10cSrcweir virtual bool AnyInput( sal_uInt16 nType ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir // may return NULL to disable session management 185cdf0e10cSrcweir virtual SalSession* CreateSalSession(); 186cdf0e10cSrcweir 187cdf0e10cSrcweir virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); 190cdf0e10cSrcweir }; 191cdf0e10cSrcweir 192cdf0e10cSrcweir #endif // _SV_SALINST_HXX 193