Changeset 470


Ignore:
Timestamp:
07/19/09 16:02:17 (3 years ago)
Author:
octorian
Message:

More detailed progress

Location:
trunk/LogicMail/src/org/logicprobe/LogicMail
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.rrc

    r457 r470  
    6868MAILBOX_DELETE_PROMPT#0="Are you sure you want to delete this message?"; 
    6969MAILBOX_DRAFT_MULTIPLE_ACCOUNTS#0="Which account would you like this message to be sent from?"; 
     70MAILCONNECTION_CLOSING_CONNECTION#0="Closing connection..."; 
     71MAILCONNECTION_OPENING_CONNECTION#0="Opening connection..."; 
     72MAILCONNECTION_REQUEST_FOLDER_MESSAGES#0="Getting folder messages..."; 
     73MAILCONNECTION_REQUEST_FOLDER_STATUS#0="Refreshing folder status..."; 
     74MAILCONNECTION_REQUEST_FOLDER_TREE#0="Getting folder tree..."; 
     75MAILCONNECTION_REQUEST_MESSAGE#0="Loading message..."; 
     76MAILCONNECTION_REQUEST_MESSAGE_ANSWERED#0="Updating message flags..."; 
     77MAILCONNECTION_REQUEST_MESSAGE_APPEND#0="Storing message..."; 
     78MAILCONNECTION_REQUEST_MESSAGE_DELETE#0="Deleting message..."; 
     79MAILCONNECTION_REQUEST_MESSAGE_UNDELETE#0="Undeleting message..."; 
     80MAILCONNECTION_REQUEST_SEND_MESSAGE#0="Sending message..."; 
    7081MAILHOME_NOACCOUNTS#0="No accounts"; 
    7182MAILHOME_TITLE#0="Home"; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.rrh

    r457 r470  
    161161MESSAGE_SAVING_ATTACHMENT#0=159; 
    162162MESSAGE_UNABLE_TO_SAVE_ATTACHMENT#0=160; 
     163MAILCONNECTION_OPENING_CONNECTION#0=161; 
     164MAILCONNECTION_CLOSING_CONNECTION#0=162; 
     165MAILCONNECTION_REQUEST_SEND_MESSAGE#0=163; 
     166MAILCONNECTION_REQUEST_FOLDER_TREE#0=164; 
     167MAILCONNECTION_REQUEST_FOLDER_STATUS#0=165; 
     168MAILCONNECTION_REQUEST_FOLDER_MESSAGES#0=166; 
     169MAILCONNECTION_REQUEST_MESSAGE#0=167; 
     170MAILCONNECTION_REQUEST_MESSAGE_DELETE#0=168; 
     171MAILCONNECTION_REQUEST_MESSAGE_UNDELETE#0=169; 
     172MAILCONNECTION_REQUEST_MESSAGE_ANSWERED#0=170; 
     173MAILCONNECTION_REQUEST_MESSAGE_APPEND#0=171; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/AbstractMailConnectionHandler.java

    r351 r470  
    3434import java.io.IOException; 
    3535 
     36import net.rim.device.api.i18n.ResourceBundle; 
    3637import net.rim.device.api.system.EventLogger; 
    3738 
    3839import org.logicprobe.LogicMail.AppInfo; 
     40import org.logicprobe.LogicMail.LogicMailResource; 
    3941import org.logicprobe.LogicMail.util.Queue; 
    4042 
     
    4547 */ 
    4648public abstract class AbstractMailConnectionHandler { 
     49        protected static ResourceBundle resources = ResourceBundle.getBundle(LogicMailResource.BUNDLE_ID, LogicMailResource.BUNDLE_NAME); 
    4750        private MailClient client; 
    4851        private ConnectionThread connectionThread; 
     
    195198     */ 
    196199        private void handleOpeningConnection() throws IOException, MailException { 
    197                 showStatus("Opening connection..."); 
     200                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_OPENING_CONNECTION)); 
    198201                if(checkLogin(client)) { 
    199202                        if(client.open()) { 
     
    256259                        Object[] params = (Object[])request[1]; 
    257260                         
    258                         // Handle the specific request 
    259                         showStatus("Processing requests..."); 
     261                        // Delegate to subclasses to handle the specific request 
    260262                        handleRequest(type, params); 
    261263                         
     
    269271        /** 
    270272         * Handles a specific request during the REQUESTS state. 
     273         * <p> 
    271274         * Subclasses should implement this to dispatch requests for all 
    272275         * 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> 
    273280         *  
    274281         * @param type Type identifier for the request. 
     
    325332     */ 
    326333        private void handleClosingConnection() throws IOException, MailException { 
    327                 showStatus("Closing connection..."); 
     334                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_CLOSING_CONNECTION)); 
    328335                handleBeforeClosing(); 
    329336                try { client.close(); } catch (IOException e) {} catch (MailException e) {} 
     
    398405         * @param message The message to show 
    399406         */ 
    400         private void showStatus(String message) { 
     407        protected void showStatus(String message) { 
    401408                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); 
    402419        } 
    403420         
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/IncomingMailConnectionHandler.java

    r467 r470  
    3737import net.rim.device.api.system.UnsupportedOperationException; 
    3838 
     39import org.logicprobe.LogicMail.LogicMailResource; 
    3940import org.logicprobe.LogicMail.message.FolderMessage; 
    4041import org.logicprobe.LogicMail.message.Message; 
     
    200201 
    201202        private void handleRequestFolderTree() throws IOException, MailException { 
     203                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_TREE)); 
    202204                FolderTreeItem root = incomingClient.getFolderTree(); 
    203205 
     
    209211         
    210212        private void handleRequestFolderStatus(FolderTreeItem[] folders) throws IOException, MailException { 
     213                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_STATUS)); 
    211214                incomingClient.refreshFolderStatus(folders); 
    212215                 
     
    218221         
    219222        private void handleRequestFolderMessagesRange(FolderTreeItem folder, int firstIndex, int lastIndex) throws IOException, MailException { 
     223                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_MESSAGES)); 
    220224                checkActiveFolder(folder); 
    221225                 
     
    241245         
    242246        private void handleRequestFolderMessagesRecent(FolderTreeItem folder) throws IOException, MailException { 
     247                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_FOLDER_MESSAGES)); 
    243248                checkActiveFolder(folder); 
    244249         
     
    252257         
    253258        private void handleRequestMessage(MessageToken messageToken) throws IOException, MailException { 
     259                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE)); 
    254260                checkActiveFolder(messageToken); 
    255261                 
     
    263269 
    264270        private void handleRequestMessageParts(MessageToken messageToken, MimeMessagePart[] messageParts) throws IOException, MailException { 
     271                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE)); 
    265272                checkActiveFolder(messageToken); 
    266273 
     
    291298         
    292299        private void handleRequestMessageDelete(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 
     300                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_DELETE)); 
    293301                checkActiveFolder(messageToken); 
    294302                 
     
    302310         
    303311        private void handleRequestMessageUndelete(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 
     312                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_UNDELETE)); 
    304313                checkActiveFolder(messageToken); 
    305314                 
     
    313322         
    314323        private void handleRequestMessageAnswered(MessageToken messageToken, MessageFlags messageFlags) throws IOException, MailException { 
     324                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_ANSWERED)); 
    315325                // Replace this with a more general method: 
    316326                if(incomingClient instanceof org.logicprobe.LogicMail.mail.imap.ImapClient) { 
     
    326336         
    327337        private void handleRequestMessageAppend(FolderTreeItem folder, String rawMessage, MessageFlags initialFlags) throws IOException, MailException { 
     338                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_MESSAGE_APPEND)); 
    328339                // Clean up this interface: 
    329340                if(incomingClient instanceof org.logicprobe.LogicMail.mail.imap.ImapClient) { 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/MailConnectionManager.java

    r237 r470  
    126126    /** 
    127127     * 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 
    128149     * of an error with the mail connection. 
    129150     *  
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/MailConnectionStatusEvent.java

    r237 r470  
    3939public class MailConnectionStatusEvent extends MailConnectionEvent { 
    4040        private String message; 
     41        private int progressType; 
     42        private int progressPercentage; 
    4143         
    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) { 
    4459                super(source, connectionConfig); 
    4560                this.message = message; 
     61                this.progressType = progressType; 
     62                this.progressPercentage = progressPercentage; 
    4663        } 
    4764         
    4865        /** 
     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        /** 
    4978         * Gets the status message. 
     79         *  
    5080         * @return Status message 
    5181         */ 
     
    5383                return message; 
    5484        } 
     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        } 
    55104} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/OutgoingMailConnectionHandler.java

    r407 r470  
    55import java.util.TimerTask; 
    66 
     7import org.logicprobe.LogicMail.LogicMailResource; 
    78import org.logicprobe.LogicMail.message.Message; 
    89import org.logicprobe.LogicMail.message.MessageEnvelope; 
     
    9495         
    9596        private void handleRequestSendMessage(MessageEnvelope envelope, Message message) throws IOException, MailException { 
     97                showStatus(resources.getString(LogicMailResource.MAILCONNECTION_REQUEST_SEND_MESSAGE)); 
    9698                String messageSource = outgoingClient.sendMessage(envelope, message); 
    9799                 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/message/MimeMessagePartFactory.java

    r469 r470  
    110110    /** 
    111111     * Find out if a particular message part type is supported 
    112      * without having to create it.  This is useful to optimize 
     112     * as displayable content.  This is useful to optimize 
    113113     * downloads on protocols that support selective retrieval 
    114114     * of message parts. 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/message/MimeMessagePartTransformer.java

    r467 r470  
    172172                } 
    173173                 
    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                } 
    175185        } 
    176186} 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/BrowserFieldManager.java

    r453 r470  
    3535import net.rim.device.api.ui.FieldChangeListener; 
    3636import net.rim.device.api.ui.MenuItem; 
    37 import net.rim.device.api.ui.XYRect; 
    3837import net.rim.device.api.ui.component.Menu; 
    3938import net.rim.device.api.ui.container.VerticalFieldManager; 
  • trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageScreen.java

    r467 r470  
    426426        // TODO: Support on-demand downloading of additional content 
    427427        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                } 
    435441        } 
    436442 
Note: See TracChangeset for help on using the changeset viewer.