Skip to content

Commit

Permalink
Merge pull request #26 from OOPMan/issue_21_update_documentation
Browse files Browse the repository at this point in the history
Issue 21 update documentation
  • Loading branch information
OOPMan authored Jul 19, 2021
2 parents 7042e41 + 4d9407a commit b8872e5
Show file tree
Hide file tree
Showing 57 changed files with 795 additions and 153 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,9 @@ compile_commands.json

# Ignore libwdi dependencies
libusb-win32
libusbK
libusbK

# Ignore installer artifacts
xbofs.win.7z
XBOFS.win.1.0.0.exe

12 changes: 10 additions & 2 deletions DriverManager/DriverManager.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
<QtInstall>6.1.1 msvc2019_64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
<QtDeploy>true</QtDeploy>
<QtDeploy>false</QtDeploy>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>6.1.1 msvc2019_64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>release</QtBuildConfig>
<QtDeploy>true</QtDeploy>
<QtDeploy>false</QtDeploy>
</PropertyGroup>
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
Expand Down Expand Up @@ -76,6 +76,10 @@
<AdditionalDependencies>libwdi.lib;winusb.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -87,6 +91,10 @@
<AdditionalDependencies>libwdi.lib;winusb.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
Expand Down
44 changes: 41 additions & 3 deletions DriverManager/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
#include "DriverManager.h"
#include <QtWidgets/QApplication>

/*
* Single instance limiting function from https://www.qtcentre.org/threads/14079-How-to-detect-that-first-instance-of-application-is-already-running
*/
class SingleInstanceLimiter
{
protected:
DWORD m_dwLastError;
HANDLE m_hMutex;

public:
SingleInstanceLimiter(TCHAR* strMutexName)
{
//Make sure that you use a name that is unique for this application otherwise
//two apps may think they are the same if they are using same name for
//3rd parm to CreateMutex
m_hMutex = CreateMutex(NULL, FALSE, strMutexName); //do early
m_dwLastError = GetLastError(); //save for use later...
}

~SingleInstanceLimiter()
{
if (m_hMutex) //Do not forget to close handles.
{
CloseHandle(m_hMutex); //Do as late as possible.
m_hMutex = NULL; //Good habit to be in.
}
}

BOOL isAnotherInstanceRunning()
{
return (ERROR_ALREADY_EXISTS == m_dwLastError);
}
};

int main(int argc, char *argv[])
{
QApplication application(argc, argv);
DriverManager mainWindow;
mainWindow.show();
return application.exec();
SingleInstanceLimiter limiter(TEXT("Global\\{58f8ed20-bc18-4523-9ec2-cd6e06f56767}"));
if (!limiter.isAnotherInstanceRunning()) {
DriverManager mainWindow;
mainWindow.show();
return application.exec();
}
return -1;
}
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2019 Adam Jorgensen
Copyright 2019-2021 Adam Jorgensen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
Expand Down
2 changes: 1 addition & 1 deletion XBOFS.win.qt/DebuggingDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>XBOFS.win: Debugging</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
Expand Down
1 change: 1 addition & 0 deletions XBOFS.win.qt/WinUsbDeviceTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void WinUsbDeviceTabWidget::handleActiveProfileComboBoxCurrentIndexChanged(int i
void WinUsbDeviceTabWidget::handleAddProfilePushButtonClicked(bool checked) {
bool ok;
QString profileName = QInputDialog::getText(this, "Add Profile", "Profile Name", QLineEdit::Normal, "", &ok);
if (profileName.length() > 255) profileName.resize(255);
if (ok && !profileName.isEmpty() && ui.activeProfileComboBox->findText(profileName) == -1) {
ui.activeProfileComboBox->addItem(profileName);
auto profileDeletedKey = QString("%1/%2").arg(profileName, DELETED);
Expand Down
2 changes: 1 addition & 1 deletion XBOFS.win.qt/XBOFSWinQTGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ XBOFSWinQTGUI::XBOFSWinQTGUI(std::shared_ptr<spdlog::logger> logger, QWidget *pa
networkManager->head(QNetworkRequest(QUrl("https://github.com/OOPMan/XBOFS.win/releases/latest")));
}
// Show or hide
show();
if (startMinimized) hide();
else show();
}

void XBOFSWinQTGUI::handleDriverManagerLinkedClick(const QString& link)
Expand Down
2 changes: 1 addition & 1 deletion XBOFS.win.qt/XBOFSWinQTGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "ui_XBOFSWinQTGUI.h"
#include "ui_WinUsbDeviceWidget.h"

const QString VERSION("v0.5.0");
const QString VERSION("v1.0.0");

using namespace XBOFSWin::settings;

Expand Down
48 changes: 45 additions & 3 deletions XBOFS.win.qt/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
#include <string>
#include <qapplication.h>
#include <qmessagebox.h>
#include <qmetatype.h>
#include <spdlog/sinks/rotating_file_sink.h>

#include "XBOFSWinQTGUI.h"

/*
* Single instance limiting function from https://www.qtcentre.org/threads/14079-How-to-detect-that-first-instance-of-application-is-already-running
*/
class SingleInstanceLimiter
{
protected:
DWORD m_dwLastError;
HANDLE m_hMutex;

public:
SingleInstanceLimiter(TCHAR* strMutexName)
{
//Make sure that you use a name that is unique for this application otherwise
//two apps may think they are the same if they are using same name for
//3rd parm to CreateMutex
m_hMutex = CreateMutex(NULL, FALSE, strMutexName); //do early
m_dwLastError = GetLastError(); //save for use later...
}

~SingleInstanceLimiter()
{
if (m_hMutex) //Do not forget to close handles.
{
CloseHandle(m_hMutex); //Do as late as possible.
m_hMutex = NULL; //Good habit to be in.
}
}

BOOL isAnotherInstanceRunning()
{
return (ERROR_ALREADY_EXISTS == m_dwLastError);
}
};

int main(int argc, char *argv[])
{
QApplication application(argc, argv);
qRegisterMetaType<std::wstring>();
SingleInstanceLimiter limiter(TEXT("Global\\{74cbcbe6-4202-4a85-9362-ae371291abd6}"));
qRegisterMetaType<std::wstring>();
// Configure logging
spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%t] [%n] [%l] %v");
spdlog::flush_every(std::chrono::seconds(1));
Expand All @@ -17,8 +53,14 @@ int main(int argc, char *argv[])
auto logger = XBOFSWin::get_logger("XBOFS.Win", sinks);
logger->info("Logging initialised");
// Display main window
XBOFSWinQTGUI mainWindow(XBOFSWin::get_logger("XBOFSWinQTGUI", logger->sinks()));
auto result = application.exec();
int result = -1;
if (!limiter.isAnotherInstanceRunning()) {
XBOFSWinQTGUI mainWindow(XBOFSWin::get_logger("XBOFSWinQTGUI", logger->sinks()));
result = application.exec();
}
else {
logger->error("Another instance of XBOFS.win is already running");
}
logger->info("Application exit");
return result;
}
Expand Down
Loading

0 comments on commit b8872e5

Please sign in to comment.