Exemple #1
0
 public function msgUpdate(Msg $msgNew)
 {
     $rv = false;
     if (isset($this->msgs[$msgNew->getId()])) {
         $msgOld = $this->msgs[$msgNew->getId()];
         if ($msgOld->getVersion() != $msgNew->getVersion()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: version'."\n";
             $msgOld->setVersion($msgNew->getVersion());
             $this->setDataChanged(true);
             $rv = true;
         }
         /*if($msgOld->getId() != $msgNew->getId()){
         			#print __CLASS__.'->'.__FUNCTION__.': changed: id'."\n";
         			$msgOld->setId($msgNew->getId());
         			$this->setDataChanged(true);
         			$rv = true;
         		}*/
         if ($msgOld->getSrcNodeId() != $msgNew->getSrcNodeId()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed srcNodeId: '.$msgOld->getSrcNodeId().' '.$msgNew->getSrcNodeId()."\n";
             $msgOld->setSrcNodeId($msgNew->getSrcNodeId());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getSrcSslKeyPub() != $msgNew->getSrcSslKeyPub()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: srcSslKeyPub'."\n";
             $msgOld->setSrcSslKeyPub($msgNew->getSrcSslKeyPub());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getDstNodeId() != $msgNew->getDstNodeId()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: dstNodeId'."\n";
             $msgOld->setDstNodeId($msgNew->getDstNodeId());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getDstSslPubKey() != $msgNew->getDstSslPubKey()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: dstSslPubKey'."\n";
             $msgOld->setDstSslPubKey($msgNew->getDstSslPubKey());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getSubject() != $msgNew->getSubject()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: subject'."\n";
             $msgOld->setSubject($msgNew->getSubject());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getBody() != $msgNew->getBody()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: text'."\n";
             $msgOld->setBody($msgNew->getBody());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getText() != $msgNew->getText()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: text'."\n";
             $msgOld->setText($msgNew->getText());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getPassword() != $msgNew->getPassword()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: password'."\n";
             $msgOld->setPassword($msgNew->getPassword());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getChecksum() != $msgNew->getChecksum()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: checksum'."\n";
             $msgOld->setChecksum($msgNew->getChecksum());
             $this->setDataChanged(true);
             $rv = true;
         }
         $msgOldSentNodes = $msgOld->getSentNodes();
         $msgNewSentNodes = $msgNew->getSentNodes();
         #if(count($msgOldSentNodes) < count($msgNewSentNodes)){
         if ($msgOldSentNodes != $msgNewSentNodes) {
             $msgOld->setSentNodes(array_unique(array_merge($msgOldSentNodes, $msgNewSentNodes)));
         }
         if ($msgOld->getRelayCount() != $msgNew->getRelayCount()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: relayCount'."\n";
             $msgOld->setRelayCount($msgNew->getRelayCount());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getForwardCycles() != $msgNew->getForwardCycles()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: forwardCycles'."\n";
             $msgOld->setForwardCycles($msgNew->getForwardCycles());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getEncryptionMode() != $msgNew->getEncryptionMode()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: encryptionMode, '.$msgOld->getEncryptionMode();
             #print ', '.$msgNew->getEncryptionMode()."\n";
             $msgOld->setEncryptionMode($msgNew->getEncryptionMode());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getStatus() != $msgNew->getStatus()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: status'."\n";
             $msgOld->setStatus($msgNew->getStatus());
             $this->setDataChanged(true);
             $rv = true;
         }
         if ($msgOld->getTimeCreated() != $msgNew->getTimeCreated()) {
             #print __CLASS__.'->'.__FUNCTION__.': changed: timeCreated'."\n";
             $msgOld->setTimeCreated($msgNew->getTimeCreated());
             $this->setDataChanged(true);
             $rv = true;
         }
         /*if($msgOld->getDataChanged() != $msgNew->getDataChanged()){
         			#print __CLASS__.'->'.__FUNCTION__.': changed: dataChanged'."\n";
         			$msgOld->setDataChanged($msgNew->getDataChanged());
         		}*/
     }
     return $rv;
 }
