Skip to content

Commit

Permalink
0.4.1.676 - Pre Alpha
Browse files Browse the repository at this point in the history
- fixed shared memory issue
- added taskkill to inno uninstaller
- added debug messages to bus
  • Loading branch information
xodj committed Jun 7, 2021
1 parent c8e6c49 commit 0ac56ac
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16.0)
#Project name and version
PROJECT(RyzenAdjCtrl VERSION 0.4.1.673 LANGUAGES CXX)
PROJECT(RyzenAdjCtrl VERSION 0.4.1.676 LANGUAGES CXX)
#Set version number in this ^^^^^^^^^
#BUILD_STANDALONE on UNIX or choose on Windows
if(WIN32)
Expand Down
57 changes: 40 additions & 17 deletions CtrlBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CTRLBUS_H

#include <QObject>
#include <QDebug>
#include "CtrlConfig.h"

#ifdef BUILD_SERVICE
Expand All @@ -15,11 +16,13 @@ class CtrlBus : public QObject
{
Q_OBJECT
public:
CtrlBus(QString qSharedMemoryKey = sharedMemoryKey)
CtrlBus(QSharedMemory *bufferToService,
QSharedMemory *bufferToGui,
QSharedMemory *guiAlreadyRunning)
: QObject(nullptr),
bufferToService(new QSharedMemory("bufferToService:" + qSharedMemoryKey)),
bufferToGui(new QSharedMemory("bufferToGui:" + qSharedMemoryKey)),
guiAlreadyRunning(new QSharedMemory("guiAlreadyRunning:" + qSharedMemoryKey))
bufferToService(bufferToService),
bufferToGui(bufferToGui),
guiAlreadyRunning(guiAlreadyRunning)
{}
~CtrlBus(){
refresh_timer->stop();
Expand All @@ -32,16 +35,26 @@ class CtrlBus : public QObject
for (int i=0;i<data.size();i++)
iodata[i] = data[i];
bufferToService->unlock();
}
} else
qDebug()<<"CtrlBus::sendMessageToService: Can't lock bufferToService!";
bufferToService->detach();
}
} else
qDebug()<<"CtrlBus::sendMessageToService: Can't attach bufferToService!";
bufferToService->detach();
}
bool isServiseRuning(){
return bufferToService->attach();
bool bReturn = false;
if(bufferToService->attach()){
bufferToService->detach();
bReturn = true;
}
return bReturn;
}
void setServiseRuning(){
bufferToService->create(buffer_size);
bufferToGui->create(buffer_size);
if(!bufferToService->create(buffer_size))
qDebug()<<"CtrlBus::setServiseRuning: Can't create bufferToService!";
if(!bufferToGui->create(buffer_size))
qDebug()<<"CtrlBus::setServiseRuning: Can't create bufferToGui!";

refresh_timer = new QTimer;
connect(refresh_timer, &QTimer::timeout,
Expand All @@ -55,13 +68,20 @@ class CtrlBus : public QObject
for (int i=0;i<data.size();i++)
iodata[i] = data[i];
bufferToGui->unlock();
}
} else
qDebug()<<"CtrlBus::sendMessageToGui: Can't lock bufferToGui!";
}
bool isGUIRuning(){
return guiAlreadyRunning->attach();
bool bReturn = false;
if(guiAlreadyRunning->attach()){
guiAlreadyRunning->detach();
bReturn = true;
}
return bReturn;
}
void setGUIRuning(){
guiAlreadyRunning->create(1);
if(!guiAlreadyRunning->create(1))
qDebug()<<"CtrlBus::setGUIRuning: Can't create guiAlreadyRunning!";

refresh_timer = new QTimer;
connect(refresh_timer, &QTimer::timeout,
Expand All @@ -84,7 +104,8 @@ class CtrlBus : public QObject
iodata[i] = '\0';
}
bufferToService->unlock();
}
} else
qDebug()<<"CtrlBus::getMessageFromGui: Can't lock bufferToService!";
if(data.size() > 0)
emit messageFromGUIRecieved(data);
}
Expand All @@ -99,9 +120,11 @@ class CtrlBus : public QObject
iodata[i] = '\0';
}
bufferToGui->unlock();
}
} else
qDebug()<<"CtrlBus::getMessageFromService: Can't lock bufferToGui!";
bufferToGui->detach();
}
} else
qDebug()<<"CtrlBus::getMessageFromService: Can't attach bufferToGui!";
if(data.size() > 0)
emit messageFromServiceRecieved(data);
}
Expand All @@ -119,9 +142,9 @@ class CtrlBus : public QObject
{
Q_OBJECT
public:
CtrlBus(QString qSharedMemoryKey = sharedMemoryKey)
CtrlBus(QSharedMemory *guiAlreadyRunning)
: QObject(nullptr),
guiAlreadyRunning(new QSharedMemory("guiAlreadyRunning:" + qSharedMemoryKey))
guiAlreadyRunning(guiAlreadyRunning)
{}
~CtrlBus(){}

Expand Down
37 changes: 35 additions & 2 deletions CtrlMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ int main(int argc, char *argv[])
checkLogsSize();
qInstallMessageHandler(messageHandler);

CtrlBus *bus = new CtrlBus;
QString qSharedMemoryKey = sharedMemoryKey;
QSharedMemory *bufferToService = new QSharedMemory("bufferToService:" + qSharedMemoryKey);
QSharedMemory *bufferToGui = new QSharedMemory("bufferToGui:" + qSharedMemoryKey);
QSharedMemory *guiAlreadyRunning = new QSharedMemory("guiAlreadyRunning:" + qSharedMemoryKey);

CtrlBus *bus = new CtrlBus(bufferToService,
bufferToGui,
guiAlreadyRunning);

if(a.arguments().contains("exit"))
return exitCommand(bus);
Expand Down Expand Up @@ -211,6 +218,32 @@ bool sudoersCheck(){
}
return fRet;
}

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

