From 70318e5463986edff014e881e7e121483679726b Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 01 Apr 2010 09:42:39 -0400
Subject: [PATCH] - create rcube_mime_struct class on Iloha's MIME (mime.inc) basis

---
 program/include/rcube_imap.php |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 7dc70df..22f4979 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -21,10 +21,6 @@
 */
 
 
-require_once('lib/mime.inc');
-require_once('lib/tnef_decoder.inc');
-
-
 /**
  * Interface class for accessing an IMAP server
  *
@@ -1614,9 +1610,10 @@
             return $headers->structure;
         }
 
-        if (!$structure_str)
+        if (!$structure_str) {
             $structure_str = $this->conn->fetchStructureString($this->mailbox, $uid, true);
-        $structure = iml_GetRawStructureArray($structure_str);
+        }
+        $structure = rcube_mime_struct::parseStructure($structure_str);
         $struct = false;
 
         // parse structure and add headers
@@ -1966,16 +1963,16 @@
         // get part encoding if not provided
         if (!is_object($o_part)) {
             $structure_str = $this->conn->fetchStructureString($this->mailbox, $uid, true); 
-            $structure = iml_GetRawStructureArray($structure_str);
+            $structure = new rcube_mime_struct();
             // error or message not found
-            if (empty($structure))
+            if (!$structure->loadStructure($structure_str)) {
                 return false;
+            }
 
-            $part_type = iml_GetPartTypeCode($structure, $part);
             $o_part = new rcube_message_part;
-            $o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other');
-            $o_part->encoding = strtolower(iml_GetPartEncodingString($structure, $part));
-            $o_part->charset = iml_GetPartCharset($structure, $part);
+            $o_part->ctype_primary = strtolower($structure->getPartType($part));
+            $o_part->encoding      = strtolower($structure->getPartEncoding($part));
+            $o_part->charset       = $structure->getPartCharset($part);
         }
       
         // TODO: Add caching for message parts
@@ -3331,6 +3328,8 @@
         if (!isset($part->body))
             $part->body = $this->get_message_part($uid, $part->mime_id, $part);
 
+        require_once('lib/tnef_decoder.inc');
+
         $pid = 0;
         $tnef_parts = array();
         $tnef_arr = tnef_decode($part->body);

--
Gitblit v1.9.1