mirror of https://github.com/BOINC/boinc.git
HTMLGFX: Checkpoint (Continuation of previous commit.)
* Custom IE Javascript interface is gone, it was replaced with a cross-browser Web RPC. In the HTML doc you can add: <script type='text/javascript' src='/api/static/boinc.js'></script> In the JavaScript code you can: var boinc = new BOINC(); From there you can get the username like: var userName = boinc.getUserName(); * Default resources are embedded within the executable in much the same way XPM images are embedded in the manager. /api/static/index.html /api/static/boinc.png /api/static/boinc.js
This commit is contained in:
parent
e31d3c86b4
commit
8bdf177e4e
|
@ -150,7 +150,7 @@ int boinc_write_graphics_status(
|
|||
}
|
||||
|
||||
int boinc_parse_graphics_status(
|
||||
double* update_time, double* cpu_time,
|
||||
double* updated_time, double* cpu_time,
|
||||
double* elapsed_time, double* fraction_done, BOINC_STATUS* status
|
||||
){
|
||||
MIOFILE mf;
|
||||
|
@ -161,10 +161,10 @@ int boinc_parse_graphics_status(
|
|||
mf.init_file(f);
|
||||
XML_PARSER xp(&mf);
|
||||
|
||||
update_time = 0;
|
||||
cpu_time = 0;
|
||||
elapsed_time = 0;
|
||||
fraction_done = 0;
|
||||
*updated_time = 0;
|
||||
*cpu_time = 0;
|
||||
*elapsed_time = 0;
|
||||
*fraction_done = 0;
|
||||
memset(status, 0, sizeof(BOINC_STATUS));
|
||||
|
||||
if (!xp.parse_start("graphics_status")) return ERR_XML_PARSE;
|
||||
|
@ -191,7 +191,7 @@ int boinc_parse_graphics_status(
|
|||
else if (xp.parse_int("network_suspended", status->network_suspended)) continue;
|
||||
}
|
||||
}
|
||||
else if (xp.parse_double("update_time", *update_time)) continue;
|
||||
else if (xp.parse_double("updated_time", *updated_time)) continue;
|
||||
else if (xp.parse_double("cpu_time", *cpu_time)) continue;
|
||||
else if (xp.parse_double("elapsed_time", *elapsed_time)) continue;
|
||||
else if (xp.parse_double("fraction_done", *fraction_done)) continue;
|
||||
|
|
|
@ -19,66 +19,6 @@ interface IHTMLBrowserHost : IDispatch
|
|||
{
|
||||
};
|
||||
|
||||
[
|
||||
object,
|
||||
dual,
|
||||
nonextensible,
|
||||
uuid(5CDAD774-B53F-46C1-A725-E3655CEEDFFB),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface IHTMLBrowserHostUI : IDispatch
|
||||
{
|
||||
HRESULT log([in] BSTR message);
|
||||
HRESULT debug([in] BSTR message);
|
||||
HRESULT info([in] BSTR message);
|
||||
HRESULT warn([in] BSTR message);
|
||||
HRESULT error([in] BSTR message);
|
||||
HRESULT isStateUpdated([out, retval] BOOL* pVal);
|
||||
HRESULT resetStateUpdate([in] BOOL newVal);
|
||||
[propget, id(1)] HRESULT appName([out, retval] BSTR* pVal);
|
||||
[propput, id(1)] HRESULT appName([in] BSTR newVal);
|
||||
[propget, id(2)] HRESULT appVersion([out, retval] LONG* pVal);
|
||||
[propput, id(2)] HRESULT appVersion([in] LONG newVal);
|
||||
[propget, id(3)] HRESULT wuName([out, retval] BSTR* pVal);
|
||||
[propput, id(3)] HRESULT wuName([in] BSTR newVal);
|
||||
[propget, id(4)] HRESULT resName([out, retval] BSTR* pVal);
|
||||
[propput, id(4)] HRESULT resName([in] BSTR newVal);
|
||||
[propget, id(5)] HRESULT teamName([out, retval] BSTR* pVal);
|
||||
[propput, id(5)] HRESULT teamName([in] BSTR newVal);
|
||||
[propget, id(6)] HRESULT userName([out, retval] BSTR* pVal);
|
||||
[propput, id(6)] HRESULT userName([in] BSTR newVal);
|
||||
[propget, id(7)] HRESULT userCreditTotal([out, retval] DOUBLE* pVal);
|
||||
[propput, id(7)] HRESULT userCreditTotal([in] DOUBLE newVal);
|
||||
[propget, id(8)] HRESULT userCreditAverage([out, retval] DOUBLE* pVal);
|
||||
[propput, id(8)] HRESULT userCreditAverage([in] DOUBLE newVal);
|
||||
[propget, id(9)] HRESULT hostCreditTotal([out, retval] DOUBLE* pVal);
|
||||
[propput, id(9)] HRESULT hostCreditTotal([in] DOUBLE newVal);
|
||||
[propget, id(10)] HRESULT hostCreditAverage([out, retval] DOUBLE* pVal);
|
||||
[propput, id(10)] HRESULT hostCreditAverage([in] DOUBLE newVal);
|
||||
[propget, id(11)] HRESULT scrsaveMode([out, retval] BOOL* pVal);
|
||||
[propput, id(11)] HRESULT scrsaveMode([in] BOOL newVal);
|
||||
[propget, id(12)] HRESULT suspended([out, retval] BOOL* pVal);
|
||||
[propput, id(12)] HRESULT suspended([in] BOOL newVal);
|
||||
[propget, id(13)] HRESULT networkSuspended([out, retval] BOOL* pVal);
|
||||
[propput, id(13)] HRESULT networkSuspended([in] BOOL newVal);
|
||||
[propget, id(14)] HRESULT exiting([out, retval] BOOL* pVal);
|
||||
[propput, id(14)] HRESULT exiting([in] BOOL newVal);
|
||||
[propget, id(15)] HRESULT exitTimeout([out, retval] DOUBLE* pVal);
|
||||
[propput, id(15)] HRESULT exitTimeout([in] DOUBLE newVal);
|
||||
[propget, id(16)] HRESULT cpuTime([out, retval] DOUBLE* pVal);
|
||||
[propput, id(16)] HRESULT cpuTime([in] DOUBLE newVal);
|
||||
[propget, id(17)] HRESULT elapsedTime([out, retval] DOUBLE* pVal);
|
||||
[propput, id(17)] HRESULT elapsedTime([in] DOUBLE newVal);
|
||||
[propget, id(18)] HRESULT fractionDone([out, retval] DOUBLE* pVal);
|
||||
[propput, id(18)] HRESULT fractionDone([in] DOUBLE newVal);
|
||||
[propget, id(19)] HRESULT vboxJob([out, retval] BOOL* pVal);
|
||||
[propput, id(19)] HRESULT vboxJob([in] BOOL newVal);
|
||||
[propget, id(20)] HRESULT rdpPort([out, retval] LONG* pVal);
|
||||
[propput, id(20)] HRESULT rdpPort([in] LONG newVal);
|
||||
[propget, id(21)] HRESULT apiPort([out, retval] LONG* pVal);
|
||||
[propput, id(21)] HRESULT apiPort([in] LONG newVal);
|
||||
};
|
||||
|
||||
[
|
||||
uuid(E734A057-9667-44EB-BC7D-313D535BADD5),
|
||||
version(1.0),
|
||||
|
@ -93,7 +33,6 @@ library HTMLGfxLib
|
|||
coclass HTMLBrowser
|
||||
{
|
||||
[default] interface IHTMLBrowserHost;
|
||||
interface IHTMLBrowserHostUI;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -31,15 +31,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
// remains consistent on all systems.
|
||||
IDI_ICON ICON "res\\boinc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// HTML
|
||||
//
|
||||
default_win.htm HTML "res\\index.html"
|
||||
console_win.js HTML "res\\console.js"
|
||||
boinc.js HTML "res\\boinc.js"
|
||||
boinc.png HTML "res\\boinc.png"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "browser_i.h"
|
||||
#include "browser_win.h"
|
||||
#include "browserlog.h"
|
||||
#include "browserctrlui_win.h"
|
||||
#include "browserctrl_win.h"
|
||||
|
||||
|
||||
|
@ -171,16 +170,6 @@ STDMETHODIMP CHTMLBrowserHost::CreateControlEx(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register a custom interface to extend the HTML Document Object Model
|
||||
// javascript: 'window.external'
|
||||
//
|
||||
CComObject<CHTMLBrowserHostUI> *pUIObject = NULL;
|
||||
hr = CComObject<CHTMLBrowserHostUI>::CreateInstance(&pUIObject);
|
||||
if (SUCCEEDED(hr) && pUIObject != NULL)
|
||||
{
|
||||
SetExternalDispatch((IHTMLBrowserHostUI*)pUIObject);
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
|
@ -229,11 +218,21 @@ STDMETHODIMP CHTMLBrowserHost::WriteWithUrlLineAndColumn(
|
|||
}
|
||||
else
|
||||
{
|
||||
browserlog_msg(
|
||||
"Console: (%S) (%S%d) %S\n"
|
||||
" File: %S, Line: %d, Column: %d",
|
||||
MapMessageLevel(level), source, messageId, messageText, fileUrl, line, column
|
||||
);
|
||||
if (wcslen(fileUrl))
|
||||
{
|
||||
browserlog_msg(
|
||||
"Console: (%S) (%S%d) %S\n"
|
||||
" File: %S, Line: %d, Column: %d",
|
||||
MapMessageLevel(level), source, messageId, messageText, fileUrl, line, column
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
browserlog_msg(
|
||||
"Console: (%S) (%S%d) %S",
|
||||
MapMessageLevel(level), source, messageId, messageText
|
||||
);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -1,381 +0,0 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define _ATL_FREE_THREADED
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
|
||||
#include <AtlBase.h>
|
||||
#include <AtlCom.h>
|
||||
#include <AtlCtl.h>
|
||||
#include <AtlWin.h>
|
||||
#include <AtlStr.h>
|
||||
#include <AtlFile.h>
|
||||
#include <AtlTypes.h>
|
||||
#include <exdisp.h>
|
||||
#include <exdispid.h>
|
||||
#include <mshtml.h>
|
||||
#include <string>
|
||||
#include "win_util.h"
|
||||
#include "version.h"
|
||||
#include "boinc_api.h"
|
||||
#include "diagnostics.h"
|
||||
#include "filesys.h"
|
||||
#include "browser_i.h"
|
||||
#include "browser_win.h"
|
||||
#include "browserlog.h"
|
||||
#include "browserctrlui_win.h"
|
||||
|
||||
|
||||
HRESULT CHTMLBrowserHostUI::FinalConstruct()
|
||||
{
|
||||
m_bStateUpdated = false;
|
||||
m_strApplicationName.Empty();
|
||||
m_lApplicationVersion = 0;
|
||||
m_strWorkunitName.Empty();
|
||||
m_strResultName.Empty();
|
||||
m_strTeamName.Empty();
|
||||
m_strUserName.Empty();
|
||||
m_dUserCreditTotal = 0.0;
|
||||
m_dUserCreditAverage = 0.0;
|
||||
m_dHostCreditTotal = 0.0;
|
||||
m_dHostCreditAverage = 0.0;
|
||||
m_bScreensaver = false;
|
||||
m_bSuspended = false;
|
||||
m_bNetworkSuspended = false;
|
||||
m_bExiting = false;
|
||||
m_dExitCountdown = 0.0;
|
||||
m_dCPUTime = 0.0;
|
||||
m_dElapsedTime = 0.0;
|
||||
m_dFractionDone = 0.0;
|
||||
m_bVboxwrapperJob = false;
|
||||
m_lRemoteDesktopPort = 0;
|
||||
m_lWebAPIPort = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CHTMLBrowserHostUI::FinalRelease()
|
||||
{
|
||||
m_strApplicationName.Empty();
|
||||
m_strWorkunitName.Empty();
|
||||
m_strResultName.Empty();
|
||||
m_strTeamName.Empty();
|
||||
m_strUserName.Empty();
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::log(BSTR message)
|
||||
{
|
||||
browserlog_msg("Console: (%S%d) %S",
|
||||
L"SCRIPT", 0, message
|
||||
);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::debug(BSTR message)
|
||||
{
|
||||
browserlog_msg("Console: (%S) (%S%d) %S",
|
||||
L"DEBUG", L"SCRIPT", 0, message
|
||||
);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::info(BSTR message)
|
||||
{
|
||||
browserlog_msg("Console: (%S) (%S%d) %S",
|
||||
L"INFO", L"SCRIPT", 0, message
|
||||
);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::warn(BSTR message)
|
||||
{
|
||||
browserlog_msg("Console: (%S) (%S%d) %S",
|
||||
L"WARNING", L"SCRIPT", 0, message
|
||||
);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::error(BSTR message)
|
||||
{
|
||||
browserlog_msg("Console: (%S) (%S%d) %S",
|
||||
L"ERROR", L"SCRIPT", 0, message
|
||||
);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::isStateUpdated(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bStateUpdated;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::resetStateUpdate(BOOL newVal)
|
||||
{
|
||||
m_bStateUpdated = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_appName(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_strApplicationName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_appName(BSTR newVal)
|
||||
{
|
||||
m_strApplicationName = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_appVersion(LONG* pVal)
|
||||
{
|
||||
*pVal = m_lApplicationVersion;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_appVersion(LONG newVal)
|
||||
{
|
||||
m_lApplicationVersion = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_wuName(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_strWorkunitName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_wuName(BSTR newVal)
|
||||
{
|
||||
m_strWorkunitName = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_resName(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_strResultName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_resName(BSTR newVal)
|
||||
{
|
||||
m_strResultName = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_teamName(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_strTeamName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_teamName(BSTR newVal)
|
||||
{
|
||||
m_strTeamName = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_userName(BSTR* pVal)
|
||||
{
|
||||
*pVal = m_strUserName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_userName(BSTR newVal)
|
||||
{
|
||||
m_strUserName = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_userCreditTotal(DOUBLE* pVal)
|
||||
{
|
||||
*pVal = m_dUserCreditTotal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_userCreditTotal(DOUBLE newVal)
|
||||
{
|
||||
m_dUserCreditTotal = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_userCreditAverage(DOUBLE* pVal)
|
||||
{
|
||||
*pVal = m_dUserCreditAverage;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_userCreditAverage(DOUBLE newVal)
|
||||
{
|
||||
m_dUserCreditAverage = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_hostCreditTotal(DOUBLE* pVal)
|
||||
{
|
||||
*pVal = m_dHostCreditTotal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_hostCreditTotal(DOUBLE newVal)
|
||||
{
|
||||
m_dHostCreditTotal = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_hostCreditAverage(DOUBLE* pVal)
|
||||
{
|
||||
*pVal = m_dHostCreditAverage;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_hostCreditAverage(DOUBLE newVal)
|
||||
{
|
||||
m_dHostCreditAverage = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_scrsaveMode(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bScreensaver;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_scrsaveMode(BOOL newVal)
|
||||
{
|
||||
m_bScreensaver = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_suspended(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bSuspended;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_suspended(BOOL newVal)
|
||||
{
|
||||
m_bSuspended = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_networkSuspended(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bNetworkSuspended;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_networkSuspended(BOOL newVal)
|
||||
{
|
||||
m_bNetworkSuspended = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_exiting(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bExiting;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_exiting(BOOL newVal)
|
||||
{
|
||||
m_bExiting = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_exitTimeout(DOUBLE *pVal)
|
||||
{
|
||||
*pVal = m_dExitCountdown;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_exitTimeout(DOUBLE newVal)
|
||||
{
|
||||
m_dExitCountdown = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_cpuTime(DOUBLE *pVal)
|
||||
{
|
||||
*pVal = m_dCPUTime;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_cpuTime(DOUBLE newVal)
|
||||
{
|
||||
m_dCPUTime = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_elapsedTime(DOUBLE *pVal)
|
||||
{
|
||||
*pVal = m_dElapsedTime;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_elapsedTime(DOUBLE newVal)
|
||||
{
|
||||
m_dElapsedTime = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_fractionDone(DOUBLE *pVal)
|
||||
{
|
||||
*pVal = m_dFractionDone;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_fractionDone(DOUBLE newVal)
|
||||
{
|
||||
m_dFractionDone = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_vboxJob(BOOL *pVal)
|
||||
{
|
||||
*pVal = m_bVboxwrapperJob;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_vboxJob(BOOL newVal)
|
||||
{
|
||||
m_bVboxwrapperJob = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_rdpPort(LONG* pVal)
|
||||
{
|
||||
*pVal = m_lRemoteDesktopPort;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_rdpPort(LONG newVal)
|
||||
{
|
||||
m_lRemoteDesktopPort = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::get_apiPort(LONG* pVal)
|
||||
{
|
||||
*pVal = m_lWebAPIPort;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHTMLBrowserHostUI::put_apiPort(LONG newVal)
|
||||
{
|
||||
m_lWebAPIPort = newVal;
|
||||
return S_OK;
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _BROWSERCTRLUI_WIN_H_
|
||||
#define _BROWSERCTRLUI_WIN_H_
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHTMLBrowserHostUI class
|
||||
|
||||
class ATL_NO_VTABLE CHTMLBrowserHostUI :
|
||||
public CComObjectRootEx<CComSingleThreadModel>,
|
||||
public IDispatchImpl<IHTMLBrowserHostUI, &IID_IHTMLBrowserHostUI, &LIBID_HTMLGfxLib, 0xFFFF, 0xFFFF>
|
||||
{
|
||||
BEGIN_COM_MAP(CHTMLBrowserHostUI)
|
||||
COM_INTERFACE_ENTRY(IHTMLBrowserHostUI)
|
||||
COM_INTERFACE_ENTRY(IDispatch)
|
||||
END_COM_MAP()
|
||||
public:
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
HRESULT FinalConstruct();
|
||||
void FinalRelease();
|
||||
|
||||
STDMETHOD(log)(BSTR message);
|
||||
STDMETHOD(debug)(BSTR message);
|
||||
STDMETHOD(info)(BSTR message);
|
||||
STDMETHOD(warn)(BSTR message);
|
||||
STDMETHOD(error)(BSTR message);
|
||||
STDMETHOD(isStateUpdated)(BOOL* pVal);
|
||||
STDMETHOD(resetStateUpdate)(BOOL newVal);
|
||||
STDMETHOD(get_appName)(BSTR* pVal);
|
||||
STDMETHOD(put_appName)(BSTR newVal);
|
||||
STDMETHOD(get_appVersion)(LONG* pVal);
|
||||
STDMETHOD(put_appVersion)(LONG newVal);
|
||||
STDMETHOD(get_wuName)(BSTR* pVal);
|
||||
STDMETHOD(put_wuName)(BSTR newVal);
|
||||
STDMETHOD(get_resName)(BSTR* pVal);
|
||||
STDMETHOD(put_resName)(BSTR newVal);
|
||||
STDMETHOD(get_teamName)(BSTR* pVal);
|
||||
STDMETHOD(put_teamName)(BSTR newVal);
|
||||
STDMETHOD(get_userName)(BSTR* pVal);
|
||||
STDMETHOD(put_userName)(BSTR newVal);
|
||||
STDMETHOD(get_userCreditTotal)(DOUBLE* pVal);
|
||||
STDMETHOD(put_userCreditTotal)(DOUBLE newVal);
|
||||
STDMETHOD(get_userCreditAverage)(DOUBLE* pVal);
|
||||
STDMETHOD(put_userCreditAverage)(DOUBLE newVal);
|
||||
STDMETHOD(get_hostCreditTotal)(DOUBLE* pVal);
|
||||
STDMETHOD(put_hostCreditTotal)(DOUBLE newVal);
|
||||
STDMETHOD(get_hostCreditAverage)(DOUBLE* pVal);
|
||||
STDMETHOD(put_hostCreditAverage)(DOUBLE newVal);
|
||||
STDMETHOD(get_scrsaveMode)(BOOL* pVal);
|
||||
STDMETHOD(put_scrsaveMode)(BOOL newVal);
|
||||
STDMETHOD(get_suspended)(BOOL* pVal);
|
||||
STDMETHOD(put_suspended)(BOOL newVal);
|
||||
STDMETHOD(get_networkSuspended)(BOOL* pVal);
|
||||
STDMETHOD(put_networkSuspended)(BOOL newVal);
|
||||
STDMETHOD(get_exiting)(BOOL* pVal);
|
||||
STDMETHOD(put_exiting)(BOOL newVal);
|
||||
STDMETHOD(get_exitTimeout)(DOUBLE* pVal);
|
||||
STDMETHOD(put_exitTimeout)(DOUBLE newVal);
|
||||
STDMETHOD(get_cpuTime)(DOUBLE* pVal);
|
||||
STDMETHOD(put_cpuTime)(DOUBLE newVal);
|
||||
STDMETHOD(get_elapsedTime)(DOUBLE* pVal);
|
||||
STDMETHOD(put_elapsedTime)(DOUBLE newVal);
|
||||
STDMETHOD(get_fractionDone)(DOUBLE* pVal);
|
||||
STDMETHOD(put_fractionDone)(DOUBLE newVal);
|
||||
STDMETHOD(get_vboxJob)(BOOL* pVal);
|
||||
STDMETHOD(put_vboxJob)(BOOL newVal);
|
||||
STDMETHOD(get_rdpPort)(LONG* pVal);
|
||||
STDMETHOD(put_rdpPort)(LONG newVal);
|
||||
STDMETHOD(get_apiPort)(LONG* pVal);
|
||||
STDMETHOD(put_apiPort)(LONG newVal);
|
||||
|
||||
BOOL m_bStateUpdated;
|
||||
CComBSTR m_strApplicationName;
|
||||
LONG m_lApplicationVersion;
|
||||
CComBSTR m_strWorkunitName;
|
||||
CComBSTR m_strResultName;
|
||||
CComBSTR m_strTeamName;
|
||||
CComBSTR m_strUserName;
|
||||
double m_dUserCreditTotal;
|
||||
double m_dUserCreditAverage;
|
||||
double m_dHostCreditTotal;
|
||||
double m_dHostCreditAverage;
|
||||
BOOL m_bScreensaver;
|
||||
BOOL m_bSuspended;
|
||||
BOOL m_bNetworkSuspended;
|
||||
BOOL m_bExiting;
|
||||
double m_dExitCountdown;
|
||||
double m_dCPUTime;
|
||||
double m_dElapsedTime;
|
||||
double m_dFractionDone;
|
||||
BOOL m_bVboxwrapperJob;
|
||||
LONG m_lRemoteDesktopPort;
|
||||
LONG m_lWebAPIPort;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -81,6 +81,7 @@ HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
|
|||
RECT rc = {0, 0, 0, 0};
|
||||
DWORD dwExStyle = 0;
|
||||
DWORD dwStyle = 0;
|
||||
APP_INIT_DATA aid;
|
||||
char szWindowTitle[256];
|
||||
char szWindowInfo[256];
|
||||
char szDebuggingInfo[256];
|
||||
|
@ -103,11 +104,12 @@ HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
|
|||
// Prepare environment for detecting system conditions
|
||||
//
|
||||
boinc_parse_init_data_file();
|
||||
boinc_get_init_data(aid);
|
||||
|
||||
// Initialize Web Server
|
||||
//
|
||||
boinc_get_port(false, iWebServerPort);
|
||||
webserver_initialize(iWebServerPort, m_bDebugging);
|
||||
webserver_initialize(iWebServerPort, m_bFullscreen, m_bDebugging);
|
||||
|
||||
// Create Window Instance
|
||||
//
|
||||
|
@ -118,27 +120,19 @@ HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
// Store a copy of APP_INIT_DATA for future use
|
||||
//
|
||||
boinc_get_init_data(m_pWnd->aid);
|
||||
|
||||
// Store web server information for future use
|
||||
//
|
||||
m_pWnd->m_iWebServerPort = iWebServerPort;
|
||||
|
||||
// Construct the window caption
|
||||
//
|
||||
if (m_pWnd->aid.app_version) {
|
||||
if (aid.app_version) {
|
||||
snprintf(
|
||||
szWindowInfo, sizeof(szWindowInfo),
|
||||
"%s version %.2f [workunit: %s]",
|
||||
m_pWnd->aid.app_name, m_pWnd->aid.app_version/100.0, m_pWnd->aid.wu_name
|
||||
aid.app_name, aid.app_version/100.0, aid.wu_name
|
||||
);
|
||||
} else {
|
||||
snprintf(
|
||||
szWindowInfo, sizeof(szWindowInfo),
|
||||
"%s [workunit: %s]",
|
||||
m_pWnd->aid.app_name, m_pWnd->aid.wu_name
|
||||
aid.app_name, aid.wu_name
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,22 +28,13 @@
|
|||
#include <exdispid.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include "util.h"
|
||||
#include "win_util.h"
|
||||
#include "version.h"
|
||||
#include "boinc_api.h"
|
||||
#include "graphics2.h"
|
||||
#include "diagnostics.h"
|
||||
#include "filesys.h"
|
||||
#include "browser_i.h"
|
||||
#include "browser_win.h"
|
||||
#include "browserlog.h"
|
||||
#include "browserctrlui_win.h"
|
||||
#include "webapi.h"
|
||||
#include "browsermain_win.h"
|
||||
#include "browserctrl_win.h"
|
||||
#include "browserwnd_win.h"
|
||||
#include "browsermain_win.h"
|
||||
#include "graphics.h"
|
||||
#include "vboxwrapper.h"
|
||||
|
||||
|
||||
CHTMLBrowserWnd::CHTMLBrowserWnd()
|
||||
|
@ -51,23 +42,8 @@ CHTMLBrowserWnd::CHTMLBrowserWnd()
|
|||
m_pBrowserHost = NULL;
|
||||
m_hIcon = NULL;
|
||||
m_hIconSmall = NULL;
|
||||
|
||||
m_bForceRereadPreferences = false;
|
||||
aid.clear();
|
||||
status.abort_request = 0;
|
||||
status.no_heartbeat = 0;
|
||||
status.quit_request = 0;
|
||||
status.reread_init_data_file = 0;
|
||||
status.suspended = 0;
|
||||
status.network_suspended = 0;
|
||||
m_dUpdateTime = 0.0;
|
||||
m_dCPUTime = 0.0;
|
||||
m_dElapsedTime = 0.0;
|
||||
m_dFractionDone = 0.0;
|
||||
m_bInitializing = false;
|
||||
m_bScreensaverMode = false;
|
||||
m_bVboxwrapperJob = false;
|
||||
m_lRemoteDesktopPort = 0;
|
||||
m_lWebAPIPort = 0;
|
||||
}
|
||||
|
||||
CHTMLBrowserWnd::~CHTMLBrowserWnd()
|
||||
|
@ -83,12 +59,6 @@ CHTMLBrowserWnd::~CHTMLBrowserWnd()
|
|||
::DestroyIcon(m_hIconSmall);
|
||||
m_hIconSmall = NULL;
|
||||
}
|
||||
|
||||
if (aid.project_preferences)
|
||||
{
|
||||
delete aid.project_preferences;
|
||||
aid.project_preferences = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CHTMLBrowserWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
|
@ -148,8 +118,8 @@ LRESULT CHTMLBrowserWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
|||
m_strEmbeddedURL += szExecutable;
|
||||
m_strEmbeddedURL += "/index.html";
|
||||
|
||||
// Stage rereading of all the state files
|
||||
m_bForceRereadPreferences = true;
|
||||
//
|
||||
m_bInitializing = true;
|
||||
|
||||
// Start the timer
|
||||
SetTimer(1, 1000);
|
||||
|
@ -192,159 +162,25 @@ LRESULT CHTMLBrowserWnd::OnInputActivity(UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
|
||||
LRESULT CHTMLBrowserWnd::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
int retval = ERR_FREAD;
|
||||
HRESULT hr = E_FAIL;
|
||||
BOOL bExit = false;
|
||||
std::string strDefaultURL;
|
||||
std::string strRunningURL;
|
||||
std::string strSuspendedURL;
|
||||
std::string strNetworkSuspendedURL;
|
||||
std::string strExitingURL;
|
||||
double dExitTimeout = 0.0;
|
||||
int temp = 0;
|
||||
CComQIPtr<IHTMLBrowserHostUI> pHostUI;
|
||||
|
||||
boinc_parse_graphics_status(
|
||||
&m_dUpdateTime,
|
||||
&m_dCPUTime,
|
||||
&m_dElapsedTime,
|
||||
&m_dFractionDone,
|
||||
&status
|
||||
);
|
||||
|
||||
// Query for the IHTMLBrowserHostUI interface so we can setup the browser with
|
||||
// information that doesn't change very much.
|
||||
//
|
||||
hr = m_pBrowserHost->GetExternal((IDispatch**)&pHostUI);
|
||||
if (SUCCEEDED(hr) && pHostUI.p)
|
||||
if (is_exiting() && (get_exit_timeout() > 5.0))
|
||||
{
|
||||
bExit = status.abort_request || status.no_heartbeat || status.quit_request;
|
||||
if (bExit && ((dtime() - m_dUpdateTime) > 5.0))
|
||||
if (!_AtlModule.m_bDebugging)
|
||||
{
|
||||
dExitTimeout = dtime() - m_dUpdateTime - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
dExitTimeout = 0.0;
|
||||
PostMessage(WM_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (dExitTimeout > 5.0)
|
||||
{
|
||||
if (!_AtlModule.m_bDebugging)
|
||||
{
|
||||
PostMessage(WM_CLOSE);
|
||||
}
|
||||
}
|
||||
if (m_bInitializing)
|
||||
{
|
||||
m_bInitializing = false;
|
||||
|
||||
pHostUI->put_suspended(status.suspended);
|
||||
pHostUI->put_networkSuspended(status.network_suspended);
|
||||
pHostUI->put_exiting(bExit);
|
||||
pHostUI->put_exitTimeout(dExitTimeout);
|
||||
pHostUI->put_cpuTime(m_dCPUTime);
|
||||
pHostUI->put_elapsedTime(m_dElapsedTime);
|
||||
pHostUI->put_fractionDone(m_dFractionDone);
|
||||
|
||||
// Check to see if vboxwrapper has logged and Web API port info or
|
||||
// Remote Desktop port info
|
||||
//
|
||||
if (m_bVboxwrapperJob)
|
||||
{
|
||||
if (!m_lRemoteDesktopPort)
|
||||
{
|
||||
if (0 == parse_vbox_remote_desktop_port(temp))
|
||||
{
|
||||
m_lRemoteDesktopPort = temp;
|
||||
browserlog_msg("Vboxwrapper remote desktop port assignment (%d).", m_lRemoteDesktopPort);
|
||||
pHostUI->put_rdpPort(m_lRemoteDesktopPort);
|
||||
}
|
||||
}
|
||||
if (!m_lWebAPIPort)
|
||||
{
|
||||
if (0 == parse_vbox_webapi_port(temp))
|
||||
{
|
||||
m_lWebAPIPort = temp;
|
||||
browserlog_msg("Vboxwrapper web api port assignment (%d).", m_lWebAPIPort);
|
||||
pHostUI->put_apiPort(m_lWebAPIPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status.reread_init_data_file || m_bForceRereadPreferences)
|
||||
{
|
||||
status.reread_init_data_file = 0;
|
||||
m_bForceRereadPreferences = false;
|
||||
|
||||
browserlog_msg("Preference change detected.");
|
||||
|
||||
// Get updated state
|
||||
//
|
||||
if (aid.project_preferences) delete aid.project_preferences;
|
||||
boinc_parse_init_data_file();
|
||||
boinc_get_init_data(aid);
|
||||
|
||||
// Inform the HTML Document DOM about the state changes
|
||||
//
|
||||
pHostUI->resetStateUpdate(TRUE);
|
||||
pHostUI->put_scrsaveMode(m_bScreensaverMode);
|
||||
pHostUI->put_appName(CComBSTR(aid.app_name));
|
||||
pHostUI->put_appVersion(aid.app_version);
|
||||
pHostUI->put_wuName(CComBSTR(aid.wu_name));
|
||||
pHostUI->put_resName(CComBSTR(aid.result_name));
|
||||
pHostUI->put_userName(CComBSTR(aid.user_name));
|
||||
pHostUI->put_teamName(CComBSTR(aid.team_name));
|
||||
pHostUI->put_userCreditTotal(aid.user_total_credit);
|
||||
pHostUI->put_userCreditAverage(aid.user_expavg_credit);
|
||||
pHostUI->put_hostCreditTotal(aid.host_total_credit);
|
||||
pHostUI->put_hostCreditAverage(aid.host_expavg_credit);
|
||||
|
||||
// Check for vboxwrapper state
|
||||
//
|
||||
m_bVboxwrapperJob = is_vboxwrapper_job();
|
||||
if (m_bVboxwrapperJob)
|
||||
{
|
||||
browserlog_msg("Vboxwrapper task detected.");
|
||||
pHostUI->put_vboxJob(m_bVboxwrapperJob);
|
||||
}
|
||||
|
||||
// Check for project configured state urls
|
||||
//
|
||||
if (0 == parse_graphics(strDefaultURL, strRunningURL, strSuspendedURL, strNetworkSuspendedURL, strExitingURL))
|
||||
{
|
||||
if (strDefaultURL.size())
|
||||
{
|
||||
m_strDefaultURL = NormalizeURL(strDefaultURL);
|
||||
browserlog_msg("Configured default_url: '%s'.", strDefaultURL.c_str());
|
||||
}
|
||||
if (strRunningURL.size())
|
||||
{
|
||||
m_strRunningURL = NormalizeURL(strRunningURL);
|
||||
browserlog_msg("Configured running_url: '%s'.", strRunningURL.c_str());
|
||||
}
|
||||
if (strSuspendedURL.size())
|
||||
{
|
||||
m_strSuspendedURL = NormalizeURL(strSuspendedURL);
|
||||
browserlog_msg("Configured suspended_url: '%s'.", strSuspendedURL.c_str());
|
||||
}
|
||||
if (strNetworkSuspendedURL.size())
|
||||
{
|
||||
m_strNetworkSuspendedURL = NormalizeURL(strNetworkSuspendedURL);
|
||||
browserlog_msg("Configured network_suspended_url: '%s'.", strNetworkSuspendedURL.c_str());
|
||||
}
|
||||
if (strExitingURL.size())
|
||||
{
|
||||
m_strExitingURL = NormalizeURL(strExitingURL);
|
||||
browserlog_msg("Configured exiting_url: '%s'.", strExitingURL.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Forcefully switch to the currect URL
|
||||
NavigateToStateURL(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Switch to the correct URL
|
||||
NavigateToStateURL(false);
|
||||
}
|
||||
// Forcefully switch to the state URL
|
||||
NavigateToStateURL(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Switch to the correct state URL
|
||||
NavigateToStateURL(false);
|
||||
}
|
||||
|
||||
bHandled = TRUE;
|
||||
|
@ -370,35 +206,13 @@ STDMETHODIMP_(void) CHTMLBrowserWnd::OnNewWindow3(IDispatch** ppDisp, VARIANT_BO
|
|||
|
||||
void CHTMLBrowserWnd::NavigateToStateURL(bool bForce)
|
||||
{
|
||||
std::string strDesiredURL;
|
||||
CComVariant vt;
|
||||
CComVariant vtTargetURL;
|
||||
CComBSTR strTargetURL;
|
||||
char buf[256];
|
||||
|
||||
// Start out with the default URL
|
||||
strTargetURL = m_strDefaultURL.c_str();
|
||||
|
||||
// See if we need to override the default
|
||||
if ((status.abort_request || status.quit_request || status.no_heartbeat) && !m_strExitingURL.empty()) {
|
||||
strTargetURL = m_strExitingURL.c_str();
|
||||
} else if (status.suspended && !m_strSuspendedURL.empty()) {
|
||||
strTargetURL = m_strSuspendedURL.c_str();
|
||||
} else if (status.network_suspended && !m_strNetworkSuspendedURL.empty()) {
|
||||
strTargetURL = m_strNetworkSuspendedURL.c_str();
|
||||
} else if (!m_strRunningURL.empty()) {
|
||||
strTargetURL = m_strRunningURL.c_str();
|
||||
}
|
||||
|
||||
// Are we running a vboxwrapper job? If so, does it expose a webapi port number?
|
||||
if ((m_bVboxwrapperJob && m_lWebAPIPort) && (strTargetURL.Length() == 0)) {
|
||||
_snprintf(buf, sizeof(buf), "http://localhost:%d/", m_lWebAPIPort);
|
||||
strTargetURL = buf;
|
||||
}
|
||||
|
||||
// If nothing has been approved to the point, use the embedded HTML page
|
||||
if (strTargetURL.Length() == 0) {
|
||||
strTargetURL = m_strEmbeddedURL;
|
||||
}
|
||||
determine_state_url(strDesiredURL);
|
||||
strTargetURL = strDesiredURL.c_str();
|
||||
|
||||
// Navigate to URL
|
||||
if ((m_strCurrentURL != strTargetURL) || bForce) {
|
||||
|
@ -410,27 +224,3 @@ void CHTMLBrowserWnd::NavigateToStateURL(bool bForce)
|
|||
m_pBrowserCtrl->Navigate2(&vtTargetURL, &vt, &vt, &vt, &vt);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CHTMLBrowserWnd::NormalizeURL(std::string& url)
|
||||
{
|
||||
std::string strNormalized;
|
||||
char buf[256];
|
||||
|
||||
if (starts_with(url, "http://") || starts_with(url, "https://"))
|
||||
{
|
||||
strNormalized = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume it is a local file
|
||||
|
||||
// Configure the base url using the http protocol pointing to our locally spun
|
||||
// up web server, use a username and password if they are provided.
|
||||
//
|
||||
_snprintf(buf, sizeof(buf), "http://localhost:%d/", m_iWebServerPort);
|
||||
strNormalized = buf;
|
||||
strNormalized += url;
|
||||
}
|
||||
|
||||
return strNormalized;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ public:
|
|||
|
||||
//
|
||||
void NavigateToStateURL(bool bForce);
|
||||
std::string NormalizeURL(std::string& url);
|
||||
|
||||
CComObject<CHTMLBrowserHost>* m_pBrowserHost;
|
||||
CComQIPtr<IWebBrowser2> m_pBrowserCtrl;
|
||||
|
@ -67,25 +66,10 @@ public:
|
|||
HICON m_hIcon;
|
||||
HICON m_hIconSmall;
|
||||
|
||||
bool m_bForceRereadPreferences;
|
||||
APP_INIT_DATA aid;
|
||||
BOINC_STATUS status;
|
||||
double m_dUpdateTime;
|
||||
double m_dCPUTime;
|
||||
double m_dElapsedTime;
|
||||
double m_dFractionDone;
|
||||
bool m_bInitializing;
|
||||
bool m_bScreensaverMode;
|
||||
bool m_bVboxwrapperJob;
|
||||
CComBSTR m_strCurrentURL;
|
||||
CComBSTR m_strEmbeddedURL;
|
||||
std::string m_strDefaultURL;
|
||||
std::string m_strRunningURL;
|
||||
std::string m_strSuspendedURL;
|
||||
std::string m_strNetworkSuspendedURL;
|
||||
std::string m_strExitingURL;
|
||||
long m_lRemoteDesktopPort;
|
||||
long m_lWebAPIPort;
|
||||
int m_iWebServerPort;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,82 +0,0 @@
|
|||
//
|
||||
//
|
||||
|
||||
var BOINC = function () {
|
||||
var req = null;
|
||||
|
||||
var updatedTime;
|
||||
var updatedStateTime;
|
||||
var userName;
|
||||
var teamName;
|
||||
var wuName;
|
||||
var elapsedTime;
|
||||
var cpuTime;
|
||||
var fractionDone;
|
||||
var isSuspended;
|
||||
var isNetworkSuspended;
|
||||
var isAbortRequested;
|
||||
var isQuitRequested;
|
||||
var rereadInitDataFile;
|
||||
|
||||
|
||||
var XMLHttpFactories = [
|
||||
function () { return new XMLHttpRequest() },
|
||||
function () { return new ActiveXObject("Msxml2.XMLHTTP") },
|
||||
function () { return new ActiveXObject("Msxml3.XMLHTTP") },
|
||||
function () { return new ActiveXObject("Microsoft.XMLHTTP") }
|
||||
];
|
||||
|
||||
for (var i = 0; i < XMLHttpFactories.length; i++) {
|
||||
try {
|
||||
req = XMLHttpFactories[i]();
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
BOINC.prototype.sendRequest = function (url, postData) {
|
||||
if (!req) return;
|
||||
req.open((postData) ? "POST" : "GET", url, false);
|
||||
req.setRequestHeader("User-Agent", "XMLHTTP/1.0");
|
||||
if (postData)
|
||||
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
req.send(postData);
|
||||
return req.responseXML
|
||||
}
|
||||
|
||||
BOINC.prototype.poll = function () {
|
||||
var xmlDoc;
|
||||
|
||||
xmlDoc = sendRequest("/api/getGraphicsStatus", "");
|
||||
|
||||
updatedTime = parseFloat(xmlDoc.getElementsByTagName("updated_time")[0].childNodes[0].nodeValue);
|
||||
fractionDone = parseFloat(xmlDoc.getElementsByTagName("fraction_done")[0].childNodes[0].nodeValue);
|
||||
elapsedTime = parseFloat(xmlDoc.getElementsByTagName("elapsed_time")[0].childNodes[0].nodeValue);
|
||||
cpuTime = parseFloat(xmlDoc.getElementsByTagName("cpu_time")[0].childNodes[0].nodeValue);
|
||||
isSuspended = parseInt(xmlDoc.getElementsByTagName("suspended")[0].childNodes[0].nodeValue);
|
||||
isNetworkSuspended = parseInt(xmlDoc.getElementsByTagName("network_suspended")[0].childNodes[0].nodeValue);
|
||||
isAbortRequested = parseInt(xmlDoc.getElementsByTagName("abort_request")[0].childNodes[0].nodeValue);
|
||||
isQuitRequested = parseInt(xmlDoc.getElementsByTagName("quit_request")[0].childNodes[0].nodeValue);
|
||||
rereadInitDataFile = parseInt(xmlDoc.getElementsByTagName("reread_init_data_file")[0].childNodes[0].nodeValue);
|
||||
|
||||
xmlDoc = null;
|
||||
|
||||
if ((updatedStateTime != updatedTime) || rereadInitDataFile) {
|
||||
updatedStateTime = updatedTime;
|
||||
|
||||
xmlDoc = sendRequest("/api/getInitData", "");
|
||||
|
||||
userName = xmlDoc.getElementsByTagName("user_name")[0].childNodes[0].nodeValue;
|
||||
teamName = xmlDoc.getElementsByTagName("team_name")[0].childNodes[0].nodeValue;
|
||||
wuName = xmlDoc.getElementsByTagName("wu_name")[0].childNodes[0].nodeValue;
|
||||
|
||||
xmlDoc = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
// Remap console functions if the console object doesn't exist in the correct
|
||||
// location
|
||||
//
|
||||
|
||||
if (!(window.console)) {
|
||||
var req = null;
|
||||
var XMLHttpFactories = [
|
||||
function () { return new XMLHttpRequest() },
|
||||
function () { return new ActiveXObject("Msxml2.XMLHTTP") },
|
||||
function () { return new ActiveXObject("Msxml3.XMLHTTP") },
|
||||
function () { return new ActiveXObject("Microsoft.XMLHTTP") }
|
||||
];
|
||||
|
||||
console = {};
|
||||
|
||||
console.createXMLHTTPObject = function () {
|
||||
var xmlhttp = false;
|
||||
for (var i = 0; i < XMLHttpFactories.length; i++) {
|
||||
try {
|
||||
xmlhttp = XMLHttpFactories[i]();
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return xmlhttp;
|
||||
}
|
||||
|
||||
console.sendRequest = function (url, postData) {
|
||||
if (req == null) {
|
||||
req = createXMLHTTPObject();
|
||||
}
|
||||
if (!req) return;
|
||||
var method = (postData) ? "POST" : "GET";
|
||||
req.open(method, url, false);
|
||||
req.setRequestHeader("User-Agent", "XMLHTTP/1.0");
|
||||
if (postData)
|
||||
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
req.send(postData);
|
||||
}
|
||||
|
||||
console.logMessage = function (level, message) {
|
||||
console.sendRequest("/api/logMessage", "level=" + level + "&message=" + message);
|
||||
};
|
||||
|
||||
console.log = function (message) {
|
||||
console.logMessage("INFO", message);
|
||||
};
|
||||
|
||||
console.debug = function (message) {
|
||||
console.logMessage("DEBUG", message);
|
||||
};
|
||||
|
||||
console.info = function (message) {
|
||||
console.logMessage("INFO", message);
|
||||
};
|
||||
|
||||
console.warn = function (message) {
|
||||
console.logMessage("WARNING", message);
|
||||
};
|
||||
|
||||
console.error = function (message) {
|
||||
console.logMessage("ERROR", message);
|
||||
};
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type="text/javascript" src="console.js" />
|
||||
<script type="text/javascript" src="boinc.js" />
|
||||
</head>
|
||||
<body style="background-color:Black;overflow:hidden">
|
||||
|
||||
<div id="content" style="position:absolute">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="vertical-align:middle">
|
||||
<img alt="" src="boinc.png" />
|
||||
</td>
|
||||
<td style="vertical-align:top; width:250px">
|
||||
<div id="username_container" style="visibility:hidden; color:White"></div>
|
||||
<div id="teamname_container" style="visibility:hidden; color:White"></div>
|
||||
<div id="workunitname_container" style="visibility:hidden; color:White"></div>
|
||||
<div id="progressbar_container" style="visibility:hidden; border: 1px Solid White; width:245px; height:23px">
|
||||
<div id="progressbar_text" style="z-index:1; position:absolute; color:White; text-align:center; height:100%; width:100%">
|
||||
</div>
|
||||
<div id="progressbar" style="z-index:0; position:absolute; height:100%; width:0px; background-color:Blue;">
|
||||
</div>
|
||||
</div>
|
||||
<div id="message_container" style="text-align:center;color:White">Initializing...</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var interval;
|
||||
var step = 5;
|
||||
var delay = 1000;
|
||||
var height = 0;
|
||||
var Hoffset = 0;
|
||||
var Woffset = 0;
|
||||
var yon = 0;
|
||||
var xon = 0;
|
||||
var xPos = 0;
|
||||
var yPos = 0;
|
||||
|
||||
function refresh() {
|
||||
var message = "";
|
||||
|
||||
if (window.external.isStateUpdated()) {
|
||||
window.external.resetStateUpdate(false);
|
||||
|
||||
var userName = window.external.userName;
|
||||
var teamName = window.external.teamName;
|
||||
var wuName = window.external.wuName;
|
||||
|
||||
username_container.innerHTML = userName;
|
||||
if (teamName.length != 0) {
|
||||
teamname_container.innerHTML = teamName;
|
||||
}
|
||||
if (wuName.length != 0) {
|
||||
workunitname_container.innerHTML = wuName;
|
||||
}
|
||||
}
|
||||
|
||||
progressbar.style.width = String(Math.floor(parseInt(progressbar_container.style.width, 10) * window.external.fractionDone) + "px");
|
||||
progressbar_text.innerHTML = String(Math.floor(100 * window.external.fractionDone) + " %");
|
||||
|
||||
if (window.external.suspended) {
|
||||
message = "Task is suspended.";
|
||||
} else if (window.external.networkSuspended) {
|
||||
message = "Network is suspended.";
|
||||
} else if (window.external.exiting) {
|
||||
message = "Exiting in " + window.external.exitTimeout + " seconds";
|
||||
}
|
||||
|
||||
if ((username_container.innerHTML.length == 0) || window.external.exiting) {
|
||||
username_container.style.visibility = "hidden";
|
||||
teamname_container.style.visibility = "hidden";
|
||||
workunitname_container.style.visibility = "hidden";
|
||||
progressbar_container.style.visibility = "hidden";
|
||||
message_container.style.visibility = "visible";
|
||||
} else {
|
||||
username_container.style.visibility = "visible";
|
||||
teamname_container.style.visibility = "visible";
|
||||
workunitname_container.style.visibility = "visible";
|
||||
progressbar_container.style.visibility = "visible";
|
||||
message_container.style.visibility = "hidden";
|
||||
if (message.length > 0) {
|
||||
message_container.innerHTML = message;
|
||||
message_container.style.textAlign = "left";
|
||||
message_container.style.visibility = "visible";
|
||||
} else {
|
||||
message_container.innerHTML = "";
|
||||
message_container.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
update_positions();
|
||||
}
|
||||
|
||||
function update_positions() {
|
||||
width = document.body.clientWidth;
|
||||
height = document.body.clientHeight;
|
||||
Hoffset = content.offsetHeight;
|
||||
Woffset = content.offsetWidth;
|
||||
content.style.left = xPos + document.body.scrollLeft;
|
||||
content.style.top = yPos + document.body.scrollTop;
|
||||
|
||||
if (yon) {
|
||||
yPos = yPos + step;
|
||||
}
|
||||
else {
|
||||
yPos = yPos - step;
|
||||
}
|
||||
if (yPos < 0) {
|
||||
yon = 1;
|
||||
yPos = 0;
|
||||
}
|
||||
if (yPos >= (height - Hoffset)) {
|
||||
yon = 0;
|
||||
yPos = (height - Hoffset);
|
||||
}
|
||||
if (xon) {
|
||||
xPos = xPos + step;
|
||||
}
|
||||
else {
|
||||
xPos = xPos - step;
|
||||
}
|
||||
if (xPos < 0) {
|
||||
xon = 1;
|
||||
xPos = 0;
|
||||
}
|
||||
if (xPos >= (width - Woffset)) {
|
||||
xon = 0;
|
||||
xPos = (width - Woffset);
|
||||
}
|
||||
}
|
||||
|
||||
interval = setInterval('refresh()', delay);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,234 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
//
|
||||
|
||||
var BOINC = function () {
|
||||
var updatedTime;
|
||||
var updatedStateTime;
|
||||
var userName;
|
||||
var teamName;
|
||||
var wuName;
|
||||
var resultName;
|
||||
var authenticator;
|
||||
var userId;
|
||||
var teamId;
|
||||
var hostId;
|
||||
var userCreditTotal;
|
||||
var userCreditAverage;
|
||||
var hostCreditTotal;
|
||||
var hostCreditAverage;
|
||||
var exit;
|
||||
var exit_timeout;
|
||||
var vboxJob;
|
||||
var webAPIPort;
|
||||
var remoteDesktopPort;
|
||||
var elapsedTime;
|
||||
var cpuTime;
|
||||
var fractionDone;
|
||||
var suspended;
|
||||
var networkSuspended;
|
||||
var abortRequested;
|
||||
var quitRequested;
|
||||
var stateFileUpdated;
|
||||
|
||||
this.poll();
|
||||
};
|
||||
|
||||
BOINC.prototype.createRequest = function () {
|
||||
var xmlHttp = null;
|
||||
var XMLHttpFactories = [
|
||||
function () { return new XMLHttpRequest() },
|
||||
function () { return new ActiveXObject('Msxml2.XMLHTTP') },
|
||||
function () { return new ActiveXObject('Msxml3.XMLHTTP') },
|
||||
function () { return new ActiveXObject('Microsoft.XMLHTTP') }
|
||||
];
|
||||
|
||||
for (var i = 0; i < XMLHttpFactories.length; i++) {
|
||||
try {
|
||||
xmlHttp = XMLHttpFactories[i]();
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
|
||||
BOINC.prototype.sendRequest = function (url) {
|
||||
var req = this.createRequest();
|
||||
var response = null;
|
||||
req.open('GET', url, false);
|
||||
req.send();
|
||||
response = req.responseXML;
|
||||
req = null;
|
||||
return response;
|
||||
}
|
||||
|
||||
BOINC.prototype.poll = function () {
|
||||
var xmlGraphicsStatusDoc;
|
||||
var xmlInitDataDoc;
|
||||
|
||||
xmlGraphicsStatusDoc = this.sendRequest('/api/getGraphicsStatus');
|
||||
this.updatedTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('updated_time')[0].childNodes[0].nodeValue);
|
||||
this.fractionDone = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('fraction_done')[0].childNodes[0].nodeValue);
|
||||
this.elapsedTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('elapsed_time')[0].childNodes[0].nodeValue);
|
||||
this.cpuTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('cpu_time')[0].childNodes[0].nodeValue);
|
||||
this.suspended = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('suspended')[0].childNodes[0].nodeValue);
|
||||
this.networkSuspended = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('network_suspended')[0].childNodes[0].nodeValue);
|
||||
this.abortRequested = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('abort_request')[0].childNodes[0].nodeValue);
|
||||
this.quitRequested = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('quit_request')[0].childNodes[0].nodeValue);
|
||||
this.stateFileUpdated = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('reread_init_data_file')[0].childNodes[0].nodeValue);
|
||||
this.exit = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('suspended')[0].childNodes[0].nodeValue);
|
||||
this.exit_timeout = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('cpu_time')[0].childNodes[0].nodeValue);
|
||||
|
||||
if (this.stateFileUpdated || (this.updatedStateTime == undefined)) {
|
||||
this.updatedStateTime = this.updatedTime;
|
||||
|
||||
this.vboxJob = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('vbox_job')[0].childNodes[0].nodeValue);
|
||||
this.webAPIPort = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('webapi_port')[0].childNodes[0].nodeValue);
|
||||
this.remoteDesktopPort = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('remote_desktop_port')[0].childNodes[0].nodeValue);
|
||||
|
||||
xmlInitDataDoc = this.sendRequest('/api/getInitData');
|
||||
this.userName = xmlInitDataDoc.getElementsByTagName('user_name')[0].childNodes[0].nodeValue;
|
||||
this.wuName = xmlInitDataDoc.getElementsByTagName('wu_name')[0].childNodes[0].nodeValue;
|
||||
this.resultName = xmlInitDataDoc.getElementsByTagName('result_name')[0].childNodes[0].nodeValue;
|
||||
this.authenticator = xmlInitDataDoc.getElementsByTagName('authenticator')[0].childNodes[0].nodeValue;
|
||||
this.userCreditTotal = parseFloat(xmlInitDataDoc.getElementsByTagName('user_total_credit')[0].childNodes[0].nodeValue);
|
||||
this.userCreditAverage = parseFloat(xmlInitDataDoc.getElementsByTagName('user_expavg_credit')[0].childNodes[0].nodeValue);
|
||||
this.hostCreditTotal = parseFloat(xmlInitDataDoc.getElementsByTagName('host_total_credit')[0].childNodes[0].nodeValue);
|
||||
this.hostCreditAverage = parseFloat(xmlInitDataDoc.getElementsByTagName('host_expavg_credit')[0].childNodes[0].nodeValue);
|
||||
|
||||
// Optional elements
|
||||
//
|
||||
try {
|
||||
this.teamName = xmlInitDataDoc.getElementsByTagName('team_name')[0].childNodes[0].nodeValue;
|
||||
} catch (e) {
|
||||
this.teamName = '';
|
||||
}
|
||||
try {
|
||||
this.userId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('userid')[0].childNodes[0].nodeValue);
|
||||
} catch (e) {
|
||||
this.userId = 0;
|
||||
}
|
||||
try {
|
||||
this.teamId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('teamid')[0].childNodes[0].nodeValue);
|
||||
} catch (e) {
|
||||
this.teamId = 0;
|
||||
}
|
||||
try {
|
||||
this.hostId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('hostid')[0].childNodes[0].nodeValue);
|
||||
} catch (e) {
|
||||
this.hostId = 0;
|
||||
}
|
||||
|
||||
this.sendRequest('/api/resetReadFlag');
|
||||
}
|
||||
}
|
||||
|
||||
BOINC.prototype.getUpdatedTime = function () {
|
||||
return this.updatedTime;
|
||||
}
|
||||
|
||||
BOINC.prototype.getUpdatedStateTime = function () {
|
||||
return this.updatedStateTime;
|
||||
}
|
||||
|
||||
BOINC.prototype.getUserName = function () {
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
BOINC.prototype.getTeamName = function () {
|
||||
return this.teamName;
|
||||
}
|
||||
|
||||
BOINC.prototype.getWorkunitName = function () {
|
||||
return this.wuName;
|
||||
}
|
||||
|
||||
BOINC.prototype.getResultName = function () {
|
||||
return this.resultName;
|
||||
}
|
||||
|
||||
BOINC.prototype.getAuthenticator = function () {
|
||||
return this.authenticator;
|
||||
}
|
||||
|
||||
BOINC.prototype.getUserId = function () {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
BOINC.prototype.getTeamId = function () {
|
||||
return this.teamId;
|
||||
}
|
||||
|
||||
BOINC.prototype.getHostId = function () {
|
||||
return this.hostId;
|
||||
}
|
||||
|
||||
BOINC.prototype.getUserCreditTotal = function () {
|
||||
return this.userCreditTotal;
|
||||
}
|
||||
|
||||
BOINC.prototype.getUserCreditAverage = function () {
|
||||
return this.userCreditAverage;
|
||||
}
|
||||
|
||||
BOINC.prototype.getHostCreditTotal = function () {
|
||||
return this.hostCreditTotal;
|
||||
}
|
||||
|
||||
BOINC.prototype.getHostCreditAverage = function () {
|
||||
return this.hostCreditAverage;
|
||||
}
|
||||
|
||||
BOINC.prototype.isExiting = function () {
|
||||
return this.exit;
|
||||
}
|
||||
|
||||
BOINC.prototype.getExitTimeout = function () {
|
||||
return this.exit_timeout;
|
||||
}
|
||||
|
||||
BOINC.prototype.isVrtualBoxJob = function () {
|
||||
return this.vboxJob;
|
||||
}
|
||||
|
||||
BOINC.prototype.getWebAPIPort = function () {
|
||||
return this.webAPIPort;
|
||||
}
|
||||
|
||||
BOINC.prototype.getRemoteDesktopPort = function () {
|
||||
return this.remoteDesktopPort;
|
||||
}
|
||||
|
||||
BOINC.prototype.getFractionDone = function () {
|
||||
return this.fractionDone;
|
||||
}
|
||||
|
||||
BOINC.prototype.getElapsedTime = function () {
|
||||
return this.elapsedTime;
|
||||
}
|
||||
|
||||
BOINC.prototype.getCPUTime = function () {
|
||||
return this.cpuTime;
|
||||
}
|
||||
|
||||
BOINC.prototype.isSuspended = function () {
|
||||
return this.suspended;
|
||||
}
|
||||
|
||||
BOINC.prototype.isNetworkSuspended = function () {
|
||||
return this.networkSuspended;
|
||||
}
|
||||
|
||||
BOINC.prototype.isAbortRequested = function () {
|
||||
return this.abortRequested;
|
||||
}
|
||||
|
||||
BOINC.prototype.isQuitRequested = function () {
|
||||
return this.quitRequested;
|
||||
}
|
||||
|
||||
BOINC.prototype.isStateFileUpdated = function () {
|
||||
return this.stateFileUpdated;
|
||||
}
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
@ -0,0 +1,140 @@
|
|||
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type='text/javascript' src='boinc.js'></script>
|
||||
</head>
|
||||
<body style='background-color: Black; overflow: hidden'>
|
||||
<div id='content' style='position: absolute'>
|
||||
<table>
|
||||
<tr>
|
||||
<td style='vertical-align: middle'>
|
||||
<img alt='' src='boinc.png' />
|
||||
</td>
|
||||
<td style='vertical-align: top; width: 250px'>
|
||||
<div id='username_container' style='visibility: hidden; color: White'></div>
|
||||
<div id='teamname_container' style='visibility: hidden; color: White'></div>
|
||||
<div id='workunitname_container' style='visibility: hidden; color: White'></div>
|
||||
<div id='progressbar_container' style='visibility: hidden; border: 1px Solid White; width: 245px; height: 23px'>
|
||||
<div id='progressbar_text' style='z-index: 1; position: absolute; color: White; text-align: center; vertical-align: middle; height: 21px; width: 245px'></div>
|
||||
<div id='progressbar' style='z-index: 0; position: absolute; height: 21px; width: 0px; background-color: Blue;'></div>
|
||||
</div>
|
||||
<div id='message_container' style='text-align: center; color: White'>Initializing...</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<script type='text/javascript'>
|
||||
var interval;
|
||||
var step = 5;
|
||||
var delay = 1000;
|
||||
var height = 0;
|
||||
var Hoffset = 0;
|
||||
var Woffset = 0;
|
||||
var yon = 0;
|
||||
var xon = 0;
|
||||
var xPos = 0;
|
||||
var yPos = 0;
|
||||
var boinc = new BOINC();
|
||||
|
||||
function refresh() {
|
||||
boinc.poll();
|
||||
console.log('this is a test');
|
||||
|
||||
var message = '';
|
||||
|
||||
if (boinc.getUserName().length != 0) {
|
||||
document.getElementById('username_container').innerHTML = boinc.getUserName();
|
||||
}
|
||||
if (boinc.getTeamName().length != 0) {
|
||||
document.getElementById('teamname_container').innerHTML = boinc.getTeamName();
|
||||
}
|
||||
if (boinc.getWorkunitName().length != 0) {
|
||||
document.getElementById('workunitname_container').innerHTML = boinc.getWorkunitName();
|
||||
}
|
||||
|
||||
document.getElementById('progressbar').style.width =
|
||||
String(Math.floor(parseInt(document.getElementById('progressbar_container').style.width) * boinc.getFractionDone()) + 'px');
|
||||
document.getElementById('progressbar_text').innerHTML =
|
||||
String(Math.floor(100 * boinc.getFractionDone()) + ' %');
|
||||
|
||||
if (boinc.isSuspended()) {
|
||||
message = 'Task is suspended.';
|
||||
} else if (boinc.isNetworkSuspended()) {
|
||||
message = 'Network is suspended.';
|
||||
} else if (boinc.isExiting()) {
|
||||
message = 'Exiting in ' + boinc.getExitTimeout() + ' seconds';
|
||||
}
|
||||
|
||||
if ((document.getElementById('username_container').innerHTML.length == 0) || boinc.isExiting()) {
|
||||
document.getElementById('username_container').style.visibility = 'hidden';
|
||||
document.getElementById('teamname_container').style.visibility = 'hidden';
|
||||
document.getElementById('workunitname_container').style.visibility = 'hidden';
|
||||
document.getElementById('progressbar_container').style.visibility = 'hidden';
|
||||
document.getElementById('message_container').style.visibility = 'visible';
|
||||
} else {
|
||||
document.getElementById('username_container').style.visibility = 'visible';
|
||||
document.getElementById('teamname_container').style.visibility = 'visible';
|
||||
document.getElementById('workunitname_container').style.visibility = 'visible';
|
||||
document.getElementById('progressbar_container').style.visibility = 'visible';
|
||||
document.getElementById('message_container').style.visibility = 'hidden';
|
||||
if (message.length > 0) {
|
||||
document.getElementById('message_container').innerHTML = message;
|
||||
document.getElementById('message_container').style.textAlign = 'left';
|
||||
document.getElementById('message_container').style.visibility = 'visible';
|
||||
} else {
|
||||
document.getElementById('message_container').innerHTML = '';
|
||||
document.getElementById('message_container').style.visibility = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
update_positions();
|
||||
}
|
||||
|
||||
function update_positions() {
|
||||
if (navigator.appName == "Microsoft Internet Explorer") {
|
||||
width = document.body.clientWidth;
|
||||
height = document.body.clientHeight;
|
||||
document.getElementById('content').style.left = xPos + document.body.scrollLeft;
|
||||
document.getElementById('content').style.top = yPos + document.body.scrollTop;
|
||||
} else {
|
||||
height = window.innerHeight;
|
||||
width = window.innerWidth;
|
||||
document.getElementById('content').style.top = yPos + window.pageYOffset;
|
||||
document.getElementById('content').style.left = xPos + window.pageXOffset;
|
||||
}
|
||||
Hoffset = document.getElementById('content').offsetHeight;
|
||||
Woffset = document.getElementById('content').offsetWidth;
|
||||
|
||||
if (yon) {
|
||||
yPos = yPos + step;
|
||||
} else {
|
||||
yPos = yPos - step;
|
||||
}
|
||||
if (yPos < 0) {
|
||||
yon = 1;
|
||||
yPos = 0;
|
||||
}
|
||||
if (yPos >= (height - Hoffset)) {
|
||||
yon = 0;
|
||||
yPos = (height - Hoffset);
|
||||
}
|
||||
if (xon) {
|
||||
xPos = xPos + step;
|
||||
} else {
|
||||
xPos = xPos - step;
|
||||
}
|
||||
if (xPos < 0) {
|
||||
xon = 1;
|
||||
xPos = 0;
|
||||
}
|
||||
if (xPos >= (width - Woffset)) {
|
||||
xon = 0;
|
||||
xPos = (width - Woffset);
|
||||
}
|
||||
}
|
||||
|
||||
interval = setInterval('refresh()', delay);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -41,7 +41,7 @@
|
|||
#define REMOTEDESKTOP_FILENAME "vbox_remote_desktop.xml"
|
||||
|
||||
|
||||
bool is_vboxwrapper_job() {
|
||||
bool is_vbox_job() {
|
||||
return 1 == boinc_file_exists(CHECKPOINT_FILENAME);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef _VBOXWRAPPER_H_
|
||||
#define _VBOXWRAPPER_H_
|
||||
|
||||
bool is_vboxwrapper_job();
|
||||
bool is_vbox_job();
|
||||
int parse_vbox_remote_desktop_port(int& remote_desktop_port);
|
||||
int parse_vbox_webapi_port(int& webapi_port);
|
||||
|
||||
|
|
|
@ -31,49 +31,298 @@
|
|||
|
||||
#include "parse.h"
|
||||
#include "filesys.h"
|
||||
#include "boinc_api.h"
|
||||
#include "app_ipc.h"
|
||||
#include "util.h"
|
||||
#include "boinc_api.h"
|
||||
#include "graphics2.h"
|
||||
#include "browserlog.h"
|
||||
#include "mongoose.h"
|
||||
#include "webapi.h"
|
||||
#include "vboxwrapper.h"
|
||||
#include "graphics.h"
|
||||
#include "webserver.h"
|
||||
#include "webapi.h"
|
||||
|
||||
|
||||
static const char *webapi_header =
|
||||
"Cache-Control: max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n";
|
||||
bool g_bWebServerInitialized = false;
|
||||
int g_iWebServerPort;
|
||||
bool g_bFullScreenMode;
|
||||
bool g_bExit;
|
||||
double g_dExitTimeout;
|
||||
bool g_bVboxJob;
|
||||
long g_lRemoteDesktopPort;
|
||||
long g_lWebAPIPort;
|
||||
APP_INIT_DATA g_aid;
|
||||
BOINC_STATUS g_status;
|
||||
double g_dUpdateTime;
|
||||
double g_dCPUTime;
|
||||
double g_dElapsedTime;
|
||||
double g_dFractionDone;
|
||||
std::string g_strDefaultURL;
|
||||
std::string g_strRunningURL;
|
||||
std::string g_strSuspendedURL;
|
||||
std::string g_strNetworkSuspendedURL;
|
||||
std::string g_strExitingURL;
|
||||
|
||||
|
||||
void handle_get_init_data(struct mg_connection *conn) {
|
||||
mg_send_file(
|
||||
conn,
|
||||
"init_data.xml",
|
||||
webapi_header
|
||||
void set_webserver_port(int port) {
|
||||
g_iWebServerPort = port;
|
||||
}
|
||||
|
||||
void set_fullscreen_mode(bool fullscreen) {
|
||||
g_bFullScreenMode = fullscreen;
|
||||
}
|
||||
|
||||
bool is_exiting() {
|
||||
return g_bExit;
|
||||
}
|
||||
|
||||
double get_exit_timeout() {
|
||||
return g_dExitTimeout;
|
||||
}
|
||||
|
||||
std::string normalize_url(std::string& url) {
|
||||
std::string normalized;
|
||||
char buf[256];
|
||||
|
||||
if (starts_with(url, "http://") || starts_with(url, "https://")) {
|
||||
normalized = url;
|
||||
} else {
|
||||
// Assume it is a local file
|
||||
_snprintf(buf, sizeof(buf), "http://localhost:%d/", g_iWebServerPort);
|
||||
normalized = buf;
|
||||
normalized += url;
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
int determine_state_url(std::string& url) {
|
||||
char buf[256];
|
||||
|
||||
// Start out with the default URL
|
||||
url = g_strDefaultURL;
|
||||
|
||||
// See if we need to override the default
|
||||
if ((g_status.abort_request || g_status.quit_request || g_status.no_heartbeat) && !g_strExitingURL.empty()) {
|
||||
url = g_strExitingURL;
|
||||
} else if (g_status.suspended && !g_strSuspendedURL.empty()) {
|
||||
url = g_strSuspendedURL;
|
||||
} else if (g_status.network_suspended && !g_strNetworkSuspendedURL.empty()) {
|
||||
url = g_strNetworkSuspendedURL;
|
||||
} else if (!g_strRunningURL.empty()) {
|
||||
url = g_strRunningURL;
|
||||
}
|
||||
|
||||
// Are we running a vbox job? If so, does it expose a webapi port number?
|
||||
if ((g_bVboxJob && g_lWebAPIPort) && (url.length() == 0)) {
|
||||
_snprintf(buf, sizeof(buf), "http://localhost:%d/", g_lWebAPIPort);
|
||||
url = buf;
|
||||
}
|
||||
|
||||
// If no other URL is selected, use the default HTML page embedded within the
|
||||
// executable
|
||||
if (url.size() == 0) {
|
||||
_snprintf(buf, sizeof(buf), "http://localhost:%d/api/static/index.html", g_iWebServerPort);
|
||||
url = buf;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void handle_poll_server() {
|
||||
int retval = 0;
|
||||
BOINC_STATUS status;
|
||||
std::string strDefaultURL;
|
||||
std::string strRunningURL;
|
||||
std::string strSuspendedURL;
|
||||
std::string strNetworkSuspendedURL;
|
||||
std::string strExitingURL;
|
||||
int temp = 0;
|
||||
|
||||
|
||||
retval = boinc_parse_graphics_status(
|
||||
&g_dUpdateTime,
|
||||
&g_dCPUTime,
|
||||
&g_dElapsedTime,
|
||||
&g_dFractionDone,
|
||||
&status
|
||||
);
|
||||
if (!retval) {
|
||||
|
||||
g_bExit = g_status.abort_request || g_status.no_heartbeat || g_status.quit_request;
|
||||
if (g_bExit && ((dtime() - g_dUpdateTime) > 5.0)) {
|
||||
g_dExitTimeout = dtime() - g_dUpdateTime - 5;
|
||||
} else {
|
||||
g_dExitTimeout = 0.0;
|
||||
}
|
||||
|
||||
// Update status entries sans the reread_init_data_file entry.
|
||||
// Give the HTML Web App time to assimulate the new info
|
||||
g_status.abort_request = status.abort_request;
|
||||
g_status.no_heartbeat = status.no_heartbeat;
|
||||
g_status.quit_request = status.quit_request;
|
||||
g_status.suspended = status.suspended;
|
||||
g_status.network_suspended = status.network_suspended;
|
||||
|
||||
// Check to see if vboxwrapper has logged any Web API port info or
|
||||
// Remote Desktop port info
|
||||
//
|
||||
if (g_bVboxJob) {
|
||||
if (!g_lRemoteDesktopPort) {
|
||||
if (!parse_vbox_remote_desktop_port(temp)) {
|
||||
g_lRemoteDesktopPort = temp;
|
||||
browserlog_msg("Vboxwrapper remote desktop port assignment (%d).", g_lRemoteDesktopPort);
|
||||
}
|
||||
}
|
||||
if (!g_lWebAPIPort) {
|
||||
if (!parse_vbox_webapi_port(temp)) {
|
||||
g_lWebAPIPort = temp;
|
||||
browserlog_msg("Vboxwrapper web api port assignment (%d).", g_lWebAPIPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status.reread_init_data_file || !g_bWebServerInitialized)
|
||||
{
|
||||
g_bWebServerInitialized = true;
|
||||
|
||||
// Notify the HTML Web application of the possible change in preferences and other
|
||||
// init data.
|
||||
browserlog_msg("Preference change detected.");
|
||||
g_status.reread_init_data_file = 1;
|
||||
g_status.max_working_set_size = 0.0;
|
||||
g_status.working_set_size = 0.0;
|
||||
|
||||
// Get updated state
|
||||
//
|
||||
if (g_aid.project_preferences) {
|
||||
delete g_aid.project_preferences;
|
||||
g_aid.project_preferences = NULL;
|
||||
}
|
||||
boinc_parse_init_data_file();
|
||||
boinc_get_init_data(g_aid);
|
||||
|
||||
// Check for vboxwrapper state
|
||||
//
|
||||
if (is_vbox_job())
|
||||
{
|
||||
g_bVboxJob = true;
|
||||
browserlog_msg("Vboxwrapper task detected.");
|
||||
}
|
||||
|
||||
// Check for project configured state urls
|
||||
//
|
||||
if (!parse_graphics(strDefaultURL, strRunningURL, strSuspendedURL, strNetworkSuspendedURL, strExitingURL))
|
||||
{
|
||||
if (strDefaultURL.size())
|
||||
{
|
||||
g_strDefaultURL = normalize_url(strDefaultURL);
|
||||
browserlog_msg("Configured default_url: '%s'.", strDefaultURL.c_str());
|
||||
}
|
||||
if (strRunningURL.size())
|
||||
{
|
||||
g_strRunningURL = normalize_url(strRunningURL);
|
||||
browserlog_msg("Configured running_url: '%s'.", strRunningURL.c_str());
|
||||
}
|
||||
if (strSuspendedURL.size())
|
||||
{
|
||||
g_strSuspendedURL = normalize_url(strSuspendedURL);
|
||||
browserlog_msg("Configured suspended_url: '%s'.", strSuspendedURL.c_str());
|
||||
}
|
||||
if (strNetworkSuspendedURL.size())
|
||||
{
|
||||
g_strNetworkSuspendedURL = normalize_url(strNetworkSuspendedURL);
|
||||
browserlog_msg("Configured network_suspended_url: '%s'.", strNetworkSuspendedURL.c_str());
|
||||
}
|
||||
if (strExitingURL.size())
|
||||
{
|
||||
g_strExitingURL = normalize_url(strExitingURL);
|
||||
browserlog_msg("Configured exiting_url: '%s'.", strExitingURL.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handle_get_graphics_status(struct mg_connection *conn) {
|
||||
mg_send_file(
|
||||
|
||||
//
|
||||
// Web Server Restful APIs
|
||||
//
|
||||
|
||||
int handle_get_init_data(struct mg_connection *conn) {
|
||||
std::string contents;
|
||||
read_file_string("init_data.xml", contents);
|
||||
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "text/xml");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_printf_data(conn, "%s", contents.c_str());
|
||||
return MG_TRUE;
|
||||
}
|
||||
|
||||
int handle_get_graphics_status(struct mg_connection *conn) {
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "text/xml");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_printf_data(
|
||||
conn,
|
||||
"graphics_status.xml",
|
||||
webapi_header
|
||||
"<graphics_status>\n"
|
||||
" <updated_time>%f</updated_time>\n"
|
||||
" <cpu_time>%f</cpu_time>\n"
|
||||
" <elapsed_time>%f</elapsed_time>\n"
|
||||
" <fraction_done>%f</fraction_done>\n"
|
||||
" <no_heartbeat>%d</no_heartbeat>\n"
|
||||
" <suspended>%d</suspended>\n"
|
||||
" <quit_request>%d</quit_request>\n"
|
||||
" <abort_request>%d</abort_request>\n"
|
||||
" <network_suspended>%d</network_suspended>\n"
|
||||
" <reread_init_data_file>%d</reread_init_data_file>\n"
|
||||
" <exit>%d</exit>\n"
|
||||
" <exit_timeout>%f</exit_timeout>\n"
|
||||
" <vbox_job>%d</vbox_job>\n"
|
||||
" <webapi_port>%d</webapi_port>\n"
|
||||
" <remote_desktop_port>%d</remote_desktop_port>\n"
|
||||
"</graphics_status>\n",
|
||||
g_dUpdateTime,
|
||||
g_dCPUTime,
|
||||
g_dElapsedTime,
|
||||
g_dFractionDone,
|
||||
g_status.no_heartbeat,
|
||||
g_status.suspended,
|
||||
g_status.quit_request,
|
||||
g_status.abort_request,
|
||||
g_status.network_suspended,
|
||||
g_status.reread_init_data_file,
|
||||
g_bExit,
|
||||
g_dExitTimeout,
|
||||
g_bVboxJob ? 1 : 0,
|
||||
g_lWebAPIPort,
|
||||
g_lRemoteDesktopPort
|
||||
);
|
||||
return MG_TRUE;
|
||||
}
|
||||
|
||||
void handle_log_message(struct mg_connection *conn) {
|
||||
char level[64], message[1024];
|
||||
mg_get_var(conn, "level", level, sizeof(level));
|
||||
mg_get_var(conn, "message", message, sizeof(message));
|
||||
browserlog_msg("Console: (%s) %s\n", level, message);
|
||||
int handle_reset_read_flag(struct mg_connection *conn) {
|
||||
g_status.reread_init_data_file = 0;
|
||||
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "text/xml");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_printf_data(conn, "<success/>\n");
|
||||
return MG_TRUE;
|
||||
}
|
||||
|
||||
void handle_filesystem_request(struct mg_connection *conn) {
|
||||
int handle_filesystem_request(struct mg_connection *conn) {
|
||||
std::string uri;
|
||||
boinc_resolve_filename_s(conn->uri+1, uri);
|
||||
mg_send_file(
|
||||
conn,
|
||||
uri.c_str(),
|
||||
webapi_header
|
||||
"Cache-Control: max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n"
|
||||
);
|
||||
return MG_MORE;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,18 @@
|
|||
#ifndef _WEBAPI_H_
|
||||
#define _WEBAPI_H_
|
||||
|
||||
void handle_get_init_data(struct mg_connection *conn);
|
||||
void handle_get_graphics_status(struct mg_connection *conn);
|
||||
void handle_log_message(struct mg_connection *conn);
|
||||
void handle_filesystem_request(struct mg_connection *conn);
|
||||
void set_webserver_port(int port);
|
||||
void set_fullscreen_mode(bool fullscreen);
|
||||
|
||||
bool is_exiting();
|
||||
double get_exit_timeout();
|
||||
int determine_state_url(std::string& url);
|
||||
|
||||
void handle_poll_server();
|
||||
|
||||
int handle_get_init_data(struct mg_connection *conn);
|
||||
int handle_get_graphics_status(struct mg_connection *conn);
|
||||
int handle_reset_read_flag(struct mg_connection *conn);
|
||||
int handle_filesystem_request(struct mg_connection *conn);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,230 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "boinc_win.h"
|
||||
#include "win_util.h"
|
||||
#else
|
||||
#include <vector>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "browserlog.h"
|
||||
#include "mongoose.h"
|
||||
#include "webstatic.h"
|
||||
|
||||
|
||||
static const char* boinc_js =
|
||||
"var BOINC = function () {"
|
||||
" var updatedTime; var updatedStateTime; var userName; var teamName; var wuName; var resultName;"
|
||||
" var authenticator; var userId; var teamId; var hostId; var userCreditTotal; var userCreditAverage;"
|
||||
" var hostCreditTotal; var hostCreditAverage; var exit; var exit_timeout; var vboxJob; var webAPIPort;"
|
||||
" var remoteDesktopPort; var elapsedTime; var cpuTime; var fractionDone; var suspended;"
|
||||
" var networkSuspended; var abortRequested; var quitRequested; var stateFileUpdated;"
|
||||
" this.poll();"
|
||||
"};"
|
||||
""
|
||||
"BOINC.prototype.createRequest = function () {"
|
||||
" var xmlHttp = null;"
|
||||
" var XMLHttpFactories = ["
|
||||
" function () { return new XMLHttpRequest() },"
|
||||
" function () { return new ActiveXObject('Msxml2.XMLHTTP') },"
|
||||
" function () { return new ActiveXObject('Msxml3.XMLHTTP') },"
|
||||
" function () { return new ActiveXObject('Microsoft.XMLHTTP') }"
|
||||
" ];"
|
||||
" for (var i = 0; i < XMLHttpFactories.length; i++) {"
|
||||
" try {"
|
||||
" xmlHttp = XMLHttpFactories[i]();"
|
||||
" } catch (e) {"
|
||||
" continue;"
|
||||
" }"
|
||||
" break;"
|
||||
" }"
|
||||
" return xmlHttp;"
|
||||
"};"
|
||||
""
|
||||
"BOINC.prototype.sendRequest = function (url) {"
|
||||
" var req = this.createRequest();"
|
||||
" var response = null;"
|
||||
" req.open('GET', url, false);"
|
||||
" req.send();"
|
||||
" response = req.responseXML;"
|
||||
" req = null;"
|
||||
" return response;"
|
||||
"};"
|
||||
""
|
||||
"BOINC.prototype.poll = function () {"
|
||||
" var xmlGraphicsStatusDoc;"
|
||||
" var xmlInitDataDoc;"
|
||||
""
|
||||
" xmlGraphicsStatusDoc = this.sendRequest('/api/getGraphicsStatus');"
|
||||
" this.updatedTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('updated_time')[0].childNodes[0].nodeValue);"
|
||||
" this.fractionDone = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('fraction_done')[0].childNodes[0].nodeValue);"
|
||||
" this.elapsedTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('elapsed_time')[0].childNodes[0].nodeValue);"
|
||||
" this.cpuTime = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('cpu_time')[0].childNodes[0].nodeValue);"
|
||||
" this.suspended = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('suspended')[0].childNodes[0].nodeValue);"
|
||||
" this.networkSuspended = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('network_suspended')[0].childNodes[0].nodeValue);"
|
||||
" this.abortRequested = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('abort_request')[0].childNodes[0].nodeValue);"
|
||||
" this.quitRequested = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('quit_request')[0].childNodes[0].nodeValue);"
|
||||
" this.stateFileUpdated = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('reread_init_data_file')[0].childNodes[0].nodeValue);"
|
||||
" this.exit = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('suspended')[0].childNodes[0].nodeValue);"
|
||||
" this.exit_timeout = parseFloat(xmlGraphicsStatusDoc.getElementsByTagName('cpu_time')[0].childNodes[0].nodeValue);"
|
||||
""
|
||||
" if (this.stateFileUpdated || (this.updatedStateTime == undefined)) {"
|
||||
" this.updatedStateTime = this.updatedTime;"
|
||||
""
|
||||
" this.vboxJob = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('vbox_job')[0].childNodes[0].nodeValue);"
|
||||
" this.webAPIPort = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('webapi_port')[0].childNodes[0].nodeValue);"
|
||||
" this.remoteDesktopPort = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('remote_desktop_port')[0].childNodes[0].nodeValue);"
|
||||
""
|
||||
" xmlInitDataDoc = this.sendRequest('/api/getInitData');"
|
||||
" this.userName = xmlInitDataDoc.getElementsByTagName('user_name')[0].childNodes[0].nodeValue;"
|
||||
" this.wuName = xmlInitDataDoc.getElementsByTagName('wu_name')[0].childNodes[0].nodeValue;"
|
||||
" this.resultName = xmlInitDataDoc.getElementsByTagName('result_name')[0].childNodes[0].nodeValue;"
|
||||
" this.authenticator = xmlInitDataDoc.getElementsByTagName('authenticator')[0].childNodes[0].nodeValue;"
|
||||
" this.userCreditTotal = parseFloat(xmlInitDataDoc.getElementsByTagName('user_total_credit')[0].childNodes[0].nodeValue);"
|
||||
" this.userCreditAverage = parseFloat(xmlInitDataDoc.getElementsByTagName('user_expavg_credit')[0].childNodes[0].nodeValue);"
|
||||
" this.hostCreditTotal = parseFloat(xmlInitDataDoc.getElementsByTagName('host_total_credit')[0].childNodes[0].nodeValue);"
|
||||
" this.hostCreditAverage = parseFloat(xmlInitDataDoc.getElementsByTagName('host_expavg_credit')[0].childNodes[0].nodeValue);"
|
||||
""
|
||||
" try {"
|
||||
" this.teamName = xmlInitDataDoc.getElementsByTagName('team_name')[0].childNodes[0].nodeValue;"
|
||||
" } catch (e) {"
|
||||
" this.teamName = '';"
|
||||
" }"
|
||||
" try {"
|
||||
" this.userId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('userid')[0].childNodes[0].nodeValue);"
|
||||
" } catch (e) {"
|
||||
" this.userId = 0;"
|
||||
" }"
|
||||
" try {"
|
||||
" this.teamId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('teamid')[0].childNodes[0].nodeValue);"
|
||||
" } catch (e) {"
|
||||
" this.teamId = 0;"
|
||||
" }"
|
||||
" try {"
|
||||
" this.hostId = parseInt(xmlGraphicsStatusDoc.getElementsByTagName('hostid')[0].childNodes[0].nodeValue);"
|
||||
" } catch (e) {"
|
||||
" this.hostId = 0;"
|
||||
" }"
|
||||
""
|
||||
" this.sendRequest('/api/resetReadFlag');"
|
||||
" }"
|
||||
"};"
|
||||
""
|
||||
"BOINC.prototype.getUpdatedTime = function () {"
|
||||
" return this.updatedTime;"
|
||||
"};"
|
||||
"BOINC.prototype.getUpdatedStateTime = function () {"
|
||||
" return this.updatedStateTime;"
|
||||
"};"
|
||||
"BOINC.prototype.getUserName = function () {"
|
||||
" return this.userName;"
|
||||
"};"
|
||||
"BOINC.prototype.getTeamName = function () {"
|
||||
" return this.teamName;"
|
||||
"};"
|
||||
"BOINC.prototype.getWorkunitName = function () {"
|
||||
" return this.wuName;"
|
||||
"};"
|
||||
"BOINC.prototype.getResultName = function () {"
|
||||
" return this.resultName;"
|
||||
"};"
|
||||
"BOINC.prototype.getAuthenticator = function () {"
|
||||
" return this.authenticator;"
|
||||
"};"
|
||||
"BOINC.prototype.getUserId = function () {"
|
||||
" return this.userId;"
|
||||
"};"
|
||||
"BOINC.prototype.getTeamId = function () {"
|
||||
" return this.teamId;"
|
||||
"};"
|
||||
"BOINC.prototype.getHostId = function () {"
|
||||
" return this.hostId;"
|
||||
"};"
|
||||
"BOINC.prototype.getUserCreditTotal = function () {"
|
||||
" return this.userCreditTotal;"
|
||||
"};"
|
||||
"BOINC.prototype.getUserCreditAverage = function () {"
|
||||
" return this.userCreditAverage;"
|
||||
"};"
|
||||
"BOINC.prototype.getHostCreditTotal = function () {"
|
||||
" return this.hostCreditTotal;"
|
||||
"};"
|
||||
"BOINC.prototype.getHostCreditAverage = function () {"
|
||||
" return this.hostCreditAverage;"
|
||||
"};"
|
||||
"BOINC.prototype.isExiting = function () {"
|
||||
" return this.exit;"
|
||||
"};"
|
||||
"BOINC.prototype.getExitTimeout = function () {"
|
||||
" return this.exit_timeout;"
|
||||
"};"
|
||||
"BOINC.prototype.isVrtualBoxJob = function () {"
|
||||
" return this.vboxJob;"
|
||||
"};"
|
||||
"BOINC.prototype.getWebAPIPort = function () {"
|
||||
" return this.webAPIPort;"
|
||||
"};"
|
||||
"BOINC.prototype.getRemoteDesktopPort = function () {"
|
||||
" return this.remoteDesktopPort;"
|
||||
"};"
|
||||
"BOINC.prototype.getFractionDone = function () {"
|
||||
" return this.fractionDone;"
|
||||
"};"
|
||||
"BOINC.prototype.getElapsedTime = function () {"
|
||||
" return this.elapsedTime;"
|
||||
"};"
|
||||
"BOINC.prototype.getCPUTime = function () {"
|
||||
" return this.cpuTime;"
|
||||
"};"
|
||||
"BOINC.prototype.isSuspended = function () {"
|
||||
" return this.suspended;"
|
||||
"};"
|
||||
"BOINC.prototype.isNetworkSuspended = function () {"
|
||||
" return this.networkSuspended;"
|
||||
"};"
|
||||
"BOINC.prototype.isAbortRequested = function () {"
|
||||
" return this.abortRequested;"
|
||||
"};"
|
||||
"BOINC.prototype.isQuitRequested = function () {"
|
||||
" return this.quitRequested;"
|
||||
"};"
|
||||
"BOINC.prototype.isStateFileUpdated = function () {"
|
||||
" return this.stateFileUpdated;"
|
||||
"};";
|
||||
|
||||
|
||||
int handle_static_boinc_js(struct mg_connection *conn) {
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "text/javascript");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_printf_data(
|
||||
conn,
|
||||
"%s",
|
||||
boinc_js
|
||||
);
|
||||
return MG_TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "boinc_win.h"
|
||||
#include "win_util.h"
|
||||
#else
|
||||
#include <vector>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "base64.h"
|
||||
#include "browserlog.h"
|
||||
#include "mongoose.h"
|
||||
#include "webstatic.h"
|
||||
|
||||
|
||||
static const char* boinc_png =
|
||||
"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"
|
||||
"ugAAAABJRU5ErkJggg==";
|
||||
|
||||
|
||||
int handle_static_boinc_png(struct mg_connection *conn) {
|
||||
std::string image;
|
||||
image = r_base64_decode(boinc_png, strlen(boinc_png));
|
||||
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "image/png");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_send_data(
|
||||
conn,
|
||||
image.c_str(),
|
||||
image.size()
|
||||
);
|
||||
return MG_TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "boinc_win.h"
|
||||
#include "win_util.h"
|
||||
#else
|
||||
#include <vector>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "browserlog.h"
|
||||
#include "mongoose.h"
|
||||
#include "webstatic.h"
|
||||
|
||||
|
||||
static const char* index_html =
|
||||
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>"
|
||||
"<html>"
|
||||
"<head>"
|
||||
" <title></title>"
|
||||
" <script type='text/javascript' src='boinc.js'></script>"
|
||||
"</head>"
|
||||
"<body style='background-color: Black; overflow: hidden'>"
|
||||
" <div id='content' style='position: absolute'>"
|
||||
" <table>"
|
||||
" <tr>"
|
||||
" <td style='vertical-align: middle'>"
|
||||
" <img alt='' src='boinc.png' />"
|
||||
" </td>"
|
||||
" <td style='vertical-align: top; width: 250px'>"
|
||||
" <div id='username_container' style='visibility: hidden; color: White'></div>"
|
||||
" <div id='teamname_container' style='visibility: hidden; color: White'></div>"
|
||||
" <div id='workunitname_container' style='visibility: hidden; color: White'></div>"
|
||||
" <div id='progressbar_container' style='visibility: hidden; border: 1px Solid White; width: 245px; height: 23px'>"
|
||||
" <div id='progressbar_text' style='z-index: 1; position: absolute; color: White; text-align: center; vertical-align: middle; height: 21px; width: 245px'></div>"
|
||||
" <div id='progressbar' style='z-index: 0; position: absolute; height: 21px; width: 0px; background-color: Blue;'></div>"
|
||||
" </div>"
|
||||
" <div id='message_container' style='text-align: center; color: White'>Initializing...</div>"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" </table>"
|
||||
" </div>"
|
||||
" <script type='text/javascript'>"
|
||||
" var interval;"
|
||||
" var step = 5;"
|
||||
" var delay = 1000;"
|
||||
" var height = 0;"
|
||||
" var Hoffset = 0;"
|
||||
" var Woffset = 0;"
|
||||
" var yon = 0;"
|
||||
" var xon = 0;"
|
||||
" var xPos = 0;"
|
||||
" var yPos = 0;"
|
||||
" var boinc = new BOINC();"
|
||||
""
|
||||
" function refresh() {"
|
||||
" boinc.poll();"
|
||||
""
|
||||
" var message = '';"
|
||||
""
|
||||
" if (boinc.getUserName().length != 0) {"
|
||||
" document.getElementById('username_container').innerHTML = boinc.getUserName();"
|
||||
" }"
|
||||
" if (boinc.getTeamName().length != 0) {"
|
||||
" document.getElementById('teamname_container').innerHTML = boinc.getTeamName();"
|
||||
" }"
|
||||
" if (boinc.getWorkunitName().length != 0) {"
|
||||
" document.getElementById('workunitname_container').innerHTML = boinc.getWorkunitName();"
|
||||
" }"
|
||||
""
|
||||
" document.getElementById('progressbar').style.width = "
|
||||
" String(Math.floor(parseInt(document.getElementById('progressbar_container').style.width) * boinc.getFractionDone()) + 'px');"
|
||||
" document.getElementById('progressbar_text').innerHTML = "
|
||||
" String(Math.floor(100 * boinc.getFractionDone()) + ' %');"
|
||||
""
|
||||
" if (boinc.isSuspended()) {"
|
||||
" message = 'Task is suspended.';"
|
||||
" } else if (boinc.isNetworkSuspended()) {"
|
||||
" message = 'Network is suspended.';"
|
||||
" } else if (boinc.isExiting()) {"
|
||||
" message = 'Exiting in ' + boinc.getExitTimeout() + ' seconds';"
|
||||
" }"
|
||||
""
|
||||
" if ((document.getElementById('username_container').innerHTML.length == 0) || boinc.isExiting()) {"
|
||||
" document.getElementById('username_container').style.visibility = 'hidden';"
|
||||
" document.getElementById('teamname_container').style.visibility = 'hidden';"
|
||||
" document.getElementById('workunitname_container').style.visibility = 'hidden';"
|
||||
" document.getElementById('progressbar_container').style.visibility = 'hidden';"
|
||||
" document.getElementById('message_container').style.visibility = 'visible';"
|
||||
" } else {"
|
||||
" document.getElementById('username_container').style.visibility = 'visible';"
|
||||
" document.getElementById('teamname_container').style.visibility = 'visible';"
|
||||
" document.getElementById('workunitname_container').style.visibility = 'visible';"
|
||||
" document.getElementById('progressbar_container').style.visibility = 'visible';"
|
||||
" document.getElementById('message_container').style.visibility = 'hidden';"
|
||||
" if (message.length > 0) {"
|
||||
" document.getElementById('message_container').innerHTML = message;"
|
||||
" document.getElementById('message_container').style.textAlign = 'left';"
|
||||
" document.getElementById('message_container').style.visibility = 'visible';"
|
||||
" } else {"
|
||||
" document.getElementById('message_container').innerHTML = '';"
|
||||
" document.getElementById('message_container').style.visibility = 'hidden';"
|
||||
" }"
|
||||
" }"
|
||||
""
|
||||
" update_positions();"
|
||||
" }"
|
||||
""
|
||||
" function update_positions() {"
|
||||
" if (navigator.appName == 'Microsoft Internet Explorer') {"
|
||||
" width = document.body.clientWidth;"
|
||||
" height = document.body.clientHeight;"
|
||||
" document.getElementById('content').style.left = xPos + document.body.scrollLeft;"
|
||||
" document.getElementById('content').style.top = yPos + document.body.scrollTop;"
|
||||
" } else {"
|
||||
" height = window.innerHeight;"
|
||||
" width = window.innerWidth;"
|
||||
" document.getElementById('content').style.top = yPos + window.pageYOffset;"
|
||||
" document.getElementById('content').style.left = xPos + window.pageXOffset;"
|
||||
" }"
|
||||
" Hoffset = document.getElementById('content').offsetHeight;"
|
||||
" Woffset = document.getElementById('content').offsetWidth;"
|
||||
""
|
||||
" if (yon) {"
|
||||
" yPos = yPos + step;"
|
||||
" } else {"
|
||||
" yPos = yPos - step;"
|
||||
" }"
|
||||
" if (yPos < 0) {"
|
||||
" yon = 1;"
|
||||
" yPos = 0;"
|
||||
" }"
|
||||
" if (yPos >= (height - Hoffset)) {"
|
||||
" yon = 0;"
|
||||
" yPos = (height - Hoffset);"
|
||||
" }"
|
||||
" if (xon) {"
|
||||
" xPos = xPos + step;"
|
||||
" } else {"
|
||||
" xPos = xPos - step;"
|
||||
" }"
|
||||
" if (xPos < 0) {"
|
||||
" xon = 1;"
|
||||
" xPos = 0;"
|
||||
" }"
|
||||
" if (xPos >= (width - Woffset)) {"
|
||||
" xon = 0;"
|
||||
" xPos = (width - Woffset);"
|
||||
" }"
|
||||
" }"
|
||||
""
|
||||
" interval = setInterval('refresh()', delay);"
|
||||
" </script>"
|
||||
"</body>"
|
||||
"</html>";
|
||||
|
||||
|
||||
int handle_static_index_html(struct mg_connection *conn) {
|
||||
mg_send_status(conn, 200);
|
||||
mg_send_header(conn, "Content-Type", "text/html");
|
||||
mg_send_header(conn, "Cache-Control", "max-age=0, post-check=0, pre-check=0, no-store, no-cache, must-revalidate");
|
||||
mg_send_header(conn, "Access-Control-Allow-Origin", "*");
|
||||
mg_printf_data(
|
||||
conn,
|
||||
"%s",
|
||||
index_html
|
||||
);
|
||||
return MG_TRUE;
|
||||
}
|
|
@ -36,6 +36,7 @@
|
|||
#include "browserlog.h"
|
||||
#include "mongoose.h"
|
||||
#include "webapi.h"
|
||||
#include "webstatic.h"
|
||||
#include "webserver.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -49,29 +50,31 @@
|
|||
#define WEBSERVER_STATE_POLLING 2
|
||||
#define WEBSERVER_STATE_EXITING 3
|
||||
|
||||
static struct mg_server* webserver;
|
||||
static int webserver_state = WEBSERVER_STATE_UNINIT;
|
||||
static char webserver_listeningport[64];
|
||||
static char webserver_documentroot[64];
|
||||
static char webserver_domain[64];
|
||||
static bool webserver_debugging = false;
|
||||
struct mg_server* webserver;
|
||||
int webserver_state = WEBSERVER_STATE_UNINIT;
|
||||
char webserver_listening[64];
|
||||
char webserver_documentroot[64];
|
||||
char webserver_domain[64];
|
||||
bool webserver_debugging = false;
|
||||
|
||||
|
||||
static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
|
||||
switch (ev) {
|
||||
case MG_REQUEST:
|
||||
if (!strcmp(conn->uri, "/api/getInitData")) {
|
||||
handle_get_init_data(conn);
|
||||
return MG_TRUE;
|
||||
if (!strcmp(conn->uri, "/api/static/index.html")) {
|
||||
return handle_static_index_html(conn);
|
||||
} else if (!strcmp(conn->uri, "/api/static/boinc.js")) {
|
||||
return handle_static_boinc_js(conn);
|
||||
} else if (!strcmp(conn->uri, "/api/static/boinc.png")) {
|
||||
return handle_static_boinc_png(conn);
|
||||
} else if (!strcmp(conn->uri, "/api/getInitData")) {
|
||||
return handle_get_init_data(conn);
|
||||
} else if (!strcmp(conn->uri, "/api/getGraphicsStatus")) {
|
||||
handle_get_graphics_status(conn);
|
||||
return MG_TRUE;
|
||||
} else if (!strcmp(conn->uri, "/api/logMessage")) {
|
||||
handle_log_message(conn);
|
||||
return MG_TRUE;
|
||||
return handle_get_graphics_status(conn);
|
||||
} else if (!strcmp(conn->uri, "/api/resetReadFlag")) {
|
||||
return handle_reset_read_flag(conn);
|
||||
} else if (boinc_file_exists(conn->uri+1)) {
|
||||
handle_filesystem_request(conn);
|
||||
return MG_MORE;
|
||||
return handle_filesystem_request(conn);
|
||||
}
|
||||
return MG_FALSE;
|
||||
case MG_AUTH:
|
||||
|
@ -88,7 +91,7 @@ static int webserver_handler() {
|
|||
switch(webserver_state) {
|
||||
case WEBSERVER_STATE_INIT:
|
||||
webserver = mg_create_server(NULL, ev_handler);
|
||||
mg_set_option(webserver, "listening_port", webserver_listeningport);
|
||||
mg_set_option(webserver, "listening_port", webserver_listening);
|
||||
mg_set_option(webserver, "document_root", webserver_documentroot);
|
||||
mg_set_option(webserver, "enable_directory_listing", "no");
|
||||
mg_set_option(webserver, "index_files", "");
|
||||
|
@ -96,6 +99,7 @@ static int webserver_handler() {
|
|||
webserver_state = WEBSERVER_STATE_POLLING;
|
||||
break;
|
||||
case WEBSERVER_STATE_POLLING:
|
||||
handle_poll_server();
|
||||
mg_poll_server(webserver, 1000);
|
||||
break;
|
||||
case WEBSERVER_STATE_EXITING:
|
||||
|
@ -135,11 +139,14 @@ int start_webserver_thread() {
|
|||
}
|
||||
|
||||
|
||||
int webserver_initialize(int port, bool debugging) {
|
||||
int webserver_initialize(int port, bool fullscreen, bool debugging) {
|
||||
if (port <= 1024) return 1;
|
||||
|
||||
set_webserver_port(port);
|
||||
set_fullscreen_mode(fullscreen);
|
||||
|
||||
snprintf(
|
||||
webserver_listeningport, sizeof(webserver_listeningport)-1,
|
||||
webserver_listening, sizeof(webserver_listening)-1,
|
||||
"127.0.0.1:%d",
|
||||
port
|
||||
);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef _WEBSERVER_H_
|
||||
#define _WEBSERVER_H_
|
||||
|
||||
int webserver_initialize(int port, bool debugging);
|
||||
int webserver_initialize(int port, bool fullscreen, bool debugging);
|
||||
int webserver_destroy();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2014-2015 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _WEBSTATIC_H_
|
||||
#define _WEBSTATIC_H_
|
||||
|
||||
int handle_static_index_html(struct mg_connection *conn);
|
||||
int handle_static_boinc_png(struct mg_connection *conn);
|
||||
int handle_static_boinc_js(struct mg_connection *conn);
|
||||
|
||||
#endif
|
|
@ -300,7 +300,6 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\samples\gfx_html\browser.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\browserctrlui_win.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\browserctrl_win.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\browserlog.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\browsermain_win.cpp" />
|
||||
|
@ -314,11 +313,13 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="..\samples\gfx_html\vboxwrapper.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\webapi.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\webboincjs.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\webboincpng.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\webindexhtml.cpp" />
|
||||
<ClCompile Include="..\samples\gfx_html\webserver.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\samples\gfx_html\browser.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\browserctrlui_win.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\browserctrl_win.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\browserlog.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\browsermain_win.h" />
|
||||
|
@ -329,6 +330,7 @@
|
|||
<ClInclude Include="..\samples\gfx_html\vboxwrapper.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\webapi.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\webserver.h" />
|
||||
<ClInclude Include="..\samples\gfx_html\webstatic.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\samples\gfx_html\browser_win.rc" />
|
||||
|
@ -355,11 +357,6 @@
|
|||
<HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">browser_i.h</HeaderFileName>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\samples\gfx_html\res\boinc.js" />
|
||||
<None Include="..\samples\gfx_html\res\console.js" />
|
||||
<None Include="..\samples\gfx_html\res\index.html" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
|
Loading…
Reference in New Issue