Commit 006f613d authored by digitalLumberjack's avatar digitalLumberjack

compatible with configgen

parent 05c267a8
......@@ -48,7 +48,7 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/LaunchAnimation.h
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/MoveCameraAnimation.h
${CMAKE_CURRENT_SOURCE_DIR}/src/RetroboxSystem.h
${CMAKE_CURRENT_SOURCE_DIR}/src/RecalboxSystem.h
)
set(ES_SOURCES
......@@ -96,7 +96,7 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RetroboxSystem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RecalboxSystem.cpp
)
#-------------------------------------------------------------------------------
......
......@@ -6,7 +6,7 @@
*/
#include "NetworkThread.h"
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
#include "guis/GuiMsgBox.h"
......@@ -32,8 +32,8 @@ void NetworkThread::run(){
boost::this_thread::sleep(boost::posix_time::hours(1));
}
if(RetroboxSystem::getInstance()->canUpdate()){
if(RetroboxSystem::getInstance()->canUpdate()){
if(RecalboxSystem::getInstance()->canUpdate()){
if(RecalboxSystem::getInstance()->canUpdate()){
mWindow->displayMessage("AN UPDATE IS AVAILABLE FOR YOUR RECALBOX");
mRunning = false;
}
......
......@@ -5,7 +5,7 @@
* Created on 29 novembre 2014, 03:15
*/
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
#include <stdlib.h>
#include <sys/statvfs.h>
#include <sstream>
......@@ -18,19 +18,19 @@
#include "AudioManager.h"
#include "VolumeControl.h"
RetroboxSystem::RetroboxSystem() {
RecalboxSystem::RecalboxSystem() {
}
RetroboxSystem * RetroboxSystem::instance = NULL;
RecalboxSystem *RecalboxSystem::instance = NULL;
RetroboxSystem * RetroboxSystem::getInstance() {
if (RetroboxSystem::instance == NULL) {
RetroboxSystem::instance = new RetroboxSystem();
RecalboxSystem *RecalboxSystem::getInstance() {
if (RecalboxSystem::instance == NULL) {
RecalboxSystem::instance = new RecalboxSystem();
}
return RetroboxSystem::instance;
return RecalboxSystem::instance;
}
unsigned long RetroboxSystem::getFreeSpaceGB(std::string mountpoint) {
unsigned long RecalboxSystem::getFreeSpaceGB(std::string mountpoint) {
struct statvfs fiData;
const char * fnPath = mountpoint.c_str();
int free = 0;
......@@ -40,7 +40,7 @@ unsigned long RetroboxSystem::getFreeSpaceGB(std::string mountpoint) {
return free;
}
std::string RetroboxSystem::getFreeSpaceInfo() {
std::string RecalboxSystem::getFreeSpaceInfo() {
struct statvfs fiData;
std::string sharePart = Settings::getInstance()->getString("SharePartition");
if(sharePart.size() > 0){
......@@ -62,7 +62,7 @@ std::string RetroboxSystem::getFreeSpaceInfo() {
}
}
bool RetroboxSystem::isFreeSpaceLimit() {
bool RecalboxSystem::isFreeSpaceLimit() {
std::string sharePart = Settings::getInstance()->getString("SharePartition");
if(sharePart.size() > 0){
return getFreeSpaceGB(sharePart) < 2;
......@@ -72,7 +72,7 @@ bool RetroboxSystem::isFreeSpaceLimit() {
}
std::string RetroboxSystem::getVersion() {
std::string RecalboxSystem::getVersion() {
std::string version = Settings::getInstance()->getString("VersionFile");
if (version.size() > 0) {
std::ifstream ifs(version);
......@@ -86,7 +86,7 @@ std::string RetroboxSystem::getVersion() {
return "";
}
bool RetroboxSystem::needToShowVersionMessage() {
bool RecalboxSystem::needToShowVersionMessage() {
std::string versionFile = Settings::getInstance()->getString("LastVersionFile");
if (versionFile.size() > 0) {
std::ifstream lvifs(versionFile);
......@@ -102,7 +102,7 @@ bool RetroboxSystem::needToShowVersionMessage() {
return true;
}
bool RetroboxSystem::versionMessageDisplayed() {
bool RecalboxSystem::versionMessageDisplayed() {
std::string versionFile = Settings::getInstance()->getString("LastVersionFile");
std::string currentVersion = getVersion();
std::ostringstream oss;
......@@ -114,7 +114,7 @@ bool RetroboxSystem::versionMessageDisplayed() {
}
}
std::string RetroboxSystem::getVersionMessage(){
std::string RecalboxSystem::getVersionMessage(){
std::string versionMessageFile = Settings::getInstance()->getString("VersionMessage");
if (versionMessageFile.size() > 0) {
std::ifstream ifs(versionMessageFile);
......@@ -129,7 +129,7 @@ std::string RetroboxSystem::getVersionMessage(){
}
bool RetroboxSystem::setAudioOutputDevice(std::string device) {
bool RecalboxSystem::setAudioOutputDevice(std::string device) {
int commandValue = -1;
int returnValue = false;
......@@ -161,7 +161,7 @@ bool RetroboxSystem::setAudioOutputDevice(std::string device) {
bool RetroboxSystem::setOverscan(bool enable){
bool RecalboxSystem::setOverscan(bool enable){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " " << "overscan";
......@@ -181,7 +181,7 @@ bool RetroboxSystem::setOverscan(bool enable){
}
}
bool RetroboxSystem::setOverclock(std::string mode){
bool RecalboxSystem::setOverclock(std::string mode){
if(mode != ""){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " "
......@@ -199,26 +199,7 @@ bool RetroboxSystem::setOverclock(std::string mode){
}
bool RetroboxSystem::setGPIOControllers(bool enable){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " " << "gpiocontrollers";
if(enable){
oss << " " << "enable";
}else {
oss << " " << "disable";
}
std::string command = oss.str();
LOG(LogInfo) << "Launching " << command;
if(system(command.c_str())){
LOG(LogWarning) << "Error executing " << command;
return false;
}else {
LOG(LogInfo) << "Overscan set to : " << enable;
return true;
}
}
bool RetroboxSystem::updateSystem(){
bool RecalboxSystem::updateSystem(){
std::string updatecommand = Settings::getInstance()->getString("UpdateCommand");
if(updatecommand.size() > 0){
int exitcode = system(updatecommand.c_str());
......@@ -227,14 +208,14 @@ bool RetroboxSystem::updateSystem(){
return false;
}
bool RetroboxSystem::ping(){
bool RecalboxSystem::ping(){
std::string updateserver = Settings::getInstance()->getString("UpdateServer");
std::string s("ping -c 1 " + updateserver);
int exitcode = system(s.c_str());
return exitcode == 0;
}
bool RetroboxSystem::canUpdate(){
bool RecalboxSystem::canUpdate(){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " " << "canupdate";
std::string command = oss.str();
......@@ -248,7 +229,7 @@ bool RetroboxSystem::canUpdate(){
}
}
bool RetroboxSystem::launchKodi(Window * window){
bool RecalboxSystem::launchKodi(Window * window){
LOG(LogInfo) << "Attempting to launch kodi...";
......@@ -270,7 +251,7 @@ bool RetroboxSystem::launchKodi(Window * window){
}
bool RetroboxSystem::enableWifi(std::string ssid, std::string key){
bool RecalboxSystem::enableWifi(std::string ssid, std::string key){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " "
<< "wifi" << " "
......@@ -287,7 +268,7 @@ bool RetroboxSystem::enableWifi(std::string ssid, std::string key){
}
}
bool RetroboxSystem::disableWifi(){
bool RecalboxSystem::disableWifi(){
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxSettingScript") << " "
<< "wifi" << " "
......@@ -301,4 +282,44 @@ bool RetroboxSystem::disableWifi(){
LOG(LogInfo) << "Cannot disable wifi ";
return false;
}
}
\ No newline at end of file
}
std::string RecalboxSystem::getRecalboxConfig(std::string key) {
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxConfigScript") << " "
<< " -command load "
<< " -key " << key;
std::string command = oss.str();
LOG(LogInfo) << "Launching " << command;
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
return result;
}
bool RecalboxSystem::setRecalboxConfig(std::string key, std::string value) {
std::ostringstream oss;
oss << Settings::getInstance()->getString("RecalboxConfigScript") << " "
<< " -command save"
<< " -key " << key
<< " -value " << value;
std::string command = oss.str();
LOG(LogInfo) << "Launching " << command;
if(system(command.c_str()) == 0){
LOG(LogInfo) << "Wifi disabled ";
return true;
}else {
LOG(LogInfo) << "Cannot disable wifi ";
return false;
}
}
......@@ -11,11 +11,11 @@
#include "Window.h"
class RetroboxSystem {
class RecalboxSystem {
public:
static RetroboxSystem * getInstance();
static RecalboxSystem * getInstance();
unsigned long getFreeSpaceGB(std::string mountpoint);
std::string getFreeSpaceInfo();
......@@ -24,7 +24,6 @@ public:
bool setAudioOutputDevice(std::string device);
bool setOverscan(bool enable);
bool setOverclock(std::string mode);
bool setGPIOControllers(bool enable);
bool versionMessageDisplayed();
bool needToShowVersionMessage();
std::string getVersionMessage();
......@@ -34,12 +33,13 @@ public:
bool launchKodi(Window * window);
bool enableWifi(std::string ssid, std::string key);
bool disableWifi();
std::string getRecalboxConfig(std::string key);
bool setRecalboxConfig(std::string key, std::string value);
private:
static RetroboxSystem * instance;
RetroboxSystem();
static RecalboxSystem * instance;
RecalboxSystem();
};
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
#include <string>
#include "Log.h"
#include "Settings.h"
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
GuiUpdate::GuiUpdate(Window* window) : GuiComponent(window), mBusyAnim(window)
......@@ -111,7 +111,7 @@ void GuiUpdate::update(int deltaTime) {
void GuiUpdate::threadUpdate()
{
bool updateOk = RetroboxSystem::getInstance()->updateSystem();
bool updateOk = RecalboxSystem::getInstance()->updateSystem();
if(updateOk){
this->onUpdateOk();
}else {
......@@ -121,8 +121,8 @@ void GuiUpdate::threadUpdate()
void GuiUpdate::threadPing()
{
if(RetroboxSystem::getInstance()->ping()){
if(RetroboxSystem::getInstance()->canUpdate()){
if(RecalboxSystem::getInstance()->ping()){
if(RecalboxSystem::getInstance()->canUpdate()){
this->onUpdateAvailable();
}else {
this->onNoUpdateAvailable();
......
......@@ -15,7 +15,7 @@
#include "Log.h"
#include "Window.h"
#include "EmulationStation.h"
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
#include "Settings.h"
#include "ScraperCmdLine.h"
#include "VolumeControl.h"
......@@ -23,7 +23,7 @@
#include <boost/locale.hpp>
#include "resources/Font.h"
#include "NetworkThread.h"
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
......@@ -297,23 +297,36 @@ int main(int argc, char* argv[])
SDL_PushEvent(quit);
}));
}
if(Settings::getInstance()->getBool("KodiStartup")){
RetroboxSystem::getInstance()->launchKodi(&window);
}
// UPDATED VERSION MESSAGE
if(RetroboxSystem::getInstance()->needToShowVersionMessage()){
window.pushGui(new GuiMsgBox(&window,
RetroboxSystem::getInstance()->getVersionMessage(),
"OK", [] {
RetroboxSystem::getInstance()->versionMessageDisplayed();
},"",nullptr,"",nullptr, ALIGN_LEFT));
}
// UPDATE CHECK THREAD
if(Settings::getInstance()->getBool("CheckUpdates")){
NetworkThread * nthread = new NetworkThread(&window);
}
// Setting in settings for better performance
if(std::string("1").compare(RecalboxSystem::getInstance()->getRecalboxConfig("kodi.enabled")) == 0){
Settings::getInstance()->setBool("kodi.enabled", true);
}
if(std::string("1").compare(RecalboxSystem::getInstance()->getRecalboxConfig("kodi.atstartup")) == 0){
Settings::getInstance()->setBool("kodi.atstartup", true);
}
if(std::string("1").compare(RecalboxSystem::getInstance()->getRecalboxConfig("kodi.xbutton")) == 0){
Settings::getInstance()->setBool("kodi.xbutton", true);
}
if(Settings::getInstance()->getBool("kodi.enabled") &&Settings::getInstance()->getBool("kodi.atstartup")){
RecalboxSystem::getInstance()->launchKodi(&window);
}
// UPDATED VERSION MESSAGE
if(RecalboxSystem::getInstance()->needToShowVersionMessage()){
window.pushGui(new GuiMsgBox(&window,
RecalboxSystem::getInstance()->getVersionMessage(),
"OK", [] {
RecalboxSystem::getInstance()->versionMessageDisplayed();
},"",nullptr,"",nullptr, ALIGN_LEFT));
}
// UPDATE CHECK THREAD
if(std::string("1").compare(RecalboxSystem::getInstance()->getRecalboxConfig("updates.enabled"))){
NetworkThread * nthread = new NetworkThread(&window);
}
//run the command line scraper then quit
if(scrape_cmdline)
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
#include "components/HelpComponent.h"
#include "components/ImageComponent.h"
#include "guis/GuiMsgBox.h"
#include "RetroboxSystem.h"
#include "RecalboxSystem.h"
Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10),
mAllowSleep(true), mSleeping(false), mTimeSinceLastInput(0)
......@@ -131,12 +131,12 @@ void Window::input(InputConfig* config, Input input)
}
else
{
if(config->isMappedTo("x", input) && input.value && !launchKodi && Settings::getInstance()->getBool("EnableKodi") && Settings::getInstance()->getBool("XKodi")){
if(config->isMappedTo("x", input) && input.value && !launchKodi && Settings::getInstance()->getBool("kodi.enabled") && Settings::getInstance()->getBool("kodi.xbutton")){
launchKodi = true;
Window * window = this;
this->pushGui(new GuiMsgBox(this, "DO YOU WANT TO START KODI MEDIA CENTER ?", "YES",
[window, this] {
if( ! RetroboxSystem::getInstance()->launchKodi(window))
if( ! RecalboxSystem::getInstance()->launchKodi(window))
LOG(LogWarning) << "Shutdown terminated with non-zero result!";
launchKodi = false;
}, "NO", [this] {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment