summaryrefslogtreecommitdiffstats
path: root/noatun/modules/dcopiface/dcopiface.cpp
blob: 4c9e0f37f8672b3fb5cf44b8759929a38b5f1eb4 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include "dcopiface.h"

#include <noatun/player.h>
#include <noatun/app.h>
#include <noatunarts/noatunarts.h>
#include <noatun/engine.h>

#include <dcopclient.h>

extern "C"
{
	TDE_EXPORT NIF *create_plugin()
	{
		return new NIF();
	}
}


NIF::NIF() : Plugin(), DCOPObject("Noatun")
{
	mLastVolume = 0;
//	connect(napp->player(), TQ_SIGNAL(newSong()), TQ_SLOT(newSongPlaying()));
}

NIF::~NIF()
{
	kapp->dcopClient()->emitDCOPSignal("exiting()", TQByteArray());
}

void NIF::toggleListView()
{
	napp->player()->toggleListView();
}

void NIF::handleButtons()
{
	napp->player()->handleButtons();
}

void NIF::removeCurrent()
{
	napp->player()->removeCurrent();
}

void NIF::back()
{
	napp->player()->back();
}

void NIF::stop()
{
	napp->player()->stop();
}

void NIF::play()
{
	napp->player()->play();
}

void NIF::playpause()
{
	napp->player()->playpause();
}

void NIF::forward()
{
	napp->player()->forward();
}

void NIF::skipTo(int msec)
{
	napp->player()->skipTo(msec);
}

void NIF::loop()
{
	napp->player()->loop();
}

void NIF::setVolume(int i)
{
	napp->player()->setVolume(i);
}

int NIF::volume()
{
	return napp->player()->volume();
}

void NIF::volumeUp()
{
	napp->player()->setVolume(napp->player()->volume() + 5);
}

void NIF::volumeDown()
{
	napp->player()->setVolume(napp->player()->volume() - 5);
}

void NIF::toggleMute()
{
	int currVol = napp->player()->volume();
	if (currVol == 0)
	{
		napp->player()->setVolume(mLastVolume);
	}
	else
	{
		mLastVolume = currVol;
		napp->player()->setVolume(0);
	}
}

int NIF::length() // returns -1 if there's no playobject
{
	return napp->player()->getLength();
}

int NIF::position() // returns -1 if there's no playobject
{
	return napp->player()->getTime();
}

int NIF::state()
{
	if (napp->player()->isPlaying())
		return 2;
	if (napp->player()->isPaused())
		return 1;

	return 0; // default to stopped
}

TQString NIF::lengthString()
{
	return napp->player()->current() ? napp->player()->current().lengthString() : "";
}

TQString NIF::timeString()
{
	return napp->player()->lengthString();
}

TQString NIF::title()
{
	return napp->player()->current() ? napp->player()->current().title() : "";
}

void NIF::setCurrentProperty(const TQString &key, const TQString &value)
{
	if (!napp->player()->current()) return;

	napp->player()->current().setProperty(key, value);
}

TQString NIF::currentProperty(const TQString &key)
{
	if (!napp->player()->current()) return "";

	return napp->player()->current().property(key);
}

void NIF::clearCurrentProperty(const TQString &key)
{
	if (!napp->player()->current()) return;

	return napp->player()->current().clearProperty(key);
}


TQCString NIF::visStack()
{
	return napp->player()->engine()->visualizationStack()->toString().c_str();
}

TQCString NIF::session()
{
	return napp->player()->engine()->session()->toString().c_str();
}

// adds one file to the playlist
void NIF::addFile(const TQString& f, bool autoplay)
{
	napp->player()->openFile(f, false, autoplay);
}

// Adds a bunch of files to the playlist
void NIF::addFile(const TQStringList &f, bool autoplay)
{
	for (TQStringList::ConstIterator it = f.begin(); it != f.end(); ++it )
		napp->player()->openFile(*it, false, autoplay);
}

void NIF::loadPlugin(const TQString &spec)
{
	napp->libraryLoader()->add(spec);
}

TQStringList NIF::availablePlugins() {
	TQStringList available_spec_files;
        TQValueList<NoatunLibraryInfo> available;

	available = napp->libraryLoader()->available();

	TQValueList<NoatunLibraryInfo>::iterator it;
	for (it = available.begin();it != available.end();it++) {
		available_spec_files += (*it).specfile;
	}

	return available_spec_files;
}

TQStringList NIF::loadedPlugins() {
	TQStringList loaded_spec_files;
        TQValueList<NoatunLibraryInfo> loaded;

	loaded = napp->libraryLoader()->loaded();

	TQValueList<NoatunLibraryInfo>::iterator it;
	for (it = loaded.begin();it != loaded.end();it++) {
		loaded_spec_files += (*it).specfile;
	}

	return loaded_spec_files;
}

bool NIF::unloadPlugin(const TQString &spec)
{
	return napp->libraryLoader()->remove(spec);
}

TQStringList NIF::mimeTypes()
{
	return napp->mimeTypes();
}

TQCString NIF::version()
{
	return napp->version();
}

void NIF::newSongPlaying()
{
	kapp->dcopClient()->emitDCOPSignal("newFile()", TQByteArray());
}

void NIF::clear()
{
	napp->playlist()->clear();
}