2011-08-11 19:39:40 -04:00
|
|
|
|
/******************************************************************
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* $Log$
|
|
|
|
|
*
|
|
|
|
|
* Copyright <EFBFBD> 2005 David Cullen, All rights reserved
|
|
|
|
|
*
|
|
|
|
|
******************************************************************/
|
|
|
|
|
#include "stdafx.h"
|
2012-10-24 15:33:02 -04:00
|
|
|
|
#include "hexchat-plugin.h"
|
2011-08-11 19:39:40 -04:00
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <tchar.h>
|
|
|
|
|
#include "wmpa.h"
|
|
|
|
|
#include "WMPADialog.h"
|
|
|
|
|
|
|
|
|
|
#define XMMS_SESSION 0
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* Globalss
|
|
|
|
|
******************************************************************/
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_plugin *ph = NULL;
|
2011-08-11 19:39:40 -04:00
|
|
|
|
CWMPPlayer4 *wmp;
|
|
|
|
|
static const char subKey[] = "Software\\FlowerSoft\\WMPA";
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
2012-10-30 03:42:48 -04:00
|
|
|
|
* hexchat_plugin_init
|
2011-08-11 19:39:40 -04:00
|
|
|
|
******************************************************************/
|
2012-10-30 03:42:48 -04:00
|
|
|
|
int hexchat_plugin_init(hexchat_plugin *plugin_handle,
|
2011-08-11 19:39:40 -04:00
|
|
|
|
char **plugin_name,
|
|
|
|
|
char **plugin_desc,
|
|
|
|
|
char **plugin_version,
|
|
|
|
|
char *arg)
|
|
|
|
|
{
|
|
|
|
|
BOOL success;
|
|
|
|
|
|
|
|
|
|
ph = plugin_handle;
|
|
|
|
|
|
|
|
|
|
*plugin_name = "WMPA";
|
|
|
|
|
*plugin_desc = "Announce the current song from Windows Media Player.";
|
|
|
|
|
*plugin_version = VER_STRING;
|
|
|
|
|
|
|
|
|
|
// Show the song browser
|
|
|
|
|
success = StartWindowsMediaPlayer();
|
|
|
|
|
if (!success) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Failed to show the song browser.");
|
|
|
|
|
hexchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
return(E_FAIL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get a pointer to the Windows Media Player control
|
|
|
|
|
wmp = GetWindowsMediaPlayer();
|
|
|
|
|
if (wmp == NULL) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Failed to get a pointer to the Windows Media Player interface.");
|
|
|
|
|
hexchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
return(E_POINTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restore the settings (need wmp first)
|
|
|
|
|
success = wmpaRestoreSettings();
|
|
|
|
|
if (!success) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Failed to restore the settings.");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_hook_command(ph, "auto", HEXCHAT_PRI_NORM, wmpaAuto, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "curr", HEXCHAT_PRI_NORM, wmpaCurr, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "find", HEXCHAT_PRI_NORM, wmpaFind, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "slist", HEXCHAT_PRI_NORM, wmpaList, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "next", HEXCHAT_PRI_NORM, wmpaNext, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "play", HEXCHAT_PRI_NORM, wmpaPlay, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "pause", HEXCHAT_PRI_NORM, wmpaPause, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "prev", HEXCHAT_PRI_NORM, wmpaPrev, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "song", HEXCHAT_PRI_NORM, wmpaSong, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "stop", HEXCHAT_PRI_NORM, wmpaStop, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "volume", HEXCHAT_PRI_NORM, wmpaVolume, 0, 0);
|
|
|
|
|
hexchat_hook_command(ph, "wmpahelp", HEXCHAT_PRI_NORM, wmpaHelp, 0, 0);
|
|
|
|
|
|
|
|
|
|
hexchat_printf(ph, "WMPA %s successfully loaded.", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
wmpaCommands();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: e-mail me if you find any bugs: dcullen@intergate.com");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
2012-10-30 03:42:48 -04:00
|
|
|
|
* hexchat_plugin_deinit
|
2011-08-11 19:39:40 -04:00
|
|
|
|
******************************************************************/
|
2012-10-30 03:42:48 -04:00
|
|
|
|
int hexchat_plugin_deinit(void)
|
2011-08-11 19:39:40 -04:00
|
|
|
|
{
|
|
|
|
|
BOOL success;
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA %s is unloading.", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
|
|
|
|
// Save the settings
|
|
|
|
|
success = wmpaSaveSettings();
|
|
|
|
|
if (!success) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Failed to save the settings.");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmp = NULL;
|
|
|
|
|
|
|
|
|
|
BOOL result = StopWindowsMediaPlayer();
|
|
|
|
|
if (!result) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA could not shut down Windows Media Player.");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA %s has unloaded.", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
2012-10-30 03:42:48 -04:00
|
|
|
|
* hexchat_plugin_get_info
|
2011-08-11 19:39:40 -04:00
|
|
|
|
******************************************************************/
|
2012-10-30 03:42:48 -04:00
|
|
|
|
void hexchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)
|
2011-08-11 19:39:40 -04:00
|
|
|
|
{
|
|
|
|
|
*name = "WMPA";
|
|
|
|
|
*desc = "Announce the current song from Windows Media Player.";
|
|
|
|
|
*version = VER_STRING;
|
|
|
|
|
if (reserved) *reserved = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaCommands
|
|
|
|
|
******************************************************************/
|
|
|
|
|
void wmpaCommands(void)
|
|
|
|
|
{
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: /auto [on/off] : Turn on/off auto announce of the current song or display the current setting");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /curr : Tell what song is currently playing");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /find [word] : Find songs with \"word\" in their title, create a new playlist, and play it");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /slist [word] : List songs with \"word\" in their title");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /next : Play the next song");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /play : Play the current song");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /pause : Pause the current song");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /prev : Play the previous song");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /song : Announce the current song from Windows Media Player in HexChat");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /stop : Stop the current song");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /volume [volume] : Set the volume (0 to 100) or display the current volume");
|
|
|
|
|
hexchat_printf(ph, "WMPA: /wmpahelp : Display this help.");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaAuto
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaAuto(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
CWMPADialog *pDialog;
|
|
|
|
|
char *state;
|
|
|
|
|
|
|
|
|
|
pDialog = GetWMPADialog();
|
2012-10-30 02:40:37 -04:00
|
|
|
|
if (pDialog == NULL) return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
|
|
|
|
if (CString(word[2]).IsEmpty()) {
|
|
|
|
|
if (pDialog->autoAnnounce) {
|
|
|
|
|
state = "on";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
state = "off";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
state = word[2];
|
|
|
|
|
if (CString(state) == "on") {
|
|
|
|
|
pDialog->autoAnnounce = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (CString(state) == "off") {
|
|
|
|
|
pDialog->autoAnnounce = FALSE;
|
|
|
|
|
}
|
|
|
|
|
wmpaSaveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: auto is %s", state);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaCurr
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaCurr(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaFind
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaFind(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
long index;
|
|
|
|
|
long count;
|
|
|
|
|
long found;
|
|
|
|
|
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
CWMPMediaCollection mc = wmp->GetMediaCollection();
|
|
|
|
|
CWMPPlaylist all = mc.getAll();
|
|
|
|
|
CWMPPlaylistCollection pc = wmp->GetPlaylistCollection();
|
|
|
|
|
CWMPPlaylistArray pa = pc.getAll();
|
|
|
|
|
CWMPPlaylist playlist;
|
|
|
|
|
CWMPMedia media;
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < pc.getAll().GetCount(); index++) {
|
|
|
|
|
if (pc.getAll().Item(index).GetName() == CString(word_eol[2])) {
|
|
|
|
|
playlist = pc.getAll().Item(index);
|
|
|
|
|
pc.remove(playlist);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playlist = pc.newPlaylist(word_eol[2]);
|
|
|
|
|
|
|
|
|
|
count = all.GetCount();
|
|
|
|
|
found = 0;
|
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
|
media = all.GetItem(index);
|
|
|
|
|
CString artist = media.getItemInfo("Artist");
|
|
|
|
|
CString title = media.getItemInfo("Title");
|
|
|
|
|
CString album = media.getItemInfo("Album");
|
|
|
|
|
if ( (artist.Find(word_eol[2]) != -1) ||
|
|
|
|
|
(title.Find(word_eol[2]) != -1) ||
|
|
|
|
|
(album.Find(word_eol[2]) != -1) ) {
|
|
|
|
|
playlist.appendItem(media);
|
|
|
|
|
found++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found > 0) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
wmp->SetCurrentPlaylist(playlist);
|
|
|
|
|
wmp->GetControls().play();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
|
|
|
|
CWMPADialog *dialog = GetWMPADialog();
|
|
|
|
|
if (dialog != NULL) {
|
|
|
|
|
dialog->UpdateSongList();
|
|
|
|
|
dialog->SelectCurrentSong();
|
|
|
|
|
dialog->UpdatePlayLists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Could not find %s", word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaList
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaList(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
long index;
|
|
|
|
|
long count;
|
|
|
|
|
long found;
|
|
|
|
|
|
|
|
|
|
if (wmp != NULL) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Listing songs with \"%s\" in them", word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
|
|
|
|
CWMPMediaCollection mc = wmp->GetMediaCollection();
|
|
|
|
|
CWMPPlaylist all = mc.getAll();
|
|
|
|
|
CWMPMedia media;
|
|
|
|
|
|
|
|
|
|
count = all.GetCount();
|
|
|
|
|
found = 0;
|
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
|
media = all.GetItem(index);
|
|
|
|
|
CString artist = media.getItemInfo("Artist");
|
|
|
|
|
CString title = media.getItemInfo("Title");
|
|
|
|
|
CString album = media.getItemInfo("Album");
|
|
|
|
|
if ( (artist.Find(word_eol[2]) != -1) ||
|
|
|
|
|
(title.Find(word_eol[2]) != -1) ||
|
|
|
|
|
(album.Find(word_eol[2]) != -1) ) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Found \"%s - %s (%s)\"", artist, title, album);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
found++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found > 0) {
|
|
|
|
|
if (found == 1)
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Found %d song with \"%s\" in it", found, word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
else
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Could not find any songs with \"%s\" in them", word_eol[2]);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaNext
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaNext(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
wmp->GetControls().next();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaPlay
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaPlay(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
wmp->GetControls().play();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaPause
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaPause(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
wmp->GetControls().pause();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Pausing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaPrev
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaPrev(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
wmp->GetControls().previous();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaSong
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaSong(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
CString songTitle = wmpaGetSongTitle();
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_commandf(ph, "me is playing %s", (LPCTSTR) songTitle);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaStop
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaStop(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (wmp != NULL) {
|
|
|
|
|
wmp->GetControls().stop();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Stopping %s", (LPCTSTR) wmpaGetSongTitle());
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaHelp
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaHelp(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "\n");
|
|
|
|
|
hexchat_printf(ph, "WMPA %s Help", VER_STRING);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
wmpaCommands();
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "\n");
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaVolume
|
|
|
|
|
******************************************************************/
|
|
|
|
|
int wmpaVolume(char *word[], char *word_eol[], void *user_data)
|
|
|
|
|
{
|
|
|
|
|
char *endPtr;
|
|
|
|
|
long volume;
|
|
|
|
|
|
|
|
|
|
if (CString(word[2]).IsEmpty()) {
|
|
|
|
|
volume = wmp->GetSettings().GetVolume();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
volume = strtol(word[2], &endPtr, 10);
|
|
|
|
|
|
|
|
|
|
if ((wmp != NULL) && (volume >= 0) && (volume <= 100)) {
|
|
|
|
|
wmp->GetSettings().SetVolume(volume);
|
|
|
|
|
wmpaSaveSettings();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: volume is %d", volume);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaRestoreSettings
|
|
|
|
|
******************************************************************/
|
|
|
|
|
BOOL wmpaRestoreSettings(void)
|
|
|
|
|
{
|
|
|
|
|
CWMPADialog *pDialog;
|
|
|
|
|
DWORD type;
|
|
|
|
|
int volume;
|
|
|
|
|
BOOL autoAnnounce;
|
|
|
|
|
DWORD size;
|
|
|
|
|
BOOL result;
|
|
|
|
|
|
|
|
|
|
if (wmp == NULL) return(FALSE);
|
|
|
|
|
|
|
|
|
|
volume = 50;
|
|
|
|
|
result = GetSetting("Volume", &type, (LPBYTE) &volume, &size);
|
|
|
|
|
wmp->GetSettings().SetVolume(volume);
|
|
|
|
|
|
|
|
|
|
autoAnnounce = FALSE;
|
|
|
|
|
pDialog = GetWMPADialog();
|
|
|
|
|
if (pDialog != NULL) {
|
|
|
|
|
result = result && GetSetting("Auto", &type, (LPBYTE) &autoAnnounce, &size);
|
|
|
|
|
pDialog->autoAnnounce = autoAnnounce;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaSaveSettings
|
|
|
|
|
******************************************************************/
|
|
|
|
|
BOOL wmpaSaveSettings(void)
|
|
|
|
|
{
|
|
|
|
|
CWMPADialog *pDialog;
|
|
|
|
|
int volume;
|
|
|
|
|
BOOL autoAnnounce;
|
|
|
|
|
BOOL result;
|
|
|
|
|
|
|
|
|
|
if (wmp == NULL) return(FALSE);
|
|
|
|
|
|
|
|
|
|
volume = wmp->GetSettings().GetVolume();
|
|
|
|
|
result = SaveSetting("Volume", REG_DWORD, (CONST BYTE *) &volume, sizeof(volume));
|
|
|
|
|
|
|
|
|
|
pDialog = GetWMPADialog();
|
|
|
|
|
if (pDialog != NULL) {
|
|
|
|
|
autoAnnounce = pDialog->autoAnnounce;
|
|
|
|
|
result = result && SaveSetting("Auto", REG_DWORD, (CONST BYTE *) &autoAnnounce, sizeof(autoAnnounce));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
result = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* wmpaGetSongTitle
|
|
|
|
|
******************************************************************/
|
|
|
|
|
CString wmpaGetSongTitle(void)
|
|
|
|
|
{
|
|
|
|
|
char buffer[32];
|
|
|
|
|
|
|
|
|
|
if (wmp == NULL) return(CString());
|
|
|
|
|
|
|
|
|
|
CWMPMedia media = wmp->GetCurrentMedia();
|
|
|
|
|
if (media == NULL) {
|
2012-10-30 03:42:48 -04:00
|
|
|
|
hexchat_printf(ph, "WMPA: Could not get current media");
|
2012-10-30 02:40:37 -04:00
|
|
|
|
return(HEXCHAT_EAT_ALL);
|
2011-08-11 19:39:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString artist = media.getItemInfo("Artist");
|
|
|
|
|
CString title = media.getItemInfo("Title");
|
|
|
|
|
CString album = media.getItemInfo("Album");
|
|
|
|
|
CString bitrate = media.getItemInfo("Bitrate");
|
|
|
|
|
CString duration = media.GetDurationString();
|
|
|
|
|
|
|
|
|
|
long krate = strtoul((LPCTSTR) bitrate, NULL, 10) / 1000;
|
|
|
|
|
_ultoa(krate, buffer, 10);
|
|
|
|
|
bitrate = CString(buffer);
|
|
|
|
|
|
|
|
|
|
// Creatte the song title
|
|
|
|
|
CString songTitle("");
|
|
|
|
|
songTitle += artist;
|
|
|
|
|
if (songTitle.IsEmpty()) songTitle += "Various";
|
|
|
|
|
songTitle += " - ";
|
|
|
|
|
songTitle += title;
|
|
|
|
|
songTitle += " (";
|
|
|
|
|
songTitle += album;
|
|
|
|
|
songTitle += ") [";
|
|
|
|
|
songTitle += duration;
|
|
|
|
|
songTitle += "/";
|
|
|
|
|
songTitle += bitrate;
|
|
|
|
|
songTitle += "Kbps]";
|
|
|
|
|
|
|
|
|
|
return(songTitle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* SaveSetting
|
|
|
|
|
******************************************************************/
|
|
|
|
|
BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size)
|
|
|
|
|
{
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
DWORD disposition;
|
|
|
|
|
LONG result;
|
|
|
|
|
|
|
|
|
|
if (wmp == NULL) return(FALSE);
|
|
|
|
|
if (name == NULL) return(FALSE);
|
|
|
|
|
|
|
|
|
|
result = RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
|
subKey,
|
|
|
|
|
0,
|
|
|
|
|
KEY_WRITE,
|
|
|
|
|
&hKey);
|
|
|
|
|
|
|
|
|
|
if (result != ERROR_SUCCESS) {
|
|
|
|
|
result = RegCreateKeyEx(HKEY_CURRENT_USER,
|
|
|
|
|
subKey,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_WRITE,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKey,
|
|
|
|
|
&disposition);
|
|
|
|
|
|
|
|
|
|
if (result != ERROR_SUCCESS) return(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = RegSetValueEx(hKey,
|
|
|
|
|
name,
|
|
|
|
|
0,
|
|
|
|
|
type,
|
|
|
|
|
value,
|
|
|
|
|
size);
|
|
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
return(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
return(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* GetSetting
|
|
|
|
|
******************************************************************/
|
|
|
|
|
BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size)
|
|
|
|
|
{
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
LONG result;
|
|
|
|
|
|
|
|
|
|
if (wmp == NULL) return(FALSE);
|
|
|
|
|
if (type == NULL) return(FALSE);
|
|
|
|
|
if (value == NULL) return(FALSE);
|
|
|
|
|
if (size == NULL) return(FALSE);
|
|
|
|
|
|
|
|
|
|
result = RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
|
subKey,
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hKey);
|
|
|
|
|
|
|
|
|
|
if (result != ERROR_SUCCESS) return(FALSE);
|
|
|
|
|
|
|
|
|
|
result = RegQueryValueEx(hKey,
|
|
|
|
|
name,
|
|
|
|
|
0,
|
|
|
|
|
type,
|
|
|
|
|
value,
|
|
|
|
|
size);
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
|
return(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
return(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|