📄 pdacomposeservlet.java
字号:
/*
* @(#)PdaComposeServlet.java
*
* Copyright (C) 2006 Sergey Bredikhin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package olivax.webmail;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import oliva.common.OlivaUtils;
import oliva.mail.MailUtils;
public class PdaComposeServlet extends HttpServlet {
static final long serialVersionUID = 1675075694621323211L;
public PdaComposeServlet() {
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = null;
try {
request.setCharacterEncoding(Context.clntCp);
response.setContentType("text/html; charset=" + Context.clntCp);
out = response.getWriter();
HttpSession session = request.getSession();
Context myContext = (Context) session.getAttribute("myContext");
if(myContext == null) {
myContext = new Context();
session.setAttribute("myContext", myContext);
}
if(!myContext.isLoggedIn()) {
Context.forward(this, request, response, "/pda_logon");
}
myContext.setNoCache(response);
// Get parameters
String action = request.getParameter("action");
String msgno = request.getParameter("msgno");
String msguid = request.getParameter("msguid");
String strPartNo = request.getParameter("partno");
int partno = -1;
if(strPartNo != null)
partno = Integer.parseInt(strPartNo);
String cp = request.getParameter("cp");
oliva.mail.SimpleMessage msg = null;
boolean isReply = false;
boolean isDelayed = false;
String fwdNo = null;
String newTo = null;
boolean initialLost = false;
if(action != null) {
if(msgno != null) {
int iMsgNo = Integer.parseInt(msgno);
if(action.equalsIgnoreCase("reply")) {
if(partno == -1) {
msg = myContext.mailBean.getReplyMessage(iMsgNo, msguid, cp, true);
} else {
msg = null;
oliva.mail.Message message = myContext.getMessage(iMsgNo, msguid, null);
if (message != null) {
msg = myContext.mailBean.getReplyMessage(message.getRfc822Part(partno).apiMessage, cp, true);
}
}
if(msg != null) {
msg.From = oliva.mail.MailUtils.getHtmlAddressList(msg.From, null);
msg.ReplyTo = oliva.mail.MailUtils.getHtmlAddressList(msg.ReplyTo, null);
msg.To = oliva.mail.MailUtils.getHtmlAddressList(msg.To, null);
msg.Cc = oliva.mail.MailUtils.getHtmlAddressList(msg.Cc, null);
if(msg.text != null) {
java.lang.StringBuffer sb = new java.lang.StringBuffer();
sb.append("\n\n\n-----Original Message-----\nFrom: " + msg.From +
"\nSent: " + oliva.common.OlivaUtils.getDateString(msg.sentDate, myContext.lang, myContext.getI18nString("_settings.dateFormat")) +
"\nTo: " + msg.To);
if(msg.Cc.length() != 0)
sb.append("\nCc: " + msg.Cc);
sb.append("\nSubject: " + msg.Subject + "\n\n");
sb.append(msg.text);
msg.text = sb.toString();
}
msg.Subject = MailUtils.getPrefixedSubject(msg.Subject, "Re");
isReply = true;
} else
initialLost = true;
}
if(action.equalsIgnoreCase("forward")) {
if(partno == -1) {
msg = myContext.mailBean.getReplyMessage(iMsgNo, msguid, cp, false);
} else {
msg = null;
oliva.mail.Message message = myContext.getMessage(iMsgNo, msguid, null);
if(message != null) {
msg = myContext.mailBean.getReplyMessage(message.getRfc822Part(partno).apiMessage, cp, false);
}
}
if(msg != null) {
msg.Subject = MailUtils.getPrefixedSubject(msg.Subject, "Fwd");
fwdNo = String.valueOf(iMsgNo);
} else
initialLost = true;
}
}
if(action.equalsIgnoreCase("new")) {
newTo = request.getParameter("to");
if(newTo != null)
newTo = oliva.common.OlivaUtils.getStringInternals(newTo, Context.clntCp);
}
if (action.equalsIgnoreCase("delayed")) {
msg = myContext.getDelayedMessage();
if (msg != null) {
isDelayed = true;
myContext.emptyDelayedMessage();
}
}
}
if(newTo == null)
newTo = "";
PdaPage pdaPage = new PdaPage();
pdaPage.setTitle(myContext.getI18nString("_str_compose_title"));
//Logo
pdaPage.addPane(myContext.getPdaLogo());
//Title
PdaPane pdaPane = new PdaPane();
pdaPane.setColor(PdaPane.COLOR_CCCCCC);
pdaPane.setHeight("20");
pdaPane.setContent("<font size=\"3\" face=\"arial, tahoma, verdana\"><strong>" +
myContext.getI18nString("_str_compose_title") + "</strong></font>");
pdaPage.addPane(pdaPane);
//Menu
StringBuffer sb = new StringBuffer();
sb.append("<font size=\"3\">");
sb.append("<a href=\"javascript:{history.back();}\">").append(myContext.getI18nString("_str_back")).append("</a> ");
sb.append("<a href=\"./pda_list?pg=-1").append("\">").append(myContext.getI18nString("_str_receive")).append("</a> ");
sb.append("<a href=\"./pda_logon?action=logout\">").append(myContext.getI18nString("_str_exit")).append("</a> ");
sb.append("</font>");
PdaPane menuPane = new PdaPane();
menuPane.setColor(PdaPane.COLOR_FFFFFF);
menuPane.setContent(sb.toString());
pdaPage.addPane(menuPane);
// Hint
sb = new StringBuffer();
if (initialLost) {
sb.append("<font size=\"3\" color=\"red\">").append(
myContext.getI18nString("_str_msg_lost")).append(
"</font>");
}
if (!initialLost && myContext._hints_enabled) {
String composeHint = null;
if (fwdNo != null) {
composeHint = "_str_hint_forward";
} else {
composeHint = "_str_hint_save_copy";
/*
composeHint = myContext.strings.getProperty("compose_hint");
if (composeHint == null) {
myContext.strings.setProperty("compose_hint",
"_str_hint_save_copy");
composeHint = "_str_hint_save_copy";
} else if (composeHint.equals("_str_hint_as_unicode")) {
myContext.strings.setProperty("compose_hint",
"_str_hint_save_copy");
composeHint = "_str_hint_save_copy";
} else {
myContext.strings.setProperty("compose_hint",
"_str_hint_as_unicode");
composeHint = "_str_hint_as_unicode";
}
*/
}
sb.append("<font size=\"3\" color=\"#000066\">").append(
myContext.getI18nString(composeHint)).append("</font>");
}
pdaPane = new PdaPane();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -