SQL driver implementation to signal notification sources
Implements the new notification signal in all QSql drivers which use notifcation. In qt5 only ibase and psql have a notification implementation. PSQL differentiates correctly between 'SelfSource' and 'OtherSource' whereas ibase only signals 'UnknownSource' as a default implementation. Change-Id: Ifcaa139b7a980ed852cf817b3f93284609360ca7 Reviewed-by: Torben Dannhauer <torben@dannhauer.info> Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
This commit is contained in:
parent
84f4b81499
commit
5caa75f665
@ -1845,8 +1845,10 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer)
|
||||
isc_event_counts(counts, eBuffer->bufferLength, eBuffer->eventBuffer, eBuffer->resultBuffer);
|
||||
if (counts[0]) {
|
||||
|
||||
if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed)
|
||||
if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) {
|
||||
emit notification(i.key());
|
||||
emit notification(i.key(), QSqlDriver::UnknownSource);
|
||||
}
|
||||
else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting)
|
||||
eBuffer->subscriptionState = QIBaseEventBuffer::Subscribed;
|
||||
|
||||
|
@ -1370,8 +1370,13 @@ void QPSQLDriver::_q_handleNotification(int)
|
||||
PGnotify *notify = 0;
|
||||
while((notify = PQnotifies(d->connection)) != 0) {
|
||||
QString name(QLatin1String(notify->relname));
|
||||
if (d->seid.contains(name))
|
||||
if (d->seid.contains(name)) {
|
||||
emit notification(name);
|
||||
if (notify->be_pid == PQbackendPID(d->connection))
|
||||
emit notification(name, QSqlDriver::SelfSource);
|
||||
else
|
||||
emit notification(name, QSqlDriver::OtherSource);
|
||||
}
|
||||
else
|
||||
qWarning("QPSQLDriver: received notification for '%s' which isn't subscribed to.",
|
||||
qPrintable(name));
|
||||
|
@ -130,6 +130,17 @@ QSqlDriver::~QSqlDriver()
|
||||
\sa subscribeToNotification()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\since 5.0
|
||||
|
||||
\fn QSqlDriver::notification(const QString &name, NotificationSource source)
|
||||
|
||||
This signal is emitted when the database posts an event notification
|
||||
that the driver subscribes to. \a name identifies the event notification, \a source indicates the signal source.
|
||||
|
||||
\sa subscribeToNotification()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QSqlDriver::open(const QString &db, const QString &user, const QString& password,
|
||||
const QString &host, int port, const QString &options)
|
||||
@ -242,9 +253,9 @@ bool QSqlDriver::isOpenError() const
|
||||
|
||||
This enum contains a list of SQL notification sources.
|
||||
|
||||
\value Unknown The notification source is unknown
|
||||
\value Self The notification source is the own connection
|
||||
\value Other The notification source is another connection
|
||||
\value UnknownSource The notification source is unknown
|
||||
\value SelfSource The notification source is this connection
|
||||
\value OtherSource The notification source is another connection
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
enum IdentifierType { FieldName, TableName };
|
||||
|
||||
enum NotificationSource { Unknown, Self, Other };
|
||||
enum NotificationSource { UnknownSource, SelfSource, OtherSource };
|
||||
|
||||
explicit QSqlDriver(QObject *parent=0);
|
||||
~QSqlDriver();
|
||||
|
Loading…
Reference in New Issue
Block a user