diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/ChangeLog musictracker-read-only/ChangeLog --- musictracker-0.4.1/ChangeLog 2007-05-16 06:42:45.000000000 +0100 +++ musictracker-read-only/ChangeLog 2008-07-10 15:24:46.000000000 +0100 @@ -1,9 +1,18 @@ ChangeLog for MusicTracker Pidgin Plugin -======================================- +2008-07-10 (Version 0.4.2 unofficial) + * Fix finding window for Foobar2000 0.9.5.3 and later + * Don't crash if track info from player isn't valid UTF-8! + * Get UTF-8 track info from iTunes and WMP + * Avoid damaging valid UTF-8 track info when removing unprintable characters + * If the track info message is empty, try to restore the status message selected in UI (e.g. for when your player stopped message is empty) + * Remove use of modified MSN protocol plugin to append now-playing info to nickname (I suggest you use msn-pecan which supports personal messages) + * Fixed to build with latest purple + 2007-05-16 (Version 0.4.1) * Added Banshee and Quod Libet support - * Fixed bug that caused disable option to not workk for MSN + * Fixed bug that caused disable option to not work for MSN * Disabling musictracker for a protocol now clears the previous status set by musictracker. Also works for Tools->MusicTracker->Toggle Status Changing diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/filter.c musictracker-read-only/src/filter.c --- musictracker-0.4.1/src/filter.c 2007-05-12 20:33:32.000000000 +0100 +++ musictracker-read-only/src/filter.c 2008-07-10 14:15:24.000000000 +0100 @@ -38,10 +38,17 @@ g_free(stri); // Remove unprintable chars - for (; *str != 0; ++str) { - if (!isprint(*str)) - *str = mask; - } + while (*str != 0) + { + gunichar c = g_utf8_get_char(str); + gchar *next = g_utf8_next_char(str); + if (!g_unichar_isprint(c)) + { + for (; str < next; str++) + *str = mask; + } + str = next; + } } const char* diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/foobar2000.c musictracker-read-only/src/foobar2000.c --- musictracker-0.4.1/src/foobar2000.c 2007-05-12 20:33:32.000000000 +0100 +++ musictracker-read-only/src/foobar2000.c 2008-07-10 13:21:55.000000000 +0100 @@ -1,13 +1,15 @@ #include "musictracker.h" #include "utils.h" #include -#include get_foobar2000_info(struct TrackInfo* ti) { - HWND mainWindow = FindWindow("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}/1", NULL); + // very brittle way of finding the foobar2000 window... + HWND mainWindow = FindWindow("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}/1", NULL); // Foobar 0.9.1 if (!mainWindow) - FindWindow("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}", NULL); + mainWindow = FindWindow("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}", NULL); + if (!mainWindow) + mainWindow = FindWindow("{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}", NULL); // Foobar 0.9.5.3 if (!mainWindow) { trace("Failed to find foobar2000 window. Assuming player is off"); ti->status = STATUS_OFF; @@ -22,7 +24,8 @@ } */ - char title[STRLEN*5], status[200]; + char title[STRLEN*5]; + // char status[200]; GetWindowText(mainWindow, title, STRLEN*5); trace("Got window title: %s", title); //SendMessage(statusWindow, SB_GETTEXT, (WPARAM) 0, (LPARAM) status); diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/itunes.cpp musictracker-read-only/src/itunes.cpp --- musictracker-0.4.1/src/itunes.cpp 2008-07-10 13:22:15.000000000 +0100 +++ musictracker-read-only/src/itunes.cpp 2008-07-10 13:43:32.000000000 +0100 @@ -1,4 +1,4 @@ -?extern "C" { +extern "C" { #include "musictracker.h" #include "utils.h" #include @@ -7,7 +7,7 @@ #define BSTR_GET(bstr, dest) \ if (bstr != NULL) { \ - WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) bstr, -1, dest, STRLEN, NULL, NULL); \ + WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) bstr, -1, dest, STRLEN, NULL, NULL); \ SysFreeString(bstr); \ } diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/Makefile.mingw musictracker-read-only/src/Makefile.mingw --- musictracker-0.4.1/src/Makefile.mingw 2007-05-12 20:33:45.000000000 +0100 +++ musictracker-read-only/src/Makefile.mingw 2008-07-10 14:22:11.000000000 +0100 @@ -9,7 +9,7 @@ include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak TARGET = musictracker -DEFINES += -D_WIN32_WINNT=0x0500 '-DVERSION="0.4"' +DEFINES += -D_WIN32_WINNT=0x0500 '-DVERSION="0.4.2 (unofficial)"' CFLAGS = -g ## diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/musictracker.c musictracker-read-only/src/musictracker.c --- musictracker-0.4.1/src/musictracker.c 2007-05-16 06:13:55.000000000 +0100 +++ musictracker-read-only/src/musictracker.c 2008-07-10 13:58:06.000000000 +0100 @@ -31,17 +31,13 @@ #include "notify.h" #include "plugin.h" #include "version.h" -#include "../protocols/msn/msn.h" #include "gtkplugin.h" #define INTERVAL 10000 -#define USE_STATUS_API 1 guint g_tid; PurplePlugin *g_plugin; gboolean s_setavailable=1, s_setaway=1, g_run=1; -void (*pmsn_cmdproc_send)(MsnCmdProc *cmdproc, const char *command, - const char *format, ...); //-------------------------------------------------------------------- @@ -179,6 +175,8 @@ //-------------------------------------------------------------------- + +#if 0 msn_act_id(PurpleConnection *gc, const char *entry) { MsnCmdProc *cmdproc; @@ -208,6 +206,7 @@ purple_account_get_username(account), alias); } +#endif //-------------------------------------------------------------------- @@ -250,12 +249,14 @@ } // Music symbol; apply after filter, else it will discard the utf-8 character + // UTF-8 encoding of U+266B 'beamed eighth notes' char symbol[4]; symbol[0] = 0xE2; symbol[1] = 0x99; symbol[2] = 0xAB; symbol[3] = 0; status = put_field(status, 'm', symbol); + return status; } //-------------------------------------------------------------------- @@ -288,6 +289,19 @@ overriden = TRUE; } + const char *status_text; + + // if the status is empty, use the current status selected through the UI (if there is one) + if (strlen(text) == 0 && (purple_savedstatus_get_message(purple_savedstatus_get_current()) != 0)) + { + trace("empty player status, using current saved status...."); + status_text = purple_savedstatus_get_message(purple_savedstatus_get_current()); + } + else + { + status_text = text; + } + status = purple_account_get_active_status (account); if (status != NULL) @@ -301,55 +315,16 @@ if (b) { + // XXX: try setting tune attribute (see defect #96) + // fall back to status message if tune attribute isn't supported by account id = purple_status_get_id (status); - b = purple_status_supports_attr (status, "message"); - + b = purple_status_supports_attr (status, "message"); if ((id != NULL) && b) { - if ((text != NULL) && message_changed(text, purple_status_get_attr_string(status, "message"))) + if ((status_text != NULL) && message_changed(status_text, purple_status_get_attr_string(status, "message"))) { - trace("Setting %s status to: %s\n", - purple_account_get_username (account), text); -#if USE_STATUS_API - purple_account_set_status (account, id, TRUE, "message", text, NULL); -#else - prInfo = purple_account_get_pluginprotocolinfo (account); - - if (prInfo && prInfo->set_status && text) - { - purple_status_set_attr_string (status, "message", text); - prInfo->set_status (account, status); - } -#endif - } - } - - if (id != NULL && !b && - !strcmp(purple_account_get_protocol_id(account), "prpl-msn")) { - PurpleConnection* conn = purple_account_get_connection(account); - - if (purple_connection_get_state(conn) == PURPLE_CONNECTED) { - char *nick = purple_connection_get_display_name(conn); - - if ((text != NULL) ) - { - //purple_connection_set_display_name(conn, text); - char buf[500]; - char *nend = nick, *p; - - while (*nend != '/' && *nend != 0) ++nend; - if (*nend == '/' && nend != nick) --nend; - for (p = nick; p != nend; ++p) - *(buf+(p-nick)) = *p; - *(buf+(p-nick)) = 0; - - if (*text != 0) { - strcat(buf, " / "); - strcat(buf, text); - } - if (message_changed(buf, nick)) - msn_act_id(conn, buf); - } + trace("Setting %s status to: %s", purple_account_get_username (account), status_text); + purple_account_set_status (account, id, TRUE, "message", status_text, NULL); } } } @@ -384,7 +359,35 @@ g_list_free (head); } +//-------------------------------------------------------------------- +static void utf8_validate(const char* text) +{ + if (!g_utf8_validate(text,-1,NULL)) + { + // we expect the player-specific track info retrieval code to get the track info strings in utf-8 + // if that failed to happen, let's assume it's in the locale encoding and convert from that + char *converted_text = g_locale_to_utf8(text,-1,NULL,NULL,NULL); + if (converted_text) + { + strcpy(text, converted_text); + g_free(converted_text); + trace("Converted from locale to valid utf-8 '%s'", text); + } + else + { + // conversion from locale encoding failed + // replace invalid sequences with '?' so we end up with a valid utf-8 string + // (as required by other glib routines used by purple core) + gchar *end; + while (!g_utf8_validate(text,-1,&end)) + { + *end = '?'; + } + trace("After removal of invalid utf-8 '%s'", text); + } + } +} //-------------------------------------------------------------------- @@ -427,6 +430,11 @@ trim(ti.artist); trace("%s,%s,%s,%s,%d", ti.player, ti.artist, ti.album, ti.track, ti.status); + // ensure track information is valid utf-8 + utf8_validate(ti.album); + utf8_validate(ti.track); + utf8_validate(ti.artist); + char *status; switch (ti.status) { case STATUS_OFF: @@ -455,6 +463,7 @@ g_tid = purple_timeout_add(INTERVAL, &cb_timeout, 0); g_plugin = plugin; +#if 0 #ifndef WIN32 void* handle = dlopen("libmsn.so", RTLD_NOW); if (!handle) @@ -474,6 +483,7 @@ trace("Failed to locate msn_cmdproc_send in libmsn.dll. MSN nick change will not be available"); } #endif +#endif // custom status format for each account GList *accounts = purple_accounts_get_all(); @@ -649,7 +659,7 @@ "MusicTracker Plugin for Pidgin", "The MusicTracker Plugin allows you to customize your status message with information about currently playing song from your music player. Portions initially adopted from pidgin-currenttrack project.", - "Arijit De ", + "Jon TURNEY ", "http://code.google.com/p/musictracker", plugin_load, diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/musictracker.h musictracker-read-only/src/musictracker.h --- musictracker-0.4.1/src/musictracker.h 2007-05-16 06:15:15.000000000 +0100 +++ musictracker-read-only/src/musictracker.h 2008-07-10 13:25:00.000000000 +0100 @@ -6,7 +6,7 @@ #include #include "prefs.h" #include "plugin.h" -#include "account.h" +#include "purple.h" #define PLUGIN_ID "core-musictracker" #define STRLEN 100 diff -Naur --exclude aclocal.m4 --exclude config --exclude configure --exclude Makefile.in --exclude .svn --exclude '*~' --exclude '*.dll' --exclude '#*' --exclude '*.o' musictracker-0.4.1/src/wmp.c musictracker-read-only/src/wmp.c --- musictracker-0.4.1/src/wmp.c 2007-05-12 20:33:32.000000000 +0100 +++ musictracker-read-only/src/wmp.c 2008-07-07 19:37:30.000000000 +0100 @@ -36,7 +36,7 @@ } #define WC_GET(buf, dest) \ - WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) buf, -1, dest, STRLEN, NULL, NULL) + WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) buf, -1, dest, STRLEN, NULL, NULL) gboolean get_wmp_info(struct TrackInfo *ti) {