src/protocols/sametime/meanwhile/error.c

changeset 12496
788b20ccec91
parent 12495
4b2c27ae504a
child 12497
a17568773be3
equal deleted inserted replaced
12495:4b2c27ae504a 12496:788b20ccec91
1
2 /*
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
4 Copyright (C) 2004 Christopher (siege) O'Brien
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include <stdio.h>
22 #include <string.h>
23
24 #include "mw_error.h"
25
26
27 static char *err_to_str(guint32 code) {
28 static char b[11]; /* 0x12345678 + NULL terminator */
29 sprintf((char *) b, "0x%08x", code);
30 b[10] = '\0';
31 return b;
32 }
33
34
35 #define CASE(val, str) \
36 case val: \
37 m = str; \
38 break;
39
40
41 char* mwError(guint32 code) {
42 const char *m;
43
44 switch(code) {
45
46 /* 8.3.1.1 General error/success codes */
47 CASE(ERR_SUCCESS, "Success");
48 CASE(ERR_FAILURE, "General failure");
49 CASE(ERR_REQUEST_DELAY, "Request delayed");
50 CASE(ERR_REQUEST_INVALID, "Request is invalid");
51 CASE(ERR_NOT_AUTHORIZED, "Not authorized");
52 CASE(ERR_NO_USER, "User is not online");
53 CASE(ERR_CHANNEL_NO_SUPPORT, "Requested channel is not supported");
54 CASE(ERR_CHANNEL_EXISTS, "Requested channel already exists");
55 CASE(ERR_SERVICE_NO_SUPPORT, "Requested service is not supported");
56 CASE(ERR_PROTOCOL_NO_SUPPORT, "Requested protocol is not supported");
57 CASE(ERR_VERSION_NO_SUPPORT, "Version is not supported");
58 CASE(ERR_USER_SKETCHY, "User is invalid or not trusted");
59 CASE(ERR_ALREADY_INITIALIZED, "Already initialized");
60 CASE(ERR_ENCRYPT_NO_SUPPORT, "Encryption method not supported");
61 CASE(ERR_NO_COMMON_ENCRYPT, "No common encryption method");
62
63 /* 8.3.1.2 Connection/disconnection errors */
64 CASE(VERSION_MISMATCH, "Version mismatch");
65 CASE(FAT_MESSAGE, "Message is too large");
66 CASE(CONNECTION_BROKEN, "Connection broken");
67 CASE(CONNECTION_ABORTED, "Connection aborted");
68 CASE(CONNECTION_REFUSED, "Connection refused");
69 CASE(CONNECTION_RESET, "Connection reset");
70 CASE(CONNECTION_TIMED, "Connection timed out");
71 CASE(CONNECTION_CLOSED, "Connection closed");
72 CASE(INCORRECT_LOGIN, "Incorrect Username/Password");
73 CASE(VERIFICATION_DOWN, "Login verification down or unavailable");
74 CASE(GUEST_IN_USE, "The guest name is currently being used");
75 CASE(MULTI_SERVER_LOGIN, "Login to two different servers concurrently");
76 CASE(MULTI_SERVER_LOGIN2, "Login to two different servers concurrently");
77 CASE(SERVER_BROKEN, "Server misconfiguration");
78
79 /* 8.3.1.3 Client error codes */
80 CASE(ERR_CLIENT_USER_GONE, "User is not online");
81 CASE(ERR_CLIENT_USER_DND, "User is in Do Not Disturb mode");
82 CASE(ERR_CLIENT_USER_ELSEWHERE, "Already logged in elsewhere");
83
84 /* 8.3.1.4 IM error codes */
85 CASE(ERR_IM_COULDNT_REGISTER, "Cannot register a reserved type");
86 CASE(ERR_IM_ALREADY_REGISTERED, "Requested type is already registered");
87 CASE(ERR_IM_NOT_REGISTERED, "Requested type is not registered");
88
89 default:
90 m = err_to_str(code);
91 }
92
93 return g_strdup(m);
94 }
95
96
97 #undef CASE

mercurial