2 Copyright (c) 2001, Loki software, inc.
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
15 Neither the name of Loki software nor the names of its contributors may be used
16 to endorse or promote products derived from this software without specific prior
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //-----------------------------------------------------------------------------
34 // monitoring window for running BSP processes (and possibly various other stuff)
37 #include "globaldefs.h"
43 #include "string/string.h"
44 #include "stream/stringstream.h"
46 #include "gtkutil/messagebox.h"
49 #include "preferences.h"
52 #include "mainframe.h"
55 void message_flush( message_info_t* self ){
56 Sys_Print( self->msg_level, self->m_buffer, self->m_length );
60 void message_print( message_info_t* self, const char* characters, std::size_t length ){
61 const char* end = characters + length;
62 while ( characters != end )
64 std::size_t space = message_info_t::bufsize - 1 - self->m_length;
66 message_flush( self );
70 std::size_t size = std::min( space, std::size_t( end - characters ) );
71 memcpy( self->m_buffer + self->m_length, characters, size );
72 self->m_length += size;
80 #include <uilib/uilib.h>
86 // a flag we have set to true when using an external BSP plugin
87 // the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop
88 // (in two seperate classes probably)
91 // EIdle: we are not listening
92 // DoMonitoringLoop will change state to EBeginStep
93 // EBeginStep: the socket is up for listening, we are expecting incoming connection
94 // incoming connection will change state to EWatching
95 // EWatching: we have a connection, monitor it
96 // connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle)
97 enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState;
98 socket_t *m_pListenSocket;
99 socket_t *m_pInSocket;
102 // used to timeout EBeginStep
104 std::size_t m_iCurrentStep;
105 // name of the map so we can run the engine
107 // buffer we use in push mode to receive data directly from the network
108 xmlParserInputBufferPtr m_xmlInputBuffer;
109 xmlParserInputPtr m_xmlInput;
110 xmlParserCtxtPtr m_xmlParserCtxt;
111 // call this to switch the set listening mode
112 bool SetupListening();
113 // start a new EBeginStep
115 // the xml and sax parser state
116 char m_xmlBuf[MAX_NETMESSAGE];
117 bool m_bNeedCtxtInit;
118 message_info_t m_message_info;
123 m_bBSPPlugin = false;
124 m_pListenSocket = NULL;
127 m_pTimer = g_timer_new();
129 m_xmlInputBuffer = NULL;
130 m_bNeedCtxtInit = true;
132 virtual ~CWatchBSP(){
136 g_timer_destroy( m_pTimer );
139 bool HasBSPPlugin() const
140 { return m_bBSPPlugin; }
142 // called regularly to keep listening
143 void RoutineProcessing();
144 // start a monitoring loop with the following steps
145 void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName );
146 void EndMonitoringLoop(){
149 string_release( m_sBSPName, string_length( m_sBSPName ) );
153 g_ptr_array_free( m_pCmd, TRUE );
157 // close everything - may be called from the outside to abort the process
159 // start a listening loop for an external process, possibly a BSP plugin
160 void ExternalListen();
163 CWatchBSP* g_pWatchBSP;
165 // watch the BSP process through network connections
166 // true: trigger the BSP steps one by one and monitor them through the network
167 // false: create a BAT / .sh file and execute it. don't bother monitoring it.
168 bool g_WatchBSP_Enabled = true;
169 // do we stop the compilation process if we come accross a leak?
170 bool g_WatchBSP_LeakStop = true;
171 bool g_WatchBSP_RunQuake = false;
172 // store prefs setting for automatic sleep mode activation
173 bool g_WatchBSP_DoSleep = true;
174 // timeout when beginning a step (in seconds)
175 // if we don't get a connection quick enough we assume something failed and go back to idling
176 int g_WatchBSP_Timeout = 10;
179 void Build_constructPreferences( PreferencesPage& page ){
180 ui::CheckButton monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled );
181 ui::CheckButton leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop );
182 ui::CheckButton runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake );
183 ui::CheckButton sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep );
184 Widget_connectToggleDependency( leakstop, monitorbsp );
185 Widget_connectToggleDependency( runengine, monitorbsp );
186 Widget_connectToggleDependency( sleep, runengine );
188 void Build_constructPage( PreferenceGroup& group ){
189 PreferencesPage page( group.createPage( "Build", "Build Preferences" ) );
190 Build_constructPreferences( page );
192 void Build_registerPreferencesPage(){
193 PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) );
196 #include "preferencesystem.h"
197 #include "stringio.h"
199 void BuildMonitor_Construct(){
200 g_pWatchBSP = new CWatchBSP();
202 g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" );
204 GlobalPreferenceSystem().registerPreference( "WatchBSP", make_property_string( g_WatchBSP_Enabled ) );
205 GlobalPreferenceSystem().registerPreference( "RunQuake2Run", make_property_string( g_WatchBSP_RunQuake ) );
206 GlobalPreferenceSystem().registerPreference( "LeakStop", make_property_string( g_WatchBSP_LeakStop ) );
207 GlobalPreferenceSystem().registerPreference( "SleepMode", make_property_string( g_WatchBSP_DoSleep ) );
209 Build_registerPreferencesPage();
212 void BuildMonitor_Destroy(){
217 CWatchBSP *GetWatchBSP(){
221 void BuildMonitor_Run( GPtrArray* commands, const char* mapName ){
222 GetWatchBSP()->DoMonitoringLoop( commands, mapName );
226 // Static functions for the SAX callbacks -------------------------------------------------------
228 // utility for saxStartElement below
229 static void abortStream( message_info_t *data ){
230 GetWatchBSP()->EndMonitoringLoop();
231 // tell there has been an error
233 if ( GetWatchBSP()->HasBSPPlugin() ) {
234 g_BSPFrontendTable.m_pfnEndListen( 2 );
237 // yeah this doesn't look good.. but it's needed so that everything will be ignored until the stream goes out
238 data->ignore_depth = -1;
242 #include "stream_version.h"
244 static void saxStartElement( message_info_t *data, const xmlChar *name, const xmlChar **attrs ){
246 globalOutputStream() << "<" << name;
248 for ( const xmlChar** p = attrs; *p != 0; p += 2 )
250 globalOutputStream() << " " << p[0] << "=" << makeQuoted( p[1] );
253 globalOutputStream() << ">\n";
256 if ( data->ignore_depth == 0 ) {
257 if ( data->pGeometry != 0 ) {
259 data->pGeometry->saxStartElement( data, name, attrs );
263 if ( strcmp( reinterpret_cast<const char*>( name ), "q3map_feedback" ) == 0 ) {
264 // check the correct version
265 // old q3map don't send a version attribute
266 // the ones we support .. send Q3MAP_STREAM_VERSION
267 if ( !attrs[0] || !attrs[1] || ( strcmp( reinterpret_cast<const char*>( attrs[0] ), "version" ) != 0 ) ) {
268 message_flush( data );
269 globalErrorStream() << "No stream version given in the feedback stream, this is an old q3map version.\n"
270 "Please turn off monitored compiling if you still wish to use this q3map executable\n";
274 else if ( strcmp( reinterpret_cast<const char*>( attrs[1] ), Q3MAP_STREAM_VERSION ) != 0 ) {
275 message_flush( data );
276 globalErrorStream() <<
277 "This version of " RADIANT_NAME " reads version " Q3MAP_STREAM_VERSION " debug streams, I got an incoming connection with version " << reinterpret_cast<const char*>( attrs[1] ) << "\n"
278 "Please make sure your versions of " RADIANT_NAME " and q3map are matching.\n";
283 // we don't treat locally
284 else if ( strcmp( reinterpret_cast<const char*>( name ), "message" ) == 0 ) {
285 int msg_level = atoi( reinterpret_cast<const char*>( attrs[1] ) );
286 if ( msg_level != data->msg_level ) {
287 message_flush( data );
288 data->msg_level = msg_level;
291 else if ( strcmp( reinterpret_cast<const char*>( name ), "polyline" ) == 0 ) {
292 // polyline has a particular status .. right now we only use it for leakfile ..
293 data->geometry_depth = data->recurse;
294 data->pGeometry = &g_pointfile;
295 data->pGeometry->saxStartElement( data, name, attrs );
297 else if ( strcmp( reinterpret_cast<const char*>( name ), "select" ) == 0 ) {
298 CSelectMsg *pSelect = new CSelectMsg();
299 data->geometry_depth = data->recurse;
300 data->pGeometry = pSelect;
301 data->pGeometry->saxStartElement( data, name, attrs );
303 else if ( strcmp( reinterpret_cast<const char*>( name ), "pointmsg" ) == 0 ) {
304 CPointMsg *pPoint = new CPointMsg();
305 data->geometry_depth = data->recurse;
306 data->pGeometry = pPoint;
307 data->pGeometry->saxStartElement( data, name, attrs );
309 else if ( strcmp( reinterpret_cast<const char*>( name ), "windingmsg" ) == 0 ) {
310 CWindingMsg *pWinding = new CWindingMsg();
311 data->geometry_depth = data->recurse;
312 data->pGeometry = pWinding;
313 data->pGeometry->saxStartElement( data, name, attrs );
317 globalErrorStream() << "Warning: ignoring unrecognized node in XML stream (" << reinterpret_cast<const char*>( name ) << ")\n";
318 // we don't recognize this node, jump over it
319 // (NOTE: the ignore mechanism is a bit screwed, only works when starting an ignore at the highest level)
320 data->ignore_depth = data->recurse;
327 static void saxEndElement( message_info_t *data, const xmlChar *name ){
329 globalOutputStream() << "<" << name << "/>\n";
333 // we are out of an ignored chunk
334 if ( data->recurse == data->ignore_depth ) {
335 data->ignore_depth = 0;
338 if ( data->pGeometry != 0 ) {
339 data->pGeometry->saxEndElement( data, name );
340 // we add the object to the debug window
341 if ( data->geometry_depth == data->recurse ) {
342 g_DbgDlg.Push( data->pGeometry );
346 if ( data->recurse == data->stop_depth ) {
347 message_flush( data );
349 globalOutputStream() << "Received error msg .. shutting down..\n";
351 GetWatchBSP()->EndMonitoringLoop();
352 // tell there has been an error
354 if ( GetWatchBSP()->HasBSPPlugin() ) {
355 g_BSPFrontendTable.m_pfnEndListen( 2 );
362 class MessageOutputStream : public TextOutputStream
364 message_info_t* m_data;
366 MessageOutputStream( message_info_t* data ) : m_data( data ){
369 std::size_t write( const char* buffer, std::size_t length ){
370 if ( m_data->pGeometry != 0 ) {
371 m_data->pGeometry->saxCharacters( m_data, reinterpret_cast<const xmlChar*>( buffer ), int(length) );
375 if ( m_data->ignore_depth == 0 ) {
376 // output the message using the level
377 message_print( m_data, buffer, length );
378 // if this message has error level flag, we mark the depth to stop the compilation when we get out
379 // we don't set the msg level if we don't stop on leak
380 if ( m_data->msg_level == 3 ) {
381 m_data->stop_depth = m_data->recurse - 1;
391 inline MessageOutputStream& operator<<( MessageOutputStream& ostream, const T& t ){
392 return ostream_write( ostream, t );
395 static void saxCharacters( message_info_t *data, const xmlChar *ch, int len ){
396 MessageOutputStream ostream( data );
397 ostream << StringRange( reinterpret_cast<const char*>( ch ), reinterpret_cast<const char*>( ch + len ) );
400 static void saxComment( void *ctx, const xmlChar *msg ){
401 globalOutputStream() << "XML comment: " << reinterpret_cast<const char*>( msg ) << "\n";
404 static void saxWarning( void *ctx, const char *msg, ... ){
405 char saxMsgBuffer[4096];
408 va_start( args, msg );
409 vsprintf( saxMsgBuffer, msg, args );
411 globalOutputStream() << "XML warning: " << saxMsgBuffer << "\n";
414 static void saxError( void *ctx, const char *msg, ... ){
415 char saxMsgBuffer[4096];
418 va_start( args, msg );
419 vsprintf( saxMsgBuffer, msg, args );
421 globalErrorStream() << "XML error: " << saxMsgBuffer << "\n";
424 static void saxFatal( void *ctx, const char *msg, ... ){
429 va_start( args, msg );
430 vsprintf( buffer, msg, args );
432 globalErrorStream() << "XML fatal error: " << buffer << "\n";
435 static xmlSAXHandler saxParser = {
436 0, /* internalSubset */
437 0, /* isStandalone */
438 0, /* hasInternalSubset */
439 0, /* hasExternalSubset */
440 0, /* resolveEntity */
443 0, /* notationDecl */
444 0, /* attributeDecl */
446 0, /* unparsedEntityDecl */
447 0, /* setDocumentLocator */
448 0, /* startDocument */
450 (startElementSAXFunc)saxStartElement, /* startElement */
451 (endElementSAXFunc)saxEndElement, /* endElement */
453 (charactersSAXFunc)saxCharacters, /* characters */
454 0, /* ignorableWhitespace */
455 0, /* processingInstruction */
456 (commentSAXFunc)saxComment, /* comment */
457 (warningSAXFunc)saxWarning, /* warning */
458 (errorSAXFunc)saxError, /* error */
459 (fatalErrorSAXFunc)saxFatal, /* fatalError */
470 // ------------------------------------------------------------------------------------------------
473 guint s_routine_id = 0;
474 static gint watchbsp_routine( gpointer data ){
475 reinterpret_cast<CWatchBSP*>( data )->RoutineProcessing();
479 void CWatchBSP::Reset(){
481 Net_Disconnect( m_pInSocket );
484 if ( m_pListenSocket ) {
485 Net_Disconnect( m_pListenSocket );
486 m_pListenSocket = NULL;
488 if ( m_xmlInputBuffer ) {
489 xmlFreeParserInputBuffer( m_xmlInputBuffer );
490 m_xmlInputBuffer = NULL;
493 if ( s_routine_id != 0 ) {
494 g_source_remove( s_routine_id );
499 bool CWatchBSP::SetupListening(){
501 if ( m_pListenSocket ) {
502 globalOutputStream() << "ERROR: m_pListenSocket != NULL in CWatchBSP::SetupListening\n";
506 globalOutputStream() << "Setting up\n";
508 m_pListenSocket = Net_ListenSocket( 39000 );
509 if ( m_pListenSocket == NULL ) {
512 globalOutputStream() << "Listening...\n";
516 void CWatchBSP::DoEBeginStep(){
518 if ( SetupListening() == false ) {
519 const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n";
520 globalOutputStream() << msg;
521 ui::alert( MainFrame_getWindow(), msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
524 // set the timer for timeouts and step cancellation
525 g_timer_reset( m_pTimer );
526 g_timer_start( m_pTimer );
528 if ( !m_bBSPPlugin ) {
529 globalOutputStream() << "=== running build command ===\n"
530 << static_cast<const char*>( g_ptr_array_index( m_pCmd, m_iCurrentStep ) ) << "\n";
532 if ( !Q_Exec( NULL, (char *)g_ptr_array_index( m_pCmd, m_iCurrentStep ), NULL, true, false ) ) {
533 StringOutputStream msg( 256 );
534 msg << "Failed to execute the following command: ";
535 msg << reinterpret_cast<const char*>( g_ptr_array_index( m_pCmd, m_iCurrentStep ) );
536 msg << "\nCheck that the file exists and that you don't run out of system resources.\n";
537 globalOutputStream() << msg.c_str();
538 ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
541 // re-initialise the debug window
542 if ( m_iCurrentStep == 0 ) {
546 m_eState = EBeginStep;
547 s_routine_id = g_timeout_add( 25, watchbsp_routine, this );
552 const char *ENGINE_ATTRIBUTE = "engine_win32";
553 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_win32";
554 #elif GDEF_OS_LINUX || GDEF_OS_BSD
555 const char *ENGINE_ATTRIBUTE = "engine_linux";
556 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_linux";
558 const char *ENGINE_ATTRIBUTE = "engine_macos";
559 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_macos";
561 #error "unsupported platform"
564 class RunEngineConfiguration
567 const char* executable;
568 const char* mp_executable;
571 RunEngineConfiguration() :
572 executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ),
573 mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){
574 do_sp_mp = !string_empty( mp_executable );
578 inline void GlobalGameDescription_string_write_mapparameter( StringOutputStream& string, const char* mapname ){
579 if ( g_pGameDescription->mGameType == "q2"
580 || g_pGameDescription->mGameType == "heretic2" ) {
581 string << ". +exec radiant.cfg +map " << mapname;
585 string << "+set sv_pure 0 ";
586 // TTimo: a check for vm_* but that's all fine
587 //cmdline = "+set sv_pure 0 +set vm_ui 0 +set vm_cgame 0 +set vm_game 0 ";
588 const char* fs_game = gamename_get();
589 if ( !string_equal( fs_game, basegame_get() ) ) {
590 string << "+set fs_game " << fs_game << " ";
592 if ( g_pGameDescription->mGameType == "wolf" ) {
593 //|| g_pGameDescription->mGameType == "et")
594 if ( string_equal( gamemode_get(), "mp" ) ) {
596 string << "+devmap " << mapname;
601 string << "+set nextmap \"spdevmap " << mapname << "\"";
606 string << "+devmap " << mapname;
612 void CWatchBSP::RoutineProcessing(){
616 // timeout: if we don't get an incoming connection fast enough, go back to idle
617 if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) {
618 ui::alert( MainFrame_getWindow(), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
621 if ( m_bBSPPlugin ) {
622 // status == 1 : didn't get the connection
623 g_BSPFrontendTable.m_pfnEndListen( 1 );
630 if ( !m_pListenSocket ) {
631 globalErrorStream() << "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n";
635 // we are not connected yet, accept any incoming connection
636 m_pInSocket = Net_Accept( m_pListenSocket );
638 globalOutputStream() << "Connected.\n";
639 // prepare the message info struct for diving in
640 memset( &m_message_info, 0, sizeof( message_info_t ) );
641 // a dumb flag to make sure we init the push parser context when first getting a msg
642 m_bNeedCtxtInit = true;
643 m_eState = EWatching;
650 if ( !m_pInSocket ) {
651 globalErrorStream() << "ERROR: m_pInSocket == NULL in CWatchBSP::RoutineProcessing EWatching state\n";
656 int ret = Net_Wait( m_pInSocket, 0, 0 );
658 globalOutputStream() << "WARNING: SOCKET_ERROR in CWatchBSP::RoutineProcessing\n";
659 globalOutputStream() << "Terminating the connection.\n";
665 // the socket has been identified, there's something (message or disconnection)
666 // see if there's anything in input
667 ret = Net_Receive( m_pInSocket, &msg );
669 // unsigned int size = msg.size; //++timo just a check
670 strcpy( m_xmlBuf, NMSG_ReadString( &msg ) );
671 if ( m_bNeedCtxtInit ) {
672 m_xmlParserCtxt = NULL;
673 m_xmlParserCtxt = xmlCreatePushParserCtxt( &saxParser, &m_message_info, m_xmlBuf, static_cast<int>( strlen( m_xmlBuf ) ), NULL );
675 if ( m_xmlParserCtxt == NULL ) {
676 globalErrorStream() << "Failed to create the XML parser (incoming stream began with: " << m_xmlBuf << ")\n";
679 m_bNeedCtxtInit = false;
683 xmlParseChunk( m_xmlParserCtxt, m_xmlBuf, static_cast<int>( strlen( m_xmlBuf ) ), 0 );
688 message_flush( &m_message_info );
689 // error or connection closed/reset
690 // NOTE: if we get an error down the XML stream we don't reach here
691 Net_Disconnect( m_pInSocket );
693 globalOutputStream() << "Connection closed.\n";
695 if ( m_bBSPPlugin ) {
697 // let the BSP plugin know that the job is done
698 g_BSPFrontendTable.m_pfnEndListen( 0 );
702 // move to next step or finish
704 if ( m_iCurrentStep < m_pCmd->len ) {
709 // launch the engine .. OMG
710 if ( g_WatchBSP_RunQuake ) {
712 // do we enter sleep mode before?
713 if ( g_WatchBSP_DoSleep ) {
714 globalOutputStream() << "Going into sleep mode..\n";
715 g_pParentWnd->OnSleep();
718 globalOutputStream() << "Running engine...\n";
719 StringOutputStream cmd( 256 );
720 // build the command line
721 cmd << EnginePath_get();
722 // this is game dependant
724 RunEngineConfiguration engineConfig;
726 if ( engineConfig.do_sp_mp ) {
727 if ( string_equal( gamemode_get(), "mp" ) ) {
728 cmd << engineConfig.mp_executable;
732 cmd << engineConfig.executable;
737 cmd << engineConfig.executable;
740 StringOutputStream cmdline;
742 GlobalGameDescription_string_write_mapparameter( cmdline, m_sBSPName );
744 globalOutputStream() << cmd.c_str() << " " << cmdline.c_str() << "\n";
747 if ( !Q_Exec( cmd.c_str(), (char *)cmdline.c_str(), EnginePath_get(), false, false ) ) {
748 StringOutputStream msg;
749 msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
750 globalOutputStream() << msg.c_str();
751 ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
765 GPtrArray* str_ptr_array_clone( GPtrArray* array ){
766 GPtrArray* cloned = g_ptr_array_sized_new( array->len );
767 for ( guint i = 0; i < array->len; ++i )
769 g_ptr_array_add( cloned, g_strdup( (char*)g_ptr_array_index( array, i ) ) );
774 void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){
775 m_sBSPName = string_clone( sBSPName );
776 if ( m_eState != EIdle ) {
777 globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n";
778 // prompt the user, should we cancel the current process and go ahead?
779 if ( ui::alert( MainFrame_getWindow(), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
780 "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) {
781 // disconnect and set EIdle state
785 m_pCmd = str_ptr_array_clone( pCmd );
790 void CWatchBSP::ExternalListen(){
795 // the part of the watchbsp interface we export to plugins
796 // NOTE: in the long run, the whole watchbsp.cpp interface needs to go out and be handled at the BSP plugin level
797 // for now we provide something really basic and limited, the essential is to have something that works fine and fast (for 1.1 final)
798 void QERApp_Listen(){
799 // open the listening socket
800 GetWatchBSP()->ExternalListen();