Commit 7e3ed534 authored by Will Stephenson's avatar Will Stephenson

Lots of Qt 4.2 dbus updates. This just leaves the hard stuff in functions.cpp to do

svn path=/trunk/KDE/kdepim/; revision=557899
parent 15c88397
......@@ -135,8 +135,8 @@ void Daemon::createDcopHandler()
bool Daemon::sendDaemon(const QString& method, const QList<QVariant>& args)
{
if (!mDBusDaemon)
mDBusDaemon = QDBus::sessionBus().findInterface(DAEMON_DBUS_SERVICE, DAEMON_DBUS_OBJECT, DAEMON_DBUS_IFACE);
QDBusError err = mDBusDaemon->callWithArgs(method, args, QDBusAbstractInterface::NoWaitForReply);
mDBusDaemon = new QDBusInterface(DAEMON_DBUS_SERVICE, DAEMON_DBUS_OBJECT, DAEMON_DBUS_IFACE);
QDBusError err = mDBusDaemon->callWithArgumentList(QDBus::NoBlock, method, args);
if (err.isValid())
{
kError(5950) << "Daemon::sendDaemon(" << method << "): D-Bus call failed: " << err.message() << endl;
......@@ -720,10 +720,11 @@ int Daemon::maxTimeSinceCheck()
*/
bool Daemon::isDaemonRegistered()
{
QDBusReply<QStringList> apps = QDBus::sessionBus().busService()->listNames();
if (!apps.isSuccess())
QDBusReply<bool> reply = QDBus::sessionBus().interface()->isServiceRegistered(DAEMON_DBUS_SERVICE);
if ( reply.isValid() )
return reply.value();
else
return false;
return apps.value().contains(DAEMON_DBUS_SERVICE);
}
......
......@@ -32,7 +32,6 @@
#include <kstdaccel.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <dcopclient.h>
#include <kdebug.h>
#include <libkcal/event.h>
......
......@@ -36,7 +36,6 @@
#include <kstandarddirs.h>
#include <kconfig.h>
#include <kaboutdata.h>
#include <dcopclient.h>
#include <kprocess.h>
#include <ktempfile.h>
#include <kfileitem.h>
......@@ -49,7 +48,7 @@
#include "alarmlistview.h"
#include "editdlg.h"
#include "daemon.h"
#include "dcophandler.h"
#include "dbushandler.h"
#include "functions.h"
#include "kamail.h"
#include "karecurrence.h"
......@@ -94,7 +93,7 @@ QString KAlarmApp::mFatalMessage;
KAlarmApp::KAlarmApp()
: KUniqueApplication(),
mInitialised(false),
mDcopHandler(new DcopHandler()),
mDBusHandler(new DBusHandler()),
mTrayWindow(0),
mPendingQuit(false),
mProcessingQueue(false),
......
......@@ -35,7 +35,7 @@ class KProcess;
namespace KCal { class Event; }
#include "alarmevent.h"
class DcopHandler;
class DBusHandler;
class AlarmCalendar;
class MainWindow;
class AlarmListView;
......@@ -158,7 +158,7 @@ class KAlarmApp : public KUniqueApplication
static int mFatalError; // a fatal error has occurred - just wait to exit
static QString mFatalMessage; // fatal error message to output
bool mInitialised; // initialisation complete: ready to handle DCOP calls
DcopHandler* mDcopHandler; // the parent of the main DCOP receiver object
DBusHandler* mDBusHandler; // the parent of the main DCOP receiver object
TrayWindow* mTrayWindow; // active system tray icon
QTime mStartOfDay; // start-of-day time currently in use
QColor mPrefsArchivedColour; // archived alarms text colour
......
......@@ -140,8 +140,8 @@ void AlarmDaemon::quit()
bool AlarmDaemon::kalarmNotify(const QString& method, const QList<QVariant>& args)
{
if (!mDBusNotify)
mDBusNotify = QDBus::sessionBus().findInterface(KALARM_DBUS_SERVICE, NOTIFY_DBUS_OBJECT, NOTIFY_DBUS_IFACE);
QDBusError err = mDBusNotify->callWithArgs(method, args, QDBusAbstractInterface::NoWaitForReply);
mDBusNotify = new QDBusInterface(KALARM_DBUS_SERVICE, NOTIFY_DBUS_OBJECT, NOTIFY_DBUS_IFACE);
QDBusError err = mDBusNotify->callWithArgumentList(QDBus::NoBlock, method, args );
if (err.isValid())
{
kError(5900) << "AlarmDaemon::kalarmNotify(" << method << "): D-Bus call failed: " << err.message() << endl;
......@@ -237,8 +237,11 @@ void AlarmDaemon::resourceLocation(const QString& id, const QString& locn, const
*/
void AlarmDaemon::reloadResource(const QString& id, bool check, bool reset)
{
// FIXME: I don't think this check is possible with dbus
#if 0
if (check && kapp->dcopClient()->senderId() != mClientName)
return;
#endif
AlarmResources* resources = AlarmResources::instance();
if (id.isEmpty())
{
......@@ -305,8 +308,11 @@ void AlarmDaemon::resourceLoaded(AlarmResource* res)
*/
void AlarmDaemon::eventHandled(const QString& eventID, bool reload)
{
// FIXME I don't think this check can be done with DBus
#if 0
if (kapp->dcopClient()->senderId() != mClientName)
return;
#endif
kDebug(5900) << "AlarmDaemon::eventHandled()" << (reload ? ": reload" : "") << endl;
setEventHandled(eventID);
if (reload)
......@@ -740,8 +746,8 @@ QString AlarmDaemon::timezone()
*/
bool AlarmDaemon::isClientRegistered() const
{
QDBusReply<QStringList> apps = QDBus::sessionBus().busService()->listNames();
if (!apps.isSuccess())
QDBusReply<bool> isRegistered = QDBus::sessionBus().interface()->isServiceRegistered(mClientName);
if (!isRegistered.isValid())
return false;
return apps.value().contains(mClientName);
return isRegistered.value();
}
......@@ -43,7 +43,6 @@
#include <kedittoolbar.h>
#include <kxmlguifactory.h>
#include <kaboutdata.h>
#include <dcopclient.h>
#include <kdebug.h>
#include <libkdepim/maillistdrag.h>
......
......@@ -25,6 +25,7 @@
#include <QScrollBar>
#include <Q3MimeSourceFactory>
#include <QtDBus>
#include <QFile>
#include <QFileInfo>
#include <QPushButton>
......@@ -70,7 +71,6 @@
#include <phonon/audiooutput.h>
#include <phonon/volumefadereffect.h>
#endif
#include <dcopclient.h>
#include <kdebug.h>
#include <ktoolinvocation.h>
......@@ -92,7 +92,14 @@ static const char* KMIX_APP_NAME = "kmix";
static const char* KMIX_DCOP_OBJECT = "Mixer0";
static const char* KMIX_DCOP_WINDOW = "kmix-mainwindow#1";
#endif
static const char* KMAIL_DCOP_OBJECT = "KMailIface";
#warning KTTSD_DBUS_* defines are made up!
static const char * KTTSD_DBUS_SERVICE_NAME = "kttsd";
static const char * KTTDS_DBUS_PATH = "org/kde/kttsd/kttsdiface";
static const char * KTTSD_DBUS_INTERFACE = "org.kde.kttsd.kttsdiface";
#warning more made up dbus interface names follow
static const char * KMAIL_DBUS_SERVICE_NAME = "kmail";
static const char * KMAIL_DBUS_PATH = "/org/kde/pim/kmail/kmailiface";
static const char * KMAIL_DBUS_INTERFACE= "org.kde.pim.kmail.kmailiface";
// The delay for enabling message window buttons if a zero delay is
// configured, i.e. the windows are placed far from the cursor.
......@@ -942,8 +949,7 @@ void MessageWin::playAudio()
#else
// An audio file is specified. Because loading it may take some time,
// call it on a timer to allow the window to display first.
Phonon::AudioOutput* output = new Phonon::AudioOutput(this);
output->setCategory(Phonon::NotificationCategory);
Phonon::AudioOutput* output = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
output->setVolume(mVolume);
Phonon::AudioPath* path = new Phonon::AudioPath(this);
path->addOutput(output);
......@@ -973,10 +979,12 @@ void MessageWin::playAudio()
* Speak the message.
* Called asynchronously to avoid delaying the display of the message.
*/
void MessageWin::slotSpeak()
{
DCOPClient* client = kapp->dcopClient();
if (!client->isApplicationRegistered("kttsd"))
QDBusConnection client = QDBus::sessionBus();
if (!client.interface()->isServiceRegistered(KTTSD_DBUS_SERVICE_NAME))
{
// kttsd is not running, so start it
QString error;
......@@ -987,13 +995,13 @@ void MessageWin::slotSpeak()
return;
}
}
QByteArray data;
QDataStream arg(&data, QIODevice::WriteOnly);
arg << mMessage << QString();
if (!client->send("kttsd", "KSpeech", "sayMessage(QString,QString)", data))
// FIXME: this would be a lot cleaner just using kttsd's dbus stub.
QDBusInterface kttsdDBus(KTTSD_DBUS_SERVICE_NAME, KTTDS_DBUS_PATH, KTTSD_DBUS_INTERFACE );
QDBusMessage reply = kttsdDBus.call("sayMessage", mMessage, QString());
if (reply.type() == QDBusMessage::ErrorMessage)
{
kDebug(5950) << "MessageWin::slotSpeak(): sayMessage() DCOP error" << endl;
KMessageBox::detailedError(0, i18n("Unable to speak message"), i18n("DCOP Call sayMessage failed"));
kDebug(5950) << "MessageWin::slotSpeak(): sayMessage() DBus error" << endl;
KMessageBox::detailedError(0, i18n("Unable to speak message"), i18n("DBus call sayMessage failed"));
}
}
......@@ -1344,21 +1352,15 @@ void MessageWin::slotShowKMailMessage()
KMessageBox::sorry(this, err);
return;
}
DCOPCString replyType;
QByteArray data, replyData;
QDataStream arg(&data, QIODevice::WriteOnly);
arg << (quint32)mKMailSerialNumber << QString();
if (kapp->dcopClient()->call("kmail", KMAIL_DCOP_OBJECT, "showMail(quint32,QString)", data, replyType, replyData)
&& replyType == "bool")
{
bool result;
QDataStream replyStream(&replyData, QIODevice::ReadOnly);
replyStream >> result;
if (result)
return; // success
}
kError(5950) << "MessageWin::slotShowKMailMessage(): kmail dcop call failed\n";
KMessageBox::sorry(this, i18n("Unable to locate this email in KMail"));
QDBusInterface kmailIface( KMAIL_DBUS_SERVICE_NAME, KMAIL_DBUS_PATH, KMAIL_DBUS_INTERFACE );
QDBusReply<bool> reply = kmailIface.call( "showMail", (qulonglong)mKMailSerialNumber, QString() );
if ( reply.isValid() )
if ( reply.value() )
return;
else
KMessageBox::sorry(this, i18n("Unable to locate this email in KMail"));
else
kError(5950) << "MessageWin::slotShowKMailMessage(): kmail dbus call to showMail failed\n";
}
/******************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment