File indexing completed on 2025-02-23 04:28:48
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Casey Link <unnamedrambler@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "AmarokClient.h" 0018 0019 #include <QDBusMessage> 0020 #include <QDBusConnection> 0021 #include <QtDebug> 0022 0023 Mp3tunesAmarokClient::Mp3tunesAmarokClient() : Mp3tunesHarmonyClient() 0024 {} 0025 0026 void Mp3tunesAmarokClient::dbusEmitMessage( const QString &message, const QString ¶m = QString() ) 0027 { 0028 QString name = "org.kde.amarok"; 0029 QDBusMessage m = QDBusMessage::createMethodCall( name, 0030 "/Mp3tunesHarmonyHandler", 0031 "", 0032 message ); 0033 if( !param.isEmpty() ) 0034 { 0035 QList<QVariant> args; 0036 args.append( param ); 0037 m.setArguments(args); 0038 } 0039 QDBusMessage response = QDBusConnection::sessionBus().call( m ); 0040 if( response.type() == QDBusMessage::ErrorMessage ) 0041 { 0042 qDebug() << "Got ERROR response " << message; 0043 qDebug() << response.errorName() << ": " << response.errorMessage(); 0044 } 0045 } 0046 0047 0048 /* SLOTS */ 0049 void 0050 Mp3tunesAmarokClient::harmonyError( const QString &error ) 0051 { 0052 qDebug() << "Received Error: " << error; 0053 } 0054 0055 void 0056 Mp3tunesAmarokClient::harmonyWaitingForEmail( const QString &pin ) 0057 { 0058 qDebug() << "Received HARMONY_WAITING_FOR_EMAIL " << pin; 0059 dbusEmitMessage( "emitWaitingForEmail", pin ); 0060 } 0061 0062 void 0063 Mp3tunesAmarokClient::harmonyWaitingForPin() 0064 { 0065 qDebug() << "Received HARMONY_WAITING_FOR_PIN"; 0066 dbusEmitMessage( "emitWaitingForPin" ); 0067 } 0068 0069 void 0070 Mp3tunesAmarokClient::harmonyConnected() 0071 { 0072 qDebug() << "Apparently Harmony is connected"; 0073 dbusEmitMessage( "emitConnected" ); 0074 } 0075 0076 void 0077 Mp3tunesAmarokClient::harmonyDisconnected() 0078 { 0079 qDebug() << "Harmony said see ya later."; 0080 dbusEmitMessage( "emitDisconnected" ); 0081 } 0082 0083 void 0084 Mp3tunesAmarokClient::harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ) 0085 { 0086 qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); 0087 QString name = "org.kde.amarok"; 0088 QDBusMessage m = QDBusMessage::createMethodCall( name, 0089 "/Mp3tunesHarmonyHandler", 0090 "", 0091 "emitDownloadReady" ); 0092 QList<QVariant> args; 0093 args.append( download.serialize() ); 0094 m.setArguments(args); 0095 QDBusMessage response = QDBusConnection::sessionBus().call( m ); 0096 if( response.type() == QDBusMessage::ErrorMessage ) 0097 { 0098 qDebug() << "Got ERROR response harmonyDownloadReady"; 0099 qDebug() << response.errorName() << ": " << response.errorMessage(); 0100 } 0101 } 0102 0103 void 0104 Mp3tunesAmarokClient::harmonyDownloadPending( const Mp3tunesHarmonyDownload &download ) 0105 { 0106 qDebug() << "Got message about pending: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); 0107 qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); 0108 QString name = "org.kde.amarok"; 0109 QDBusMessage m = QDBusMessage::createMethodCall( name, 0110 "/Mp3tunesHarmonyHandler", 0111 "", 0112 "emitDownloadPending" ); 0113 QList<QVariant> args; 0114 args.append( download.serialize() ); 0115 m.setArguments(args); 0116 QDBusMessage response = QDBusConnection::sessionBus().call( m ); 0117 if( response.type() == QDBusMessage::ErrorMessage ) 0118 { 0119 qDebug() << "Got ERROR response harmonyDownloadPending"; 0120 qDebug() << response.errorName() << ": " << response.errorMessage(); 0121 } 0122 }