Fixed Manifest Behavor (#199)

* fixed Manifest install/un-install behavior

* removed un-used param

* fixed double or in log msg
This commit is contained in:
ykeara
2019-05-18 12:00:32 -05:00
committed by GitHub
parent 3d50eb7995
commit 511b189efd
2 changed files with 84 additions and 14 deletions
+83 -14
View File
@@ -117,15 +117,30 @@ void enableApplicationAutostart()
// OpenVR must be initialized before calling this function. // OpenVR must be initialized before calling this function.
void installApplicationManifest( const std::string manifestPath ) void installApplicationManifest( const std::string manifestPath )
{ {
const auto app_error if ( vr::VRApplications()->IsApplicationInstalled(
= vr::VRApplications()->AddApplicationManifest( manifestPath.c_str() ); application_strings::applicationKey ) )
if ( app_error != vr::VRApplicationError_None )
{ {
throw std::runtime_error( LOG( ERROR ) << "Manifest Is already Installed for Key "
std::string( "Could not add application manifest: " ) << application_strings::applicationKey;
+ std::string( LOG( ERROR ) << "You may have installed Advanced Settings in another "
vr::VRApplications()->GetApplicationsErrorNameFromEnum( "directory please remove it OR"
app_error ) ) ); " manually delete the manifest install in in Steam "
"install at Steam\\config\\appconfig.json";
}
else
{
const auto app_error = vr::VRApplications()->AddApplicationManifest(
manifestPath.c_str() );
LOG( INFO ) << "Manifest Installed at: " << manifestPath;
if ( app_error != vr::VRApplicationError_None )
{
throw std::runtime_error(
std::string( "Could not add application manifest: " )
+ std::string(
vr::VRApplications()->GetApplicationsErrorNameFromEnum(
app_error ) ) );
}
vr::VRSettings()->Sync( true );
} }
} }
@@ -136,6 +151,19 @@ void removeApplicationManifest( const std::string manifestPath )
application_strings::applicationKey ) ) application_strings::applicationKey ) )
{ {
vr::VRApplications()->RemoveApplicationManifest( manifestPath.c_str() ); vr::VRApplications()->RemoveApplicationManifest( manifestPath.c_str() );
LOG( INFO ) << "Attempting to Remove Manifest At: " << manifestPath;
vr::VRSettings()->Sync( true );
}
if ( vr::VRApplications()->IsApplicationInstalled(
application_strings::applicationKey ) )
{
LOG( ERROR ) << "Removal Failed, run Advanced Settings from previous "
"install directory OR manually delete it in Steam "
"install at Steam\\config\\appconfig.json";
}
else
{
LOG( INFO ) << "Manifest Removed Successfully";
} }
} }
@@ -168,15 +196,55 @@ void reinstallApplicationManifest( const std::string manifestPath )
} }
const auto oldManifestPath const auto oldManifestPath
= QDir::cleanPath( QDir( oldApplicationWorkingDir ) = QDir::toNativeSeparators(
.absoluteFilePath( kVRManifestName ) ); QDir::cleanPath( QDir( oldApplicationWorkingDir )
.absoluteFilePath( kVRManifestName ) ) )
removeApplicationManifest( manifestPath ); .toStdString();
removeApplicationManifest( oldManifestPath );
} }
installApplicationManifest( manifestPath ); installApplicationManifest( manifestPath );
} }
void forceRemoveApplicationManifest()
{
if ( vr::VRApplications()->IsApplicationInstalled(
application_strings::applicationKey ) )
{
// String size was arbitrarily chosen by original author.
constexpr auto kStringSize = 1024;
char oldApplicationWorkingDir[kStringSize] = { 0 };
auto app_error = vr::VRApplicationError_None;
vr::VRApplications()->GetApplicationPropertyString(
application_strings::applicationKey,
vr::VRApplicationProperty_WorkingDirectory_String,
oldApplicationWorkingDir,
kStringSize,
&app_error );
if ( app_error != vr::VRApplicationError_None )
{
throw std::runtime_error(
"Could not find working directory of already "
"installed application: "
+ std::string(
vr::VRApplications()->GetApplicationsErrorNameFromEnum(
app_error ) ) );
}
const auto oldManifestPath
= QDir::toNativeSeparators(
QDir::cleanPath( QDir( oldApplicationWorkingDir )
.absoluteFilePath( kVRManifestName ) ) )
.toStdString();
removeApplicationManifest( oldManifestPath );
}
else
{
LOG( INFO ) << "No Manifest Installed";
}
}
// Initializes OpenVR and calls the relevant manifest functions. // Initializes OpenVR and calls the relevant manifest functions.
// The .vrmanifest is used by SteamVR however the exact functiontionality is not // The .vrmanifest is used by SteamVR however the exact functiontionality is not
// documented in the official documentation. // documented in the official documentation.
@@ -201,7 +269,8 @@ void reinstallApplicationManifest( const std::string manifestPath )
{ {
throw std::runtime_error( "Could not find application manifest." ); throw std::runtime_error( "Could not find application manifest." );
} }
// Keep Settings Clean
vr::VRSettings()->Sync( true );
if ( installManifest ) if ( installManifest )
{ {
reinstallApplicationManifest( *manifestPath ); reinstallApplicationManifest( *manifestPath );
@@ -210,7 +279,7 @@ void reinstallApplicationManifest( const std::string manifestPath )
} }
else if ( removeManifest ) else if ( removeManifest )
{ {
removeApplicationManifest( *manifestPath ); forceRemoveApplicationManifest();
LOG( INFO ) << "Manifest removed."; LOG( INFO ) << "Manifest removed.";
} }
} }
+1
View File
@@ -101,6 +101,7 @@ void enableApplicationAutostart();
void installApplicationManifest( const std::string manifestPath ); void installApplicationManifest( const std::string manifestPath );
void removeApplicationManifest( const std::string manifestPath ); void removeApplicationManifest( const std::string manifestPath );
void reinstallApplicationManifest( const std::string manifestPath ); void reinstallApplicationManifest( const std::string manifestPath );
void forceRemoveApplicationManifest();
[[noreturn]] void handleManifests( const bool installManifest, [[noreturn]] void handleManifests( const bool installManifest,
const bool removeManifest ); const bool removeManifest );