Notifications for new entries
This commit is contained in:
parent
15b0fc7d6b
commit
543292c825
2
TODO.txt
2
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
|
||||
|
|
|
@ -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/"));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "FeedController.h"
|
||||
|
||||
#include <Message.h>
|
||||
#include <Notification.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -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);
|
||||
|
|
Ŝarĝante…
Reference in New Issue