-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for 'flashpoint://' protocol
CLIFp can register itself to respond to use of the above URL scheme in order to start titles. Additionally, the new 'share' command will generate links based on titles that use the protocol and adds them to the clipboard so that users can more easily share them. Also implements an https redirect page to be hosted on GitHub that redirects to a FP protocol link. This is useful so that users can still share links on messageing platforms that don't allow for custom scheme hyperlinks directly.
- Loading branch information
1 parent
6964b13
commit 705072b
Showing
21 changed files
with
473 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Unit Include | ||
#include "c-share.h" | ||
|
||
// Qx Includes | ||
#include <qx/core/qx-system.h> | ||
|
||
// Project Includes | ||
#include "task/t-message.h" | ||
#include "utility.h" | ||
|
||
//=============================================================================================================== | ||
// CShareError | ||
//=============================================================================================================== | ||
|
||
//-Constructor------------------------------------------------------------- | ||
//Private: | ||
CShareError::CShareError(Type t, const QString& s) : | ||
mType(t), | ||
mSpecific(s) | ||
{} | ||
|
||
//-Instance Functions------------------------------------------------------------- | ||
//Public: | ||
bool CShareError::isValid() const { return mType != NoError; } | ||
QString CShareError::specific() const { return mSpecific; } | ||
CShareError::Type CShareError::type() const { return mType; } | ||
|
||
//Private: | ||
Qx::Severity CShareError::deriveSeverity() const { return Qx::Critical; } | ||
quint32 CShareError::deriveValue() const { return mType; } | ||
QString CShareError::derivePrimary() const { return ERR_STRINGS.value(mType); } | ||
QString CShareError::deriveSecondary() const { return mSpecific; } | ||
|
||
//=============================================================================================================== | ||
// CShare | ||
//=============================================================================================================== | ||
|
||
//-Constructor------------------------------------------------------------- | ||
//Public: | ||
CShare::CShare(Core& coreRef) : TitleCommand(coreRef) {} | ||
|
||
//-Instance Functions------------------------------------------------------------- | ||
//Protected: | ||
QList<const QCommandLineOption*> CShare::options() { return CL_OPTIONS_SPECIFIC + TitleCommand::options(); } | ||
QString CShare::name() { return NAME; } | ||
|
||
Qx::Error CShare::perform() | ||
{ | ||
// Prioritize scheme (un)registration | ||
if(mParser.isSet(CL_OPTION_CONFIGURE)) | ||
{ | ||
mCore.logEvent(NAME, LOG_EVENT_REGISTRATION); | ||
|
||
if(!Qx::setDefaultProtocolHandler(SCHEME, SCHEME_NAME, QDir::toNativeSeparators(CLIFP_PATH), {"play", "-u"})) | ||
{ | ||
CShareError err(CShareError::RegistrationFailed); | ||
mCore.postError(NAME, err); | ||
return err; | ||
} | ||
|
||
// Enqueue success message task | ||
TMessage* successMsg = new TMessage(&mCore); | ||
successMsg->setStage(Task::Stage::Primary); | ||
successMsg->setText(MSG_REGISTRATION_COMPLETE); | ||
mCore.enqueueSingleTask(successMsg); | ||
|
||
return CShareError(); | ||
} | ||
else if(mParser.isSet(CL_OPTION_UNCONFIGURE)) | ||
{ | ||
mCore.logEvent(NAME, LOG_EVENT_UNREGISTRATION); | ||
|
||
if(!Qx::removeDefaultProtocolHandler(SCHEME, SCHEME_NAME)) | ||
{ | ||
CShareError err(CShareError::UnregistrationFailed); | ||
mCore.postError(NAME, err); | ||
return err; | ||
} | ||
|
||
// Enqueue success message task | ||
TMessage* successMsg = new TMessage(&mCore); | ||
successMsg->setStage(Task::Stage::Primary); | ||
successMsg->setText(MSG_UNREGISTRATION_COMPLETE); | ||
mCore.enqueueSingleTask(successMsg); | ||
|
||
return CShareError(); | ||
} | ||
|
||
// Get ID of title to share | ||
QUuid shareId; | ||
if(Qx::Error ide = getTitleId(shareId); ide.isValid()) | ||
return ide; | ||
|
||
mCore.setStatus(STATUS_SHARE, shareId.toString(QUuid::WithoutBraces)); | ||
|
||
// Generate URL | ||
QString idStr = shareId.toString(QUuid::WithoutBraces); | ||
QString shareUrl = mParser.isSet(CL_OPTION_UNIVERSAL) ? SCHEME_TEMPLATE_UNI.arg(idStr) : SCHEME_TEMPLATE_STD.arg(idStr); | ||
mCore.logEvent(NAME, LOG_EVENT_URL.arg(shareUrl)); | ||
|
||
// Add URL to clipboard | ||
mCore.requestClipboardUpdate(shareUrl); | ||
|
||
// Enqueue message task | ||
TMessage* urlMsg = new TMessage(&mCore); | ||
urlMsg->setStage(Task::Stage::Primary); | ||
urlMsg->setText(MSG_GENERATED_URL.arg(shareUrl)); | ||
urlMsg->setSelectable(true); | ||
mCore.enqueueSingleTask(urlMsg); | ||
|
||
// Return success | ||
return Qx::Error(); | ||
} |
Oops, something went wrong.