Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Release of the new C++ 1.0 version of MemTypeGui.
Browse files Browse the repository at this point in the history
  • Loading branch information
oyzzo committed May 27, 2017
2 parents 03bb20c + d7c9dec commit 1015bdf
Show file tree
Hide file tree
Showing 62 changed files with 3,748 additions and 1,602 deletions.
1 change: 1 addition & 0 deletions 99-MemType.rules
@@ -0,0 +1 @@
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="a033", GROUP="users", MODE="0666"
58 changes: 58 additions & 0 deletions MemTypeManager/MemTypeManager.pro
@@ -0,0 +1,58 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-02-16T19:39:42
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = MemTypeManager
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0


SOURCES += main.cpp\
mainwindow.cpp \
credential.cpp \
credentialwidget.cpp \
credentialeditwindow.cpp \
noekeon.c \
memtype.c \
device.cpp \
statuswidget.cpp \
versionwindow.cpp

HEADERS += mainwindow.h \
credentialwidget.h \
credentialeditwindow.h \
credential.h \
noekeon_api.h \
memtype_api.h \
device.h \
statuswidget.h \
versionwindow.h

FORMS += mainwindow.ui \
credentialwidget.ui \
credentialeditwindow.ui \
statuswidget.ui \
versionwindow.ui

RESOURCES += \
resources.qrc

INCLUDEPATH += /usr/include/libusb-1.0
LIBS += -lusb-1.0
CONFIG += c++11
336 changes: 336 additions & 0 deletions MemTypeManager/MemTypeManager.pro.user

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions MemTypeManager/credential.cpp
@@ -0,0 +1,27 @@
#include "credential.h"

Credential::Credential()
{
this->name = "";
this->user = "";
this->hop = "\\t";
this->password = "";
this->submit = "\\n";
this->fits = false;
}

uint16_t Credential::Size()
{
uint16_t size;

memtype_credential_t cred;
cred.name = (char*)this->name.c_str();
cred.user = (char*)this->user.c_str();
cred.hop = (char*)this->hop.c_str();
cred.pass = (char*)this->password.c_str();
cred.submit = (char*)this->submit.c_str();

size = Memtype_credBuffSize(&cred, 1);

return size;
}
24 changes: 24 additions & 0 deletions MemTypeManager/credential.h
@@ -0,0 +1,24 @@
#ifndef CREDENTIAL_H
#define CREDENTIAL_H

#include <string>
#include "memtype_api.h"

using namespace std;

class Credential
{
public:
// Attributes
string name;
string user;
string hop;
string password;
string submit;
bool fits; // Is the credential writted into device?

Credential();
uint16_t Size();
};

#endif // CREDENTIAL_H
43 changes: 43 additions & 0 deletions MemTypeManager/credentialeditwindow.cpp
@@ -0,0 +1,43 @@
#include "credentialeditwindow.h"
#include "ui_credentialeditwindow.h"

CredentialEditWindow::CredentialEditWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::CredentialEditWindow)
{
ui->setupUi(this);
connect(ui->cancelCredentialButton, &QPushButton::clicked, this, &CredentialEditWindow::close);
connect(ui->okCredentialButton, &QPushButton::clicked, this, &CredentialEditWindow::saveCredential);
connect(ui->delayButton, &QPushButton::clicked, this, &CredentialEditWindow::addDelay);
}

CredentialEditWindow::~CredentialEditWindow()
{
delete ui;
}

void CredentialEditWindow::setCredential(Credential* credential)
{
this->cred = credential;
this->ui->nameEdit->setText(QString::fromStdString(this->cred->name));
this->ui->userEdit->setText(QString::fromStdString(this->cred->user).replace("\t","\\t").replace("\n","\\n").replace("\x16",""));
this->ui->hopEdit->setText(QString::fromStdString(this->cred->hop).replace("\t","\\t").replace("\n","\\n").replace("\x16",""));
this->ui->passwdEdit->setText(QString::fromStdString(this->cred->password).replace("\t","\\t").replace("\n","\\n").replace("\x16",""));
this->ui->submitEdit->setText(QString::fromStdString(this->cred->submit).replace("\t","\\t").replace("\n","\\n").replace("\x16",""));
}

void CredentialEditWindow::saveCredential()
{
this->cred->name = ui->nameEdit->text().toStdString();
this->cred->user = ui->userEdit->text().replace("\\t","\t").replace("\\n","\n").replace("","\x16").toStdString();
this->cred->hop = ui->hopEdit->text().replace("\\t","\t").replace("\\n","\n").replace("","\x16").toStdString();
this->cred->password = ui->passwdEdit->text().replace("\\t","\t").replace("\\n","\n").replace("","\x16").toStdString();
this->cred->submit = ui->submitEdit->text().replace("\\t","\t").replace("\\n","\n").replace("","\x16").toStdString();

emit accepted();
this->close();
}
void CredentialEditWindow::addDelay()
{
this->ui->hopEdit->setText(this->ui->hopEdit->text().prepend("")); /* Unicode watch char */
}
32 changes: 32 additions & 0 deletions MemTypeManager/credentialeditwindow.h
@@ -0,0 +1,32 @@
#ifndef CREDENTIALEDITWINDOW_H
#define CREDENTIALEDITWINDOW_H

#include <QMainWindow>
#include "credential.h"

namespace Ui {
class CredentialEditWindow;
}

class CredentialEditWindow : public QMainWindow
{
Q_OBJECT

public:
explicit CredentialEditWindow(QWidget *parent = 0);
~CredentialEditWindow();

void setCredential(Credential *credential);

public slots:
void addDelay();
signals:
void accepted();

private:
Credential* cred;
Ui::CredentialEditWindow *ui;
void saveCredential();
};

#endif // CREDENTIALEDITWINDOW_H
166 changes: 166 additions & 0 deletions MemTypeManager/credentialeditwindow.ui
@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CredentialEditWindow</class>
<widget class="QMainWindow" name="CredentialEditWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>337</width>
<height>261</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Edit Credential</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameEdit">
<property name="maxLength">
<number>32</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>User</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="userEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Hop</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="hopEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Passwd</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="passwdEdit"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Submit</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="submitEdit"/>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="delayButton">
<property name="text">
<string>500ms Delay</string>
</property>
<property name="icon">
<iconset>
<normalon>:/img/time.png</normalon>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okCredentialButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelCredentialButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit 1015bdf

Please sign in to comment.