1
/***************************************************************************
2
* Copyright (C) 2005 - 2007 by *
3
* Christian Muehlhaeuser, Last.fm Ltd <chris@last.fm> *
4
* Erik Jaelevik, Last.fm Ltd <erik@last.fm> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
20
***************************************************************************/
25
#include "interfaces/MediaDeviceInterface.h"
28
#include <QSqlDatabase>
29
#include <QFileSystemWatcher>
32
#include "TrackInfo.h"
35
#include "CocoaWatcher.h"
36
#include <CoreFoundation/CoreFoundation.h>
37
#include <Carbon/Carbon.h>
43
class MediaDeviceWatcher : public QObject
49
~MediaDeviceWatcher();
52
void forceDetection( const QString& path );
55
void startWithiTunes();
59
void deviceAdded( const QString& uid );
60
void deviceChangeStart( const QString& uid, QDateTime lastItunesUpdateTime );
61
void deviceChangeEnd( const QString& uid );
63
void trackChanged( const TrackInfo& track, int playCounter );
65
void shutdownHelper( const QString& path );
68
MediaDeviceInterface* m_gpod;
70
QDomDocument m_newsubdoc;
71
QDomElement m_submitQueue;
74
// DRY function, builds m_subdoc domtree
75
void buildDomTree( const QList<TrackInfo>& );
78
CocoaThread* m_cthread;
81
bool updateTrack( TrackInfo track, bool autoScrobble = false );
82
QList<TrackInfo> readQueue( const QString& uid );
88
class CocoaThread : public QThread
91
CocoaThread( MediaDeviceWatcher* parent ) : QThread( parent ), m_parent( parent ), m_itunesRunning( false )
96
~CocoaThread() { m_run = false; }
102
CocoaWatcher* m_cocoa;
103
MediaDeviceWatcher* m_parent;
105
bool m_itunesRunning;
107
bool isITunesRunning();
111
#endif // end Q_WS_MAC