From 7902df457d3401c83f78a6ddd48df1a7f07f68b1 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 20 Oct 2005 18:20:26 -0400
Subject: [PATCH] Fixed SSL support; improved Courier compatibility; some visual enhancements and bugfixes

---
 skins/default/common.css                     |   85 ++++--
 program/localization/se/messages.inc         |   56 ++++
 config/db.inc.php.dist                       |    2 
 program/include/main.inc                     |   49 ++-
 program/steps/mail/compose.inc               |    2 
 skins/default/mail.css                       |   28 +-
 config/main.inc.php.dist                     |    8 
 skins/default/images/buttons/logout.gif      |    0 
 program/steps/mail/move_del.inc              |    6 
 program/localization/se/labels.inc           |  173 ++++++++++++++
 index.php                                    |   14 
 skins/default/includes/taskbar.html          |    8 
 skins/default/settings.css                   |    4 
 program/steps/mail/func.inc                  |   18 
 skins/default/images/buttons/settings.gif    |    0 
 skins/default/templates/login.html           |    6 
 skins/default/images/taskbar.gif             |    0 
 skins/default/includes/header.html           |    9 
 skins/default/images/buttons/addressbook.gif |    0 
 program/js/app.js                            |    2 
 skins/default/images/buttons/mail.gif        |    0 
 program/include/rcube_imap.inc               |  185 +++++++++++++-
 skins/default/addresses.css                  |   12 
 23 files changed, 544 insertions(+), 123 deletions(-)

diff --git a/config/db.inc.php.dist b/config/db.inc.php.dist
index 9875309..fdb7d7e 100644
--- a/config/db.inc.php.dist
+++ b/config/db.inc.php.dist
@@ -16,7 +16,7 @@
 
 // PEAR database DSN for read/write operations
 // format is db_provider://user:password@host/databse
-// currentyl suported db_providers: mysql, sqlite, pgsql
+// currentyl suported db_providers: mysql, sqlite
 
 $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';
 // sqlite example: 'sqlite://./sqlite.db?mode=0646';
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 351e4b8..c8d1ad0 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -22,7 +22,8 @@
 // this is recommended if the IMAP server does not run on the same machine
 $rcmail_config['enable_caching'] = TRUE;
 
-// automatically create a new user when log-in the first time
+// automatically create a new RoundCube user when log-in the first time.
+// a new user will be created once the IMAP login succeeded.
 // set to false if only registered users can use this service
 $rcmail_config['auto_create_user'] = TRUE;
 
@@ -67,6 +68,9 @@
 // use this folder to store temp files (must be writebale for apache user)
 $rcmail_config['temp_dir'] = 'temp/';
 
+// session lifetime in minutes
+$rcmail_config['session_lifetime'] = 10;
+
 // check client IP in session athorization
 $rcmail_config['ip_check'] = TRUE;
 
@@ -80,7 +84,7 @@
 $rcmail_config['date_long'] = 'd.m.Y H:i';
 
 // add this user-agent to message headers when sending
-$rcmail_config['useragent'] = 'RoundCube Webmail/0.1-20051011';
+$rcmail_config['useragent'] = 'RoundCube Webmail/0.1-20051021';
 
 // only list folders within this path
 $rcmail_config['imap_root'] = '';
