Changeset 25 in subversion


Ignore:
Timestamp:
Oct 11, 2005 5:11:42 PM (8 years ago)
Author:
roundcube
Message:

Better support for Courier IMAP

Location:
trunk/roundcubemail/program
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r21 r25  
    387387function console($msg, $type=1) 
    388388  { 
    389   print $msg; 
    390   print "\n<hr>\n"; 
     389  if ($GLOBALS['REMOTE_REQUEST']) 
     390    print "// $msg\n"; 
     391  else 
     392    { 
     393    print $msg; 
     394    print "\n<hr>\n"; 
     395    } 
    391396  } 
    392397 
  • trunk/roundcubemail/program/include/rcube_imap.inc

    r21 r25  
    2929  { 
    3030  var $conn; 
     31  var $root_ns = ''; 
    3132  var $root_dir = ''; 
    3233  var $mailbox = 'INBOX'; 
     
    5556 
    5657 
    57   function iloha_imap($connection='') 
    58     { 
    59     if ($connection) 
    60       { 
    61       $a_url = parse_url($connection); 
    62       $scheme = $a_url['scheme'] ? $a_url['scheme'] : 'imap'; 
    63       $port = $a_url['port'] ? $a_url['port'] : ($scheme=='imaps' ? 993 : 143); 
    64       $host = $a_url['host']; 
    65       $user = $a_url['user']; 
    66       $pass = $a_url['pass']; 
    67        
    68       //var_dump($a_url); 
    69        
    70       $this->connect($host, $user, $pass, $port); 
    71       } 
    72     } 
    73  
    74  
    7558  function connect($host, $user, $pass, $port=143, $use_ssl=FALSE) 
    7659    { 
     
    8063    if ($use_ssl && in_array('openssl', get_loaded_extensions())) 
    8164      $ICL_SSL = TRUE; 
     65    else if ($use_ssl) 
     66      { 
     67      raise_error(array('code' => 403, 
     68                        'type' => 'imap', 
     69                        'message' => 'Open SSL not available;'), TRUE, FALSE); 
     70      $port = 143; 
     71      } 
    8272 
    8373    $ICL_PORT = $port; 
     
    8676    $this->user = $user; 
    8777    $this->pass = $pass; 
    88      
     78    $this->port = $port; 
     79    $this->ssl = $use_ssl; 
     80     
     81    // print trace mesages 
    8982    if ($this->conn && ($CONFIG['debug_level'] & 8)) 
    90       print $this->conn->message; 
    91        
     83      console($this->conn->message); 
     84     
     85    // write error log 
    9286    else if (!$this->conn && $GLOBALS['iil_error']) 
    9387      { 
     
    9589                       'type' => 'imap', 
    9690                       'message' => $GLOBALS['iil_error']), TRUE, FALSE); 
     91      } 
     92 
     93    // get account namespace 
     94    if ($this->conn) 
     95      { 
     96      iil_C_NameSpace($this->conn); 
     97       
     98      if (!empty($this->conn->delimiter)) 
     99        $this->delimiter = $this->conn->delimiter; 
     100      if (!empty($this->conn->rootdir)) 
     101        $this->root_ns = $this->conn->rootdir; 
    97102      } 
    98103 
     
    108113 
    109114 
     115  function reconnect() 
     116    { 
     117    $this->close(); 
     118    $this->connect($this->host, $this->user, $this->pass, $this->port, $this->ssl); 
     119    } 
     120 
     121 
    110122  function set_rootdir($root) 
    111123    { 
    112     if (substr($root, -1, 1)==='/') 
     124    if (ereg('[\.\/]$', $root)) //(substr($root, -1, 1)==='/') 
    113125      $root = substr($root, 0, -1); 
    114126 
    115127    $this->root_dir = $root; 
     128     
     129    if (empty($this->delimiter)) 
     130      $this->get_hierarchy_delimiter(); 
    116131    } 
    117132 
     
    369384    if ($a_msg_headers[$uid]) 
    370385      return $a_msg_headers[$uid]; 
    371      
     386 
    372387    $msg_id = $this->_uid2id($uid); 
    373388    $header = iil_C_FetchHeader($this->conn, $mailbox, $msg_id); 
    374      
     389 
    375390    // write headers cache 
    376391    $a_msg_headers[$uid] = $header; 
     
    428443      $result = iil_C_Flag($this->conn, $this->mailbox, join(',', $msg_ids), $flag); 
    429444 
    430  
    431445    // reload message headers if cached 
    432446    $cache_key = $this->mailbox.'.msg'; 
    433     if ($result && ($a_cached_headers = $this->get_cache($cache_key))) 
    434       { 
     447    if ($this->caching_enabled && $result && ($a_cached_headers = $this->get_cache($cache_key))) 
     448      { 
     449      // close and re-open connection       
     450      $this->reconnect(); 
     451 
    435452      foreach ($uids as $uid) 
    436453        { 
     
    493510    if (!is_array($a_uids)) 
    494511      return false; 
    495        
     512 
    496513    // convert uids to message ids 
    497514    $a_mids = array(); 
    498515    foreach ($a_uids as $uid) 
    499516      $a_mids[] = $this->_uid2id($uid, $from_mbox); 
    500          
     517 
    501518    $moved = iil_C_Move($this->conn, join(',', $a_mids), $from_mbox, $to_mbox); 
    502519     
     
    647664    $abs_name = $this->_mod_mailbox($name); 
    648665    $a_mailbox_cache = $this->get_cache('mailboxes'); 
     666     
     667    if (strlen($this->root_ns)) 
     668      $abs_name = $this->root_ns.$abs_name; 
    649669 
    650670    if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) 
    651       $result = iil_C_CreateFolder($this->conn, $abs_name); 
     671      $result = iil_C_CreateFolder($this->conn, iil_utf7_encode($abs_name)); 
    652672 
    653673    // update mailboxlist cache 
    654674    if ($result && $subscribe) 
    655       $this->subscribe($name); 
    656  
    657     return $result; 
     675      $this->subscribe($this->root_ns.$name); 
     676 
     677    return $result ? $this->root_ns.$name : FALSE; 
    658678    } 
    659679 
     
    912932  function _mod_mailbox($mbox, $mode='in') 
    913933    { 
    914     if ($this->root_dir && $mode=='in') 
    915       $mbox = $this->root_dir.'/'.$mbox; 
    916     else if ($this->root_dir && $mode=='out') 
     934    if (!empty($this->root_dir) && $mode=='in') 
     935      $mbox = $this->root_dir.$this->delimiter.$mbox; 
     936    else if (strlen($this->root_dir) && $mode=='out') 
    917937      $mbox = substr($mbox, strlen($this->root_dir)+1); 
    918938 
  • trunk/roundcubemail/program/include/rcube_smtp.inc

    r11 r25  
    1 <? 
     1<?php 
    22 
    33/* 
  • trunk/roundcubemail/program/lib/imap.inc

    r21 r25  
    326326         
    327327        //open socket connection 
    328         $conn->fp = @fsockopen($host, $ICL_PORT); 
     328        $conn->fp = @fsockopen($host, $ICL_PORT, &$errno, &$errstr, 10); 
    329329        if (!$conn->fp){ 
    330         $iil_error = "Could not connect to $host at port $ICL_PORT"; 
     330        $iil_error = "Could not connect to $host at port $ICL_PORT: $errstr"; 
    331331        $iil_errornum = -1; 
    332332                return false; 
     
    14411441                        if ($line[0]=="*") $c++; 
    14421442                }while (!iil_StartsWith($line, "flg")); 
    1443                  
     1443 
    14441444                if (iil_ParseResult($line) == 0){ 
    14451445                        iil_C_ExpireCachedItems($conn, $mailbox, $messages); 
  • trunk/roundcubemail/program/steps/mail/compose.inc

    r20 r25  
    404404  // create a reply-subject 
    405405  else if (isset($REPLY_MESSAGE['subject'])) 
    406     $subject = 'Re: '.$REPLY_MESSAGE['subject']; 
     406    { 
     407    if (strpos($REPLY_MESSAGE['subject'], 'Re:')===0) 
     408      $subject = $REPLY_MESSAGE['subject']; 
     409    else 
     410      $subject = 'Re: '.$REPLY_MESSAGE['subject']; 
     411    } 
    407412 
    408413  // create a forward-subject 
  • trunk/roundcubemail/program/steps/mail/sendmail.inc

    r11 r25  
    217217  // check if mailbox exists 
    218218  if (!in_array_nocase($CONFIG['sent_mbox'], $IMAP->list_mailboxes())) 
    219     $IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE); 
     219    $mbox = $IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE); 
     220  else 
     221    $mbox = TRUE; 
    220222 
    221223  // append message to sent box 
    222   $saved = $IMAP->save_message($CONFIG['sent_mbox'], $header_str."\r\n".$msg_body); 
     224  if ($mbox) 
     225    $saved = $IMAP->save_message($CONFIG['sent_mbox'], $header_str."\r\n".$msg_body); 
     226 
     227  // raise error if saving failed 
     228  if (!$saved) 
     229    raise_error(array('code' => 800, 
     230                      'type' => 'imap', 
     231                      'file' => __FILE__, 
     232                      'message' => "Could not save message in $CONFIG[sent_mbox]"), TRUE, FALSE); 
    223233  } 
    224234 
  • trunk/roundcubemail/program/steps/settings/manage_folders.inc

    r8 r25  
    5252  if ($create && $_GET['_remote']) 
    5353    { 
    54     $commands = sprintf("this.add_folder_row('%s')", rep_specialchars_output($_GET['_name'], 'js')); 
     54    $commands = sprintf("this.add_folder_row('%s')", rep_specialchars_output($create, 'js')); 
    5555    rcube_remote_response($commands); 
    5656    } 
Note: See TracChangeset for help on using the changeset viewer.