Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mrbook.mrpostman.hotmail
Class HotmailMailSession  view HotmailMailSession download HotmailMailSession.java

java.lang.Object
  extended byorg.mrbook.mrpostman.WebMailSession
      extended byorg.mrbook.mrpostman.hotmail.HotmailMailSession

public class HotmailMailSession
extends org.mrbook.mrpostman.WebMailSession


Field Summary
private  boolean authenticated
           
private static java.lang.String[] AUTHORS
          Our hardcoded ModuleInfo data.
private  java.lang.String baseUrl
           
private  com.sonalb.net.http.cookie.CookieJar cj
           
static java.lang.String CVSID
           
 boolean flagMsgAsRead
          Flag message as read after RETR
(package private)  java.lang.String inboxUrlStr
           
static java.util.HashMap local
          Locales to work with account in other languages but English.
private static java.util.logging.Logger logger
           
private  java.util.Vector messageIDS
           
private static org.mrbook.mrpostman.ModuleInfo MODULE_INFO
           
private  java.lang.String msgDeleteBaseUrl
           
private  java.lang.String msgReadBaseUrl
           
private  int numMessages
           
private  int numNewMessages
           
 boolean onlyReturnUnreadMsgs
          Flag to indicate whether this app will only retrieve the unread messages
private static org.mrbook.mrpostman.ModuleOption[] OPTIONS
           
private static java.lang.String startLoginPageURL
           
private static java.lang.String UserAgent
           
 
Fields inherited from class org.mrbook.mrpostman.WebMailSession
WMS_LOGIN_FAILED, WMS_LOGIN_OK, WMS_MODULE_ERROR, WMS_PAGE_STRUCTURE
 
Constructor Summary
HotmailMailSession()
           
 
Method Summary
private  java.lang.String createPostRequest(java.lang.String username, java.lang.String password)
          Build the hotmail login url parameters
 boolean deleteMessage(int num)
          Delete the message with the supplied index number.
private  java.lang.String getBaseURL(java.net.URL url)
          Strip the base context url from the request url for use in later gets
private  java.lang.String getCharSetFromContentType(java.lang.String ctype)
          Pull out the charset from the Content-Type string if available.
 org.mrbook.mrpostman.ModuleInfo getModuleInfo()
          Return the module info.
 java.lang.String getModuleName()
          Return the module name to the MrPostman controller
 java.lang.String[] getRecognizedExtensions()
          Return the list of email extensions supported by this module
 int getSizeOfMessage(int num)
          Return the size of the specified msg (indexed from 1!) This is a bit of a frig and isn't guaranteed to be correct (certainly not for hotmail circular messages!).
 java.lang.String getUniqueMessageId(int num)
          Return hotmail's UIDL for this message.
 int login(java.lang.String username, java.lang.String password, boolean secureLogin)
          Perform the login and retrieve the authentication cookie needed for subsequent requests.
static void main(java.lang.String[] args)
          A debug main method
 int numMessages()
          Return the number of messages in the inbox (read and unread) We'll do this by selecting the inbox and searching for message links
 void outputLinesMessage(int num, java.io.PrintWriter pw, int numLines)
          Retrieve the email header and numLines of the email body.
 void outputMessage(int num, java.io.PrintWriter pw)
          Retrieve and output the message.
 void quitSession()
          Handle the QUIT command.
private  void retrieveMessage(int num, java.io.PrintWriter pw, int numLines)
          Retrieve the msg specified by the supplied msg number (indexed from 1!) Strip the HTML tags and output the message (complete with header and attachments) to the supplied PrintWriter if numLines != -1 then limit the number of body lines to be this value (used for the TOP command) Assumptions: the msg will be surrounded by 'pre' and '/pre' tags.
 void setOption(java.lang.String optionName, java.lang.String value)
          Set a module option with a value from the preferences or from the GUI Currently understood options are listed in the MODULE_INFO specification above.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVSID

public static final java.lang.String CVSID
See Also:
Constant Field Values

AUTHORS

private static final java.lang.String[] AUTHORS
Our hardcoded ModuleInfo data.


OPTIONS

private static final org.mrbook.mrpostman.ModuleOption[] OPTIONS

MODULE_INFO

