diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 84533097e..9d148e3df 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -5,6 +5,7 @@ Added: ▪ Background color of notifications is now changeable. (issue #134) ▪ Auto-update setting of individual Tiny Tiny RSS feeds can now be changed. +▪ RSS Guard is now useable as external RSS reader by common web browsers like Firefox etc. (issue #135) 3.0.0 ————— diff --git a/src/main.cpp b/src/main.cpp index eb23d82c4..a5667f0cb 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,8 +66,10 @@ int main(int argc, char *argv[]) { Application application(APP_LOW_NAME, argc, argv); qDebug("Instantiated Application class."); + // TODO: dat '\n' do konstant + // Check if another instance is running. - if (application.sendMessage(APP_IS_RUNNING)) { + if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join('\n'))) { qWarning("Another instance of the application is already running. Notifying it."); return EXIT_FAILURE; } diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index 0ff6edeae..b1ede783a 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -29,6 +29,7 @@ #include "adblock/adblockmanager.h" #include "services/abstract/serviceroot.h" +#include "services/standard/standardserviceroot.h" #include "services/standard/standardserviceentrypoint.h" #include "services/tt-rss/ttrssserviceentrypoint.h" @@ -158,12 +159,30 @@ void Application::restoreDatabaseSettings(bool restore_database, bool restore_se void Application::processExecutionMessage(const QString &message) { qDebug("Received '%s' execution message from another application instance.", qPrintable(message)); - if (message == APP_IS_RUNNING) { - showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information); - mainForm()->display(); - } - else if (message == APP_QUIT_INSTANCE) { - quit(); + // TODO: dat '\n' do konstant a taky "feed:" + + foreach (QString msg, message.split('\n')) { + if (msg == APP_IS_RUNNING) { + showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information); + mainForm()->display(); + } + else if (msg == APP_QUIT_INSTANCE) { + quit(); + } + else if (msg.startsWith(QL1S("feed:"))) { + // Application was running, and someone wants to add new feed. + StandardServiceRoot *root = qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot(); + + if (root != NULL) { + root->checkArgumentForFeedAdding(msg); + } + else { + showGuiMessage(tr("Cannot add feed"), + tr("Feed cannot be added because standard RSS/ATOM account is not enabled."), + QSystemTrayIcon::Warning, qApp->mainForm(), + true); + } + } } } diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 8fa26db42..5ee6f22c5 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -41,6 +41,7 @@ #include #include #include +#include StandardServiceRoot::StandardServiceRoot(RootItem *parent) @@ -95,6 +96,8 @@ void StandardServiceRoot::start() { } } } + + checkArgumentsForFeedAdding(); } void StandardServiceRoot::stop() { @@ -296,6 +299,19 @@ void StandardServiceRoot::loadFromDatabase(){ m_recycleBin->updateCounts(true); } +void StandardServiceRoot::checkArgumentsForFeedAdding() { + foreach (QString arg, qApp->arguments().mid(1)) { + checkArgumentForFeedAdding(arg); + } +} + +void StandardServiceRoot::checkArgumentForFeedAdding(const QString &argument) { + if (argument.startsWith(QL1S("feed:"))) { + qApp->clipboard()->setText(argument); + addNewFeed(); + } +} + QList StandardServiceRoot::allCategories() { QList cats = getSubTreeCategories(); QList std_cats; diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 95425dc20..bfb43b461 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -95,6 +95,7 @@ class StandardServiceRoot : public ServiceRoot { bool cleanFeeds(QList items, bool clean_read_only); void loadFromDatabase(); + void checkArgumentForFeedAdding(const QString &argument); public slots: void addNewCategory(); @@ -103,6 +104,8 @@ class StandardServiceRoot : public ServiceRoot { void exportFeeds(); private: + void checkArgumentsForFeedAdding(); + // Returns converted ids of given feeds // which are suitable as IN clause for SQL queries. QStringList textualFeedIds(const QList &feeds);