Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] RSS monitor #931

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ add_executable(
src/picotorrent/ipc/applicationoptionsconnection
src/picotorrent/ipc/server

# RSS
src/picotorrent/rss/feedmanager

# Dialogs
src/picotorrent/ui/dialogs/aboutdialog
src/picotorrent/ui/dialogs/addmagnetlinkdialog
Expand All @@ -179,6 +182,7 @@ add_executable(
src/picotorrent/ui/dialogs/preferencesgeneralpage
src/picotorrent/ui/dialogs/preferenceslabelspage
src/picotorrent/ui/dialogs/preferencesproxypage
src/picotorrent/ui/dialogs/preferencesrsspage

# Models
src/picotorrent/ui/models/filestoragemodel
Expand Down Expand Up @@ -242,7 +246,7 @@ target_link_libraries(
PRIVATE

# wxWidgets
core base propgrid
core base propgrid xml

# Windows
Comctl32
Expand Down
17 changes: 17 additions & 0 deletions res/dbmigrations/20200927003412_rss_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE rss_feed (
id INTEGER PRIMARY KEY,
url TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
created_at INTEGER NOT NULL,
updated_at INTEGER
);

CREATE TABLE rss_feed_filter (
id INTEGER PRIMARY KEY,
feed_id INTEGER NOT NULL,
is_regex INTEGER NOT NULL,
include_filter TEXT,
exclude_filter TEXT,

FOREIGN KEY(feed_id) REFERENCES rss_feed(id)
);
1 change: 1 addition & 0 deletions src/picotorrent/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ AppIcon ICON "..\\..\\res\\app.ico"
20200916213321_insert_locale_name_setting DBMIGRATION "..\\..\\res\\dbmigrations\\20200916213321_insert_locale_name_setting.sql"
20200919221011_create_label_table DBMIGRATION "..\\..\\res\\dbmigrations\\20200919221011_create_label_table.sql"
20200925235912_save_resume_data_interval DBMIGRATION "..\\..\\res\\dbmigrations\\20200925235912_save_resume_data_interval.sql"
20200927003412_rss_tables DBMIGRATION "..\\..\\res\\dbmigrations\\20200927003412_rss_tables.sql"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILE_VERSION
Expand Down
17 changes: 17 additions & 0 deletions src/picotorrent/rss/feedmanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "feedmanager.hpp"

#include <wx/sstream.h>
#include <wx/xml/xml.h>

#include "../http/httpclient.hpp"

using pt::RSS::FeedManager;

FeedManager::FeedManager()
: m_httpClient(std::make_unique<Http::HttpClient>())
{
}

FeedManager::~FeedManager()
{
}
23 changes: 23 additions & 0 deletions src/picotorrent/rss/feedmanager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include <memory>

namespace pt::Http { class HttpClient; }

namespace pt::RSS
{
class FeedManager : public wxEvtHandler
{
public:
FeedManager();
virtual ~FeedManager();

private:
std::unique_ptr<Http::HttpClient> m_httpClient;
};
}
10 changes: 10 additions & 0 deletions src/picotorrent/ui/dialogs/preferencesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "preferencesgeneralpage.hpp"
#include "preferenceslabelspage.hpp"
#include "preferencesproxypage.hpp"
#include "preferencesrsspage.hpp"
#include "../translator.hpp"

using pt::UI::Dialogs::PreferencesDialog;
Expand All @@ -29,6 +30,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent, std::shared_ptr<Core::Con
m_labels(new PreferencesLabelsPage(m_book, cfg)),
m_connection(new PreferencesConnectionPage(m_book, cfg)),
m_proxy(new PreferencesProxyPage(m_book, cfg)),
m_rss(new PreferencesRssPage(m_book, cfg)),
m_advanced(new PreferencesAdvancedPage(m_book, cfg)),
m_wantsRestart(false)
{
Expand All @@ -38,6 +40,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent, std::shared_ptr<Core::Con
m_list->Append(i18n("labels"));
m_list->Append(i18n("connection"));
m_list->Append(i18n("proxy"));
m_list->Append(i18n("rss"));
m_list->Append(i18n("advanced"));
m_list->Select(0);

Expand All @@ -46,6 +49,7 @@ PreferencesDialog::PreferencesDialog(wxWindow* parent, std::shared_ptr<Core::Con
m_book->AddPage(m_labels, wxEmptyString, false);
m_book->AddPage(m_connection, wxEmptyString, false);
m_book->AddPage(m_proxy, wxEmptyString, false);
m_book->AddPage(m_rss, wxEmptyString, false);
m_book->AddPage(m_advanced, wxEmptyString, false);

m_mainSizer = new wxBoxSizer(wxHORIZONTAL);
Expand Down Expand Up @@ -127,6 +131,11 @@ void PreferencesDialog::OnOk(wxCommandEvent& evt)
return;
}

if (!m_rss->IsValid())
{
return;
}

if (!m_advanced->IsValid())
{
return;
Expand All @@ -139,6 +148,7 @@ void PreferencesDialog::OnOk(wxCommandEvent& evt)
m_labels->Save();
m_connection->Save(&restartRequired);
m_proxy->Save();
m_rss->Save();
m_advanced->Save();

if (restartRequired)
Expand Down
16 changes: 5 additions & 11 deletions src/picotorrent/ui/dialogs/preferencesdialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@
class wxBookCtrlEvent;
class wxSimplebook;

namespace pt
{
namespace Core
{
class Configuration;
}
namespace UI
{
namespace Dialogs
namespace pt::Core { class Configuration; }

namespace pt::UI::Dialogs
{
class PreferencesAdvancedPage;
class PreferencesConnectionPage;
class PreferencesDownloadsPage;
class PreferencesGeneralPage;
class PreferencesLabelsPage;
class PreferencesProxyPage;
class PreferencesRssPage;

class PreferencesDialog : public wxDialog
{
Expand Down Expand Up @@ -54,8 +49,7 @@ namespace Dialogs
PreferencesLabelsPage* m_labels;
PreferencesConnectionPage* m_connection;
PreferencesProxyPage* m_proxy;
PreferencesRssPage* m_rss;
PreferencesAdvancedPage* m_advanced;
};
}
}
}
21 changes: 21 additions & 0 deletions src/picotorrent/ui/dialogs/preferencesrsspage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "preferencesrsspage.hpp"

using pt::UI::Dialogs::PreferencesRssPage;

PreferencesRssPage::PreferencesRssPage(wxWindow* parent, std::shared_ptr<Core::Configuration> cfg)
: m_cfg(cfg)
{
}

PreferencesRssPage::~PreferencesRssPage()
{
}

bool PreferencesRssPage::IsValid()
{
return true;
}

void PreferencesRssPage::Save()
{
}
26 changes: 26 additions & 0 deletions src/picotorrent/ui/dialogs/preferencesrsspage.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include <memory>

namespace pt::Core { class Configuration; }

namespace pt::UI::Dialogs
{
class PreferencesRssPage : public wxPanel
{
public:
PreferencesRssPage(wxWindow* parent, std::shared_ptr<Core::Configuration> cfg);
virtual ~PreferencesRssPage();

bool IsValid();
void Save();

private:
std::shared_ptr<Core::Configuration> m_cfg;
};
}
2 changes: 2 additions & 0 deletions src/picotorrent/ui/mainframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "../core/environment.hpp"
#include "../core/utils.hpp"
#include "../ipc/server.hpp"
#include "../rss/feedmanager.hpp"
#include "dialogs/aboutdialog.hpp"
#include "dialogs/addmagnetlinkdialog.hpp"
#include "dialogs/addtorrentdialog.hpp"
Expand All @@ -48,6 +49,7 @@ MainFrame::MainFrame(std::shared_ptr<Core::Environment> env, std::shared_ptr<Cor
m_env(env),
m_db(db),
m_cfg(cfg),
m_feedManager(std::make_unique<RSS::FeedManager>()),
m_session(new BitTorrent::Session(this, db, cfg, env)),
m_splitter(new wxSplitterWindow(this, ptID_MAIN_SPLITTER)),
m_statusBar(new StatusBar(this)),
Expand Down
4 changes: 3 additions & 1 deletion src/picotorrent/ui/mainframe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
class wxSplitterWindow;
class wxTaskBarIconEvent;

namespace pt::RSS { class FeedManager; }

namespace pt
{
class UpdateChecker;

namespace BitTorrent
{
Expand Down Expand Up @@ -86,6 +87,7 @@ namespace Models
std::shared_ptr<Core::Database> m_db;
std::shared_ptr<Core::Configuration> m_cfg;
std::unique_ptr<IPC::Server> m_ipc;
std::unique_ptr<RSS::FeedManager> m_feedManager;

wxMenu* m_viewMenu;
wxMenu* m_filtersMenu;
Expand Down