kom.gateway
Class GetMail

java.lang.Object
  |
  +--kom.gateway.DBLow
        |
        +--kom.gateway.DBHigh
              |
              +--kom.gateway.KOMutil
                    |
                    +--kom.gateway.Form
                          |
                          +--kom.gateway.Chat
                                |
                                +--kom.gateway.Grade
                                      |
                                      +--kom.gateway.News
                                            |
                                            +--kom.gateway.Build
                                                  |
                                                  +--kom.gateway.SendMail
                                                        |
                                                        +--kom.gateway.Action
                                                              |
                                                              +--kom.gateway.GetMail

public class GetMail
extends Action
implements java.lang.Runnable, java.io.FilenameFilter

Handles incoming mail to persons or forums in the database


Inner Class Summary
(package private)  class GetMail.MessageDelivery
          Methods for delivering a message to one or more recipients in the database
 
Inner classes inherited from class kom.gateway.Build
Build.KOMactivity, Build.KOMcategory, Build.KOMhome, Build.KOMmsg, Build.KOMmt, Build.KOMquery, Build.KOMsub, Build.KOMthr, Build.KOMuser
 
Inner classes inherited from class kom.gateway.KOMutil
KOMutil.LookupTables, KOMutil.UFtable
 
Field Summary
(package private) static java.lang.String headerFileNamePrefix
          Header files have this name prefix
(package private)  long mailCheckingInterval
          Interval for checking incoming mail (ms).
(package private)  java.lang.String mailDir
          Spool directory for incoming mail files
(package private) static MsgIdTable oldmsgs
          Msgid vs local obj ref
private  java.util.Vector orcpts
          Old recipients, taken from existing headers
private  boolean sleeping
          True if thread is not awake
(package private)  boolean stopped
          Set to true to stop the thread
protected  java.lang.Thread thread
          Thread for mail checking
 
Fields inherited from class kom.gateway.Action
CR, CRLF, LF, ovwt, parser
 
Fields inherited from class kom.gateway.Build
curract, kBalt, kBalt2, kBintro, kBintro2, kBrespondents, kBscale, kBscale2, kCnameq, kCnameq2, kCnewlocname, kCnewmembermail, khead, kPlogin, kPloginpw, kPnewloccat, kPnewlocshort, kPopenness, kPsecret, kPsecret2, kstephead, ksteptail, ktail, modified, qrytable, SM
 
Fields inherited from class kom.gateway.News
format, HTML, limit, NEWSLIMIT, PLAIN, REGULAR, userObject
 
Fields inherited from class kom.gateway.Chat
oldbody, oldpres, reverseChat
 
Fields inherited from class kom.gateway.Form
acceptform, added, bodytext, curform, formcodes, isHTML, isVote, kBase, kBbody, kCname, kCuser, kDColor, kFBase, KFC, kHColor, kIcons, kKFC, kLColor, kPboard, kPcomm, kPdate, kPhtml, kPhtmldef, kPinterval, kPnotif, kPshort, kPtype, kServer, kTarea, oldOutput, outputText, submitted, substkey
 
Fields inherited from class kom.gateway.KOMutil
ACT, anyAccess, arglist, argsep, argtab, attachments, BOK, BOUNDARYSTART, CAT, CHA, cidTable, CLO, config, curNgd, DIC, environment, gateway, gavePassword, GEN, GRA, GRP, inlineCurr, inlines, INT, LINE_CUTOFF, LINE_FUDGE, LIS, lt, MAILIT, messageRecipientTypeCode, MIM, MOD, N_RECTY, N_RECTYPECODE, newsclient, newsClients, newsData, nntpAuth, NWS, NWSART, objCache, oCurr, oldnews, POSTIT, RAT, REC_BCC, REC_CC, REC_TO, recTypeCode, REP, response, rLoc, savednews, sCursor, servletBase, session, THR, userData, USR, VOT
 
Fields inherited from class kom.gateway.DBHigh
AdminURL, cache, HomeURL, UsersURL
 
Fields inherited from class kom.gateway.DBLow
absCDBpath, config, fSep, fSeparator, msgAuth, msgParts
 
Constructor Summary
GetMail(ServerConfig conf, HTTPResponse response, Gateway gateway)
          Constructor.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Implements FilenameFilter
private  void addRcpt(java.lang.String pr, java.lang.String pnum, KomData rto, java.util.Hashtable hrecs, KomData obj, KomData newrcpts)
           
 void checkMail()
          Checks for new mail and tries to deliver it to the "mailboxes" of the recipients, removing the mail files after delivery.
(package private)  void debugLog(java.lang.String s)
           
 void deliver(GetMail.MessageDelivery msd)
          Looks up recipients and tries to deliver message from mail file.
 boolean deliverMail(GetMail.MessageDelivery msd)
          Looks up recipients and tries to deliver message from mail file (mailSpoolFile) to recipients according to the mailTo vector.
private  void edistribute(KomData obj)
          Distributes an incoming email message to its recipients
