Source Code Cross Referenced for MailMain.java in  » Mail-Clients » columba-1.4 » org » columba » mail » main » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.mail.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014:        //
015:        //All Rights Reserved.
016:        package org.columba.mail.main;
017:
018:        import java.awt.BorderLayout;
019:        import java.util.logging.Logger;
020:
021:        import javax.swing.JCheckBox;
022:        import javax.swing.JOptionPane;
023:        import javax.swing.JPanel;
024:
025:        import org.apache.commons.cli.CommandLine;
026:        import org.apache.commons.cli.Option;
027:        import org.apache.commons.cli.OptionBuilder;
028:        import org.columa.core.config.IDefaultItem;
029:        import org.columba.api.plugin.PluginLoadingFailedException;
030:        import org.columba.core.backgroundtask.BackgroundTaskManager;
031:        import org.columba.core.component.api.IComponentPlugin;
032:        import org.columba.core.config.DefaultItem;
033:        import org.columba.core.connectionstate.ConnectionStateImpl;
034:        import org.columba.core.facade.ServiceFacadeRegistry;
035:        import org.columba.core.gui.base.MultiLineLabel;
036:        import org.columba.core.gui.frame.DefaultContainer;
037:        import org.columba.core.gui.frame.FrameManager;
038:        import org.columba.core.main.ColumbaCmdLineParser;
039:        import org.columba.core.shutdown.ShutdownManager;
040:        import org.columba.mail.config.IncomingItem;
041:        import org.columba.mail.config.MailConfig;
042:        import org.columba.mail.facade.DialogFacade;
043:        import org.columba.mail.folder.IMailFolder;
044:        import org.columba.mail.folder.virtual.ActivateVirtualFolderCommand;
045:        import org.columba.mail.gui.composer.ComposerController;
046:        import org.columba.mail.gui.composer.ComposerModel;
047:        import org.columba.mail.gui.config.accountwizard.AccountWizardLauncher;
048:        import org.columba.mail.gui.tree.FolderTreeModel;
049:        import org.columba.mail.nativ.defaultmailclient.SystemDefaultMailClientHandler;
050:        import org.columba.mail.parser.MailUrlParser;
051:        import org.columba.mail.pgp.MultipartEncryptedRenderer;
052:        import org.columba.mail.pgp.MultipartSignedRenderer;
053:        import org.columba.mail.shutdown.ClearRecentFlagPlugin;
054:        import org.columba.mail.shutdown.SaveAllFoldersPlugin;
055:        import org.columba.mail.shutdown.SavePOP3CachePlugin;
056:        import org.columba.mail.spam.SaveSpamDBPlugin;
057:        import org.columba.mail.util.MailResourceLoader;
058:        import org.columba.ristretto.composer.MimeTreeRenderer;
059:        import org.columba.ristretto.parser.ParserException;
060:
061:        /**
062:         * Main entrypoint for mail component.
063:         *
064:         * @author fdietz
065:         */
066:        public class MailMain implements  IComponentPlugin {
067:            /** JDK 1.4+ logging framework logger, used for logging. */
068:            private static final Logger LOG = Logger
069:                    .getLogger("org.columba.mail.main");
070:
071:            public MailMain() {
072:            }
073:
074:            /**
075:             *
076:             */
077:            public void init() {
078:                // Init PGP
079:                MimeTreeRenderer renderer = MimeTreeRenderer.getInstance();
080:                renderer.addMimePartRenderer(new MultipartSignedRenderer());
081:                renderer.addMimePartRenderer(new MultipartEncryptedRenderer());
082:
083:                // Init Plugins
084:                /*PluginManager.getInstance().addHandlers(
085:                		"org/columba/mail/plugin/pluginhandler.xml");
086:
087:                try {
088:                	InputStream is = this.getClass().getResourceAsStream(
089:                			"/org/columba/mail/action/action.xml");
090:                	PluginManager.getInstance().getHandler(IExtensionHandlerKeys.ORG_COLUMBA_CORE_ACTION)
091:                			.loadExtensionsFromStream(is);
092:                } catch (PluginHandlerNotFoundException ex) {
093:                	ex.printStackTrace();
094:                }*/
095:
096:                Runnable plugin = new SaveAllFoldersPlugin();
097:                BackgroundTaskManager.getInstance().register(plugin);
098:
099:                plugin = new SavePOP3CachePlugin();
100:                BackgroundTaskManager.getInstance().register(plugin);
101:                ShutdownManager.getInstance().register(plugin);
102:
103:                plugin = new SaveSpamDBPlugin();
104:                BackgroundTaskManager.getInstance().register(plugin);
105:                ShutdownManager.getInstance().register(plugin);
106:
107:                plugin = new ClearRecentFlagPlugin();
108:                ShutdownManager.getInstance().register(plugin);
109:
110:                ServiceFacadeRegistry.getInstance().register(
111:                        org.columba.mail.facade.IDialogFacade.class,
112:                        new DialogFacade());
113:            }
114:
115:            public void registerCommandLineArguments() {
116:                ColumbaCmdLineParser parser = ColumbaCmdLineParser
117:                        .getInstance();
118:
119:                Option composeOption = new Option("compose", true,
120:                        "compose message");
121:                parser.addOption(composeOption);
122:
123:                Option mailOption = OptionBuilder.create("mail");
124:                mailOption.setOptionalArg(true);
125:
126:                parser.addOption(mailOption);
127:            }
128:
129:            /**
130:             * @see org.columba.core.component.api.IComponentPlugin#handleCommandLineParameters(java.lang.String[])
131:             */
132:            public void handleCommandLineParameters(CommandLine commandLine) {
133:
134:                if (commandLine.hasOption("mail")) {
135:                    // check if the optional value exists
136:                    if (commandLine.getOptionValue("mail") != null) {
137:                        try {
138:                            ComposerModel model = new ComposerModel(
139:                                    MailUrlParser.parse(commandLine
140:                                            .getOptionValue("mail")));
141:
142:                            // new NewMessageAction().actionPerformed(null);
143:                            ComposerController controller = new ComposerController();
144:                            new DefaultContainer(controller);
145:
146:                            controller.setComposerModel(model);
147:
148:                            ColumbaCmdLineParser.getInstance()
149:                                    .setRestoreLastSession(false);
150:                        } catch (ParserException e1) {
151:                            LOG.warning(e1.getLocalizedMessage());
152:                        }
153:                    } else {
154:                        try {
155:                            FrameManager.getInstance()
156:                                    .openView("ThreePaneMail");
157:
158:                            ColumbaCmdLineParser.getInstance()
159:                                    .setRestoreLastSession(false);
160:                        } catch (PluginLoadingFailedException e) {
161:                            LOG.severe(e.getLocalizedMessage());
162:                        }
163:                    }
164:                }
165:
166:                if (commandLine.hasOption("compose")) {
167:                    String option = commandLine.getOptionValue("compose");
168:                    ComposerModel model = new ComposerModel(MessageOptionParser
169:                            .parse(option));
170:
171:                    ComposerController controller = new ComposerController();
172:                    new DefaultContainer(controller);
173:
174:                    controller.setComposerModel(model);
175:
176:                    ColumbaCmdLineParser.getInstance().setRestoreLastSession(
177:                            false);
178:                }
179:            }
180:
181:            /**
182:             *
183:             */
184:            public void postStartup() {
185:                // Check default mail client
186:                checkDefaultClient();
187:
188:                // Show first time Account Wizard
189:                if (MailConfig.getInstance().getAccountList().count() == 0) {
190:                    new AccountWizardLauncher().launchWizard(true);
191:                }
192:
193:                // Check Internet Connection
194:                if (MailConfig.getInstance().getAccountList().count() > 0) {
195:                    try {
196:                        IncomingItem testConnection = MailConfig.getInstance()
197:                                .getAccountList().getDefaultAccount()
198:                                .getIncomingItem();
199:                        ConnectionStateImpl.getInstance().setTestConnection(
200:                                testConnection.get("host"),
201:                                testConnection.getInteger("port"));
202:                        ConnectionStateImpl.getInstance().checkPhysicalState();
203:                    } catch (RuntimeException e) {
204:                        e.printStackTrace();
205:                    }
206:                }
207:
208:                // Activate all Virtual Folders
209:                ActivateVirtualFolderCommand
210:                        .activateAll((IMailFolder) FolderTreeModel
211:                                .getInstance().getRoot());
212:            }
213:
214:            private void checkDefaultClient() {
215:                // Check if Columba is the default mail client
216:                SystemDefaultMailClientHandler defaultClientHandler = new SystemDefaultMailClientHandler();
217:                IDefaultItem item = new DefaultItem(MailConfig.getInstance()
218:                        .get("options"));
219:
220:                boolean checkDefault = item.getBooleanWithDefault(
221:                        "options/defaultclient", "check", true);
222:
223:                if (checkDefault
224:                        && defaultClientHandler
225:                                .platfromSupportsDefaultMailClient()) {
226:                    if (!defaultClientHandler.isDefaultMailClient()) {
227:
228:                        JPanel panel = new JPanel(new BorderLayout(0, 10));
229:
230:                        panel.add(new MultiLineLabel(MailResourceLoader
231:                                .getString("dialog", "defaultclient",
232:                                        "make_default")), BorderLayout.NORTH);
233:
234:                        JCheckBox askAgain = new JCheckBox(MailResourceLoader
235:                                .getString("dialog", "defaultclient",
236:                                        "ask_no_more"));
237:                        panel.add(askAgain, BorderLayout.CENTER);
238:
239:                        // Some error in the client/server communication
240:                        // --> fall back to default login process
241:
242:                        // @author hubms: wait until the first frame is displayable
243:                        // fix for bug [#CA-177]
244:                        while (!(FrameManager.getInstance().getActiveFrame()
245:                                .isDisplayable())) {
246:                            try {
247:                                Thread.sleep(100);
248:                            } catch (InterruptedException e) {
249:                                LOG.severe(e.getMessage());
250:                            }
251:                        }
252:
253:                        // fix for bug [#CA-199] java 1.6.0-b105 trick
254:                        if (!FrameManager.getInstance().getActiveFrame()
255:                                .isValid())
256:                            FrameManager.getInstance().getActiveFrame()
257:                                    .doLayout();
258:
259:                        int result = JOptionPane.showConfirmDialog(FrameManager
260:                                .getInstance().getActiveFrame(), panel,
261:                                MailResourceLoader.getString("dialog",
262:                                        "defaultclient", "title"),
263:                                JOptionPane.YES_NO_OPTION);
264:                        if (result == JOptionPane.OK_OPTION) {
265:                            defaultClientHandler.setDefaultMailClient();
266:                        }
267:
268:                        item.setBoolean("options/defaultclient", "check",
269:                                !askAgain.isSelected());
270:                    }
271:                }
272:            }
273:
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.