]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/lib/magicenvelope.php
Diaspora plugin is almost there (for remote salmon slaps at least)
[quix0rs-gnu-social.git] / plugins / OStatus / lib / magicenvelope.php
index e6b068c92447dc01ce5abb4e156544783f76090b..e96862bbadc0d03a7d7f221a8d2b07c63672bfb9 100644 (file)
@@ -205,10 +205,10 @@ class MagicEnvelope
      *
      * @return string representation of XML document
      */
-    public function toXML($flavour=null) {
+    public function toXML(Profile $target=null, $flavour=null) {
         $xs = new XMLStringer();
         $xs->startXML();    // header, to point out it's not HTML or anything...
-        if (Event::handle('StartMagicEnvelopeToXML', array($this, $xs, $flavour))) {
+        if (Event::handle('StartMagicEnvelopeToXML', array($this, $xs, $flavour, $target))) {
             // fall back to our default, normal Magic Envelope XML.
             // the $xs element _may_ have had elements added, or could get in the end event
             $xs->elementStart('me:env', array('xmlns:me' => self::NS));
@@ -218,7 +218,7 @@ class MagicEnvelope
             $xs->element('me:sig', null, $this->getSignature());
             $xs->elementEnd('me:env');
 
-            Event::handle('EndMagicEnvelopeToXML', array($this, $xs, $flavour));
+            Event::handle('EndMagicEnvelopeToXML', array($this, $xs, $flavour, $target));
         }
         return $xs->getString();
     }
@@ -266,6 +266,9 @@ class MagicEnvelope
 
     public function getSignature()
     {
+        if (empty($this->sig)) {
+            throw new ServerException('You must first call signMessage before getSignature');
+        }
         return $this->sig;
     }
 
@@ -274,6 +277,11 @@ class MagicEnvelope
         return $this->alg;
     }
 
+    public function getData()
+    {
+        return $this->data;
+    }
+
     public function getDataType()
     {
         return $this->data_type;