update dev300-m58
[ooovba.git] / automation / source / server / server.cxx
blob916bbc44129cd0a69acd1f146f5e4faabaa73a03
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: server.cxx,v $
10 * $Revision: 1.26 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_automation.hxx"
34 // do not use Application Idle but AutoTimer instead
35 #define TIMERIDLE
37 #define NO_JPEG
39 #ifndef NO_JPEG
40 #include <svtools/jpeg.hxx>
41 #endif
42 #include <vcl/timer.hxx>
43 #include <vcl/wrkwin.hxx>
44 #include <osl/diagnose.h>
45 #include <osl/mutex.hxx>
47 #ifndef _DIALOG_HXX //autogen
48 #include <vcl/dialog.hxx>
49 #endif
50 #include <tools/stream.hxx>
51 #include <tools/config.hxx>
53 #include <vos/socket.hxx>
55 #if 1
56 #include <svtools/ttprops.hxx>
57 #include <basic/ttstrhlp.hxx>
58 #include <svtools/stritem.hxx>
59 #include <svtools/stringtransfer.hxx>
60 #include <vcl/sound.hxx>
61 #include "testtool.hrc"
62 #include <vcl/bitmap.hxx>
63 // Hat keinen Includeschutz
64 #include <svtools/svtdata.hxx>
65 //#ifndef _DTRANS_HXX //autogen
66 //#include <so2/dtrans.hxx>
67 //#endif
68 #endif // 1
69 #include <rtl/textenc.h>
70 #include <rtl/uri.h>
71 #include <rtl/uri.hxx>
72 #include "statemnt.hxx"
73 #include "scmdstrm.hxx"
74 #include "rcontrol.hxx"
75 #include "server.hxx"
76 #include "testtool.hxx"
77 #include "automation/automation.hxx"
78 #include "recorder.hxx"
80 #include "basic/svtmsg.hrc"
82 #ifdef DBG_UTIL
83 void TestToolDebugPrint( const sal_Char *pString )
85 if ( !DbgFilterMessage( pString ) )
86 StatementList::DirectLog( S_AssertError, UniString( pString, RTL_TEXTENCODING_UTF8 ) );
88 void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString )
90 TestToolDebugPrint( pString );
92 #endif
95 ULONG RemoteControlCommunicationManager::nPortIs = TT_PORT_NOT_INITIALIZED;
96 USHORT RemoteControlCommunicationManager::nComm = 0;
97 BOOL RemoteControlCommunicationManager::bQuiet = FALSE;
99 #if OSL_DEBUG_LEVEL > 1
100 RemoteControlCommunicationManager::RemoteControlCommunicationManager( EditWindow * pDbgWin )
101 #else
102 RemoteControlCommunicationManager::RemoteControlCommunicationManager()
103 #endif
104 : CommunicationManagerServerViaSocket( GetPort(), 1, TRUE )
105 #if OSL_DEBUG_LEVEL > 1
106 , m_pDbgWin( pDbgWin )
107 #endif
108 , pTimer( NULL )
110 bIsPortValid = ( GetPort() != 0 );
111 if ( bQuiet )
113 SetInfoType( CM_NO_TEXT );
115 else
117 SetInfoType( CM_SHORT_TEXT | CM_ALL );
118 ByteString aByteString;
119 InfoMsg( InfoString( aByteString, CM_ALL ) ); // Anzeigen, daß wir da sind
123 RemoteControlCommunicationManager::~RemoteControlCommunicationManager()
125 if ( pTimer )
126 delete pTimer;
127 DoQuickShutdown();
130 void RemoteControlCommunicationManager::ConnectionOpened( CommunicationLink* pCL )
132 StatementFlow::pCommLink = pCL;
133 CommunicationManagerServerViaSocket::ConnectionOpened( pCL );
137 void RemoteControlCommunicationManager::ConnectionClosed( CommunicationLink* pCL )
139 StatementFlow::pCommLink = NULL;
140 CommunicationManagerServerViaSocket::ConnectionClosed( pCL );
144 IMPL_LINK( RemoteControlCommunicationManager, SetWinCaption, Timer*, EMPTYARG )
146 if ( pTimer )
148 delete pTimer;
149 pTimer = NULL;
152 if ( StatementList::GetFirstDocFrame() )
154 if ( !aOriginalWinCaption.Len() )
155 aOriginalWinCaption = StatementList::GetFirstDocFrame()->GetText();
156 StatementList::GetFirstDocFrame()->SetText(String(aOriginalWinCaption).AppendAscii(" TT").Append(aAdditionalWinCaption).AppendAscii("[").Append(UniString::CreateFromInt32(nPortToListen)).AppendAscii("]"));
158 else
159 { // Dann Probieren wir es eben in 1 Sekunde nochmal
160 pTimer = new Timer(); // Wird im Link gelöscht
161 pTimer->SetTimeout( 1000 );
162 pTimer->SetTimeoutHdl( LINK( this, RemoteControlCommunicationManager, SetWinCaption ) );
163 pTimer->Start();
165 return 0;
168 void RemoteControlCommunicationManager::InfoMsg( InfoString aMsg )
170 if ( !bIsPortValid )
171 return;
172 aAdditionalWinCaption = UniString( aMsg, RTL_TEXTENCODING_ASCII_US );
173 SetWinCaption();
174 #if OSL_DEBUG_LEVEL > 1
175 m_pDbgWin->AddText( UniString( (ByteString)aMsg, RTL_TEXTENCODING_ASCII_US ) );
176 m_pDbgWin->AddText( "\n" );
177 #endif
180 ULONG RemoteControlCommunicationManager::GetPort()
182 if ( TT_PORT_NOT_INITIALIZED == nPortIs )
183 { // Read Config
185 USHORT i;
186 // are we to be automated at all?
187 BOOL bAutomate = FALSE;
188 for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
190 if ( Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("/enableautomation")
191 || Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("-enableautomation"))
193 bAutomate = TRUE;
194 break;
198 // if started within Portal determin location of testtool.ini/rc by analysing the commandline
199 // /userid:demo1[/export/home/user/demo1]
200 // -userid:demo1[/export/home/user/demo1]
201 String aIniFileDir;
202 for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
204 if ( Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("/userid:")
205 || Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("-userid:") )
207 rtl::OUString aEncHome
208 = Application::GetCommandLineParam(i).GetBuffer();
210 rtl::OUString aDecHome = rtl::Uri::decode(aEncHome,
211 rtl_UriDecodeWithCharset,
212 RTL_TEXTENCODING_UTF8);
214 aIniFileDir = aDecHome;
215 aIniFileDir.Erase( 0, aIniFileDir.Search('[')+1 );
216 aIniFileDir.Erase( aIniFileDir.Search(']') );
220 if ( ! aIniFileDir.Len() )
221 aIniFileDir = Config::GetDefDirectory();
223 Config aConf(Config::GetConfigName( aIniFileDir, CUniString("testtool") ));
224 aConf.SetGroup("Communication");
226 ByteString aNoTesttoolKey( ByteString("Exclude_").Append( ByteString( Application::GetAppFileName(), RTL_TEXTENCODING_UTF8 ) ) );
227 // -notesttool
228 for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
230 if ( Application::GetCommandLineParam( i ).CompareIgnoreCaseToAscii("-notesttool") == COMPARE_EQUAL )
231 aConf.WriteKey( aNoTesttoolKey, "something" );
234 nPortIs = aConf.ReadKey("TTPort","0").ToInt32();
236 // noch prüfen ob dieses Office getestet werden soll.
237 if ( !bAutomate || aConf.ReadKey( aNoTesttoolKey, "" ) != "" )
238 nPortIs = 0;
240 nComm = (USHORT)aConf.ReadKey("Comm","0").ToInt32();
241 if ( nComm )
242 aConf.DeleteKey("Comm");
244 bQuiet = ( aConf.ReadKey("Quiet","no").CompareIgnoreCaseToAscii("yes") == COMPARE_EQUAL );
246 return nPortIs;
249 #if OSL_DEBUG_LEVEL > 1
250 #define MIN_IDLE 10000 // Ruhe vor dem Sturm min 10 Sekunden
251 #else
252 #define MIN_IDLE 60000 // Ruhe vor dem Sturm min 1 Minuten
253 #endif
255 class ExtraIdle : public AutoTimer
257 virtual void Timeout();
259 USHORT nStep;
260 ImplRemoteControl *pRemoteControl;
261 public:
262 ExtraIdle( ImplRemoteControl *pRC );
266 ExtraIdle::ExtraIdle( ImplRemoteControl *pRC )
267 : nStep( 0 )
268 , pRemoteControl (pRC )
270 SetTimeout( 120000 ); // 2 Minuten
271 #if OSL_DEBUG_LEVEL > 1
272 SetTimeout( 40000 ); // 40 Sekunden
273 #endif
274 Start();
277 void ExtraIdle::Timeout()
279 if ( !StatementList::pTTProperties )
280 StatementList::pTTProperties = new TTProperties();
282 if ( !StatementList::pTTProperties->GetSlots() )
284 delete this;
285 return;
288 // Müssen wir selbst idlen?
289 #if OSL_DEBUG_LEVEL > 1
290 ULONG nLastInputInterval = Application::GetLastInputInterval();
291 BOOL bIsInModalMode = Application::IsInModalMode();
292 if ( bIsInModalMode || nLastInputInterval < MIN_IDLE )
293 #else
294 if ( Application::IsInModalMode() || Application::GetLastInputInterval() < MIN_IDLE )
295 #endif
297 if ( nStep ) // Schon angefangen? dann abbrechen, sonst später nochmal
299 if ( nStep < 15 )
301 Sound::Beep();
302 Sound::Beep();
304 #if OSL_DEBUG_LEVEL < 2
305 delete this;
306 #endif
308 #if OSL_DEBUG_LEVEL > 1
309 if ( nStep < 15 )
311 Sound::Beep();
312 Sound::Beep();
314 #endif
315 return;
318 if ( StatementList::pFirst ) // Verarbeitung neu aufsetzen
320 GetpApp()->PostUserEvent( LINK( pRemoteControl, ImplRemoteControl, CommandHdl ) );
321 return;
325 switch ( nStep++ ) // Probieren ob wir noch was machen können
327 case 0:
329 SfxPoolItem *pItem = new SfxStringItem((USHORT)StatementList::pTTProperties->nSidNewDocDirect, CUniString("swriter/web") );
330 new StatementSlot( StatementList::pTTProperties->nSidNewDocDirect, pItem );
331 SetTimeout(30000);
332 return;
334 case 1:
336 new StatementSlot( StatementList::pTTProperties->nSidSourceView );
337 #if OSL_DEBUG_LEVEL > 1
338 SetTimeout(7000);
339 #else
340 SetTimeout(1500);
341 #endif
342 return;
344 case 2:
346 new StatementSlot( StatementList::pTTProperties->nSidSelectAll );
347 return;
349 case 3:
352 #if OSL_DEBUG_LEVEL > 1
353 //#define TT_NO_DECRYPT
354 #define TT_CODE
355 #else
356 #define TT_CODE
357 #endif
359 #ifdef TT_NO_DECRYPT
360 String aStr =
364 #else
365 ByteString aStr =
366 "\n"
367 "VRQJ`ob\n"
368 "YEZO\n"
369 "ob\n"
370 "UmRo`\n"
371 "5J~O2o5+90~5,6xW$+5:c9o0UXRm`Y UQ~JP~X]`Y\\|%Y`Yo]~O||2[pP0Y1J,|V),,7:,+|JS+U*[/O|K\n"
372 "|KaLYNV~]]2W/]*Y9|`*Y,P=[5P|U\n"
373 "]}mqbw`zZU\\L\n"
374 "LZdYWo9\n"
375 "/J\n"
376 "U~[QoZ\n"
377 "Rqd~V\n"
378 ",)1~00\n"
379 "\n"
380 ")0~*2=\n"
381 "++2\\5&K|~5n9r~9/*9<*~051*Q|0~0rY|~./97~Q*7,Z9<|KY0:=K*<=w~qY`IbOKzLwN,`7b,V~]E`]b\\ORE~\n"
382 "\n"
383 "Vq~bR`W;a+Y\\J=LKJa+W*I/PbR~JLUX[|b~`Z2P/R*[9a~W=9~/9p8=a*P=J0OZ~7L`JbL=P<WbaLQbPO]JYKbD\n"
384 "aY`J5J:b~7=2~+9)9W1,50b9X3P0`YbYVJ`Jb \\`Z]`Vb\n"
385 "VRQJ`b"
387 #endif
389 #ifdef TT_CODE
390 for ( USHORT i = 0 ; i < aStr.Len() ; i++ )
392 if ( aStr.GetChar(i) < 32 || aStr.GetChar(i) > 126 )
394 // do nothing
396 else
398 aStr.SetChar( i, aStr.GetChar(i) - 32 );
399 aStr.SetChar( i, 126 - aStr.GetChar(i) );
402 if ( i > (aStr.Len() / 2) && (i&1) )
404 sal_Char c = aStr.GetChar(i);
405 aStr.SetChar( i, aStr.GetChar(aStr.Len()-i-1) );
406 aStr.SetChar( aStr.Len()-i-1, c );
409 #endif
411 ::svt::OStringTransfer::CopyString( UniString( aStr, RTL_TEXTENCODING_ASCII_US ), StatementList::GetFirstDocFrame() );
413 new StatementSlot( StatementList::pTTProperties->nSidPaste );
414 return;
416 case 4:
418 new StatementSlot( StatementList::pTTProperties->nSidSourceView );
419 return;
421 case 5:
423 new StatementSlot( StatementList::pTTProperties->nSidSelectAll );
424 new StatementSlot( StatementList::pTTProperties->nSidCopy );
425 new StatementSlot( StatementList::pTTProperties->nSidPaste );
426 return;
428 case 6:
430 ByteString aTr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-");
431 ByteString aData =
432 "P-S-0U04Fihixh00l0004b0b300-PS0g30428333y243q334j44426a6a65576c8k97aJecf7feccedg2inj3ghlshde5krk+lno"
433 "PpqpBfjsgusp1unp-po-PS0gm044x465e6b6L6boygeg-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo"
434 "-ooo-ooo-oo-1M04020Y30J0o080B040R040M-N0M700l010l000k000000000006000N011I112r222M-N0gJ40D000U001R011"
435 "0110500vr0001014p148mcg1R4koV18s95cwkAE2V8gImM5kgQY9WcosCw22I556p669I99aoaadrddd6eeeNghhIhhiriik6lll"
436 "NlmmImoprppp6qqqNsttItturuuw6xxxNxyyHyAA6BBBNBCCHCEE6FFFNFGGHGII6JJJNJKKHKMM6NNNNNOOHOQQ6RRRNRSSCSUU"
437 "NUVVIVVWpWWYIYYZrZZZ6+++M-N0Q700R000l000l000g00000006000N011I112r222M-N0kJ40C0003110d1110110r00t6000"
438 "Q041l18cF14gtk1ous48Acw295gAlEIMv28cxkY5FosQE2595dU9sY56q669N9aaCaddNdeeIeghrhhh6iiiNkllIllmrmmo6ppp"
439 "NpqqIqstrttt6uuuIwwxrxxx6yyyIAABrBBB6CCCIEEFrFFF6GGGIIIJrJJJ6KKKIMMNrNNN6OOOIQQRrRRR6SSSIUUVrVVV6WWW"
440 "IYYZrZZZ6+++U-S0d3009004Q040Of0TPU5QGjFCdPoji85WiqEopkCag321kP8dW4yO4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ANqcqvan4y0Erpl01fAfmLaI8pmOgsRUDvuF5e9YnWNhxtSzS4fsjj1J"
493 "1EIGpcw0WfiaOul1s19ZIECoLBx-#S";
496 //#if OSL_DEBUG_LEVEL > 1
497 // SvFileStream aStream( "d:\\gh_writeback.jpg" , STREAM_STD_READWRITE | STREAM_TRUNC );
498 //#else
499 SvMemoryStream aStream;
500 //#endif
501 xub_StrLen c;
502 xub_StrLen cRest = 0;
504 xub_StrLen nIndex;
505 for ( nIndex = 0 ; nIndex < aData.Len() ; nIndex++ )
507 if ( ( nIndex & 3 ) == 0 )
509 cRest = aData.GetChar( nIndex );
510 cRest = aTr.Search( (sal_Char)cRest );
512 else
514 c = aData.GetChar( nIndex );
515 c = aTr.Search( (sal_Char)c );
517 c <<= 2;
518 c |= ( ( cRest & 0x30 ) >> 4 );
519 cRest <<= 2;
521 aStream << sal_Char(c);
525 aStream.Seek(0);
526 #ifndef NO_JPEG
527 Graphic aGraphic;
528 if ( ImportJPEG( aStream, aGraphic, NULL ) )
530 Bitmap *pBmp = new Bitmap( aGraphic.GetBitmap() );
531 StatementList::pTTProperties->Img( pBmp );
532 delete pBmp;
534 else
535 #endif
537 ::svt::OStringTransfer::CopyString( CUniString("\nSorry! no bitmap"), StatementList::GetFirstDocFrame() );
540 /***********************************************************************
541 // USHORT nBC = pBmp->GetBitCount();
542 // pBmp->Scale( 0.02, 0.02 );
543 // nBC = pBmp->GetBitCount();
544 // SvMemoryStream aStream;
545 SvFileStream aStream( "d:\gh_small50.jpg", STREAM_STD_READ );
547 aStream.Seek( 0 );
548 xub_StrLen c;
549 String aOut;
550 String aDreierGruppe;
551 xub_StrLen cRest=0;
552 aStream >> c;
553 while ( !aStream.IsEof() )
555 cRest <<= 2; // Im ersten Durchgang egal, da immer 0
556 cRest |= ( c & 0x03 );
557 c >>= 2;
558 aDreierGruppe += aTr.GetChar( c );
560 if ( aDreierGruppe.Len() == 3 )
562 aOut += aTr.GetChar( cRest );
563 aOut += aDreierGruppe;
564 cRest = 0;
565 aDreierGruppe = "";
567 aStream >> c;
569 if ( aDreierGruppe.Len() )
571 aOut += cRest;
572 aOut += aDreierGruppe;
574 ::svt::OStringTransfer::CopyString( aOut );
575 **********************************************************************************/
577 new StatementSlot( StatementList::pTTProperties->nSidPaste );
578 return;
580 case 7:
582 new StatementSlot( 20384 ); // FN_TOOL_ANKER_CHAR aus SW?
583 return;
587 // Wir sind am Ende
589 #if OSL_DEBUG_LEVEL < 2
590 delete this;
591 #endif
594 IMPL_LINK( ImplRemoteControl, IdleHdl, Application*, EMPTYARG )
596 if( StatementList::pFirst )
598 #if OSL_DEBUG_LEVEL > 1
599 m_pDbgWin->AddText( "* " );
600 #endif
601 GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) );
603 return 0;
608 IMPL_LINK( ImplRemoteControl, CommandHdl, Application*, EMPTYARG )
610 #if OSL_DEBUG_LEVEL > 1
611 m_pDbgWin->AddText( "Entering CommandHdl\n" );
612 #endif
614 if ( StatementList::MaybeResetSafeReschedule() )
616 StatementList::bExecuting = FALSE; // Wird nacher im SafeReschedule wieder zurückgesetzt
617 #if OSL_DEBUG_LEVEL > 1
618 m_pDbgWin->AddText( "SafeReschedule has been reset\n" );
619 #endif
622 if ( ( StatementList::bReadingCommands && !StatementList::bDying ) ||
623 ( StatementList::bExecuting ) ||
624 ( StatementList::IsInReschedule() ) )
626 #if OSL_DEBUG_LEVEL > 1
627 if ( StatementList::bReadingCommands )
628 m_pDbgWin->AddText( "Reading Commands " );
629 if ( StatementList::bExecuting )
630 m_pDbgWin->AddText( "In Execute " );
631 if ( StatementList::IsInReschedule() )
633 m_pDbgWin->AddText( "In Reschedule FocusWindow: 0x" );
634 m_pDbgWin->AddText(
635 String::CreateFromInt64(
636 sal::static_int_cast< sal_Int64 >(
637 reinterpret_cast< sal_IntPtr >(GetpApp()->GetFocusWindow())),
638 16 ));
639 m_pDbgWin->AddText( " " );
641 m_pDbgWin->AddText( "Leaving CommandHdl\n" );
642 #endif
643 return 0; // Garnicht erst irgendwelchen blödsinn machen
646 while( StatementList::pFirst && ( !StatementList::bReadingCommands || StatementList::bDying ) )
647 // Schleift hier bis Befehl nicht zurückkommt,
648 // Wird dann rekursiv über IdleHdl und PostUserEvent aufgerufen.
650 m_bInsideExecutionLoop = TRUE;
651 #ifdef TIMERIDLE
652 m_aIdleTimer.Stop();
653 m_aIdleTimer.Start();
654 #endif
655 StatementList *pC = StatementList::pFirst;
657 // MessBox MB( pMainWin, WB_DEF_OK|WB_OK, "Pause ...", "... und Weiter" );
658 // MB.Execute();
660 if ( !StatementList::bCatchGPF )
662 if (!pC->CheckWindowWait() || !pC->Execute())
664 #if OSL_DEBUG_LEVEL > 1
665 m_pDbgWin->AddText( "Leaving CommandHdl\n" );
666 #endif
667 return 0; // So dass die App nochmal ´ne chance bekommt
670 else
674 if (!pC->CheckWindowWait() || !pC->Execute())
676 #if OSL_DEBUG_LEVEL > 1
677 m_pDbgWin->AddText( "Leaving CommandHdl\n" );
678 #endif
679 return 0; // So dass die App nochmal ´ne chance bekommt
682 catch( ... )
684 if ( !StatementFlow::bUseIPC )
685 throw; // aus der Hilfe heraus nicht leise abbrechen
689 ModelessDialog *pDlg = new ModelessDialog(NULL);
690 pDlg->SetOutputSizePixel(Size(150,0));
691 pDlg->SetText( String ( TTProperties::GetSvtResId( TT_GPF ) ) );
692 pDlg->Show();
693 DBG_ERROR("GPF");
694 pC->ReportError( GEN_RES_STR0( S_GPF_ABORT ) );
695 StatementList::bDying = TRUE;
696 while ( StatementList::pFirst ) // Kommandos werden übersprungen
697 StatementList::NormalReschedule();
698 delete pDlg;
700 catch ( ... )
702 Application::Quit();
704 Application::Quit();
708 /* #i46293# remove reschedules
709 for (int xx = 1;xx < 20;xx++)
710 StatementList::NormalReschedule();
712 m_bInsideExecutionLoop = FALSE;
715 StatementList::aWindowWaitUId = SmartId(); // Warten rücksetzen, da handler sowieso verlassen wird
717 /* if( StatementList::pFirst && !StatementList::bReadingCommands )
718 // Abfrage nötig, da andere CommandHdl aktiv sein können oder
719 // neue Commands gelesen werden können
721 delete StatementList::pFirst; // Löscht die gesamte Liste !!
722 StatementList::pFirst = NULL;
723 StatementList::pCurrent = NULL; // Nur zur Sicherheit, sollte hier sowieso NULL sein
726 #if OSL_DEBUG_LEVEL > 1
727 m_pDbgWin->AddText( "Leaving CommandHdl\n" );
728 #endif
729 return 0;
732 IMPL_LINK( ImplRemoteControl, QueCommandsEvent, CommunicationLink*, pCL )
734 SvStream *pTemp = pCL->GetServiceData();
735 QueCommands( SI_IPCCommandBlock, pTemp );
736 delete pTemp;
737 return 0;
740 BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn )
742 // return TRUE;
743 USHORT nId;
745 if( !m_bIdleInserted )
747 #ifdef TIMERIDLE
748 m_aIdleTimer.SetTimeoutHdl( LINK( this, ImplRemoteControl, IdleHdl ) );
749 m_aIdleTimer.SetTimeout( 500 );
750 m_aIdleTimer.Start();
751 #else
752 GetpApp()->InsertIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ), 1 );
753 #endif
754 m_bIdleInserted = TRUE;
758 StatementList::bReadingCommands = TRUE;
760 #if OSL_DEBUG_LEVEL > 1
761 if (!m_pDbgWin->bQuiet)
762 m_pDbgWin->Show();
763 m_pDbgWin->AddText( "Reading " );
764 m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) );
765 m_pDbgWin->AddText( " :\n" );
766 #endif
768 if( nServiceId != SI_IPCCommandBlock && nServiceId != SI_DirectCommandBlock )
770 DBG_ERROR1( "Ungültiger Request :%i", (int)nServiceId );
771 return FALSE;
774 SCmdStream *pCmdStream = new SCmdStream(pIn);
776 pCmdStream->Read( nId );
777 while( !pIn->IsEof() )
779 switch( nId )
781 case SICommand:
783 new StatementCommand( pCmdStream ); // Wird im Konstruktor an Liste angehängt
784 break;
786 case SIControl:
787 case SIStringControl:
789 new StatementControl( pCmdStream, nId ); // Wird im Konstruktor an Liste angehängt
790 break;
792 case SISlot:
794 new StatementSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt
795 break;
797 case SIUnoSlot:
799 new StatementUnoSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt
800 break;
802 case SIFlow:
804 new StatementFlow( nServiceId, pCmdStream, this ); // Wird im Konstruktor an Liste angehängt
805 break;
807 default:
808 DBG_ERROR1( "Unbekannter Request Nr:%i", nId );
809 break;
811 if( !pIn->IsEof() )
812 pCmdStream->Read( nId );
813 else {
814 DBG_ERROR( "truncated input stream" );
818 StatementList::bReadingCommands = FALSE;
820 delete pCmdStream;
821 #if OSL_DEBUG_LEVEL > 1
822 m_pDbgWin->AddText( "Done Reading " );
823 m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) );
824 m_pDbgWin->AddText( " :\n" );
825 #endif
826 if ( !m_bInsideExecutionLoop )
828 #ifdef DEBUG
829 m_pDbgWin->AddText( "Posting Event for CommandHdl.\n" );
830 #endif
832 GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) );
834 #ifdef DEBUG
835 else
836 m_bInsideExecutionLoop = TRUE;
837 #endif
838 return TRUE;
839 } // BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn )
842 SvStream* ImplRemoteControl::GetReturnStream()
844 SvStream* pTemp = pRetStream;
845 pRetStream = NULL;
846 return pTemp;
849 ImplRemoteControl::ImplRemoteControl()
850 : m_bIdleInserted( FALSE )
851 , m_bInsideExecutionLoop( FALSE )
852 #if OSL_DEBUG_LEVEL > 1
853 , m_pDbgWin(NULL)
854 #endif
855 , pRetStream(NULL)
857 #if OSL_DEBUG_LEVEL > 1
858 if ( RemoteControlCommunicationManager::GetPort() != TT_NO_PORT_DEFINED || RemoteControlCommunicationManager::nComm )
860 m_pDbgWin = new EditWindow( NULL, CUniString("Debug Window"), WB_VSCROLL );
861 m_pDbgWin->bQuiet = TRUE;
862 m_pDbgWin->Hide();
863 StatementList::m_pDbgWin = m_pDbgWin;
865 #endif
866 if ( RemoteControlCommunicationManager::GetPort() == TT_NO_PORT_DEFINED )
867 pServiceMgr = NULL;
868 else
870 #if OSL_DEBUG_LEVEL > 1
871 pServiceMgr = new RemoteControlCommunicationManager( m_pDbgWin );
872 #else
873 pServiceMgr = new RemoteControlCommunicationManager();
874 #endif
875 pServiceMgr->SetDataReceivedHdl( LINK( this, ImplRemoteControl, QueCommandsEvent ) );
876 pServiceMgr->StartCommunication();
878 #ifdef DBG_UTIL
879 DbgSetPrintTestTool( TestToolDebugPrint );
880 // first change it, so we get the original Pointer
881 StatementCommand::pOriginal_osl_DebugMessageFunc = osl_setDebugMessageFunc( osl_TestToolDebugPrint );
882 if ( DbgGetErrorOut() != DBG_OUT_TESTTOOL )
883 osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc );
884 #endif
886 if ( RemoteControlCommunicationManager::nComm )
887 new ExtraIdle( this ); // Setzt die Bearbeitung wieder auf
890 ImplRemoteControl::~ImplRemoteControl()
892 if ( MacroRecorder::HasMacroRecorder() )
893 MacroRecorder::GetMacroRecorder()->SetActionRecord( FALSE ); // Will delete MacroRecorder if necessary
896 StatementList::bDying = TRUE;
897 #if OSL_DEBUG_LEVEL > 1
898 if ( m_pDbgWin )
899 m_pDbgWin->bQuiet = TRUE; // Keine Ausgabe mehr im Debugwindow
900 #endif
902 #ifdef DBG_UTIL
903 // Zurücksetzen, so daß nachfolgende Assertions nicht verloren gehen
904 DbgSetPrintTestTool( NULL );
905 osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc );
906 #endif
908 if ( StatementList::pFirst )
909 { // Es sind noch Kommandos da, also auch eine Möglichkeit zurückzusenden.
910 StatementList::pFirst->ReportError( GEN_RES_STR0( S_APP_SHUTDOWN ) );
911 while ( StatementList::pFirst ) // Kommandos werden übersprungen
912 StatementList::NormalReschedule(); // Fehler zurückgeschickt
915 if ( pServiceMgr )
916 pServiceMgr->StopCommunication();
918 if ( GetTTSettings()->pDisplayHidWin )
920 delete (Window*)(GetTTSettings()->pDisplayHidWin);
921 GetTTSettings()->pDisplayHidWin = NULL;
923 if ( GetTTSettings()->pTranslateWin )
925 delete (Window*)(GetTTSettings()->pTranslateWin);
926 GetTTSettings()->pTranslateWin = NULL;
928 #if OSL_DEBUG_LEVEL > 1
929 delete m_pDbgWin;
930 #endif
931 if( m_bIdleInserted )
933 #ifdef TIMERIDLE
934 m_aIdleTimer.Stop();
935 #else
936 GetpApp()->RemoveIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ) );
937 #endif
938 m_bIdleInserted = FALSE;
940 delete pServiceMgr;
943 RemoteControl::RemoteControl()
945 pImpl = new ImplRemoteControl;
948 RemoteControl::~RemoteControl()
950 delete pImpl;
953 static ::osl::Mutex aMutex;
954 static RemoteControl* pRemoteControl = 0;
955 extern "C" void CreateRemoteControl()
957 if ( !pRemoteControl )
959 ::osl::MutexGuard aGuard( aMutex );
960 if ( !pRemoteControl )
961 pRemoteControl = new RemoteControl();
965 extern "C" void DestroyRemoteControl()
967 ::osl::MutexGuard aGuard( aMutex );
968 delete pRemoteControl;
969 pRemoteControl = 0;
972 extern "C" void CreateEventLogger()
974 MacroRecorder::GetMacroRecorder()->SetActionLog();
977 extern "C" void DestroyEventLogger()
979 MacroRecorder::GetMacroRecorder()->SetActionLog( FALSE ); // Will delete MacroRecorder if necessary