summaryrefslogtreecommitdiff
path: root/plugins/ListeningTo/players/mradio.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-05-22 23:55:23 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-05-22 23:55:23 +0000
commitf6a9dc6e0bc5fe02e9ad6c9b047a1af874423ea3 (patch)
tree7596d8861d5e8d157abfd9ec5e640a8e2ac89101 /plugins/ListeningTo/players/mradio.cpp
parent4ca47cd69c780d25f3403a777fdbbdca8a01bdf2 (diff)
adding ListeningTo YM
git-svn-id: http://svn.miranda-ng.org/main/trunk@138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ListeningTo/players/mradio.cpp')
-rw-r--r--plugins/ListeningTo/players/mradio.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/ListeningTo/players/mradio.cpp b/plugins/ListeningTo/players/mradio.cpp
new file mode 100644
index 0000000000..27b4685cb7
--- /dev/null
+++ b/plugins/ListeningTo/players/mradio.cpp
@@ -0,0 +1,92 @@
+/*
+Copyright (C) 2008 Jan Holub
+
+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 "..\\commons.h"
+
+MRadio::MRadio()
+{
+ name = _T("mRadio");
+ needPoll = TRUE;
+}
+
+
+void MRadio::EnableDisable()
+{
+ if (!ServiceExists(MS_RADIO_COMMAND))
+ enabled = FALSE;
+}
+
+
+int MRadio::GetData()
+{
+ HANDLE hContact;
+
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact != NULL)
+ {
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (proto)
+ {
+ if (strcmp("mRadio", proto) == 0)
+ {
+ WORD status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE);
+ if (status == ID_STATUS_ONLINE)
+ break;
+ }
+ }
+
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
+ }
+
+ if (hContact)
+ {
+ DBVARIANT dbv = {0};
+ if (!DBGetContactSettingString(hContact, "mRadio", "Nick", &dbv))
+ {
+ listening_info.cbSize = sizeof(listening_info);
+ listening_info.dwFlags = LTI_TCHAR;
+ listening_info.ptszArtist = mir_tstrdup(_T("Radio"));
+ listening_info.ptszType = mir_tstrdup(_T("Radio"));
+ listening_info.ptszTitle = mir_a2t(dbv.pszVal);
+
+ DBFreeVariant(&dbv);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+BOOL MRadio::GetListeningInfo(LISTENINGTOINFO *lti)
+{
+ FreeData();
+
+ if (enabled)
+ {
+ if (CallService(MS_RADIO_COMMAND, MRC_STATUS, RD_STATUS_GET) == RD_STATUS_PLAYING)
+ {
+ if (!GetData())
+ FreeData();
+ }
+ }
+
+ return Player::GetListeningInfo(lti);
+} \ No newline at end of file