private  java.util.Hashtable getHeaderRecs(KomData obj, javax.mail.internet.MimeMessage msg, java.lang.String[] rid)
           
 KomData insertMessage(javax.mail.internet.MimeMessage msg, java.lang.String ref, java.lang.String msgid, java.util.Vector rcv, GetMail.MessageDelivery msd, KomData orcpt, KomData newrcpts)
          Makes a Message object from the contents of a mailbox and delivers the message to the recipients
 java.lang.String localObject(java.lang.String msgid)
          Gets a possible local object corresponding to a message id
 KomData mkrecop(KomData r)
           
(package private)  java.lang.String noEol(java.lang.String line)
          Replaces any eol characters by space
 void run()
          Thread control loop.
private  void setFrom(KomData obj, javax.mail.internet.MimeMessage msg)
           
 void stop()
          Tells the GetMail thread to stop running
 
Methods inherited from class kom.gateway.Action
Accept, addAddress, addBatchOfEntries, addBatchOfUsers, AddChat, AddGen, AddGrades, addm, AddMemb, addOneEntry, addOneUser, AddRec, addReceiver, addtype, addUser, authData, CastVote, CheckMsgPwd, checkNews, Create, create1, CreateForm, createForum, createObject, creUser, deleteObj, display, display, distribute, emailCheck, findDraftObject, findRef, getAddress, getAllRecs, getBoard, getEmail, getRecs, getShort, getType, getUser, getXrecs, Login, makeAddress, process, queryinvite, Register, resetUpdate, setPartHeaders, SnetLogin
 
Methods inherited from class kom.gateway.SendMail
addmailaddr, addRecipients, addReferences, closed, disconnected, getFrom, getSender, inetAddr, makeCid, makeContent, makeMime, messageDelivered, messageNotDelivered, messagePartiallyDelivered, mkIadd, opened, post, reduceRecipients, sameAddr, sendEmail
 
Methods inherited from class kom.gateway.Build
addParts, addrecs, build, buildReferences, checkCDB, contentHeaders, copyParts, delete, dispdelete, dispexcl, disphelp, dispinfo, displogin, dispmain, dispnormal, dispparent, disppreview, disprecs, dispreg, doLogin, expunge, getAct, getHier, getKOMmsg, getKOMmsg, getMessageId, getMimeRef, getMt, getNewsClient, getNewsGroupData, getObj, getRecop, getThreads, getUserNews, handleOverviews, history, logout, makeBodyPart, makecont, makeform, makehtml, makeoper, makerec, makerec, makerec, makeRelatedPart, makeSimpleHTMLpart, menufoot, menuhead, messageid, messageid, mimeChange, mkmbox, mkmbox, moderate, modifytype, newMimeBodyPart, nntpServer, outpreview, page, setDefault, setDefaults, setUserValue, showatts, special, store, xform, xform, xform, xform
 
Methods inherited from class kom.gateway.News
addMem, bookmarks, checkNewMemb, checkUnseen, countmod, dispActNews, dispBook, dispCatNews, dispForumNews, dispLetterNews, dispModNews, dispMods, dispPersNews, dispSavedNews, dispSavedQueries, getRead, makeNews, markCat, markPres, markrecs, markSeen, newVote, nextUnread, putShort, storeNews, threadno
 
Methods inherited from class kom.gateway.Grade
catover, cretab, fetchGrade, fetchRate, getEvaluation, getgrade, isTeacher, listover, newGrade, printRatings, showcat, showgrades, shownumbers, showover, showstud, showuser
 
Methods inherited from class kom.gateway.Chat
addChat, chat, chatFetch, chatHeader, chatIndex, chatInput, chatList, chatOut, chatOutput, chatStore, checkEnter, enter, isActive, leave, leaveChat, pres, qchat, setUser, transform
 
Methods inherited from class kom.gateway.Form
, add, addBody, addv, checkHTML, checkHTTP, checkTag, checkVote, complete, contains, dispauth, dispbody, dispcheck, dispname, dispselect, disptype, form, form, form, form, formsegment, getAreaResult, getForm, getHTML, getOutputText, getQryValues, getResultBox, getResultText, getSelect1, getSelect2, getSelectResult, getTag, getVote, getVoteArea, getVoteCheck, getVoteSelect, getVoteSubmit, getVoteTag, getVoteText, insertSelect, makeHTML, nextmatching, normalize, restoreOutput, saveOutput, textareaSubst, transform, translate, trbody
 
Methods inherited from class kom.gateway.KOMutil
a, accessCont, accessCont, accessObj, addInfoData, addrToLocal, changeEnvironment, cidReplace, contType, decodeText, deleted, dispMailMessage, doAction, equal, excluded, fetchNews, findId, findId, findlocal, findLogin, findOwner, findUser, getActId, getcont, getcont, getcontV, getcontV, getCurNgd, getmemb, getMsgParts, getMsgText, getNews, getNewsAuth, getobj, getobject, getold, getParent, getPart, getSimpleFileName, getSimpleFileName, getStream, getTail, getTextPart, getVal, getVal, isAllowed, isarg, isMember, isOrganizer, isOrganizer, ispunct, isType, isValidEmailAddress, loggedIn, mailDate, mailDate, mimeMessage, mimeMessageStream, mkdate, mkdate, noQuote, parseArglist, parseArgs, setCids, setNewsAuth, setValidMsgPwd, showBody, showHeader, showHeader, showHeaders, showInputStream, showMailMessage, showMessage, showMultipart, toString, transbody, urlexpand, userGavePassword, userGavePassword, wrap
 
