Convert setup to new paths

This commit is contained in:
Vasily
2019-03-19 16:10:35 +01:00
committed by username223
parent 98d1a62947
commit 04c59d5f20
3 changed files with 18 additions and 37 deletions
+1 -2
View File
@@ -87,8 +87,7 @@ int main( int argc, char* argv[] )
} }
else else
{ {
manifest::installApplicationManifest( manifest::installApplicationManifest( *manifestPath );
QString::fromStdString( *manifestPath ) );
} }
} }
catch ( std::exception& e ) catch ( std::exception& e )
+14 -32
View File
@@ -116,17 +116,10 @@ void enableApplicationAutostart()
// Installs the application manifest. If a manifest with the same application // Installs the application manifest. If a manifest with the same application
// key is already installed, nothing will happen. // key is already installed, nothing will happen.
// OpenVR must be initialized before calling this function. // OpenVR must be initialized before calling this function.
void installApplicationManifest( const QString manifestPath ) void installApplicationManifest( const std::string manifestPath )
{ {
if ( vr::VRApplications()->IsApplicationInstalled( const auto app_error
application_strings::applicationKey ) ) = vr::VRApplications()->AddApplicationManifest( manifestPath.c_str() );
{
// We don't want to disrupt applications that are already installed.
return;
}
const auto app_error = vr::VRApplications()->AddApplicationManifest(
QDir::toNativeSeparators( manifestPath ).toStdString().c_str() );
if ( app_error != vr::VRApplicationError_None ) if ( app_error != vr::VRApplicationError_None )
{ {
throw std::runtime_error( throw std::runtime_error(
@@ -138,33 +131,18 @@ void installApplicationManifest( const QString manifestPath )
} }
// Removes the application manifest. // Removes the application manifest.
void removeApplicationManifest( const QString manifestPath ) void removeApplicationManifest( const std::string manifestPath )
{ {
if ( !QFile::exists( manifestPath ) )
{
throw std::runtime_error(
std::string( "Could not find application manifest: " )
+ manifestPath.toStdString() );
}
if ( vr::VRApplications()->IsApplicationInstalled( if ( vr::VRApplications()->IsApplicationInstalled(
application_strings::applicationKey ) ) application_strings::applicationKey ) )
{ {
vr::VRApplications()->RemoveApplicationManifest( vr::VRApplications()->RemoveApplicationManifest( manifestPath.c_str() );
QDir::toNativeSeparators( manifestPath ).toStdString().c_str() );
} }
} }
// Removes and then installs the application manifest. // Removes and then installs the application manifest.
void reinstallApplicationManifest( const QString manifestPath ) void reinstallApplicationManifest( const std::string manifestPath )
{ {
if ( !QFile::exists( manifestPath ) )
{
throw std::runtime_error(
std::string( "Could not find application manifest: " )
+ manifestPath.toStdString() );
}
if ( vr::VRApplications()->IsApplicationInstalled( if ( vr::VRApplications()->IsApplicationInstalled(
application_strings::applicationKey ) ) application_strings::applicationKey ) )
{ {
@@ -217,18 +195,22 @@ void reinstallApplicationManifest( const QString manifestPath )
try try
{ {
const auto manifestPath const auto manifestPath
= QDir::cleanPath( QDir( QCoreApplication::applicationDirPath() ) = paths::binaryDirectoryFindFile( manifest::kVRManifestName );
.absoluteFilePath( kVRManifestName ) );
if ( !manifestPath.has_value() )
{
throw std::runtime_error( "Could not find application manifest." );
}
if ( installManifest ) if ( installManifest )
{ {
reinstallApplicationManifest( manifestPath ); reinstallApplicationManifest( *manifestPath );
enableApplicationAutostart(); enableApplicationAutostart();
LOG( INFO ) << "Manifest reinstalled."; LOG( INFO ) << "Manifest reinstalled.";
} }
else if ( removeManifest ) else if ( removeManifest )
{ {
removeApplicationManifest( manifestPath ); removeApplicationManifest( *manifestPath );
LOG( INFO ) << "Manifest removed."; LOG( INFO ) << "Manifest removed.";
} }
} }
+3 -3
View File
@@ -98,9 +98,9 @@ namespace manifest
constexpr auto kVRManifestName = "manifest.vrmanifest"; constexpr auto kVRManifestName = "manifest.vrmanifest";
void enableApplicationAutostart(); void enableApplicationAutostart();
void installApplicationManifest( const QString manifestPath ); void installApplicationManifest( const std::string manifestPath );
void removeApplicationManifest( const QString manifestPath ); void removeApplicationManifest( const std::string manifestPath );
void reinstallApplicationManifest( const QString manifestPath ); void reinstallApplicationManifest( const std::string manifestPath );
[[noreturn]] void handleManifests( const bool installManifest, [[noreturn]] void handleManifests( const bool installManifest,
const bool removeManifest ); const bool removeManifest );