From 5985d08fc5c315ab753649ebdae4d05f1d7e6e52 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Sun, 11 Jan 2015 00:39:10 +0100 Subject: [PATCH 1/5] Respect destdir in public key path --- Makefile.in | 5 +++-- telegram-purple.c | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 87c4d5f..30923c8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,8 +1,9 @@ srcdir=@srcdir@ -CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ -Wall -Wextra -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC +CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ -Wall -Wextra -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC -DDESTDIR=\"@PREFIX@\" LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@ @PURPLE_LIBS@ @LIBS@ -lcrypto -rdynamic -ggdb -CPPFLAGS=@CPPFLAGS@ -DFLAGS +CPPFLAGS=@CPPFLAGS@ -DFLAGS +DESTDIR=@PREFIX@ COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} LINK_FLAGS=${LDFLAGS} diff --git a/telegram-purple.c b/telegram-purple.c index 2b95778..f915352 100755 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -63,10 +63,14 @@ #define _(m) m +#ifndef DESTDIR +#define DESTDIR +#endif + PurplePlugin *_telegram_protocol = NULL; PurpleGroup *tggroup; const char *config_dir = ".telegram-purple"; -const char *pk_path = "/etc/telegram-purple/server.pub"; +const char *pk_path = DESTDIR"/etc/telegram-purple/server.pub"; void tgprpl_login_on_connected(); void on_user_get_info (struct tgl_state *TLS, void *info_data, int success, struct tgl_user *U); From a08a267e22fa45cda15cc46c34ff34f5b8ce67f3 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Tue, 13 Jan 2015 22:10:31 +0100 Subject: [PATCH 2/5] fix compat. with centos --- telegram-purple.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/telegram-purple.c b/telegram-purple.c index f915352..6c0dc29 100755 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -99,6 +99,23 @@ static char *format_img_full (int imgstore) { return g_strdup_printf ("%s",br, imgstore); } +static char *format_size (gint64 size) { + char *sizes[] = { + "b", + "Kb", + "Mb", + "Gb", + "Pb" + }; + int base = 0; + double s = (double) size; + while (s > 1024 && base < 4) { + s /= 1024; + ++ base; + } + return g_strdup_printf ("%.1f %s, ", s, sizes[base]); +} + static char *format_service_msg (struct tgl_state *TLS, struct tgl_message *M) { assert (M && M->service); @@ -221,7 +238,7 @@ static char *format_print_name (struct tgl_state *TLS, tgl_peer_id_t id, const c } static char *format_document_desc (char *type, char *caption, gint64 size) { - char *s = g_format_size (size); + char *s = format_size (size); char *msg = g_strdup_printf ("[%s] %s %s", type, caption, s); g_free (s); return msg; @@ -767,7 +784,7 @@ static void tgprpl_tooltip_text (PurpleBuddy * buddy, PurpleNotifyUserInfo * inf tgl_peer_id_t *peer = purple_buddy_get_protocol_data(buddy); if (!peer) { - purple_notify_user_info_add_pair_plaintext(info, "Status", "Offline"); + purple_notify_user_info_add_pair (info, "Status", "Offline"); return; } tgl_peer_t *P = tgl_peer_get (get_conn_from_buddy (buddy)->TLS, *peer); @@ -775,8 +792,8 @@ static void tgprpl_tooltip_text (PurpleBuddy * buddy, PurpleNotifyUserInfo * inf warning ("tgprpl_tooltip_text: warning peer with id %d not found in tree.\n", peer->id); return; } - purple_notify_user_info_add_pair_plaintext (info, "Status", format_status(&P->user.status)); - purple_notify_user_info_add_pair_plaintext (info, "Last seen: ", format_time(P->user.status.when)); + purple_notify_user_info_add_pair (info, "Status", format_status(&P->user.status)); + purple_notify_user_info_add_pair (info, "Last seen: ", format_time(P->user.status.when)); } static GList *tgprpl_status_types (PurpleAccount * acct) { From 977947a3570ba58187c4e858cf3dbcee65aa1788 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Mon, 19 Jan 2015 23:26:02 +0100 Subject: [PATCH 3/5] Revert "Respect destdir in public key path" This reverts commit 5985d08fc5c315ab753649ebdae4d05f1d7e6e52. --- Makefile.in | 5 ++--- telegram-purple.c | 6 +----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index 30923c8..87c4d5f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,9 +1,8 @@ srcdir=@srcdir@ -CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ -Wall -Wextra -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC -DDESTDIR=\"@PREFIX@\" +CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ -Wall -Wextra -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@ @PURPLE_LIBS@ @LIBS@ -lcrypto -rdynamic -ggdb -CPPFLAGS=@CPPFLAGS@ -DFLAGS -DESTDIR=@PREFIX@ +CPPFLAGS=@CPPFLAGS@ -DFLAGS COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} LINK_FLAGS=${LDFLAGS} diff --git a/telegram-purple.c b/telegram-purple.c index 71ec838..2b95215 100755 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -64,14 +64,10 @@ #define _(m) m -#ifndef DESTDIR -#define DESTDIR -#endif - PurplePlugin *_telegram_protocol = NULL; PurpleGroup *tggroup; const char *config_dir = ".telegram-purple"; -const char *pk_path = DESTDIR"/etc/telegram-purple/server.pub"; +const char *pk_path = "/etc/telegram-purple/server.pub"; void tgprpl_login_on_connected(); void on_user_get_info (struct tgl_state *TLS, void *info_data, int success, struct tgl_user *U); From 6ba649fdba42954a15b34d9d0e537f02a7e3437d Mon Sep 17 00:00:00 2001 From: mjentsch Date: Mon, 19 Jan 2015 23:45:10 +0100 Subject: [PATCH 4/5] Remove functions unsupported in old glib versions --- telegram-base.c | 4 ++-- tgp-structs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-base.c b/telegram-base.c index 1b575f3..1b1d4d2 100644 --- a/telegram-base.c +++ b/telegram-base.c @@ -544,8 +544,8 @@ PurpleConversation *chat_show (PurpleConnection *gc, int id) { PurpleConversation *convo = purple_find_chat(gc, id); if (! convo) { gchar *name = g_strdup_printf ("%d", id); - if (! g_hash_table_contains (conn->joining_chats, name)) { - g_hash_table_insert(conn->joining_chats, name, 0); + if (! g_hash_table_lookup (conn->joining_chats, name)) { + g_hash_table_insert (conn->joining_chats, name, (void *)1); tgl_do_get_chat_info (conn->TLS, TGL_MK_CHAT(id), 0, on_chat_get_info, NULL); } else { g_free(name); diff --git a/tgp-structs.c b/tgp-structs.c index 138e777..3ddb012 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -104,7 +104,7 @@ connection_data *connection_data_init (struct tgl_state *TLS, PurpleConnection * conn->pa = pa; conn->new_messages = g_queue_new (); conn->pending_reads = g_queue_new (); - conn->joining_chats = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + conn->joining_chats = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); return conn; } From 7ef16481803ffa951dc0ea5cc14d3b80b5e17a7b Mon Sep 17 00:00:00 2001 From: mjentsch Date: Tue, 20 Jan 2015 00:23:32 +0100 Subject: [PATCH 5/5] Remove more functions unsupported in old glib versions --- tgp-structs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tgp-structs.c b/tgp-structs.c index 3ddb012..2588108 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -90,6 +90,16 @@ static void used_image_free (gpointer data) debug ("used_image: unref %d", id); } +static void queue_free_full (GQueue *queue, GDestroyNotify free_func) +{ + void *entry; + + while ((entry = g_queue_pop_head(queue))) { + free_func (entry); + } + g_queue_free (queue); +} + void used_images_add (connection_data *data, gint imgid) { data->used_images = g_list_append (data->used_images, GINT_TO_POINTER(imgid)); @@ -111,8 +121,8 @@ connection_data *connection_data_init (struct tgl_state *TLS, PurpleConnection * void *connection_data_free (connection_data *conn) { purple_timeout_remove(conn->timer); - g_queue_free_full (conn->pending_reads, pending_reads_free_cb); - g_queue_free_full (conn->new_messages, message_text_free); + queue_free_full (conn->pending_reads, pending_reads_free_cb); + queue_free_full (conn->new_messages, message_text_free); g_hash_table_destroy (conn->joining_chats); g_list_free_full (conn->used_images, used_image_free); tgl_free_all (conn->TLS);