01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.mail.filter.plugins;
17:
18: import org.columba.api.command.ICommand;
19: import org.columba.core.filter.AbstractFilterAction;
20: import org.columba.core.filter.FilterAction;
21: import org.columba.core.filter.IFilterAction;
22: import org.columba.core.folder.api.IFolder;
23: import org.columba.mail.command.MailFolderCommandReference;
24: import org.columba.mail.folder.command.MarkMessageCommand;
25:
26: /**
27: * @author freddy
28: *
29: * To change this generated comment edit the template variable "typecomment":
30: * Window>Preferences>Java>Templates. To enable and disable the creation of type
31: * comments go to Window>Preferences>Java>Code Generation.
32: */
33: public class MarkMessageAsReadAction extends AbstractFilterAction {
34: /**
35: * @see org.columba.modules.mail.filter.action.AbstractFilterAction#execute()
36: */
37: public ICommand getCommand(IFilterAction filterAction,
38: IFolder srcFolder, Object[] uids) throws Exception {
39: MailFolderCommandReference r = new MailFolderCommandReference(
40: srcFolder, uids);
41:
42: String variant = filterAction.get("markvariant");
43:
44: if (variant.equals("read")) {
45: r.setMarkVariant(MarkMessageCommand.MARK_AS_READ);
46: } else if (variant.equals("unread")) {
47: r.setMarkVariant(MarkMessageCommand.MARK_AS_UNREAD);
48: } else if (variant.equals("flagged")) {
49: r.setMarkVariant(MarkMessageCommand.MARK_AS_FLAGGED);
50: } else if (variant.equals("not_flagged")) {
51: r.setMarkVariant(MarkMessageCommand.MARK_AS_UNFLAGGED);
52: } else if (variant.equals("expunged")) {
53: r.setMarkVariant(MarkMessageCommand.MARK_AS_EXPUNGED);
54: } else if (variant.equals("not_expunged")) {
55: r.setMarkVariant(MarkMessageCommand.MARK_AS_UNEXPUNGED);
56: } else if (variant.equals("answered")) {
57: r.setMarkVariant(MarkMessageCommand.MARK_AS_ANSWERED);
58: } else if (variant.equals("spam")) {
59: r.setMarkVariant(MarkMessageCommand.MARK_AS_SPAM);
60: } else if (variant.equals("no_spam")) {
61: r.setMarkVariant(MarkMessageCommand.MARK_AS_NOTSPAM);
62: }
63: // if something goes wrong here, fall back to "mark as read"
64: else {
65: r.setMarkVariant(MarkMessageCommand.MARK_AS_READ);
66: }
67:
68: MarkMessageCommand c = new MarkMessageCommand(r);
69:
70: return c;
71: }
72: }
|