More cleanups/fixes for new stream code.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Jul 2009 05:54:40 +0000 (23:54 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Jul 2009 05:54:40 +0000 (23:54 -0600)
imp/compose.php
imp/lib/Compose.php
imp/lib/Message.php
imp/lib/Spam.php
imp/view.php

index 238652b..c96de27 100644 (file)
@@ -552,8 +552,8 @@ case 'selectlist_process':
                 $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
                 if ($data && !is_a($data, 'PEAR_Error')) {
                     $part = new Horde_Mime_Part();
-                    $part->setContents($data);
                     $part->setName(reset($val));
+                    $part->setContents($data);
                     try {
                         $imp_compose->addMIMEPartAttachment($part);
                     } catch (IMP_Compose_Exception $e) {
index 425a595..d0fb5bf 100644 (file)
@@ -585,7 +585,7 @@ class IMP_Compose
                     $replace_part = new Horde_Mime_Part();
                     $replace_part->setType('text/plain');
                     $replace_part->setCharset($charset);
-                    $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit');
+                    $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]');
                     $mime_message->alterPart($i, $replace_part);
                 }
             }
@@ -2058,7 +2058,7 @@ class IMP_Compose
                  * fails (?) */
                 $part = new Horde_Mime_Part();
                 $part->setType($response->getHeader('content-type'));
-                $part->setContents($response->getBody(), '8bit');
+                $part->setContents($response->getBody());
                 $part->setDisposition('attachment');
                 $img_data[$url] = '"cid:' . $part->setContentID() . '"';
                 $img_parts[] = $part;
@@ -2157,14 +2157,14 @@ class IMP_Compose
             $link_part->setType('text/plain');
             $link_part->setCharset($charset);
             $link_part->setDisposition('inline');
-            $link_part->setContents($trailer, '8bit');
+            $link_part->setContents($trailer);
             $link_part->setDescription(_("Attachment Information"));
 
             $mixed_part->addPart($link_part);
             return $mixed_part;
         }
 
-        $part->appendContents("\n-----\n" . $trailer, '8bit');
+        $part->appendContents("\n-----\n" . $trailer);
 
         return $part;
     }
index e816d0b..4885810 100644 (file)
@@ -516,7 +516,7 @@ class IMP_Message
 
             /* We need to make sure all text is in the correct charset. */
             $newPart->setCharset(NLS::getCharset());
-            $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $oldPart->getType(), $oldPart->getName(true)), '8bit');
+            $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $oldPart->getType(), $oldPart->getName(true)));
             $message->alterPart($partid, $newPart);
         }
 
index c9e6283..1c5262b 100644 (file)
@@ -99,7 +99,7 @@ class IMP_Spam
 
                 if ($to) {
                     if (!isset($raw_msg)) {
-                        $raw_msg = $imp_contents->fullMessageText();
+                        $raw_msg = $imp_contents->fullMessageText(true);
                     }
 
                     if (!isset($imp_compose)) {
index a7950ff..9f2db61 100644 (file)
@@ -39,8 +39,8 @@ function _sanitizeName($name)
 
 function _fullMessageTextLength($ob)
 {
-    fseek($ob[1], 0, SEEK_END);
-    $len = strlen($ob[0]) + ftell($ob[1]);
+    $stat = fstat($ob[1]);
+    $len = strlen($ob[0]) + $stat['size']);
     rewind($ob[1]);
     return $len;
 }
@@ -153,6 +153,7 @@ case 'download_render':
 
     $browser->downloadHeaders($name, $type, false, strlen($body));
     if (is_resource($body)) {
+        rewind($body);
         fpassthru($body);
     } else {
         echo $body;
@@ -173,6 +174,7 @@ case 'view_source':
     $msg = $contents->fullMessageText(array('stream' => true));
     $browser->downloadHeaders('Message Source', 'text/plain', true, _fullMessageTextLength($msg));
     echo $msg[0];
+    rewind($msg[1]);
     fpassthru($msg[1]);
     exit;
 
@@ -195,6 +197,7 @@ case 'save_message':
     $msg = $contents->fullMessageText(array('stream' => true));
     $browser->downloadHeaders($name . '.eml', 'message/rfc822', false, strlen($hdr) + _fullMessageTextLength($msg));
     echo $hdr . $msg[0];
+    rewind($msg[1]);
     fpassthru($msg[1]);
     exit;
 }