summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TelepathyQt4/channel.cpp21
-rw-r--r--TelepathyQt4/channel.h1
-rw-r--r--TelepathyQt4/constants.h98
-rw-r--r--tests/dbus/chan-basics.cpp123
-rw-r--r--tools/qt4-constants-gen.py2
5 files changed, 168 insertions, 77 deletions
diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp
index 2cbd5ed0..dd2d5562 100644
--- a/TelepathyQt4/channel.cpp
+++ b/TelepathyQt4/channel.cpp
@@ -288,10 +288,6 @@ Channel::Private::Private(Channel *parent, const ConnectionPtr &connection,
parent->connect(connection.data(),
SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
SLOT(onConnectionInvalidated()));
-
- parent->connect(connection.data(),
- SIGNAL(destroyed()),
- SLOT(onConnectionDestroyed()));
}
else {
warning() << "Connection given as the owner for a Channel was "
@@ -2587,9 +2583,8 @@ void Channel::onClosed()
mPriv->groupSelfContactRemoveInfo);
message = mPriv->groupSelfContactRemoveInfo.message();
} else {
- // I think this is the nearest error code we can get at the moment
- error = QLatin1String(TELEPATHY_ERROR_TERMINATED);
- message = QLatin1String("Closed");
+ error = TP_QT4_ERROR_CANCELLED;
+ message = QLatin1String("channel closed");
}
invalidate(error, message);
@@ -2624,16 +2619,8 @@ void Channel::onConnectionInvalidated()
{
debug() << "Owning connection died leaving an orphan Channel, "
"changing to closed";
- invalidate(QLatin1String(TELEPATHY_ERROR_CANCELLED),
- QLatin1String("Connection given as the owner of this channel was invalidate"));
-}
-
-void Channel::onConnectionDestroyed()
-{
- debug() << "Owning connection destroyed, cutting off dangling pointer";
- mPriv->connection.reset();
- invalidate(QLatin1String(TELEPATHY_ERROR_CANCELLED),
- QLatin1String("Connection given as the owner of this channel was destroyed"));
+ invalidate(QLatin1String(TP_QT4_ERROR_ORPHANED),
+ QLatin1String("Connection given as the owner of this channel was invalidated"));
}
void Channel::gotGroupProperties(QDBusPendingCallWatcher *watcher)
diff --git a/TelepathyQt4/channel.h b/TelepathyQt4/channel.h
index d3cdc730..dce22c4e 100644
--- a/TelepathyQt4/channel.h
+++ b/TelepathyQt4/channel.h
@@ -204,7 +204,6 @@ private Q_SLOTS:
void onConnectionReady(Tp::PendingOperation *op);
void onConnectionInvalidated();
- void onConnectionDestroyed();
void gotGroupProperties(QDBusPendingCallWatcher *watcher);
void gotGroupFlags(QDBusPendingCallWatcher *watcher);
diff --git a/TelepathyQt4/constants.h b/TelepathyQt4/constants.h
index 668ef56b..2f926e73 100644
--- a/TelepathyQt4/constants.h
+++ b/TelepathyQt4/constants.h
@@ -48,12 +48,24 @@
#define TELEPATHY_CONNECTION_MANAGER_BUS_NAME_BASE "org.freedesktop.Telepathy.ConnectionManager."
/**
+ * The prefix for a connection manager's bus name, to which the CM's name (e.g.
+ * "gabble") should be appended.
+ */
+#define TP_QT4_CONNECTION_MANAGER_BUS_NAME_BASE QLatin1String("org.freedesktop.Telepathy.ConnectionManager.")
+
+/**
* The prefix for a connection manager's object path, to which the CM's name
* (e.g. "gabble") should be appended.
*/
#define TELEPATHY_CONNECTION_MANAGER_OBJECT_PATH_BASE "/org/freedesktop/Telepathy/ConnectionManager/"
/**
+ * The prefix for a connection manager's object path, to which the CM's name
+ * (e.g. "gabble") should be appended.
+ */
+#define TP_QT4_CONNECTION_MANAGER_OBJECT_PATH_BASE QLatin1String("/org/freedesktop/Telepathy/ConnectionManager/")
+
+/**
* The prefix for a connection's bus name, to which the CM's name (e.g.
* "gabble"), the protocol (e.g. "jabber") and an element
* representing the account should be appended.
@@ -61,6 +73,13 @@
#define TELEPATHY_CONNECTION_BUS_NAME_BASE "org.freedesktop.Telepathy.Connection."
/**
+ * The prefix for a connection's bus name, to which the CM's name (e.g.
+ * "gabble"), the protocol (e.g. "jabber") and an element
+ * representing the account should be appended.
+ */
+#define TP_QT4_CONNECTION_BUS_NAME_BASE QLatin1String("org.freedesktop.Telepathy.Connection.")
+
+/**
* The prefix for a connection's object path, to which the CM's name (e.g.
* "gabble"), the protocol (e.g. "jabber") and an element
* representing the account should be appended.
@@ -76,6 +95,14 @@
"org.freedesktop.Telepathy.AccountManager"
/**
+ * The well-known bus name of the Account Manager.
+ *
+ * \see Tp::AccountManager
+ */
+#define TP_QT4_ACCOUNT_MANAGER_BUS_NAME \
+ (QLatin1String("org.freedesktop.Telepathy.AccountManager"))
+
+/**
* The object path of the Account Manager object.
*
* \see Tp::AccountManager
@@ -84,6 +111,14 @@
"/org/freedesktop/Telepathy/AccountManager"
/**
+ * The object path of the Account Manager object.
+ *
+ * \see Tp::AccountManager
+ */
+#define TP_QT4_ACCOUNT_MANAGER_OBJECT_PATH \
+ (QLatin1String("/org/freedesktop/Telepathy/AccountManager"))
+
+/**
* The prefix for an Account's object path, to which the CM's name (e.g.
* "gabble"), the protocol (e.g. "jabber") and an element
* identifying the particular account should be appended.
@@ -94,6 +129,16 @@
"/org/freedesktop/Telepathy/Account"
/**
+ * The prefix for an Account's object path, to which the CM's name (e.g.
+ * "gabble"), the protocol (e.g. "jabber") and an element
+ * identifying the particular account should be appended.
+ *
+ * \see Tp::Account
+ */
+#define TP_QT4_ACCOUNT_OBJECT_PATH_BASE \
+ (QLatin1String("/org/freedesktop/Telepathy/Account"))
+
+/**
* @}
*/
@@ -117,6 +162,21 @@
/**
* \ingroup errorstrconsts
*
+ * The error name "org.freedesktop.DBus.Error.NameHasNoOwner" as a QLatin1String.
+ *
+ * Raised by the D-Bus daemon when looking up the owner of a well-known name,
+ * if no process owns that name.
+ *
+ * Also used by DBusProxy to indicate that the owner of a well-known name
+ * has disappeared (usually indicating that the process owning that name
+ * exited or crashed).
+ */
+#define TP_QT4_DBUS_ERROR_NAME_HAS_NO_OWNER \
+ (QLatin1String("org.freedesktop.DBus.Error.NameHasNoOwner"))
+
+/**
+ * \ingroup errorstrconsts
+ *
* The error name "org.freedesktop.DBus.Error.UnknownMethod".
*
* Raised by the D-Bus daemon when the method name invoked isn't
@@ -128,6 +188,17 @@
/**
* \ingroup errorstrconsts
*
+ * The error name "org.freedesktop.DBus.Error.UnknownMethod" as a QLatin1String.
+ *
+ * Raised by the D-Bus daemon when the method name invoked isn't
+ * known by the object you invoked it on.
+ */
+#define TP_QT4_DBUS_ERROR_UNKNOWN_METHOD \
+ (QLatin1String("org.freedesktop.DBus.Error.UnknownMethod"))
+
+/**
+ * \ingroup errorstrconsts
+ *
* The error name "org.freedesktop.Telepathy.Qt4.Error.ObjectRemoved".
*/
#define TELEPATHY_QT4_ERROR_OBJECT_REMOVED \
@@ -136,9 +207,36 @@
/**
* \ingroup errorstrconsts
*
+ * The error name "org.freedesktop.Telepathy.Qt4.Error.ObjectRemoved" as a QLatin1String.
+ */
+#define TP_QT4_ERROR_OBJECT_REMOVED \
+ (QLatin1String("org.freedesktop.Telepathy.Qt4.Error.ObjectRemoved"))
+
+/**
+ * \ingroup errorstrconsts
+ *
* The error name "org.freedesktop.Telepathy.Qt4.Error.Inconsistent".
*/
#define TELEPATHY_QT4_ERROR_INCONSISTENT \
"org.freedesktop.Telepathy.Qt4.Error.Inconsistent"
+/**
+ * \ingroup errorstrconsts
+ *
+ * The error name "org.freedesktop.Telepathy.Qt4.Error.Inconsistent" as a QLatin1String.
+ */
+#define TP_QT4_ERROR_INCONSISTENT \
+ (QLatin1String("org.freedesktop.Telepathy.Qt4.Error.Inconsistent"))
+
+/**
+ * \ingroup errorstrconsts
+ *
+ * The error name "org.freedesktop.Telepathy.Qt4.Error.Orphaned" as a QLatin1String.
+ *
+ * This error is used when the "parent" proxy of an object gets invalidated. For example, a Channel
+ * whose corresponding Connection is invalidated invalidates itself with this error.
+ */
+#define TP_QT4_ERROR_ORPHANED \
+ (QLatin1String("org.freedesktop.Telepathy.Qt4.Error.Orphaned"))
+
#endif
diff --git a/tests/dbus/chan-basics.cpp b/tests/dbus/chan-basics.cpp
index 4cbe1e78..f82ffd65 100644
--- a/tests/dbus/chan-basics.cpp
+++ b/tests/dbus/chan-basics.cpp
@@ -36,7 +36,7 @@ public:
protected Q_SLOTS:
void expectConnReady(Tp::ConnectionStatus, Tp::ConnectionStatusReason);
- void expectConnInvalidated();
+ void expectInvalidated(const QString &reason);
void expectPendingHandleFinished(Tp::PendingOperation*);
void expectCreateChannelFinished(Tp::PendingOperation *);
void expectEnsureChannelFinished(Tp::PendingOperation *);
@@ -85,8 +85,9 @@ void TestChanBasics::expectConnReady(Tp::ConnectionStatus newStatus,
}
}
-void TestChanBasics::expectConnInvalidated()
+void TestChanBasics::expectInvalidated(const QString &reason)
{
+ qDebug() << sender() << "invalidated:" << reason;
mLoop->exit(0);
}
@@ -234,6 +235,8 @@ void TestChanBasics::initTestCase()
void TestChanBasics::init()
{
initImpl();
+
+ mChan.reset();
}
void TestChanBasics::testRequestHandle()
@@ -268,31 +271,29 @@ void TestChanBasics::testCreateChannel()
SLOT(expectCreateChannelFinished(Tp::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
- if (mChan) {
- QVERIFY(connect(mChan->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mChan->isReady(), true);
- QCOMPARE(mChan->isRequested(), true);
- QCOMPARE(mChan->groupCanAddContacts(), false);
- QCOMPARE(mChan->groupCanRemoveContacts(), false);
- QCOMPARE(mChan->initiatorContact()->id(), QString(QLatin1String("me@example.com")));
- QCOMPARE(mChan->groupSelfContact()->id(), QString(QLatin1String("me@example.com")));
- QCOMPARE(mChan->groupSelfContact(), mConn->selfContact());
-
- QStringList ids;
- Q_FOREACH (const ContactPtr &contact, mChan->groupContacts()) {
- ids << contact->id();
- }
- ids.sort();
- QStringList toCheck = QStringList() << QLatin1String("me@example.com")
- << QLatin1String("alice");
- toCheck.sort();
- QCOMPARE(ids, toCheck);
+ Q_ASSERT(!mChan.isNull());
- mChan.reset();
+ QVERIFY(connect(mChan->becomeReady(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mChan->isReady(), true);
+ QCOMPARE(mChan->isRequested(), true);
+ QCOMPARE(mChan->groupCanAddContacts(), false);
+ QCOMPARE(mChan->groupCanRemoveContacts(), false);
+ QCOMPARE(mChan->initiatorContact()->id(), QString(QLatin1String("me@example.com")));
+ QCOMPARE(mChan->groupSelfContact()->id(), QString(QLatin1String("me@example.com")));
+ QCOMPARE(mChan->groupSelfContact(), mConn->selfContact());
+
+ QStringList ids;
+ Q_FOREACH (const ContactPtr &contact, mChan->groupContacts()) {
+ ids << contact->id();
}
+ ids.sort();
+ QStringList toCheck = QStringList() << QLatin1String("me@example.com")
+ << QLatin1String("alice");
+ toCheck.sort();
+ QCOMPARE(ids, toCheck);
}
void TestChanBasics::testEnsureChannel()
@@ -309,37 +310,35 @@ void TestChanBasics::testEnsureChannel()
SLOT(expectEnsureChannelFinished(Tp::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
- if (mChan) {
- QVERIFY(connect(mChan->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mChan->isReady(), true);
- QCOMPARE(mChan->isRequested(), true);
- QCOMPARE(mChan->groupCanAddContacts(), false);
- QCOMPARE(mChan->groupCanRemoveContacts(), false);
- QCOMPARE(mChan->initiatorContact()->id(), QString(QLatin1String("me@example.com")));
- QCOMPARE(mChan->groupSelfContact()->id(), QString(QLatin1String("me@example.com")));
- QCOMPARE(mChan->groupSelfContact(), mConn->selfContact());
-
- QStringList ids;
- Q_FOREACH (const ContactPtr &contact, mChan->groupContacts()) {
- ids << contact->id();
- }
- ids.sort();
- QStringList toCheck = QStringList() << QLatin1String("me@example.com")
- << QLatin1String("alice");
- toCheck.sort();
- QCOMPARE(ids, toCheck);
-
- QVERIFY(connect(mChan->requestClose(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mChan->isValid(), false);
+ QVERIFY(!mChan.isNull());
- mChan.reset();
+ QVERIFY(connect(mChan->becomeReady(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mChan->isReady(), true);
+ QCOMPARE(mChan->isRequested(), true);
+ QCOMPARE(mChan->groupCanAddContacts(), false);
+ QCOMPARE(mChan->groupCanRemoveContacts(), false);
+ QCOMPARE(mChan->initiatorContact()->id(), QString(QLatin1String("me@example.com")));
+ QCOMPARE(mChan->groupSelfContact()->id(), QString(QLatin1String("me@example.com")));
+ QCOMPARE(mChan->groupSelfContact(), mConn->selfContact());
+
+ QStringList ids;
+ Q_FOREACH (const ContactPtr &contact, mChan->groupContacts()) {
+ ids << contact->id();
}
+ ids.sort();
+ QStringList toCheck = QStringList() << QLatin1String("me@example.com")
+ << QLatin1String("alice");
+ toCheck.sort();
+ QCOMPARE(ids, toCheck);
+
+ QVERIFY(connect(mChan->requestClose(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mChan->isValid(), false);
}
void TestChanBasics::cleanup()
@@ -360,14 +359,22 @@ void TestChanBasics::cleanupTestCase()
QVERIFY(connect(mConn.data(),
SIGNAL(invalidated(Tp::DBusProxy *,
const QString &, const QString &)),
- SLOT(expectConnInvalidated())));
+ SLOT(expectInvalidated(QString))));
QCOMPARE(mLoop->exec(), 0);
}
}
- if (mConnService != 0) {
- g_object_unref(mConnService);
- mConnService = 0;
+ if (mChan) {
+ if (mChan->isValid()) {
+ QVERIFY(connect(mChan.data(),
+ SIGNAL(invalidated(Tp::DBusProxy *,
+ const QString &, const QString &)),
+ SLOT(expectInvalidated(QString))));
+ QCOMPARE(mLoop->exec(), 0);
+ }
+
+ QVERIFY(mChan->invalidationReason() == TP_QT4_ERROR_CANCELLED ||
+ mChan->invalidationReason() == TP_QT4_ERROR_ORPHANED);
}
cleanupTestCaseImpl();
diff --git a/tools/qt4-constants-gen.py b/tools/qt4-constants-gen.py
index 47a7a4e1..11c4b5ed 100644
--- a/tools/qt4-constants-gen.py
+++ b/tools/qt4-constants-gen.py
@@ -150,7 +150,7 @@ namespace %s
* The interface name "%(name)s" as a QLatin1String, usable in QString requiring contexts even when
* building with Q_NO_CAST_FROM_ASCII defined.
*/
-#define %(DEFINE)s QLatin1String("%(name)s")
+#define %(DEFINE)s (QLatin1String("%(name)s"))
""" % {'name' : iface.getAttribute('name'),
'DEFINE' : self.define_prefix + 'IFACE_' + get_by_path(iface, '../@name').upper().replace('/', '')})