001: /* -----------------------------------------------------------------------------
002: * Copyright (c) 2001, Low Kin Onn
003: * All rights reserved.
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: *
008: * Redistributions of source code must retain the above copyright notice, this
009: * list of conditions and the following disclaimer.
010: *
011: * Redistributions in binary form must reproduce the above copyright notice,
012: * this list of conditions and the following disclaimer in the documentation
013: * and/or other materials provided with the distribution.
014: *
015: * Neither name of the Scioworks Pte. Ltd. nor the names of its contributors
016: * may beused to endorse or promote products derived from this software without
017: * specific prior written permission.
018: *
019: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
021: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
023: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
024: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
025: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
026: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
027: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
028: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: *
030: * -----------------------------------------------------------------------------
031: */
032:
033: package scioworks.imap.presentation;
034:
035: import javax.mail.*;
036:
037: public class ImapWebSessionData implements java.io.Serializable {
038:
039: public static final String SESSION_KEY = "ImapWebSessionData";
040:
041: private URLName imapURL = null;
042: private Session imapSession = null;
043: private Store imapStore = null;
044: String userMessage = null;
045:
046: public ImapWebSessionData() {
047: }
048:
049: public ImapWebSessionData(URLName url) {
050: this .imapURL = url;
051: }
052:
053: public URLName getImapURL() {
054: return imapURL;
055: }
056:
057: public void setImapURL(URLName url) {
058: this .imapURL = url;
059: }
060:
061: public void setImapSession(Session session) {
062: this .imapSession = session;
063: }
064:
065: public Session getImapSession() {
066: return imapSession;
067: }
068:
069: public void setImapStore(Store store) {
070: this .imapStore = store;
071: }
072:
073: public Store getImapStore() {
074: return imapStore;
075: }
076:
077: public void setUserMessage(String msg) {
078: this .userMessage = msg;
079: }
080:
081: public String getUserMessage() {
082: return userMessage;
083: }
084:
085: /**
086: * Retrieve the most recent user message and then clear it so no
087: * other app tries to use it.
088: */
089: public String getAndClearUserMessage() {
090: String msg = this .userMessage;
091: this .userMessage = null;
092: return msg;
093: }
094:
095: public boolean isValidSession() {
096: /** @todo : to check if this is sufficient */
097: if (imapSession == null) {
098: return false;
099: } else {
100: return true;
101: }
102: }
103: }
|