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

Notification improvements

File:
1 edited

Legend:

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

    r376 r388  
    11/*- 
    2  * Copyright (c) 2006, Derek Konigsberg 
     2 * Copyright (c) 2009, Derek Konigsberg 
    33 * All rights reserved. 
    44 * 
     
    3333 
    3434import java.util.Calendar; 
     35import java.util.Hashtable; 
    3536 
    3637import net.rim.blackberry.api.homescreen.HomeScreen; 
     
    3940import net.rim.device.api.system.ApplicationManager; 
    4041import net.rim.device.api.system.EventLogger; 
     42import net.rim.device.api.system.RuntimeStore; 
    4143import net.rim.device.api.ui.UiApplication; 
     44 
    4245import org.logicprobe.LogicMail.ui.MailHomeScreen; 
    4346import org.logicprobe.LogicMail.ui.NotificationHandler; 
     47import org.logicprobe.LogicMail.conf.AccountConfig; 
    4448import org.logicprobe.LogicMail.conf.MailSettings; 
    4549 
     
    110114    } 
    111115     
    112     /** The constant event source object. */ 
    113     private static final Object eventSource = new Object() { 
    114                 public String toString() { 
    115                 return "LogicMail New Message"; 
    116                 } 
    117         }; 
    118          
    119116    /** 
    120117     * Method to execute in autostart mode. 
     
    141138                        HomeScreen.updateIcon(AppInfo.getIcon(), 0); 
    142139                        HomeScreen.setRolloverIcon(AppInfo.getRolloverIcon(), 0); 
    143                         // Configure the notification source 
    144                         NotificationsManager.registerSource(AppInfo.GUID, eventSource, NotificationsConstants.CASUAL); 
     140 
     141                        // Configure a notification source for each account 
     142                        MailSettings mailSettings = MailSettings.getInstance(); 
     143                        mailSettings.loadSettings(); 
     144                        int numAccounts = mailSettings.getNumAccounts(); 
     145                        Hashtable eventSourceMap = new Hashtable(numAccounts); 
     146                        for(int i=0; i<numAccounts; i++) { 
     147                                AccountConfig accountConfig = mailSettings.getAccountConfig(i); 
     148                                LogicMailEventSource eventSource = 
     149                                        new LogicMailEventSource(accountConfig.getAcctName(), accountConfig.getUniqueId()); 
     150                                NotificationsManager.registerSource( 
     151                                        eventSource.getEventSourceId(), 
     152                                        eventSource, 
     153                                        NotificationsConstants.CASUAL); 
     154                                eventSourceMap.put(new Long(accountConfig.getUniqueId()), eventSource); 
     155                        } 
    145156                         
     157                        // Save the registered event sources in the runtime store 
     158                        RuntimeStore.getRuntimeStore().put(AppInfo.GUID, eventSourceMap); 
    146159                        keepGoing = false; 
    147160                    } 
     
    150163                 System.exit(0); 
    151164            } 
    152         });      
     165        }); 
    153166    } 
    154167}  
Note: See TracChangeset for help on using the changeset viewer.