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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2008-09-23 12:17:56 UTC
  • mfrom: (2.1.8 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080923121756-6u4x8bwq89qlzt32
Tags: 2.00+dfsg-2
Update to package description: note that Alpine is no longer in
alpha. (Closes: #499640)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: view 1160 2008-08-22 01:12:33Z mikes@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(appdir2)/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(appdir2)/browse/0/INBOX"]
 
66
    }
 
67
  } else {
 
68
    WPCmd PEInfo statmsg "Cannot view unspecified folder"
 
69
    error [list _redirect "[cgi_root]/$_wp(appdir2)/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(appdir2)/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
    if {[catch {
 
87
      WPCmd source "[pwd]/messageview.tcl"
 
88
      WPCmd source "[pwd]/messagelist.tcl"
 
89
    } result]} {
 
90
      error [list _action browse "cannot load message viewer: $result"]
 
91
    }
 
92
  }
 
93
 
 
94
  # process any actions specified by view_args
 
95
  if {$delete > 0} {
 
96
    if {0 == [catch [WPCmd PEMessage $delete number] dnum]} {
 
97
      
 
98
    }
 
99
    # ELSE already deleted, don't worry about it
 
100
  } elseif {$spam > 0} {
 
101
    if {0 == [catch [WPCmd PEMessage $spam number] snum]} {
 
102
 
 
103
    }
 
104
    # ELSE already reported, don't worry about it
 
105
  } elseif {$unread > 0} {
 
106
    if {[catch {WPCmd PEMessage $unread flag new 1} result]} {
 
107
      # ERROR: Cannot set $u unread
 
108
    }
 
109
  } elseif {[string length $star]} {
 
110
    switch -- $star {
 
111
      0 {
 
112
        if {[catch {WPCmd PEMessage $u flag important 0} result]} {
 
113
          # ERROR: Cannot set Star on message $u
 
114
        }
 
115
      }
 
116
      1 {
 
117
        if {[catch {WPCmd PEMessage $u flag important 1} result]} {
 
118
          # ERROR: Cannot set Star on message $u
 
119
        }
 
120
      }
 
121
      default {}
 
122
    }
 
123
  }
 
124
 
 
125
  if {[catch {WPCmd PEMessage $u charset} charset]
 
126
      || [string length $charset] == 0
 
127
      || [string compare us-ascii [string tolower $charset]] == 0} {
 
128
    set charset "ISO-8859-1"
 
129
  }
 
130
 
 
131
  if {[catch {WPCmd PEMessage $u number} n]} {
 
132
    WPCmd PEInfo statmsg "$n"
 
133
    error [list _redirect "$_wp(serverpath)/$_wp(appdir2)/browse/$c/$f"]
 
134
  }
 
135
 
 
136
  cgi_http_head {
 
137
    WPStdHttpHdrs "text/html; charset=$charset"
 
138
  }
 
139
 
 
140
  # counts and so forth
 
141
  set mc [WPCmd PEMailbox messagecount]
 
142
 
 
143
  set unext [WPCmd PEMailbox uid [WPCmd PEMailbox next $n 1]]
 
144
  set delim [WPCmd PEFolder delimiter $c]
 
145
 
 
146
 
 
147
  cgi_html {
 
148
    cgi_head {
 
149
      cgi_content_type "text/html; charset=$charset"
 
150
      cgi_title [wpPageTitle "Message $n of $mc in $f"]
 
151
      cgi_base "href=$_wp(serverpath)/$_wp(appdir2)/"
 
152
      cgi_stylesheet css/menu.css
 
153
      cgi_stylesheet css/cbn/screen.css
 
154
      cgi_stylesheet css/cbn/folderdialog.css
 
155
      cgi_stylesheet $_wp(yui)/build/container/assets/container-core.css
 
156
      cgi_stylesheet $_wp(yui)/build/menu/assets/skins/sam/menu.css
 
157
      cgi_stylesheet $_wp(yui)/build/button/assets/skins/sam/button.css
 
158
      # Yahoo UI libraries
 
159
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/utilities/utilities.js" {}
 
160
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/container/container-min.js" {}
 
161
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/datasource/datasource-beta-min.js" {}
 
162
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/menu/menu-min.js" {}
 
163
      cgi_script type=text/javascript language="JavaScript" src="$_wp(yui)/build/button/button-min.js" {}
 
164
      # local libraries
 
165
      cgi_script type=text/javascript language="JavaScript" src="lib/common.js" {}
 
166
      cgi_script type=text/javascript language="JavaScript" src="lib/mailbox.js" {}
 
167
      # page specfic JS
 
168
      cgi_javascript {
 
169
        cgi_puts "YAHOO.alpine.cgi_root = '$_wp(serverpath)';"
 
170
        cgi_puts "YAHOO.alpine.app_root = '$_wp(serverpath)/$_wp(appdir2)';"
 
171
        cgi_puts "YAHOO.alpine.current.c = $c;"
 
172
        cgi_puts "YAHOO.alpine.current.f = \"$f\";"
 
173
        cgi_puts "YAHOO.alpine.current.u = $u;"
 
174
        cgi_puts "YAHOO.alpine.current.count = $mc;"
 
175
        cgi_puts "YAHOO.alpine.current.selected = [WPCmd PEMailbox selected];"
 
176
        cgi_puts "YAHOO.alpine.current.searched = [WPCmd PEMailbox searched];"
 
177
        cgi_puts "YAHOO.alpine.current.focused = [WPCmd PEMailbox focus];"
 
178
        if {[lsearch -exact [list Junk Trash] $f] >= 0} {
 
179
          cgi_puts "function doEmpty(ctrlObj,listOption){"
 
180
          cgi_puts " if(listOption == 'all'){"
 
181
          cgi_puts "  emptyFolder('$c','$f','all',{status:true,fn:'updateViewLinksAndSuch(0,0,0,0,0,0);'});"
 
182
          cgi_puts " } else {"
 
183
          cgi_puts "  newMessageText({control:ctrlObj,parms:{op:'trash'}});"
 
184
          cgi_puts " }"
 
185
          cgi_puts " return false;"
 
186
          cgi_puts "}"
 
187
        }
 
188
        cgi_puts "function bodyOnLoad() {"
 
189
        cgi_puts " initMenus();"
 
190
        cgi_puts " initMorcButton('viewMorcButton');"
 
191
        cgi_puts " if(YAHOO.env.ua.gecko > 0){ sizeVPHeight(); window.onresize = resizeVPHeight; }"
 
192
        cgi_puts " setNewMailCheckInterval([WPCmd PEInfo inputtimeout]);"
 
193
        wpStatusAndNewmailJavascript
 
194
        wpSaveMenuJavascript "view" $c $f [WPCmd PEFolder defaultcollection] morcInViewDone
 
195
        cgi_puts "}"
 
196
 
 
197
        cgi_puts "browserDetect();"
 
198
      }
 
199
    }
 
200
 
 
201
    cgi_body class=wap "onLoad=bodyOnLoad()" {
 
202
      cgi_division  id="skip" {
 
203
        cgi_put [cgi_url "Skip to Next Message" "#"]
 
204
        cgi_put [cgi_url "Skip to Message List" "browse#messages"]
 
205
        cgi_put [cgi_url "Skip to Folders" "#folders"]
 
206
        cgi_put [cgi_url "Skip to Compose" "compose#to"]
 
207
      }
 
208
 
 
209
      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(appdir2)/browse/${c}/${f}?u=${u}"] "$f" 1 mailboxSearch()] {} {
 
210
        # CONTEXT COMMANDS
 
211
        cgi_division class=hdrBtns {
 
212
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi1" ""][cgi_span "class=hdrBtnText" Print]" "print" "onClick=if(window.print){window.print();return false;}else return true;"]
 
213
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi2" ""][cgi_span "class=hdrBtnText" Settings]" "settings"]
 
214
          cgi_put [cgi_url "[cgi_span "class=sp hdrBtnImg hbi3" ""][cgi_span "class=hdrBtnText" Help]" # "onClick=return openMailboxHelp();" class=wap]
 
215
          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}"]
 
216
        }
 
217
      } {
 
218
        cgi_division id=listTopMenubar "style=\"display: none;\"" {
 
219
          cgi_puts [WPCmd cgi_buffer "drawTopListMenuBar $c {$f}"]
 
220
        }
 
221
        cgi_division id=viewTopMenubar {
 
222
          cgi_puts [WPCmd cgi_buffer "drawTopViewMenuBar $c {$f} $u $n"]
 
223
        }
 
224
      } {
 
225
        cgi_puts [WPCmd cgi_buffer "drawMessageText $c {$f} $u $showimg"]
 
226
      } {
 
227
        cgi_division id=listBottomMenubar "style=\"display: none;\"" {
 
228
          cgi_puts [WPCmd cgi_buffer "drawBottomListMenuBar $c {$f} 0 0 $mc"]
 
229
        }
 
230
        cgi_division id=viewBottomMenubar {
 
231
          cgi_puts [WPCmd cgi_buffer "drawBottomViewMenuBar $c {$f} $u $n $mc"]
 
232
        }
 
233
      }
 
234
 
 
235
      # any debugging info to insert?
 
236
      foreach dmsg $dmsgs {
 
237
        cgi_html_comment "DEBUG: $dmsg"
 
238
        cgi_puts ""
 
239
      }
 
240
    }
 
241
  }
 
242
}