checkLogsSize();
qInstallMessageHandler(messageHandler);
fileName = "Logs/RyzenAdjCtrl.log";

QString qSharedMemoryKey = sharedMemoryKey;
QSharedMemory *guiAlreadyRunning = new QSharedMemory("guiAlreadyRunning:" + qSharedMemoryKey);

CtrlBus *bus = new CtrlBus(guiAlreadyRunning);
if(bus->isGUIRuning()){
qDebug() << "Ctrl Main - Application Is Already Running.";
qDebug() << "Ctrl Main - Exit.";
return 1;
} else {
if(!sudoersCheck())
return 1;
new CtrlService(bus, new CtrlSettings);
new CtrlGui(bus, new CtrlSettings);
}

return a.exec();
}
#else //WIN32
#include <unistd.h>
bool sudoersCheck(){
Expand All @@ -225,7 +258,6 @@ bool sudoersCheck(){
} else
return true;
}
#endif //WIN32

int main(int argc, char *argv[])
{
Expand All @@ -249,4 +281,5 @@ int main(int argc, char *argv[])

return a.exec();
}
#endif //WIN32
#endif //BUILD_SERVICE
10 changes: 6 additions & 4 deletions RyzenAdjCtrl.iss.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DisableDirPage=no
DisableProgramGroupPage=no
OutputBaseFilename=RyzenAdjCtrl-v.${STR_CTRL_VERSION}-Setup
VersionInfoVersion=${STR_CTRL_VERSION}
CloseApplications=force

[Files]
Source: "Appfolder\Config\StyleSheet.xml"; DestDir: "{app}\Config\"; Flags: ignoreversion
Expand Down Expand Up @@ -49,16 +50,17 @@ Name: "{userdesktop}\RyzenAdjCtrl"; Filename: "{app}\RyzenAdjCtrl.exe"; Tasks: d
Name: "{userstartup}\RyzenAdjCtrl"; Filename: "{app}\RyzenAdjCtrl.exe"; Tasks: addAutoStart

[Tasks]
Name: "addWindowsTask"; Description: "Autorun RyzenAdjCtrl Service at start"; GroupDescription: "Autorun:";
Name: "addAutoStart"; Description: "Autorun RyzenAdjCtrl GUI at start"; GroupDescription: "Autorun:";
Name: "addWindowsTask"; Description: "Autorun RyzenAdjCtrl Service at start"; GroupDescription: "Autorun:"
Name: "addAutoStart"; Description: "Autorun RyzenAdjCtrl GUI at start"; GroupDescription: "Autorun:"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Run]
Filename: {app}\RyzenAdjCtrl.exe; Parameters: "install"; StatusMsg: RyzenAdjCtrl Service windows tasks is installing. Please wait... Tasks: addWindowsTask
Filename: "{app}\RyzenAdjCtrl.exe"; Parameters: "install"; StatusMsg: "RyzenAdjCtrl Service windows tasks is installing. Please wait..."; Tasks: addWindowsTask
Filename: "{app}\RyzenAdjCtrl.exe"; Description: "Launch RyzenAdjCtrl"; Flags: postinstall nowait skipifsilent

[UninstallRun]
Filename: {app}\RyzenAdjCtrl.exe; Parameters: "uninstall";
Filename: "{app}\RyzenAdjCtrl.exe"; Parameters: "uninstall"
Filename: "{cmd}"; Parameters: "/C ""taskkill /im RyzenAdjCtrl.exe /f /t"

[Code]
{ ///////////////////////////////////////////////////////////////////// }
Expand Down

0 comments on commit 0ac56ac

Please sign in to comment.