diff --git a/index.php b/index.php
index 2354523..a32fcea 100644
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
 /*
  +-----------------------------------------------------------------------+
  | RoundCube Webmail IMAP Client                                         |
- | Version 0.1-20051007                                                  |
+ | Version 0.1-20051018                                                  |
  |                                                                       |
  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
  | Licensed under the GNU GPL                                            |
@@ -68,6 +68,11 @@
 require_once('include/bugs.inc');
 require_once('include/main.inc');
 require_once('include/cache.inc');
+require_once('PEAR.php');
+
+
+// set PEAR error handling
+// PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_NOTICE);
 
 
 // catch some url/post parameters
@@ -138,7 +143,8 @@
 // check session cookie and auth string
 else if ($_action!='login' && $_auth && $sess_auth)
   {
-  if ($_auth !== $sess_auth || $_auth != rcmail_auth_hash($_SESSION['client_id'], $_SESSION['auth_time']))
+  if ($_auth !== $sess_auth || $_auth != rcmail_auth_hash($_SESSION['client_id'], $_SESSION['auth_time']) ||
+      ($CONFIG['session_lifetime'] && $SESS_CHANGED + $CONFIG['session_lifetime']*60 < mktime()))
     {
     $message = show_message('sessionerror', 'error');
     rcmail_kill_session();
@@ -149,12 +155,14 @@
 // log in to imap server
 if (!empty($_SESSION['user_id']) && $_task=='mail')
   {
-  $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']));
+  $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']);
   if (!$conn)
     {
     show_message('imaperror', 'error');
     $_SESSION['user_id'] = '';
     }
+  else
+    rcmail_set_imap_prop();
   }
 
 
diff --git a/program/include/main.inc b/program/include/main.inc
index b4b2aa9..4a872a5 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -51,6 +51,10 @@
     ini_set('display_errors', 1);
   else
     ini_set('display_errors', 0);
+  
+  // set session garbage collecting time according to session_lifetime
+  if (!empty($CONFIG['session_lifetime']))
+    ini_set('session.gc_maxlifetime', ($CONFIG['session_lifetime']+2)*60);
 
 
   // prepare DB connection
@@ -138,34 +142,43 @@
 
   $IMAP = new rcube_imap();
 
+  // connect with stored session data
+  if ($connect)
+    {
+    if (!($conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'])))
+      show_message('imaperror', 'error');
+      
+    rcmail_set_imap_prop();
+    }
+
   // enable caching of imap data
   if ($CONFIG['enable_caching']===TRUE)
     $IMAP->set_caching(TRUE);
 
-  // set root dir from config
-  if (strlen($CONFIG['imap_root']))
-    $IMAP->set_rootdir($CONFIG['imap_root']);
-    
   if (is_array($CONFIG['default_imap_folders']))
     $IMAP->set_default_mailboxes($CONFIG['default_imap_folders']);
-
-  if (strlen($_SESSION['mbox']))
-    $IMAP->set_mailbox($_SESSION['mbox']);
-
-  if (isset($_SESSION['page']))
-    $IMAP->set_page($_SESSION['page']);
 
   // set pagesize from config
   if (isset($CONFIG['pagesize']))
     $IMAP->set_pagesize($CONFIG['pagesize']);
+  }
 
 
-  // connect with stored session data
-  if ($connect)
-    {
-    if (!($conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']))))
-      show_message('imaperror', 'error');
-    }
+// set root dir and last stored mailbox
+// this must be done AFTER connecting to the server
+function rcmail_set_imap_prop()
+  {
+  global $CONFIG, $IMAP;
+
+  // set root dir from config
+  if (strlen($CONFIG['imap_root']))
+    $IMAP->set_rootdir($CONFIG['imap_root']);
+
+  if (strlen($_SESSION['mbox']))
+    $IMAP->set_mailbox($_SESSION['mbox']);
+    
+  if (isset($_SESSION['page']))
+    $IMAP->set_page($_SESSION['page']);
   }
 
 
@@ -262,7 +275,7 @@
     {
     $host = $a_host['host'];
     $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
-    $imap_port = isset($a_host['post']) ? $a_host['post'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
+    $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
     }
 
   // exit if IMAP login failed
@@ -301,6 +314,8 @@
     {
     $_SESSION['user_id']   = $user_id;
     $_SESSION['imap_host'] = $host;
+    $_SESSION['imap_port'] = $imap_port;
+    $_SESSION['imap_ssl']  = $imap_ssl;
     $_SESSION['username']  = $user;
     $_SESSION['password']  = encrypt_passwd($pass);
 
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index a6e8d78..83ee321 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -57,7 +57,7 @@
 
   function connect($host, $user, $pass, $port=143, $use_ssl=FALSE)
     {
-    global $ICL_PORT, $CONFIG;
+    global $ICL_SSL, $ICL_PORT, $CONFIG;
     
     // check for Open-SSL support in PHP build
     if ($use_ssl && in_array('openssl', get_loaded_extensions()))
@@ -66,6 +66,7 @@
       {
       raise_error(array('code' => 403,
                         'type' => 'imap',
+                        'file' => __FILE__,
                         'message' => 'Open SSL not available;'), TRUE, FALSE);
       $port = 143;
       }
@@ -98,7 +99,10 @@
       if (!empty($this->conn->delimiter))
         $this->delimiter = $this->conn->delimiter;
       if (!empty($this->conn->rootdir))
-        $this->root_ns = $this->conn->rootdir;
+        {
+        $this->set_rootdir($this->conn->rootdir);
+        $this->root_ns = ereg_replace('[\.\/]$', '', $this->conn->rootdir);
+        }
       }
 
     return $this->conn ? TRUE : FALSE;
@@ -185,6 +189,9 @@
     if ($this->conn && empty($this->delimiter))
       $this->delimiter = iil_C_GetHierarchyDelimiter($this->conn);
 
+    if (empty($this->delimiter))
+      $this->delimiter = '/';
+
     return $this->delimiter;
     }
 
@@ -268,8 +275,6 @@
     else
       $count = iil_C_CountMessages($this->conn, $mailbox);
 
-// print "/**** get messagecount for $mailbox ($mode): $count ****/\n";
-
     if (is_array($a_mailbox_cache[$mailbox]))
       $a_mailbox_cache[$mailbox] = array();
       
@@ -277,8 +282,6 @@
     
     // write back to cache
     $this->update_cache('messagecount', $a_mailbox_cache);
-
-//var_dump($a_mailbox_cache);
 
     return (int)$count;
     }
@@ -294,30 +297,163 @@
 
 
   // private method for listing message header
