/pidgin/main: 3be5d45ba972: Style: fix gg (partially)
Tomasz Wasilczyk
twasilczyk at pidgin.im
Mon Feb 3 15:28:12 EST 2014
Changeset: 3be5d45ba9720ab7ab86e81f40a72d020519aaf1
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-02-03 21:28 +0100
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/3be5d45ba972
Description:
Style: fix gg (partially)
diffstat:
libpurple/protocols/gg/image.c | 54 +++++++-------
libpurple/protocols/gg/libgadu-events.c | 10 +-
libpurple/protocols/gg/libgaduw.c | 22 +++--
libpurple/protocols/gg/message-prpl.c | 28 +++---
libpurple/protocols/gg/pubdir-prpl.c | 121 +++++++++++++++----------------
libpurple/protocols/gg/purplew.c | 25 +++---
libpurple/protocols/gg/purplew.h | 4 +-
7 files changed, 133 insertions(+), 131 deletions(-)
diffs (truncated from 956 to 300 lines):
diff --git a/libpurple/protocols/gg/image.c b/libpurple/protocols/gg/image.c
--- a/libpurple/protocols/gg/image.c
+++ b/libpurple/protocols/gg/image.c
@@ -96,9 +96,9 @@ void ggp_image_setup(PurpleConnection *g
{
GGPInfo *accdata = purple_connection_get_protocol_data(gc);
ggp_image_session_data *sdata = g_new0(ggp_image_session_data, 1);
-
+
accdata->image_data = sdata;
-
+
sdata->got_images = g_hash_table_new_full(
g_int64_hash, g_int64_equal, g_free,
ggp_image_got_free);
@@ -113,7 +113,7 @@ void ggp_image_setup(PurpleConnection *g
void ggp_image_cleanup(PurpleConnection *gc)
{
ggp_image_session_data *sdata = ggp_image_get_sdata(gc);
-
+
g_hash_table_destroy(sdata->got_images);
g_hash_table_destroy(sdata->incoming_images);
g_hash_table_destroy(sdata->sent_images);
@@ -130,31 +130,31 @@ ggp_image_prepare_result ggp_image_prepa
gconstpointer image_data;
uint32_t image_crc;
ggp_image_sent *sent_image;
-
+
if (!image)
{
purple_debug_error("gg", "ggp_image_prepare: image %d "
"not found in image store\n", stored_id);
return GGP_IMAGE_PREPARE_FAILURE;
}
-
+
image_size = purple_imgstore_get_size(image);
-
+
if (image_size > GGP_IMAGE_SIZE_MAX)
{
purple_debug_warning("gg", "ggp_image_prepare: image "
"is too big (max bytes: %d)\n", GGP_IMAGE_SIZE_MAX);
return GGP_IMAGE_PREPARE_TOO_BIG;
}
-
+
purple_imgstore_ref(image);
image_data = purple_imgstore_get_data(image);
image_crc = gg_crc32(0, image_data, image_size);
-
+
purple_debug_info("gg", "ggp_image_prepare: image prepared "
"[id=%d, crc=%u, size=%" G_GSIZE_FORMAT "]\n",
stored_id, image_crc, image_size);
-
+
*id = ggp_image_params_to_id(image_crc, image_size);
sent_image = g_new(ggp_image_sent, 1);
@@ -162,7 +162,7 @@ ggp_image_prepare_result ggp_image_prepa
sent_image->conv_name = g_strdup(purple_conversation_get_name(conv));
g_hash_table_insert(sdata->sent_images, ggp_uint64dup(*id),
sent_image);
-
+
return GGP_IMAGE_PREPARE_OK;
}
@@ -174,7 +174,7 @@ void ggp_image_recv(PurpleConnection *gc
ggp_image_requested *req;
GList *it;
uint64_t id;
-
+
/* TODO: This PurpleStoredImage will be rendered within the IM window
and right-clicking the image will allow the user to save the image
to disk. The default filename used in this dialog is the filename
@@ -187,9 +187,9 @@ void ggp_image_recv(PurpleConnection *gc
g_memdup(image_reply->image, image_reply->size),
image_reply->size,
image_reply->filename);
-
+
id = ggp_image_params_to_id(image_reply->crc32, image_reply->size);
-
+
purple_debug_info("gg", "ggp_image_recv: got image "
"[stored_id=%d, crc=%u, size=%u, filename=%s, id="
GGP_IMAGE_ID_FORMAT "]\n",
@@ -216,7 +216,7 @@ void ggp_image_recv(PurpleConnection *gc
{
ggp_image_requested_listener *listener = it->data;
it = g_list_next(it);
-
+
listener->cb(gc, id, stored_id, listener->user_data);
}
g_hash_table_remove(sdata->incoming_images, &id);
@@ -232,17 +232,17 @@ void ggp_image_send(PurpleConnection *gc
PurpleConversation *conv;
uint64_t id;
gchar *gg_filename;
-
+
purple_debug_info("gg", "ggp_image_send: got image request "
"[uin=%u, crc=%u, size=%u]\n",
image_request->sender,
image_request->crc32,
image_request->size);
-
+
id = ggp_image_params_to_id(image_request->crc32, image_request->size);
-
+
sent_image = g_hash_table_lookup(sdata->sent_images, &id);
-
+
if (sent_image == NULL && image_request->sender == ggp_str_to_uin(
purple_account_get_username(purple_connection_get_account(gc))))
{
@@ -256,15 +256,15 @@ void ggp_image_send(PurpleConnection *gc
"not found\n");
return;
}
-
+
purple_debug_misc("gg", "ggp_image_send: requested image found "
"[id=" GGP_IMAGE_ID_FORMAT ", stored id=%d, conv=%s]\n",
id,
sent_image->id,
sent_image->conv_name);
-
+
image = purple_imgstore_find_by_id(sent_image->id);
-
+
if (!image)
{
purple_debug_error("gg", "ggp_image_send: requested image "
@@ -273,15 +273,15 @@ void ggp_image_send(PurpleConnection *gc
GINT_TO_POINTER(image_request->crc32));
return;
}
-
- //TODO: check allowed recipients
+
+ /* TODO: check allowed recipients */
gg_filename = g_strdup_printf(GGP_IMAGE_ID_FORMAT, id);
gg_image_reply(accdata->session, image_request->sender,
gg_filename,
purple_imgstore_get_data(image),
purple_imgstore_get_size(image));
g_free(gg_filename);
-
+
conv = purple_conversations_find_with_account(
sent_image->conv_name,
purple_connection_get_account(gc));
@@ -305,7 +305,7 @@ void ggp_image_request(PurpleConnection
ggp_image_requested_listener *listener;
uint32_t crc = id >> 32;
uint32_t size = id;
-
+
if (size > GGP_IMAGE_SIZE_MAX && crc <= GGP_IMAGE_SIZE_MAX)
{
uint32_t tmp;
@@ -315,7 +315,7 @@ void ggp_image_request(PurpleConnection
crc = size;
size = tmp;
}
-
+
req = g_hash_table_lookup(sdata->incoming_images, &id);
if (!req)
{
@@ -333,7 +333,7 @@ void ggp_image_request(PurpleConnection
"image " GGP_IMAGE_ID_FORMAT " already requested\n",
id);
}
-
+
listener = g_new0(ggp_image_requested_listener, 1);
listener->cb = cb;
listener->user_data = user_data;
diff --git a/libpurple/protocols/gg/libgadu-events.c b/libpurple/protocols/gg/libgadu-events.c
--- a/libpurple/protocols/gg/libgadu-events.c
+++ b/libpurple/protocols/gg/libgadu-events.c
@@ -38,10 +38,10 @@ void ggp_events_user_data(PurpleConnecti
{
guint user_idx;
gboolean is_update;
-
+
purple_debug_info("gg", "GG_EVENT_USER_DATA [type=%d, user_count=%"
G_GSIZE_FORMAT "]\n", data->type, data->user_count);
-
+
/*
type =
1, 3: user information sent after connecting (divided by
@@ -49,7 +49,7 @@ void ggp_events_user_data(PurpleConnecti
0: data update
*/
is_update = (data->type == 0);
-
+
for (user_idx = 0; user_idx < data->user_count; user_idx++)
{
struct gg_event_user_data_user *data_user =
@@ -69,7 +69,7 @@ void ggp_events_user_data(PurpleConnecti
ggp_avatar_buddy_remove(gc, uin);
continue;
}
-
+
timestamp = atoi(data_attr->value);
if (timestamp <= 0)
continue;
@@ -77,7 +77,7 @@ void ggp_events_user_data(PurpleConnecti
ggp_avatar_buddy_update(gc, uin, timestamp);
}
}
-
+
if (!is_update && !got_avatar)
ggp_avatar_buddy_remove(gc, uin);
}
diff --git a/libpurple/protocols/gg/libgaduw.c b/libpurple/protocols/gg/libgaduw.c
--- a/libpurple/protocols/gg/libgaduw.c
+++ b/libpurple/protocols/gg/libgaduw.c
@@ -59,7 +59,7 @@ const gchar * ggp_libgaduw_version(Purpl
{
GGPInfo *accdata = purple_connection_get_protocol_data(gc);
const gchar *ver = accdata->session->client_version;
-
+
if (ver != NULL && isdigit(ver[0]))
return ver;
return GG_DEFAULT_CLIENT_VERSION;
@@ -124,7 +124,7 @@ ggp_libgaduw_http_req * ggp_libgaduw_htt
ggp_libgaduw_http_req *req;
purple_debug_misc("gg", "ggp_libgaduw_http_watch(h=%p, "
"show_processing=%d)\n", h, show_processing);
-
+
req = g_new(ggp_libgaduw_http_req, 1);
req->user_data = user_data;
req->cb = cb;
@@ -136,7 +136,7 @@ ggp_libgaduw_http_req * ggp_libgaduw_htt
req, ggp_libgaduw_http_processing_cancel);
req->inpa = ggp_purplew_http_input_add(h, ggp_libgaduw_http_handler,
req);
-
+
return req;
}
@@ -152,7 +152,7 @@ static void ggp_libgaduw_http_handler(gp
PurpleInputCondition cond)
{
ggp_libgaduw_http_req *req = _req;
-
+
if (req->h->callback(req->h) == -1 || req->h->state == GG_STATE_ERROR)
{
purple_debug_error("gg", "ggp_libgaduw_http_handler: failed to "
@@ -160,11 +160,13 @@ static void ggp_libgaduw_http_handler(gp
ggp_libgaduw_http_finish(req, FALSE);
return;
}
-
- //TODO: verbose mode
- //purple_debug_misc("gg", "ggp_libgaduw_http_handler: got fd update "
- // "[check=%d, state=%d]\n", req->h->check, req->h->state);
-
+
+ if (purple_debug_is_verbose()) {
+ purple_debug_misc("gg", "ggp_libgaduw_http_handler: got fd "
+ "update [check=%d, state=%d]\n", req->h->check,
+ req->h->state);
+ }
+
if (req->h->state != GG_STATE_DONE)
{
purple_input_remove(req->inpa);
@@ -172,7 +174,7 @@ static void ggp_libgaduw_http_handler(gp
ggp_libgaduw_http_handler, req);
return;
}
-
+
if (!req->h->data || !req->h->body)
{
purple_debug_error("gg", "ggp_libgaduw_http_handler: got empty "
diff --git a/libpurple/protocols/gg/message-prpl.c b/libpurple/protocols/gg/message-prpl.c
--- a/libpurple/protocols/gg/message-prpl.c
More information about the Commits
mailing list