From d1eea8fde5e87bd79317b923ae61b43b6f9081a4 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 15 Mar 2013 08:17:46 +0000 Subject: files renaming git-svn-id: http://svn.miranda-ng.org/main/trunk@4038 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Watrack_MPD/src/init.c | 95 -------- plugins/Watrack_MPD/src/init.cpp | 95 ++++++++ plugins/Watrack_MPD/src/main.c | 433 ---------------------------------- plugins/Watrack_MPD/src/main.cpp | 433 ++++++++++++++++++++++++++++++++++ plugins/Watrack_MPD/src/options.c | 91 ------- plugins/Watrack_MPD/src/options.cpp | 91 +++++++ plugins/Watrack_MPD/src/utilities.c | 48 ---- plugins/Watrack_MPD/src/utilities.cpp | 48 ++++ 8 files changed, 667 insertions(+), 667 deletions(-) delete mode 100755 plugins/Watrack_MPD/src/init.c create mode 100755 plugins/Watrack_MPD/src/init.cpp delete mode 100755 plugins/Watrack_MPD/src/main.c create mode 100755 plugins/Watrack_MPD/src/main.cpp delete mode 100755 plugins/Watrack_MPD/src/options.c create mode 100755 plugins/Watrack_MPD/src/options.cpp delete mode 100755 plugins/Watrack_MPD/src/utilities.c create mode 100755 plugins/Watrack_MPD/src/utilities.cpp (limited to 'plugins') diff --git a/plugins/Watrack_MPD/src/init.c b/plugins/Watrack_MPD/src/init.c deleted file mode 100755 index bfd7199856..0000000000 --- a/plugins/Watrack_MPD/src/init.c +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright © 2009-2010 sss -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "commonheaders.h" - -#define PLUGIN_NAME "Watrack_MPD" - -HINSTANCE hInst; -BOOL bWatrackService = FALSE; -int hLangpack = 0; -static int OnModulesLoaded(WPARAM wParam,LPARAM lParam); -extern char *date(); -extern int WaMpdOptInit(WPARAM wParam,LPARAM lParam); - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - PLUGIN_NAME, - PLUGIN_MAKE_VERSION(0,0,0,4), - "Music Player Daemon support for Watrack.", - "sss, others..", - "sss123next@list.ru", - "© 2009 sss, others...", - "http://sss.chaoslab.ru:81/tracker/mim_plugs/", - UNICODE_AWARE, - // 692E87D0-6C71-4CDC-9E36-2B69FBDC4C - {0x692e87d0, 0x6c71, 0x4cdc, {0x9e, 0x36, 0x2b, 0x2d, 0x69, 0xfb, 0xdc, 0x4c}} -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -int __declspec(dllexport) Load() -{ - mir_getLP(&pluginInfo); - HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - return 0; -} - -void InitVars() -{ - gbPort = DBGetContactSettingWord(NULL, szModuleName, "Port", 6600); - gbPassword = (TCHAR*)malloc(64*sizeof(TCHAR)); - gbHost = (TCHAR*)malloc(128*sizeof(TCHAR)); - gbHost = UniGetContactSettingUtf(NULL, szModuleName, "Server", _T("127.0.0.1")); - gbPassword = UniGetContactSettingUtf(NULL, szModuleName, "Password", _T("")); -} - - -extern void RegisterPlayer(); -static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) -{ - HANDLE hHookOptionInit; - NETLIBUSER nlu = {0}; - nlu.cbSize = sizeof(nlu); - nlu.flags = (NUF_OUTGOING | NUF_HTTPCONNS); - nlu.szDescriptiveName = "Watrack MPD connection"; - nlu.szSettingsModule = PLUGIN_NAME; - ghNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); - InitVars(); - hHookOptionInit = HookEvent(ME_OPT_INITIALISE, WaMpdOptInit); - if (ServiceExists("WATrack/Player")) - bWatrackService = TRUE; - RegisterPlayer(); - - return 0; -} - - -int __declspec(dllexport) Unload(void) -{ - free(gbHost); - free(gbPassword); - return 0; -} diff --git a/plugins/Watrack_MPD/src/init.cpp b/plugins/Watrack_MPD/src/init.cpp new file mode 100755 index 0000000000..bfd7199856 --- /dev/null +++ b/plugins/Watrack_MPD/src/init.cpp @@ -0,0 +1,95 @@ +// Copyright © 2009-2010 sss +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "commonheaders.h" + +#define PLUGIN_NAME "Watrack_MPD" + +HINSTANCE hInst; +BOOL bWatrackService = FALSE; +int hLangpack = 0; +static int OnModulesLoaded(WPARAM wParam,LPARAM lParam); +extern char *date(); +extern int WaMpdOptInit(WPARAM wParam,LPARAM lParam); + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + PLUGIN_NAME, + PLUGIN_MAKE_VERSION(0,0,0,4), + "Music Player Daemon support for Watrack.", + "sss, others..", + "sss123next@list.ru", + "© 2009 sss, others...", + "http://sss.chaoslab.ru:81/tracker/mim_plugs/", + UNICODE_AWARE, + // 692E87D0-6C71-4CDC-9E36-2B69FBDC4C + {0x692e87d0, 0x6c71, 0x4cdc, {0x9e, 0x36, 0x2b, 0x2d, 0x69, 0xfb, 0xdc, 0x4c}} +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +int __declspec(dllexport) Load() +{ + mir_getLP(&pluginInfo); + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + return 0; +} + +void InitVars() +{ + gbPort = DBGetContactSettingWord(NULL, szModuleName, "Port", 6600); + gbPassword = (TCHAR*)malloc(64*sizeof(TCHAR)); + gbHost = (TCHAR*)malloc(128*sizeof(TCHAR)); + gbHost = UniGetContactSettingUtf(NULL, szModuleName, "Server", _T("127.0.0.1")); + gbPassword = UniGetContactSettingUtf(NULL, szModuleName, "Password", _T("")); +} + + +extern void RegisterPlayer(); +static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + HANDLE hHookOptionInit; + NETLIBUSER nlu = {0}; + nlu.cbSize = sizeof(nlu); + nlu.flags = (NUF_OUTGOING | NUF_HTTPCONNS); + nlu.szDescriptiveName = "Watrack MPD connection"; + nlu.szSettingsModule = PLUGIN_NAME; + ghNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + InitVars(); + hHookOptionInit = HookEvent(ME_OPT_INITIALISE, WaMpdOptInit); + if (ServiceExists("WATrack/Player")) + bWatrackService = TRUE; + RegisterPlayer(); + + return 0; +} + + +int __declspec(dllexport) Unload(void) +{ + free(gbHost); + free(gbPassword); + return 0; +} diff --git a/plugins/Watrack_MPD/src/main.c b/plugins/Watrack_MPD/src/main.c deleted file mode 100755 index 17a8c29d64..0000000000 --- a/plugins/Watrack_MPD/src/main.c +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright © 2008 sss, chaos.persei -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - - - -#include "commonheaders.h" - - -//maybe add mutex ? -void Start(void *param); -int Parser(); - -LPINITPROC Init() -{ - mir_forkthread(&Start, 0); - return 0; -} -void Stop(); -LPDEINITPROC DeInit() -{ - Stop(); - return 0; -} -LPCHECKPROC CheckPlayer(HWND wnd, int flags) -{ - if(!ghConnection) - { - mir_forkthread(&Start, 0); - return 0; - } - if(Parser()) - return (LPCHECKPROC)WAT_MES_STOPPED; - if(Connected) - return (LPCHECKPROC)WAT_MES_PLAYING; - return 0; -} -LPGETSTATUSPROC GetStatus() -{ - if(!ghConnection) - { - mir_forkthread(&Start, 0); - return 0; - } - if(Parser()) - return (LPGETSTATUSPROC)-1; - return (LPGETSTATUSPROC)(gbState); -} -LPNAMEPROC GetFileName(HWND wnd, int flags) -{ - if(!ghConnection) - { - mir_forkthread(&Start, 0); - return 0; - } - return 0; -} -SONGINFO SongInfo = {0}; - -LPINFOPROC GetPlayerInfo(LPSONGINFO info, int flags) -{ - if(!ghConnection) - { - mir_forkthread(&Start, 0); - return 0; - } - if(Parser()) - return (LPINFOPROC)-1; -/* - - info->channels = SongInfo.channels; - info->codec = SongInfo.codec; - info->comment = SongInfo.comment; - info->cover = SongInfo.cover; - info->date = SongInfo.date; - info->fps = SongInfo.fps; - info->fsize = SongInfo.fsize; - - info->icon = SongInfo.icon; - info->kbps = SongInfo.kbps; - info->khz = SongInfo.khz; - info->lyric = SongInfo.lyric; - info->mfile = SongInfo.mfile; - info->player = SongInfo.player; - info->plyver = SongInfo.plyver; - info->status = SongInfo.status; - info->time = SongInfo.time; - info->title = SongInfo.title; - info->total = SongInfo.total; - info->track = SongInfo.track;*/ - info->total = SongInfo.total; - info->time = SongInfo.time; - info->mfile = SongInfo.mfile; - info->txtver = SongInfo.txtver; - info->title = SongInfo.title; - info->artist = SongInfo.artist; - info->genre = SongInfo.genre; - info->album = SongInfo.album; - info->year = SongInfo.year; - info->kbps = SongInfo.kbps; - info->track = SongInfo.track; - info->khz = SongInfo.khz; - info->volume = SongInfo.volume; -/* info->url = SongInfo.url; //?? - info->vbr = SongInfo.vbr; - info->volume = SongInfo.volume; - */ - return 0; -} -LPCOMMANDPROC SendCommand(HWND wnd, int command, int value) -{ - switch (command) - { - case WAT_CTRL_PREV: - Netlib_Send(ghConnection, "previous\n", strlen("previous\n"), 0); - break; - case WAT_CTRL_PLAY: //add resuming support - if(gbState != WAT_MES_PAUSED) - Netlib_Send(ghConnection, "play\n", strlen("play\n"), 0); - else - Netlib_Send(ghConnection, "pause 0\n", strlen("pause 0\n"), 0); - break; - case WAT_CTRL_PAUSE: - Netlib_Send(ghConnection, "pause 1\n", strlen("pause 1\n"), 0); - break; - case WAT_CTRL_STOP: - Netlib_Send(ghConnection, "stop\n", strlen("stop\n"), 0); - break; - case WAT_CTRL_NEXT: - Netlib_Send(ghConnection, "next\n", strlen("next\n"), 0); - break; - case WAT_CTRL_VOLDN: - break; - case WAT_CTRL_VOLUP: - break; - case WAT_CTRL_SEEK: - break; - default: - break; - } - return 0; -} - - -void RegisterPlayer() -{ - if(!bWatrackService) - return; - { - PLAYERCELL player = {0}; - player.Desc = "Music Player Daemon"; - player.Check = (LPCHECKPROC)CheckPlayer; - player.Init = (LPINITPROC)Init; - player.DeInit = (LPDEINITPROC)DeInit; - player.GetStatus = (LPGETSTATUSPROC)GetStatus; - player.Command = (LPCOMMANDPROC)SendCommand; - player.flags = (WAT_OPT_HASURL|WAT_OPT_SINGLEINST|WAT_OPT_PLAYERINFO); - player.GetName = (LPNAMEPROC)GetFileName; - player.GetInfo = (LPINFOPROC)GetPlayerInfo; -// player.Icon = //TODO:implement icon support - player.Notes = _T("mpd is a nice music player for *nix which have not any gui, just daemon.\nuses very small amount of ram, cpu."); - player.URL = "http://www.musicpd.org"; - CallService(MS_WAT_PLAYER, (WPARAM)WAT_ACT_REGISTER, (LPARAM)&player); - } -} -void ReStart(void *data); -int Parser() -{ - static NETLIBPACKETRECVER nlpr = {0}; - char *ptr; - char tmp[256]; - int i; - char *buf; - static char ver[16]; - nlpr.cbSize = sizeof(nlpr); - nlpr.dwTimeout = 5; - if(!ghConnection) - { - mir_forkthread(&Start, 0); - } - if(ghConnection) - { - int recvResult; -/* do - { - recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); - if(recvResult == SOCKET_ERROR) - { - ReStart(); - return 1; - } - } - while(recvResult > 0);*/ - if(!Connected) - { - char tmp[128]; - char *tmp2 = mir_t2a(gbPassword); - recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); - if(recvResult == SOCKET_ERROR) - { - mir_forkthread(&ReStart, 0); -// ReStart(); - return 1; - } - if(strlen(tmp2) > 2) - { - strcpy(tmp, "password "); - strcat(tmp, tmp2); - strcat(tmp, "\n"); - Netlib_Send(ghConnection, tmp, strlen(tmp), 0); - recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); - if(recvResult == SOCKET_ERROR) - { - mir_forkthread(&ReStart, 0); - return 1; - } - } - mir_free(tmp2); - } - Netlib_Send(ghConnection, "status\n", strlen("status\n"), 0); - recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); - if(recvResult == SOCKET_ERROR) - { - mir_forkthread(&ReStart, 0); - return 1; - } - Netlib_Send(ghConnection, "currentsong\n", strlen("currentsong\n"), 0); - recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); - if(recvResult == SOCKET_ERROR) - { - mir_forkthread(&ReStart, 0); - return 1; - } - nlpr.bytesUsed = nlpr.bytesAvailable; - } - buf = nlpr.buffer; - if(ptr = strstr(buf, "MPD")) - { - Connected = TRUE; - ptr = &ptr[4]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - strcpy(ver, tmp); - SongInfo.txtver = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.txtver = (TCHAR*)mir_utf8decodeW(ver); - if(ptr = strstr(buf, "file:")) - { - ptr = &ptr[6]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.mfile = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.mfile = _T(""); - if(ptr = strstr(buf, "Time:")) - { - ptr = &ptr[6]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.total = atoi(tmp); - } - else if(!SongInfo.total) - SongInfo.total = 0; - if(ptr = strstr(buf, "time:")) - { - ptr = &ptr[6]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.time = atoi(tmp); - } - else if(!SongInfo.time) - SongInfo.time = 0; - if(ptr = strstr(buf, "Title:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.title = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.title = _T("Unknown track"); - if(ptr = strstr(buf, "Artist:")) - { - ptr = &ptr[8]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.artist = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.artist = _T("Unknown artist"); - if(ptr = strstr(buf, "Genre:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.genre = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.genre = _T("Unknown genre"); - if(ptr = strstr(buf, "Album:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.album = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.album = _T("Unknown album"); - if(ptr = strstr(buf, "Date:")) - { - ptr = &ptr[6]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.year = (TCHAR*)mir_utf8decodeW(tmp); - } - else - SongInfo.year = _T("Unknown year"); - if(ptr = strstr(buf, "volume:")) - { - ptr = &ptr[8]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.volume = atoi(tmp); - } - else if(!SongInfo.volume) - SongInfo.volume = 0; - if(ptr = strstr(buf, "audio:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.khz = atoi(tmp); - } - else if(!SongInfo.khz) - SongInfo.khz = 0; - if(ptr = strstr(buf, "bitrate:")) - { - ptr = &ptr[9]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.kbps = atoi(tmp); - } - else if(!SongInfo.kbps) - SongInfo.kbps = 0; - - if(ptr = strstr(buf, "Track:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - SongInfo.track = atoi(tmp); - } - else if(!SongInfo.track) - SongInfo.track = 0; - if(ptr = strstr(buf, "state:")) - { - ptr = &ptr[7]; - for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) - tmp[i] = ptr[i]; - tmp[i] = '\0'; - if(strstr(tmp, "play")) - gbState = WAT_MES_PLAYING; - if(strstr(tmp, "pause")) - gbState = WAT_MES_PAUSED; - if(strstr(tmp, "stop")) - gbState = WAT_MES_STOPPED; - } - else if(!gbState) - gbState = WAT_MES_UNKNOWN; - return 0; -} - - -void Start(void* param) -{ - NETLIBOPENCONNECTION nloc = {0}; - char *tmp = (char*)mir_u2a(gbHost); - nloc.cbSize = sizeof(nloc); - nloc.szHost = tmp; - nloc.timeout = 5; - nloc.wPort = gbPort; - Connected = FALSE; - ghConnection = NetLib_CreateConnection(ghNetlibUser, &nloc); - if(ghConnection) - ghPacketReciever = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER,(WPARAM)ghConnection,2048); -} -void Stop() -{ - if(ghPacketReciever) - Netlib_CloseHandle(ghPacketReciever); - if(ghConnection) - Netlib_CloseHandle(ghConnection); - if(ghNetlibUser && (ghNetlibUser != INVALID_HANDLE_VALUE)) - CallService(MS_NETLIB_SHUTDOWN,(WPARAM)ghNetlibUser,0); -} -void ReStart(void *param) -{ - if(ghPacketReciever) - Netlib_CloseHandle(ghPacketReciever); - if(ghConnection) - Netlib_CloseHandle(ghConnection); - Sleep(500); - mir_forkthread(&Start, 0); -} - diff --git a/plugins/Watrack_MPD/src/main.cpp b/plugins/Watrack_MPD/src/main.cpp new file mode 100755 index 0000000000..17a8c29d64 --- /dev/null +++ b/plugins/Watrack_MPD/src/main.cpp @@ -0,0 +1,433 @@ +// Copyright © 2008 sss, chaos.persei +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + + + +#include "commonheaders.h" + + +//maybe add mutex ? +void Start(void *param); +int Parser(); + +LPINITPROC Init() +{ + mir_forkthread(&Start, 0); + return 0; +} +void Stop(); +LPDEINITPROC DeInit() +{ + Stop(); + return 0; +} +LPCHECKPROC CheckPlayer(HWND wnd, int flags) +{ + if(!ghConnection) + { + mir_forkthread(&Start, 0); + return 0; + } + if(Parser()) + return (LPCHECKPROC)WAT_MES_STOPPED; + if(Connected) + return (LPCHECKPROC)WAT_MES_PLAYING; + return 0; +} +LPGETSTATUSPROC GetStatus() +{ + if(!ghConnection) + { + mir_forkthread(&Start, 0); + return 0; + } + if(Parser()) + return (LPGETSTATUSPROC)-1; + return (LPGETSTATUSPROC)(gbState); +} +LPNAMEPROC GetFileName(HWND wnd, int flags) +{ + if(!ghConnection) + { + mir_forkthread(&Start, 0); + return 0; + } + return 0; +} +SONGINFO SongInfo = {0}; + +LPINFOPROC GetPlayerInfo(LPSONGINFO info, int flags) +{ + if(!ghConnection) + { + mir_forkthread(&Start, 0); + return 0; + } + if(Parser()) + return (LPINFOPROC)-1; +/* + + info->channels = SongInfo.channels; + info->codec = SongInfo.codec; + info->comment = SongInfo.comment; + info->cover = SongInfo.cover; + info->date = SongInfo.date; + info->fps = SongInfo.fps; + info->fsize = SongInfo.fsize; + + info->icon = SongInfo.icon; + info->kbps = SongInfo.kbps; + info->khz = SongInfo.khz; + info->lyric = SongInfo.lyric; + info->mfile = SongInfo.mfile; + info->player = SongInfo.player; + info->plyver = SongInfo.plyver; + info->status = SongInfo.status; + info->time = SongInfo.time; + info->title = SongInfo.title; + info->total = SongInfo.total; + info->track = SongInfo.track;*/ + info->total = SongInfo.total; + info->time = SongInfo.time; + info->mfile = SongInfo.mfile; + info->txtver = SongInfo.txtver; + info->title = SongInfo.title; + info->artist = SongInfo.artist; + info->genre = SongInfo.genre; + info->album = SongInfo.album; + info->year = SongInfo.year; + info->kbps = SongInfo.kbps; + info->track = SongInfo.track; + info->khz = SongInfo.khz; + info->volume = SongInfo.volume; +/* info->url = SongInfo.url; //?? + info->vbr = SongInfo.vbr; + info->volume = SongInfo.volume; + */ + return 0; +} +LPCOMMANDPROC SendCommand(HWND wnd, int command, int value) +{ + switch (command) + { + case WAT_CTRL_PREV: + Netlib_Send(ghConnection, "previous\n", strlen("previous\n"), 0); + break; + case WAT_CTRL_PLAY: //add resuming support + if(gbState != WAT_MES_PAUSED) + Netlib_Send(ghConnection, "play\n", strlen("play\n"), 0); + else + Netlib_Send(ghConnection, "pause 0\n", strlen("pause 0\n"), 0); + break; + case WAT_CTRL_PAUSE: + Netlib_Send(ghConnection, "pause 1\n", strlen("pause 1\n"), 0); + break; + case WAT_CTRL_STOP: + Netlib_Send(ghConnection, "stop\n", strlen("stop\n"), 0); + break; + case WAT_CTRL_NEXT: + Netlib_Send(ghConnection, "next\n", strlen("next\n"), 0); + break; + case WAT_CTRL_VOLDN: + break; + case WAT_CTRL_VOLUP: + break; + case WAT_CTRL_SEEK: + break; + default: + break; + } + return 0; +} + + +void RegisterPlayer() +{ + if(!bWatrackService) + return; + { + PLAYERCELL player = {0}; + player.Desc = "Music Player Daemon"; + player.Check = (LPCHECKPROC)CheckPlayer; + player.Init = (LPINITPROC)Init; + player.DeInit = (LPDEINITPROC)DeInit; + player.GetStatus = (LPGETSTATUSPROC)GetStatus; + player.Command = (LPCOMMANDPROC)SendCommand; + player.flags = (WAT_OPT_HASURL|WAT_OPT_SINGLEINST|WAT_OPT_PLAYERINFO); + player.GetName = (LPNAMEPROC)GetFileName; + player.GetInfo = (LPINFOPROC)GetPlayerInfo; +// player.Icon = //TODO:implement icon support + player.Notes = _T("mpd is a nice music player for *nix which have not any gui, just daemon.\nuses very small amount of ram, cpu."); + player.URL = "http://www.musicpd.org"; + CallService(MS_WAT_PLAYER, (WPARAM)WAT_ACT_REGISTER, (LPARAM)&player); + } +} +void ReStart(void *data); +int Parser() +{ + static NETLIBPACKETRECVER nlpr = {0}; + char *ptr; + char tmp[256]; + int i; + char *buf; + static char ver[16]; + nlpr.cbSize = sizeof(nlpr); + nlpr.dwTimeout = 5; + if(!ghConnection) + { + mir_forkthread(&Start, 0); + } + if(ghConnection) + { + int recvResult; +/* do + { + recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); + if(recvResult == SOCKET_ERROR) + { + ReStart(); + return 1; + } + } + while(recvResult > 0);*/ + if(!Connected) + { + char tmp[128]; + char *tmp2 = mir_t2a(gbPassword); + recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); + if(recvResult == SOCKET_ERROR) + { + mir_forkthread(&ReStart, 0); +// ReStart(); + return 1; + } + if(strlen(tmp2) > 2) + { + strcpy(tmp, "password "); + strcat(tmp, tmp2); + strcat(tmp, "\n"); + Netlib_Send(ghConnection, tmp, strlen(tmp), 0); + recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); + if(recvResult == SOCKET_ERROR) + { + mir_forkthread(&ReStart, 0); + return 1; + } + } + mir_free(tmp2); + } + Netlib_Send(ghConnection, "status\n", strlen("status\n"), 0); + recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); + if(recvResult == SOCKET_ERROR) + { + mir_forkthread(&ReStart, 0); + return 1; + } + Netlib_Send(ghConnection, "currentsong\n", strlen("currentsong\n"), 0); + recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); + if(recvResult == SOCKET_ERROR) + { + mir_forkthread(&ReStart, 0); + return 1; + } + nlpr.bytesUsed = nlpr.bytesAvailable; + } + buf = nlpr.buffer; + if(ptr = strstr(buf, "MPD")) + { + Connected = TRUE; + ptr = &ptr[4]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + strcpy(ver, tmp); + SongInfo.txtver = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.txtver = (TCHAR*)mir_utf8decodeW(ver); + if(ptr = strstr(buf, "file:")) + { + ptr = &ptr[6]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.mfile = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.mfile = _T(""); + if(ptr = strstr(buf, "Time:")) + { + ptr = &ptr[6]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.total = atoi(tmp); + } + else if(!SongInfo.total) + SongInfo.total = 0; + if(ptr = strstr(buf, "time:")) + { + ptr = &ptr[6]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.time = atoi(tmp); + } + else if(!SongInfo.time) + SongInfo.time = 0; + if(ptr = strstr(buf, "Title:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.title = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.title = _T("Unknown track"); + if(ptr = strstr(buf, "Artist:")) + { + ptr = &ptr[8]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.artist = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.artist = _T("Unknown artist"); + if(ptr = strstr(buf, "Genre:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.genre = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.genre = _T("Unknown genre"); + if(ptr = strstr(buf, "Album:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.album = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.album = _T("Unknown album"); + if(ptr = strstr(buf, "Date:")) + { + ptr = &ptr[6]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.year = (TCHAR*)mir_utf8decodeW(tmp); + } + else + SongInfo.year = _T("Unknown year"); + if(ptr = strstr(buf, "volume:")) + { + ptr = &ptr[8]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.volume = atoi(tmp); + } + else if(!SongInfo.volume) + SongInfo.volume = 0; + if(ptr = strstr(buf, "audio:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.khz = atoi(tmp); + } + else if(!SongInfo.khz) + SongInfo.khz = 0; + if(ptr = strstr(buf, "bitrate:")) + { + ptr = &ptr[9]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.kbps = atoi(tmp); + } + else if(!SongInfo.kbps) + SongInfo.kbps = 0; + + if(ptr = strstr(buf, "Track:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + SongInfo.track = atoi(tmp); + } + else if(!SongInfo.track) + SongInfo.track = 0; + if(ptr = strstr(buf, "state:")) + { + ptr = &ptr[7]; + for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) + tmp[i] = ptr[i]; + tmp[i] = '\0'; + if(strstr(tmp, "play")) + gbState = WAT_MES_PLAYING; + if(strstr(tmp, "pause")) + gbState = WAT_MES_PAUSED; + if(strstr(tmp, "stop")) + gbState = WAT_MES_STOPPED; + } + else if(!gbState) + gbState = WAT_MES_UNKNOWN; + return 0; +} + + +void Start(void* param) +{ + NETLIBOPENCONNECTION nloc = {0}; + char *tmp = (char*)mir_u2a(gbHost); + nloc.cbSize = sizeof(nloc); + nloc.szHost = tmp; + nloc.timeout = 5; + nloc.wPort = gbPort; + Connected = FALSE; + ghConnection = NetLib_CreateConnection(ghNetlibUser, &nloc); + if(ghConnection) + ghPacketReciever = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER,(WPARAM)ghConnection,2048); +} +void Stop() +{ + if(ghPacketReciever) + Netlib_CloseHandle(ghPacketReciever); + if(ghConnection) + Netlib_CloseHandle(ghConnection); + if(ghNetlibUser && (ghNetlibUser != INVALID_HANDLE_VALUE)) + CallService(MS_NETLIB_SHUTDOWN,(WPARAM)ghNetlibUser,0); +} +void ReStart(void *param) +{ + if(ghPacketReciever) + Netlib_CloseHandle(ghPacketReciever); + if(ghConnection) + Netlib_CloseHandle(ghConnection); + Sleep(500); + mir_forkthread(&Start, 0); +} + diff --git a/plugins/Watrack_MPD/src/options.c b/plugins/Watrack_MPD/src/options.c deleted file mode 100755 index ef607d78ed..0000000000 --- a/plugins/Watrack_MPD/src/options.c +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright © 2008 sss, chaos.persei -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "commonheaders.h" -#include - -HINSTANCE hInst; -static INT_PTR CALLBACK DlgProcWaMpdOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -int WaMpdOptInit(WPARAM wParam,LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_WA_MPD); - odp.ptszTitle = LPGENT("Winamp Track"); - odp.ptszGroup = LPGENT("Plugins"); - odp.ptszTab = LPGENT("Watrack MPD"); - odp.flags=ODPF_BOLDGROUPS|ODPF_TCHAR; - odp.pfnDlgProc = DlgProcWaMpdOpts; - Options_AddPage(wParam, &odp); - return 0; -} - - -static INT_PTR CALLBACK DlgProcWaMpdOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - SetDlgItemInt(hwndDlg, IDC_PORT, DBGetContactSettingWord(NULL, szModuleName, "Port", 6600), FALSE); - SetDlgItemText(hwndDlg, IDC_SERVER, UniGetContactSettingUtf(NULL, szModuleName, "Server", _T("127.0.0.1"))); - SetDlgItemText(hwndDlg, IDC_PASSWORD, UniGetContactSettingUtf(NULL, szModuleName, "Password", _T(""))); - return TRUE; - } - - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - - } - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) - { - - case PSN_APPLY: - { - TCHAR szText[128]; - DBWriteContactSettingWord(NULL, szModuleName, "Port", (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE)); - gbPort = (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE); - GetDlgItemText(hwndDlg, IDC_SERVER, szText, sizeof(szText)); - DBWriteContactSettingTString(NULL, szModuleName, "Server", szText); - _tcscpy(gbHost, szText); - GetDlgItemText(hwndDlg, IDC_PASSWORD, szText, sizeof(szText)); - DBWriteContactSettingTString(NULL, szModuleName, "Password", szText); - _tcscpy(gbPassword, szText); - return TRUE; - } - } - } - break; - } - - return FALSE; -} - - - diff --git a/plugins/Watrack_MPD/src/options.cpp b/plugins/Watrack_MPD/src/options.cpp new file mode 100755 index 0000000000..ef607d78ed --- /dev/null +++ b/plugins/Watrack_MPD/src/options.cpp @@ -0,0 +1,91 @@ +// Copyright © 2008 sss, chaos.persei +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "commonheaders.h" +#include + +HINSTANCE hInst; +static INT_PTR CALLBACK DlgProcWaMpdOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +int WaMpdOptInit(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_WA_MPD); + odp.ptszTitle = LPGENT("Winamp Track"); + odp.ptszGroup = LPGENT("Plugins"); + odp.ptszTab = LPGENT("Watrack MPD"); + odp.flags=ODPF_BOLDGROUPS|ODPF_TCHAR; + odp.pfnDlgProc = DlgProcWaMpdOpts; + Options_AddPage(wParam, &odp); + return 0; +} + + +static INT_PTR CALLBACK DlgProcWaMpdOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + SetDlgItemInt(hwndDlg, IDC_PORT, DBGetContactSettingWord(NULL, szModuleName, "Port", 6600), FALSE); + SetDlgItemText(hwndDlg, IDC_SERVER, UniGetContactSettingUtf(NULL, szModuleName, "Server", _T("127.0.0.1"))); + SetDlgItemText(hwndDlg, IDC_PASSWORD, UniGetContactSettingUtf(NULL, szModuleName, "Password", _T(""))); + return TRUE; + } + + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + + } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) + { + + case PSN_APPLY: + { + TCHAR szText[128]; + DBWriteContactSettingWord(NULL, szModuleName, "Port", (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE)); + gbPort = (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE); + GetDlgItemText(hwndDlg, IDC_SERVER, szText, sizeof(szText)); + DBWriteContactSettingTString(NULL, szModuleName, "Server", szText); + _tcscpy(gbHost, szText); + GetDlgItemText(hwndDlg, IDC_PASSWORD, szText, sizeof(szText)); + DBWriteContactSettingTString(NULL, szModuleName, "Password", szText); + _tcscpy(gbPassword, szText); + return TRUE; + } + } + } + break; + } + + return FALSE; +} + + + diff --git a/plugins/Watrack_MPD/src/utilities.c b/plugins/Watrack_MPD/src/utilities.c deleted file mode 100755 index 4d63f1f7f4..0000000000 --- a/plugins/Watrack_MPD/src/utilities.c +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright © 2008 sss, chaos.persei -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "commonheaders.h" - -TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef) -{ - DBVARIANT dbv = {DBVT_DELETED}; - TCHAR* szRes; - if (DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) - return _tcsdup(szDef); - if(dbv.pszVal) - szRes = _tcsdup(dbv.ptszVal); - DBFreeVariant(&dbv); - return szRes; -} - -HANDLE NetLib_CreateConnection(HANDLE hUser, NETLIBOPENCONNECTION* nloc) //from icq ) -{ - HANDLE hConnection; - - nloc->cbSize = sizeof(NETLIBOPENCONNECTION); - nloc->flags |= NLOCF_V2; - - hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)nloc); - if (!hConnection && (GetLastError() == 87)) - { // this ensures, an old Miranda will be able to connect also - nloc->cbSize = NETLIBOPENCONNECTION_V1_SIZE; - hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hConnection, (LPARAM)nloc); - } - return hConnection; -} - - diff --git a/plugins/Watrack_MPD/src/utilities.cpp b/plugins/Watrack_MPD/src/utilities.cpp new file mode 100755 index 0000000000..4d63f1f7f4 --- /dev/null +++ b/plugins/Watrack_MPD/src/utilities.cpp @@ -0,0 +1,48 @@ +// Copyright © 2008 sss, chaos.persei +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#include "commonheaders.h" + +TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef) +{ + DBVARIANT dbv = {DBVT_DELETED}; + TCHAR* szRes; + if (DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) + return _tcsdup(szDef); + if(dbv.pszVal) + szRes = _tcsdup(dbv.ptszVal); + DBFreeVariant(&dbv); + return szRes; +} + +HANDLE NetLib_CreateConnection(HANDLE hUser, NETLIBOPENCONNECTION* nloc) //from icq ) +{ + HANDLE hConnection; + + nloc->cbSize = sizeof(NETLIBOPENCONNECTION); + nloc->flags |= NLOCF_V2; + + hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)nloc); + if (!hConnection && (GetLastError() == 87)) + { // this ensures, an old Miranda will be able to connect also + nloc->cbSize = NETLIBOPENCONNECTION_V1_SIZE; + hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hConnection, (LPARAM)nloc); + } + return hConnection; +} + + -- cgit v1.2.3