This commit is contained in:
David Sansome 2010-09-26 21:31:24 +00:00
parent 0c95f7c234
commit c7bd0d3b01
6 changed files with 26 additions and 0 deletions

View File

@ -140,6 +140,11 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
return sendMessage(message.toUtf8(), timeout); return sendMessage(message.toUtf8(), timeout);
} }
bool QtLocalPeer::sendMessage(const char* message, int timeout)
{
return sendMessage(QByteArray(message), timeout);
}
bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout) bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
{ {
if (!isClient()) if (!isClient())

View File

@ -60,12 +60,14 @@ public:
bool isClient(); bool isClient();
bool sendMessage(const QString &message, int timeout); bool sendMessage(const QString &message, int timeout);
bool sendMessage(const QByteArray &message, int timeout); bool sendMessage(const QByteArray &message, int timeout);
bool sendMessage(const char* message, int timeout);
QString applicationId() const QString applicationId() const
{ return id; } { return id; }
Q_SIGNALS: Q_SIGNALS:
void messageReceived(const QString &message); void messageReceived(const QString &message);
void messageReceived(const QByteArray &message); void messageReceived(const QByteArray &message);
void messageReceived(const char* message);
protected Q_SLOTS: protected Q_SLOTS:
void receiveConnection(); void receiveConnection();

View File

@ -145,6 +145,7 @@ void QtSingleApplication::sysInit(const QString &appId)
peer = new QtLocalPeer(this, appId); peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
} }
@ -271,6 +272,11 @@ bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
return peer->sendMessage(message, timeout); return peer->sendMessage(message, timeout);
} }
bool QtSingleApplication::sendMessage(const char* message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*! /*!
Returns the application identifier. Two processes with the same Returns the application identifier. Two processes with the same
@ -300,10 +306,12 @@ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessag
if (activateOnMessage) { if (activateOnMessage) {
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
connect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow()));
} }
else { else {
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
disconnect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow()));
} }
} }

View File

@ -92,12 +92,14 @@ public:
public Q_SLOTS: public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000); bool sendMessage(const QString &message, int timeout = 5000);
bool sendMessage(const QByteArray &message, int timeout = 5000); bool sendMessage(const QByteArray &message, int timeout = 5000);
bool sendMessage(const char* message, int timeout = 5000);
void activateWindow(); void activateWindow();
Q_SIGNALS: Q_SIGNALS:
void messageReceived(const QString &message); void messageReceived(const QString &message);
void messageReceived(const QByteArray &message); void messageReceived(const QByteArray &message);
void messageReceived(const char* message);
private: private:

View File

@ -82,6 +82,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
peer = new QtLocalPeer(this); peer = new QtLocalPeer(this);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
} }
@ -96,6 +97,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc
peer = new QtLocalPeer(this, appId); peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
} }
@ -140,6 +142,11 @@ bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout
return peer->sendMessage(message, timeout); return peer->sendMessage(message, timeout);
} }
bool QtSingleCoreApplication::sendMessage(const char* message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*! /*!
Returns the application identifier. Two processes with the same Returns the application identifier. Two processes with the same

View File

@ -63,11 +63,13 @@ public:
public Q_SLOTS: public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000); bool sendMessage(const QString &message, int timeout = 5000);
bool sendMessage(const QByteArray &message, int timeout = 5000); bool sendMessage(const QByteArray &message, int timeout = 5000);
bool sendMessage(const char* message, int timeout = 5000);
Q_SIGNALS: Q_SIGNALS:
void messageReceived(const QString &message); void messageReceived(const QString &message);
void messageReceived(const QByteArray &message); void messageReceived(const QByteArray &message);
void messageReceived(const char* message);
private: private: