~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/cgi/alpine/2.0/view

  • Committer: Package Import Robot
  • Author(s): Asheesh Laroia
  • Date: 2013-05-19 16:15:01 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130519161501-epf6pfldn07xnd11
Tags: 2.10+dfsg-1
* New upstream release.
* This release ships a fix for an issue where the PREFDATETIME token
  was always set to "Sun" incorrectly. (Closes: #692870)
* This release ships a fix for IMAP-encoded non-ASCII folder names.
  (Closes: #674067)
* This release simplifies (and corrects) S/MIME handling for messages
  that encrypted *and* signed. (Closes: #653420)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: view 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2008 University of Washington
 
5
#
 
6
# Licensed under the Apache License, Version 2.0 (the "License");
 
7
# you may not use this file except in compliance with the License.
 
8
# You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# ========================================================================
 
13
 
 
14
#  view.tcl
 
15
#
 
16
#  Purpose:  CGI script generating page to display text of requested
 
17
#            message
 
18
#
 
19
#  Input:    PATH_INFO: [/<col_number>]/<folder_name>[/<uid_of_viewed_msg>
 
20
#            along with possible search parameters:
 
21
set view_args {
 
22
  {delete       {}      0}
 
23
  {spam         {}      0}
 
24
  {unread       {}      0}
 
25
  {star         {}      {}}
 
26
  {showimg      {}      {}}
 
27
  {hideimg      {}      {}}
 
28
  {searchText   {}      {}}
 
29
}
 
30
 
 
31
 
 
32
# On input failure, redirect to home page "browse"
 
33
proc view_redirect {} {
 
34
  global _wp
 
35
 
 
36
  cgi_http_head {
 
37
    cgi_redirect "[cgi_root]/$_wp(appdir)/$_wp(ui2dir)/browse"
 
38
  }
 
39
}
 
40
 
 
41
# inherit global config
 
42
source ./alpine.tcl
 
43
source ./common.tcl
 
44
source ./foldercache.tcl
 
45
source ./messageview.tcl
 
46
 
 
47
# TEST
 
48
proc cgi_suffix {args} {
 
49
  return ""
 
50
}
 
51
 
 
52
# for inserting debug comments at end of page
 
53
set dmsgs ""
 
54
proc dm {s} {
 
55
  global dmsgs
 
56
  lappend dmsgs $s
 
57
}
 
58
 
 
59
 
 
60
WPEval $view_args {
 
61
  # grok PATH_INFO for collection 'c' and folder 'f'
 
62
  if {[info exists env(PATH_INFO)] && [string length $env(PATH_INFO)]} {
 
63
    if {0 == [regexp {^/([0-9]+)/(.*)/([0-9]+)$} $env(PATH_INFO) dummy c f u]} {
 
64
      WPCmd PEInfo statmsg "Cannot open invalid path: $env(PATH_INFO)"
 
65
      error [list _redirect "[cgi_root]/$_wp(appdir)/$_wp(ui2dir)/browse/0/INBOX"]
 
66
    }
 
67
  } else {
 
68
    WPCmd PEInfo statmsg "Cannot view unspecified folder"
 
69
    error [list _redirect "[cgi_root]/$_wp(appdir)/$_wp(ui2dir)/browse/0/INBOX"]
 
70
  }
 
71
 
 
72
  # verify or visit specified collection/folder
 
73
  if {[catch {setCurrentFolder c f u} result]} {
 
74
    set authlist [wpHandleAuthException $result [list $c "folders in collection"] $f]
 
75
    if {0 == [llength $authlist]} {
 
76
      WPCmd PEInfo statmsg "$result"
 
77
      error [list _redirect "$_wp(serverpath)/$_wp(appdir)/$_wp(ui2dir)/browse/$c/$f"]
 
78
    }
 
79
  }
 
80
 
 
81
  # load message drawing routine for this session
 
82
  # save per-message source, proc overhead
 
83
  # to reinstall on the fly:
 
84
  #catch {WPCmd rename drawMessageText {}}
 
85
  if {0 == [llength [WPCmd info commands drawMessageText]]} {
 
86
    set cgidir [file join $_wp(cgipath) $_wp(appdir) $_wp(ui2dir)]
 
87
    if {[catch {
 
88
      WPCmd source "${cgidir}/messageview.tcl"
 
89
      WPCmd source "${cgidir}/messagelist.tcl"
 
90
    } result]} {
 
91
      error [list _action browse "cannot load message viewer: $result"]
 
92
    }
 
93
  }
 
94
 
 
95
  # process any actions specified by view_args
 
96
  if {$delete > 0} {
 
97
    if {0 == [catch [WPCmd PEMessage $delete number] dnum]} {
 
98
      
 
99
    }
 
100
    # ELSE already deleted, don't worry about it
 
101
  } elseif {$spam > 0} {
 
102
    if {0 == [catch [WPCmd PEMessage $spam number] snum]} {
 
103
 
 
104
    }
 
105
    # ELSE already reported, don't worry about it
 
106
  } elseif {$unread > 0} {
 
107
    if {[catch {WPCmd PEMessage $unread flag new 1} result]} {
 
108
      # ERROR: Cannot set $u unread
 
109
    }
 
110
  } elseif {[string length $star]} {
 
111
    switch -- $star {
 
112
      0 {
 
113
        if {[catch {WPCmd PEMessage $u flag important 0} result]} {
 
114
          # ERROR: Cannot set Star on message $u
 
115
        }
 
116
      }
 
117
      1 {
 
118
        if {[catch {WPCmd PEMessage $u flag important 1} result]} {
 
119
          # ERROR: Cannot set Star on message $u
 
120
        }
 
121
      }
 
122
      default {}
 
123
    }
 
124
  }
 
125
 
 
126
  if {[catch {WPCmd PEMessage $u charset} charset]
 
127
      || [string length $charset] == 0
 
128
      || [string compare us-ascii [string tolower $charset]] == 0} {
 
129
    set charset "ISO-8859-1"
 
130
  }
 
131
 
 
132
  if {[catch {WPCmd PEMessage $u number} n]} {
 
133
    WPCmd PEInfo statmsg "$n"
 
134
    error [list _redirect "$_wp(serverpath)/$_wp(appdir)/$_wp(ui2dir)/browse/$c/$f"]
 
135
  }
 
136
 
 
137
  cgi_http_head {
 
138
    WPStdHttpHdrs "text/html; charset=$charset"
 
139
  }
 
140
 
 
141
  # counts and so forth
 
142
  set mc [WPCmd PEMailbox messagecount]
 
143
 
 
144
  set unext [WPCmd PEMailbox uid [WPCmd PEMailbox next $n 1]]
 
145
  set delim [WPCmd PEFolder delimiter $c]
 
146
 
 
147
 
 
148
  cgi_html {
 
149
    cgi_head {
 
150
      cgi_content_type "text/html; charset=$charset"
 
151
      cgi_title [wpPageTitle "Message $n of $mc in $f"]
 
152
      cgi_base "href=$_wp(serverpath)/$_wp(appdir)/$_wp(ui2dir)/"
 
153
      cgi_stylesheet css/menu.css
 
154
      cgi_stylesheet css/cbn/screen.css
 
155
      cgi_stylesheet css/cbn/folderdialog.css
 
156
      cgi_stylesheet $_wp(yui)/build/container/assets/container-core.css
 
157
      cgi_stylesheet $_wp(yui)/build/menu/assets/skins/sam/menu.css
 
158
      cgi_stylesheet $_wp(yui)/build/button/assets/skins/sam/button.css
 
159
      # Yahoo UI libraries
 
160
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/utilities/utilities.js" {}
 
161
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/container/container-min.js" {}
 
162
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/datasource/datasource-min.js" {}
 
163
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/menu/menu-min.js" {}
 
164
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/button/button-min.js" {}
 
165
      # local libraries
 
166
      cgi_script type=text/javascript language="JavaScript" src="lib/common.js" {}
 
167
      cgi_script type=text/javascript language="JavaScript" src="lib/mailbox.js" {}
 
168
      # page specfic JS
 
169
      cgi_javascript {
 
170
        cgi_puts "YAHOO.alpine.cgi_root = '$_wp(serverpath)';"
 
171
        cgi_puts "YAHOO.alpine.app_root = '$_wp(serverpath)/$_wp(appdir)/$_wp(ui2dir)';"
 
172
        cgi_puts "YAHOO.alpine.current.c = $c;"
 
173
        cgi_puts "YAHOO.alpine.current.f = \"$f\";"
 
174
        cgi_puts "YAHOO.alpine.current.u = $u;"
 
175
        cgi_puts "YAHOO.alpine.current.count = $mc;"
 
176
        cgi_puts "YAHOO.alpine.current.selected = [WPCmd PEMailbox selected];"
 
177
        cgi_puts "YAHOO.alpine.current.searched = [WPCmd PEMailbox searched];"
 
178
        cgi_puts "YAHOO.alpine.current.focused = [WPCmd PEMailbox focus];"
 
179
        cgi_puts "function bodyOnLoad() {"
 
180
        cgi_puts " initMenus();"
 
181
        cgi_puts " initMorcButton('viewMorcButton');"
 
182
        cgi_puts " if(YAHOO.env.ua.gecko > 0){ sizeVPHeight(); window.onresize = resizeVPHeight; }"
 
183
        cgi_puts " setCheckMailFunction('gCheck', newMailCheck);"
 
184
        cgi_puts " setNewMailCheckInterval([WPCmd PEInfo inputtimeout]);"
 
185
        wpStatusAndNewmailJavascript
 
186
        wpSaveMenuJavascript "view" $c $f [WPCmd PEFolder defaultcollection] morcInViewDone
 
187
        cgi_puts "}"
 
188
 
 
189
        cgi_puts "browserDetect();"
 
190
      }
 
191
    }
 
192
 
 
193
    cgi_body class=wap "onLoad=bodyOnLoad()" {
 
194
      cgi_division  id="skip" {
 
195
        cgi_put [cgi_url "Skip to Next Message" "#" "onClick=return newMessageText({control:this,parms:{op:'next'}});"]
 
196
        cgi_put [cgi_url "Skip to Message List" "browse"]
 
197
        cgi_put [cgi_url "Skip to Folders" "folders"]
 
198
        cgi_put [cgi_url "Skip to Compose" "compose"]
 
199
      }
 
200
 
 
201
      wpCommonPageLayout view $c $f $u [cgi_url "[cgi_quote_html $f], Message $n of $mc" browse/$c/[WPPercentQuote $f $delim] id=gBigContext] [list [cgi_cgi "$_wp(appdir)/$_wp(ui2dir)/browse/${c}/${f}?u=${u}"] "$f" 1 mailboxSearch()] {} {
 
202
        # CONTEXT COMMANDS
 
203
        cgi_division class=hdrBtns {
 
204
          cgi_javascript {
 
205
            cgi_put "if(window.print) document.write('[cgi_buffer {cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi1" ""][cgi_span "class=hdrBtnText" Print]" "print" "onClick=return printContent()"]}]');"
 
206
          }
 
207
 
 
208
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi2" ""][cgi_span "class=hdrBtnText" Settings]" "settings"]
 
209
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi3" ""][cgi_span "class=hdrBtnText" Help]" # "onClick=return openMailboxHelp();" class=wap]
 
210
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi4" ""][cgi_span "class=hdrBtnText" "Sign out"]" "../../session/logout.tcl?cid=[WPCmd PEInfo key]&sessid=${sessid}"]
 
211
        }
 
212
      } {
 
213
        cgi_division id=listTopMenubar "style=\"display: none;\"" {
 
214
          cgi_puts [WPCmd cgi_buffer "drawTopListMenuBar $c {$f}"]
 
215
        }
 
216
        cgi_division id=viewTopMenubar {
 
217
          cgi_puts [WPCmd cgi_buffer "drawTopViewMenuBar $c {$f} $u $n"]
 
218
        }
 
219
      } {
 
220
        cgi_puts [WPCmd cgi_buffer "drawMessageText $c {$f} $u $showimg"]
 
221
      } {
 
222
        cgi_division id=listBottomMenubar "style=\"display: none;\"" {
 
223
          cgi_puts [WPCmd cgi_buffer "drawBottomListMenuBar $c {$f} 0 0 $mc"]
 
224
        }
 
225
        cgi_division id=viewBottomMenubar {
 
226
          cgi_puts [WPCmd cgi_buffer "drawBottomViewMenuBar $c {$f} $u $n $mc"]
 
227
        }
 
228
      }
 
229
 
 
230
      # any debugging info to insert?
 
231
      foreach dmsg $dmsgs {
 
232
        cgi_html_comment "DEBUG: $dmsg"
 
233
        cgi_puts ""
 
234
      }
 
235
    }
 
236
  }
 
237
}