/pidgin/main: a6223370667b: Style: fix braces for http, keyring

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon Feb 3 19:11:49 EST 2014


Changeset: a6223370667b186e5cf6544b73d09f23ae19a319
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-02-04 01:11 +0100
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/a6223370667b

Description:

Style: fix braces for http, keyring

diffstat:

 libpurple/http.c                             |  57 +++++++++++-------
 libpurple/keyring.c                          |  30 ++++++----
 libpurple/plugins/keyrings/gnomekeyring.c    |  21 ++++--
 libpurple/plugins/keyrings/internalkeyring.c |   6 +-
 libpurple/plugins/keyrings/secretservice.c   |  83 ++++++++++++++-------------
 libpurple/plugins/keyrings/wincred.c         |   3 +-
 6 files changed, 114 insertions(+), 86 deletions(-)

diffs (truncated from 528 to 300 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -290,8 +290,10 @@ static GHashTable *purple_http_hc_by_ptr
 
 static time_t purple_http_rfc1123_to_time(const gchar *str)
 {
-	static const gchar *months[13] = {"jan", "feb", "mar", "apr", "may", "jun",
-		"jul", "aug", "sep", "oct", "nov", "dec", NULL};
+	static const gchar *months[13] = {
+		"jan", "feb", "mar", "apr", "may", "jun",
+		"jul", "aug", "sep", "oct", "nov", "dec", NULL
+	};
 	GMatchInfo *match_info;
 	gchar *d_date, *d_month, *d_year, *d_time;
 	int month;
@@ -314,8 +316,7 @@ static time_t purple_http_rfc1123_to_tim
 	g_match_info_free(match_info);
 
 	month = 0;
-	while (months[month] != NULL)
-	{
+	while (months[month] != NULL) {
 		if (0 == g_ascii_strcasecmp(d_month, months[month]))
 			break;
 		month++;
@@ -584,8 +585,7 @@ static void purple_http_headers_remove(P
 
 	/* Could be optimized to O(1). */
 	it = g_list_first(hdrs->list);
-	while (it)
-	{
+	while (it) {
 		PurpleKeyValuePair *kvp = it->data;
 		curr = it;
 		it = g_list_next(it);
@@ -853,7 +853,8 @@ static gboolean _purple_http_recv_header
 	}
 
 	while ((eol = strstr(hc->response_buffer->str, "\r\n"))
-		!= NULL) {
+		!= NULL)
+	{
 		gchar *hdrline = hc->response_buffer->str;
 		int hdrline_len = eol - hdrline;
 
@@ -883,7 +884,8 @@ static gboolean _purple_http_recv_header
 			hc->main_header_got = TRUE;
 			delim = strchr(hdrline, ' ');
 			if (delim == NULL || 1 != sscanf(delim + 1, "%d",
-				&hc->response->code)) {
+				&hc->response->code))
+			{
 				purple_debug_warning("http",
 					"Invalid response code\n");
 				_purple_http_error(hc, _("Error parsing HTTP"));
@@ -1106,7 +1108,8 @@ static gboolean _purple_http_recv_loopbo
 			hc->length_expected = hc->length_got;
 		}
 		if (hc->length_expected >= 0 &&
-			hc->length_got < (guint)hc->length_expected) {
+			hc->length_got < (guint)hc->length_expected)
+		{
 			purple_debug_warning("http", "No more data while reading"
 				" contents\n");
 			_purple_http_error(hc, _("Error parsing HTTP"));
@@ -1158,15 +1161,15 @@ static gboolean _purple_http_recv_loopbo
 			is_deflate = purple_http_headers_match(
 				hc->response->headers, "Content-Encoding",
 				"deflate");
-			if (is_gzip || is_deflate)
-			{
+			if (is_gzip || is_deflate) {
 				hc->gz_stream = purple_http_gz_new(
 					hc->request->max_length + 1,
 					is_deflate);
 			}
 		}
 		if (hc->headers_got && hc->response_buffer &&
-			hc->response_buffer->len > 0) {
+			hc->response_buffer->len > 0)
+		{
 			int buffer_len = hc->response_buffer->len;
 			gchar *buffer = g_string_free(hc->response_buffer, FALSE);
 			hc->response_buffer = NULL;
@@ -1218,7 +1221,8 @@ static gboolean _purple_http_recv_loopbo
 
 		if (purple_debug_is_unsafe() && purple_debug_is_verbose() &&
 			!purple_http_cookie_jar_is_empty(
-				hc->request->cookie_jar)) {
+				hc->request->cookie_jar))
+		{
 			gchar *cookies = purple_http_cookie_jar_dump(
 				hc->request->cookie_jar);
 			purple_debug_misc("http", "Cookies: %s\n", cookies);
@@ -1233,7 +1237,8 @@ static gboolean _purple_http_recv_loopbo
 		redirect = purple_http_headers_get(hc->response->headers,
 			"location");
 		if (redirect && (hc->request->max_redirects == -1 ||
-			hc->request->max_redirects > hc->redirects_count)) {
+			hc->request->max_redirects > hc->redirects_count))
+		{
 			PurpleHttpURL *url = purple_http_url_parse(redirect);
 
 			hc->redirects_count++;
@@ -1291,7 +1296,8 @@ static void _purple_http_send_got_data(P
 	estimated_length = hc->request_contents_written + stored;
 
 	if (hc->request->contents_length != -1 &&
-		hc->request->contents_length != estimated_length) {
+		hc->request->contents_length != estimated_length)
+	{
 		purple_debug_warning("http",
 			"Invalid amount of data has been written\n");
 	}
@@ -1461,7 +1467,8 @@ static gboolean _purple_http_reconnect(P
 
 	url = hc->url;
 	if (g_strcmp0(url->protocol, "") == 0 ||
-		g_ascii_strcasecmp(url->protocol, "http") == 0) {
+		g_ascii_strcasecmp(url->protocol, "http") == 0)
+	{
 		/* do nothing */
 	} else if (g_ascii_strcasecmp(url->protocol, "https") == 0) {
 		is_ssl = TRUE;
@@ -1827,7 +1834,8 @@ static void purple_http_conn_notify_prog
 
 	now = g_get_monotonic_time();
 	if (hc->watcher_last_call + hc->watcher_interval_threshold
-		> now && processed != total) {
+		> now && processed != total)
+	{
 		if (hc->watcher_delayed_handle)
 			return;
 		hc->watcher_delayed_handle = purple_timeout_add_seconds(
@@ -1934,7 +1942,8 @@ static void purple_http_cookie_jar_parse
 		semicolon = strchr(cookie, ';');
 
 		if (eqsign == NULL || eqsign == cookie ||
-			(semicolon != NULL && semicolon < eqsign)) {
+			(semicolon != NULL && semicolon < eqsign))
+		{
 			if (purple_debug_is_unsafe())
 				purple_debug_warning("http",
 					"Invalid cookie: [%s]\n", cookie);
@@ -1990,7 +1999,8 @@ static gchar * purple_http_cookie_jar_ge
 
 	g_hash_table_iter_init(&it, cookie_jar->tab);
 	while (g_hash_table_iter_next(&it, (gpointer*)&key,
-		(gpointer*)&cookie)) {
+		(gpointer*)&cookie))
+	{
 		if (cookie->expires != -1 && cookie->expires <= now)
 			continue;
 		g_string_append_printf(str, "%s=%s; ", key, cookie->value);
@@ -2903,9 +2913,11 @@ purple_http_url_parse(const char *raw_ur
 		gchar *port_str;
 
 		if (!g_regex_match(purple_http_re_url_host, host_full, 0,
-			&match_info)) {
+			&match_info))
+		{
 			if (purple_debug_is_verbose() &&
-				purple_debug_is_unsafe()) {
+				purple_debug_is_unsafe())
+			{
 				purple_debug_warning("http",
 					"Invalid host provided for URL: %s\n",
 					raw_url);
@@ -3003,7 +3015,8 @@ purple_http_url_relative(PurpleHttpURL *
 
 	if (relative_url->path) {
 		if (relative_url->path[0] == '/' ||
-			base_url->path == NULL) {
+			base_url->path == NULL)
+		{
 			g_free(base_url->path);
 			base_url->path = g_strdup(relative_url->path);
 		} else {
diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -270,7 +270,8 @@ purple_keyring_set_inuse_save_cb(PurpleA
 	if (error == NULL) {
 		/* no error */
 	} else if (g_error_matches(error, PURPLE_KEYRING_ERROR,
-		PURPLE_KEYRING_ERROR_NOPASSWORD)) {
+		PURPLE_KEYRING_ERROR_NOPASSWORD))
+	{
 		if (purple_debug_is_verbose()) {
 			purple_debug_misc("keyring", "No password found while "
 				"changing keyring for account %s: %s.\n",
@@ -278,7 +279,8 @@ purple_keyring_set_inuse_save_cb(PurpleA
 				error->message);
 		}
 	} else if (g_error_matches(error, PURPLE_KEYRING_ERROR,
-		PURPLE_KEYRING_ERROR_ACCESSDENIED)) {
+		PURPLE_KEYRING_ERROR_ACCESSDENIED))
+	{
 		purple_debug_info("keyring", "Access denied while changing "
 			"keyring for account %s: %s.\n",
 			purple_keyring_print_account(account), error->message);
@@ -287,7 +289,8 @@ purple_keyring_set_inuse_save_cb(PurpleA
 			g_error_free(tracker->error);
 		tracker->error = g_error_copy(error);
 	} else if (g_error_matches(error, PURPLE_KEYRING_ERROR,
-		PURPLE_KEYRING_ERROR_CANCELLED)) {
+		PURPLE_KEYRING_ERROR_CANCELLED))
+	{
 		purple_debug_info("keyring", "Operation cancelled while "
 			"changing keyring for account %s: %s.\n",
 			purple_keyring_print_account(account), error->message);
@@ -295,7 +298,8 @@ purple_keyring_set_inuse_save_cb(PurpleA
 		if (tracker->error == NULL)
 			tracker->error = g_error_copy(error);
 	} else if (g_error_matches(error, PURPLE_KEYRING_ERROR,
-		PURPLE_KEYRING_ERROR_BACKENDFAIL)) {
+		PURPLE_KEYRING_ERROR_BACKENDFAIL))
+	{
 		purple_debug_error("keyring", "Failed to communicate with "
 			"backend while changing keyring for account %s: %s. "
 			"Aborting changes.\n",
@@ -349,7 +353,8 @@ purple_keyring_set_inuse_read_cb(PurpleA
 	if (error != NULL) {
 		if (tracker->force == TRUE || g_error_matches(error,
 			PURPLE_KEYRING_ERROR,
-			PURPLE_KEYRING_ERROR_NOPASSWORD)) {
+			PURPLE_KEYRING_ERROR_NOPASSWORD))
+		{
 			/* Don't save password, and ignore it. */
 		} else {
 			tracker->abort = TRUE;
@@ -464,7 +469,8 @@ purple_keyring_register(PurpleKeyring *k
 	if (purple_keyring_get_id(keyring) == NULL ||
 		purple_keyring_get_name(keyring) == NULL ||
 		purple_keyring_get_read_password(keyring) == NULL ||
-		purple_keyring_get_save_password(keyring) == NULL) {
+		purple_keyring_get_save_password(keyring) == NULL)
+	{
 		purple_debug_error("keyring", "Cannot register %s, some "
 			"required fields are missing.\n",
 			keyring_id ? keyring_id : "(null)");
@@ -479,7 +485,8 @@ purple_keyring_register(PurpleKeyring *k
 
 	/* If this is the configured keyring, use it. */
 	if (purple_keyring_inuse == NULL &&
-		g_strcmp0(keyring_id, purple_keyring_to_use) == 0) {
+		g_strcmp0(keyring_id, purple_keyring_to_use) == 0)
+	{
 		purple_debug_misc("keyring", "Keyring %s matches keyring to "
 			"use, using it.", keyring_id);
 		purple_keyring_set_inuse(keyring, TRUE, NULL, NULL);
@@ -539,7 +546,8 @@ purple_keyring_get_options(void)
 	static gchar currentDisabledName[40];
 
 	if (purple_keyring_get_inuse() == NULL && purple_keyring_to_use != NULL
-		&& purple_keyring_to_use[0] != '\0') {
+		&& purple_keyring_to_use[0] != '\0')
+	{
 		g_snprintf(currentDisabledName, sizeof(currentDisabledName),
 			_("%s (disabled)"), purple_keyring_to_use);
 
@@ -1284,8 +1292,7 @@ purple_keyring_init(void)
 
 	purple_keyring_pref_connect();
 
-	for (it = purple_plugins_get_all(); it != NULL; it = it->next)
-	{
+	for (it = purple_plugins_get_all(); it != NULL; it = it->next) {
 		PurplePlugin *plugin = (PurplePlugin *)it->data;
 
 		if (plugin->info == NULL || plugin->info->id == NULL)
@@ -1296,8 +1303,7 @@ purple_keyring_init(void)
 		if (purple_plugin_is_loaded(plugin))
 			continue;
 
-		if (purple_plugin_load(plugin))
-		{
+		if (purple_plugin_load(plugin)) {
 			purple_keyring_loaded_plugins = g_list_append(
 				purple_keyring_loaded_plugins, plugin);
 		}
diff --git a/libpurple/plugins/keyrings/gnomekeyring.c b/libpurple/plugins/keyrings/gnomekeyring.c
--- a/libpurple/plugins/keyrings/gnomekeyring.c
+++ b/libpurple/plugins/keyrings/gnomekeyring.c
@@ -102,13 +102,15 @@ gnomekeyring_read_cb(GnomeKeyringResult 
 			PURPLE_KEYRING_ERROR_NOPASSWORD,
 			_("No password found for account."));
 	} else if (result == GNOME_KEYRING_RESULT_DENIED ||
-		result == GNOME_KEYRING_RESULT_CANCELLED) {
+		result == GNOME_KEYRING_RESULT_CANCELLED)
+	{
 		error = g_error_new(PURPLE_KEYRING_ERROR,
 			PURPLE_KEYRING_ERROR_ACCESSDENIED,
 			_("Access denied."));
 		gnomekeyring_cancel_queue();
 	} else if (result == GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON ||
-		result == GNOME_KEYRING_RESULT_IO_ERROR) {
+		result == GNOME_KEYRING_RESULT_IO_ERROR)
+	{



More information about the Commits mailing list