summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory/src/Options.h
blob: 125078fb2a4a84e76037c113c1d315b45a5c83be (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
Basic History plugin
Copyright (C) 2011-2012 Krzysztof Kral

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#include "IImport.h"
#include "IExport.h"

struct FilterOptions
{
	FilterOptions()
		:onlyIncomming(false),
		onlyOutgoing(false)
	{
	}

	FilterOptions(const std::wstring& _name)
		:name(_name),
		onlyIncomming(false),
		onlyOutgoing(false)
	{
	}

	std::wstring name;
	std::vector<int> events;
	bool onlyIncomming;
	bool onlyOutgoing;
};

struct TaskOptions
{
	bool compress;
	bool useFtp;
	bool isSystem;
	bool active;
	bool forceExecute;
	bool showMBAfterExecute;
	bool exportImported;
	enum TaskType
	{
		Export,
		Delete,
		ExportAndDelete,
		Import,
		ImportAndMarge
	} type;

	enum EventUnit
	{
		Minute,
		Hour,
		Day
	} eventUnit;

	enum TrigerType
	{
		AtStart,
		AtEnd,
		Daily, 
		Weekly,
		Monthly,
		DeltaMin,
		DeltaHour
	} trigerType;

	IExport::ExportType exportType;
	IImport::ImportType importType;
	int eventDeltaTime;
	int filterId;
	int dayTime;
	int dayOfWeek;
	int dayOfMonth;
	int deltaTime;
	int orderNr;
	time_t lastExport;
	std::wstring ftpName;
	std::wstring filterName;
	std::wstring filePath;
	std::wstring taskName;
	std::string zipPassword; // char* because zip file using ANSI password
	std::vector<MCONTACT> contacts;
	TaskOptions()
	{
		forceExecute = false;
		showMBAfterExecute = false;
		exportImported = true;
		type = Export;
		eventUnit = Hour;
		trigerType = AtStart;
		exportType = IExport::RichHtml;
		importType = IImport::Binary;
		eventDeltaTime = 0;
		filterId = 0;
		compress = true;
		useFtp = false;
		isSystem = false;
		active = true;
		dayTime = 20 * 60;
		dayOfWeek = 0;
		dayOfMonth = 1;
		deltaTime = 24;
		orderNr = 0;
		wchar_t buf[MAX_PATH];
		if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, buf)))
		{
			filePath = buf;
			filePath += L"\\";
		}

		filePath += TranslateT("History");
		filePath += L"_<contact>_<date>.<ext>";
		lastExport = time(NULL);
	}
};

class Options
{
private:
	std::vector<FilterOptions> customFiltersTemp;
public:
	Options();
	~Options();
	static int InitOptions(WPARAM wParam, LPARAM lParam);

	static INT_PTR CALLBACK DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsGroupList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsMessages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsSearching(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsExport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsScheduler(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static INT_PTR CALLBACK DlgProcOptsTask(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
	static bool FTPAvail();

	static Options *instance;
	void Save();
	void SaveTasks(std::list<TaskOptions>* tasks);
	void SaveTaskTime(TaskOptions& to);
	void Load(void);
	void LoadTasks();

	bool showContacts, showContactGroups, noFindBorder, groupNewOnTop, groupShowEvents, groupShowTime, groupShowName, groupShowMessage;
	bool messagesNewOnTop, messagesShowDate, messagesShowSec, messagesShowName, messagesShowEvents, messagesUseSmileys;
	bool searchForInList, searchForInMess, searchMatchCase, searchMatchWhole, searchOnlyIn, searchOnlyOut, searchOnlyGroup, searchAllContacts;
	bool schedulerAlerts, schedulerHistoryAlerts;
	int groupMessageLen, groupTime, groupMessagesNumber;

	std::vector<FilterOptions> customFilters;
	int defFilter;
	unsigned int codepageTxt, codepageHtml1, codepageHtml2;
	std::wstring encodingTxt, encodingHtml1, encodingHtml2;
	bool exportHtml1ShowDate, exportHtml2ShowDate, exportHtml2UseSmileys;
	std::wstring extCssHtml2;
	std::vector<TaskOptions> taskOptions;
	std::wstring ftpLogPath;
	std::wstring ftpExePathDef;
	std::wstring ftpExePath;
	mir_cs criticalSection;

	enum Fonts
	{
		OutTimestamp = 0,
		InTimestamp,
		OutName,
		InName,
		OutMessages,
		InMessages,
		GroupList,
		Find,
	};

	enum Colors
	{
		OutBackground = 0,
		InBackground,
		GroupListBackground,
		WindowBackground,
		ContactListBackground,
		FindBackground,
	};

	COLORREF GetFont(Fonts fontId, PLOGFONT font);
	COLORREF GetColor(Colors colorId);
};