Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Authors and credits (partial info)
Browse files Browse the repository at this point in the history
  • Loading branch information
bertof committed Mar 15, 2017
1 parent d193cf6 commit ddc75d2
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ find_package(Boost 1.58.0 COMPONENTS filesystem date_time)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})

set(SOURCE_FILES main.cpp Pin/Pin.h Generator/bertofGenerator/Generator.h Exceptions/NotImplementedException.h Generator/bertofGenerator/Generator.cpp Logger/ScreenLogger/ScreenLogger.h Logger/ScreenLogger/ScreenLogger.cpp Exceptions/InvalidInputException.h Generator/GeneratorInerface.h Logger/Logger.cpp Logger/Logger.h Logger/TextLogger/TextLogger.cpp Logger/TextLogger/TextLogger.h Logger/DoubleLogger/DoubleLogger.cpp Logger/DoubleLogger/DoubleLogger.h Graphics/SplashScreen/SplashScreen.cpp Graphics/SplashScreen/SplashScreen.h InputHandling/InputHandler.cpp InputHandling/InputHandler.h Graphics/HelpScreen/HelpScreen.cpp Graphics/HelpScreen/HelpScreen.h Graphics/Info/Info.cpp Graphics/Info/Info.h Exceptions/HelpScreenException.h)
set(SOURCE_FILES main.cpp Pin/Pin.h Generator/bertofGenerator/Generator.h Exceptions/NotImplementedException.h Generator/bertofGenerator/Generator.cpp Logger/ScreenLogger/ScreenLogger.h Logger/ScreenLogger/ScreenLogger.cpp Exceptions/InvalidInputException.h Generator/GeneratorInerface.h Logger/Logger.cpp Logger/Logger.h Logger/TextLogger/TextLogger.cpp Logger/TextLogger/TextLogger.h Logger/DoubleLogger/DoubleLogger.cpp Logger/DoubleLogger/DoubleLogger.h Graphics/SplashScreen/SplashScreen.cpp Graphics/SplashScreen/SplashScreen.h InputHandling/InputHandler.cpp InputHandling/InputHandler.h Graphics/HelpScreen/HelpScreen.cpp Graphics/HelpScreen/HelpScreen.h Graphics/Info/Info.cpp Graphics/Info/Info.h Exceptions/HelpScreenException.h Exceptions/AuthorsScreenException.h Graphics/AuthorsScreen/AuthorsScreen.cpp Graphics/AuthorsScreen/AuthorsScreen.h)
add_executable(WPS_pin_generator ${SOURCE_FILES})


Expand Down
45 changes: 45 additions & 0 deletions Exceptions/AuthorsScreenException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Created by pily on 15/03/17.
//

#ifndef WPS_PIN_GENERATOR_AUTHORSCREENEXCEPTION_H
#define WPS_PIN_GENERATOR_AUTHORSCREENEXCEPTION_H

#include <string>
#include <exception>

class AuthorsScreenException : public std::exception {
public:
/** Constructor (C string)
* @param message C-style string error message.
* The string contents are copied upon construction.
* Hence, responsibility for deleting the char* lies
* with the caller.
*/
explicit AuthorsScreenException(const char *message) : errorMessage_(message) {}

/** Constructor (C++ STL string)
* @param message The error message.
*/
explicit AuthorsScreenException(const std::string &message = "Authors screen showed") : errorMessage_(message) {}

/** Destructor
* Virtual to allow subclassing
*/
virtual ~AuthorsScreenException() throw() {}

/** Returns a pointer to the (constant) error description.
*
* @return
*/
const char *what() const throw() {
return errorMessage_.c_str();
}

private:
/** Saved error message
*/
std::string errorMessage_;
};

#endif //WPS_PIN_GENERATOR_AUTHORSCREENEXCEPTION_H
15 changes: 15 additions & 0 deletions Graphics/AuthorsScreen/AuthorsScreen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Created by pily on 15/03/17.
//

#include "AuthorsScreen.h"
#include <string>
#include "../Info/Info.h"
#include "../../lib/rang/include/rang.hpp"

void AuthorsScreen::printAuthorsScreen() {

std::cout << rang::style::reset << rang::fg::green << "AUTHORS" << rang::style::reset << std::endl
<< Info::getAuthorInfos()
<< std::endl;
}
13 changes: 13 additions & 0 deletions Graphics/AuthorsScreen/AuthorsScreen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Created by pily on 15/03/17.
//

#ifndef WPS_PIN_GENERATOR_AUTHORSSCREEN_H
#define WPS_PIN_GENERATOR_AUTHORSSCREEN_H

class AuthorsScreen {
public:
static void printAuthorsScreen();
};

