From 1a75c8e1be58a25510642605dcd40c5c65e9c3f3 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 24 Oct 2012 21:33:02 +0200 Subject: A lot more rebranding --- plugins/wmpa/hexchat-plugin.cpp | 590 +++++++++++++++++++++++++++++++++++ plugins/wmpa/hexchat-plugin.h | 368 ++++++++++++++++++++++ plugins/wmpa/wmpa-xp.vcxproj | 4 +- plugins/wmpa/wmpa-xp.vcxproj.filters | 4 +- plugins/wmpa/wmpa.vcxproj | 4 +- plugins/wmpa/wmpa.vcxproj.filters | 4 +- plugins/wmpa/wmpadialog.cpp | 2 +- plugins/wmpa/xchat-plugin.cpp | 590 ----------------------------------- plugins/wmpa/xchat-plugin.h | 368 ---------------------- 9 files changed, 967 insertions(+), 967 deletions(-) create mode 100644 plugins/wmpa/hexchat-plugin.cpp create mode 100644 plugins/wmpa/hexchat-plugin.h delete mode 100644 plugins/wmpa/xchat-plugin.cpp delete mode 100644 plugins/wmpa/xchat-plugin.h (limited to 'plugins/wmpa') diff --git a/plugins/wmpa/hexchat-plugin.cpp b/plugins/wmpa/hexchat-plugin.cpp new file mode 100644 index 00000000..b8a21135 --- /dev/null +++ b/plugins/wmpa/hexchat-plugin.cpp @@ -0,0 +1,590 @@ +/****************************************************************** +* $Id$ +* +* $Log$ +* +* Copyright © 2005 David Cullen, All rights reserved +* +******************************************************************/ +#include "stdafx.h" +#include "hexchat-plugin.h" +#include +#include +#include "wmpa.h" +#include "WMPADialog.h" + +#define XMMS_SESSION 0 + +/****************************************************************** +* Globalss +******************************************************************/ +xchat_plugin *ph = NULL; +CWMPPlayer4 *wmp; +static const char subKey[] = "Software\\FlowerSoft\\WMPA"; + +/****************************************************************** +* xchat_plugin_init +******************************************************************/ +int xchat_plugin_init(xchat_plugin *plugin_handle, + 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) { + xchat_printf(ph, "WMPA: Failed to show the song browser."); + xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); + return(E_FAIL); + } + + // Get a pointer to the Windows Media Player control + wmp = GetWindowsMediaPlayer(); + if (wmp == NULL) { + xchat_printf(ph, "WMPA: Failed to get a pointer to the Windows Media Player interface."); + xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); + return(E_POINTER); + } + + // Restore the settings (need wmp first) + success = wmpaRestoreSettings(); + if (!success) { + xchat_printf(ph, "WMPA: Failed to restore the settings."); + } + + xchat_hook_command(ph, "auto", XCHAT_PRI_NORM, wmpaAuto, 0, 0); + xchat_hook_command(ph, "curr", XCHAT_PRI_NORM, wmpaCurr, 0, 0); + xchat_hook_command(ph, "find", XCHAT_PRI_NORM, wmpaFind, 0, 0); + xchat_hook_command(ph, "slist", XCHAT_PRI_NORM, wmpaList, 0, 0); + xchat_hook_command(ph, "next", XCHAT_PRI_NORM, wmpaNext, 0, 0); + xchat_hook_command(ph, "play", XCHAT_PRI_NORM, wmpaPlay, 0, 0); + xchat_hook_command(ph, "pause", XCHAT_PRI_NORM, wmpaPause, 0, 0); + xchat_hook_command(ph, "prev", XCHAT_PRI_NORM, wmpaPrev, 0, 0); + xchat_hook_command(ph, "song", XCHAT_PRI_NORM, wmpaSong, 0, 0); + xchat_hook_command(ph, "stop", XCHAT_PRI_NORM, wmpaStop, 0, 0); + xchat_hook_command(ph, "volume", XCHAT_PRI_NORM, wmpaVolume, 0, 0); + xchat_hook_command(ph, "wmpahelp", XCHAT_PRI_NORM, wmpaHelp, 0, 0); + + xchat_printf(ph, "WMPA %s successfully loaded.", VER_STRING); + wmpaCommands(); + xchat_printf(ph, "WMPA: e-mail me if you find any bugs: dcullen@intergate.com"); + + return 1; +} + +/****************************************************************** +* xchat_plugin_deinit +******************************************************************/ +int xchat_plugin_deinit(void) +{ + BOOL success; + + xchat_printf(ph, "WMPA %s is unloading.", VER_STRING); + + // Save the settings + success = wmpaSaveSettings(); + if (!success) { + xchat_printf(ph, "WMPA: Failed to save the settings."); + } + + wmp = NULL; + + BOOL result = StopWindowsMediaPlayer(); + if (!result) { + xchat_printf(ph, "WMPA could not shut down Windows Media Player."); + } + + xchat_printf(ph, "WMPA %s has unloaded.", VER_STRING); + return 1; +} + +/****************************************************************** +* xchat_plugin_get_info +******************************************************************/ +void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) +{ + *name = "WMPA"; + *desc = "Announce the current song from Windows Media Player."; + *version = VER_STRING; + if (reserved) *reserved = NULL; +} + +/****************************************************************** +* wmpaCommands +******************************************************************/ +void wmpaCommands(void) +{ + xchat_printf(ph, "WMPA: /auto [on/off] : Turn on/off auto announce of the current song or display the current setting"); + xchat_printf(ph, "WMPA: /curr : Tell what song is currently playing"); + xchat_printf(ph, "WMPA: /find [word] : Find songs with \"word\" in their title, create a new playlist, and play it"); + xchat_printf(ph, "WMPA: /slist [word] : List songs with \"word\" in their title"); + xchat_printf(ph, "WMPA: /next : Play the next song"); + xchat_printf(ph, "WMPA: /play : Play the current song"); + xchat_printf(ph, "WMPA: /pause : Pause the current song"); + xchat_printf(ph, "WMPA: /prev : Play the previous song"); + xchat_printf(ph, "WMPA: /song : Announce the current song from Windows Media Player in HexChat"); + xchat_printf(ph, "WMPA: /stop : Stop the current song"); + xchat_printf(ph, "WMPA: /volume [volume] : Set the volume (0 to 100) or display the current volume"); + xchat_printf(ph, "WMPA: /wmpahelp : Display this help."); +} + +/****************************************************************** +* wmpaAuto +******************************************************************/ +int wmpaAuto(char *word[], char *word_eol[], void *user_data) +{ + CWMPADialog *pDialog; + char *state; + + pDialog = GetWMPADialog(); + if (pDialog == NULL) return(XCHAT_EAT_ALL); + + 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(); + } + + xchat_printf(ph, "WMPA: auto is %s", state); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaCurr +******************************************************************/ +int wmpaCurr(char *word[], char *word_eol[], void *user_data) +{ + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* 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) { + xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); + wmp->SetCurrentPlaylist(playlist); + wmp->GetControls().play(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + + CWMPADialog *dialog = GetWMPADialog(); + if (dialog != NULL) { + dialog->UpdateSongList(); + dialog->SelectCurrentSong(); + dialog->UpdatePlayLists(); + } + + } + else { + xchat_printf(ph, "WMPA: Could not find %s", word_eol[2]); + } + + } + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaList +******************************************************************/ +int wmpaList(char *word[], char *word_eol[], void *user_data) +{ + long index; + long count; + long found; + + if (wmp != NULL) { + xchat_printf(ph, "WMPA: Listing songs with \"%s\" in them", word_eol[2]); + + 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) ) { + xchat_printf(ph, "WMPA: Found \"%s - %s (%s)\"", artist, title, album); + found++; + } + } + + if (found > 0) { + if (found == 1) + xchat_printf(ph, "WMPA: Found %d song with \"%s\" in it", found, word_eol[2]); + else + xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); + } + else { + xchat_printf(ph, "WMPA: Could not find any songs with \"%s\" in them", word_eol[2]); + } + + } + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaNext +******************************************************************/ +int wmpaNext(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().next(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPlay +******************************************************************/ +int wmpaPlay(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().play(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPause +******************************************************************/ +int wmpaPause(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().pause(); + xchat_printf(ph, "WMPA: Pausing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPrev +******************************************************************/ +int wmpaPrev(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().previous(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaSong +******************************************************************/ +int wmpaSong(char *word[], char *word_eol[], void *user_data) +{ + CString songTitle = wmpaGetSongTitle(); + + xchat_commandf(ph, "me is playing %s", (LPCTSTR) songTitle); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaStop +******************************************************************/ +int wmpaStop(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().stop(); + xchat_printf(ph, "WMPA: Stopping %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaHelp +******************************************************************/ +int wmpaHelp(char *word[], char *word_eol[], void *user_data) +{ + xchat_printf(ph, "\n"); + xchat_printf(ph, "WMPA %s Help", VER_STRING); + wmpaCommands(); + xchat_printf(ph, "\n"); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* 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(); + } + } + + xchat_printf(ph, "WMPA: volume is %d", volume); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* 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) { + xchat_printf(ph, "WMPA: Could not get current media"); + return(XCHAT_EAT_ALL); + } + + 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); +} + diff --git a/plugins/wmpa/hexchat-plugin.h b/plugins/wmpa/hexchat-plugin.h new file mode 100644 index 00000000..cec27a6f --- /dev/null +++ b/plugins/wmpa/hexchat-plugin.h @@ -0,0 +1,368 @@ +/* You can distribute this header with your plugins for easy compilation */ +#ifndef HEXCHAT_PLUGIN_H +#define HEXCHAT_PLUGIN_H + +#define VER_STRING _T("1.0.2 (BETA)") + +#include "stdafx.h" +#include +#include +#include + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + + + typedef struct _xchat_plugin xchat_plugin; + typedef struct _xchat_list xchat_list; + typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C + typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C + struct _xchat_plugin { + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); + }; +#endif + + + xchat_hook * + xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + + xchat_hook * + xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + + void * + xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + + void + xchat_print (xchat_plugin *ph, + const char *text); + + void + xchat_printf (xchat_plugin *ph, + const char *format, ...); + + void + xchat_command (xchat_plugin *ph, + const char *command); + + void + xchat_commandf (xchat_plugin *ph, + const char *format, ...); + + int + xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + + int + xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + + xchat_context * + xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + + xchat_context * + xchat_get_context (xchat_plugin *ph); + + const char * + xchat_get_info (xchat_plugin *ph, + const char *id); + + int + xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + + xchat_list * + xchat_list_get (xchat_plugin *ph, + const char *name); + + void + xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + + const char * const * + xchat_list_fields (xchat_plugin *ph, + const char *name); + + int + xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + + const char * + xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + int + xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + time_t + xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + void * + xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + + void + xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + + int + xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + + char * + xchat_gettext (xchat_plugin *ph, + const char *msgid); + + void + xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + + char * + xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + + void + xchat_free (xchat_plugin *ph, + void *ptr); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#endif + +#ifdef __cplusplus +} +#endif + +/****************************************************************** +* Globals +******************************************************************/ +extern xchat_plugin *ph; + +/****************************************************************** +* Prototypes +******************************************************************/ +void wmpaCommands(void); +int wmpaAuto(char *word[], char *word_eol[], void *user_data); +int wmpaCurr(char *word[], char *word_eol[], void *user_data); +int wmpaFind(char *word[], char *word_eol[], void *user_data); +int wmpaList(char *word[], char *word_eol[], void *user_data); +int wmpaNext(char *word[], char *word_eol[], void *user_data); +int wmpaPlay(char *word[], char *word_eol[], void *user_data); +int wmpaPause(char *word[], char *word_eol[], void *user_data); +int wmpaPrev(char *word[], char *word_eol[], void *user_data); +int wmpaSong(char *word[], char *word_eol[], void *user_data); +int wmpaStop(char *word[], char *word_eol[], void *user_data); +int wmpaVolume(char *word[], char *word_eol[], void *user_data); +int wmpaHelp(char *word[], char *word_eol[], void *user_data); +BOOL wmpaRestoreSettings(void); +BOOL wmpaSaveSettings(void); +CString wmpaGetSongTitle(void); +BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size); +BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size); + +#endif /* XCHAT_PLUGIN_H */ + diff --git a/plugins/wmpa/wmpa-xp.vcxproj b/plugins/wmpa/wmpa-xp.vcxproj index fb367520..15fed71d 100644 --- a/plugins/wmpa/wmpa-xp.vcxproj +++ b/plugins/wmpa/wmpa-xp.vcxproj @@ -118,7 +118,7 @@ - + @@ -142,7 +142,7 @@ - + diff --git a/plugins/wmpa/wmpa-xp.vcxproj.filters b/plugins/wmpa/wmpa-xp.vcxproj.filters index 2be9d82f..7910f0d8 100644 --- a/plugins/wmpa/wmpa-xp.vcxproj.filters +++ b/plugins/wmpa/wmpa-xp.vcxproj.filters @@ -78,7 +78,7 @@ Source Files - + Source Files @@ -146,7 +146,7 @@ Header Files - + Header Files diff --git a/plugins/wmpa/wmpa.vcxproj b/plugins/wmpa/wmpa.vcxproj index 7dafe2a6..0e5db7dc 100644 --- a/plugins/wmpa/wmpa.vcxproj +++ b/plugins/wmpa/wmpa.vcxproj @@ -115,7 +115,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/plugins/wmpa/wmpa.vcxproj.filters b/plugins/wmpa/wmpa.vcxproj.filters index 2be9d82f..7910f0d8 100644 --- a/plugins/wmpa/wmpa.vcxproj.filters +++ b/plugins/wmpa/wmpa.vcxproj.filters @@ -78,7 +78,7 @@ Source Files - + Source Files @@ -146,7 +146,7 @@ Header Files - + Header Files diff --git a/plugins/wmpa/wmpadialog.cpp b/plugins/wmpa/wmpadialog.cpp index b0cdd16e..90bae309 100644 --- a/plugins/wmpa/wmpadialog.cpp +++ b/plugins/wmpa/wmpadialog.cpp @@ -10,7 +10,7 @@ #include "wmpa.h" #include "WMPADialog.h" #include "shellapi.h" -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/plugins/wmpa/xchat-plugin.cpp b/plugins/wmpa/xchat-plugin.cpp deleted file mode 100644 index 7b3bc737..00000000 --- a/plugins/wmpa/xchat-plugin.cpp +++ /dev/null @@ -1,590 +0,0 @@ -/****************************************************************** -* $Id$ -* -* $Log$ -* -* Copyright © 2005 David Cullen, All rights reserved -* -******************************************************************/ -#include "stdafx.h" -#include "xchat-plugin.h" -#include -#include -#include "wmpa.h" -#include "WMPADialog.h" - -#define XMMS_SESSION 0 - -/****************************************************************** -* Globalss -******************************************************************/ -xchat_plugin *ph = NULL; -CWMPPlayer4 *wmp; -static const char subKey[] = "Software\\FlowerSoft\\WMPA"; - -/****************************************************************** -* xchat_plugin_init -******************************************************************/ -int xchat_plugin_init(xchat_plugin *plugin_handle, - 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) { - xchat_printf(ph, "WMPA: Failed to show the song browser."); - xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); - return(E_FAIL); - } - - // Get a pointer to the Windows Media Player control - wmp = GetWindowsMediaPlayer(); - if (wmp == NULL) { - xchat_printf(ph, "WMPA: Failed to get a pointer to the Windows Media Player interface."); - xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); - return(E_POINTER); - } - - // Restore the settings (need wmp first) - success = wmpaRestoreSettings(); - if (!success) { - xchat_printf(ph, "WMPA: Failed to restore the settings."); - } - - xchat_hook_command(ph, "auto", XCHAT_PRI_NORM, wmpaAuto, 0, 0); - xchat_hook_command(ph, "curr", XCHAT_PRI_NORM, wmpaCurr, 0, 0); - xchat_hook_command(ph, "find", XCHAT_PRI_NORM, wmpaFind, 0, 0); - xchat_hook_command(ph, "slist", XCHAT_PRI_NORM, wmpaList, 0, 0); - xchat_hook_command(ph, "next", XCHAT_PRI_NORM, wmpaNext, 0, 0); - xchat_hook_command(ph, "play", XCHAT_PRI_NORM, wmpaPlay, 0, 0); - xchat_hook_command(ph, "pause", XCHAT_PRI_NORM, wmpaPause, 0, 0); - xchat_hook_command(ph, "prev", XCHAT_PRI_NORM, wmpaPrev, 0, 0); - xchat_hook_command(ph, "song", XCHAT_PRI_NORM, wmpaSong, 0, 0); - xchat_hook_command(ph, "stop", XCHAT_PRI_NORM, wmpaStop, 0, 0); - xchat_hook_command(ph, "volume", XCHAT_PRI_NORM, wmpaVolume, 0, 0); - xchat_hook_command(ph, "wmpahelp", XCHAT_PRI_NORM, wmpaHelp, 0, 0); - - xchat_printf(ph, "WMPA %s successfully loaded.", VER_STRING); - wmpaCommands(); - xchat_printf(ph, "WMPA: e-mail me if you find any bugs: dcullen@intergate.com"); - - return 1; -} - -/****************************************************************** -* xchat_plugin_deinit -******************************************************************/ -int xchat_plugin_deinit(void) -{ - BOOL success; - - xchat_printf(ph, "WMPA %s is unloading.", VER_STRING); - - // Save the settings - success = wmpaSaveSettings(); - if (!success) { - xchat_printf(ph, "WMPA: Failed to save the settings."); - } - - wmp = NULL; - - BOOL result = StopWindowsMediaPlayer(); - if (!result) { - xchat_printf(ph, "WMPA could not shut down Windows Media Player."); - } - - xchat_printf(ph, "WMPA %s has unloaded.", VER_STRING); - return 1; -} - -/****************************************************************** -* xchat_plugin_get_info -******************************************************************/ -void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) -{ - *name = "WMPA"; - *desc = "Announce the current song from Windows Media Player."; - *version = VER_STRING; - if (reserved) *reserved = NULL; -} - -/****************************************************************** -* wmpaCommands -******************************************************************/ -void wmpaCommands(void) -{ - xchat_printf(ph, "WMPA: /auto [on/off] : Turn on/off auto announce of the current song or display the current setting"); - xchat_printf(ph, "WMPA: /curr : Tell what song is currently playing"); - xchat_printf(ph, "WMPA: /find [word] : Find songs with \"word\" in their title, create a new playlist, and play it"); - xchat_printf(ph, "WMPA: /slist [word] : List songs with \"word\" in their title"); - xchat_printf(ph, "WMPA: /next : Play the next song"); - xchat_printf(ph, "WMPA: /play : Play the current song"); - xchat_printf(ph, "WMPA: /pause : Pause the current song"); - xchat_printf(ph, "WMPA: /prev : Play the previous song"); - xchat_printf(ph, "WMPA: /song : Announce the current song from Windows Media Player in HexChat"); - xchat_printf(ph, "WMPA: /stop : Stop the current song"); - xchat_printf(ph, "WMPA: /volume [volume] : Set the volume (0 to 100) or display the current volume"); - xchat_printf(ph, "WMPA: /wmpahelp : Display this help."); -} - -/****************************************************************** -* wmpaAuto -******************************************************************/ -int wmpaAuto(char *word[], char *word_eol[], void *user_data) -{ - CWMPADialog *pDialog; - char *state; - - pDialog = GetWMPADialog(); - if (pDialog == NULL) return(XCHAT_EAT_ALL); - - 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(); - } - - xchat_printf(ph, "WMPA: auto is %s", state); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaCurr -******************************************************************/ -int wmpaCurr(char *word[], char *word_eol[], void *user_data) -{ - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* 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) { - xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); - wmp->SetCurrentPlaylist(playlist); - wmp->GetControls().play(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - - CWMPADialog *dialog = GetWMPADialog(); - if (dialog != NULL) { - dialog->UpdateSongList(); - dialog->SelectCurrentSong(); - dialog->UpdatePlayLists(); - } - - } - else { - xchat_printf(ph, "WMPA: Could not find %s", word_eol[2]); - } - - } - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaList -******************************************************************/ -int wmpaList(char *word[], char *word_eol[], void *user_data) -{ - long index; - long count; - long found; - - if (wmp != NULL) { - xchat_printf(ph, "WMPA: Listing songs with \"%s\" in them", word_eol[2]); - - 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) ) { - xchat_printf(ph, "WMPA: Found \"%s - %s (%s)\"", artist, title, album); - found++; - } - } - - if (found > 0) { - if (found == 1) - xchat_printf(ph, "WMPA: Found %d song with \"%s\" in it", found, word_eol[2]); - else - xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); - } - else { - xchat_printf(ph, "WMPA: Could not find any songs with \"%s\" in them", word_eol[2]); - } - - } - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaNext -******************************************************************/ -int wmpaNext(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().next(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPlay -******************************************************************/ -int wmpaPlay(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().play(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPause -******************************************************************/ -int wmpaPause(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().pause(); - xchat_printf(ph, "WMPA: Pausing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPrev -******************************************************************/ -int wmpaPrev(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().previous(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaSong -******************************************************************/ -int wmpaSong(char *word[], char *word_eol[], void *user_data) -{ - CString songTitle = wmpaGetSongTitle(); - - xchat_commandf(ph, "me is playing %s", (LPCTSTR) songTitle); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaStop -******************************************************************/ -int wmpaStop(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().stop(); - xchat_printf(ph, "WMPA: Stopping %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaHelp -******************************************************************/ -int wmpaHelp(char *word[], char *word_eol[], void *user_data) -{ - xchat_printf(ph, "\n"); - xchat_printf(ph, "WMPA %s Help", VER_STRING); - wmpaCommands(); - xchat_printf(ph, "\n"); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* 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(); - } - } - - xchat_printf(ph, "WMPA: volume is %d", volume); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* 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) { - xchat_printf(ph, "WMPA: Could not get current media"); - return(XCHAT_EAT_ALL); - } - - 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); -} - diff --git a/plugins/wmpa/xchat-plugin.h b/plugins/wmpa/xchat-plugin.h deleted file mode 100644 index ee189ffe..00000000 --- a/plugins/wmpa/xchat-plugin.h +++ /dev/null @@ -1,368 +0,0 @@ -/* You can distribute this header with your plugins for easy compilation */ -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -#define VER_STRING _T("1.0.2 (BETA)") - -#include "stdafx.h" -#include -#include -#include - -#define XCHAT_IFACE_MAJOR 1 -#define XCHAT_IFACE_MINOR 9 -#define XCHAT_IFACE_MICRO 11 -#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ - (XCHAT_IFACE_MINOR * 100) + \ - (XCHAT_IFACE_MICRO)) - -#define XCHAT_PRI_HIGHEST 127 -#define XCHAT_PRI_HIGH 64 -#define XCHAT_PRI_NORM 0 -#define XCHAT_PRI_LOW (-64) -#define XCHAT_PRI_LOWEST (-128) - -#define XCHAT_FD_READ 1 -#define XCHAT_FD_WRITE 2 -#define XCHAT_FD_EXCEPTION 4 -#define XCHAT_FD_NOTSOCKET 8 - -#define XCHAT_EAT_NONE 0 /* pass it on through! */ -#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ -#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ -#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ - -#ifdef __cplusplus -extern "C" { -#endif - - - typedef struct _xchat_plugin xchat_plugin; - typedef struct _xchat_list xchat_list; - typedef struct _xchat_hook xchat_hook; -#ifndef PLUGIN_C - typedef struct _xchat_context xchat_context; -#endif - -#ifndef PLUGIN_C - struct _xchat_plugin { - /* these are only used on win32 */ - xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - void *(*xchat_unhook) (xchat_plugin *ph, - xchat_hook *hook); - void (*xchat_print) (xchat_plugin *ph, - const char *text); - void (*xchat_printf) (xchat_plugin *ph, - const char *format, ...); - void (*xchat_command) (xchat_plugin *ph, - const char *command); - void (*xchat_commandf) (xchat_plugin *ph, - const char *format, ...); - int (*xchat_nickcmp) (xchat_plugin *ph, - const char *s1, - const char *s2); - int (*xchat_set_context) (xchat_plugin *ph, - xchat_context *ctx); - xchat_context *(*xchat_find_context) (xchat_plugin *ph, - const char *servname, - const char *channel); - xchat_context *(*xchat_get_context) (xchat_plugin *ph); - const char *(*xchat_get_info) (xchat_plugin *ph, - const char *id); - int (*xchat_get_prefs) (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - xchat_list * (*xchat_list_get) (xchat_plugin *ph, - const char *name); - void (*xchat_list_free) (xchat_plugin *ph, - xchat_list *xlist); - const char * const * (*xchat_list_fields) (xchat_plugin *ph, - const char *name); - int (*xchat_list_next) (xchat_plugin *ph, - xchat_list *xlist); - const char * (*xchat_list_str) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - int (*xchat_list_int) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - void * (*xchat_plugingui_add) (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - void (*xchat_plugingui_remove) (xchat_plugin *ph, - void *handle); - int (*xchat_emit_print) (xchat_plugin *ph, - const char *event_name, ...); - int (*xchat_read_fd) (xchat_plugin *ph, - void *src, - char *buf, - int *len); - time_t (*xchat_list_time) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - char *(*xchat_gettext) (xchat_plugin *ph, - const char *msgid); - void (*xchat_send_modes) (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - char *(*xchat_strip) (xchat_plugin *ph, - const char *str, - int len, - int flags); - void (*xchat_free) (xchat_plugin *ph, - void *ptr); - }; -#endif - - - xchat_hook * - xchat_hook_command (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - - xchat_hook * - xchat_hook_server (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_print (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_timer (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_fd (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - - void * - xchat_unhook (xchat_plugin *ph, - xchat_hook *hook); - - void - xchat_print (xchat_plugin *ph, - const char *text); - - void - xchat_printf (xchat_plugin *ph, - const char *format, ...); - - void - xchat_command (xchat_plugin *ph, - const char *command); - - void - xchat_commandf (xchat_plugin *ph, - const char *format, ...); - - int - xchat_nickcmp (xchat_plugin *ph, - const char *s1, - const char *s2); - - int - xchat_set_context (xchat_plugin *ph, - xchat_context *ctx); - - xchat_context * - xchat_find_context (xchat_plugin *ph, - const char *servname, - const char *channel); - - xchat_context * - xchat_get_context (xchat_plugin *ph); - - const char * - xchat_get_info (xchat_plugin *ph, - const char *id); - - int - xchat_get_prefs (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - - xchat_list * - xchat_list_get (xchat_plugin *ph, - const char *name); - - void - xchat_list_free (xchat_plugin *ph, - xchat_list *xlist); - - const char * const * - xchat_list_fields (xchat_plugin *ph, - const char *name); - - int - xchat_list_next (xchat_plugin *ph, - xchat_list *xlist); - - const char * - xchat_list_str (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - int - xchat_list_int (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - time_t - xchat_list_time (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - void * - xchat_plugingui_add (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - - void - xchat_plugingui_remove (xchat_plugin *ph, - void *handle); - - int - xchat_emit_print (xchat_plugin *ph, - const char *event_name, ...); - - char * - xchat_gettext (xchat_plugin *ph, - const char *msgid); - - void - xchat_send_modes (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - - char * - xchat_strip (xchat_plugin *ph, - const char *str, - int len, - int flags); - - void - xchat_free (xchat_plugin *ph, - void *ptr); - -#if !defined(PLUGIN_C) && defined(WIN32) -#ifndef XCHAT_PLUGIN_HANDLE -#define XCHAT_PLUGIN_HANDLE (ph) -#endif -#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) -#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) -#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) -#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) -#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) -#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) -#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) -#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) -#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) -#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) -#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) -#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) -#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) -#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) -#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) -#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) -#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) -#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) -#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) -#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) -#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) -#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) -#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) -#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) -#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) -#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) -#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) -#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) -#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) -#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#endif - -#ifdef __cplusplus -} -#endif - -/****************************************************************** -* Globals -******************************************************************/ -extern xchat_plugin *ph; - -/****************************************************************** -* Prototypes -******************************************************************/ -void wmpaCommands(void); -int wmpaAuto(char *word[], char *word_eol[], void *user_data); -int wmpaCurr(char *word[], char *word_eol[], void *user_data); -int wmpaFind(char *word[], char *word_eol[], void *user_data); -int wmpaList(char *word[], char *word_eol[], void *user_data); -int wmpaNext(char *word[], char *word_eol[], void *user_data); -int wmpaPlay(char *word[], char *word_eol[], void *user_data); -int wmpaPause(char *word[], char *word_eol[], void *user_data); -int wmpaPrev(char *word[], char *word_eol[], void *user_data); -int wmpaSong(char *word[], char *word_eol[], void *user_data); -int wmpaStop(char *word[], char *word_eol[], void *user_data); -int wmpaVolume(char *word[], char *word_eol[], void *user_data); -int wmpaHelp(char *word[], char *word_eol[], void *user_data); -BOOL wmpaRestoreSettings(void); -BOOL wmpaSaveSettings(void); -CString wmpaGetSongTitle(void); -BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size); -BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size); - -#endif /* XCHAT_PLUGIN_H */ - -- cgit 1.4.1