NSM: Add status message log display to GUI.
This commit is contained in:
parent
4ef20c0f71
commit
ae633840fb
|
@ -93,6 +93,19 @@ enum {
|
|||
|
||||
static int pending_operation = COMMAND_NONE;
|
||||
|
||||
|
||||
#define GUIMSG( fmt, args... ) \
|
||||
{ \
|
||||
MESSAGE( fmt, ## args ); \
|
||||
if ( gui_is_active ) \
|
||||
{ \
|
||||
char *s;\
|
||||
asprintf( &s, fmt, ## args );\
|
||||
osc_server->send( gui_addr, "/nsm/gui/server/message", s);\
|
||||
free(s);\
|
||||
}\
|
||||
}
|
||||
|
||||
struct Client
|
||||
{
|
||||
private:
|
||||
|
@ -307,11 +320,11 @@ handle_client_process_death ( int pid )
|
|||
|
||||
if ( dead_because_we_said )
|
||||
{
|
||||
MESSAGE( "Client %s terminated because we told it to.", c->name );
|
||||
GUIMSG( "Client %s terminated because we told it to.", c->name );
|
||||
}
|
||||
else
|
||||
{
|
||||
MESSAGE( "Client %s died unexpectedly.", c->name );
|
||||
GUIMSG( "Client %s died unexpectedly.", c->name );
|
||||
}
|
||||
|
||||
if ( c->pending_command() == COMMAND_QUIT )
|
||||
|
@ -518,11 +531,11 @@ number_of_active_clients ( void )
|
|||
void
|
||||
wait_for_announce ( void )
|
||||
{
|
||||
MESSAGE( "Waiting for announce messages from clients" );
|
||||
GUIMSG( "Waiting for announce messages from clients" );
|
||||
|
||||
int n = 5 * 1000;
|
||||
|
||||
int active;
|
||||
long unsigned int active;
|
||||
|
||||
while ( n > 0 )
|
||||
{
|
||||
|
@ -535,14 +548,15 @@ wait_for_announce ( void )
|
|||
if ( client.size() == active )
|
||||
break;
|
||||
}
|
||||
|
||||
MESSAGE( "Done. %i out of %i clients announced within the initialization grace period", active, client.size() );
|
||||
|
||||
GUIMSG( "Done. %lu out of %lu clients announced within the initialization grace period", active, client.size() );
|
||||
}
|
||||
|
||||
void
|
||||
wait_for_replies ( void )
|
||||
{
|
||||
MESSAGE( "Waiting for clients to reply to commands" );
|
||||
|
||||
GUIMSG( "Waiting for clients to reply to commands" );
|
||||
|
||||
int n = 60 * 1000; /* 60 seconds */
|
||||
|
||||
|
@ -556,6 +570,7 @@ wait_for_replies ( void )
|
|||
break;
|
||||
}
|
||||
|
||||
GUIMSG( "Done waiting" );
|
||||
/* FIXME: do something about unresponsive clients */
|
||||
}
|
||||
|
||||
|
@ -602,7 +617,7 @@ launch ( const char *executable, const char *client_id )
|
|||
int pid;
|
||||
if ( ! (pid = fork()) )
|
||||
{
|
||||
MESSAGE( "Launching %s\n", executable );
|
||||
GUIMSG( "Launching %s", executable );
|
||||
|
||||
char *args[] = { strdup( executable ), NULL };
|
||||
|
||||
|
@ -766,8 +781,6 @@ OSC_HANDLER( add )
|
|||
|
||||
OSC_HANDLER( announce )
|
||||
{
|
||||
MESSAGE( "Got announce" );
|
||||
|
||||
const char *client_name = &argv[0]->s;
|
||||
const char *capabilities = &argv[1]->s;
|
||||
const char *executable_path = &argv[2]->s;
|
||||
|
@ -775,6 +788,8 @@ OSC_HANDLER( announce )
|
|||
int minor = argv[4]->i;
|
||||
int pid = argv[5]->i;
|
||||
|
||||
GUIMSG( "Got announce from %s", client_name );
|
||||
|
||||
if ( ! session_path )
|
||||
{
|
||||
osc_server->send( lo_message_get_source( msg ), "/error",
|
||||
|
@ -928,7 +943,7 @@ wait_for_dumb_clients_to_die ( )
|
|||
{
|
||||
struct signalfd_siginfo fdsi;
|
||||
|
||||
MESSAGE( "Waiting for any dumb clients to die." );
|
||||
GUIMSG( "Waiting for any dumb clients to die." );
|
||||
|
||||
for ( int i = 0; i < 6; i++ )
|
||||
{
|
||||
|
@ -947,6 +962,8 @@ wait_for_dumb_clients_to_die ( )
|
|||
|
||||
usleep( 50000 );
|
||||
}
|
||||
|
||||
GUIMSG( "Done waiting" );
|
||||
|
||||
/* FIXME: give up on remaining clients and purge them */
|
||||
}
|
||||
|
@ -1015,7 +1032,7 @@ command_all_clients_to_save ( )
|
|||
{
|
||||
if ( session_path )
|
||||
{
|
||||
MESSAGE( "Commanding attached clients to save." );
|
||||
GUIMSG( "Commanding attached clients to save." );
|
||||
|
||||
for ( std::list<Client*>::iterator i = client.begin();
|
||||
i != client.end();
|
||||
|
@ -1033,7 +1050,7 @@ command_all_clients_to_save ( )
|
|||
void
|
||||
command_client_to_stop ( Client *c )
|
||||
{
|
||||
MESSAGE( "Stopping client %s", c->name );
|
||||
GUIMSG( "Stopping client %s", c->name );
|
||||
|
||||
if ( c->pid > 0 )
|
||||
{
|
||||
|
@ -1436,7 +1453,7 @@ OSC_HANDLER( new )
|
|||
close_session();
|
||||
}
|
||||
|
||||
MESSAGE( "Creating new session" );
|
||||
GUIMSG( "Creating new session \"%s\"", &argv[0]->s );
|
||||
|
||||
char *spath;
|
||||
asprintf( &spath, "%s/%s", session_root, &argv[0]->s );
|
||||
|
@ -1511,7 +1528,7 @@ list_file ( const char *fpath, const struct stat *sb, int tflag )
|
|||
|
||||
OSC_HANDLER( list )
|
||||
{
|
||||
MESSAGE( "Listing sessions" );
|
||||
GUIMSG( "Listing sessions" );
|
||||
|
||||
list_response_address = lo_message_get_source( msg );
|
||||
|
||||
|
@ -1520,14 +1537,13 @@ OSC_HANDLER( list )
|
|||
osc_server->send( lo_message_get_source( msg ), path,
|
||||
ERR_OK,
|
||||
"Done." );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSC_HANDLER( open )
|
||||
{
|
||||
DMESSAGE( "Got open" );
|
||||
|
||||
GUIMSG( "Opening session %s", &argv[0]->s );
|
||||
|
||||
if ( pending_operation != COMMAND_NONE )
|
||||
{
|
||||
osc_server->send( lo_message_get_source( msg ), "/error", path,
|
||||
|
@ -1637,7 +1653,7 @@ OSC_HANDLER( abort )
|
|||
goto done;
|
||||
}
|
||||
|
||||
MESSAGE( "Commanding attached clients to quit." );
|
||||
GUIMSG( "Commanding attached clients to quit." );
|
||||
|
||||
close_session();
|
||||
|
||||
|
@ -1645,6 +1661,7 @@ OSC_HANDLER( abort )
|
|||
"Aborted." );
|
||||
|
||||
MESSAGE( "Done" );
|
||||
|
||||
done:
|
||||
|
||||
pending_operation = COMMAND_NONE;
|
||||
|
@ -1672,10 +1689,9 @@ OSC_HANDLER( close )
|
|||
|
||||
goto done;
|
||||
}
|
||||
|
||||
command_all_clients_to_save();
|
||||
|
||||
MESSAGE( "Commanding attached clients to quit." );
|
||||
GUIMSG( "Commanding attached clients to quit." );
|
||||
|
||||
close_session();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <FL/Fl_Tile.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
|
||||
#include <FL/Fl_Text_Display.H>
|
||||
#include "FL/Fl_Packscroller.H"
|
||||
#include "FL/Fl_Scalepack.H"
|
||||
|
||||
|
@ -517,6 +517,8 @@ public:
|
|||
|
||||
Fl_Tree *session_browser;
|
||||
|
||||
Fl_Text_Display *status_display;
|
||||
|
||||
static void cb_handle ( Fl_Widget *w, void *v )
|
||||
{
|
||||
((NSM_Controller*)v)->cb_handle( w );
|
||||
|
@ -882,7 +884,7 @@ public:
|
|||
}
|
||||
|
||||
{ Fl_Tile *o = new Fl_Tile( X, Y + 30, W, H - 30 );
|
||||
{ Fl_Scalepack *o = new Fl_Scalepack( X, Y + 30, 300, H - 30 );
|
||||
{ Fl_Scalepack *o = new Fl_Scalepack( X, Y + 30, 300, H - 105 );
|
||||
o->type( FL_VERTICAL );
|
||||
o->spacing( 2 );
|
||||
|
||||
|
@ -890,7 +892,7 @@ public:
|
|||
}
|
||||
|
||||
{
|
||||
Fl_Tree *o = session_browser = new Fl_Tree( X, Y + 50, W / 3, H - 50 );
|
||||
Fl_Tree *o = session_browser = new Fl_Tree( X, Y + 50, W / 3, H - 125 );
|
||||
o->callback( cb_handle, (void *)this );
|
||||
o->color( FL_DARK1 );
|
||||
o->item_labelbgcolor( o->color() );
|
||||
|
@ -907,7 +909,7 @@ public:
|
|||
}
|
||||
|
||||
Fl_Scalepack *scalepack;
|
||||
{ Fl_Scalepack *o = scalepack = new Fl_Scalepack( X + 300, Y + 30, W - 300, H - 30 );
|
||||
{ Fl_Scalepack *o = scalepack = new Fl_Scalepack( X + 300, Y + 30, W - 300, H - 105 );
|
||||
o->type( FL_VERTICAL );
|
||||
o->spacing( 2 );
|
||||
|
||||
|
@ -923,7 +925,7 @@ public:
|
|||
}
|
||||
|
||||
{
|
||||
Fl_Packscroller *o = new Fl_Packscroller( 0, 0, 100, H - 100 );
|
||||
Fl_Packscroller *o = new Fl_Packscroller( 0, 0, 100, H - 105 );
|
||||
o->align( FL_ALIGN_TOP );
|
||||
o->labeltype( FL_SHADOW_LABEL );
|
||||
{
|
||||
|
@ -940,12 +942,22 @@ public:
|
|||
/* Fl_Group::current()->resizable( o ); */
|
||||
} // Fl_Scalepack
|
||||
|
||||
{ Fl_Box *o = new Fl_Box( X + 300, Y + 30, 100, H - 30 );
|
||||
{ Fl_Box *o = new Fl_Box( X + 300, Y + 30, 100, H - 105 );
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
|
||||
{ Fl_Text_Display *o = status_display = new Fl_Text_Display( X, Y + H - 75, W, 75 );
|
||||
o->color( FL_DARK1 );
|
||||
o->textcolor( FL_GREEN );
|
||||
o->textfont( FL_COURIER );
|
||||
o->textsize( 10 );
|
||||
Fl_Text_Buffer *b = new Fl_Text_Buffer();
|
||||
o->buffer(b);
|
||||
}
|
||||
|
||||
o->end();
|
||||
resizable( o );
|
||||
|
||||
} // Fl_tile
|
||||
|
||||
end();
|
||||
|
@ -1004,6 +1016,7 @@ public:
|
|||
|
||||
osc->add_method( "/nsm/server/broadcast", NULL, osc_broadcast_handler, osc, "msg" );
|
||||
osc->add_method( "/nsm/gui/server_announce", "s", osc_handler, osc, "msg" );
|
||||
osc->add_method( "/nsm/gui/server/message", "s", osc_handler, osc, "msg" );
|
||||
osc->add_method( "/nsm/gui/gui_announce", "s", osc_handler, osc, "msg" );
|
||||
osc->add_method( "/nsm/gui/session/session", "s", osc_handler, osc, "path,display_name" );
|
||||
osc->add_method( "/nsm/gui/session/name", "ss", osc_handler, osc, "path,display_name" );
|
||||
|
@ -1070,7 +1083,13 @@ private:
|
|||
|
||||
Fl::lock();
|
||||
|
||||
if ( !strcmp( path, "/nsm/gui/session/session" ) &&
|
||||
if ( !strcmp( path, "/nsm/gui/server/message" ) && !strcmp( types, "s" ) )
|
||||
{
|
||||
controller->status_display->insert( &argv[0]->s );
|
||||
controller->status_display->show_insert_position();
|
||||
controller->status_display->insert( "\n" );
|
||||
}
|
||||
else if ( !strcmp( path, "/nsm/gui/session/session" ) &&
|
||||
! strcmp( types, "s" ) )
|
||||
{
|
||||
controller->add_session_to_list( &argv[0]->s );
|
||||
|
@ -1143,7 +1162,12 @@ private:
|
|||
last_ping_response = time( NULL );
|
||||
}
|
||||
else if ( ! strcmp( types, "ss" ) )
|
||||
{
|
||||
MESSAGE( "%s says %s", &argv[0]->s, &argv[1]->s);
|
||||
|
||||
controller->status_display->insert( &argv[1]->s );
|
||||
controller->status_display->insert( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !strncmp( path, "/nsm/gui/client/", strlen( "/nsm/gui/client/" ) ) )
|
||||
|
|
Loading…
Reference in New Issue