1 // Copyright 2012 Idol Software, Inc.
3 // This file is part of CrashHandler library.
5 // CrashHandler library 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.
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\UploaderSoap.nsmap"
20 #include "gsoapWinInet.h"
25 DumpUploaderWebService::DumpUploaderWebService(int responseTimeoutSec
)
26 : UploaderSoapProxy(SOAP_ENC_MTOM
|SOAP_IO_KEEPALIVE
|SOAP_C_UTFSTRING
/*SOAP_C_MBSTRING*/)
27 , m_serviceUrl("https://www.crash-server.com")
30 if (ERROR_SUCCESS
== reg
.Open(HKEY_LOCAL_MACHINE
, _T("Software\\Idol Software\\DumpUploader"), KEY_READ
))
34 if (ERROR_SUCCESS
== reg
.QueryStringValue(_T("ServiceURL"), str
.GetBuffer(size
), &size
))
36 str
.ReleaseBuffer(size
-1);
40 DWORD cfgResponseTimeoutSec
= 0;
41 if (ERROR_SUCCESS
== reg
.QueryDWORDValue(_T("ResponseTimeoutSec"), cfgResponseTimeoutSec
) && cfgResponseTimeoutSec
!= 0)
42 responseTimeoutSec
= static_cast<int>(cfgResponseTimeoutSec
);
44 #ifdef _DEBUG // soap_set_*_logfile defined only in DEBUG build of GSOAP
45 DWORD traceEnable
= FALSE
;
46 if (ERROR_SUCCESS
== reg
.QueryDWORDValue(_T("TraceEnable"), traceEnable
) && traceEnable
!= FALSE
)
49 if (ERROR_SUCCESS
== reg
.QueryStringValue(_T("TraceFolder"), str
.GetBuffer(size
), &size
))
51 str
.ReleaseBuffer(size
-1);
52 soap_set_test_logfile(this, str
+ _T("\\_gsoap_test.log"));
53 soap_set_sent_logfile(this, str
+ _T("\\_gsoap_sent.log"));
54 soap_set_recv_logfile(this, str
+ _T("\\_gsoap_recv.log"));
60 m_serviceUrl
+= "/DumpUploader.asmx";
62 soap_endpoint
= m_serviceUrl
.c_str();
63 recv_timeout
= responseTimeoutSec
;
64 soap_register_plugin(this, wininet_plugin
);
67 std::wstring
DumpUploaderWebService::GetErrorText()
71 std::vector
<wchar_t> buf(o
.str().size() + 1);
72 buf
.resize(MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
) o
.str().c_str(), (int)o
.str().size() + 1, &buf
.front(), (int)buf
.size()));
74 return std::wstring(buf
.begin(), buf
.end());
77 void DumpUploaderWebService::SetProgressCallback(pfnProgressCallback progressCallback
, LPVOID context
)
79 wininet_set_progress_callback(this, progressCallback
, context
);