161
172
case ArtistMetaData:
162
return metaData(QLatin1String("ARTIST" ));
173
return metaData(QLatin1String("ARTIST"));
163
174
case AlbumMetaData:
164
return metaData(QLatin1String("ALBUM" ));
175
return metaData(QLatin1String("ALBUM"));
165
176
case TitleMetaData:
166
return metaData(QLatin1String("TITLE" ));
177
return metaData(QLatin1String("TITLE"));
167
178
case DateMetaData:
168
return metaData(QLatin1String("DATE" ));
179
return metaData(QLatin1String("DATE"));
169
180
case GenreMetaData:
170
return metaData(QLatin1String("GENRE" ));
181
return metaData(QLatin1String("GENRE"));
171
182
case TracknumberMetaData:
172
183
return metaData(QLatin1String("TRACKNUMBER"));
173
184
case DescriptionMetaData:
238
249
// for setting a new URL
240
251
d->mediaSource = newSource;
241
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
242
d->kiofallback = 0; // kiofallback auto-deletes
243
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
245
//X if (url.scheme() == "http") {
246
//X d->kiofallback = Platform::createMediaStream(url, this);
247
//X if (d->kiofallback) {
253
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
253
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
254
d->abstractStream = 0; // abstractStream auto-deletes
254
255
if (d->mediaSource.type() == MediaSource::Stream) {
255
256
Q_ASSERT(d->mediaSource.stream());
256
257
d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d);
318
319
d->sourceQueue.clear();
322
void MediaObjectPrivate::sendToZeitgeist(const QString &event_interpretation,
323
const QString &event_manifestation,
324
const QString &event_actor,
325
const QDateTime &subject_timestamp,
326
const QUrl &subject_uri,
327
const QString &subject_text,
328
const QString &subject_interpretation,
329
const QString &subject_manifestation,
330
const QString &subject_mimetype)
332
#ifdef HAVE_QZEITGEIST
333
QtZeitgeist::DataModel::Subject subject;
334
QString url = subject_uri.toString();
335
QString path = url.left(url.lastIndexOf(QLatin1Char('/')));
337
subject.setText(subject_text);
338
subject.setInterpretation(subject_interpretation);
339
subject.setManifestation(subject_manifestation);
340
subject.setOrigin(path);
341
subject.setMimeType(subject_mimetype);
343
QtZeitgeist::DataModel::SubjectList subjects;
346
QtZeitgeist::DataModel::Event event;
347
event.setTimestamp(subject_timestamp);
348
event.setInterpretation(event_interpretation);
349
event.setManifestation(event_manifestation);
350
event.setActor(event_actor);
351
event.setSubjects(subjects);
353
QtZeitgeist::DataModel::EventList events;
356
QDBusPendingReply<QtZeitgeist::DataModel::EventIdList> reply =
357
log->insertEvents(events);
359
Q_UNUSED(event_interpretation)
360
Q_UNUSED(event_manifestation)
361
Q_UNUSED(event_actor)
362
Q_UNUSED(subject_timestamp)
363
Q_UNUSED(subject_uri)
364
Q_UNUSED(subject_text)
365
Q_UNUSED(subject_interpretation)
366
Q_UNUSED(subject_manifestation)
367
Q_UNUSED(subject_mimetype)
371
void MediaObjectPrivate::sendToZeitgeist(State eventState)
373
#ifdef HAVE_QZEITGEIST
375
if (readyForZeitgeist && q->property("PlaybackTracking").toBool()) {
376
pDebug() << "Current state:" << eventState;
377
QString eventInterpretation;
378
switch (eventState) {
380
eventInterpretation = QtZeitgeist::Interpretation::Event::ZGAccessEvent;
384
eventInterpretation = QtZeitgeist::Interpretation::Event::ZGLeaveEvent;
386
//These states are not signifigant events.
394
QStringList titles = q->metaData(TitleMetaData);
395
QStringList artists = q->metaData(ArtistMetaData);
397
if (titles.empty()) {
398
QString file = mediaSource.url().toString();
399
title = file.right(file.length()-file.lastIndexOf("/")-1);
401
if (artists.empty()) {
404
title = QString(QObject::tr("%0 by %1")).arg(titles[0]).arg(artists[0]);
407
pDebug() << "Sending" << title << "to zeitgeist";
410
QString subjectInterpretation;
412
subjectInterpretation = QtZeitgeist::Interpretation::Subject::NFOVideo;
415
subjectInterpretation = QtZeitgeist::Interpretation::Subject::NFOAudio;
418
pDebug() << "Zeitgeist mime type:" << mime;
419
pDebug() << "Zeitgeist URL:" << mediaSource.url();
420
pDebug() << "mediasource type:" << mediaSource.type();
423
switch (mediaSource.type()) {
424
case MediaSource::Empty:
425
case MediaSource::Invalid:
427
case MediaSource::Url:
428
subjectType = QtZeitgeist::Manifestation::Subject::NFORemoteDataObject;
430
case MediaSource::CaptureDevice:
431
case MediaSource::Disc:
432
case MediaSource::Stream:
433
subjectType = QtZeitgeist::Manifestation::Subject::NFOMediaStream;
435
case MediaSource::LocalFile:
436
subjectType = QtZeitgeist::Manifestation::Subject::NFOFileDataObject;
440
sendToZeitgeist(eventInterpretation,
441
QtZeitgeist::Manifestation::Event::ZGUserActivity,
442
QLatin1Literal("app://" ) % Platform::applicationName() % QLatin1Literal(".desktop"),
443
QDateTime::currentDateTime(),
446
subjectInterpretation,
450
// Unset this so we don't send it again after a pause+play
451
readyForZeitgeist = false;
457
void MediaObjectPrivate::sendToZeitgeist()
460
sendToZeitgeist(q->state());
321
463
bool MediaObjectPrivate::aboutToDeleteBackendObject()
323
465
//pDebug() << Q_FUNC_INFO;
344
486
QMetaObject::invokeMethod(q, "stateChanged", Qt::QueuedConnection, Q_ARG(Phonon::State, Phonon::ErrorState), Q_ARG(Phonon::State, lastState));
345
487
//emit q->stateChanged(ErrorState, lastState);
489
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
491
// TODO: this needs serious cleanup...
348
492
void MediaObjectPrivate::_k_stateChanged(Phonon::State newstate, Phonon::State oldstate)
350
494
Q_Q(MediaObject);
496
// Zeitgeist ---------------------------------------------------------------
497
if (newstate == StoppedState) {
498
readyForZeitgeist = true;
500
pDebug() << "State changed from" << oldstate << "to" << newstate << "-> sending to zeitgeist.";
501
sendToZeitgeist(newstate);
503
// AbstractMediaStream fallback stuff --------------------------------------
352
504
if (errorOverride) {
353
505
errorOverride = false;
354
506
if (newstate == ErrorState) {