+  // by DrSlump <drslump@drslump.biz>
+  function __list_headers($mailbox='', $page=NULL, $sort_field='date', $sort_order='DESC')
+    {
+    $a_out = array();
+    $cached_count = 0;
+
+    if (!strlen($mailbox))
+      return $a_out;
+
+    $mbox_count = $this->_messagecount($mailbox /*, 'ALL', TRUE*/);
+
+    $revalidate = false;
+    if ($mbox_count)
+      {
+      // get cached headers
+      $a_out = $this->get_cache($mailbox.'.msg');
+      $a_out = is_array($a_out) ? $a_out : array(); // make sure we get an array
+
+      $cached_count = count($a_out);
+      $a_new = array();
+      $revalidate = true; // revalidate by default
+     
+      // if the cache count is greater then there have been changes for sure
+      if ($cached_count <= $mbox_count)
+        {
+        $from = $cached_count?$cached_count:1;
+       
+        //get new headers (at least one is returned)
+        $a_temp = iil_C_FetchHeaders($this->conn, $mailbox, $from . ':' . $mbox_count);
+        $duplicated = $cached_count?true:false;
+       
+        foreach ($a_temp as $hdr)
+          {
+          //skip the first one if duplicated
+          if ($duplicated)
+            {
+            //check for changes using the UID
+            $lastCacheHdr = end($a_out);
+            if ($hdr->uid === $lastCacheHdr->uid)
+              $revalidate = false;
+
+            $duplicated = false;
+            continue;
+            }
+           
+          //skip deleted ones
+          if (! $hdr->deleted)
+            $a_new[ $hdr->uid ] = $hdr;
+          }
+        }
+
+      //revalidate cache if needed
+      $to = $mbox_count - count($a_new);
+      if ($revalidate && $to !== 0)    //we'll need to reindex the array so we have to make a copy
+        {
+        $a_dirty = $a_out;
+        $a_out = array();
+        $a_buffers = array();
+
+        //fetch chunks of 20 headers
+        $step = 20;
+        $found = false;
+         
+        //fetch headers in blocks starting from new to old
+        do {
+          $from = $to-$step;
+          if ($from < 1) $from = 1;
+
+          //store the block in a temporal buffer
+          $a_buffers[$from] = iil_C_FetchHeaders($this->conn, $mailbox, $from . ':' . $to);
+
+          //compare the fetched headers with the ones in the cache
+          $idx = 0;
+          foreach ($a_buffers[$from] as $k=>$hdr)
+            {
+            //if it's different the comparison ends
+            if (!isset($a_dirty[$hdr->uid]) || $a_dirty[$hdr->uid]->id !== $hdr->id)
+              break;
+
+            //if we arrive here then we know that the older messages in cache are ok
+            $found = $hdr->id;
+            $idx++;
+            }
+
+          //remove from the buffer the headers which are already cached
+          if ($found)
+            $a_buffers[$from] = array_splice($a_buffers[$from], 0, $idx );
+             
+          $to = $from-1;
+          }
+        while ($found===false && $from > 1);
+
+        //just keep the headers we are certain that didn't change in the cache
+        if ($found !== false)
+          {
+          foreach ($a_dirty as $hdr)
+            {
+            if ($hdr->id > $found) break;
+            $a_out[$hdr->uid] = $hdr;
+            }
+          }
+           
+        //we builded the block buffers from new to older, we process them in reverse order
+        ksort($a_buffers, SORT_NUMERIC);
+        foreach ($a_buffers as $a_buff)
+          {
+          foreach ($a_buff as $hdr)
+            {
+            if (! $hdr->deleted)
+              $a_out[$hdr->uid] = $hdr;
+            }
+          }
+        }
+         
+      //array_merge() would reindex the keys, so we use this 'hack'
+      $a_out += $a_new;
+      }
+ 
+    //write headers list to cache if needed
+    if ($revalidate || count($a_out)!=$cached_count) {
+      $this->update_cache($mailbox.'.msg', $a_out);
+     }
+
+    //sort headers by a specific col
+    $a_out = iil_SortHeaders( $a_out, $sort_field, $sort_order );
+   
+    // return complete list of messages
+    if (strtolower($page)=='all')
+      return $a_out;
+
+    $start_msg = ($this->list_page-1) * $this->page_size;
+    return array_slice($a_out, $start_msg, $this->page_size);
+    }
+
+
+  // old function; replaced 2005/10/18
+  // private method for listing message header
   function _list_headers($mailbox='', $page=NULL, $sort_field='date', $sort_order='DESC')
     {
-    $max = $this->_messagecount($mailbox /*, 'ALL', TRUE*/);
-    
+    $max = $this->_messagecount($mailbox);
+
     if (!strlen($mailbox))
       return array();
 
     // get cached headers
     $a_msg_headers = $this->get_cache($mailbox.'.msg');
 
-// print "/**** count = $max; headers = ".sizeof($a_msg_headers)." ****/\n";
-
     // retrieve headers from IMAP
     if (!is_array($a_msg_headers) || sizeof($a_msg_headers) != $max)
       {
       $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, "1:$max");
       $a_msg_headers = array();
-      
+
       if (!empty($a_header_index))
-		foreach ($a_header_index as $i => $headers)
-			if (!$headers->deleted)
-				$a_msg_headers[$headers->uid] = $headers;
-        
-// print "/**** fetch headers ****/\n";
+        foreach ($a_header_index as $i => $headers)
+          if (!$headers->deleted)
+            $a_msg_headers[$headers->uid] = $headers;
       }
     else
       $headers_cached = TRUE;
