From 17e2cedefeda576ef61f85abf41f44108cbf114f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 26 Dec 2011 03:10:42 +0000 Subject: [PATCH] - API/client/manager: allow applications to supply a "web graphics URL", in which case the manager's "Show Graphics" button opens a browser at that URL. This typically would used for applications that implement a web server that serves pages showing job information in HTML. - vboxwrapper: if is specified in the config file, set up port forwarding to that port and use the above API call with URL "http://localhost:port" svn path=/trunk/boinc/; revision=24898 --- api/boinc_api.cpp | 7 +++++++ api/boinc_api.h | 1 + checkin_notes | 19 ++++++++++++++++++ samples/vboxwrapper/vbox.cpp | 27 ------------------------- samples/vboxwrapper/vboxwrapper.cpp | 31 +++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp index 1f8e0268b9..5346b15372 100644 --- a/api/boinc_api.cpp +++ b/api/boinc_api.cpp @@ -1449,3 +1449,10 @@ double boinc_get_fraction_done() { double boinc_elapsed_time() { return running_interrupt_count*TIMER_PERIOD; } + +void boinc_web_graphics_url(char* url) { + char buf[256]; + if (standalone) return; + sprintf(buf, "%s", url); + app_client_shm->shm->graphics_reply.send_msg(buf); +} diff --git a/api/boinc_api.h b/api/boinc_api.h index 9378ee85d8..072c14aef8 100644 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -117,6 +117,7 @@ extern double boinc_get_fraction_done(); extern void boinc_register_timer_callback(FUNC_PTR); extern double boinc_worker_thread_cpu_time(); extern int boinc_init_parallel(); +extern void boinc_web_graphics_url(char*); #ifdef __APPLE__ extern int setMacPList(void); diff --git a/checkin_notes b/checkin_notes index fef20eef81..c07a192e06 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9480,3 +9480,22 @@ Rom 25 Dec 2011 samples/vboxwrapper/ vbox.cpp vboxwrapper.cpp + +David 26 Dec 2011 + - API/client/manager: + allow applications to supply a "web graphics URL", + in which case the manager's "Show Graphics" button + opens a browser at that URL. + This typically would used for applications that + implement a web server that serves pages showing + job information in HTML. + - vboxwrapper: if is specified in the config file, + set up port forwarding to that port + and use the above API call with URL "http://localhost:port" + + samples/ + vboxwrapper/ + vbox.cpp + vboxwrapper.cpp + api/ + boinc_api.cpp,h diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 9e2b9a2f09..4f21abf614 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -838,33 +838,6 @@ int VBOX_VM::register_vm_firewall_rules() { retval = vbm_popen(command, output, "add updated port forwarding rule"); if(retval) return retval; - fprintf( - stderr, - "%s VM communication is allowed on port '%d'.\n", - boinc_msg_prefix(buf, sizeof(buf)), pf_host_port - ); - - - // Write firewall rule to disk - // - MIOFILE mf; - FILE* f = boinc_fopen(PORTFORWARD_FILENAME, "w"); - mf.init_file(f); - - mf.printf( - "\n" - " \n" - " vboxwrapper\n" - " %d\n" - " %d\n" - " \n" - "\n", - pf_host_port, - pf_guest_port - ); - - fclose(f); - return 0; } diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index a48233999b..75a595d600 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -337,6 +337,37 @@ int main(int argc, char** argv) { set_floppy_image(aid, vm); set_throttles(aid, vm); + // write port-forwarding info if relevant + // + if (vm.pf_guest_port && vm.pf_host_port) { + fprintf( + stderr, + "%s port forwarding enabled on port '%d'.\n", + boinc_msg_prefix(buf, sizeof(buf)), vm.pf_host_port + ); + + // Write info to disk + // + MIOFILE mf; + FILE* f = boinc_fopen(PORTFORWARD_FILENAME, "w"); + mf.init_file(f); + + mf.printf( + "\n" + " \n" + " %d\n" + " %d\n" + " \n" + "\n", + vm.pf_host_port, + vm.pf_guest_port + ); + + fclose(f); + sprintf(buf, "http://localhost:%d", vm.pf_host_port); + boinc_web_graphics_url(buf); + } + while (1) { // Discover the VM's current state vm.poll();