Exemple #2
0
 /**
  * @dataProvider providerEncryption
  */
 public function testEncryption($srcUserNickname, $subject, $text, $ignore)
 {
     $msg = new Msg();
     $msg->setVersion(1);
     $msg->setId('cafed00d-2131-4159-8e11-0b4dbadb1738');
     $msg->setSrcNodeId('cafed00d-2331-4159-8e11-0b4dbadb1738');
     $msg->setSrcSslKeyPub(static::SRC1_SSL_KEY_PUB);
     $msg->setSrcUserNickname($srcUserNickname);
     $msg->setDstNodeId('cafed00d-2431-4159-8e11-0b4dbadb1738');
     $msg->setDstSslPubKey(static::DST1_SSL_KEY_PUB);
     $msg->setSubject($subject);
     $msg->setText($text);
     $msg->setSslKeyPrv(static::SRC1_SSL_KEY_PRV, static::SSL_KEY_PRV_PASS);
     $msg->setIgnore($ignore);
     $this->assertTrue($msg->encrypt());
     $body = $msg->getBody();
     $timeCreated = $msg->getTimeCreated();
     $password = $msg->getPassword();
     $checksum = $msg->getChecksum();
     $msg = new Msg();
     $msg->setVersion(1);
     $msg->setId('cafed00d-2131-4159-8e11-0b4dbadb1738');
     $msg->setSrcNodeId('cafed00d-2331-4159-8e11-0b4dbadb1738');
     $msg->setBody($body);
     $msg->setSrcSslKeyPub(static::SRC1_SSL_KEY_PUB);
     $msg->setDstSslPubKey(static::DST1_SSL_KEY_PUB);
     $msg->setSslKeyPrv(static::DST1_SSL_KEY_PRV, static::SSL_KEY_PRV_PASS);
     $msg->setDstNodeId('cafed00d-2431-4159-8e11-0b4dbadb1738');
     $msg->setTimeCreated($timeCreated);
     $msg->setPassword($password);
     $msg->setChecksum($checksum);
     $textDecrypted = $msg->decrypt();
     $this->assertEquals($subject, $msg->getSubject());
     $this->assertEquals($text, $textDecrypted);
     $this->assertEquals($text, $msg->getText());
     $this->assertEquals($srcUserNickname, $msg->getSrcUserNickname());
     $this->assertEquals($ignore, $msg->getIgnore());
 }
Exemple #3
0
 public function imapMailAdd(Msg $msg)
 {
     if ($this->getKernel() && $this->getKernel()->getIpcImapConnection()) {
         $version = $msg->getVersion();
         $id = $msg->getId();
         $srcNodeId = $msg->getSrcNodeId();
         $srcUserNickname = $msg->getSrcUserNickname();
         $dstNodeId = $msg->getDstNodeId();
         $subject = $msg->getSubject();
         $text = $msg->getText();
         $checksum = $msg->getChecksum();
         $relayCount = $msg->getRelayCount();
         $encryptionMode = $msg->getEncryptionMode();
         $status = $msg->getStatus();
         $timeCreated = $msg->getTimeCreated();
         $timeReceived = $msg->getTimeReceived();
         $args = array();
         $args[] = $version;
         $args[] = $id;
         $args[] = $srcNodeId;
         $args[] = $srcUserNickname;
         $args[] = $dstNodeId;
         $args[] = $subject;
         $args[] = $text;
         $args[] = $checksum;
         $args[] = $relayCount;
         $args[] = $encryptionMode;
         $args[] = $status;
         $args[] = $timeCreated;
         $args[] = $timeReceived;
         $this->getKernel()->getIpcImapConnection()->execAsync('mailAdd', $args);
     }
 }