@@ -345,7 +481,7 @@
     $start_msg = ($this->list_page-1) * $this->page_size;
     return array_slice($a_headers, $start_msg, $this->page_size);
     }
-
+  
 
   // return sorted array of message UIDs
   function message_index($mbox='', $sort_field='date', $sort_order='DESC')
@@ -668,17 +804,17 @@
     $abs_name = $this->_mod_mailbox($name);
     $a_mailbox_cache = $this->get_cache('mailboxes');
     
-    if (strlen($this->root_ns))
-      $abs_name = $this->root_ns.$abs_name;
+    //if (strlen($this->root_ns))
+    //  $abs_name = $this->root_ns.$abs_name;
 
     if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache)))
       $result = iil_C_CreateFolder($this->conn, iil_utf7_encode($abs_name));
 
     // update mailboxlist cache
     if ($result && $subscribe)
-      $this->subscribe($this->root_ns.$name);
+      $this->subscribe($name);
 
-    return $result ? $this->root_ns.$name : FALSE;
+    return $result ? $name : FALSE;
     }
 
 
@@ -935,9 +1071,12 @@
 
   function _mod_mailbox($mbox, $mode='in')
     {
-    if (!empty($this->root_dir) && $mode=='in')
+    if (!empty($this->root_ns) && $this->root_ns == $mbox)
+      return $mbox;
+
+    if (!empty($this->root_dir) &&  $mode=='in') 
       $mbox = $this->root_dir.$this->delimiter.$mbox;
-    else if (strlen($this->root_dir) && $mode=='out')
+    else if (strlen($this->root_dir) && $mode=='out') 
       $mbox = substr($mbox, strlen($this->root_dir)+1);
 
     return $mbox;
diff --git a/program/js/app.js b/program/js/app.js
index 18ce674..418f33c 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -204,7 +204,7 @@
 
     // flag object as complete
     this.loaded = true;
-      
+          
     // show message
     if (this.pending_message)
       this.display_message(this.pending_message[0], this.pending_message[1]);
diff --git a/program/localization/se/labels.inc b/program/localization/se/labels.inc
new file mode 100644
index 0000000..13930bb
--- /dev/null
+++ b/program/localization/se/labels.inc
@@ -0,0 +1,173 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | language/en/labels.inc                                                |
+ |                                                                       |
+ | Language file of the RoundCube Webmail client                         |
+ | Copyright (C) 2005, RoundQube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Fredrik Nygren <f.nygren@gmail.com>                           |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+$labels = array();
+
+// login page
+$labels['username']  = 'Anv�ndarnamn';
+$labels['password']  = 'L�senord';
+$labels['server']    = 'Server';
+$labels['login']     = 'Logga in';
+
+// taskbar
+$labels['logout']   = 'Logga ut';
+$labels['mail']     = 'E-post';
+$labels['settings'] = 'Personliga inst�llningar';
+$labels['addressbook'] = 'Adressbok';
+
+// mailbox names
+$labels['inbox']  = 'Inbox';
+$labels['sent']   = 'Skickat';
+$labels['trash']  = 'Papperskorg';
+$labels['drafts'] = 'Utskick';
+$labels['junk']   = 'Skr�ppost';
+
+// message listing
+$labels['subject'] = '�mne';
+$labels['from']    = 'Avs�ndare';
+$labels['to']      = 'Mottagare';
+$labels['cc']      = 'Kopia';
+$labels['bcc']     = 'Bcc';
+$labels['replyto'] = 'Svar-till';
+$labels['date']    = 'Datum';
+$labels['size']    = 'Storlek';
+$labels['priority'] = 'Prioritering';
+$labels['organization'] = 'Organisation';
+
+// aliases
+$labels['reply-to'] = $labels['replyto'];
+
+$labels['mailboxlist'] = 'Mappar';
+$labels['messagesfromto'] = 'Meddelande $from till $to av $count';
+$labels['messagenrof'] = 'Message $nr av $count';
+
+$labels['moveto']   = 'flytta till...';
+$labels['download'] = 'ladda ner';
+
+$labels['filename'] = 'Filnamn';
+$labels['filesize'] = 'Filstorlek';
+
+$labels['preferhtml'] = 'F�redra HTML';
+$labels['htmlmessage'] = 'HTML-meddelanden';
+$labels['prettydate'] = 'Fina datum';
+
+$labels['addtoaddressbook'] = 'L�gg till adressbok';
+
+// weekdays short
+$labels['sun'] = 'S�n';
+$labels['mon'] = 'M�n';
+$labels['tue'] = 'Tis';
+$labels['wed'] = 'Ons';
+$labels['thu'] = 'Tor';
+$labels['fri'] = 'Fre';
+$labels['sat'] = 'L�s';
+
+// weekdays long
+$labels['sunday']    = 'S�ndag';
+$labels['monday']    = 'M�ndag';
+$labels['tuesday']   = 'Tisdag';
+$labels['wednesday'] = 'Onsdag';
+$labels['thursday']  = 'Torsdag';
+$labels['friday']    = 'Fredag';
+$labels['saturday']  = 'L�dag';
+
+$labels['today'] = 'Idag';
+
+// toolbar buttons
+$labels['writenewmessage']  = 'Skapa nytt meddelande';
+$labels['replytomessage']   = 'Svar p� meddelande';
+$labels['forwardmessage']   = 'Skicka vidare meddelande';
+$labels['deletemessage']    = 'Flytta till papperskorgen';
+$labels['printmessage']     = 'Skriv ut';
+$labels['previousmessages'] = 'Visa tidigare';
+$labels['nextmessages']     = 'Visa n�sta';
+$labels['backtolist']       = 'Tillbaka till meddelandelistan';
+
+$labels['select'] = 'V�lj';
+$labels['all'] = 'Alla';
+$labels['none'] = 'Ingen';
+$labels['unread'] = 'Ol�st';
+
+// message compose
+$labels['compose']  = 'Skriv meddelande';
+$labels['sendmessage']  = 'Skicka meddelande nu';
+$labels['addattachment']  = 'Bifoga fil';
+
+$labels['attachments'] = 'Filer';
+$labels['upload'] = 'Ladda upp';
+$labels['close']  = 'St�ng';
+
+$labels['low']     = 'L�g';
+$labels['lowest']  = 'L�gst';
+$labels['normal']  = 'Normal';
+$labels['high']    = 'H�g';
+$labels['highest'] = 'H�gst';
+
+$labels['showimages'] = 'Visa bilder';
+
+
+// address boook
+$labels['name']      = 'Visa namn';
+$labels['firstname'] = 'F�rnamn';
+$labels['surname']   = 'Efternamn';
+$labels['email']     = 'E-post';
+
+$labels['addcontact'] = 'L�gg till ny kontakt';
+$labels['editcontact'] = '�ndra kontakt';
+
+$labels['edit']   = '�ndra';
+$labels['cancel'] = 'Avbryt';
+$labels['save']   = 'Spara';
+$labels['delete'] = 'Radera';
+
+$labels['newcontact']     = 'Skapa nytt kontaktkort';
+$labels['deletecontact']  = 'Radera valda kontakter';
+$labels['composeto']      = 'Skriv e-post till';
+$labels['contactsfromto'] = 'Kontakter $from till $to av $count';
+
+
+// settings
+$labels['settingsfor']  = 'Inst�llningar f�r';
+
+$labels['preferences']  = 'Inst�llningar';
+$labels['userpreferences']  = 'Anv�ndarinst�llningar';
+$labels['editpreferences']  = '�ndra anv�ndarinst�llningar';
+
+$labels['identities']  = 'Identiteter';
+$labels['manageidentities']  = 'Hantera identiteter f�r kontot';
+$labels['newidentity']  = 'Ny identitet';
+
+$labels['newitem']  = 'Ny post';
+$labels['edititem']  = '�ndra post';
+
+$labels['setdefault']  = 'S�tt som standard';
+$labels['language']  = 'Spr�k';
+$labels['timezone']  = 'Tidszon';
+$labels['pagesize']  = 'Rader per sida';
+
+
+$labels['folders']  = 'Mappar';
+$labels['foldername']  = 'Mappnamn';
+$labels['subscribed']  = 'Ansluten';
+$labels['create']  = 'Skapa';
+$labels['createfolder']  = 'Skapa ny mapp';
+$labels['deletefolder']  = 'Radera mapp';
+$labels['managefolders']  = 'Hantera mappar';
+
+
+?>
\ No newline at end of file
diff --git a/program/localization/se/messages.inc b/program/localization/se/messages.inc
new file mode 100644
index 0000000..7ec1e98
--- /dev/null
+++ b/program/localization/se/messages.inc
@@ -0,0 +1,56 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | language/en/messages.inc                                              |
+ |                                                                       |
+ | Language file of the RoundCube Webmail client                         |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Fredrik Nygren <f.nygren@gmail.com>                           |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+$messages = array();
+
+$messages['loginfailed']  = 'Inloggningen misslyckades';
+
+$messages['cookiesdisabled'] = 'Din webbl�sare accepterar inte cookies';
+
+$messages['sessionerror'] = 'Din session �r felaktig eller har g�tt ut';
+
+$messages['imaperror'] = 'Kommunikationen med IMAP-servern misslyckades';
+
+$messages['nomessagesfound'] = 'Inga meddelanden i den h�r mappen';
+
+$messages['loggedout'] = 'Du har avslutat sessionen. Hej d�!';
+
+$messages['mailboxempty'] = 'Mappen �r tom';
+
+$messages['loadingdata'] = 'Laddar data...';
+
+$messages['messagesent'] = 'Meddelande skickades';
+
+$messages['successfullysaved'] = 'Sparat';
+
+$messages['addedsuccessfully'] = 'Kontakt har lagts till i adressboken';
+
+$messages['contactexists'] = 'En kontakt med den angivna e-postadressen existerar redan';
+
+$messages['blockedimages'] = 'F�r att skydda dig har externa bilder blockerats fr�n meddelandet';
+
+$messages['encryptedmessage'] = 'Det h�r �r ett krypterat meddelande som inte kan visas. Tyv�rr!';
+
+$messages['nocontactsfound'] = 'Inga kontakter hittades';
+
+$messages['sendingfailed'] = 'Misslyckades med att skicka meddelandet';
+
+$messages['errorsaving'] = 'Problem med sparandet uppstod';
+
+
+?>
\ No newline at end of file
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 52b64d8..f7e094a 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -509,7 +509,7 @@
                        rcube_label('normal'),
                        rcube_label('high'),
                        rcube_label('highest')),
