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:
17: package org.columba.mail.filter.plugins;
18:
19: import java.io.File;
20: import java.net.URL;
21:
22: import org.columba.api.command.ICommand;
23: import org.columba.api.command.ICommandReference;
24: import org.columba.api.command.IWorkerStatusController;
25: import org.columba.core.command.Command;
26: import org.columba.core.filter.AbstractFilterAction;
27: import org.columba.core.filter.IFilterAction;
28: import org.columba.core.folder.DefaultFolderCommandReference;
29: import org.columba.core.folder.api.IFolder;
30:
31: /**
32: * @author freddy
33: *
34: * To change this generated comment edit the template variable "typecomment":
35: * Window>Preferences>Java>Templates.
36: * To enable and disable the creation of type comments go to
37: * Window>Preferences>Java>Code Generation.
38: */
39: public class PlaySoundFilterAction extends AbstractFilterAction {
40:
41: /**
42: * @see org.columba.mail.filter.plugins.AbstractFilterAction#getCommand()
43: */
44: public ICommand getCommand(IFilterAction filterAction,
45: IFolder srcFolder, Object[] uids) throws Exception {
46:
47: // just a simple example
48: for (int i = 0; i < uids.length; i++) {
49: System.out
50: .println("Hello World for message-uid=" + uids[i]);
51: }
52:
53: // for time consuming tasks you need to create
54: // your own Command
55:
56: DefaultFolderCommandReference r = new DefaultFolderCommandReference(
57: srcFolder, uids);
58:
59: PlaySoundCommand c = new PlaySoundCommand(r);
60:
61: return c;
62:
63: }
64:
65: /**
66: *
67: * @author freddy
68: *
69: * To change this generated comment edit the template variable "typecomment":
70: * Window>Preferences>Java>Templates.
71: * To enable and disable the creation of type comments go to
72: * Window>Preferences>Java>Code Generation.
73: */
74: class PlaySoundCommand extends Command {
75: public PlaySoundCommand(ICommandReference reference) {
76: super (reference);
77: }
78:
79: public void execute(IWorkerStatusController worker)
80: throws Exception {
81:
82: // you need a sound.wav in your program folder
83: File soundFile = new File("sound.wav");
84: URL url = soundFile.toURL();
85:
86: PlaySound.play(url);
87: }
88: }
89: }
|