Sync DrDump crash handler with TortoiseSVN codebase
[TortoiseGit.git] / ext / CrashServer / CrashHandler / DumpUploaderServiceLib / DumpUploaderWebService.cpp
blob69fd76c2b5a0b85e1a55db5c2a2ac5a90e409b8a
1 // Copyright 2014 Idol Software, Inc.
2 //
3 // This file is part of Doctor Dump SDK.
4 //
5 // Doctor Dump SDK is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "DumpUploaderWebService.h"
19 #include "generated/CustomBinding_DumpUploadService3_Uploader.nsmap"
20 #include "gsoapWinInet.h"
21 #include <sstream>
22 #include <atlbase.h>
23 #include <atlstr.h>
25 DumpUploaderWebService::DumpUploaderWebService(int responseTimeoutSec)
26 : Base(SOAP_ENC_MTOM|SOAP_IO_KEEPALIVE|SOAP_C_UTFSTRING/*SOAP_C_MBSTRING*/)
27 , m_testMode(false)
28 , m_serviceUrl("https://www.drdump.com")
30 CRegKey reg;
31 if (ERROR_SUCCESS == reg.Open(HKEY_LOCAL_MACHINE, _T("Software\\Idol Software\\DumpUploader"), KEY_READ))
33 CString str;
34 ULONG size = 1000;
35 if (ERROR_SUCCESS == reg.QueryStringValue(_T("ServiceURL"), str.GetBuffer(size), &size))
37 str.ReleaseBuffer(size-1);
38 m_serviceUrl = str;
41 DWORD cfgResponseTimeoutSec = 0;
42 if (ERROR_SUCCESS == reg.QueryDWORDValue(_T("ResponseTimeoutSec"), cfgResponseTimeoutSec) && cfgResponseTimeoutSec != 0)
43 responseTimeoutSec = static_cast<int>(cfgResponseTimeoutSec);
45 DWORD testMode = 0;
46 if (ERROR_SUCCESS == reg.QueryDWORDValue(_T("TestMode"), testMode))
47 m_testMode = testMode != 0;
49 #ifdef _DEBUG // soap_set_*_logfile defined only in DEBUG build of GSOAP
50 DWORD traceEnable = FALSE;
51 if (ERROR_SUCCESS == reg.QueryDWORDValue(_T("TraceEnable"), traceEnable) && traceEnable != FALSE)
53 size = 1000;
54 if (ERROR_SUCCESS == reg.QueryStringValue(_T("TraceFolder"), str.GetBuffer(size), &size))
56 str.ReleaseBuffer(size-1);
57 soap_set_test_logfile(this, str + _T("\\_gsoap_test.log"));
58 soap_set_sent_logfile(this, str + _T("\\_gsoap_sent.log"));
59 soap_set_recv_logfile(this, str + _T("\\_gsoap_recv.log"));
62 #endif
65 m_serviceUrl += "/Service/DumpUploader3.svc";
67 soap_endpoint = m_serviceUrl.c_str();
68 recv_timeout = responseTimeoutSec;
69 soap_register_plugin(this, wininet_plugin);
72 std::wstring DumpUploaderWebService::GetErrorText()
74 std::ostringstream o;
75 soap_stream_fault(o);
76 std::vector<wchar_t> buf(o.str().size() + 1);
77 buf.resize(MultiByteToWideChar(CP_UTF8, 0, (LPCSTR) o.str().c_str(), (int)o.str().size() + 1, &buf.front(), (int)buf.size()));
79 return std::wstring(buf.begin(), buf.end());
82 void DumpUploaderWebService::SetProgressCallback(pfnProgressCallback progressCallback, LPVOID context)
84 wininet_set_progress_callback(this, progressCallback, context);
87 int DumpUploaderWebService::Hello(_ns1__Hello *ns1__Hello, _ns1__HelloResponse *ns1__HelloResponse)
89 if (!m_testMode)
90 return Base::Hello(ns1__Hello, ns1__HelloResponse);
92 return Base::Hello(ns1__Hello, ns1__HelloResponse);
95 int DumpUploaderWebService::UploadMiniDump(_ns1__UploadMiniDump *ns1__UploadMiniDump, _ns1__UploadMiniDumpResponse *ns1__UploadMiniDumpResponse)
97 return Base::UploadMiniDump(ns1__UploadMiniDump, ns1__UploadMiniDumpResponse);
100 int DumpUploaderWebService::UploadAdditionalInfo(_ns1__UploadAdditionalInfo *ns1__UploadAdditionalInfo, _ns1__UploadAdditionalInfoResponse *ns1__UploadAdditionalInfoResponse)
102 return Base::UploadAdditionalInfo(ns1__UploadAdditionalInfo, ns1__UploadAdditionalInfoResponse);
105 int DumpUploaderWebService::UploadSymbol(_ns1__UploadSymbol *ns1__UploadSymbol, _ns1__UploadSymbolResponse *ns1__UploadSymbolResponse)
107 return Base::UploadSymbol(ns1__UploadSymbol, ns1__UploadSymbolResponse);