summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlli Salli <ollisal@gmail.com>2011-12-31 14:56:55 (GMT)
committerOlli Salli <ollisal@gmail.com>2011-12-31 14:56:55 (GMT)
commit46cec237dd40f7f711d4115914c7003fe65a3374 (patch)
treebabdf7561327c728831b73e7557f0dfc4260ed97
parent86ec1d65849acd730c9faf5a651ad210a59b56c2 (diff)
downloadtelepathy-qt4-46cec237dd40f7f711d4115914c7003fe65a3374.tar.gz
telepathy-qt4-46cec237dd40f7f711d4115914c7003fe65a3374.tar.xz
Add debug dump operator for Tp::ContactCapabilities
-rw-r--r--TelepathyQt/contact-capabilities.cpp44
-rw-r--r--TelepathyQt/contact-capabilities.h2
-rw-r--r--examples/stream-tubes/tube-initiator.cpp2
3 files changed, 48 insertions, 0 deletions
diff --git a/TelepathyQt/contact-capabilities.cpp b/TelepathyQt/contact-capabilities.cpp
index 7a59f25..62b7096 100644
--- a/TelepathyQt/contact-capabilities.cpp
+++ b/TelepathyQt/contact-capabilities.cpp
@@ -124,4 +124,48 @@ QStringList ContactCapabilities::streamTubeServices() const
return ret.toList();
}
+/**
+ * Outputs a human-readable description of the capabilities to a debugging stream.
+ *
+ * \param debug The QDebug debugging stream to output to.
+ * \param capabilities The capabilities to dump.
+ * \return The stream, with space inserted after the debug dump if necessary.
+ */
+QDebug operator<<(QDebug debug, const ContactCapabilities &caps)
+{
+ QDebug stream = debug.nospace();
+
+ stream << "Tp::ContactCapabilities {\n";
+
+ if (caps.isSpecificToContact()) {
+ stream << " is specific to this particular contact\n";
+ } else {
+ stream << " is common to all contacts in the network\n";
+ }
+
+ stream << " can have one-to-one text conversations: " <<
+ (caps.textChats() ? "yes" : "no") << '\n';
+ stream << " can have StreamedMedia calls in general: " <<
+ (caps.streamedMediaCalls() ? "yes" : "no") << '\n';
+ stream << " ... calls with an initial audio stream: " <<
+ (caps.streamedMediaAudioCalls() ? "yes" : "no") << '\n';
+ stream << " ... calls with an initial video stream: " <<
+ (caps.streamedMediaVideoCalls() ? "yes" : "no") << '\n';
+ stream << " ... calls with both initial audio and video streams: " <<
+ (caps.streamedMediaVideoCallsWithAudio() ? "yes" : "no") << '\n';
+ stream << " ... adding streams to already existing calls: " <<
+ (caps.upgradingStreamedMediaCalls() ? "yes" : "no") << '\n';
+ stream << " can send and receive files: " <<
+ (caps.fileTransfers() ? "yes" : "no") << '\n';
+
+ if (caps.streamTubeServices().isEmpty()) {
+ stream << " exports no services over Telepathy Stream Tubes\n";
+ } else {
+ stream << " exports these services over Telepathy Stream Tubes: [" <<
+ caps.streamTubeServices().join(QLatin1String(", ")) << "]\n";
+ }
+
+ return (stream << '}').space();
+}
+
} // Tp
diff --git a/TelepathyQt/contact-capabilities.h b/TelepathyQt/contact-capabilities.h
index 52de21e..75f32ba 100644
--- a/TelepathyQt/contact-capabilities.h
+++ b/TelepathyQt/contact-capabilities.h
@@ -59,6 +59,8 @@ protected:
bool specificToContact);
};
+TP_QT_EXPORT QDebug operator<<(QDebug debug, const ContactCapabilities &capabilities);
+
} // Tp
Q_DECLARE_METATYPE(Tp::ContactCapabilities);
diff --git a/examples/stream-tubes/tube-initiator.cpp b/examples/stream-tubes/tube-initiator.cpp
index b645466..3b5a3b5 100644
--- a/examples/stream-tubes/tube-initiator.cpp
+++ b/examples/stream-tubes/tube-initiator.cpp
@@ -158,6 +158,8 @@ void TubeInitiator::onContactRetrieved(PendingOperation *op)
SIGNAL(capabilitiesChanged(Tp::ContactCapabilities)),
SLOT(onContactCapabilitiesChanged()));
+ qDebug() << "Current capabilities:" << mContact->capabilities() << "for contact" << mContact->id();
+
if (mContact->capabilities().streamTubes(QLatin1String("tp-qt-stube-example"))) {
onContactCapabilitiesChanged();
} else {