summary refs log tree commit diff stats
path: root/plugins/winamp
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2015-04-13 16:15:07 -0400
committerTingPing <tingping@tingping.se>2015-04-13 16:25:36 -0400
commit72d7f64f8b47049842799ae7d5fe9d598922b3ab (patch)
tree0183e58f237bce0b58859db82cab5907d5fe22e4 /plugins/winamp
parentc86389f99b17bb5bdc40a92f54f85f5c2ef2b2d6 (diff)
winamp: Fix utf8 song titles
Fixes #1350
Diffstat (limited to 'plugins/winamp')
-rw-r--r--plugins/winamp/winamp.c19
-rw-r--r--plugins/winamp/winamp.vcxproj17
2 files changed, 19 insertions, 17 deletions
diff --git a/plugins/winamp/winamp.c b/plugins/winamp/winamp.c
index 389adcbc..9b3b4335 100644
--- a/plugins/winamp/winamp.c
+++ b/plugins/winamp/winamp.c
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <glib.h>
 
 #include "hexchat-plugin.h"
 
@@ -50,11 +51,12 @@ static int
 winamp(char *word[], char *word_eol[], void *userdata)
 {
 
-char current_play[2048], *p;
+wchar_t wcurrent_play[2048];
+char *current_play, *p;
 char p_esc[2048];
 char cur_esc[2048];
 char truc[2048];
-HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
+HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
 
     if (hwndWinamp)
 	{
@@ -109,7 +111,14 @@ HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
 
                 if (!word_eol[2][0])
 			    {
-					GetWindowText(hwndWinamp, current_play, sizeof(current_play));
+					int len = GetWindowTextW(hwndWinamp, wcurrent_play, sizeof(wcurrent_play));
+
+					current_play = g_utf16_to_utf8 (wcurrent_play, len, NULL, NULL, NULL);
+					if (!current_play)
+					{
+						hexchat_print (ph, "Winamp: Error getting song information.");
+						return HEXCHAT_EAT_ALL;
+					}
 
 					if (strchr(current_play, '-'))
 					{
@@ -142,7 +151,7 @@ HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);
 					}
 	
 	   				hexchat_commandf(ph, truc);
-	
+					g_free (current_play);
 				}
 				else hexchat_print(ph, "Winamp: Nothing being played.");
 			}
@@ -170,7 +179,7 @@ hexchat_plugin_init(hexchat_plugin *plugin_handle,
 
 	*plugin_name = "Winamp";
 	*plugin_desc = "Winamp plugin for HexChat";
-	*plugin_version = "0.5";
+	*plugin_version = "0.6";
 
 	hexchat_hook_command (ph, "WINAMP", HEXCHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
    	hexchat_command (ph, "MENU -ishare\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");
diff --git a/plugins/winamp/winamp.vcxproj b/plugins/winamp/winamp.vcxproj
index b325c40d..e6289edc 100644
--- a/plugins/winamp/winamp.vcxproj
+++ b/plugins/winamp/winamp.vcxproj
@@ -27,22 +27,15 @@
     <TargetName>hcwinamp</TargetName>

     <OutDir>$(HexChatRel)plugins\</OutDir>

   </PropertyGroup>

-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

-    <ClCompile>

-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

-    </ClCompile>

-    <Link>

-      <ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>

-    </Link>

-  </ItemDefinitionGroup>

-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

+  <ItemDefinitionGroup>

     <ClCompile>

       <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

     </ClCompile>

     <Link>

       <ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>

+      <AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>

+      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

     </Link>

   </ItemDefinitionGroup>

   <ItemGroup>

@@ -52,4 +45,4 @@
     <ClCompile Include="winamp.c" />

   </ItemGroup>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

-</Project>

+</Project>
\ No newline at end of file