diff options
Diffstat (limited to 'Sluift/ITunesInterface.mm')
-rw-r--r-- | Sluift/ITunesInterface.mm | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/Sluift/ITunesInterface.mm b/Sluift/ITunesInterface.mm index a11be20..a5ada5b 100644 --- a/Sluift/ITunesInterface.mm +++ b/Sluift/ITunesInterface.mm @@ -19,10 +19,10 @@ using namespace Swift; struct ITunesInterface::Private { - Private() : iTunes(nil) { - } + Private() : iTunes(nil) { + } - iTunesApplication* iTunes; + iTunesApplication* iTunes; }; ITunesInterface::ITunesInterface() : p(boost::make_shared<Private>()) { @@ -32,27 +32,27 @@ ITunesInterface::~ITunesInterface() { } boost::optional<ITunesInterface::Track> ITunesInterface::getCurrentTrack() const { - if (!haveApplication()) { - return boost::optional<ITunesInterface::Track>(); - } - iTunesTrack* currentTrack = p->iTunes.currentTrack; - if (!currentTrack) { - return boost::optional<ITunesInterface::Track>(); - } - ITunesInterface::Track result; - result.name = ns2StdString(currentTrack.name); - result.artist = ns2StdString(currentTrack.artist); - result.album = ns2StdString(currentTrack.album); - result.trackNumber = currentTrack.trackNumber; - result.duration = currentTrack.duration; - result.rating = currentTrack.rating; - return result; + if (!haveApplication()) { + return boost::optional<ITunesInterface::Track>(); + } + iTunesTrack* currentTrack = p->iTunes.currentTrack; + if (!currentTrack) { + return boost::optional<ITunesInterface::Track>(); + } + ITunesInterface::Track result; + result.name = ns2StdString(currentTrack.name); + result.artist = ns2StdString(currentTrack.artist); + result.album = ns2StdString(currentTrack.album); + result.trackNumber = currentTrack.trackNumber; + result.duration = currentTrack.duration; + result.rating = currentTrack.rating; + return result; } bool ITunesInterface::haveApplication() const { - if (!p->iTunes) { - p->iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; - } - return p->iTunes != nil && [p->iTunes isRunning]; + if (!p->iTunes) { + p->iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; + } + return p->iTunes != nil && [p->iTunes isRunning]; } |