-                 array(1, 2, 0, 4, 5));
+                 array(5, 4, 0, 2, 1));
                  
   $sel = isset($_POST['_priority']) ? $_POST['_priority'] : 0;
 
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index c0b303a..98e0cdb 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -198,11 +198,15 @@
   $out = '';
   foreach ($arrFolders as $key=>$folder)
     {
-    // shorten the folder name to a given length
-    if ($maxlength && $maxlength>1)
-      $foldername = abbrevate_string($folder['name'], $maxlength);
+    $folder_lc = strtolower($folder['id']);
+    if (in_array($folder_lc, $special))
+      $foldername = rcube_label($folder_lc);
     else
       $foldername = $folder['name'];
+
+    // shorten the folder name to a given length
+    if ($maxlength && $maxlength>1)
+      $foldername = abbrevate_string($foldername, $maxlength);
 
     $out .= sprintf('<option value="%s">%s%s</option>'."\n",
                     $folder['id'],
@@ -303,13 +307,13 @@
       if ($col=='from' || $col=='to')
         $cont = rep_specialchars_output(rcmail_address_string($header->$col, 3, $attrib['addicon']));
       else if ($col=='subject')
-        $cont = rep_specialchars_output($IMAP->decode_header($header->$col));
+        $cont = rep_specialchars_output($IMAP->decode_header($header->$col), 'html', 'all');
       else if ($col=='size')
         $cont = show_bytes($header->$col);
       else if ($col=='date')
         $cont = format_date($header->date); //date('m.d.Y G:i:s', strtotime($header->date));
       else
-        $cont = rep_specialchars_output($header->$col);
+        $cont = rep_specialchars_output($header->$col, 'html', 'all');
         
 	  $out .= '<td class="'.$col.'">' . $cont . "</td>\n";
       }
@@ -377,13 +381,13 @@
       if ($col=='from' || $col=='to')
         $cont = rep_specialchars_output(rcmail_address_string($header->$col, 3));
       else if ($col=='subject')
-        $cont = rep_specialchars_output($IMAP->decode_header($header->$col));
+        $cont = rep_specialchars_output($IMAP->decode_header($header->$col), 'html', 'all');
       else if ($col=='size')
         $cont = show_bytes($header->$col);
       else if ($col=='date')
         $cont = format_date($header->date); //date('m.d.Y G:i:s', strtotime($header->date));
       else
-        $cont = rep_specialchars_output($header->$col);
+        $cont = rep_specialchars_output($header->$col, 'html', 'all');
           
       $a_msg_cols[$col] = $cont;
       }
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 20d46e3..41b11d5 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -65,11 +65,13 @@
 $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
 
