// 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 .
#define _ATL_FREE_THREADED
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "win_util.h"
#include "version.h"
#include "boinc_api.h"
#include "diagnostics.h"
#include "filesys.h"
#include "browser_i.h"
#include "browser_i.c"
#include "browser_win.h"
#include "browserlog.h"
#include "browserctrl_win.h"
#include "browserwnd_win.h"
#include "browsermain_win.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
CBrowserModule::CBrowserModule()
{
m_pWnd = NULL;
m_bFullscreen = false;
}
HRESULT CBrowserModule::InitializeCom() throw()
{
return ::OleInitialize(NULL);
}
void CBrowserModule::UninitializeCom() throw()
{
::OleUninitialize();
}
HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
{
RECT rc = {0, 0, 0, 0};
DWORD dwExStyle = 0;
DWORD dwStyle = 0;
char szWindowTitle[256];
HRESULT hr = __super::PreMessageLoop(nShowCmd);
if (FAILED(hr)) {
return hr;
}
// Initialize ATL Window Classes
//
AtlAxWinInit();
// Prepare environment for detecting system conditions
//
boinc_parse_init_data_file();
// Create Window Container
//
m_pWnd = new CHTMLBrowserWnd();
if (m_pWnd == NULL)
{
__super::PostMessageLoop();
return E_OUTOFMEMORY;
}
// Store a copy of APP_INIT_DATA for future use
boinc_get_init_data(m_pWnd->aid);
// Construct the window caption
if (m_pWnd->aid.app_version) {
snprintf(
szWindowTitle, sizeof(szWindowTitle),
"%s version %.2f [workunit: %s]",
m_pWnd->aid.app_name, m_pWnd->aid.app_version/100.0, m_pWnd->aid.wu_name
);
} else {
snprintf(
szWindowTitle, sizeof(szWindowTitle),
"%s [workunit: %s]",
m_pWnd->aid.app_name, m_pWnd->aid.wu_name
);
}
// Determine window size and placement
if (m_bFullscreen) {
HDC dc = GetDC(NULL);
rc.left = 0;
rc.top = 0;
rc.right = GetDeviceCaps(dc, HORZRES);
rc.bottom = GetDeviceCaps(dc, VERTRES);
ReleaseDC(NULL, dc);
dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_POPUP;
dwExStyle = WS_EX_APPWINDOW|WS_EX_TOPMOST;
while(ShowCursor(false) >= 0);
} else {
rc.left = 0;
rc.top = 0;
rc.right = 800;
rc.bottom = 600;
dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW;
dwExStyle = WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
while(ShowCursor(true) < 0);
}
// Create Window
//
m_pWnd->Create(GetDesktopWindow(), rc, szWindowTitle, dwStyle, dwExStyle);
m_pWnd->ShowWindow(nShowCmd);
return S_OK;
}
HRESULT CBrowserModule::PostMessageLoop() throw()
{
if (m_pWnd)
{
delete m_pWnd;
m_pWnd = NULL;
}
AtlAxWinTerm();
return __super::PostMessageLoop();
}
int CBrowserModule::BOINCParseCommandLine(int argc, char** argv) {
for (int i=1; i