1 // Copyright 2014 Idol Software, Inc.
3 // This file is part of Doctor Dump SDK.
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.
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/>.
22 #include "..\..\CommonLibs\Log\log.h"
23 #include "..\DumpUploaderServiceLib\DumpUploaderWebService.h"
24 #include "DumpUploader.h"
28 namespace soap_helpers
33 std::function
<S
* (soap
*, int)> m_create
;
34 std::function
<void (soap
*, S
*)> m_deleter
;
37 SoapStuct(const SoapStuct
&);
38 SoapStuct(const SoapStuct
&& other
);
40 SoapStuct(soap
* webService
,
41 std::function
<S
* (soap
*, int)> create
,
42 std::function
<void (soap
*, S
*)> deleter
)
43 : m_webService(webService
)
47 m_s
= m_create(m_webService
, 1);
52 m_deleter(m_webService
, m_s
);
55 operator S
*() { return m_s
; }
56 S
* operator->() { return m_s
; }
57 S
* get() { return m_s
; }
59 std::shared_ptr
<void> m_data
;
61 #define SOAP_STRUCT(Str, Var) soap_helpers::SoapStuct<Str> Var(&m_webService, soap_new_##Str, soap_delete_##Str)
62 #define SOAP_SHARED_STRUCT(Str, Var) std::shared_ptr<soap_helpers::SoapStuct<Str>> Var(new soap_helpers::SoapStuct<Str>(&m_webService, soap_new_##Str, soap_delete_##Str))
67 struct DumpAdditionalInfo
73 std::wstring description
;
78 std::wstring clientID
;
82 std::wstring urlToProblem
;
83 std::vector
<BYTE
> context
;
86 HaveSolutionResponseType
,
87 NeedMiniDumpResponseType
,
88 NeedFullDumpResponseType
,
89 NeedMoreInfoResponseType
,
94 virtual ResponseType
GetResponseType() const = 0;
96 static std::unique_ptr
<Response
> CreateResponse(const ns1__Response
& response
, Log
& log
);
99 struct HaveSolutionResponse
: public Response
101 bool askConfirmation
;
102 ns4__HaveSolutionResponse_SolutionType type
;
104 std::vector
<BYTE
> exe
;
105 ResponseType
GetResponseType() const override
{ return HaveSolutionResponseType
; }
108 struct NeedMiniDumpResponse
: public Response
110 ResponseType
GetResponseType() const override
{ return NeedMiniDumpResponseType
; }
113 struct NeedFullDumpResponse
: public Response
115 DWORD restrictedDumpType
;
117 ResponseType
GetResponseType() const override
{ return NeedFullDumpResponseType
; }
120 struct NeedMoreInfoResponse
: public Response
122 std::vector
<BYTE
> infoModule
;
123 std::wstring infoModuleCfg
;
124 ResponseType
GetResponseType() const override
{ return NeedMoreInfoResponseType
; }
127 struct StopResponse
: public Response
129 ResponseType
GetResponseType() const override
{ return StopResponseType
; }
132 struct ErrorResponse
: public Response
135 ResponseType
GetResponseType() const override
{ return ErrorResponseType
; }
138 struct IUploadProgress
140 virtual void OnProgress(SIZE_T total
, SIZE_T sent
) = 0;
143 class SoapException
: public std::runtime_error
146 explicit SoapException(int soapError
, const std::string
& message
) : m_soapError(soapError
), std::runtime_error(message
) {}
147 explicit SoapException(int soapError
, const char* message
) : m_soapError(soapError
), std::runtime_error(message
) {}
149 bool IsNetworkProblem() const { return m_soapError
== SOAP_TCP_ERROR
; }
152 class DumpUploaderWebServiceEx
155 DumpUploaderWebServiceEx(Log
& log_
);
157 std::unique_ptr
<Response
> Hello(const Application
& app
, std::wstring appName
, std::wstring companyName
,const DumpAdditionalInfo
& addInfo
);
158 std::unique_ptr
<Response
> UploadMiniDump(const std::vector
<BYTE
>& context
, const Application
& app
, const DumpAdditionalInfo
& addInfo
, const std::wstring
& dumpFile
);
159 std::unique_ptr
<Response
> UploadFullDump(const std::vector
<BYTE
>& context
, const Application
& app
, int miniDumpId
, const std::wstring
& fullDumpZipPath
, IUploadProgress
* uploadProgress
);
160 std::unique_ptr
<Response
> UploadAdditionalInfo(const std::vector
<BYTE
>& context
, const Application
& app
, int miniDumpId
, const std::wstring
& addInfoFile
, IUploadProgress
* uploadProgress
);
161 std::unique_ptr
<Response
> RejectedToSendAdditionalInfo(const std::vector
<BYTE
>& context
, const Application
& app
, int miniDumpId
);
165 DumpUploaderWebService m_webService
;
167 typedef std::vector
<std::shared_ptr
<void>> DeferredDelete
;
168 _xop__Include
* CreateXopInclude(DeferredDelete
& context
, const std::vector
<BYTE
>& data
);
169 _xop__Include
* CreateXopIncludeFromFile(DeferredDelete
& context
, const std::wstring
& path
);
170 ns1__ClientLib
* CreateClientLib(DeferredDelete
& context
);
171 ns1__Application
* CreateApp(DeferredDelete
& context
, const Application
& appsrc
);
172 ns1__AppAdditionalInfo
* CreateAppAddInfo(DeferredDelete
& context
, std::wstring
& appName
, std::wstring
& companyName
);
173 ns1__DumpAdditionalInfo
* CreateDumpAddInfo(DeferredDelete
& context
, const DumpAdditionalInfo
&addInfo
);
174 void ThrowOnSoapFail(int res
);
175 static std::vector
<unsigned char> ReadFile(const std::wstring
& path
);