Ignore:
Timestamp:
04/16/19 16:06:37 (5 years ago)
Author:
bln4
Message:

You can now check for new mail while logged in (when you open the mail bay)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/auth/Mail.java

    r1294 r1320  
    3434import javax.crypto.NoSuchPaddingException;
    3535
     36import org.expeditee.auth.gui.MailBay;
    3637import org.expeditee.gui.FrameIO;
    3738import org.expeditee.settings.UserSettings;
     
    5556        public static void sendMail(MailEntry mail, String colleagueName) {
    5657                // Ensure dead drop area is set up.
    57                 Path databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(UserSettings.UserName.get() + "+" + colleagueName);
     58                String me = UserSettings.UserName.get().toLowerCase();
     59                String them = colleagueName.toLowerCase();
     60                Path databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(me + "+" + them);
     61                if (!databaseFileDirPath.toFile().exists()) {
     62                        databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(them + "+" + me);
     63                }
    5864                Path databaseFilePath = databaseFileDirPath.resolve(colleagueName + ".db");
    5965                File databaseFile = databaseFilePath.toFile();
     
    234240                }
    235241        }
     242
     243        public static void checkMail(PrivateKey key) throws NoSuchAlgorithmException, NoSuchPaddingException,
     244                        IllegalBlockSizeException, BadPaddingException, InvalidKeyException, KeyStoreException,
     245                        FileNotFoundException, CertificateException, IOException, ClassNotFoundException, SQLException, ParseException {
     246                MailBay.clear();
     247                AuthenticatorBrowser.getInstance().loadMailDatabase();
     248                List<MailEntry> mailForLoggingInUser = Mail.getEntries(UserSettings.UserName.get(), key);                       
     249                for (MailEntry mail: mailForLoggingInUser) {
     250                        MailBay.addMessage(mail.timestamp, mail.message, mail.message2, mail.options);
     251                }
     252               
     253                // Update last read files.
     254                Path deadDropPath = Paths.get(FrameIO.DEAD_DROPS_PATH);
     255                for (File connectionDir: deadDropPath.toFile().listFiles()) {
     256                        if (connectionDir.isDirectory()) {
     257                                Path deaddropforcontactPath = Paths.get(connectionDir.getAbsolutePath());
     258                                AuthenticatorBrowser.getInstance().updateLastReadMailTime(deaddropforcontactPath);
     259                        }
     260                }
     261        }
    236262}
Note: See TracChangeset for help on using the changeset viewer.