Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new commits #1

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ReviveOverlay: Update multiplayer fix
- Update multiplayer fix so the Oauth token is retrieved from locally stored Oculus client offline data, rather than a local instance of the Oculus platform
- Remove login option from tray
- Add notification upon launching common multiplayer titles if Oauth token is unable to be retrieved
  • Loading branch information
ahmanwoods committed Sep 5, 2022
commit aea57c5b6054d9f92770189f695109472e8ebb29
1 change: 0 additions & 1 deletion ReviveOverlay/Overlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ Rectangle {
if (Revive.launchApplication(appKey)) {
activateSound.play();
currentAppId = appId;
Platform.reLogin(appId);
heartbeat.start();
} else {
failSound.play();
Expand Down
10 changes: 5 additions & 5 deletions ReviveOverlay/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "openvroverlaycontroller.h"
#include "revivemanifestcontroller.h"
#include "windowsservices.h"
#include "oculusplatform.h"
#include "oculusoauthtokencontroller.h"
#include <qt_windows.h>
#include <winsparkle.h>

Expand All @@ -19,7 +19,7 @@
#include <QSslSocket>

extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}

Expand Down Expand Up @@ -81,14 +81,14 @@ int main(int argc, char *argv[])
if (!CReviveManifestController::SharedInstance()->Init())
qDebug("Failed to initialize the revive manifest");

if (!COculusPlatform::SharedInstance()->Init(CReviveManifestController::SharedInstance()->GetBasePath()))
qDebug("Failed to initialize the oculus platform");
if (!COculusOauthTokenController::SharedInstance()->Init())
qDebug("Failed to initialize the Oculus Oauth token");

// Create a QML engine.
QQmlEngine qmlEngine;
qmlEngine.rootContext()->setContextProperty("Revive", CReviveManifestController::SharedInstance());
qmlEngine.rootContext()->setContextProperty("OpenVR", COpenVROverlayController::SharedInstance());
qmlEngine.rootContext()->setContextProperty("Platform", COculusPlatform::SharedInstance());
qmlEngine.rootContext()->setContextProperty("Platform", COculusOauthTokenController::SharedInstance());

QQmlComponent qmlComponent( &qmlEngine, QUrl("qrc:/Overlay.qml"));
if (qmlComponent.isError())
Expand Down
106 changes: 106 additions & 0 deletions ReviveOverlay/oculusoauthtokencontroller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#include "oculusoauthtokencontroller.h"
#include "trayiconcontroller.h"
#include "windowsservices.h"
#include <stdlib.h>

#include <QCoreApplication>

COculusOauthTokenController *COculusOauthTokenController::SharedInstance()
{
static COculusOauthTokenController *instance = nullptr;
if ( !instance )
{
instance = new COculusOauthTokenController();
}
return instance;
}

COculusOauthTokenController::COculusOauthTokenController()
: m_strAccessToken()
, m_roamingAppDataPath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))
{
}

COculusOauthTokenController::~COculusOauthTokenController()
{
}

bool COculusOauthTokenController::Init()
{
//Clean up saved credentials from previous versions as they're no longer needed
WindowsServices::DeleteCredentials();
//cd up from %APPDATA%/Roaming/APPNAME to %APPDATA%/Roaming
m_roamingAppDataPath.cdUp();

if(LoadToken())
{
return true;
}

CTrayIconController::SharedInstance()->ShowInformation(TrayInfo_OculusAccessTokenNotFound);
return false;
}

bool COculusOauthTokenController::LoadToken()
{
QString oculusOfflineDb = m_roamingAppDataPath.filePath("Oculus/Sessions/_oaf/data.sqlite");
QString tempOculusOfflineDB = m_roamingAppDataPath.filePath("Oculus/Sessions/_oaf/revive_data.sqlite");

if (!QFile::exists(oculusOfflineDb))
return false;

//Check for temp db that somehow missed cleanup
if (QFile::exists(tempOculusOfflineDB))
QFile::remove(tempOculusOfflineDB);

//The SQLite DB is locked by the oculus service, so we need to make a copy
QFile::copy(oculusOfflineDb, tempOculusOfflineDB);
QSqlDatabase sqliteDb = QSqlDatabase::addDatabase( "QSQLITE" );
sqliteDb.setDatabaseName(tempOculusOfflineDB);

if(!sqliteDb.open())
{
QFile::remove(tempOculusOfflineDB);
return false;
}

QSqlQuery query = QSqlQuery( sqliteDb );
if( !query.exec( "SELECT value FROM 'Objects' WHERE hashkey = '__OAF_OFFLINE_DATA_KEY__'" ))
{
QFile::remove(tempOculusOfflineDB);
return false;
}
query.first();

QByteArray offlineDataByteArray = query.value(0).toByteArray();
if (!offlineDataByteArray.contains("last_valid_auth_token"))
{
QFile::remove(tempOculusOfflineDB);
return false;
}
qsizetype token_start_index = offlineDataByteArray.indexOf("last_valid_auth_token") + 31;

qsizetype token_stop_index = -1;
if(offlineDataByteArray.contains("last_valid_fb_access_token"))
{
token_stop_index = offlineDataByteArray.indexOf("last_valid_fb_access_token") - 4;
}

if ( offlineDataByteArray.mid(token_start_index).contains("last_valid_auth_token_type"))
{
/*'last_valid_auth_token_type' matches 'last_valid_auth_token' in indexOf, so
search after the index of 'last_valid_auth_token' */
token_stop_index = offlineDataByteArray.mid(token_start_index).indexOf("last_valid_auth_token_type") - 4;
}

if (token_stop_index == -1)
{
return false;
}

m_strAccessToken = QString::fromStdString(offlineDataByteArray.mid(token_start_index, token_stop_index).toStdString());
TokenChanged();
qDebug("Oculus Oauth token: %s", qUtf8Printable(m_strAccessToken));
QFile::remove(tempOculusOfflineDB);
return true;
}
44 changes: 44 additions & 0 deletions ReviveOverlay/oculusoauthtokencontroller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef OCULUSOAUTHTOKENCONTROLLER_H
#define OCULUSOAUTHTOKENCONTROLLER_H

#include <QObject>
#include <QString>
#include <QLibrary>
#include <QTimer>
#include <QFile>
#include <QtSql>

typedef struct {
} ovrOculusInitParams;

class COculusOauthTokenController : public QObject
{
Q_OBJECT
typedef QObject BaseClass;

Q_PROPERTY(bool connected READ Connected NOTIFY TokenChanged);
Q_PROPERTY(QString AccessToken READ GetToken NOTIFY TokenChanged);
public:
static COculusOauthTokenController *SharedInstance();

public:
COculusOauthTokenController();
virtual ~COculusOauthTokenController();

bool Init();
bool LoadToken();

bool Connected() { return !m_strAccessToken.isEmpty(); }
QString GetToken() { return m_strAccessToken; }

signals:
void TokenChanged();

protected slots:

private:
QString m_strAccessToken;
QDir m_roamingAppDataPath;
};

#endif // OCULUSOAUTHTOKENCONTROLLER_H
137 changes: 0 additions & 137 deletions ReviveOverlay/oculusplatform.cpp

This file was deleted.

Loading