Let Pogger open Feed Entry files
This commit is contained in:
parent
e9ba66729e
commit
65bfeba4f6
4
Makefile
4
Makefile
|
@ -49,8 +49,8 @@ SRCS = \
|
||||||
|
|
||||||
# Specify the resource definition files to use. Full or relative paths can be
|
# Specify the resource definition files to use. Full or relative paths can be
|
||||||
# used.
|
# used.
|
||||||
RDEFS = # \
|
RDEFS = \
|
||||||
# src/Pogger.rdef \
|
src/Pogger.rdef \
|
||||||
|
|
||||||
|
|
||||||
# Specify the resource files to use. Full or relative paths can be used.
|
# Specify the resource files to use. Full or relative paths can be used.
|
||||||
|
|
4
TODO.txt
4
TODO.txt
|
@ -1,7 +1,8 @@
|
||||||
Important Features:
|
Important Features:
|
||||||
* Open With support
|
|
||||||
* Open As support
|
* Open As support
|
||||||
* File extension support
|
* File extension support
|
||||||
|
* Show download progress/failures in FeedView's feedlist
|
||||||
|
* Update FeedView's feedlist when feeds added/removed
|
||||||
* Show in desktray
|
* Show in desktray
|
||||||
* Make archivable
|
* Make archivable
|
||||||
* Get menu working
|
* Get menu working
|
||||||
|
@ -13,6 +14,7 @@ Important improvements:
|
||||||
* Proper queue list (see Multiple downloads at once?)
|
* Proper queue list (see Multiple downloads at once?)
|
||||||
* No hardcoded paths
|
* No hardcoded paths
|
||||||
* Remove unnecessary `new`-- make sure to delete everything
|
* Remove unnecessary `new`-- make sure to delete everything
|
||||||
|
* General input sanitization
|
||||||
* File error-handling
|
* File error-handling
|
||||||
* e.g., Utils.cpp's userFileError
|
* e.g., Utils.cpp's userFileError
|
||||||
* Check if arg is a file or not (treat appropriately)
|
* Check if arg is a file or not (treat appropriately)
|
||||||
|
|
61
src/App.cpp
61
src/App.cpp
|
@ -6,6 +6,7 @@
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
|
#include <Roster.h>
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
@ -107,8 +108,17 @@ App::MessageReceived(BMessage* msg)
|
||||||
void
|
void
|
||||||
App::ArgvReceived(int32 argc, char** argv)
|
App::ArgvReceived(int32 argc, char** argv)
|
||||||
{
|
{
|
||||||
|
BMessage refMsg(B_REFS_RECEIVED);
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (BUrl(argv[i]).IsValid()) {
|
entry_ref ref;
|
||||||
|
BEntry entry(argv[i]);
|
||||||
|
std::cout << "ARGV" << std::endl;
|
||||||
|
|
||||||
|
if (entry.Exists() && entry.GetRef(&ref) == B_OK) {
|
||||||
|
refMsg.AddRef("refs", &ref);
|
||||||
|
}
|
||||||
|
else if (BUrl(argv[i]).IsValid()) {
|
||||||
Feed* newFeed = new Feed(BUrl(argv[i]));
|
Feed* newFeed = new Feed(BUrl(argv[i]));
|
||||||
|
|
||||||
BMessage* enqueue = new BMessage(kEnqueueFeed);
|
BMessage* enqueue = new BMessage(kEnqueueFeed);
|
||||||
|
@ -117,8 +127,55 @@ App::ArgvReceived(int32 argc, char** argv)
|
||||||
MessageReceived(enqueue);
|
MessageReceived(enqueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RefsReceived(&refMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
App::RefsReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
entry_ref ref;
|
||||||
|
BFile file;
|
||||||
|
BNodeInfo info;
|
||||||
|
char type[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
|
while (message->HasRef("refs", i)) {
|
||||||
|
BMessage msg = BMessage(B_REFS_RECEIVED);
|
||||||
|
message->FindRef("refs", i++, &ref);
|
||||||
|
msg.AddRef("refs", &ref);
|
||||||
|
|
||||||
|
file.SetTo(&ref, B_READ_ONLY);
|
||||||
|
info.SetTo(&file);
|
||||||
|
info.GetType(type);
|
||||||
|
|
||||||
|
if (BString(type) == BString("text/x-feed-entry"))
|
||||||
|
_OpenEntryFile(&msg);
|
||||||
|
else if (BString(type) == BString("application/x-feed-source"))
|
||||||
|
_OpenSourceFile(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
App::_OpenEntryFile(BMessage* refMessage)
|
||||||
|
{
|
||||||
|
const char* openWith = fPreferences->EntryOpenWith();
|
||||||
|
entry_ref openRef;
|
||||||
|
|
||||||
|
|
||||||
|
if (BMimeType(openWith).IsValid())
|
||||||
|
BRoster().Launch(openWith, refMessage);
|
||||||
|
else if (BEntry(openWith).GetRef(&openRef) == B_OK)
|
||||||
|
BRoster().Launch(&openRef, refMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
App::_OpenSourceFile(BMessage* refMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* configPath = "/boot/home/config/settings/Pogger/";
|
const char* configPath = "/boot/home/config/settings/Pogger/";
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
App(void);
|
App(void);
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
void ArgvReceived(int32 argc, char** argv);
|
void ArgvReceived(int32 argc, char** argv);
|
||||||
|
void RefsReceived(BMessage* message);
|
||||||
|
|
||||||
MainWindow* fMainWindow;
|
MainWindow* fMainWindow;
|
||||||
Preferences* fPreferences;
|
Preferences* fPreferences;
|
||||||
|
@ -30,6 +31,9 @@ public:
|
||||||
BMessageRunner* fUpdateRunner;
|
BMessageRunner* fUpdateRunner;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _OpenEntryFile(BMessage* refMessage);
|
||||||
|
void _OpenSourceFile(BMessage* refMessage);
|
||||||
|
|
||||||
FeedController* fFeedController;
|
FeedController* fFeedController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,27 @@ EntriesView::MessageReceived(BMessage* msg)
|
||||||
fOpenWithMenuField->MenuItem()->Label());
|
fOpenWithMenuField->MenuItem()->Label());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kOpenWithPath:
|
||||||
|
{
|
||||||
|
entry_ref ref;
|
||||||
|
if (msg->HasRef("refs") && msg->FindRef("refs", &ref) == B_OK) {
|
||||||
|
((App*)be_app)->fPreferences->SetEntryOpenWith(
|
||||||
|
BPath(&ref).Path());
|
||||||
|
}
|
||||||
|
|
||||||
|
delete fOpenWithPanel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kOpenWithBrowse:
|
||||||
|
{
|
||||||
|
entry_ref appsRef;
|
||||||
|
BEntry("/boot/system/apps/").GetRef(&appsRef);
|
||||||
|
|
||||||
|
fOpenWithPanel = new BFilePanel(B_OPEN_PANEL, NULL, &appsRef,
|
||||||
|
B_FILE_NODE, false, new BMessage(kOpenWithPath));
|
||||||
|
fOpenWithPanel->Show();
|
||||||
|
fOpenWithPanel->SetTarget(this);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
BGroupView::MessageReceived(msg);
|
BGroupView::MessageReceived(msg);
|
||||||
|
@ -199,19 +220,20 @@ EntriesView::_PopulateOpenWithMenu()
|
||||||
BStringList signatures;
|
BStringList signatures;
|
||||||
BMessage types;
|
BMessage types;
|
||||||
|
|
||||||
|
BMenuItem* prefItem = new BMenuItem(preferred, new BMessage(kOpenWithSelect));
|
||||||
|
prefItem->SetMarked(true);
|
||||||
|
fOpenWithMenu->AddItem(prefItem);
|
||||||
|
|
||||||
html.GetSupportingApps(&types);
|
html.GetSupportingApps(&types);
|
||||||
if (types.FindStrings("applications", &signatures) != B_OK)
|
if (types.FindStrings("applications", &signatures) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < signatures.CountStrings(); i++) {
|
for (int i = 0; i < signatures.CountStrings(); i++) {
|
||||||
BString string = signatures.StringAt(i);
|
BString string = signatures.StringAt(i);
|
||||||
|
BMenuItem* item = new BMenuItem(string, new BMessage(kOpenWithSelect));
|
||||||
if (string != preferred)
|
if (string != preferred)
|
||||||
fOpenWithMenu->AddItem(
|
fOpenWithMenu->AddItem(item);
|
||||||
new BMenuItem(string, new BMessage(kOpenWithSelect)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fOpenWithMenu->AddItem(
|
|
||||||
new BMenuItem(preferred, new BMessage(kOpenWithSelect)), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
class BBox;
|
class BBox;
|
||||||
class BButton;
|
class BButton;
|
||||||
|
class BFilePanel;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
|
@ -27,6 +28,7 @@ enum
|
||||||
kOpenUrlRadio = 'roow',
|
kOpenUrlRadio = 'roow',
|
||||||
kOpenAutoRadio = 'raow',
|
kOpenAutoRadio = 'raow',
|
||||||
kOpenWithSelect = 'mnow',
|
kOpenWithSelect = 'mnow',
|
||||||
|
kOpenWithPath = 'pbow',
|
||||||
kOpenWithBrowse = 'tbow'
|
kOpenWithBrowse = 'tbow'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +61,7 @@ private:
|
||||||
BPopUpMenu* fOpenWithMenu;
|
BPopUpMenu* fOpenWithMenu;
|
||||||
BMenuField* fOpenWithMenuField;
|
BMenuField* fOpenWithMenuField;
|
||||||
BButton* fOpenWithSelectButton;
|
BButton* fOpenWithSelectButton;
|
||||||
|
BFilePanel* fOpenWithPanel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyight 2021 Jaidyn Levesque <jadedctrl@teknik.io>
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.Pogger";
|
||||||
|
|
||||||
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
major = 0,
|
||||||
|
middle = 0,
|
||||||
|
minor = 1,
|
||||||
|
|
||||||
|
short_info = "Feed reader",
|
||||||
|
long_info = "An RSS/Atom feed service"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource file_types message {
|
||||||
|
"types" = "text/x-feed-entry",
|
||||||
|
"types" = "application/x-feed-source"
|
||||||
|
};
|
Ŝarĝante…
Reference in New Issue