Make PeerPtr work for RPC calls
[quassel.git] / src / common / peer.cpp
index 671f634..3785326 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2013 by the Quassel Project                        *
+ *   Copyright (C) 2005-2015 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -32,3 +32,22 @@ AuthHandler *Peer::authHandler() const
 {
     return _authHandler;
 }
+
+
+// Note that we need to use a fixed-size integer instead of uintptr_t, in order
+// to avoid issues with different architectures for client and core.
+// In practice, we'll never really have to restore the real value of a PeerPtr from
+// a QVariant.
+QDataStream &operator<<(QDataStream &out, PeerPtr ptr)
+{
+    out << reinterpret_cast<quint64>(ptr);
+    return out;
+}
+
+QDataStream &operator>>(QDataStream &in, PeerPtr &ptr)
+{
+    quint64 value;
+    in >> value;
+    ptr = reinterpret_cast<PeerPtr>(value);
+    return in;
+}