blob: 752b2005adffab7a50f66421e1c44abcb14d2c0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "net.h"
#include <noatun/player.h>
#include <noatun/app.h>
extern "C"
{
TDE_EXPORT Plugin *create_plugin()
{
return new Net();
}
}
Net::Net() : TQServerSocket(7539, 10), Plugin()
{
mFDs.setAutoDelete(true);
connect(napp->player(), TQ_SIGNAL(newSong()), TQ_SLOT(newSong()));
}
Net::~Net()
{
}
void Net::newConnection(int fd)
{
TQSocket *s=new TQSocket;
s->setSocket(fd);
mFDs.append(s);
}
void Net::newSong()
{
if (!napp->player()->current())
return;
for (TQSocket *i=mFDs.first(); i!=0; i=mFDs.next())
{
TQCString line;
line=napp->player()->current().title().latin1();
line+='\n';
::write(i->socket(), (const void*)line.data(), line.length());
}
}
void Net::closed()
{
for (TQSocket *i=mFDs.first(); i!=0; i=mFDs.next())
{
if (sender()==i)
mFDs.removeRef(i);
}
}
#include "net.moc"
|