--- a/libpurple/protocols/novell/nmconn.c Sat Nov 02 23:02:26 2019 -0400
+++ b/libpurple/protocols/novell/nmconn.c Sun Nov 03 20:27:37 2019 -0500
@@ -36,27 +36,6 @@
#define NO_ESCAPE(ch) ((ch == 0x20) || (ch >= 0x30 && ch <= 0x39) || \
(ch >= 0x41 && ch <= 0x5a) || (ch >= 0x61 && ch <= 0x7a))
-/* Read data from conn until the end of a line */
-read_line(NMConn * conn, char *buff, int len)
- while ((rc == NM_OK) && (total_bytes < (len - 1))) {
- rc = nm_read_all(conn, &buff[total_bytes], 1);
- if (buff[total_bytes - 1] == '\n') {
- buff[total_bytes] = '\0';
url_escape_string(char *src)
@@ -188,8 +167,8 @@
- purple_gio_graceful_close(conn->stream, conn->input,
+ purple_gio_graceful_close(conn->stream, G_INPUT_STREAM(conn->input), g_clear_object(&conn->input);
g_clear_object(&conn->output);
@@ -199,68 +178,10 @@
-nm_tcp_write(NMConn * conn, const void *buff, int len)
- if (conn == NULL || buff == NULL)
- return g_output_stream_write(conn->output, buff, len, NULL, NULL);
-nm_tcp_read(NMConn * conn, void *buff, int len)
- if (conn == NULL || buff == NULL)
- return g_input_stream_read(conn->input, buff, len, NULL, NULL);
-nm_read_all(NMConn * conn, char *buff, int len)
+nm_write_fields(NMUser *user, NMField *fields)
- if (conn == NULL || buff == NULL)
- if (!g_input_stream_read_all(conn->input, buff, len, NULL, NULL, NULL)) {
-nm_read_uint32(NMConn *conn, guint32 *val)
- rc = nm_read_all(conn, (char *)val, sizeof(*val));
- *val = GUINT32_FROM_LE(*val);
-nm_read_uint16(NMConn *conn, guint16 *val)
- rc = nm_read_all(conn, (char *)val, sizeof(*val));
- *val = GUINT16_FROM_LE(*val);
-nm_write_fields(NMConn * conn, NMField * fields)
@@ -270,9 +191,10 @@
- if (conn == NULL || fields == NULL) {
+ g_return_val_if_fail(user != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(conn != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(fields != NULL, NMERR_BAD_PARM); /* Format each field as valid "post" data and write it out */
for (field = fields; (rc == NM_OK) && (field->tag); field++) {
@@ -285,7 +207,8 @@
/* Write the field tag */
bytes_to_send = g_snprintf(buffer, sizeof(buffer), "&tag=%s", field->tag);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); @@ -294,7 +217,8 @@
method = encode_method(field->method);
bytes_to_send = g_snprintf(buffer, sizeof(buffer), "&cmd=%s", method);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); @@ -310,9 +234,13 @@
bytes_to_send = g_snprintf(buffer, sizeof(buffer),
if (bytes_to_send > (int)sizeof(buffer)) {
- ret = nm_tcp_write(conn, buffer, sizeof(buffer));
+ ret = g_output_stream_write(conn->output, buffer, + user->cancellable, NULL); - ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, + user->cancellable, NULL); @@ -329,7 +257,9 @@
val = nm_count_fields((NMField *) field->ptr_value);
bytes_to_send = g_snprintf(buffer, sizeof(buffer),
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, + user->cancellable, NULL); @@ -340,7 +270,9 @@
bytes_to_send = g_snprintf(buffer, sizeof(buffer),
"&val=%u", field->value);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, + user->cancellable, NULL); @@ -353,7 +285,8 @@
bytes_to_send = g_snprintf(buffer, sizeof(buffer),
"&type=%u", field->type);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); @@ -364,8 +297,7 @@
if (field->type == NMFIELD_TYPE_ARRAY ||
field->type == NMFIELD_TYPE_MV) {
- rc = nm_write_fields(conn, (NMField *) field->ptr_value);
+ rc = nm_write_fields(user, (NMField *)field->ptr_value); @@ -374,9 +306,10 @@
-nm_send_request(NMConn *conn, char *cmd, NMField *fields,
- nm_response_cb cb, gpointer data, NMRequest **request)
+nm_send_request(NMUser *user, char *cmd, NMField *fields, nm_response_cb cb, + gpointer data, NMRequest **request) @@ -384,13 +317,16 @@
NMField *request_fields = NULL;
- if (conn == NULL || cmd == NULL)
+ g_return_val_if_fail(user != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(conn != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(cmd != NULL, NMERR_BAD_PARM); bytes_to_send = g_snprintf(buffer, sizeof(buffer),
"POST /%s HTTP/1.0\r\n", cmd);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); @@ -400,13 +336,15 @@
if (purple_strequal("login", cmd)) {
bytes_to_send = g_snprintf(buffer, sizeof(buffer),
"Host: %s:%d\r\n\r\n", conn->addr, conn->port);
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); bytes_to_send = g_snprintf(buffer, sizeof(buffer), "\r\n");
- ret = nm_tcp_write(conn, buffer, bytes_to_send);
+ ret = g_output_stream_write(conn->output, buffer, bytes_to_send, + user->cancellable, NULL); @@ -426,12 +364,13 @@
/* Send the request to the server */
- rc = nm_write_fields(conn, request_fields);
+ rc = nm_write_fields(user, request_fields); /* Write the CRLF to terminate the data */
- ret = nm_tcp_write(conn, "\r\n", strlen("\r\n"));
+ ret = g_output_stream_write(conn->output, "\r\n", strlen("\r\n"), + user->cancellable, NULL); @@ -457,22 +396,24 @@
-nm_read_header(NMConn * conn)
+nm_read_header(NMUser *user)
- rc = read_line(conn, buffer, sizeof(buffer));
+ g_return_val_if_fail(user != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(conn != NULL, NMERR_BAD_PARM); + buffer = g_data_input_stream_read_line(conn->input, NULL, user->cancellable, /* Find the return code */
ptr = strchr(buffer, ' ');
@@ -493,8 +434,19 @@
/* Finish reading header, in the future we might want to do more processing here */
/* TODO: handle more general redirects in the future */
- while ((rc == NM_OK) && (!purple_strequal(buffer, "\r\n"))) {
- rc = read_line(conn, buffer, sizeof(buffer));
+ while ((error == NULL) && !purple_strequal(buffer, "\r")) { + buffer = g_data_input_stream_read_line(conn->input, NULL, + user->cancellable, &error); + if (error->code != G_IO_ERROR_WOULD_BLOCK && + error->code != G_IO_ERROR_CANCELLED) { if (rc == NM_OK && rtn_code == 301)
@@ -504,8 +456,9 @@
-nm_read_fields(NMConn * conn, int count, NMField ** fields)
+nm_read_fields(NMUser *user, int count, NMField **fields) @@ -513,9 +466,12 @@
NMField *sub_fields = NULL;
- if (conn == NULL || fields == NULL)
+ g_return_val_if_fail(user != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(conn != NULL, NMERR_BAD_PARM); + g_return_val_if_fail(fields != NULL, NMERR_BAD_PARM); @@ -523,36 +479,46 @@
/* Read the field type, method, and tag */
- rc = nm_read_all(conn, (char *)&type, sizeof(type));
- if (rc != NM_OK || type == 0)
+ type = g_data_input_stream_read_byte(conn->input, user->cancellable, + if (error != NULL || type == 0) { - rc = nm_read_all(conn, (char *)&method, sizeof(method));
+ method = g_data_input_stream_read_byte(conn->input, user->cancellable, - rc = nm_read_uint32(conn, &val);
+ val = g_data_input_stream_read_uint32(conn->input, user->cancellable, - rc = nm_read_all(conn, tag, val);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), tag, val, NULL, + user->cancellable, &error); if (type == NMFIELD_TYPE_MV || type == NMFIELD_TYPE_ARRAY) {
/* Read the subarray (first read the number of items in the array) */
- rc = nm_read_uint32(conn, &val);
+ val = g_data_input_stream_read_uint32(conn->input, + user->cancellable, &error); - rc = nm_read_fields(conn, val, &sub_fields);
+ rc = nm_read_fields(user, val, &sub_fields); @@ -565,9 +531,11 @@
} else if (type == NMFIELD_TYPE_UTF8 || type == NMFIELD_TYPE_DN) {
/* Read the string (first read the length) */
- rc = nm_read_uint32(conn, &val);
+ val = g_data_input_stream_read_uint32(conn->input, + user->cancellable, &error); if (val >= NMFIELD_MAX_STR_LENGTH) {
@@ -577,9 +545,11 @@
str = g_new0(char, val + 1);
- rc = nm_read_all(conn, str, val);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), str, val, + NULL, user->cancellable, &error); *fields = nm_field_add_pointer(*fields, tag, 0, method,
@@ -589,9 +559,11 @@
/* Read the numerical value */
- rc = nm_read_uint32(conn, &val);
+ val = g_data_input_stream_read_uint32(conn->input, + user->cancellable, &error); *fields = nm_field_add_number(*fields, tag, 0, method,
@@ -605,6 +577,13 @@
nm_free_fields(&sub_fields);
+ if (error->code != G_IO_ERROR_WOULD_BLOCK && error->code != G_IO_ERROR_CANCELLED) { --- a/libpurple/protocols/novell/nmconn.h Sat Nov 02 23:02:26 2019 -0400
+++ b/libpurple/protocols/novell/nmconn.h Sun Nov 03 20:27:37 2019 -0500
@@ -49,7 +49,7 @@
/* Connections to server. */
+ GDataInputStream *input; @@ -73,64 +73,9 @@
void nm_release_conn(NMConn *conn);
- * Write len bytes from the given buffer.
- * @param conn The connection to write to.
- * @param buff The buffer to write from.
- * @param len The number of bytes to write.
- * @return The number of bytes written.
-int nm_tcp_write(NMConn * conn, const void *buff, int len);
- * Read at most len bytes into the given buffer.
- * @param conn The connection to read from.
- * @param buff The buffer to write to.
- * @param len The maximum number of bytes to read.
- * @return The number of bytes read.
-int nm_tcp_read(NMConn * conn, void *buff, int len);
- * Read exactly len bytes into the given buffer.
- * @param conn The connection to read from.
- * @param buff The buffer to write to.
- * @param len The number of bytes to read.
- * @return NM_OK on success, NMERR_TCP_READ if read fails.
-NMERR_T nm_read_all(NMConn * conn, char *buf, int len);
- * Read a 32 bit value and convert it to the host byte order.
- * @param conn The connection to read from.
- * @param val A pointer to unsigned 32 bit integer
- * @return NM_OK on success, NMERR_TCP_READ if read fails.
-nm_read_uint32(NMConn *conn, guint32 *val);
- * Read a 16 bit value and convert it to the host byte order.
- * @param conn The connection to read from.
- * @param val A pointer to unsigned 16 bit integer
- * @return NM_OK on success, NMERR_TCP_READ if read fails.
-nm_read_uint16(NMConn *conn, guint16 *val);
* Dispatch a request to the server.
- * @param conn The connection.
+ * @param user The logged-in user. * @param cmd The request to dispatch.
* @param fields The field list for the request.
* @param cb The response callback for the new request object.
@@ -140,32 +85,32 @@
* @return NM_OK on success.
-nm_send_request(NMConn *conn, char *cmd, NMField *fields,
- nm_response_cb cb, gpointer data, NMRequest **request);
+nm_send_request(NMUser *user, char *cmd, NMField *fields, nm_response_cb cb, + gpointer data, NMRequest **request); * Write out the given field list.
- * @param conn The connection to write to.
+ * @param user The logged-in user. * @param fields The field list to write.
* @return NM_OK on success.
-NMERR_T nm_write_fields(NMConn * conn, NMField * fields);
+NMERR_T nm_write_fields(NMUser *user, NMField *fields); * Read the headers for a response.
- * @param conn The connection to read from.
+ * @param user The logged-in user. * @return NM_OK on success.
-NMERR_T nm_read_header(NMConn * conn);
+NMERR_T nm_read_header(NMUser *user); * Read a field list from the connection.
- * @param conn The connection to read from.
+ * @param user The logged-in user. * @param count The maximum number of fields to read (or -1 for no max).
* @param fields The field list. This is an out param. It
* should be freed by calling nm_free_fields
@@ -173,7 +118,7 @@
* @return NM_OK on success.
-NMERR_T nm_read_fields(NMConn * conn, int count, NMField ** fields);
+NMERR_T nm_read_fields(NMUser *user, int count, NMField **fields); * Add a request to the connections request list.
--- a/libpurple/protocols/novell/nmevent.c Sat Nov 02 23:02:26 2019 -0400
+++ b/libpurple/protocols/novell/nmevent.c Sun Nov 03 20:27:37 2019 -0500
@@ -144,31 +144,43 @@
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); /* Read the conference flags */
- rc = nm_read_uint32(conn, &flags);
+ flags = g_data_input_stream_read_uint32(conn->input, user->cancellable, /* Read the message text */
- rc = nm_read_uint32(conn, &size);
- if (size > 100000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
msg = g_new0(char, size + 1);
- rc = nm_read_all(conn, msg, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), msg, size, + NULL, user->cancellable, &error); purple_debug(PURPLE_DEBUG_INFO, "novell", "Message is %s\n", msg);
@@ -194,6 +206,16 @@
+ if (error->code == G_IO_ERROR_CANCELLED) { /* Check to see if we already know about the conference */
conference = nm_conference_list_find(user, guid);
@@ -260,31 +282,42 @@
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); /* Read the the message */
- rc = nm_read_uint32(conn, &size);
- if (size > 100000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
msg = g_new0(char, size + 1);
- rc = nm_read_all(conn, msg, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), msg, size, + NULL, user->cancellable, &error); /* Store the event data */
NMConference *conference;
nm_event_set_text(event, msg);
@@ -316,6 +349,11 @@
nm_release_conference(conference);
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -336,16 +374,32 @@
NMConference *conference;
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); + if (error->code == G_IO_ERROR_CANCELLED) { conference = nm_conference_list_find(user, guid);
@@ -387,25 +441,36 @@
NMConference *conference;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
- guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
+ guid = g_new0(char, size + 1); + g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); conference = nm_conference_list_find(user, guid);
nm_event_set_conference(event, conference);
rc = NMERR_CONFERENCE_NOT_FOUND;
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -425,24 +490,31 @@
NMConference *conference;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); /* Read the conference flags */
- rc = nm_read_uint32(conn, &flags);
+ flags = g_data_input_stream_read_uint32(conn->input, user->cancellable,
conference = nm_conference_list_find(user, guid);
nm_event_set_conference(event, conference);
@@ -456,6 +528,11 @@
rc = NMERR_CONFERENCE_NOT_FOUND;
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -474,19 +551,25 @@
NMConference *conference;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
- guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
+ guid = g_new0(char, size + 1); + g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); conference = nm_conference_list_find(user, guid);
nm_event_set_conference(event, conference);
@@ -494,6 +577,11 @@
rc = NMERR_CONFERENCE_NOT_FOUND;
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -513,24 +601,31 @@
NMConference *conference;
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); /* Read the conference flags */
- rc = nm_read_uint32(conn, &flags);
+ flags = g_data_input_stream_read_uint32(conn->input, user->cancellable,
conference = nm_conference_list_find(user, guid);
nm_conference_set_flags(conference, flags);
@@ -555,6 +650,11 @@
rc = NMERR_CONFERENCE_NOT_FOUND;
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -571,25 +671,36 @@
NMConference *conference;
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
- guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
+ guid = g_new0(char, size + 1); + g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, NULL, + user->cancellable, &error); conference = nm_conference_list_find(user, guid);
nm_event_set_conference(event, conference);
rc = NMERR_CONFERENCE_NOT_FOUND;
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -609,24 +720,31 @@
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
- rc = nm_read_uint16(conn, &status);
+ status = g_data_input_stream_read_uint16(conn->input, user->cancellable, /* Read the status text */
- rc = nm_read_uint32(conn, &size);
- if (size > 10000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
text = g_new0(char, size + 1);
- rc = nm_read_all(conn, text, size);
+ g_input_stream_read_all(G_INPUT_STREAM(conn->input), text, size, + NULL, user->cancellable, &error);
nm_event_set_text(event, text);
/* Get a reference to the user record and store the new status */
@@ -635,6 +753,11 @@
nm_event_set_user_record(event, user_record);
nm_user_record_set_status(user_record, status, text);
+ if (error->code != G_IO_ERROR_CANCELLED) { @@ -650,16 +773,27 @@
conn = nm_user_get_conn(user);
/* Read the conference guid */
- rc = nm_read_uint32(conn, &size);
- if (size > 1000) return NMERR_PROTOCOL;
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable,
guid = g_new0(char, size + 1);
- rc = nm_read_all(conn, guid, size);
+ rc = g_input_stream_read_all(G_INPUT_STREAM(conn->input), guid, size, + NULL, user->cancellable, &error); + if (error->code != G_IO_ERROR_CANCELLED) { @@ -803,6 +937,7 @@
@@ -813,20 +948,22 @@
conn = nm_user_get_conn(user);
/* Read the event source */
- rc = nm_read_uint32(conn, &size);
+ size = g_data_input_stream_read_uint32(conn->input, user->cancellable, /* Size is larger than our 1MB sanity check. Ignore it. */
source = g_new0(char, size);
- rc = nm_read_all(conn, source, size);
+ rc = g_input_stream_read_all(G_INPUT_STREAM(conn->input), source, + size, NULL, user->cancellable, &error); /* Read the event data */
event = nm_create_event(type, source, time(0));
@@ -901,6 +1038,11 @@
+ if (error->code != G_IO_ERROR_CANCELLED) { --- a/libpurple/protocols/novell/nmuser.c Sat Nov 02 23:02:26 2019 -0400
+++ b/libpurple/protocols/novell/nmuser.c Sun Nov 03 20:27:37 2019 -0500
@@ -139,7 +139,7 @@
- rc = nm_send_request(user->conn, "login", fields, callback, data, NULL);
+ rc = nm_send_request(user, "login", fields, callback, data, NULL); @@ -172,7 +172,7 @@
- rc = nm_send_request(user->conn, "setstatus", fields, callback, data, NULL);
+ rc = nm_send_request(user, "setstatus", fields, callback, data, NULL); @@ -195,7 +195,7 @@
g_strdup(node->data), NMFIELD_TYPE_UTF8);
- rc = nm_send_request(user->conn, "getdetails", fields, callback, data, NULL);
+ rc = nm_send_request(user, "getdetails", fields, callback, data, NULL); @@ -229,7 +229,7 @@
- rc = nm_send_request(user->conn, "getdetails", fields, callback, data, NULL);
+ rc = nm_send_request(user, "getdetails", fields, callback, data, NULL); @@ -281,7 +281,7 @@
- rc = nm_send_request(user->conn, "createconf", fields, callback, data, &req);
+ rc = nm_send_request(user, "createconf", fields, callback, data, &req); if (rc == NM_OK && req) {
nm_conference_add_ref(conference);
nm_request_set_data(req, conference);
@@ -317,7 +317,7 @@
/* Send the request to the server */
- rc = nm_send_request(user->conn, "leaveconf", fields, callback, data, &req);
+ rc = nm_send_request(user, "leaveconf", fields, callback, data, &req); nm_request_set_data(req, conference);
@@ -350,7 +350,7 @@
/* Send the request to the server */
- rc = nm_send_request(user->conn, "joinconf", fields, callback, data, &req);
+ rc = nm_send_request(user, "joinconf", fields, callback, data, &req); nm_request_set_data(req, conference);
@@ -384,7 +384,7 @@
/* Send the request to the server */
- rc = nm_send_request(user->conn, "rejectconf", fields, callback, data, &req);
+ rc = nm_send_request(user, "rejectconf", fields, callback, data, &req); nm_request_set_data(req, conference);
@@ -428,7 +428,7 @@
g_strdup(message), NMFIELD_TYPE_UTF8);
/* Send the request to the server */
- rc = nm_send_request(user->conn, "sendinvite", fields, callback, data, &req);
+ rc = nm_send_request(user, "sendinvite", fields, callback, data, &req); nm_request_set_data(req, conference);
@@ -505,7 +505,7 @@
- rc = nm_send_request(user->conn, "sendmessage", fields, callback, NULL, NULL);
+ rc = nm_send_request(user, "sendmessage", fields, callback, NULL, NULL); @@ -545,7 +545,7 @@
tmp, NMFIELD_TYPE_ARRAY);
- rc = nm_send_request(user->conn, "sendtyping", fields, callback, NULL, NULL);
+ rc = nm_send_request(user, "sendtyping", fields, callback, NULL, NULL); @@ -596,7 +596,7 @@
g_strdup(display_name), NMFIELD_TYPE_UTF8);
/* Dispatch the request */
- rc = nm_send_request(user->conn, "createcontact", fields, callback, data, &req);
+ rc = nm_send_request(user, "createcontact", fields, callback, data, &req); nm_request_set_data(req, contact);
@@ -631,7 +631,7 @@
/* Dispatch the request */
- rc = nm_send_request(user->conn, "deletecontact", fields, callback, data, &req);
+ rc = nm_send_request(user, "deletecontact", fields, callback, data, &req); nm_request_set_data(req, contact);
@@ -669,7 +669,7 @@
g_strdup("-1"), NMFIELD_TYPE_UTF8);
/* Dispatch the request */
- rc = nm_send_request(user->conn, "createfolder", fields, callback, data, &req);
+ rc = nm_send_request(user, "createfolder", fields, callback, data, &req); nm_request_set_data(req, g_strdup(name));
@@ -698,7 +698,7 @@
/* Dispatch the request */
- rc = nm_send_request(user->conn, "deletecontact", fields, callback, data, &req);
+ rc = nm_send_request(user, "deletecontact", fields, callback, data, &req); nm_request_set_data(req, folder);
@@ -730,7 +730,7 @@
g_strdup(dn), NMFIELD_TYPE_UTF8);
/* Dispatch the request */
- rc = nm_send_request(user->conn, "getstatus", fields, callback, data, &req);
+ rc = nm_send_request(user, "getstatus", fields, callback, data, &req); nm_request_set_data(req, user_record);
@@ -779,7 +779,8 @@
0, fields, NMFIELD_TYPE_ARRAY);
- rc = nm_send_request(user->conn, "updateitem", list, callback, data, &req);
+ rc = nm_send_request(user, "updateitem", list, callback, data, nm_request_set_data(req, contact);
@@ -832,7 +833,8 @@
0, fields, NMFIELD_TYPE_ARRAY);
- rc = nm_send_request(user->conn, "updateitem", list, callback, data, &req);
+ rc = nm_send_request(user, "updateitem", list, callback, data, nm_request_set_data(req, folder);
@@ -881,7 +883,7 @@
/* Dispatch the request */
- rc = nm_send_request(user->conn, "movecontact", list, callback, data, &req);
+ rc = nm_send_request(user, "movecontact", list, callback, data, &req); nm_request_set_data(req, contact);
@@ -916,7 +918,7 @@
fields = nm_field_add_pointer(fields, tag, 0, NMFIELD_METHOD_ADD, 0,
g_strdup(who), NMFIELD_TYPE_UTF8);
- rc = nm_send_request(user->conn, "createblock", fields, callback, data, NULL);
+ rc = nm_send_request(user, "createblock", fields, callback, data, NULL); @@ -950,7 +952,7 @@
fields = nm_field_add_pointer(fields, tag, 0, NMFIELD_METHOD_DELETE, 0,
g_strdup(dn), NMFIELD_TYPE_DN);
- rc = nm_send_request(user->conn, "updateblocks", fields, callback, data, NULL);
+ rc = nm_send_request(user, "updateblocks", fields, callback, data, NULL); @@ -971,7 +973,7 @@
(default_deny ? g_strdup("1") : g_strdup("0")),
- rc = nm_send_request(user->conn, "updateblocks", fields, callback, data, NULL);
+ rc = nm_send_request(user, "updateblocks", fields, callback, data, NULL); @@ -985,7 +987,7 @@
- rc = nm_send_request(user->conn, "ping", NULL, callback, data, NULL);
+ rc = nm_send_request(user, "ping", NULL, callback, data, NULL); @@ -996,6 +998,7 @@
@@ -1003,18 +1006,22 @@
/* Check to see if this is an event or a response */
- rc = nm_read_all(conn, (char *) &val, sizeof(val));
- if (strncmp((char *) &val, "HTTP", strlen("HTTP")) == 0)
+ val = g_data_input_stream_read_uint32(conn->input, user->cancellable, + if (val == ('H' + ('T' << 8) + ('T' << 16) + ('P' << 24))) { rc = nm_process_response(user);
- rc = nm_process_event(user, GUINT32_FROM_LE(val));
+ rc = nm_process_event(user, val);
+ if (error->code == G_IO_ERROR_WOULD_BLOCK || error->code == G_IO_ERROR_CANCELLED) { + /* Try again later or ignore. */
@@ -1757,9 +1764,9 @@
NMConn *conn = user->conn;
- rc = nm_read_header(conn);
+ rc = nm_read_header(user); - rc = nm_read_fields(conn, -1, &fields);
+ rc = nm_read_fields(user, -1, &fields);