-  
+
 // update mailboxlist
 $mbox = $IMAP->get_mailbox_name();
 $commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
-$commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN'));
+
+if ($_action=='moveto')
+  $commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN'));
 
 
 // add new rows from next page (if any)
diff --git a/skins/default/addresses.css b/skins/default/addresses.css
index d660c3c..a0fb15c 100644
--- a/skins/default/addresses.css
+++ b/skins/default/addresses.css
@@ -4,7 +4,7 @@
 #abooktoolbar
 {
   position: absolute;
-  top: 32px;
+  top: 45px;
   left: 200px;
   height: 35px;
 }
@@ -17,7 +17,7 @@
 #abookcountbar
 {
   position: absolute;
-  top: 50px;
+  top: 60px;
   left: 490px;
   width: 200px;
   height: 20px;
@@ -34,10 +34,10 @@
 #addresslist
 {
   position: absolute;
-  top: 75px;
+  top: 85px;
   left: 20px;
   width: 450px;
-  bottom: 60px;
+  bottom: 40px;
   border: 1px solid #999999;
   background-color: #F9F9F9;
   overflow: auto;
@@ -63,10 +63,10 @@
 #contacts-box
 {
   position: absolute;
-  top: 75px;
+  top: 85px;
   left: 490px;
   right: 40px;
-  bottom: 60px;
+  bottom: 40px;
   border: 1px solid #999999;
   overflow: hidden;
   /* css hack for IE */
diff --git a/skins/default/common.css b/skins/default/common.css
index 2ba97d8..67e404e 100755
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -3,7 +3,7 @@
 body
 {
   margin: 8px;
-  background-color: #F2F2F2; /* #EBEBEB; */
+  background-color: #F6F6F6; /* #EBEBEB; */
   color: #000000;
 }
 
@@ -103,43 +103,62 @@
 
 #header
 {
-/* margin: 10px auto; */
+  position: absolute;
+  top: 10px;
+  left: 20px;
   width: 170px;
   height: 40px;
-  margin-top: 0px;
-  margin-left: 10px;
-/* border: 1px solid #cccccc;  */
-}
-
-#footer
-{
-  position: fixed !important;
-  left: 0px;
-  right: 0px;
-  bottom: 0px !important;
-  height: 40px;
-  background-color: #f2f2f2;
-
-  /* css hack for IE */
-  position: absolute;
-  bottom: auto;
-  top: expression((parseInt(document.documentElement.clientHeight)+parseInt(document.documentElement.scrollTop)-42)+'px');
-  width: expression(parseInt(document.documentElement.clientWidth)+'px');
+  z-index: 100;
 }
 
 #taskbar
 {
-  margin: 0px auto;
-  width: 400px;
-  height: 34px;
-  padding: 3px;
-  text-align: center;
-  border: 1px solid #cccccc;  
+  position: absolute;
+  top: 0px;
+  right: 0px;
+  width: 600px;
+  height: 37px;
+  background: url(images/taskbar.gif) top right no-repeat;
+  padding: 10px 24px 0px 0px;
+  text-align: right;
+  white-space: nowrap;
+  z-index: 2;
 }
 
-#taskbar a
+#taskbar a,
+#taskbar a:active,
+#taskbar a:visited
 {
-  padding-right: 10px;
+  font-size: 11px;
+  color: #666666;
+  text-decoration: none;
+  padding: 6px 16px 6px 30px;
+  background-repeat: no-repeat;
+}
+
+#taskbar a:hover
+{
+  color: #333333;
+}
+
+a.button-mail
+{
+  background-image: url(images/buttons/mail.gif);
+}
+
+a.button-addressbook
+{
+  background-image: url(images/buttons/addressbook.gif);
+}
+
+a.button-settings
+{
+  background-image: url(images/buttons/settings.gif);
+}
+
+a.button-logout
+{
+  background-image: url(images/buttons/logout.gif);
 }
 
 
@@ -147,7 +166,7 @@
 {
   position: absolute;
   display: none;
-  top: 0px;
+  top: -1px;
   left: 200px;
   right: 200px;
   z-index: 5000;
@@ -157,8 +176,8 @@
 {
   width: 400px;
   margin: 0px auto;
-  height: 22px;
-  min-height: 22px;
+  height: 24px;
+  min-height: 24px;
   padding: 8px 10px 8px 46px;
 }
 
@@ -188,7 +207,7 @@
 #message div.loading
 {
   background: url(images/display/loading.gif) 6px 3px no-repeat;
-  background-color: #EFEFEF;
+  background-color: #EBEBEB;
   border: 1px solid #CCCCCC;
 }
 
diff --git a/skins/default/images/buttons/addressbook.gif b/skins/default/images/buttons/addressbook.gif
new file mode 100644
index 0000000..d8c0c17
--- /dev/null
+++ b/skins/default/images/buttons/addressbook.gif
Binary files differ
diff --git a/skins/default/images/buttons/logout.gif b/skins/default/images/buttons/logout.gif
index f8000fc..93eb1aa 100644
--- a/skins/default/images/buttons/logout.gif
+++ b/skins/default/images/buttons/logout.gif
Binary files differ
diff --git a/skins/default/images/buttons/mail.gif b/skins/default/images/buttons/mail.gif
new file mode 100644
index 0000000..8bb93f7
--- /dev/null
+++ b/skins/default/images/buttons/mail.gif
Binary files differ
diff --git a/skins/default/images/buttons/settings.gif b/skins/default/images/buttons/settings.gif
new file mode 100644
index 0000000..a390cd9
--- /dev/null
+++ b/skins/default/images/buttons/settings.gif
Binary files differ
diff --git a/skins/default/images/taskbar.gif b/skins/default/images/taskbar.gif
new file mode 100644
index 0000000..b6fc91c
--- /dev/null
+++ b/skins/default/images/taskbar.gif
Binary files differ
diff --git a/skins/default/includes/header.html b/skins/default/includes/header.html
index b795ad1..375140f 100644
--- a/skins/default/includes/header.html
+++ b/skins/default/includes/header.html
@@ -1,3 +1,10 @@
-<div id="header"><img src="/images/roundcube_logo.png" width="165" height="55" alt="RoundCube Webmail" /></div>
+<div id="taskbar">
+<roundcube:button command="mail" label="mail" class="button-mail" />
+<roundcube:button command="addressbook" label="addressbook" class="button-addressbook" />
+<roundcube:button command="settings" label="settings" class="button-settings" />
+<roundcube:button command="logout" label="logout" class="button-logout" />
+</div>
+
+<div id="header"><roundcube:button command="mail" image="/images/roundcube_logo.png" alt="RoundCube Webmail" width="165" height="55" /></div>
 
 <roundcube:object name="message" id="message" />
\ No newline at end of file
diff --git a/skins/default/includes/taskbar.html b/skins/default/includes/taskbar.html
index b0ebc55..be3d57d 100644
--- a/skins/default/includes/taskbar.html
+++ b/skins/default/includes/taskbar.html
@@ -1,11 +1,3 @@
-<div id="footer">
-<div id="taskbar">
-<roundcube:button command="mail" image="/images/buttons/mail.png" title="mail" width="32" height="32" />
-<roundcube:button command="addressbook" image="/images/buttons/addressbook.png" title="addressbook" width="32" height="32" />
-<roundcube:button command="settings" image="/images/buttons/settings.png" title="settings" width="32" height="32" />
-<roundcube:button command="logout" image="/images/buttons/logout.png" title="logout" width="32" height="32" />
-</div>
-</div>
 
 <!--
 <form name="debugform" style="position:absolute; right:10px; bottom:10px;">
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 5ebad53..3925c4e 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -4,7 +4,7 @@
 #messagetoolbar
 {
   position: absolute;
-  top: 20px;
+  top: 45px;
   left: 200px;
   right: 250px;
   height: 35px;
@@ -44,7 +44,7 @@
 {
   position: absolute;
   left: 200px;
-  bottom: 60px;
+  bottom: 20px;
   height: 16px;
   width: 400px;
 }
@@ -73,8 +73,8 @@
 #messagecountbar
 {
   position: absolute;
-  top: 35px;
-  right: 60px;
+  top: 60px;
+  right: 40px;
   width: 250px;
   height: 20px;
   text-align: right;
@@ -98,10 +98,10 @@
 #mailcontframe
 {
   position: absolute;
-  top: 60px;
+  top: 85px;
   left: 200px;
   right: 40px;
-  bottom: 80px;
+  bottom: 40px;
   border: 1px solid #999999;
   background-color: #F9F9F9;
   overflow: auto;
@@ -160,7 +160,7 @@
 #mailboxlist-header
 {
   position: absolute;
-  top: 80px;
+  top: 85px;
   left: 20px;
   width: 140px !important;
 /*  width: 162px; */
@@ -177,10 +177,10 @@
 #mailboxlist-container
 {
   position: absolute;
-  top: 100px;
+  top: 105px;
   left: 20px;
   width: 160px;
-  bottom: 80px;
+  bottom: 40px;
   border: 1px solid #CCCCCC;
   background-color: #F9F9F9;
   overflow: auto;
@@ -403,11 +403,11 @@
 #messageframe
 {
   position: absolute;
-  top: 70px;
+  top: 85px;
   left: 200px;
   right: 40px;
   /* css hack for IE */
-  margin-bottom: 50px;
+  margin-bottom: 10px;
   width: expression(document.body.clientWidth-240);
 }
 
@@ -476,7 +476,7 @@
 {
   min-height: 300px;
   margin-top: 10px;
-  margin-bottom: 50px;
+  margin-bottom: 10px;
   background-color: #FFFFFF;
   border: 1px solid #cccccc;
   border-top: none;
@@ -535,10 +535,10 @@
 #compose-container
 {
   position: absolute;
-  top: 70px;
+  top: 90px;
   left: 200px;
   right: 40px;
-  bottom: 60px;
+  bottom: 20px;
   padding: 0px;
   margin: 0px;
   /* css hack for IE */
diff --git a/skins/default/settings.css b/skins/default/settings.css
index b35f715..427a739 100644
--- a/skins/default/settings.css
+++ b/skins/default/settings.css
@@ -4,7 +4,7 @@
 #tabsbar
 {
   position: absolute;
-  top: 42px;
+  top: 45px;
   left: 220px;
   right: 60px;
   height: 22px;
@@ -120,7 +120,7 @@
 {
   width: 500px;
   margin-top: 20px;
-  margin-bottom: 50px;
+  margin-bottom: 20px;
   border: 1px solid #999999;
 }
 
diff --git a/skins/default/templates/login.html b/skins/default/templates/login.html
index 7f44f57..bf928c2 100644
--- a/skins/default/templates/login.html
+++ b/skins/default/templates/login.html
@@ -7,7 +7,7 @@
 
 #login-form
   {
-	margin: 50px auto;
+	margin: 150px auto;
 	width: 350px;
   }
 
@@ -15,7 +15,9 @@
 </head>
 <body>
 
-<roundcube:include file="/includes/header.html" />
+<div id="header"><img src="skins/default/images/roundcube_logo.png" id="rcmbtn104" width="165" height="55" border="0" alt="RoundCube Webmail" /></div>
+
+<roundcube:object name="message" id="message" />
 
 <div id="login-form">
 <form name="form" action="./" method="post">

--
Gitblit v1.9.1