//#endif
// Open existing bookmark and show headers (items).
if( m_openPage || m_getPage || m_getModPage ) {
try {
RssItunesFeed feed = null;
if( m_openPage ) {
m_curBookmark = UiUtil.getSelectedIndex(m_bookmarkList);
}
if( m_curBookmark<0 ){
continue;
}
if( m_openPage ) {
String parm = m_bookmarkList.getString(
m_curBookmark);
feed = (RssItunesFeed)m_rssFeeds.get(parm);
m_curRssParser = new RssFeedParser( feed );
m_openPage = ( feed.getItems().size() > 0 );
m_getPage = !m_openPage;
m_prevDisp = m_bookmarkList;
} else {
feed = m_curRssParser.getRssFeed();
}
if( m_openPage ) {
/* Loading feed... */
initializeLoadingFormRsc("text.l.feed",
m_bookmarkList);
} else {
/* Updating feed... */
initializeLoadingFormRsc(
m_getModPage ? "text.u.mfeed" :
"text.u.feed", m_prevDisp);
}
if(feed.getUrl().length() == 0) {
recordExcFormFin("Unable to open feed. No URL.",
new Exception(
"Feed has no URL cannot load."));
continue;
}
if (!m_openPage) {
/** Get RSS feed */
final int maxItemCount =
m_appSettings.getMaximumItemCountInFeed();
final boolean convHtml =
!m_appSettings.getHtmlEnabled();
//#ifdef DTEST
System.gc();
long beginMem = Runtime.getRuntime().freeMemory();
//#endif
m_curRssParser.parseRssFeed( m_getModPage, convHtml,
maxItemCount );
//#ifdef DTEST
System.gc();
System.out.println("RssItunesFeed size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
feed = m_curRssParser.getRssFeed();
//#ifdef DTEST
System.gc();
beginMem = Runtime.getRuntime().freeMemory();
//#endif
m_rssFeeds.put(feed.getName(), feed);
//#ifdef DTEST
System.gc();
System.out.println("RssItunesFeed store size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
}
//#ifdef DTEST
System.gc();
long beginMem = Runtime.getRuntime().freeMemory();
//#endif
final HeaderList hdrList = new HeaderList(this, feed);
//#ifdef DTEST
System.gc();
System.out.println("headerList size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
hdrList.fillHeadersList();
setCurrent( hdrList );
//#ifdef DTEST
hdrList.testFeed(true);
hdrList.testFeed(false);
hdrList.testFeed2(true);
hdrList.testFeed2(false);
//#endif
}catch(CauseMemoryException e) {
System.gc();
if ((m_curRssParser != null) &&
(m_curRssParser.getRssFeed() != null)) {
m_curRssParser.getRssFeed().setItems(new Vector());
}
recordExcFormFinRsc(
/* \nOut of memory loading/parsing feed on:\n */
(m_openPage ? "exc.om.ld" : "exc.om.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(Exception e) {
/* Error loading/parsing feed on:\n \1 */
recordExcFormFinRsc(
(m_openPage ? "exc.er.ld" : "exc.er.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(OutOfMemoryError e) {
System.gc();
if ((m_curRssParser != null) &&
(m_curRssParser.getRssFeed() != null)) {
m_curRssParser.getRssFeed().setItems(new Vector());
}
recordExcFormFinRsc(
/* Out of memory loading/parsing feed on:\n */
(m_openPage ? "exc.om.ld" : "exc.om.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(Throwable t) {
recordExcFormFinRsc(
/* Internal error loading/parsing feed on:\n */
(m_openPage ? "exc.int.ld" : "exc.int.pse"),
m_curRssParser.getRssFeed().getUrl(), t);
} finally {
m_getPage = false;
m_openPage = false;
m_getModPage = false;
}
}
/* Handle going to settings form. */
if( m_getSettingsForm ) {
m_getSettingsForm = false;
/* Loading settings... */
initializeLoadingFormRsc("text.l.s", m_bookmarkList);
try{
//#ifdef DTEST
System.gc();
long beginMem = Runtime.getRuntime().freeMemory();
//#endif
final SettingsForm settingsForm = new SettingsForm(this);
//#ifdef DTEST
System.gc();
System.out.println("SettingsForm size=" +
(beginMem - Runtime.getRuntime().freeMemory()));
//#endif
if (m_loadForm.hasExc()) {
m_loadForm.addStartCmd( settingsForm );
} else {
setCurrent( settingsForm );
}
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading settings form */
recordExcFormFinRsc("exc.om.set", t);
} catch(Throwable t) {
/* \nInternal error loading settings form */
recordExcFormFinRsc("exc.int.lset", t);
}
}
//#ifndef DSMALLMEM
/* Handle going to help form. */
if( m_getHelpForm ) {
m_getHelpForm = false;
/* Loading help... */
initializeLoadingFormRsc("text.l.h", m_bookmarkList);
try{
final HelpForm helpForm = initializeHelp();
setCurrent( helpForm );
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading help form */
recordExcFormFinRsc("exc.om.bhlp", t);
} catch(Throwable t) {
/* \nInternal error loading help form */
recordExcFormFinRsc("exc.int.bhlp", t);
}
}
//#endif
/* Handle going to bookmark form. */
if( m_getAddBMForm || m_getEditBMForm ) {
try {
if( m_getEditBMForm ) {
m_curBookmark = UiUtil.getSelectedIndex(m_bookmarkList);
if( m_curBookmark<0 ){
continue;
}
}
if( m_getAddBMForm ) {
/* Loading add bookmark... */
initializeLoadingFormRsc("text.l.bmrk",
m_bookmarkList);
} else {
/* Loading edit bookmark... */
initializeLoadingFormRsc("text.edit",
m_bookmarkList);
}
//#ifdef DTEST
System.gc();
long beginMem = Runtime.getRuntime().freeMemory();
//#endif
BMForm bmForm = new BMForm(m_getAddBMForm);
//#ifdef DTEST
System.gc();
System.out.println("BMForm size=" +
(beginMem - Runtime.getRuntime().freeMemory()));
//#endif
if (m_getEditBMForm) {
final RssItunesFeed bm = (RssItunesFeed)m_rssFeeds.get(
m_bookmarkList.getString(m_curBookmark));
bmForm.updateBM(bm);
}
setCurrent( bmForm );
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading bookmark form */
recordExcFormFinRsc("exc.om.bmk", t);
} catch(Throwable t) {
/* \nInternal error loading bookmark form */
recordExcFormFinRsc("exc.int.bmk", t);
} finally {
m_getAddBMForm = false;
m_getEditBMForm = false;
}
}
if( m_refreshAllFeeds || m_refreshUpdFeeds ) {
/* Updating all or modified feeds... */
initializeLoadingFormRsc((m_refreshUpdFeeds ?
"text.um.feed" : "text.ua.feed"),
m_bookmarkList);
/* Updating all (modified) feeds...*/
Gauge gauge = new Gauge(ResourceProviderME.get(
m_refreshAllFeeds ? "text.ua.feed" :
"text.um.feed"),
false, m_rssFeeds.size(), 0);
int pl = m_loadForm.append(gauge);
try{
boolean errFound = false;
final int maxItemCount =
m_appSettings.getMaximumItemCountInFeed();
final boolean convHtml =
!m_appSettings.getHtmlEnabled();
Enumeration keyEnum = m_rssFeeds.keys();
int ic = 1;
while(keyEnum.hasMoreElements()) {
final String fname =
(String)keyEnum.nextElement();
RssItunesFeed feed =
(RssItunesFeed)m_rssFeeds.get(fname);
try{
m_loadForm.appendMsg(fname + "...");
RssFeedParser parser = new RssFeedParser( feed );
parser.parseRssFeed( m_refreshUpdFeeds,
convHtml, maxItemCount);
m_rssFeeds.put( fname, feed );
m_loadForm.appendMsg("ok\n");
} catch(CauseMemoryException ex) {
throw ex;
} catch(Exception ex) {
recordExcForm("Error parsing feed " +
feed.getName(), ex);
errFound = true;
}
gauge.setValue(ic);
ic++;
}
if (errFound) {
setLoadingFinished(
/* Finished with one or more exceptions */
/* or errors below. */
ResourceProviderME.get("text.fin.errb"),
/* Updating finished with one or more */
/* exceptions or errors above*/
ResourceProviderME.get("text.fin.erra"));
setCurrent( m_loadForm );
} else {
setLoadingFinished("Updating finished",
"Updating finished use back to return.");
setCurrent( m_bookmarkList );
}
pl = -1;
} catch(CauseMemoryException ex) {
recordExcForm("Out Of Memory Error parsing feeds", ex);
m_loadForm.appendMsg("Trying to free memory.");
freeFeedItems();
recordFin();
} catch(Exception ex) {
recordExcFormFin("Error parsing feeds", ex);
} catch(OutOfMemoryError ex) {
System.gc();
recordExcForm("Out Of Memory Error parsing feeds", ex);
m_loadForm.appendMsg("Trying to free memory.");
freeFeedItems();
recordFin();
} catch(Throwable t) {
recordExcFormFin("Internal error parsing feeds", t);
} finally {
if (pl >= 0) {
m_loadForm.delete(pl);
}
m_refreshAllFeeds = false;
m_refreshUpdFeeds = false;
}
}
// Go to import feed form
if( m_getImportForm ) {
try {
/* Loading import form... */
initializeLoadingFormRsc("text.l.imp",
m_bookmarkList);
//#ifdef DTEST
System.gc();
long beginMem = Runtime.getRuntime().freeMemory();
//#endif
ImportFeedsForm importFeedsForm;
//#ifdef DTEST
if (m_getTestImportForm) {
RssItunesFeed bm = (RssItunesFeed)m_rssFeeds.get(
m_bookmarkList.getString(m_curBookmark));
importFeedsForm = new ImportFeedsForm(this,
m_bookmarkList, m_rssFeeds, m_appSettings,
m_loadForm, bm.getUrl());
} else
//#endif
importFeedsForm = new ImportFeedsForm(this,
m_bookmarkList, m_rssFeeds, m_appSettings,
m_loadForm, m_appSettings.getImportUrl());
//#ifdef DTEST
System.gc();
System.out.println("ImportForm size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
setCurrent( importFeedsForm );
} catch(Exception ex) {
recordExcFormFin("Error loading import form\n", ex);
} catch(OutOfMemoryError ex) {
System.gc();
recordExcFormFin("Out Of Memory loading import form\n",
ex);
} catch(Throwable t) {
recordExcFormFin("Internal loading import form\n", t);
} finally {
m_getImportForm = false;
//#ifdef DTEST
m_getTestImportForm = false;
//#endif
}
}
//#ifdef DTESTUI
if ((m_bookmarkIndex < m_bookmarkList.size()) &&
(m_bookmarkIndex >= 0)) {
if (m_bookmarkList.getSelectedIndex() >= 0) {
m_bookmarkList.setSelectedIndex(
m_bookmarkList.getSelectedIndex(), false);
}
m_bookmarkList.setSelectedIndex(m_bookmarkIndex, true);
commandAction(m_editBookmark, m_bookmarkList);
m_bookmarkIndex++;
if (m_bookmarkIndex >= m_bookmarkList.size()) {
m_bookmarkIndex = -1;
System.out.println("Test UI Test Rss feeds last");
}
}
//#endif
//#ifdef DJSR75
/* Find files in the file system to get for bookmark or
import from. */
if( m_getFile ) {
if (m_fileRtnForm instanceof ImportFeedsForm) {
/* Loading files to import from... */
initializeLoadingFormRsc("text.l.f.imp",
m_fileRtnForm);
} else {
/* Loading files to bookmark from... */
initializeLoadingFormRsc("text.l.f.bk",
m_fileRtnForm);
}
try {
final KFileSelectorMgr fileSelectorMgr =
new KFileSelectorMgr();
fileSelectorMgr.doLaunchSelector(this,
m_fileRtnForm, m_fileURL);
} catch(OutOfMemoryError ex) {
System.gc();
/* Out Of Memory Error getting file form. */
recordExcFormFinRsc("exc.om.flf", ex);
} catch (Throwable t) {
/* Internal error getting file form. */
recordExcFormFinRsc("exc.int.flf", t);
} finally {
m_getFile = false;
}
}
//#endif
/* Handle going to link (platform request.). */
//#ifdef DMIDP20
if (m_platformReq) {
try {
/* Loading web page... */
initializeLoadingFormRsc("text.l.wp", m_itemForm);
if( super.platformRequest(m_platformURL) ) {
initializeLoadingForm("Exiting saving data...",
m_itemRtnList);
m_exit = true;
exitApp();
} else {
setCurrent( m_itemRtnList );
}
} catch (ConnectionNotFoundException e) {
//#ifdef DLOGGING
logger.severe("Error opening link " + m_platformURL, e);
//#endif
final Alert badLink = new Alert("Could not connect to link",
"Bad link: " + m_platformURL,
null, AlertType.ERROR);
badLink.setTimeout(Alert.FOREVER);
setCurrent( badLink, m_itemRtnList );
} finally {
m_platformReq = false;
}
}
//#endif
/* Sort the read or unread items. */
if ( m_runNews ) {
try {
/* Sorting items... */
initializeLoadingFormRsc("text.s.item",
m_bookmarkList);
AllNewsList unreadHeaderList = new AllNewsList(this,
m_bookmarkList, m_rssFeeds,
m_appSettings.getMarkUnreadItems() ?
m_unreadImage : null,
m_appSettings.getMarkUnreadItems() ?
m_readImage : null);
//#ifdef DTESTUI
m_unreadHeaderTestList = unreadHeaderList;
//#endif
unreadHeaderList.initializeUnreadHhdrsList();
unreadHeaderList.sortUnreadItems( true,
m_bookmarkList, m_rssFeeds );
setCurrent( unreadHeaderList );
}catch(OutOfMemoryError t) {
System.gc();
recordExcFormFin("\nOut Of Memory Error sorting items", t);
}catch(Throwable t) {
recordExcFormFin("\nInternal error sorting items", t);
} finally {
m_runNews = false;
}
}
if ( m_backFrHdr ) {
m_backFrHdr = false;
/* Updating feed... */
initializeLoadingFormRsc("text.u.feed", m_bookmarkList);
try {
m_rssFeeds.put(m_curRssParser.getRssFeed());
} catch (Throwable t) {
recordExcFormFin("Internal error updating feed.", t);
}
setCurrent( m_bookmarkList );
}
if ( m_showItem ) {
m_showItem = false;
initializeLoadingFormRsc( "text.l.it", m_itemRtnList );
RssItunesFeed feed = m_curRssParser.getRssFeed();
citem.setUnreadItem(false);
initializeItemForm( feed, citem, m_itemRtnList );
//#ifdef DTESTUI
m_itemNext = true;
//#endif