-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSaveProcessor.h
52 lines (42 loc) · 1.14 KB
/
SaveProcessor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include "SettingsStorage.h"
#include "ITransactionProcessor.h"
#include <atlfile.h>
class CSaveProcessor :
public ITransactionProcessor
{
SettingsStorage& m_settings;
CAtlFile m_file;
bool m_open;
void Process(const CString& text)
{
if (m_settings.GetSaveToFile())
{
if (!m_open)
{
if (SUCCEEDED(
m_file.Create(m_settings.GetSaveFilename(), GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ, CREATE_ALWAYS)))
{
m_file.Seek(FILE_END);
m_open = true;
}
}
if (m_open)
{
m_file.Write((LPVOID)(LPCTSTR)text, text.GetLength());
}
}
}
public:
CSaveProcessor(SettingsStorage& settings) : m_settings(settings), m_open(false) {}
virtual void OnRequest(DWORD context, CString& request, CHttpHeaders& headers, bool isSSL, DWORD tickCount)
{
// Process(request);
}
virtual void OnResponse(DWORD context, CString& response, CHttpHeaders& headers, bool isSSL, bool shouldBeFiltered, DWORD tickCount)
{
//if (!shouldBeFiltered)
// Process(response);
}
};