summaryrefslogtreecommitdiff
path: root/include/m_errors.h
blob: c19e76dfe77e5fc2f3a253363db6ac287c2691b2 (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
/*

Miranda IM: the free IM client for Microsoft* Windows*

Copyright 2000-2008 Miranda ICQ/IM project, 
all portions of this codebase are copyrighted to the people 
listed in contributors.txt.

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; either version 2
of the License, or (at your option) any later version.

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef M_ERRORS_H__
#define M_ERRORS_H__ 1

#define MERR_UNICODE				0x01
#define MERR_DEFAULT_INFO			0x02
#define MERR_DEFAULT_WARNING		0x04
#define MERR_DEFAULT_ERROR			0x08
#define MERR_DEFAULT_ALL			0x0E

#ifdef _UNICODE
	#define MERR_TCHAR				MERR_UNICODE
#else
	#define MERR_TCHAR				0
#endif

// Error notifications are sorted according to this level
#define MERR_LEVEL_INFO				1
#define MERR_LEVEL_WARNING			2
#define MERR_LEVEL_ERROR			3

// Predefined error types (no need to call MS_ERROR_REGISTER)
#define MERR_TYPE_INFO				"Core/Info"
#define MERR_TYPE_SRV_INFO			"Core/SrvInfo"
#define MERR_TYPE_WARNING			"Core/Warning"
#define MERR_TYPE_SRV_WARNING		"Core/SrvWarning"
#define MERR_TYPE_SRV_ERROR			"Core/SrvError"
#define MERR_TYPE_NETWORK			"Core/Network"
#define MERR_TYPE_LOGIN				"Core/Login"

// Specify set of buttons to make query box
#define MERR_BTN_NONE				0
#define MERR_BTN_YESNO				1
#define MERR_BTN_YESNOCANCEL		2
#define MERR_BTN_ABORTRETRYIGNORE	4

// General-purpose error definition
typedef struct
{
	int                 cbSize;
	DWORD               flags;
	int                 level;
	char                *name;

	union {
		TCHAR           *ptszTitle;
		char            *pszTitle;
		WCHAR           *pwszTitle;
	};
} MIRANDAERROR_TYPE;

// General-purpose error definition
typedef struct
{
	int                 cbSize;
	DWORD               flags;
	char                *type;

	union {
		TCHAR           *ptszModuleTitle;
		char            *pszModuleTitle;
		WCHAR           *pwszModuleTitle;
	};

	int                 buttons;
	int                 btnDefault;
	char                *pszQueryName; // to save answer in DB
	char                *pszSvcCallback;
	LPARAM              lParam;

	// information itself
	HANDLE              hContact;
	union {
		TCHAR           *ptszTitle;
		char            *pszTitle;
		WCHAR           *pwszTitle;
	};
	union {
		TCHAR           *ptszText;
		char            *pszText;
		WCHAR           *pwszText;
	};

	// filled by core and may be used in handlers.
	MIRANDAERROR_TYPE   *typeInfo;
	DWORD               dwTimestamp;
} MIRANDAERROR;

// Information about particular error handler for options UI
typedef struct
{
	int                 cbSize;
	DWORD               flags;
	char                *pszDbModule;

	HANDLE              hIcolibIcon;
	union {
		TCHAR           *ptszTitle;
		char            *pszTitle;
		WCHAR           *pwszTitle;
	};
} MIRANDAERROR_HANDLER;

#define MS_ERROR_REGISTER           "Errors/Register"
#define MS_ERROR_ADDHANDLER         "Errors/AddHandler"
#define MS_ERROR_PROCESS            "Errors/Process"
#define ME_ERROR_ONPROCESS          "Errors/OnProcess"

#ifndef MIRANDA_ERRORS_NOHELPERS
	#ifdef __cplusplus
		#define	DEFVAL(x)	= x
	#else
		#define	DEFVAL(x)
	#endif

	static __forceinline void mir_ReportError(HANDLE hContact, TCHAR *ptszModuleTitle, char *pszType, TCHAR *ptszText, TCHAR *ptszTitle DEFVAL(NULL))
	{
		MIRANDAERROR err = {0};
		err.cbSize = sizeof(err);
		err.flags = MERR_TCHAR;
		err.type = pszType;
		err.ptszModuleTitle = ptszModuleTitle;
		err.hContact = hContact;
		err.ptszText = ptszText;
		err.ptszTitle = ptszTitle;
		CallServiceSync(MS_ERROR_PROCESS, 0, (LPARAM)&err);
	}

	#undef DEFVAL
#endif // MIRANDA_ERRORS_NOHELPERS

#endif // M_ERRORS_H__