Hi!
I was working on Telepathy KDE and i noticed that the '!=' operator had not
been implemented in Tp::Presence and Tp::PresenceSpec. This patch fixes
that. I know that one could easily use the '==' operator and implement this
functionality in the application using Tp::Presence itself, but i think that
this should be implemented by the Tp::Presence class itself in order to keep
code using the Telepathy Qt4 API cleaner.

Regards
Rohan Garg
From f4bc047608c76cd4474a0c7e3e490e1534558c84 Mon Sep 17 00:00:00 2001
From: Rohan Garg <[email protected]>
Date: Thu, 29 Sep 2011 00:03:07 +0530
Subject: [PATCH] Implement the != operator for Tp::Presence and
 Tp::PresenceSpec

---
 TelepathyQt4/presence.cpp |   25 +++++++++++++++++++++++++
 TelepathyQt4/presence.h   |    2 ++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/presence.cpp b/TelepathyQt4/presence.cpp
index acbc5d6..3810616 100644
--- a/TelepathyQt4/presence.cpp
+++ b/TelepathyQt4/presence.cpp
@@ -128,6 +128,18 @@ bool Presence::operator==(const Presence &other) const
     return mPriv->sp == other.mPriv->sp;
 }
 
+bool Presence::operator!=(const Presence &other) const
+{
+    if (!isValid() || !other.isValid()) {
+        if (!isValid() && !other.isValid()) {
+            return false;
+        }
+        return true;
+    }
+
+    return mPriv->sp != other.mPriv->sp;
+}
+
 ConnectionPresenceType Presence::type() const
 {
     if (!isValid()) {
@@ -245,6 +257,19 @@ bool PresenceSpec::operator==(const PresenceSpec &other) const
            (mPriv->spec == other.mPriv->spec);
 }
 
+bool PresenceSpec::operator!=(const PresenceSpec &other) const
+{
+    if (!isValid() || !other.isValid()) {
+        if (!isValid() && !other.isValid()) {
+            return false;
+        }
+        return true;
+    }
+
+    return (mPriv->status != other.mPriv->status) &&
+           (mPriv->spec != other.mPriv->spec);
+}
+
 bool PresenceSpec::operator<(const PresenceSpec &other) const
 {
     if (!isValid()) {
diff --git a/TelepathyQt4/presence.h b/TelepathyQt4/presence.h
index 242236e..d12fb5e 100644
--- a/TelepathyQt4/presence.h
+++ b/TelepathyQt4/presence.h
@@ -54,6 +54,7 @@ public:
 
     Presence &operator=(const Presence &other);
     bool operator==(const Presence &other) const;
+    bool operator!=(const Presence &other) const;
 
     ConnectionPresenceType type() const;
     QString status() const;
@@ -82,6 +83,7 @@ public:
 
     PresenceSpec &operator=(const PresenceSpec &other);
     bool operator==(const PresenceSpec &other) const;
+    bool operator!=(const PresenceSpec &other) const;
     bool operator<(const PresenceSpec &other) const;
 
     Presence presence(const QString &statusMessage = QString()) const;
-- 
1.7.5.4

_______________________________________________
telepathy mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/telepathy

Reply via email to