Allow configuring compression level
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
committed by
Steffen Jaeckel
parent
06f2ba19b4
commit
541c22cb13
@@ -280,7 +280,8 @@ struct _xmpp_conn_t {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct xmpp_compression *state;
|
struct xmpp_compression *state;
|
||||||
int allowed, supported, dont_reset;
|
int allowed, dont_reset, level;
|
||||||
|
int supported;
|
||||||
} compression;
|
} compression;
|
||||||
|
|
||||||
char *lang;
|
char *lang;
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ int compression_init(xmpp_conn_t *conn)
|
|||||||
|
|
||||||
comp->compression.stream.next_out = comp->compression.buffer;
|
comp->compression.stream.next_out = comp->compression.buffer;
|
||||||
comp->compression.stream.avail_out = STROPHE_COMPRESSION_BUFFER_SIZE;
|
comp->compression.stream.avail_out = STROPHE_COMPRESSION_BUFFER_SIZE;
|
||||||
int ret = deflateInit(&comp->compression.stream, Z_DEFAULT_COMPRESSION);
|
int ret = deflateInit(&comp->compression.stream, conn->compression.level);
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
strophe_free_and_null(conn->ctx, comp->compression.buffer);
|
strophe_free_and_null(conn->ctx, comp->compression.buffer);
|
||||||
conn->error = ret;
|
conn->error = ret;
|
||||||
|
|||||||
@@ -167,6 +167,8 @@ xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t *ctx)
|
|||||||
tls_clear_password_cache(conn);
|
tls_clear_password_cache(conn);
|
||||||
conn->password_retries = 1;
|
conn->password_retries = 1;
|
||||||
|
|
||||||
|
conn->compression.level = -1;
|
||||||
|
|
||||||
conn->parser =
|
conn->parser =
|
||||||
parser_new(conn->ctx, _handle_stream_start, _handle_stream_end,
|
parser_new(conn->ctx, _handle_stream_start, _handle_stream_end,
|
||||||
_handle_stream_stanza, conn);
|
_handle_stream_stanza, conn);
|
||||||
@@ -348,6 +350,10 @@ int xmpp_conn_release(xmpp_conn_t *conn)
|
|||||||
* In case the user enters the password manually it can be useful to
|
* In case the user enters the password manually it can be useful to
|
||||||
* directly retry if the decryption of the key file failed.
|
* directly retry if the decryption of the key file failed.
|
||||||
*
|
*
|
||||||
|
* - \ref XMPP_SETTING_COMPRESSION_LEVEL
|
||||||
|
* Set the compression level. \n
|
||||||
|
* For zlib the valid range is `-1` to `9`.
|
||||||
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
* @param setting The setting that shall be configured
|
* @param setting The setting that shall be configured
|
||||||
* @param value The value, the settings should get
|
* @param value The value, the settings should get
|
||||||
@@ -365,6 +371,9 @@ void xmpp_conn_set_int(xmpp_conn_t *conn,
|
|||||||
else
|
else
|
||||||
conn->password_retries = value;
|
conn->password_retries = value;
|
||||||
break;
|
break;
|
||||||
|
case XMPP_SETTING_COMPRESSION_LEVEL:
|
||||||
|
conn->compression.level = value;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
strophe_warn(conn->ctx, "xmpp", "Invalid Int setting %d", setting);
|
strophe_warn(conn->ctx, "xmpp", "Invalid Int setting %d", setting);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ typedef enum xmpp_conn_setting_t {
|
|||||||
/* Int values */
|
/* Int values */
|
||||||
XMPP_SETTING_PASSWORD_RETRIES = 0x40, /**< Number of retry attempts to
|
XMPP_SETTING_PASSWORD_RETRIES = 0x40, /**< Number of retry attempts to
|
||||||
decrypt a private key file. */
|
decrypt a private key file. */
|
||||||
|
XMPP_SETTING_COMPRESSION_LEVEL, /**< Compression level. */
|
||||||
|
|
||||||
/* Pointer values */
|
/* Pointer values */
|
||||||
XMPP_SETTING_PASSWORD_CALLBACK_USERDATA = 0x80, /**< Userdata for password
|
XMPP_SETTING_PASSWORD_CALLBACK_USERDATA = 0x80, /**< Userdata for password
|
||||||
|
|||||||
Reference in New Issue
Block a user