The Winamp Remote Control suite
a remote control client and plugin for Winamp 2.x, 5.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WinampClientBase.cpp
Go to the documentation of this file.
1 #include <sstream>
2 #include "windows.h"
3 #include "stddef.h"
4 
5 #include "RPCFuncsU.h" // the only use of this header
6 #include "waint.h"
7 #include "WinampClientBase.h"
8 
9 static char IdentBuf[2 * MAX_COMPUTERNAME_LENGTH + 2];
10 
14 static void GetIdent(void)
15 {
16 
17  char NameBuf[MAX_COMPUTERNAME_LENGTH + 1];char ComputerBuf [MAX_COMPUTERNAME_LENGTH + 1];
18 
19  unsigned long BufLen;
20  BufLen = MAX_COMPUTERNAME_LENGTH + 1;
21  GetComputerName(ComputerBuf, &BufLen);
22  BufLen = MAX_COMPUTERNAME_LENGTH + 1;
23  GetUserName(NameBuf, &BufLen);
24  sprintf(IdentBuf, "%s@%s", NameBuf, ComputerBuf);
25 
26 }
27 
28 namespace WinampRemote
29 {
30 namespace Client
31 {
32 
34 {
35  GetIdent();
36 }
37 
39 {
41 }
42 
44 {
46 }
47 
49 {
51 }
52 
54 {
56 }
57 
59 {
61 }
62 
64 {
66 }
67 
69 {
71 }
72 
74 {
76 }
77 
78 
79 string WinampClientBase::getPlayListItem(int index, bool title) const
80 {
81  char buffer[MAX_PATH] = "";
82  strcpy(buffer, IdentBuf);
84  string result = buffer;
85  return result;
86 }
87 
89 {
91 }
92 
94 {
96 }
97 
98 string WinampClientBase::getCurrentPlayListItem(int& index, bool title) const
99 {
101  return getPlayListItem(index, title);
102 }
103 
104 
105 vector<string> WinampClientBase::getPlayList(bool title) const
106 {
107  vector<string> result;
108 
109  std::string playlist;
110  if (title)
112  else
114 
115 
116  std::stringstream input(playlist);
117  std::string line;
118 
119  while ( std::getline( input, line ) )
120  {
121  result.push_back(line);
122  }
123 
124  return result;
125 
126 }
127 
128 void WinampClientBase::setPlayList(const vector<string>& playlist)
129 {
130 
131  stringstream sstr;
132 
133  for (unsigned int i = 0 ; i < playlist.size() ; i++ )
134  {
135  sstr << playlist.at(i).c_str() << endl;
136  }
137 
138  deletePlaylist();
139  string list = sstr.str();
141 
142 }
143 
144 
145 void WinampClientBase::insertPlayList(const vector<string>& playlist, int position)
146 {
147  vector<string> newPlaylist = getPlayList(false);
148 
149  vector<string>::iterator it;
150 
151  it = newPlaylist.begin();
152 
153  newPlaylist.insert (it + position , playlist.begin(),playlist.end());
154 
155  setPlayList(newPlaylist);
156 
157 }
158 
159 
161 {
163 }
164 
166 {
168 }
169 
171 {
173 }
174 
176 {
178 }
179 
181 {
183 }
184 
186 {
188 }
189 
191 {
193 }
194 
196 {
198 }
199 
201 {
203 }
204 
206 {
208 }
209 
211 {
213 }
214 
216 {
217  setVolume(getVolume() + 1);
218 }
219 
221 {
222  setVolume(getVolume() - 1);
223 }
224 
226 {
228 }
229 
231 {
232  return IntegerResult(IdentBuf, IPC_SETVOLUME, -666);
233 }
234 
236 {
238 }
239 
241 {
242  return IntegerResult(IdentBuf, IPC_SETPANNING, -666);
243 }
244 
245 
247 {
249 }
250 
252 {
254 }
255 
257 {
259 }
260 
262 {
263 // int repeat = IntegerResult(IdentBuf, IPC_GETREPEATOPTION, 0);
265 
266 }
267 
269 {
271 }
272 
277 {
279 }
280 
281 
283 {
284  setEQOn(!getEQOn());
285 }
286 
288 {
289  return getEQData(11);
290 }
291 
293 {
294  return setEQData(11, value);
295 }
296 
298 {
300 }
301 
303 {
304  return getEQData(12);
305 }
306 
308 {
309  return setEQData(12, value);
310 }
311 
312 int WinampClientBase::getEQData(int eqindex) const
313 {
314  return IntegerResult(IdentBuf, IPC_GETEQDATA, eqindex);
315 }
316 
317 void WinampClientBase::setEQData(int eqindex, byte eqvalue)
318 {
319  getEQData(eqindex);
321 }
322 
323 void WinampClientBase::getTimes(int& songLength, int& songPos) const
324 {
325 
326  int songS = IntegerResult(IdentBuf, IPC_GETOUTPUTTIME, 1);
327  int posMS = IntegerResult(IdentBuf, IPC_GETOUTPUTTIME, 0);
328 
329  songLength = songS;
330  songPos = posMS;
331 
332 }
333 
335 {
336 
337  std::string result = "";
338  BUFFER returnBuf;
339 
340  returnBuf.BufferLength = 0;
341  returnBuf.Buffer = NULL;
342 
343  WAGetStringList( (unsigned char *) IdentBuf, &returnBuf, Command);
344 
345  result = (char *) returnBuf.Buffer;
346  MIDL_user_free(returnBuf.Buffer);
347 
348  return result;
349 
350 }
351 
353 {
354 
355  WASetStringList( (unsigned char *) IdentBuf, (unsigned char *) list.c_str(), list.size() + 1, Command);
356 
357 }
358 
359 } // end of namespace Client
360 } // end of namespace WinampRemote
361