diff --git a/TODO.txt b/TODO.txt index 46306d9..244d72e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,8 +4,6 @@ * Revamp configuration * Fix saving, etc. * Notifications - * On new entries - * Sound effect, too * On failures * Show progress * With progress bar diff --git a/src/Config.cpp b/src/Config.cpp index 5f800fe..0344168 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -11,7 +11,6 @@ Config::Config() { - Load(); } @@ -33,7 +32,7 @@ Config::Load() BMessage storage; storage.Unflatten(&file); - updateInterval = storage.GetFloat("updateInterval", .5); + updateInterval = storage.GetInt64("updateInterval", 3600000000); outDir = BString(storage.GetString("outDir", "/boot/home/feeds/")); cacheDir = BString(storage.GetString("cacheDir", "/boot/home/config/cache/Pogger/")); diff --git a/src/Entry.cpp b/src/Entry.cpp index 9d04624..e275f59 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -40,7 +40,7 @@ Entry::Filetize(BDirectory outDir) title.String(), title.CountChars()); file->WriteAttr("Feed:description", B_STRING_TYPE, 0, description.String(), description.CountChars()); - file->WriteAttr("FEED:source", B_STRING_TYPE, 0, + file->WriteAttr("Feed:source", B_STRING_TYPE, 0, feedTitle.String(), feedTitle.CountChars()); file->WriteAttr("META:url", B_STRING_TYPE, 0, postUrl.String(), postUrl.CountChars()); diff --git a/src/FeedController.cpp b/src/FeedController.cpp index c7e4e00..a249b47 100644 --- a/src/FeedController.cpp +++ b/src/FeedController.cpp @@ -6,6 +6,7 @@ #include "FeedController.h" #include +#include #include @@ -125,6 +126,7 @@ FeedController::_ParseLoop(void* ignored) while (receive_data(&sender, (void*)feedBuffer, sizeof(Feed)) != 0) { BList entries; + BString title; BDirectory outDir = BDirectory(((App*)be_app)->cfg->outDir); if (feedBuffer->IsAtom()) { @@ -132,6 +134,7 @@ FeedController::_ParseLoop(void* ignored) feed = new AtomFeed(feedBuffer); feed->Parse(); entries = feed->GetNewEntries(); + title = feed->GetTitle(); delete(feed); } else if (feedBuffer->IsRss()) { @@ -139,12 +142,30 @@ FeedController::_ParseLoop(void* ignored) feed = new RssFeed(feedBuffer); feed->Parse(); entries = feed->GetNewEntries(); + title = feed->GetTitle(); delete(feed); } - if (feedBuffer->IsAtom() || feedBuffer->IsRss()) + if ((feedBuffer->IsAtom() || feedBuffer->IsRss()) + && entries.CountItems() > 0) + { for (int i = 0; i < entries.CountItems(); i++) ((Entry*)entries.ItemAt(i))->Filetize(outDir); + + BNotification notifyNew = (B_INFORMATION_NOTIFICATION); + BString notifyLabel("New Feed Entries"); + BString notifyText("%n% new entries from %source%"); + + BString numStr(""); + numStr << entries.CountItems(); + notifyText.ReplaceAll("%source%", title); + notifyText.ReplaceAll("%n%", numStr); + + + notifyNew.SetTitle(notifyLabel); + notifyNew.SetContent(notifyText); + notifyNew.Send(); + } } delete (feedBuffer);