#endif //WPS_PIN_GENERATOR_AUTHORSSCREEN_H
6 changes: 4 additions & 2 deletions Graphics/HelpScreen/HelpScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@

std::string HelpScreen::getHelpScreen() {
return
"Version: " + Info::getVersion() + "\n" +
"USAGE:\n" +
"Authors:\t" + Info::getAuthorNames() + "\n" +
"Version:\t" + Info::getVersion() + "\n" +
"USAGE:\t\t" +
Info::getExecutableName() + " [options]\n" +
"\n" +
"OPTIONS:\n" +
"-b, --bssid <BSSID>\t\tInput target BSSID\n" +
"-g\t\t\t\t\t\tUse the generator algorithm\n" +
"-d\t\t\t\t\t\tUse the database\n" +
"-h, --help\t\t\t\tPrint this help page\n" +
"--authors\t\tPrint authors credits\n" +
"--debug\t\t\t\t\tPrint all th debug info" +
"-v, --verbouse\tLog is more verbouse\n" +
"--logfile [log.txt]\t\tEnables log to file (default log.txt)\n" +
Expand Down
9 changes: 8 additions & 1 deletion Graphics/Info/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ std::string Info::getVersion() {
}

std::string Info::getProjectName() {
return "WPS-pin-generator";
return "WPS-pin generator";
}

std::string Info::getExecutableName() {
return "WPS_pin_generator";
}
std::string Info::getAuthorNames() {
return "bertof";
}
std::string Info::getAuthorInfos() {
//TODO complete those info
return "bertof\n\tEmail:\tbertof [at] protonmail.com\n\tGitHub:\thttps://github.com/bertof";
}
19 changes: 19 additions & 0 deletions Graphics/Info/Info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@

#include <string>

/*** Centralized information about this program
*/
class Info {
public:
/*** Get a string with the version of the program
* @return version string
*/
static std::string getVersion();
/*** Get the full name of the project
* @return project name string
*/
static std::string getProjectName();
/*** Get the executable name
* @return executable name
*/
static std::string getExecutableName();
/*** Get author name
* @return author string
*/
static std::string getAuthorNames();
/*** Get some info about the author
* @return author info
*/
static std::string getAuthorInfos();
};

#endif //WPS_PIN_GENERATOR_VERSION_H
7 changes: 5 additions & 2 deletions Graphics/SplashScreen/SplashScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

#include "SplashScreen.h"
#include <iostream>
#include "../../lib/rang/include/rang.hpp"
#include "../Info/Info.h"

std::string SplashScreen::getSplashScreen() {
return "WPS Pin Generator - by Bertof";
void SplashScreen::printSplashScreen() {
std::cout << rang::style::reset << rang::style::bold << rang::fg::cyan
<< Info::getProjectName() << rang::style::reset << std::endl;
}
1 change: 0 additions & 1 deletion Graphics/SplashScreen/SplashScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class SplashScreen {
public:
static void printSplashScreen();
static std::string getSplashScreen();
};

#endif //WPS_PIN_GENERATOR_SPASHSCREEN_H
8 changes: 8 additions & 0 deletions InputHandling/InputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "../Logger/TextLogger/TextLogger.h"
#include "../Logger/DoubleLogger/DoubleLogger.h"
#include "../Exceptions/InvalidInputException.h"
#include "../Exceptions/AuthorsScreenException.h"
#include "../Graphics/HelpScreen/HelpScreen.h"
#include "../Graphics/AuthorsScreen/AuthorsScreen.h"

#include "../Generator/GeneratorInerface.h"
#include "../Generator/bertofGenerator/Generator.h"
Expand Down Expand Up @@ -82,6 +84,10 @@ void InputHandler::handle(int argc, char **argv) {
else if (args[i] == "--help" || args[i] == "-h") {
throw HelpScreenException();
}
// Authors dialog
else if (args[i] == "--authors") {
throw AuthorsScreenException();
}

// BSSID input
else if (args[i] == "-b" || args[i] == "--bssid") {
Expand Down Expand Up @@ -203,6 +209,8 @@ void InputHandler::handle(int argc, char **argv) {
} catch (NotImplementedException e) {
std::shared_ptr<DoubleLogger> logger(DoubleLogger::getDoubleLogger());
logger->logError(std::string(e.what()));
} catch (AuthorsScreenException e) {
AuthorsScreen::printAuthorsScreen();
}
}

Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
//TODO switch to smart pointers

// Spash screen
logger->log(SplashScreen::getSplashScreen());
SplashScreen::printSplashScreen();

// Handle input
InputHandler::handle(argc, argv);
Expand Down

0 comments on commit ddc75d2

Please sign in to comment.