Changeset 470
- Timestamp:
- 07/19/09 16:02:17 (3 years ago)
- Location:
- trunk/LogicMail/src/org/logicprobe/LogicMail
- Files:
-
- 11 edited
-
LogicMail.rrc (modified) (1 diff)
-
LogicMail.rrh (modified) (1 diff)
-
mail/AbstractMailConnectionHandler.java (modified) (7 diffs)
-
mail/IncomingMailConnectionHandler.java (modified) (11 diffs)
-
mail/MailConnectionManager.java (modified) (1 diff)
-
mail/MailConnectionStatusEvent.java (modified) (2 diffs)
-
mail/OutgoingMailConnectionHandler.java (modified) (2 diffs)
-
message/MimeMessagePartFactory.java (modified) (1 diff)
-
message/MimeMessagePartTransformer.java (modified) (1 diff)
-
ui/BrowserFieldManager.java (modified) (1 diff)
-
ui/MessageScreen.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.rrc
r457 r470 68 68 MAILBOX_DELETE_PROMPT#0="Are you sure you want to delete this message?"; 69 69 MAILBOX_DRAFT_MULTIPLE_ACCOUNTS#0="Which account would you like this message to be sent from?"; 70 MAILCONNECTION_CLOSING_CONNECTION#0="Closing connection..."; 71 MAILCONNECTION_OPENING_CONNECTION#0="Opening connection..."; 72 MAILCONNECTION_REQUEST_FOLDER_MESSAGES#0="Getting folder messages..."; 73 MAILCONNECTION_REQUEST_FOLDER_STATUS#0="Refreshing folder status..."; 74 MAILCONNECTION_REQUEST_FOLDER_TREE#0="Getting folder tree..."; 75 MAILCONNECTION_REQUEST_MESSAGE#0="Loading message..."; 76 MAILCONNECTION_REQUEST_MESSAGE_ANSWERED#0="Updating message flags..."; 77 MAILCONNECTION_REQUEST_MESSAGE_APPEND#0="Storing message..."; 78 MAILCONNECTION_REQUEST_MESSAGE_DELETE#0="Deleting message..."; 79 MAILCONNECTION_REQUEST_MESSAGE_UNDELETE#0="Undeleting message..."; 80 MAILCONNECTION_REQUEST_SEND_MESSAGE#0="Sending message..."; 70 81 MAILHOME_NOACCOUNTS#0="No accounts"; 71 82 MAILHOME_TITLE#0="Home"; -
trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.rrh
r457 r470 161 161 MESSAGE_SAVING_ATTACHMENT#0=159; 162 162 MESSAGE_UNABLE_TO_SAVE_ATTACHMENT#0=160; 163 MAILCONNECTION_OPENING_CONNECTION#0=161; 164 MAILCONNECTION_CLOSING_CONNECTION#0=162; 165 MAILCONNECTION_REQUEST_SEND_MESSAGE#0=163; 166 MAILCONNECTION_REQUEST_FOLDER_TREE#0=164; 167 MAILCONNECTION_REQUEST_FOLDER_STATUS#0=165; 168 MAILCONNECTION_REQUEST_FOLDER_MESSAGES#0=166; 169 MAILCONNECTION_REQUEST_MESSAGE#0=167; 170 MAILCONNECTION_REQUEST_MESSAGE_DELETE#0=168; 171 MAILCONNECTION_REQUEST_MESSAGE_UNDELETE#0=169; 172 MAILCONNECTION_REQUEST_MESSAGE_ANSWERED#0=170; 173 MAILCONNECTION_REQUEST_MESSAGE_APPEND#0=171; -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/AbstractMailConnectionHandler.java
r351 r470 34 34 import java.io.IOException; 35 35 36 import net.rim.device.api.i18n.ResourceBundle; 36 37 import net.rim.device.api.system.EventLogger; 37 38 38 39 import org.logicprobe.LogicMail.AppInfo; 40 import org.logicprobe.LogicMail.LogicMailResource; 39 41 import org.logicprobe.LogicMail.util.Queue; 40 42 … … 45 47 */ 46 48 public abstract class AbstractMailConnectionHandler { 49 protected static ResourceBundle resources = ResourceBundle.getBundle(LogicMailResource.BUNDLE_ID, LogicMailResource.BUNDLE_NAME); 47 50 private MailClient client; 48 51 private ConnectionThread connectionThread; … … 195 198 */ 196 199 private void handleOpeningConnection() throws IOException, MailException { 197 showStatus( "Opening connection...");200 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_OPENING_CONNECTION)); 198 201 if(checkLogin(client)) { 199 202 if(client.open()) { … … 256 259 Object[] params = (Object[])request[1]; 257 260 258 // Handle the specific request 259 showStatus("Processing requests..."); 261 // Delegate to subclasses to handle the specific request 260 262 handleRequest(type, params); 261 263 … … 269 271 /** 270 272 * Handles a specific request during the REQUESTS state. 273 * <p> 271 274 * Subclasses should implement this to dispatch requests for all 272 275 * the request types they know how to handle. 276 * Subclasses should also call {@link #showStatus(String)} and/or 277 * {@link #showStatus(String, int)} as necessary to update the 278 * user on the status of the operation. 279 * </p> 273 280 * 274 281 * @param type Type identifier for the request. … … 325 332 */ 326 333 private void handleClosingConnection() throws IOException, MailException { 327 showStatus( "Closing connection...");334 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_CLOSING_CONNECTION)); 328 335 handleBeforeClosing(); 329 336 try { client.close(); } catch (IOException e) {} catch (MailException e) {} … … 398 405 * @param message The message to show 399 406 */ 400 pr ivatevoid showStatus(String message) {407 protected void showStatus(String message) { 401 408 MailConnectionManager.getInstance().fireMailConnectionStatus(client.getConnectionConfig(), message); 409 } 410 411 /** 412 * Show a status message with a progress percentage. 413 * 414 * @param message The message to show 415 * @param progress The progress percentage 416 */ 417 protected void showStatus(String message, int progress) { 418 MailConnectionManager.getInstance().fireMailConnectionStatus(client.getConnectionConfig(), message, progress); 402 419 } 403 420 -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/IncomingMailConnectionHandler.java
r467 r470 37 37 import net.rim.device.api.system.UnsupportedOperationException; 38 38 39 import org.logicprobe.LogicMail.LogicMailResource; 39 40 import org.logicprobe.LogicMail.message.FolderMessage; 40 41 import org.logicprobe.LogicMail.message.Message; … … 200 201 201 202 private void handleRequestFolderTree() throws IOException, MailException { 203 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_TREE)); 202 204 FolderTreeItem root = incomingClient.getFolderTree(); 203 205 … … 209 211 210 212 private void handleRequestFolderStatus(FolderTreeItem[] folders) throws IOException, MailException { 213 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_STATUS)); 211 214 incomingClient.refreshFolderStatus(folders); 212 215 … … 218 221 219 222 private void handleRequestFolderMessagesRange(FolderTreeItem folder, int firstIndex, int lastIndex) throws IOException, MailException { 223 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_MESSAGES)); 220 224 checkActiveFolder(folder); 221 225 … … 241 245 242 246 private void handleRequestFolderMessagesRecent(FolderTreeItem folder) throws IOException, MailException { 247 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_MESSAGES)); 243 248 checkActiveFolder(folder); 244 249 … … 252 257 253 258 private void handleRequestMessage(MessageToken messageToken) throws IOException, MailException { 259 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE)); 254 260 checkActiveFolder(messageToken); 255 261 … … 263 269 264 270 private void handleRequestMessageParts(MessageToken messageToken, MimeMessagePart[] messageParts) throws IOException, MailException { 271 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE)); 265 272 checkActiveFolder(messageToken); 266 273 … … 291 298 292 299 private void handleRequestMessageDelete(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 300 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_DELETE)); 293 301 checkActiveFolder(messageToken); 294 302 … … 302 310 303 311 private void handleRequestMessageUndelete(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 312 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_UNDELETE)); 304 313 checkActiveFolder(messageToken); 305 314 … … 313 322 314 323 private void handleRequestMessageAnswered(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 324 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_ANSWERED)); 315 325 // Replace this with a more general method: 316 326 if(incomingClient instanceof org.logicprobe.LogicMail.mail.imap.ImapClient) { … … 326 336 327 337 private void handleRequestMessageAppend(FolderTreeItem folder, String rawMessage, MessageFlags initialFlags) throws IOException, MailException { 338 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_APPEND)); 328 339 // Clean up this interface: 329 340 if(incomingClient instanceof org.logicprobe.LogicMail.mail.imap.ImapClient) { -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/MailConnectionManager.java
r237 r470 126 126 /** 127 127 * Notifies all registered <tt>MailConnectionListener</tt>s 128 * of an updated status message with a progress percentage. 129 * 130 * @param connectionConfig The configuration for the connection that generated this event. 131 * @param message The status message. 132 * @param progress The progress percentage. 133 */ 134 void fireMailConnectionStatus(ConnectionConfig connectionConfig, String message, int progress) { 135 Object[] listeners = listenerList.getListeners(MailConnectionListener.class); 136 MailConnectionStatusEvent e = null; 137 for(int i=0; i<listeners.length; i++) { 138 if(e == null) { 139 e = new MailConnectionStatusEvent( 140 this, connectionConfig, message, 141 MailConnectionStatusEvent.PROGRESS_MEASURED, progress); 142 } 143 ((MailConnectionListener)listeners[i]).mailConnectionStatus(e); 144 } 145 } 146 147 /** 148 * Notifies all registered <tt>MailConnectionListener</tt>s 128 149 * of an error with the mail connection. 129 150 * -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/MailConnectionStatusEvent.java
r237 r470 39 39 public class MailConnectionStatusEvent extends MailConnectionEvent { 40 40 private String message; 41 private int progressType; 42 private int progressPercentage; 41 43 42 /** Creates a new instance of MailConnectionStatusEvent */ 43 public MailConnectionStatusEvent(Object source, ConnectionConfig connectionConfig, String message) { 44 /** The progress is indeterminate. */ 45 public static final int PROGRESS_INDETERMINATE = 0; 46 /** The progress is measured incrementally. */ 47 public static final int PROGRESS_MEASURED = 0; 48 49 /** 50 * Creates a new instance of MailConnectionStatusEvent. 51 * 52 * @param source the source 53 * @param connectionConfig the connection configuration instance 54 * @param message the status message 55 * @param progressType the progress type 56 * @param progressPercentage the progress percentage 57 */ 58 public MailConnectionStatusEvent(Object source, ConnectionConfig connectionConfig, String message, int progressType, int progressPercentage) { 44 59 super(source, connectionConfig); 45 60 this.message = message; 61 this.progressType = progressType; 62 this.progressPercentage = progressPercentage; 46 63 } 47 64 48 65 /** 66 * Creates a new instance of MailConnectionStatusEvent 67 * with indeterminate progress. 68 * 69 * @param source the source 70 * @param connectionConfig the connection configuration instance 71 * @param message the status message 72 */ 73 public MailConnectionStatusEvent(Object source, ConnectionConfig connectionConfig, String message) { 74 this(source, connectionConfig, message, PROGRESS_INDETERMINATE, 0); 75 } 76 77 /** 49 78 * Gets the status message. 79 * 50 80 * @return Status message 51 81 */ … … 53 83 return message; 54 84 } 85 86 /** 87 * Gets the progress type. 88 * 89 * @return The progress type. 90 */ 91 public int getProgressType() { 92 return progressType; 93 } 94 95 /** 96 * Gets the progress percentage. 97 * Only valid if the progress type is <tt>PROGRESS_MEASURED</tt>. 98 * 99 * @return The progress percentage. 100 */ 101 public int getProgressPercentage() { 102 return progressPercentage; 103 } 55 104 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/mail/OutgoingMailConnectionHandler.java
r407 r470 5 5 import java.util.TimerTask; 6 6 7 import org.logicprobe.LogicMail.LogicMailResource; 7 8 import org.logicprobe.LogicMail.message.Message; 8 9 import org.logicprobe.LogicMail.message.MessageEnvelope; … … 94 95 95 96 private void handleRequestSendMessage(MessageEnvelope envelope, Message message) throws IOException, MailException { 97 showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_SEND_MESSAGE)); 96 98 String messageSource = outgoingClient.sendMessage(envelope, message); 97 99 -
trunk/LogicMail/src/org/logicprobe/LogicMail/message/MimeMessagePartFactory.java
r469 r470 110 110 /** 111 111 * Find out if a particular message part type is supported 112 * without having to create it. This is useful to optimize112 * as displayable content. This is useful to optimize 113 113 * downloads on protocols that support selective retrieval 114 114 * of message parts. -
trunk/LogicMail/src/org/logicprobe/LogicMail/message/MimeMessagePartTransformer.java
r467 r470 172 172 } 173 173 174 // TODO: Add ApplicationPart, AudioPart, VideoPart, and MessagePart 174 public void visitApplicationPart(ApplicationPart part) { 175 attachmentParts.addElement(part); 176 } 177 178 public void visitAudioPart(AudioPart part) { 179 attachmentParts.addElement(part); 180 } 181 182 public void visitVideoPart(VideoPart part) { 183 attachmentParts.addElement(part); 184 } 175 185 } 176 186 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/BrowserFieldManager.java
r453 r470 35 35 import net.rim.device.api.ui.FieldChangeListener; 36 36 import net.rim.device.api.ui.MenuItem; 37 import net.rim.device.api.ui.XYRect;38 37 import net.rim.device.api.ui.component.Menu; 39 38 import net.rim.device.api.ui.container.VerticalFieldManager; -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageScreen.java
r467 r470 426 426 // TODO: Support on-demand downloading of additional content 427 427 MimeMessageContent content = messageNode.getMessageContent(contentPart); 428 if(content != null) { 429 FileSaveDialog dialog = new FileSaveDialog(contentPart.getName()); 430 if(dialog.doModal() != Dialog.CANCEL) { 431 (new SaveAttachmentThread(content, dialog.getFileUrl())).start(); 432 Status.show(resources.getString(LogicMailResource.MESSAGE_SAVING_ATTACHMENT)); 433 } 434 } 428 FileSaveDialog dialog = new FileSaveDialog(contentPart.getName()); 429 if(dialog.doModal() != Dialog.CANCEL) { 430 if(content != null) { 431 // Content has been downloaded already, so just save it 432 (new SaveAttachmentThread(content, dialog.getFileUrl())).start(); 433 Status.show(resources.getString(LogicMailResource.MESSAGE_SAVING_ATTACHMENT)); 434 } 435 else { 436 // Download content from server, then save it 437 // TODO: Implement on-demand attachment downloading 438 Status.show("Attachment has not been downloaded from the server"); 439 } 440 } 435 441 } 436 442
Note: See TracChangeset
for help on using the changeset viewer.
