WIP Unify error codes returned to the connection handler
Error argument in the connection handler is not always set and in some cases provides meaningless values. For example, every TLS module returns its specific error codes. Current solution unifies error codes and allows to distinguish between different types of disconnection. Fixes #123.
This commit is contained in:
@@ -38,7 +38,25 @@ void conn_handler(xmpp_conn_t *const conn,
|
||||
secured ? "secured" : "NOT secured");
|
||||
xmpp_disconnect(conn);
|
||||
} else {
|
||||
fprintf(stderr, "DEBUG: disconnected\n");
|
||||
switch (error) {
|
||||
case XMPP_EOK:
|
||||
fprintf(stderr, "DEBUG: disconnected successfully.\n");
|
||||
break;
|
||||
case XMPP_EINVOP:
|
||||
/*
|
||||
* This may happen when the requested functionality is not
|
||||
* supported or some data is not provided when it is required (e.g.
|
||||
* resource part).
|
||||
*/
|
||||
fprintf(stderr, "DEBUG: disconnected, invalid operation.\n");
|
||||
break;
|
||||
case XMPP_ECERT:
|
||||
/*
|
||||
* In this case, application can reconnect with
|
||||
* XMPP_CONN_FLAG_TRUST_TLS if user permits.
|
||||
*/
|
||||
fprintf(stderr, "DEBUG: disconnected, invalid TLS certificate.\n");
|
||||
}
|
||||
xmpp_stop(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user