From 73e66a02b1804f51e6b6803072d45543b58be635 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Wed, 12 Dec 2012 16:52:29 +0000 Subject: renamed back git-svn-id: http://svn.miranda-ng.org/main/trunk@2731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../ListeningTo/src/players/foo_mlt/foo_mlt.cpp | 392 +++++++++++++++++ .../ListeningTo/src/players/foo_mlt/foo_mlt_10.cpp | 392 ----------------- .../src/players/winamp_mlt/mlt_winamp.cpp | 470 +++++++++++++++++++++ .../src/players/winamp_mlt/mlt_winamp_10.cpp | 470 --------------------- plugins/testplugin/testplug.cpp | 76 ++++ plugins/testplugin/testplug_10.cpp | 76 ---- 6 files changed, 938 insertions(+), 938 deletions(-) create mode 100644 plugins/ListeningTo/src/players/foo_mlt/foo_mlt.cpp delete mode 100644 plugins/ListeningTo/src/players/foo_mlt/foo_mlt_10.cpp create mode 100644 plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp.cpp delete mode 100644 plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp_10.cpp create mode 100644 plugins/testplugin/testplug.cpp delete mode 100644 plugins/testplugin/testplug_10.cpp diff --git a/plugins/ListeningTo/src/players/foo_mlt/foo_mlt.cpp b/plugins/ListeningTo/src/players/foo_mlt/foo_mlt.cpp new file mode 100644 index 0000000000..dde1dfe15d --- /dev/null +++ b/plugins/ListeningTo/src/players/foo_mlt/foo_mlt.cpp @@ -0,0 +1,392 @@ +/* +Copyright (C) 2005-2009 Ricardo Pescuma Domenecci + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "foobar2000/SDK/foobar2000.h" +#include "foobar2000/helpers/helpers.h" +#include "m_listeningto.h" +#include +#include + + +using namespace pfc; + + +// Globals ////////////////////////////////////////////////////////////////////////////// + + +#define MIRANDA_DW_PROTECTION 0x8754 + +#define DATA_SIZE 1024 + +UINT timer = 0; +WCHAR lastSongData[DATA_SIZE] = L""; + +static bool g_off = true; //global state for sending listeningto infos + + +// Functions //////////////////////////////////////////////////////////////////////////// + + +BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) +{ + // Find the windows + TCHAR class_name[256]; + if (GetClassName(hwnd, class_name, 256)) + { + class_name[255] = _T('\0'); + + if (lstrcmpi(MIRANDA_WINDOWCLASS, class_name) == 0) + { + COPYDATASTRUCT *cds = (COPYDATASTRUCT *) lParam; + SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) cds); + } + } + + return TRUE; +} + +inline void SendData(WCHAR *text) +{ + static WCHAR lastMsg[DATA_SIZE] = L""; + + if (wcscmp(lastMsg, text) == 0) + return; + + // Prepare the struct + COPYDATASTRUCT cds; + cds.dwData = MIRANDA_DW_PROTECTION; + cds.lpData = text; + cds.cbData = (wcslen(text) + 1) * sizeof(WCHAR); + + EnumWindows(EnumWindowsProc, (LPARAM) &cds); + + wcsncpy(lastMsg, text, DATA_SIZE); + lastMsg[DATA_SIZE-1] = L'\0'; +} + + +void Concat(WCHAR *data, size_t &size, const char *str, size_t len = 0) +{ + if (size < 3 * sizeof(WCHAR)) + return; + + if (str != NULL) + { + if (len == 0) + len = strlen(str); + + if (size >= len + 3) + { + size -= MultiByteToWideChar(CP_UTF8, 0, str, len * sizeof(char), &data[DATA_SIZE - size], size * sizeof(WCHAR)); + data[DATA_SIZE - size] = L'\0'; + } + } + + wcscat(data, L"\\0"); + size -= 2; +} + + +void Concat(WCHAR *data, size_t &size) +{ + if (size < 3 * sizeof(WCHAR)) + return; + + wcscat(data, L"\\0"); + size -= 2; +} + + +void Concat(WCHAR *data, size_t &size, const WCHAR *str, size_t len = 0) +{ + if (size < 3 * sizeof(WCHAR)) + return; + + if (str != NULL) + { + if (len == 0) + len = wcslen(str); + + if (size >= len + 3) + { + wcscpy(&data[DATA_SIZE - size], str); + size -= len; + data[DATA_SIZE - size] = L'\0'; + } + } + + wcscat(data, L"\\0"); + size -= 2; +} + + +void GetMetadata(const file_info *info, char *field, WCHAR *data, size_t &size) +{ + const char *val = info->meta_get(field, 0); + if (val != NULL && val[0] != '\0') + { + Concat(data, size, val); + } + else + { + Concat(data, size); + } +} + + +void KillTimer(UINT id = 0) +{ + if (id != 0) + { + KillTimer(NULL, id); + } + if (timer != 0) + { + if (timer != id) + KillTimer(NULL, timer); + timer = 0; + } +} + + +void CALLBACK SendEmptyData(HWND hWnd = 0, UINT nMsg = 0, UINT nIDEvent = 0, DWORD dwTime = 0) +{ + KillTimer(nIDEvent); + + // L"\\0\\0\\0\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" + SendData(L"0\\0foobar2000\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); +} + + +void SetTimer() +{ + KillTimer(); + timer = SetTimer(NULL, 1, 1000, SendEmptyData); +} + + +BOOL IsRadio(metadb_handle_ptr p_track) +{ + const char *filename = p_track->get_path(); + return (filename != NULL && strstr(filename, "://") != 0 && strncmp(filename, "file://", 7) != 0); +} + + +void SendDataMusic(const char *filename, const file_info *info) +{ + WCHAR data[DATA_SIZE]; + size_t size = DATA_SIZE; + data[0] = L'\0'; + + // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" + Concat(data, size, "1"); + Concat(data, size, "foobar2000"); + Concat(data, size, "Music"); + + const char *val = info->meta_get("TITLE", 0); + if (val != NULL && val[0] != '\0') + { + Concat(data, size, val); + } + else if (filename != NULL && filename[0] != '\0') + { + const char *name = strrchr(filename, '\\'); + if (name == NULL) + strrchr(filename, '/'); + + if (name == NULL) + { + Concat(data, size); + } + else + { + const char *dot = strrchr(name, '.'); + Concat(data, size, name + 1, dot == NULL ? 0 : dot - name - 1); + } + } + else + { + Concat(data, size); + } + + GetMetadata(info, "ARTIST", data, size); + GetMetadata(info, "ALBUM", data, size); + GetMetadata(info, "TRACKNUMBER", data, size); + GetMetadata(info, "DATE", data, size); + GetMetadata(info, "GENRE", data, size); + + int len = (int) info->get_length(); + if (len > 0) + { + char tmp[10]; + Concat(data, size, itoa(len, tmp, 10)); + } + else + { + Concat(data, size); + } + + Concat(data, size); + + SendData(data); + wcsncpy(lastSongData, data, DATA_SIZE); + lastSongData[DATA_SIZE-1] = L'\0'; +} + +void SendDataRadio(const file_info *info, const file_info *info2) +{ + WCHAR data[DATA_SIZE]; + size_t size = DATA_SIZE; + data[0] = L'\0'; + + // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0<Station name>\\0" + Concat(data, size, "1"); + Concat(data, size, "foobar2000"); + Concat(data, size, "Radio"); + + GetMetadata(info, "TITLE", data, size); + GetMetadata(info, "ARTIST", data, size); + GetMetadata(info, "ALBUM", data, size); + GetMetadata(info, "TRACKNUMBER", data, size); + GetMetadata(info, "DATE", data, size); + GetMetadata(info2, "GENRE", data, size); + + int len = (int) info->get_length(); + if (len > 0) + { + char tmp[10]; + Concat(data, size, itoa(len, tmp, 10)); + } + else + { + Concat(data, size); + } + + // Station name + GetMetadata(info2, "TITLE", data, size); + + SendData(data); + wcsncpy(lastSongData, data, DATA_SIZE); + lastSongData[DATA_SIZE-1] = L'\0'; +} + + +// Foobar //////////////////////////////////////////////////////////////////////////// + +class play_callback_miranda : public play_callback_static +{ + virtual void on_playback_starting(play_control::t_track_command p_command, bool p_paused) {} + virtual void on_playback_new_track(metadb_handle_ptr p_track) + { + if (g_off) return; + + KillTimer(); + if (IsRadio(p_track)) + return; + + in_metadb_sync_fromhandle l_sync(p_track); + + const file_info *info; + if (p_track->get_info_locked(info)) + SendDataMusic(p_track->get_path(), info); + } + virtual void on_playback_stop(play_control::t_stop_reason p_reason) + { + if (g_off) return; + SetTimer(); + } + virtual void on_playback_seek(double p_time) {} + virtual void on_playback_pause(bool p_state) + { + if (g_off) return; + if (p_state) + { + SetTimer(); + } + else + { + KillTimer(); + if (lastSongData[0] != L'\0') + SendData(lastSongData); + } + } + virtual void on_playback_edited(metadb_handle_ptr p_track) {} + virtual void on_playback_dynamic_info(const file_info & info) {} + virtual void on_playback_dynamic_info_track(const file_info & info) + { + if (g_off) return; + metadb_handle_ptr p_track; + static_api_ptr_t<play_control>()->get_now_playing(p_track); + if (p_track.is_valid()) + { + if (IsRadio(p_track)) + { + in_metadb_sync_fromhandle l_sync(p_track); + + const file_info *info2; + if (!p_track->get_info_locked(info2)) + return; + + SendDataRadio(&info, info2); + } + p_track.release(); + } + } + virtual void on_playback_time(double p_time) {} + virtual void on_volume_change(float p_new_val) {}; + + virtual unsigned get_flags() + { + return flag_on_playback_new_track | flag_on_playback_pause | flag_on_playback_stop | flag_on_playback_dynamic_info_track; + } +}; + + +static play_callback_static_factory_t<play_callback_miranda> miranda_callback_factory; + +class myinitquit : public initquit { +public: + void on_init() + { + //check if foo_comserver2 is present and set g_off to false if foo_mlt go active + //TODO:detect foo_comserver2 from component list (can also check for other plugins) + CLSID clsid; + if(S_OK != CLSIDFromProgID(L"Foobar2000.Application.0.7", &clsid)) { + g_off = false; + SetTimer(); + } + } + void on_quit() + { + if (!g_off && FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SendData(L"0\\0foobar2000\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); + } +}; + +static initquit_factory_t<myinitquit> g_myinitquit_factory; + +DECLARE_COMPONENT_VERSION("Miranda ListeningTo foobar2000 Plugin", +"1.1.1", +"compiled with foo_SDK-2010-10-02\r\n\ +Sending listeningto information to Mitanda IM client\r\n\ +if no foo_comserver2 is present.\r\n\ +Copyright (C) 2006-2010 Ricardo Pescuma Domenecci\r\n\ +http://www.miranda-im.org\r\n\ +http://pescuma.org/miranda/listeningto" +) diff --git a/plugins/ListeningTo/src/players/foo_mlt/foo_mlt_10.cpp b/plugins/ListeningTo/src/players/foo_mlt/foo_mlt_10.cpp deleted file mode 100644 index dde1dfe15d..0000000000 --- a/plugins/ListeningTo/src/players/foo_mlt/foo_mlt_10.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -Copyright (C) 2005-2009 Ricardo Pescuma Domenecci - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "foobar2000/SDK/foobar2000.h" -#include "foobar2000/helpers/helpers.h" -#include "m_listeningto.h" -#include <windows.h> -#include <process.h> - - -using namespace pfc; - - -// Globals ////////////////////////////////////////////////////////////////////////////// - - -#define MIRANDA_DW_PROTECTION 0x8754 - -#define DATA_SIZE 1024 - -UINT timer = 0; -WCHAR lastSongData[DATA_SIZE] = L""; - -static bool g_off = true; //global state for sending listeningto infos - - -// Functions //////////////////////////////////////////////////////////////////////////// - - -BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - // Find the windows - TCHAR class_name[256]; - if (GetClassName(hwnd, class_name, 256)) - { - class_name[255] = _T('\0'); - - if (lstrcmpi(MIRANDA_WINDOWCLASS, class_name) == 0) - { - COPYDATASTRUCT *cds = (COPYDATASTRUCT *) lParam; - SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) cds); - } - } - - return TRUE; -} - -inline void SendData(WCHAR *text) -{ - static WCHAR lastMsg[DATA_SIZE] = L""; - - if (wcscmp(lastMsg, text) == 0) - return; - - // Prepare the struct - COPYDATASTRUCT cds; - cds.dwData = MIRANDA_DW_PROTECTION; - cds.lpData = text; - cds.cbData = (wcslen(text) + 1) * sizeof(WCHAR); - - EnumWindows(EnumWindowsProc, (LPARAM) &cds); - - wcsncpy(lastMsg, text, DATA_SIZE); - lastMsg[DATA_SIZE-1] = L'\0'; -} - - -void Concat(WCHAR *data, size_t &size, const char *str, size_t len = 0) -{ - if (size < 3 * sizeof(WCHAR)) - return; - - if (str != NULL) - { - if (len == 0) - len = strlen(str); - - if (size >= len + 3) - { - size -= MultiByteToWideChar(CP_UTF8, 0, str, len * sizeof(char), &data[DATA_SIZE - size], size * sizeof(WCHAR)); - data[DATA_SIZE - size] = L'\0'; - } - } - - wcscat(data, L"\\0"); - size -= 2; -} - - -void Concat(WCHAR *data, size_t &size) -{ - if (size < 3 * sizeof(WCHAR)) - return; - - wcscat(data, L"\\0"); - size -= 2; -} - - -void Concat(WCHAR *data, size_t &size, const WCHAR *str, size_t len = 0) -{ - if (size < 3 * sizeof(WCHAR)) - return; - - if (str != NULL) - { - if (len == 0) - len = wcslen(str); - - if (size >= len + 3) - { - wcscpy(&data[DATA_SIZE - size], str); - size -= len; - data[DATA_SIZE - size] = L'\0'; - } - } - - wcscat(data, L"\\0"); - size -= 2; -} - - -void GetMetadata(const file_info *info, char *field, WCHAR *data, size_t &size) -{ - const char *val = info->meta_get(field, 0); - if (val != NULL && val[0] != '\0') - { - Concat(data, size, val); - } - else - { - Concat(data, size); - } -} - - -void KillTimer(UINT id = 0) -{ - if (id != 0) - { - KillTimer(NULL, id); - } - if (timer != 0) - { - if (timer != id) - KillTimer(NULL, timer); - timer = 0; - } -} - - -void CALLBACK SendEmptyData(HWND hWnd = 0, UINT nMsg = 0, UINT nIDEvent = 0, DWORD dwTime = 0) -{ - KillTimer(nIDEvent); - - // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" - SendData(L"0\\0foobar2000\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); -} - - -void SetTimer() -{ - KillTimer(); - timer = SetTimer(NULL, 1, 1000, SendEmptyData); -} - - -BOOL IsRadio(metadb_handle_ptr p_track) -{ - const char *filename = p_track->get_path(); - return (filename != NULL && strstr(filename, "://") != 0 && strncmp(filename, "file://", 7) != 0); -} - - -void SendDataMusic(const char *filename, const file_info *info) -{ - WCHAR data[DATA_SIZE]; - size_t size = DATA_SIZE; - data[0] = L'\0'; - - // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" - Concat(data, size, "1"); - Concat(data, size, "foobar2000"); - Concat(data, size, "Music"); - - const char *val = info->meta_get("TITLE", 0); - if (val != NULL && val[0] != '\0') - { - Concat(data, size, val); - } - else if (filename != NULL && filename[0] != '\0') - { - const char *name = strrchr(filename, '\\'); - if (name == NULL) - strrchr(filename, '/'); - - if (name == NULL) - { - Concat(data, size); - } - else - { - const char *dot = strrchr(name, '.'); - Concat(data, size, name + 1, dot == NULL ? 0 : dot - name - 1); - } - } - else - { - Concat(data, size); - } - - GetMetadata(info, "ARTIST", data, size); - GetMetadata(info, "ALBUM", data, size); - GetMetadata(info, "TRACKNUMBER", data, size); - GetMetadata(info, "DATE", data, size); - GetMetadata(info, "GENRE", data, size); - - int len = (int) info->get_length(); - if (len > 0) - { - char tmp[10]; - Concat(data, size, itoa(len, tmp, 10)); - } - else - { - Concat(data, size); - } - - Concat(data, size); - - SendData(data); - wcsncpy(lastSongData, data, DATA_SIZE); - lastSongData[DATA_SIZE-1] = L'\0'; -} - -void SendDataRadio(const file_info *info, const file_info *info2) -{ - WCHAR data[DATA_SIZE]; - size_t size = DATA_SIZE; - data[0] = L'\0'; - - // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0<Station name>\\0" - Concat(data, size, "1"); - Concat(data, size, "foobar2000"); - Concat(data, size, "Radio"); - - GetMetadata(info, "TITLE", data, size); - GetMetadata(info, "ARTIST", data, size); - GetMetadata(info, "ALBUM", data, size); - GetMetadata(info, "TRACKNUMBER", data, size); - GetMetadata(info, "DATE", data, size); - GetMetadata(info2, "GENRE", data, size); - - int len = (int) info->get_length(); - if (len > 0) - { - char tmp[10]; - Concat(data, size, itoa(len, tmp, 10)); - } - else - { - Concat(data, size); - } - - // Station name - GetMetadata(info2, "TITLE", data, size); - - SendData(data); - wcsncpy(lastSongData, data, DATA_SIZE); - lastSongData[DATA_SIZE-1] = L'\0'; -} - - -// Foobar //////////////////////////////////////////////////////////////////////////// - -class play_callback_miranda : public play_callback_static -{ - virtual void on_playback_starting(play_control::t_track_command p_command, bool p_paused) {} - virtual void on_playback_new_track(metadb_handle_ptr p_track) - { - if (g_off) return; - - KillTimer(); - if (IsRadio(p_track)) - return; - - in_metadb_sync_fromhandle l_sync(p_track); - - const file_info *info; - if (p_track->get_info_locked(info)) - SendDataMusic(p_track->get_path(), info); - } - virtual void on_playback_stop(play_control::t_stop_reason p_reason) - { - if (g_off) return; - SetTimer(); - } - virtual void on_playback_seek(double p_time) {} - virtual void on_playback_pause(bool p_state) - { - if (g_off) return; - if (p_state) - { - SetTimer(); - } - else - { - KillTimer(); - if (lastSongData[0] != L'\0') - SendData(lastSongData); - } - } - virtual void on_playback_edited(metadb_handle_ptr p_track) {} - virtual void on_playback_dynamic_info(const file_info & info) {} - virtual void on_playback_dynamic_info_track(const file_info & info) - { - if (g_off) return; - metadb_handle_ptr p_track; - static_api_ptr_t<play_control>()->get_now_playing(p_track); - if (p_track.is_valid()) - { - if (IsRadio(p_track)) - { - in_metadb_sync_fromhandle l_sync(p_track); - - const file_info *info2; - if (!p_track->get_info_locked(info2)) - return; - - SendDataRadio(&info, info2); - } - p_track.release(); - } - } - virtual void on_playback_time(double p_time) {} - virtual void on_volume_change(float p_new_val) {}; - - virtual unsigned get_flags() - { - return flag_on_playback_new_track | flag_on_playback_pause | flag_on_playback_stop | flag_on_playback_dynamic_info_track; - } -}; - - -static play_callback_static_factory_t<play_callback_miranda> miranda_callback_factory; - -class myinitquit : public initquit { -public: - void on_init() - { - //check if foo_comserver2 is present and set g_off to false if foo_mlt go active - //TODO:detect foo_comserver2 from component list (can also check for other plugins) - CLSID clsid; - if(S_OK != CLSIDFromProgID(L"Foobar2000.Application.0.7", &clsid)) { - g_off = false; - SetTimer(); - } - } - void on_quit() - { - if (!g_off && FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SendData(L"0\\0foobar2000\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); - } -}; - -static initquit_factory_t<myinitquit> g_myinitquit_factory; - -DECLARE_COMPONENT_VERSION("Miranda ListeningTo foobar2000 Plugin", -"1.1.1", -"compiled with foo_SDK-2010-10-02\r\n\ -Sending listeningto information to Mitanda IM client\r\n\ -if no foo_comserver2 is present.\r\n\ -Copyright (C) 2006-2010 Ricardo Pescuma Domenecci\r\n\ -http://www.miranda-im.org\r\n\ -http://pescuma.org/miranda/listeningto" -) diff --git a/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp.cpp b/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp.cpp new file mode 100644 index 0000000000..66a1f5984d --- /dev/null +++ b/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp.cpp @@ -0,0 +1,470 @@ +/* +Copyright (C) 2005-2009 Ricardo Pescuma Domenecci + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + + +#include <windows.h> +#include <tchar.h> +#include <stdio.h> +#include <process.h> +#include "m_listeningto.h" + +#include "wa_ipc.h" +#include "GEN.h" + +// Plugin data ////////////////////////////////////////////////////////////////////////// + +int init(); +void quit(); +void config(); + +winampGeneralPurposePlugin plugin = { + GPPHDR_VER, + "Miranda ListeningTo Winamp Plugin", // Plug-in description + init, + config, + quit, + 0, // handle to Winamp main window, loaded by winamp when this dll is loaded + 0 // hinstance to this dll, loaded by winamp when this dll is loaded +}; + + +// Globals ////////////////////////////////////////////////////////////////////////////// + + +#define MIRANDA_DW_PROTECTION 0x8754 + +#define MESSAGE_WINDOWCLASS MIRANDA_WINDOWCLASS ".Winamp" + +#define DATA_SIZE 1024 + +#define WA_STATE_CHANGE 0x0000029A + +WNDPROC oldWndProc = NULL; +WNDPROC oldMainWndProc = NULL; +HMENU hMenuCreated = NULL; +HWND hMsgWnd = NULL; +HWND hPlWnd = NULL; +HINSTANCE hInst = NULL; + +// Message window proc +LRESULT CALLBACK MsgWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +// Playlist window message processor +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + + + +// Functions //////////////////////////////////////////////////////////////////////////// + + +void WindowThread(void *param) +{ + // Create window + WNDCLASS wc = {0}; + wc.lpfnWndProc = MsgWndProc; + wc.hInstance = hInst; + wc.lpszClassName = MESSAGE_WINDOWCLASS; + + RegisterClass(&wc); + + hMsgWnd = CreateWindow(MESSAGE_WINDOWCLASS, _T("Miranda ListeningTo Winamp Plugin"), + 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL); + + if (hMsgWnd != NULL) + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SetTimer(hMsgWnd, 0, 5000, NULL); + + MSG msg; + BOOL bRet; + while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) + { + if (bRet == -1) + { + // handle the error and possibly exit + break; + } + else + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + _endthread(); +} + +extern "C" BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + { + hInst = hInstDll; + + plugin.hwndParent = NULL; + + _beginthread(WindowThread, 0, NULL); + } + + return TRUE; +} + +// Winamp interface function +extern "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() +{ + KillTimer(hMsgWnd, 0); + + return &plugin; +} + +BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) +{ + // Find the windows + char class_name[1024]; + if (GetClassName(hwnd, class_name, sizeof(class_name))) + { + class_name[sizeof(class_name)-1] = '\0'; + + if (_strcmpi(MIRANDA_WINDOWCLASS, class_name) == 0) + { + COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam; + SendMessage(hwnd, WM_COPYDATA, (WPARAM) plugin.hwndParent, (LPARAM) cds); + } + } + + return TRUE; +} + +inline void SendData(WCHAR *text) +{ + static WCHAR lastMsg[1024] = L""; + + if (wcscmp(lastMsg, text) == 0) + return; + + // Prepare the struct + COPYDATASTRUCT cds; + cds.dwData = MIRANDA_DW_PROTECTION; + cds.lpData = text; + cds.cbData = (wcslen(text) + 1) * sizeof(WCHAR); + + EnumWindows(EnumWindowsProc, (LPARAM) &cds); + + wcsncpy(lastMsg, text, 1024); + lastMsg[1023] = L'\0'; +} + + +void Concat(WCHAR *data, size_t &size, char *str, size_t len = 0) +{ + if (size < 3 * sizeof(WCHAR)) + return; + + if (str != NULL) + { + if (len == 0) + len = strlen(str); + + if (size >= len + 3) + { + MultiByteToWideChar(CP_ACP, 0, str, len * sizeof(char), &data[DATA_SIZE - size], size * sizeof(WCHAR)); + size -= len; + data[DATA_SIZE - size] = L'\0'; + } + } + + wcscat(data, L"\\0"); + size -= 2; +} + + +void GetMetadata(extendedFileInfoStruct *efi, char *field, WCHAR *data, size_t &size) +{ + efi->ret[0] = '\0'; + efi->metadata = field; + if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) && efi->ret[0] != '\0') + { + Concat(data, size, efi->ret); + } + else + { + Concat(data, size, NULL); + } +} + + +void SendDataToMiranda(char *filename, char *title) +{ + extendedFileInfoStruct efi; + char tmp[256]; + + efi.ret = tmp; + efi.retlen = sizeof(tmp); + efi.filename = filename; + + WCHAR data[DATA_SIZE]; + size_t size = DATA_SIZE; + data[0] = L'\0'; + + // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" + Concat(data, size, "1"); + Concat(data, size, "Winamp"); + + int version = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETVERSION); + BOOL is_radio = (strstr(filename, "://") != 0) && (strncmp(filename, "cda://", 6) != 0); + + if (is_radio) + Concat(data, size, "Radio"); + else if (WINAMP_VERSION_MAJOR(version) >= 5 && SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_IS_PLAYING_VIDEO)) + Concat(data, size, "Video"); + else + Concat(data, size, "Music"); + + efi.ret[0] = '\0'; + efi.metadata = "TITLE"; + if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) &efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) && efi.ret[0] != '\0') + { + Concat(data, size, efi.ret); + } + else if (title != NULL && title[0] != '\0' && strcmpi(title, filename) != 0) + { + Concat(data, size, title); + } + else + { + char *name = strrchr(filename, '\\'); + if (name == NULL) + strrchr(filename, '/'); + + if (name == NULL) + { + Concat(data, size, NULL); + } + else + { + char *dot = strrchr(name, '.'); + Concat(data, size, name + 1, dot == NULL ? 0 : dot - name - 1); + } + } + + GetMetadata(&efi, "ARTIST", data, size); + GetMetadata(&efi, "ALBUM", data, size); + GetMetadata(&efi, "TRACK", data, size); + GetMetadata(&efi, "YEAR", data, size); + GetMetadata(&efi, "GENRE", data, size); + + efi.ret[0] = '\0'; + efi.metadata = "LENGTH"; + if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) &efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) + && efi.ret[0] != '\0' && efi.ret[1] != '\0') + { + char tmp[10]; + itoa(atoi(efi.ret) / 1000, tmp, 10); + Concat(data, size, tmp); + } + else + { + Concat(data, size, NULL); + } + Concat(data, size, NULL); + + SendData(data); +} + + +// Message window proc +LRESULT CALLBACK MsgWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static BOOL last_was_stop = TRUE; + static DWORD last_notification = 0; + static char last_filename[1024] = {0}; + + switch(message) + { + case WM_TIMER: + { + KillTimer(hwnd, wParam); + + if (wParam == 0) + { + // Startup + if (plugin.hwndParent == NULL) + { + plugin.hwndParent = FindWindow("Winamp v1.x", NULL); + if (plugin.hwndParent != NULL) + { + init(); + + // If playing, show current song + if (SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING) == 1) + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SetTimer(hMsgWnd, 1, 500, NULL); + } + } + } + else if (wParam == 1) + { + // Song change + if (SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING) == 1) + { + int track = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETLISTPOS); + char *filename = (char *) SendMessage(plugin.hwndParent, WM_WA_IPC, track, IPC_GETPLAYLISTFILE); + + if (filename == NULL || filename[0] == '\0') + { + if (!last_was_stop) + { + last_was_stop = TRUE; + + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); + } + } + else + { + BOOL is_radio = (strstr(filename, "://") != 0); + if (last_was_stop || is_radio || strcmpi(last_filename, filename) != 0) + { + last_was_stop = FALSE; + strncpy(last_filename, filename, sizeof(last_filename)); + last_filename[sizeof(last_filename) - 1] = '\0'; + + // Miranda is running? + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SendDataToMiranda(last_filename, (char *) SendMessage(plugin.hwndParent, WM_WA_IPC, track, IPC_GETPLAYLISTTITLE)); + + if (is_radio) + // To try to get info from radio stations + SetTimer(hMsgWnd, 1, 3000, NULL); + } + } + } + else + { + if (!last_was_stop) + { + last_was_stop = TRUE; + + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); + } + } + } + + break; + } + } + + return DefWindowProc(hwnd, message, wParam, lParam); +} + +// Playlist window message processor +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_USER: + { + if(wParam == WA_STATE_CHANGE) + { + int type = HIWORD(lParam); + if(type == 0x4000 || type == 0) + { + KillTimer(hMsgWnd, 1); + SetTimer(hMsgWnd, 1, 1000, NULL); + } + } + break; + } + } + + return CallWindowProc(oldWndProc, hwnd, message, wParam, lParam); +} + + +LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_COMMAND: + { + switch(wParam) + { + case 40045: // Play + case 40046: // Pause + { + KillTimer(hMsgWnd, 1); + SetTimer(hMsgWnd, 1, 500, NULL); + break; + } + } + break; + } + case WM_WA_IPC: + { + switch(lParam) + { + case IPC_PLAYING_FILE: + { + KillTimer(hMsgWnd, 1); + SetTimer(hMsgWnd, 1, 500, NULL); + break; + } + } + break; + } + case WM_CLOSE: + { + PostMessage(hMsgWnd, WM_TIMER, 1, 0); + PostMessage(hMsgWnd, WM_CLOSE, 0, 0); + break; + } + } + + return CallWindowProc(oldMainWndProc, hwnd, message, wParam, lParam); +} + + +void quit() +{ + if (oldMainWndProc != NULL) + SetWindowLongPtr(plugin.hwndParent, GWLP_WNDPROC, (LONG) oldMainWndProc); + + if (oldWndProc != NULL) + SetWindowLongPtr(hPlWnd, GWLP_WNDPROC, (LONG) oldWndProc); + + if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) + SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); + +} + + +int init() +{ + KillTimer(hMsgWnd, 0); + + oldMainWndProc = (WNDPROC)SetWindowLongPtr(plugin.hwndParent, GWLP_WNDPROC, (LONG) MainWndProc); + + hPlWnd = (HWND) SendMessage(plugin.hwndParent, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND); + oldWndProc = (WNDPROC) SetWindowLongPtr(hPlWnd, GWLP_WNDPROC, (LONG)WndProc); + + return 0; +} + +void config() { + MessageBox(NULL, _T("Copyright (C) 2006 Ricardo Pescuma Domenecci"), _T("Miranda ListeningTo Winamp Plugin"), 0); +} diff --git a/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp_10.cpp b/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp_10.cpp deleted file mode 100644 index 66a1f5984d..0000000000 --- a/plugins/ListeningTo/src/players/winamp_mlt/mlt_winamp_10.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* -Copyright (C) 2005-2009 Ricardo Pescuma Domenecci - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - - -#include <windows.h> -#include <tchar.h> -#include <stdio.h> -#include <process.h> -#include "m_listeningto.h" - -#include "wa_ipc.h" -#include "GEN.h" - -// Plugin data ////////////////////////////////////////////////////////////////////////// - -int init(); -void quit(); -void config(); - -winampGeneralPurposePlugin plugin = { - GPPHDR_VER, - "Miranda ListeningTo Winamp Plugin", // Plug-in description - init, - config, - quit, - 0, // handle to Winamp main window, loaded by winamp when this dll is loaded - 0 // hinstance to this dll, loaded by winamp when this dll is loaded -}; - - -// Globals ////////////////////////////////////////////////////////////////////////////// - - -#define MIRANDA_DW_PROTECTION 0x8754 - -#define MESSAGE_WINDOWCLASS MIRANDA_WINDOWCLASS ".Winamp" - -#define DATA_SIZE 1024 - -#define WA_STATE_CHANGE 0x0000029A - -WNDPROC oldWndProc = NULL; -WNDPROC oldMainWndProc = NULL; -HMENU hMenuCreated = NULL; -HWND hMsgWnd = NULL; -HWND hPlWnd = NULL; -HINSTANCE hInst = NULL; - -// Message window proc -LRESULT CALLBACK MsgWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -// Playlist window message processor -LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - - - -// Functions //////////////////////////////////////////////////////////////////////////// - - -void WindowThread(void *param) -{ - // Create window - WNDCLASS wc = {0}; - wc.lpfnWndProc = MsgWndProc; - wc.hInstance = hInst; - wc.lpszClassName = MESSAGE_WINDOWCLASS; - - RegisterClass(&wc); - - hMsgWnd = CreateWindow(MESSAGE_WINDOWCLASS, _T("Miranda ListeningTo Winamp Plugin"), - 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL); - - if (hMsgWnd != NULL) - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SetTimer(hMsgWnd, 0, 5000, NULL); - - MSG msg; - BOOL bRet; - while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) - { - if (bRet == -1) - { - // handle the error and possibly exit - break; - } - else - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - _endthread(); -} - -extern "C" BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - hInst = hInstDll; - - plugin.hwndParent = NULL; - - _beginthread(WindowThread, 0, NULL); - } - - return TRUE; -} - -// Winamp interface function -extern "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() -{ - KillTimer(hMsgWnd, 0); - - return &plugin; -} - -BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - // Find the windows - char class_name[1024]; - if (GetClassName(hwnd, class_name, sizeof(class_name))) - { - class_name[sizeof(class_name)-1] = '\0'; - - if (_strcmpi(MIRANDA_WINDOWCLASS, class_name) == 0) - { - COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam; - SendMessage(hwnd, WM_COPYDATA, (WPARAM) plugin.hwndParent, (LPARAM) cds); - } - } - - return TRUE; -} - -inline void SendData(WCHAR *text) -{ - static WCHAR lastMsg[1024] = L""; - - if (wcscmp(lastMsg, text) == 0) - return; - - // Prepare the struct - COPYDATASTRUCT cds; - cds.dwData = MIRANDA_DW_PROTECTION; - cds.lpData = text; - cds.cbData = (wcslen(text) + 1) * sizeof(WCHAR); - - EnumWindows(EnumWindowsProc, (LPARAM) &cds); - - wcsncpy(lastMsg, text, 1024); - lastMsg[1023] = L'\0'; -} - - -void Concat(WCHAR *data, size_t &size, char *str, size_t len = 0) -{ - if (size < 3 * sizeof(WCHAR)) - return; - - if (str != NULL) - { - if (len == 0) - len = strlen(str); - - if (size >= len + 3) - { - MultiByteToWideChar(CP_ACP, 0, str, len * sizeof(char), &data[DATA_SIZE - size], size * sizeof(WCHAR)); - size -= len; - data[DATA_SIZE - size] = L'\0'; - } - } - - wcscat(data, L"\\0"); - size -= 2; -} - - -void GetMetadata(extendedFileInfoStruct *efi, char *field, WCHAR *data, size_t &size) -{ - efi->ret[0] = '\0'; - efi->metadata = field; - if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) && efi->ret[0] != '\0') - { - Concat(data, size, efi->ret); - } - else - { - Concat(data, size, NULL); - } -} - - -void SendDataToMiranda(char *filename, char *title) -{ - extendedFileInfoStruct efi; - char tmp[256]; - - efi.ret = tmp; - efi.retlen = sizeof(tmp); - efi.filename = filename; - - WCHAR data[DATA_SIZE]; - size_t size = DATA_SIZE; - data[0] = L'\0'; - - // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" - Concat(data, size, "1"); - Concat(data, size, "Winamp"); - - int version = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETVERSION); - BOOL is_radio = (strstr(filename, "://") != 0) && (strncmp(filename, "cda://", 6) != 0); - - if (is_radio) - Concat(data, size, "Radio"); - else if (WINAMP_VERSION_MAJOR(version) >= 5 && SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_IS_PLAYING_VIDEO)) - Concat(data, size, "Video"); - else - Concat(data, size, "Music"); - - efi.ret[0] = '\0'; - efi.metadata = "TITLE"; - if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) &efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) && efi.ret[0] != '\0') - { - Concat(data, size, efi.ret); - } - else if (title != NULL && title[0] != '\0' && strcmpi(title, filename) != 0) - { - Concat(data, size, title); - } - else - { - char *name = strrchr(filename, '\\'); - if (name == NULL) - strrchr(filename, '/'); - - if (name == NULL) - { - Concat(data, size, NULL); - } - else - { - char *dot = strrchr(name, '.'); - Concat(data, size, name + 1, dot == NULL ? 0 : dot - name - 1); - } - } - - GetMetadata(&efi, "ARTIST", data, size); - GetMetadata(&efi, "ALBUM", data, size); - GetMetadata(&efi, "TRACK", data, size); - GetMetadata(&efi, "YEAR", data, size); - GetMetadata(&efi, "GENRE", data, size); - - efi.ret[0] = '\0'; - efi.metadata = "LENGTH"; - if (SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM) &efi, IPC_GET_EXTENDED_FILE_INFO_HOOKABLE) - && efi.ret[0] != '\0' && efi.ret[1] != '\0') - { - char tmp[10]; - itoa(atoi(efi.ret) / 1000, tmp, 10); - Concat(data, size, tmp); - } - else - { - Concat(data, size, NULL); - } - Concat(data, size, NULL); - - SendData(data); -} - - -// Message window proc -LRESULT CALLBACK MsgWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - static BOOL last_was_stop = TRUE; - static DWORD last_notification = 0; - static char last_filename[1024] = {0}; - - switch(message) - { - case WM_TIMER: - { - KillTimer(hwnd, wParam); - - if (wParam == 0) - { - // Startup - if (plugin.hwndParent == NULL) - { - plugin.hwndParent = FindWindow("Winamp v1.x", NULL); - if (plugin.hwndParent != NULL) - { - init(); - - // If playing, show current song - if (SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING) == 1) - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SetTimer(hMsgWnd, 1, 500, NULL); - } - } - } - else if (wParam == 1) - { - // Song change - if (SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING) == 1) - { - int track = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETLISTPOS); - char *filename = (char *) SendMessage(plugin.hwndParent, WM_WA_IPC, track, IPC_GETPLAYLISTFILE); - - if (filename == NULL || filename[0] == '\0') - { - if (!last_was_stop) - { - last_was_stop = TRUE; - - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); - } - } - else - { - BOOL is_radio = (strstr(filename, "://") != 0); - if (last_was_stop || is_radio || strcmpi(last_filename, filename) != 0) - { - last_was_stop = FALSE; - strncpy(last_filename, filename, sizeof(last_filename)); - last_filename[sizeof(last_filename) - 1] = '\0'; - - // Miranda is running? - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SendDataToMiranda(last_filename, (char *) SendMessage(plugin.hwndParent, WM_WA_IPC, track, IPC_GETPLAYLISTTITLE)); - - if (is_radio) - // To try to get info from radio stations - SetTimer(hMsgWnd, 1, 3000, NULL); - } - } - } - else - { - if (!last_was_stop) - { - last_was_stop = TRUE; - - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); - } - } - } - - break; - } - } - - return DefWindowProc(hwnd, message, wParam, lParam); -} - -// Playlist window message processor -LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_USER: - { - if(wParam == WA_STATE_CHANGE) - { - int type = HIWORD(lParam); - if(type == 0x4000 || type == 0) - { - KillTimer(hMsgWnd, 1); - SetTimer(hMsgWnd, 1, 1000, NULL); - } - } - break; - } - } - - return CallWindowProc(oldWndProc, hwnd, message, wParam, lParam); -} - - -LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_COMMAND: - { - switch(wParam) - { - case 40045: // Play - case 40046: // Pause - { - KillTimer(hMsgWnd, 1); - SetTimer(hMsgWnd, 1, 500, NULL); - break; - } - } - break; - } - case WM_WA_IPC: - { - switch(lParam) - { - case IPC_PLAYING_FILE: - { - KillTimer(hMsgWnd, 1); - SetTimer(hMsgWnd, 1, 500, NULL); - break; - } - } - break; - } - case WM_CLOSE: - { - PostMessage(hMsgWnd, WM_TIMER, 1, 0); - PostMessage(hMsgWnd, WM_CLOSE, 0, 0); - break; - } - } - - return CallWindowProc(oldMainWndProc, hwnd, message, wParam, lParam); -} - - -void quit() -{ - if (oldMainWndProc != NULL) - SetWindowLongPtr(plugin.hwndParent, GWLP_WNDPROC, (LONG) oldMainWndProc); - - if (oldWndProc != NULL) - SetWindowLongPtr(hPlWnd, GWLP_WNDPROC, (LONG) oldWndProc); - - if (FindWindow(MIRANDA_WINDOWCLASS, NULL) != NULL) - SendData(L"0\\0Winamp\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0"); - -} - - -int init() -{ - KillTimer(hMsgWnd, 0); - - oldMainWndProc = (WNDPROC)SetWindowLongPtr(plugin.hwndParent, GWLP_WNDPROC, (LONG) MainWndProc); - - hPlWnd = (HWND) SendMessage(plugin.hwndParent, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND); - oldWndProc = (WNDPROC) SetWindowLongPtr(hPlWnd, GWLP_WNDPROC, (LONG)WndProc); - - return 0; -} - -void config() { - MessageBox(NULL, _T("Copyright (C) 2006 Ricardo Pescuma Domenecci"), _T("Miranda ListeningTo Winamp Plugin"), 0); -} diff --git a/plugins/testplugin/testplug.cpp b/plugins/testplugin/testplug.cpp new file mode 100644 index 0000000000..2c98789edc --- /dev/null +++ b/plugins/testplugin/testplug.cpp @@ -0,0 +1,76 @@ +/* +Miranda NG plugin template +http://miranda-ng.org/ + +This file is placed in the public domain. Anybody is free to use or +modify it as they wish with no restriction. +There is no warranty. +*/ + +#include <windows.h> +#include <tchar.h> + +#include <newpluginapi.h> +#include <m_langpack.h> +#include <m_clist.h> +#include <m_skin.h> + +HINSTANCE hInst = NULL; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "Plugin Template", + PLUGIN_MAKE_VERSION(0,0,0,2), + "The long description of your plugin, to go in the plugin options dialog", + "J. Random Hacker", + "noreply@sourceforge.net", + "© 2002 J. Random Hacker", + "http://miranda-ng.org/", + UNICODE_AWARE, //not transient + // Generate your own unique id for your plugin. + // Do not use this UUID! + // Use uuidgen.exe to generate the uuuid + {0x8b86253, 0xec6e, 0x4d09, { 0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8 }} //{08B86253-EC6E-4d09-B7A9-64ACDF0627B8} +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) +{ + MessageBox(NULL, TranslateT("Just groovy, baby!"), TranslateT("Plugin-o-rama"), MB_OK); + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID interfaces[] = {MIID_TESTPLUGIN, MIID_LAST}; + +extern "C" __declspec(dllexport) int Load() +{ + mir_getLP(&pluginInfo); + + CLISTMENUITEM mi = {0}; + + CreateServiceFunction("TestPlug/MenuCommand", PluginMenuCommand); + mi.cbSize = sizeof(mi); + mi.position = -0x7FFFFFFF; + mi.flags = CMIF_TCHAR; + mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA); + mi.ptszName = LPGENT("&Test Plugin..."); + mi.pszService = "TestPlug/MenuCommand"; + Menu_AddMainMenuItem(&mi); + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + return 0; +} diff --git a/plugins/testplugin/testplug_10.cpp b/plugins/testplugin/testplug_10.cpp deleted file mode 100644 index 2c98789edc..0000000000 --- a/plugins/testplugin/testplug_10.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -Miranda NG plugin template -http://miranda-ng.org/ - -This file is placed in the public domain. Anybody is free to use or -modify it as they wish with no restriction. -There is no warranty. -*/ - -#include <windows.h> -#include <tchar.h> - -#include <newpluginapi.h> -#include <m_langpack.h> -#include <m_clist.h> -#include <m_skin.h> - -HINSTANCE hInst = NULL; -int hLangpack; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - "Plugin Template", - PLUGIN_MAKE_VERSION(0,0,0,2), - "The long description of your plugin, to go in the plugin options dialog", - "J. Random Hacker", - "noreply@sourceforge.net", - "© 2002 J. Random Hacker", - "http://miranda-ng.org/", - UNICODE_AWARE, //not transient - // Generate your own unique id for your plugin. - // Do not use this UUID! - // Use uuidgen.exe to generate the uuuid - {0x8b86253, 0xec6e, 0x4d09, { 0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8 }} //{08B86253-EC6E-4d09-B7A9-64ACDF0627B8} -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) -{ - MessageBox(NULL, TranslateT("Just groovy, baby!"), TranslateT("Plugin-o-rama"), MB_OK); - return 0; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID interfaces[] = {MIID_TESTPLUGIN, MIID_LAST}; - -extern "C" __declspec(dllexport) int Load() -{ - mir_getLP(&pluginInfo); - - CLISTMENUITEM mi = {0}; - - CreateServiceFunction("TestPlug/MenuCommand", PluginMenuCommand); - mi.cbSize = sizeof(mi); - mi.position = -0x7FFFFFFF; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA); - mi.ptszName = LPGENT("&Test Plugin..."); - mi.pszService = "TestPlug/MenuCommand"; - Menu_AddMainMenuItem(&mi); - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - return 0; -} -- cgit v1.2.3