1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-20 04:41:36 +02:00

Check if Adium is running before setting status. Be more efficient about forming the Applescript string.

This commit is contained in:
Alejandro Wainzinger
2011-06-05 17:57:33 -07:00
parent 1021e9c1b5
commit 4f8165cc8a
2 changed files with 23 additions and 5 deletions

View File

@@ -26,13 +26,18 @@
#include "adiumplugin.h" #include "adiumplugin.h"
#include "adium.h" #include "adium.h"
QString adium_beforeStatus;
QString adium_afterStatus;
static void setStatus(const QString &status) static void setStatus(const QString &status)
{ {
QString adiumStatus = "tell application \"Adium\"\n"; // The command that updates the status
adiumStatus.append("set the status message of every account to \""); QString scriptqstr;
adiumStatus.append(status); scriptqstr.append(adium_beforeStatus);
adiumStatus.append("\"\nend tell\n"); scriptqstr.append(status);
const char* scriptstr = adiumStatus.toUtf8(); scriptqstr.append(adium_afterStatus);
const char* scriptstr = scriptqstr.toUtf8();
script( scriptstr ); script( scriptstr );
} }
@@ -42,6 +47,17 @@ AdiumPlugin::AdiumPlugin()
: InfoPlugin() : InfoPlugin()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
adium_beforeStatus = "if appIsRunning(\"Adium\") then\n";
adium_beforeStatus.append("tell application \"Adium\"\n");
adium_beforeStatus.append("set the status message of every account to \"");
adium_afterStatus.append("\"\nend tell\n");
adium_afterStatus.append("end if\n");
adium_afterStatus.append("on appIsRunning(appName)\n");
adium_afterStatus.append("tell application \"System Events\" to (name of processes) contains appName\n");
adium_afterStatus.append("end appIsRunning\n");
m_supportedPushTypes << InfoNowPlaying << InfoNowPaused << InfoNowResumed << InfoNowStopped; m_supportedPushTypes << InfoNowPlaying << InfoNowPaused << InfoNowResumed << InfoNowStopped;
m_active = TomahawkSettings::instance()->nowPlayingEnabled(); m_active = TomahawkSettings::instance()->nowPlayingEnabled();

View File

@@ -54,6 +54,8 @@ public slots:
private: private:
bool m_active; bool m_active;
QString m_beforeStatus;
QString m_afterStatus;
}; };