private static final org.mrbook.mrpostman.ModuleInfo MODULE_INFO

logger

private static java.util.logging.Logger logger

startLoginPageURL

private static java.lang.String startLoginPageURL

UserAgent

private static java.lang.String UserAgent

local

public static final java.util.HashMap local
Locales to work with account in other languages but English.


baseUrl

private java.lang.String baseUrl

inboxUrlStr

java.lang.String inboxUrlStr

messageIDS

private java.util.Vector messageIDS

msgReadBaseUrl

private java.lang.String msgReadBaseUrl

msgDeleteBaseUrl

private java.lang.String msgDeleteBaseUrl

cj

private com.sonalb.net.http.cookie.CookieJar cj

numMessages

private int numMessages

numNewMessages

private int numNewMessages

authenticated

private boolean authenticated

onlyReturnUnreadMsgs

public boolean onlyReturnUnreadMsgs
Flag to indicate whether this app will only retrieve the unread messages


flagMsgAsRead

public boolean flagMsgAsRead
Flag message as read after RETR

Constructor Detail

HotmailMailSession

public HotmailMailSession()
Method Detail

getCharSetFromContentType

private java.lang.String getCharSetFromContentType(java.lang.String ctype)
Pull out the charset from the Content-Type string if available.


login

public int login(java.lang.String username,
                 java.lang.String password,
                 boolean secureLogin)
Perform the login and retrieve the authentication cookie needed for subsequent requests. We'll do this by: 1 Retrieving the login.asp main page. 2 Extracting the login service url (passport service) 3 Posting a login block 4 Following the returned 'meta refresh' hotmail uses to avoid https alerts 5 Verifying the page is not an error page


getBaseURL

private java.lang.String getBaseURL(java.net.URL url)
Strip the base context url from the request url for use in later gets


createPostRequest

private java.lang.String createPostRequest(java.lang.String username,
                                           java.lang.String password)
Build the hotmail login url parameters


numMessages

public int numMessages()
Return the number of messages in the inbox (read and unread) We'll do this by selecting the inbox and searching for message links


outputMessage

public void outputMessage(int num,
                          java.io.PrintWriter pw)
Retrieve and output the message. If option is enabled, flag the message as read. This is called by the RETR command.


outputLinesMessage

public void outputLinesMessage(int num,
                               java.io.PrintWriter pw,
                               int numLines)
Retrieve the email header and numLines of the email body. The message will not be marked as read. This is called by the TOP command.


retrieveMessage

private void retrieveMessage(int num,
                             java.io.PrintWriter pw,
                             int numLines)
Retrieve the msg specified by the supplied msg number (indexed from 1!) Strip the HTML tags and output the message (complete with header and attachments) to the supplied PrintWriter if numLines != -1 then limit the number of body lines to be this value (used for the TOP command) Assumptions: the msg will be surrounded by 'pre' and '/pre' tags.


getSizeOfMessage

public int getSizeOfMessage(int num)
Return the size of the specified msg (indexed from 1!) This is a bit of a frig and isn't guaranteed to be correct (certainly not for hotmail circular messages!).


getModuleName

public java.lang.String getModuleName()
Return the module name to the MrPostman controller


getRecognizedExtensions

public java.lang.String[] getRecognizedExtensions()
Return the list of email extensions supported by this module


deleteMessage

public boolean deleteMessage(int num)
Delete the message with the supplied index number. Returns true if message was deleted successful.


getUniqueMessageId

public java.lang.String getUniqueMessageId(int num)
                                    throws org.mrbook.mrpostman.MailSessionException
Return hotmail's UIDL for this message. We can get this by generating the MD5 hash of the message header fields. Hopefully this is unique!


quitSession

public void quitSession()
Handle the QUIT command. We need to move all our read messages to our READ folder and logout. NOTE: We can't do this after each RETR as that would adjust all the message ids!


main

public static void main(java.lang.String[] args)
A debug main method


getModuleInfo

public org.mrbook.mrpostman.ModuleInfo getModuleInfo()
Return the module info.


setOption

public void setOption(java.lang.String optionName,
                      java.lang.String value)
Set a module option with a value from the preferences or from the GUI Currently understood options are listed in the MODULE_INFO specification above.