~itmages/itmages/itmages-windows-extension

« back to all changes in this revision

Viewing changes to errorshandler.c

  • Committer: Dmitry
  • Date: 2012-03-11 07:56:24 UTC
  • Revision ID: git-v1:d5a30bf1fe74b46641b08d0151d39dba15b67f0e
Migrate from launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    ITmages  upload client for Windows
 
3
    Copyright (C) 2011 Dmitriy Simbiriatin <slpiv@itmages.ru>
 
4
 
 
5
    This program is free software; you can redistribute it and/or
 
6
    modify it under the terms of the GNU General Public License
 
7
    as published by the Free Software Foundation; either version 2
 
8
    of the License, or (at your option) any later version.
 
9
 
 
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 General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software
 
17
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#include <windows.h>
 
21
#include <libintl.h>
 
22
#include <locale.h>
 
23
#include "errorshandler.h"
 
24
 
 
25
void ErrorsHandler(ItmagesErrorIds error_number)
 
26
{
 
27
    switch (error_number) {
 
28
    case ERROR_WRITEFILE:
 
29
        MessageBox(
 
30
                NULL,
 
31
                gettext("Failed to open the file for writing. Possibly another program already use it."),
 
32
                gettext("ITmages - Error"),
 
33
                MB_OK | MB_ICONERROR);
 
34
        MessageBeep(MB_ICONERROR);
 
35
        break;
 
36
    case ERROR_READFILE:
 
37
        MessageBox(
 
38
                NULL,
 
39
                gettext("Failed to read from the file. Possibly another program already use it."),
 
40
                gettext("ITmages - Error"),
 
41
                MB_OK | MB_ICONERROR);
 
42
        MessageBeep(MB_ICONERROR);
 
43
        break;
 
44
    case ERROR_CURL:
 
45
        MessageBox(
 
46
                NULL,
 
47
                gettext("Upload error. Please check your internet connection."),
 
48
                gettext("ITmages - Error"),
 
49
                MB_OK | MB_ICONERROR);
 
50
        MessageBeep(MB_ICONERROR);
 
51
        break;
 
52
    case ERROR_MEMALLOC:
 
53
        MessageBox(
 
54
                NULL,
 
55
                gettext("Failed to allocate the memory."),
 
56
                gettext("ITmages - Error"),
 
57
                MB_OK | MB_ICONERROR);
 
58
        MessageBeep(MB_ICONERROR);
 
59
        break;
 
60
    case ERROR_PARSERESPONSE:
 
61
        MessageBox(
 
62
                NULL,
 
63
                gettext("Failed to parse the response from the server."),
 
64
                gettext("ITmages - Error"),
 
65
                MB_OK | MB_ICONERROR);
 
66
        MessageBeep(MB_ICONERROR);
 
67
        break;
 
68
    case ERROR_GETIMGPATH:
 
69
        MessageBox(
 
70
                NULL,
 
71
                gettext("Failed to get the image path."),
 
72
                gettext("ITmages - Error"),
 
73
                MB_OK | MB_ICONERROR);
 
74
        MessageBeep(MB_ICONERROR);
 
75
        break;
 
76
    case ERROR_SUPPORTEDIMG:
 
77
        MessageBox(
 
78
                NULL,
 
79
                gettext("Unsupported image type. ITmages supports only jpg/jpeg, png and gif images."),
 
80
                gettext("ITmages - Error"),
 
81
                MB_OK | MB_ICONERROR);
 
82
        MessageBeep(MB_ICONERROR);
 
83
        break;
 
84
    case ERROR_GETIMGSIZE:
 
85
        MessageBox(
 
86
                NULL,
 
87
                gettext("Failed to get the image's size."),
 
88
                gettext("ITmages - Error"),
 
89
                MB_OK | MB_ICONERROR);
 
90
        MessageBeep(MB_ICONERROR);
 
91
        break;
 
92
    case ERROR_MAXIMGSIZE:
 
93
        MessageBox(
 
94
                NULL,
 
95
                gettext("Unsupported image size. Image's size have to be less than 6 Mb."),
 
96
                gettext("ITmages - Error"),
 
97
                MB_OK | MB_ICONERROR);
 
98
        MessageBeep(MB_ICONERROR);
 
99
        break;
 
100
    case ERROR_OPENCLIPBOARD:
 
101
        MessageBox(
 
102
                NULL,
 
103
                gettext("Failed to open the clipboard."),
 
104
                gettext("ITmages - Error"),
 
105
                MB_OK | MB_ICONERROR);
 
106
        MessageBeep(MB_ICONERROR);
 
107
        break;
 
108
    case ERROR_REGISTERWNDCLS:
 
109
        MessageBox(
 
110
                NULL,
 
111
                gettext("Failed to register window's class."),
 
112
                gettext("ITmages - Error"),
 
113
                MB_OK | MB_ICONERROR);
 
114
        MessageBeep(MB_ICONERROR);
 
115
        break;
 
116
    case ERROR_GETSETTINGSDIR:
 
117
        MessageBox(
 
118
                NULL,
 
119
                gettext("Failed to get the default settings directory."),
 
120
                gettext("ITmages - Error"),
 
121
                MB_OK | MB_ICONERROR);
 
122
        MessageBeep(MB_ICONERROR);
 
123
        break;
 
124
    case ERROR_GETCOOKIESDIR:
 
125
        MessageBox(
 
126
                NULL,
 
127
                gettext("Failed to get the default cookies directory."),
 
128
                gettext("ITmages - Error"),
 
129
                MB_OK | MB_ICONERROR);
 
130
        MessageBeep(MB_ICONERROR);
 
131
        break;
 
132
    case ERROR_READCONFFILE:
 
133
        MessageBox(
 
134
                NULL,
 
135
                gettext("Failed to read the configuration file."),
 
136
                gettext("ITmages - Error"),
 
137
                MB_OK | MB_ICONERROR);
 
138
        MessageBeep(MB_ICONERROR);
 
139
        break;
 
140
    case ERROR_WRITECONFFILE:
 
141
        MessageBox(
 
142
                NULL,
 
143
                gettext("Failed to write the settings into the configuration file."),
 
144
                gettext("ITmages - Error"),
 
145
                MB_OK | MB_ICONERROR);
 
146
        MessageBeep(MB_ICONERROR);
 
147
        break;
 
148
    case ERROR_CREATETHREAD:
 
149
        MessageBox(
 
150
                NULL,
 
151
                gettext("Failed to create a new thread."),
 
152
                gettext("ITmages - Error"),
 
153
                MB_OK | MB_ICONERROR);
 
154
        MessageBeep(MB_ICONERROR);
 
155
        break;
 
156
    case ERROR_CONNECTION:
 
157
        MessageBox(
 
158
                NULL,
 
159
                gettext("Failed to connect to the server."),
 
160
                gettext("ITmages - Error"),
 
161
                MB_OK | MB_ICONERROR);
 
162
        MessageBeep(MB_ICONERROR);
 
163
        break;
 
164
    case ERROR_LOGIN:
 
165
        MessageBox(
 
166
                NULL,
 
167
                gettext("Failed to login. Check your login and password."),
 
168
                gettext("ITmages - Error"),
 
169
                MB_OK | MB_ICONERROR);
 
170
        MessageBeep(MB_ICONERROR);
 
171
        break;
 
172
    case ERROR_LOGOUT:
 
173
        MessageBox(
 
174
                NULL,
 
175
                gettext("Failed to logout."),
 
176
                gettext("ITmages - Error"),
 
177
                MB_OK | MB_ICONERROR);
 
178
        MessageBeep(MB_ICONERROR);
 
179
        break;
 
180
    case ERROR_BIGWIDTH:
 
181
        MessageBox(
 
182
                NULL,
 
183
                gettext("The reduce value have to be less than actual width of the image."),
 
184
                gettext("ITmages - Warning"),
 
185
                MB_OK | MB_ICONWARNING);
 
186
        MessageBeep(MB_ICONWARNING);
 
187
        break;
 
188
    case ERROR_BADIMGSIZE:
 
189
        MessageBox(
 
190
                NULL,
 
191
                gettext("Wrong image size. Possible, image is corrupted."),
 
192
                gettext("ITmages - Error"),
 
193
                MB_OK | MB_ICONERROR);
 
194
        MessageBeep(MB_ICONERROR);
 
195
        break;
 
196
    case ERROR_GETIMGWIDTH:
 
197
        MessageBox(
 
198
                NULL,
 
199
                gettext("Failed to get the image's width."),
 
200
                gettext("ITmages - Error"),
 
201
                MB_OK | MB_ICONERROR);
 
202
        MessageBeep(MB_ICONERROR);
 
203
        break;
 
204
    case ERROR_GETIMGINFO:
 
205
        MessageBox(
 
206
                NULL,
 
207
                gettext("Failed to get the information about the image."),
 
208
                gettext("ITmages - Error"),
 
209
                MB_OK | MB_ICONERROR);
 
210
        MessageBeep(MB_ICONERROR);
 
211
        break;
 
212
    default:
 
213
        MessageBox(
 
214
                NULL,
 
215
                gettext("Wrong error's id."),
 
216
                gettext("ITmages - Error"),
 
217
                MB_OK | MB_ICONERROR);
 
218
        MessageBeep(MB_ICONERROR);
 
219
    }
 
220
}