Skip to content

Commit

Permalink
Change protocol handling to allow sending the URI as a single argument
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Oct 26, 2023
1 parent 8a35677 commit d1f23ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/command/c-share.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Qx::Error CShare::perform()
{
mCore.logEvent(NAME, LOG_EVENT_REGISTRATION);

if(!Qx::setDefaultProtocolHandler(SCHEME, SCHEME_NAME, CLIFP_PATH, {u"play"_s, u"-u"_s}))
if(!Qx::setDefaultProtocolHandler(SCHEME, SCHEME_NAME))
{
CShareError err(CShareError::RegistrationFailed);
mCore.postError(NAME, err);
Expand Down
11 changes: 10 additions & 1 deletion app/src/kernel/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,16 @@ Qx::Error Core::initialize(QStringList& commandLine)
logEvent(NAME, LOG_EVENT_G_HELP_SHOWN);
}
else
commandLine = clParser.positionalArguments(); // Remove core options from command line list
{
QStringList pArgs = clParser.positionalArguments();
if(pArgs.count() == 1 && pArgs.front().startsWith(FLASHPOINT_PROTOCOL_SCHEME))
{
logEvent(NAME, LOG_EVENT_PROTOCOL_FORWARD);
commandLine = {"play", "-u", pArgs.front()};
}
else
commandLine = pArgs; // Remove core options from command line list
}

// Return success
return CoreError();
Expand Down
9 changes: 9 additions & 0 deletions app/src/kernel/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class Core : public QObject

//-Class Structs---------------------------------------------------------------------
public:
/* TODO: These should be made their own files like message.h is in frontend
* (or one file, like "requests.h"), or message.h should be removed with its
* struct moved to here
*/
struct Error
{
QString source;
Expand Down Expand Up @@ -117,6 +121,7 @@ class Core : public QObject
QStringList items;
};


//-Class Variables------------------------------------------------------------------------------------------------------
public:
// Status
Expand All @@ -143,6 +148,7 @@ class Core : public QObject
static inline const QString LOG_EVENT_G_HELP_SHOWN = u"Displayed general help information"_s;
static inline const QString LOG_EVENT_VER_SHOWN = u"Displayed version information"_s;
static inline const QString LOG_EVENT_NOTIFCATION_LEVEL = u"Notification Level is: %1"_s;
static inline const QString LOG_EVENT_PROTOCOL_FORWARD = u"Delegated protocol request to 'play'"_s;
static inline const QString LOG_EVENT_FLASHPOINT_VERSION_TXT = u"Flashpoint version.txt: %1"_s;
static inline const QString LOG_EVENT_FLASHPOINT_VERSION = u"Flashpoint version: %1"_s;
static inline const QString LOG_EVENT_FLASHPOINT_EDITION = u"Flashpoint edition: %1"_s;
Expand Down Expand Up @@ -216,6 +222,9 @@ class Core : public QObject
// Helper
static const int FIND_ENTRY_LIMIT = 20;

// Protocol
static inline const QString FLASHPOINT_PROTOCOL_SCHEME = u"flashpoint://"_s;

// Meta
static inline const QString NAME = u"core"_s;

Expand Down

0 comments on commit d1f23ef

Please sign in to comment.