/soc/2015/mmcc/main: 771673aea4ea: convert macro to helper function
Michael McConville
mmcconville at mykolab.com
Tue Jun 23 16:02:34 EDT 2015
Changeset: 771673aea4eae3881b0263abb9e2256f38eca70b
Author: Michael McConville <mmcconville at mykolab.com>
Date: 2015-06-20 12:48 -0400
Branch: default
URL: https://hg.pidgin.im/soc/2015/mmcc/main/rev/771673aea4ea
Description:
convert macro to helper function
diffstat:
libpurple/protocols/jabber/jabber.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diffs (82 lines):
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2668,8 +2668,12 @@ char *jabber_parse_error(JabberStream *j
const char *xmlns = purple_xmlnode_get_namespace(packet);
char *cdata = NULL;
-#define SET_REASON(x) \
- if(reason != NULL) { *reason = x; }
+static void
+set_reason(PurpleConnectionError x) {
+ if (reason != NULL) {
+ *reason = x;
+ }
+}
if((error = purple_xmlnode_get_child(packet, "error"))) {
PurpleXmlNode *t = purple_xmlnode_get_child_with_namespace(error, "text", NS_XMPP_STANZAS);
@@ -2684,7 +2688,7 @@ char *jabber_parse_error(JabberStream *j
if(purple_xmlnode_get_child(error, "bad-request")) {
text = _("Bad Request");
} else if(purple_xmlnode_get_child(error, "conflict")) {
- SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
+ set_reason(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
text = _("Conflict");
} else if(purple_xmlnode_get_child(error, "feature-not-implemented")) {
text = _("Feature Not Implemented");
@@ -2729,7 +2733,7 @@ char *jabber_parse_error(JabberStream *j
}
} else if(xmlns && !strcmp(xmlns, NS_XMPP_SASL)) {
/* Most common reason can be the default */
- SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
+ set_reason(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
if(purple_xmlnode_get_child(packet, "aborted")) {
text = _("Authorization Aborted");
} else if(purple_xmlnode_get_child(packet, "incorrect-encoding")) {
@@ -2739,10 +2743,10 @@ char *jabber_parse_error(JabberStream *j
} else if(purple_xmlnode_get_child(packet, "invalid-mechanism")) {
text = _("Invalid Authorization Mechanism");
} else if(purple_xmlnode_get_child(packet, "mechanism-too-weak")) {
- SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
+ set_reason(PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE);
text = _("Authorization mechanism too weak");
} else if(purple_xmlnode_get_child(packet, "not-authorized")) {
- SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
+ set_reason(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
/* Clear the pasword if it isn't being saved */
if (!purple_account_get_remember_password(purple_connection_get_account(js->gc)))
purple_account_set_password(purple_connection_get_account(js->gc), NULL, NULL, NULL);
@@ -2750,20 +2754,20 @@ char *jabber_parse_error(JabberStream *j
} else if(purple_xmlnode_get_child(packet, "temporary-auth-failure")) {
text = _("Temporary Authentication Failure");
} else {
- SET_REASON(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
+ set_reason(PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED);
text = _("Authentication Failure");
}
} else if(!strcmp(packet->name, "stream:error") ||
(!strcmp(packet->name, "error") && xmlns &&
!strcmp(xmlns, NS_XMPP_STREAMS))) {
/* Most common reason as default: */
- SET_REASON(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
+ set_reason(PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
if(purple_xmlnode_get_child(packet, "bad-format")) {
text = _("Bad Format");
} else if(purple_xmlnode_get_child(packet, "bad-namespace-prefix")) {
text = _("Bad Namespace Prefix");
} else if(purple_xmlnode_get_child(packet, "conflict")) {
- SET_REASON(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
+ set_reason(PURPLE_CONNECTION_ERROR_NAME_IN_USE);
text = _("Resource Conflict");
} else if(purple_xmlnode_get_child(packet, "connection-timeout")) {
text = _("Connection Timeout");
@@ -2812,8 +2816,6 @@ char *jabber_parse_error(JabberStream *j
}
}
-#undef SET_REASON
-
if(text || cdata) {
char *ret = g_strdup_printf("%s%s%s", code ? code : "",
code ? ": " : "", text ? text : cdata);
More information about the Commits
mailing list