BrightSide Workbench Full Report + Source Code
org.turro.mail.reader.MailReader Class Reference
Inheritance diagram for org.turro.mail.reader.MailReader:
Collaboration diagram for org.turro.mail.reader.MailReader:

Public Member Functions

 MailReader ()
 
boolean isReadOnly ()
 
boolean isSeen (Message message)
 
void seen (Message message)
 
void delete (Message message)
 
void close ()
 
Message[] getMessages ()
 
- Public Member Functions inherited from org.turro.elephant.impl.abstracts.AbstractImplementation
 AbstractImplementation ()
 
void setElement (IElement element)
 
void setConstructor (IConstructor constructor)
 
void setConfiguration (Element configuration)
 
KeyValueMap getAttributes ()
 
Long getLongAttribute (String key)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.elephant.impl.abstracts.AbstractImplementation
IElement iel
 
IConstructor constructor
 
Element configuration
 
Map attributes
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file MailReader.java.

Constructor & Destructor Documentation

◆ MailReader()

org.turro.mail.reader.MailReader.MailReader ( )

Definition at line 42 of file MailReader.java.

42  {
43  }

Member Function Documentation

◆ close()

void org.turro.mail.reader.MailReader.close ( )

Definition at line 74 of file MailReader.java.

74  {
75  try {
76  if (emailFolder != null) {
77  emailFolder.close(false);
78  }
79  if (store != null) {
80  store.close();
81  }
82  } catch (MessagingException ex) {
83  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
84  }
85  }
Here is the call graph for this function:

◆ delete()

void org.turro.mail.reader.MailReader.delete ( Message  message)

Definition at line 66 of file MailReader.java.

66  {
67  try {
68  message.setFlag(Flags.Flag.DELETED, true);
69  } catch (MessagingException ex) {
70  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
71  }
72  }
Here is the call graph for this function:

◆ getMessages()

Message [] org.turro.mail.reader.MailReader.getMessages ( )

Definition at line 87 of file MailReader.java.

87  {
88  try {
89  KeyValueMap kvm = getAttributes();
90  Properties properties = new Properties();
91 
92  if(kvm.get("type").startsWith("pop3")) {
93  properties.put("mail.pop3.host", kvm.get("mailhost"));
94  properties.put("mail.pop3.port", kvm.get("port"));
95  properties.put("mail.pop3.starttls.enable", kvm.get("tls"));
96  properties.put("mail.pop3.ssl.enable", kvm.get("ssl"));
97  } else if(kvm.get("type").startsWith("imap")) {
98  properties.put("mail.imap.host", kvm.get("mailhost"));
99  properties.put("mail.imap.port", kvm.get("port"));
100  properties.put("mail.imap.starttls.enable", kvm.get("tls"));
101  properties.put("mail.imap.ssl.enable", kvm.get("ssl"));
102  }
103  Session emailSession = Session.getDefaultInstance(properties);
104 
105  store = emailSession.getStore(kvm.get("type"));
106 
107  String password = kvm.get("password");
108  if (password == null) {
109  try {
110  password = ElephantContext.decrypt(kvm.get("cryptpass"));
111  } catch (Exception ex) {
112  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
113  }
114  }
115  store.connect(
116  kvm.get("mailhost"),
117  kvm.get(Integer.class, "port"),
118  kvm.get("user"),
119  password);
120 
121  emailFolder = store.getFolder(kvm.get(String.class, "folder", "INBOX"));
122  emailFolder.open(Folder.READ_WRITE);
123 
124  int count = kvm.get(Integer.class, "count", 50) - 1;
125 
126  int messageCount = emailFolder.getMessageCount();
127 
128  return emailFolder.getMessages(messageCount - count, messageCount);
129  } catch (MessagingException ex) {
130  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
131  }
132  return null;
133  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReadOnly()

boolean org.turro.mail.reader.MailReader.isReadOnly ( )

Definition at line 45 of file MailReader.java.

45  {
46  return getAttributes().get("type").startsWith("pop3");
47  }
Here is the call graph for this function:

◆ isSeen()

boolean org.turro.mail.reader.MailReader.isSeen ( Message  message)

Definition at line 49 of file MailReader.java.

49  {
50  try {
51  return message.isSet(Flags.Flag.SEEN);
52  } catch (MessagingException ex) {
53  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
54  }
55  return false;
56  }
Here is the call graph for this function:

◆ seen()

void org.turro.mail.reader.MailReader.seen ( Message  message)

Definition at line 58 of file MailReader.java.

58  {
59  try {
60  message.setFlag(Flags.Flag.SEEN, true);
61  } catch (MessagingException ex) {
62  Logger.getLogger(MailReader.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
63  }
64  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: