1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-21 16:55:02 -05:00

winamp: Clean up formatting

This commit is contained in:
TingPing 2015-04-13 16:21:14 -04:00
parent 72d7f64f8b
commit a8392c7f95

View File

@ -50,129 +50,116 @@ song_strcpy (char *dest, char *src)
static int
winamp(char *word[], char *word_eol[], void *userdata)
{
wchar_t wcurrent_play[2048];
char *current_play, *p;
char p_esc[2048];
char cur_esc[2048];
char truc[2048];
HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
wchar_t wcurrent_play[2048];
char *current_play, *p;
char p_esc[2048];
char cur_esc[2048];
char truc[2048];
HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
if (hwndWinamp)
if (hwndWinamp)
{
{
if (!stricmp("PAUSE", word[2]))
if (!stricmp("PAUSE", word[2]))
{
if (SendMessage(hwndWinamp,WM_USER, 0, 104))
{
if (SendMessage(hwndWinamp,WM_USER, 0, 104))
{
SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
hexchat_printf(ph, "Winamp: playing");
else
hexchat_printf(ph, "Winamp: paused");
}
}
else
if (!stricmp("STOP", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
hexchat_printf(ph, "Winamp: stopped");
}
else
if (!stricmp("PLAY", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
hexchat_printf(ph, "Winamp: playing");
}
else
if (!stricmp("NEXT", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
hexchat_printf(ph, "Winamp: next playlist entry");
}
else
if (!stricmp("PREV", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
hexchat_printf(ph, "Winamp: previous playlist entry");
}
else
if (!stricmp("START", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
hexchat_printf(ph, "Winamp: playlist start");
}
else
if (!word_eol[2][0])
{
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, '-'))
{
p = current_play + strlen(current_play) - 8;
while (p >= current_play)
{
if (!strnicmp(p, "- Winamp", 8)) break;
p--;
}
if (p >= current_play) p--;
while (p >= current_play && *p == ' ') p--;
*++p=0;
p = strchr(current_play, '.') + 1;
song_strcpy(p_esc, p);
song_strcpy(cur_esc, current_play);
if (p)
{
sprintf(truc, "me is now playing:%s", p_esc);
}
else
{
sprintf(truc, "me is now playing:%s", cur_esc);
}
hexchat_commandf(ph, truc);
g_free (current_play);
}
else hexchat_print(ph, "Winamp: Nothing being played.");
if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
hexchat_printf(ph, "Winamp: playing");
else
hexchat_printf(ph, "Winamp: paused");
}
else
hexchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
}
}
else if (!stricmp("STOP", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
hexchat_printf(ph, "Winamp: stopped");
}
else if (!stricmp("PLAY", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
hexchat_printf(ph, "Winamp: playing");
}
else if (!stricmp("NEXT", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
hexchat_printf(ph, "Winamp: next playlist entry");
}
else if (!stricmp("PREV", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
hexchat_printf(ph, "Winamp: previous playlist entry");
}
else if (!stricmp("START", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
hexchat_printf(ph, "Winamp: playlist start");
}
else if (!word_eol[2][0])
{
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, '-'))
{
p = current_play + strlen(current_play) - 8;
while (p >= current_play)
{
if (!strnicmp(p, "- Winamp", 8)) break;
p--;
}
if (p >= current_play)
p--;
while (p >= current_play && *p == ' ')
p--;
*++p=0;
p = strchr(current_play, '.') + 1;
song_strcpy(p_esc, p);
song_strcpy(cur_esc, current_play);
if (p)
{
sprintf(truc, "me is now playing:%s", p_esc);
}
else
{
sprintf(truc, "me is now playing:%s", cur_esc);
}
hexchat_commandf(ph, truc);
g_free (current_play);
}
else
hexchat_print(ph, "Winamp: Nothing being played.");
}
else
hexchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
}
else
{
hexchat_print(ph, "Winamp not found.\n");
hexchat_print(ph, "Winamp not found.\n");
}
return HEXCHAT_EAT_ALL;
}
int
hexchat_plugin_init(hexchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
/* we need to save this for use with any hexchat_* functions */
ph = plugin_handle;
@ -186,7 +173,7 @@ hexchat_plugin_init(hexchat_plugin *plugin_handle,
hexchat_print (ph, "Winamp plugin loaded\n");
return 1; /* return 1 for success */
return 1; /* return 1 for success */
}
int