| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "module.h" |
| 19 |
#include "ignore.h" |
| 20 |
#include "levels.h" |
| 21 |
#include "module-formats.h" |
| 22 |
#include "printtext.h" |
| 23 |
#include "signals.h" |
| 24 |
#include "fe-common/core/module-formats.h" |
| 25 |
#include "fe-common/irc/module-formats.h" |
| 26 |
|
| 27 |
#include "xmpp-servers.h" |
| 28 |
#include "xep/registration.h" |
| 29 |
|
| 30 |
static void |
| 31 |
sig_failed(const char *username, const char *domain, gpointer error) |
| 32 |
{ |
| 33 |
char *reason, *str = NULL; |
| 34 |
|
| 35 |
switch(GPOINTER_TO_INT(error)) { |
| 36 |
case REGISTRATION_ERROR_UNAUTHORIZED: |
| 37 |
case REGISTRATION_ERROR_UNAUTHORIZED_REG: |
| 38 |
reason = "Registration unauthorized"; |
| 39 |
break; |
| 40 |
case REGISTRATION_ERROR_UNIMPLEMENTED: |
| 41 |
case REGISTRATION_ERROR_UNAVAILABLE: |
| 42 |
reason = "Service unavailable"; |
| 43 |
break; |
| 44 |
case REGISTRATION_ERROR_CONFLICT: |
| 45 |
reason = "Account already exists"; |
| 46 |
break; |
| 47 |
case REGISTRATION_ERROR_TIMEOUT: |
| 48 |
case REGISTRATION_ERROR_TIMEOUT_SERVER: |
| 49 |
reason = "Connection times out"; |
| 50 |
break; |
| 51 |
case REGISTRATION_ERROR_CLOSED: |
| 52 |
reason = "Connection was closed"; |
| 53 |
break; |
| 54 |
case REGISTRATION_ERROR_CONNECTION: |
| 55 |
reason = "Cannot open connection"; |
| 56 |
break; |
| 57 |
case REGISTRATION_ERROR_INFO: |
| 58 |
reason = "Cannot send registration information"; |
| 59 |
break; |
| 60 |
case REGISTRATION_ERROR_UNKNOWN: |
| 61 |
reason = "Cannot register account (unknown reason)"; |
| 62 |
break; |
| 63 |
default: |
| 64 |
reason = str = g_strdup_printf("Cannot register account (%d)", |
| 65 |
GPOINTER_TO_INT(error)); |
| 66 |
} |
| 67 |
printformat_module(MODULE_NAME, NULL, NULL, |
| 68 |
MSGLEVEL_CRAP, XMPPTXT_REGISTRATION_FAILED, username, domain, |
| 69 |
reason); |
| 70 |
g_free(str); |
| 71 |
} |
| 72 |
|
| 73 |
static void |
| 74 |
sig_succeed(const char *username, const char *domain) |
| 75 |
{ |
| 76 |
printformat_module(MODULE_NAME, NULL, NULL, |
| 77 |
MSGLEVEL_CRAP, XMPPTXT_REGISTRATION_SUCCEED, username, domain); |
| 78 |
} |
| 79 |
|
| 80 |
static void |
| 81 |
sig_started(const char *username, const char *domain) |
| 82 |
{ |
| 83 |
printformat_module(MODULE_NAME, NULL, NULL, |
| 84 |
MSGLEVEL_CRAP, XMPPTXT_REGISTRATION_STARTED, username, domain); |
| 85 |
} |
| 86 |
|
| 87 |
void |
| 88 |
fe_registration_init(void) |
| 89 |
{ |
| 90 |
signal_add("xmpp registration failed", sig_failed); |
| 91 |
signal_add("xmpp registration succeed", sig_succeed); |
| 92 |
signal_add("xmpp registration started", sig_started); |
| 93 |
} |
| 94 |
|
| 95 |
void |
| 96 |
fe_registration_deinit(void) |
| 97 |
{ |
| 98 |
signal_remove("xmpp registration failed", sig_failed); |
| 99 |
signal_remove("xmpp registration succeed", sig_succeed); |
| 100 |
signal_remove("xmpp registration started", sig_started); |
| 101 |
} |