Import civetweb ans jsoncpp
This commit is contained in:
119
3P/civetweb/testutils/Browser/Browser.cpp
Normal file
119
3P/civetweb/testutils/Browser/Browser.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
// To build the source, set your drive letter Q: to the Qt SDK root,
|
||||
// e.g., use "subst q: C:\QtSDK\Desktop\Qt\4.8.0\msvc2010" on the cmd line.
|
||||
// This minimal source is derived from http://trac.webkit.org/wiki/QtWebKitTiling,
|
||||
// for an example with more features see http://doc.qt.nokia.com/qt-maemo/maemo5-graphicswebview.html
|
||||
|
||||
|
||||
#include <QApplication.h>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsWebView>
|
||||
#include <QWebSettings>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
const char * DEFAULT_URL = "http://localhost/";
|
||||
const char * DEFAULT_SIZE = "550x720";
|
||||
const char * DEFAULT_PROXY = 0;
|
||||
|
||||
|
||||
static void ShowUsage(const char * exeName) {
|
||||
|
||||
const char * name = "";
|
||||
if (exeName) {
|
||||
name = strrchr(exeName, '\\');
|
||||
if (name) {
|
||||
name++;
|
||||
} else {
|
||||
name = exeName;
|
||||
}
|
||||
}
|
||||
|
||||
std::string msg = "Usage:\n";
|
||||
msg += " " + std::string(name) + " [-w###x###] [url]\n";
|
||||
msg += " " + std::string(name) + " -h\n\n";
|
||||
msg += "Use -w###x### to specify the window size\n";
|
||||
MessageBoxA(NULL, msg.c_str(), name, MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
|
||||
class BGraphicsWebView : public QGraphicsWebView {
|
||||
public:
|
||||
bool loadFinished(bool);
|
||||
};
|
||||
|
||||
|
||||
bool BGraphicsWebView::loadFinished(bool) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
const char * url = DEFAULT_URL;
|
||||
const char * size = DEFAULT_SIZE;
|
||||
const char * proxy = DEFAULT_PROXY;
|
||||
|
||||
for (int i = 1; i<argc; i++) {
|
||||
if (argv[i][0]=='/' || argv[i][0]=='-') {
|
||||
if (argv[i][1]=='h' || argv[i][1]=='H' || argv[i][1]=='?') {
|
||||
ShowUsage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
else if ((argv[i][1]=='w') || (argv[i][1]=='W')) {
|
||||
if ((argv[i][2]!=0) && (strchr(argv[1],'x')!=0) && (size==DEFAULT_SIZE)) {
|
||||
size = argv[i]+2;
|
||||
}
|
||||
}
|
||||
else if ((argv[i][1]=='p') || (argv[i][1]=='P')) {
|
||||
proxy = argv[i]+2;
|
||||
}
|
||||
else {
|
||||
ShowUsage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (url==DEFAULT_URL) {
|
||||
url = argv[i];
|
||||
} else {
|
||||
ShowUsage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QApplication app(argc, argv);
|
||||
if (proxy) {
|
||||
QUrl proxyUrl = proxy;
|
||||
QNetworkProxy netProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port());
|
||||
QNetworkProxy::setApplicationProxy(netProxy);
|
||||
}
|
||||
|
||||
QGraphicsScene scene;
|
||||
|
||||
QGraphicsView view(&scene);
|
||||
view.setFrameShape(QFrame::NoFrame);
|
||||
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
BGraphicsWebView webview;
|
||||
int width=0, height=0;
|
||||
if (2!=sscanf(size,"%ux%u", &width, &height)) {
|
||||
ShowUsage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
webview.resize(width, height);
|
||||
webview.load(QUrl(url));
|
||||
|
||||
scene.addItem(&webview);
|
||||
view.setFixedSize(width, height);
|
||||
view.show();
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
return ret;
|
||||
}
|
||||
90
3P/civetweb/testutils/Browser/Browser.vcxproj
Normal file
90
3P/civetweb/testutils/Browser/Browser.vcxproj
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{277772B0-D4B3-451E-86B6-261FBC645793}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Browser</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>Q:\include\QtGui\;Q:\include\;Q:\include\QtWebKit\;Q:\include\QtNetwork\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>qtmaind.lib;QtGuid4.lib;QtCored4.lib;QtWebKitd4.lib;QtNetworkd4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>Q:\lib</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>Q:\include\QtGui\;Q:\include\;Q:\include\QtWebKit\;Q:\include\QtNetwork\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>qtmain.lib;QtGui4.lib;QtCore4.lib;QtWebKit4.lib;QtNetwork4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>Q:\lib</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Browser.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user