From fcc7f861b170596c6970aecb1ddc87a3567b112f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sat, 30 Jul 2011 11:32:13 -0400
Subject: [PATCH] Log session validation errors; keep error message when redirecting to login after session error

---
 program/js/app.js |   49 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index b424f00..a9ed9ad 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -252,7 +252,10 @@
         }
         // show printing dialog
         else if (this.env.action == 'print' && this.env.uid)
-          window.print();
+          if (bw.safari)
+            window.setTimeout('window.print()', 10);
+          else
+            window.print();
 
         // get unread count for each mailbox
         if (this.gui_objects.mailboxlist) {
@@ -429,6 +432,11 @@
     this.start_keepalive();
   };
 
+  this.log = function(msg)
+  {
+    if (window.console && console.log)
+      console.log(msg);
+  };
 
   /*********************************************************/
   /*********       client command interface        *********/
@@ -1872,9 +1880,7 @@
     if (action == 'preview' && String(target.location.href).indexOf(url) >= 0)
       this.show_contentframe(true);
     else {
-      if (!this.env.frame_lock) {
-        (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading');
-      }
+      this.lock_frame();
       this.location_href(this.env.comm_path+url, target);
 
       // mark as read and change mbox unread counter
@@ -1907,6 +1913,12 @@
 
     if (!show && this.busy)
       this.set_busy(false, null, this.env.frame_lock);
+  };
+
+  this.lock_frame = function()
+  {
+    if (!this.env.frame_lock)
+      (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading');
   };
 
   // list a specific page
@@ -3730,7 +3742,9 @@
 
     if (this.ksearch_pane)
       this.ksearch_pane.hide();
-   };
+
+    this.ksearch_destroy();
+  };
 
   // Aborts pending autocomplete requests
   this.ksearch_destroy = function()
@@ -3896,8 +3910,10 @@
       if (this.env.group)
         add_url += '&_gid='+urlencode(this.env.group);
 
-      this.set_busy(true);
-      this.location_href(this.env.comm_path+'&_action='+action+'&_source='+urlencode(this.env.source)+'&_cid='+urlencode(cid) + add_url, target);
+      this.lock_frame();
+      this.location_href(this.env.comm_path+'&_action='+action
+        +'&_source='+urlencode(this.env.source)
+        +'&_cid='+urlencode(cid) + add_url, target);
     }
     return true;
   };
@@ -4417,6 +4433,7 @@
       this.contact_list.clear_selection();
     }
 
+    this.lock_frame();
     this.location_href(this.env.comm_path+'&_action=search'+add_url, target);
 
     return true;
@@ -4450,6 +4467,7 @@
         add_url = '&_framed=1';
         target = window.frames[this.env.contentframe];
       }
+      this.lock_frame();
       this.location_href(this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url, target);
     }
 
@@ -4851,9 +4869,7 @@
       this.show_contentframe(true);
     }
     else {
-      if (!this.env.frame_lock) {
-        (parent.rcmail ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading');
-      }
+      this.lock_frame();
       this.location_href(this.env.comm_path+url, target);
     }
   };
@@ -5137,7 +5153,8 @@
       obj.click(function() { return ref.hide_message(obj); });
     }
 
-    window.setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout);
+    if (timeout > 0)
+      window.setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout);
     return id;
   };
 
@@ -5495,11 +5512,11 @@
       url = '?_task=utils&_action=html2text',
       lock = this.set_busy(true, 'converting');
 
-    console.log('HTTP POST: ' + url);
+    this.log('HTTP POST: ' + url);
 
     $.ajax({ type: 'POST', url: url, data: htmlText, contentType: 'application/octet-stream',
       error: function(o, status, err) { rcmail.http_error(o, status, err, lock); },
-      success: function(data) { rcmail.set_busy(false, null, lock); $(document.getElementById(id)).val(data); console.log(data); }
+      success: function(data) { rcmail.set_busy(false, null, lock); $(document.getElementById(id)).val(data); rcmail.log(data); }
     });
   };
 
@@ -5592,7 +5609,7 @@
     url += '&_remote=1';
 
     // send request
-    console.log('HTTP GET: ' + url);
+    this.log('HTTP GET: ' + url);
 
     return $.ajax({
       type: 'GET', url: url, data: { _unlock:(lock?lock:0) }, dataType: 'json',
@@ -5624,7 +5641,7 @@
     }
 
     // send request
-    console.log('HTTP POST: ' + url);
+    this.log('HTTP POST: ' + url);
 
     return $.ajax({
       type: 'POST', url: url, data: postdata, dataType: 'json',
@@ -5658,7 +5675,7 @@
 
     // if we get javascript code from server -> execute it
     if (response.exec) {
-      console.log(response.exec);
+      this.log(response.exec);
       eval(response.exec);
     }
 

--
Gitblit v1.9.1