Methods inherited from class kom.gateway.DBHigh
addContent, addContent, addDraft, addInfo, addLast, addMember, addNews, addObj, addObj, addObject, addObject, addQuery, cleanDrafts, contentCount, createNews, depth, expungeRef, findContent, findDraft, findDraftData, findInfo, findMemb, findNews, findObject, findObject, findQuery, getFormContents, getQryDefault, getQueries, getseq, getStringValues, getValues, invalidateCount, isEmpty, isStandard, listDraft, makeArea, modObject, msgExists, nextDraft, queryExists, ref2path, refExists, removeDraft, removeQuery, replaceObject, Stream2String, String2Stream, StringBuffer2Stream, updateCount, updCount, updref, updseq
 
Methods inherited from class kom.gateway.DBLow
accessPart, addFile, areaExists, basedRef, createArea, errorLog, expungeFile, File2Stream, File2String, findPart, getFile, getFileContents, getFileStream, getPath, getStandard, isMailSpool, lastModified, length, listFiles, makePart, msgPartStream, partfile, partpath, printStackTrace, readObject, removeFile, replaceMime, updseq1, validate, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

oldmsgs

static MsgIdTable oldmsgs
Msgid vs local obj ref

thread

protected java.lang.Thread thread
Thread for mail checking

stopped

boolean stopped
Set to true to stop the thread

sleeping

private boolean sleeping
True if thread is not awake

mailCheckingInterval

long mailCheckingInterval
Interval for checking incoming mail (ms). The parameter value in the server configuration is given in seconds.

mailDir

java.lang.String mailDir
Spool directory for incoming mail files

headerFileNamePrefix

static final java.lang.String headerFileNamePrefix
Header files have this name prefix

orcpts

private java.util.Vector orcpts
Old recipients, taken from existing headers
Constructor Detail

GetMail

public GetMail(ServerConfig conf,
               HTTPResponse response,
               Gateway gateway)
Constructor.
Parameters:
conf - Configuration data
Method Detail

stop

public void stop()
Tells the GetMail thread to stop running

checkMail

public void checkMail()
Checks for new mail and tries to deliver it to the "mailboxes" of the recipients, removing the mail files after delivery.

deliver

public void deliver(GetMail.MessageDelivery msd)
Looks up recipients and tries to deliver message from mail file.
Parameters:
fn - Header ("HD.*") file name in mail spool directory

deliverMail

public boolean deliverMail(GetMail.MessageDelivery msd)
Looks up recipients and tries to deliver message from mail file (mailSpoolFile) to recipients according to the mailTo vector.

localObject

public java.lang.String localObject(java.lang.String msgid)
Gets a possible local object corresponding to a message id
Parameters:
msgid - Message id
Returns:
Old object if msgid corresponds to an existing local message

insertMessage

public KomData insertMessage(javax.mail.internet.MimeMessage msg,
                             java.lang.String ref,
                             java.lang.String msgid,
                             java.util.Vector rcv,
                             GetMail.MessageDelivery msd,
                             KomData orcpt,
                             KomData newrcpts)
Makes a Message object from the contents of a mailbox and delivers the message to the recipients
Parameters:
msg - MimeMessage object
ref - /mail/nn/
rcv - Vector of recipients (validated as existing)
Returns:
Message object table

setFrom

private final void setFrom(KomData obj,
                           javax.mail.internet.MimeMessage msg)
                    throws javax.mail.MessagingException

addRcpt

private final void addRcpt(java.lang.String pr,
                           java.lang.String pnum,
                           KomData rto,
                           java.util.Hashtable hrecs,
                           KomData obj,
                           KomData newrcpts)

getHeaderRecs

private java.util.Hashtable getHeaderRecs(KomData obj,
                                          javax.mail.internet.MimeMessage msg,
                                          java.lang.String[] rid)

edistribute

private void edistribute(KomData obj)
Distributes an incoming email message to its recipients
Parameters:
obj - Message object

noEol

java.lang.String noEol(java.lang.String line)
Replaces any eol characters by space
Parameters:
line - String
Returns:
cleaned-up string

mkrecop

public KomData mkrecop(KomData r)

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Implements FilenameFilter
Specified by:
accept in interface java.io.FilenameFilter

run

public void run()
Thread control loop. Checks for new mail every mailCheckingInterval milliseconds
Specified by:
run in interface java.lang.Runnable

debugLog

void debugLog(java.lang.String s)
Overrides:
debugLog in class DBLow