blob: dbdd7e2f5df87c9ae801ece203683a69849f2136 (
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"
{
KDE_EXPORT Plugin *create_plugin()
{
return new Net();
}
}
Net::Net() : TQServerSocket(7539, 10), Plugin()
{
mFDs.setAutoDelete(true);
connect(napp->player(), TQT_SIGNAL(newSong()), TQT_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"
|