2021-01-09 16:53:39 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
#ifndef FEEDCONTROLLER_H
|
|
|
|
#define FEEDCONTROLLER_H
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
2021-01-13 20:23:21 -06:00
|
|
|
class BList;
|
2021-01-09 16:53:39 -06:00
|
|
|
class BMessage;
|
2021-02-26 21:28:12 -06:00
|
|
|
class BMessageRunner;
|
|
|
|
class Feed;
|
2021-01-09 16:53:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
kEnqueueFeed = 'fenq',
|
|
|
|
kClearQueue = 'frmq',
|
2021-02-18 23:16:45 -06:00
|
|
|
kDownloadStart = 'fdst',
|
2021-01-13 17:28:07 -06:00
|
|
|
kDownloadComplete = 'fdlc',
|
|
|
|
kDownloadFail = 'fdlf',
|
|
|
|
kParseComplete = 'fpec',
|
|
|
|
kParseFail = 'fpef',
|
2021-02-26 21:28:12 -06:00
|
|
|
kUpdateSubscribed = 'fups',
|
|
|
|
kControllerCheck = 'coch'
|
2021-01-09 16:53:39 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FeedController{
|
|
|
|
public:
|
|
|
|
FeedController();
|
|
|
|
~FeedController();
|
2021-02-21 13:16:35 -06:00
|
|
|
|
2021-01-09 16:53:39 -06:00
|
|
|
void MessageReceived(BMessage* msg);
|
2021-02-26 21:28:12 -06:00
|
|
|
|
2021-01-13 20:23:21 -06:00
|
|
|
static BList SubscribedFeeds();
|
2021-01-09 16:53:39 -06:00
|
|
|
|
|
|
|
private:
|
2021-02-26 21:28:12 -06:00
|
|
|
static int32 _DownloadLoop(void* data);
|
|
|
|
static int32 _ParseLoop(void* data);
|
|
|
|
|
|
|
|
void _EnqueueFeed(Feed* feed);
|
|
|
|
void _ProcessQueueItem();
|
|
|
|
void _CheckStatus();
|
2021-01-09 16:53:39 -06:00
|
|
|
|
2021-02-26 21:28:12 -06:00
|
|
|
thread_id fMainThread;
|
2021-01-09 16:53:39 -06:00
|
|
|
thread_id fDownloadThread;
|
|
|
|
thread_id fParseThread;
|
2021-02-26 21:28:12 -06:00
|
|
|
|
|
|
|
BList* fDownloadQueue;
|
|
|
|
BMessageRunner* fMessageRunner;
|
2021-01-09 16:53:39 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FEEDCONTROLLER_H
|
|
|
|
|