Renamte ssh to Steam.
This commit is contained in:
parent
9760826252
commit
eb4989c2ef
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
16
src/main.cpp
16
src/main.cpp
@ -215,7 +215,7 @@
|
||||
#include "network/protocols/get_public_address.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/ssm.hpp"
|
||||
#include "online/steam.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "race/highscore_manager.hpp"
|
||||
#include "race/history.hpp"
|
||||
@ -1516,13 +1516,13 @@ int main(int argc, char *argv[] )
|
||||
{
|
||||
CommandLine::init(argc, argv);
|
||||
|
||||
SSM *ssm = new SSM();
|
||||
bool steam_avail = ssm->isSteamAvailable();
|
||||
std::string id = ssm->getId();
|
||||
std::string name = ssm->getName();
|
||||
int n = ssm->saveAvatarAs("test.png");
|
||||
//std::vector<std::string> friends = ssm->getFriends();
|
||||
//std::string quit = ssm->sendCommand("quit");
|
||||
Steam *steam = new Steam();
|
||||
bool steam_avail = steam->isSteamAvailable();
|
||||
std::string id = steam->getId();
|
||||
std::string name = steam->getName();
|
||||
int n = steam->saveAvatarAs("test.png");
|
||||
//std::vector<std::string> friends = steam->getFriends();
|
||||
//std::string quit = steam->sendCommand("quit");
|
||||
|
||||
CrashReporting::installHandlers();
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "online/ssm.hpp"
|
||||
#include "online/steam.hpp"
|
||||
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -24,7 +24,7 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
SSM::SSM()
|
||||
Steam::Steam()
|
||||
{
|
||||
#ifdef WIN32
|
||||
// Based on: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx
|
||||
@ -39,42 +39,42 @@ SSM::SSM()
|
||||
|
||||
if (!CreatePipe(&m_child_stdout_read, &m_child_stdout_write, &sec_attr, 0))
|
||||
{
|
||||
Log::error("SSM", "Error creating StdoutRd CreatePipe");
|
||||
Log::error("Steam", "Error creating StdoutRd CreatePipe");
|
||||
}
|
||||
|
||||
// Ensure the read handle to the pipe for STDOUT is not inherited.
|
||||
|
||||
if (!SetHandleInformation(m_child_stdout_read, HANDLE_FLAG_INHERIT, 0))
|
||||
{
|
||||
Log::error("SSM", "Stdout SetHandleInformation");
|
||||
Log::error("Steam", "Stdout SetHandleInformation");
|
||||
}
|
||||
|
||||
// Create a pipe for the child process's STDIN.
|
||||
if (!CreatePipe(&m_child_stdin_read, &m_child_stdin_write, &sec_attr, 0))
|
||||
{
|
||||
Log::error("SSM", "Stdin CreatePipe");
|
||||
Log::error("Steam", "Stdin CreatePipe");
|
||||
}
|
||||
|
||||
// Ensure the write handle to the pipe for STDIN is not inherited.
|
||||
|
||||
if (!SetHandleInformation(m_child_stdin_write, HANDLE_FLAG_INHERIT, 0))
|
||||
{
|
||||
Log::error("SSM", "Stdin SetHandleInformation");
|
||||
Log::error("Steam", "Stdin SetHandleInformation");
|
||||
}
|
||||
|
||||
// Create the child process.
|
||||
|
||||
createChildProcess();
|
||||
#endif
|
||||
} // SSM
|
||||
} // Steam
|
||||
// ----------------------------------------------------------------------------
|
||||
SSM::~SSM()
|
||||
Steam::~Steam()
|
||||
{
|
||||
|
||||
} // ~SSM
|
||||
} // ~Steam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
int SSM::createChildProcess()
|
||||
int Steam::createChildProcess()
|
||||
{
|
||||
#ifdef WIN32
|
||||
TCHAR command_line[] = TEXT("ssm.exe 1");
|
||||
@ -112,7 +112,7 @@ int SSM::createChildProcess()
|
||||
// If an error occurs, exit the application.
|
||||
if (!bSuccess)
|
||||
{
|
||||
Log::error("SSM", "CreateProcess");
|
||||
Log::error("Steam", "CreateProcess");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -129,7 +129,7 @@ int SSM::createChildProcess()
|
||||
} // createChildProcess
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string SSM::getLine()
|
||||
std::string Steam::getLine()
|
||||
{
|
||||
#define BUFSIZE 1024
|
||||
CHAR buffer[BUFSIZE];
|
||||
@ -147,7 +147,7 @@ std::string SSM::getLine()
|
||||
} // getLine
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string SSM::sendCommand(const std::string &command)
|
||||
std::string Steam::sendCommand(const std::string &command)
|
||||
{
|
||||
#ifdef WIN32
|
||||
// Write to the pipe that is the standard input for a child process.
|
||||
@ -163,7 +163,7 @@ std::string SSM::sendCommand(const std::string &command)
|
||||
} // sendCommand
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string SSM::decodeString(const std::string &s)
|
||||
std::string Steam::decodeString(const std::string &s)
|
||||
{
|
||||
std::vector<std::string> l = StringUtils::split(s, ' ');
|
||||
if (l.size() != 2) return "INVALID ANSWER - wrong number of fields";
|
||||
@ -180,7 +180,7 @@ std::string SSM::decodeString(const std::string &s)
|
||||
/** Returns the steam user name. SSM returns 'N name" where N is
|
||||
* the length of the name.
|
||||
*/
|
||||
std::string SSM::getName()
|
||||
std::string Steam::getName()
|
||||
{
|
||||
std::string s = sendCommand("name");
|
||||
return decodeString(s);
|
||||
@ -190,7 +190,7 @@ std::string SSM::getName()
|
||||
/** Returns a unique id (string) from steam. SSM returns 'N ID" where N is
|
||||
* the length of the ID.
|
||||
*/
|
||||
std::string SSM::getId()
|
||||
std::string Steam::getId()
|
||||
{
|
||||
std::string s = sendCommand("id");
|
||||
return decodeString(s);
|
||||
@ -200,7 +200,7 @@ std::string SSM::getId()
|
||||
/** Returns a std::vector with the names of all friends. SSM returns a first
|
||||
* line with the number of friends, then one friend in a line.
|
||||
*/
|
||||
std::vector<std::string> SSM::getFriends()
|
||||
std::vector<std::string> Steam::getFriends()
|
||||
{
|
||||
std::string s = sendCommand("friends");
|
||||
int num_friends;
|
||||
@ -214,7 +214,7 @@ std::vector<std::string> SSM::getFriends()
|
||||
return result;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
int SSM::saveAvatarAs(const std::string filename)
|
||||
int Steam::saveAvatarAs(const std::string filename)
|
||||
{
|
||||
//std::string s = sendCommand(std::string("avatar ")+filename);
|
||||
std::string s = sendCommand("avatar");
|
@ -15,8 +15,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SSM_HPP
|
||||
#define HEADER_SSM_HPP
|
||||
#ifndef HEADER_STEAM_HPP
|
||||
#define HEADER_STEAM_HPP
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
@ -25,7 +25,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class SSM
|
||||
/** This class provides a simple interface to the SteamWorks API. Due to
|
||||
* our current license, the SteamWorks lib can not be linked with STK.
|
||||
* So this wrapper class actually starts a seprate process (ssm, see
|
||||
* https://github.com/hiker/steam-synchron-manager) and communicats
|
||||
* with the SSM using pipes.
|
||||
*/
|
||||
class Steam
|
||||
{
|
||||
private:
|
||||
#ifdef WIN32
|
||||
@ -43,16 +49,16 @@ private:
|
||||
std::string sendCommand(const std::string &command);
|
||||
std::string getLine();
|
||||
public:
|
||||
SSM();
|
||||
~SSM();
|
||||
Steam();
|
||||
~Steam();
|
||||
std::string getName();
|
||||
std::string getId();
|
||||
int saveAvatarAs(const std::string filename);
|
||||
std::vector<std::string> getFriends();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the connection to the SSM was successful, i.e.
|
||||
/** Returns true if the connection to the Steam API was successful, i.e.
|
||||
* connection to steam worked, and SteamWorks API could be initialised. */
|
||||
bool isSteamAvailable() { return m_steam_available; }
|
||||
}; // class SSM
|
||||
}; // class Steam
|
||||
|
||||
#endif // HEADER_SSM_HPP
|
||||
#endif // HEADER_STEAM_HPP
|
Loading…
Reference in New Issue
Block a user