Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
- Changed CLI option --mode,-m to --algorithm,-a
- Fix check for updates bug reports false new version
- Proceeded Doxygen Documentation (~0.60% Documented)
  • Loading branch information
baderouaich committed Sep 27, 2021
1 parent 7c3f67a commit 128cf1c
Show file tree
Hide file tree
Showing 29 changed files with 207 additions and 126 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 2.0.0
- Changed CLI option --mode,-m to --algorithm,-a
- Fix check for updates bug
- Proceeded Doxygen Documentation (~0.60% Documented)


# 1.4.0
Expand Down
4 changes: 2 additions & 2 deletions Source/Algorithm/Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class ENIGMA_API Algorithm
/**
* Intention of creating an instance of an Algorithm.
*
* to not initialize resources not needed for an operation.
* (like when encrypting, we initialize a random seeder which is not needed
* helps to avoid initializing resources not needed for an specific operation.
* (for example when encrypting, we initialize a random seeder which is not needed
* when decrypting)
*/
enum class Intent : byte
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ do { \
///


//void TimedFunction(
//static void TimedFunction(
// const std::function<void()>& onStart,
// const std::function<void()>& func,
// const std::function<void(double)>& onFinish)
// const std::function<void(::Enigma::f64)>& onFinish)
//{
// onStart();
// ENIGMA_BEGIN_TIMER(t1);
// func();
// auto elapsed = ENIGMA_END_TIMER(t1, double, std::milli) / 1000.0;
// ::Enigma::f64 elapsed = ENIGMA_END_TIMER(t1, double, std::milli) / 1000.0;
// onFinish(elapsed);
//}
//
//




#endif // !ENIGMA_MACROS_H
2 changes: 1 addition & 1 deletion Source/Core/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef ENIGMA_PLATFORM_H
#define ENIGMA_PLATFORM_H

/*
/**
* Detects current platform
*/

Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#ifndef ENIGMA_VERSION_H
#define ENIGMA_VERSION_H

// major, minor, patch string (needed for Enigma.rc)
#define ENIGMA_VERSION_STR "1.4.0"
/** major, minor, patch string(needed for Enigma.rc) */
#define ENIGMA_VERSION_STR "2.0.0"

// major, minor, patch divided (needed for Enigma.rc)
#define ENIGMA_VERSION_DIV 1, 4, 0
/** major, minor, patch divided (needed for Enigma.rc) */
#define ENIGMA_VERSION_DIV 2, 0, 0

#define ENIGMA_VERSION ENIGMA_VERSION_STR

Expand Down
41 changes: 25 additions & 16 deletions Source/Database/Database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@


NS_ENIGMA_BEGIN
/*

/**
* Enigma SQLite database to store and retrieve encryption records
* User can export and import Database file to clouds or drives
* Database file will store Encrypted Text and Encrypted Files ciphers and other info
Expand All @@ -27,6 +28,7 @@ class ENIGMA_API Database final
ENIGMA_STATIC_CLASS(Database);

public:
/** Encryption Table order by column */
enum class OrderBy : byte
{
ID,
Expand All @@ -36,7 +38,8 @@ class ENIGMA_API Database final

ENIGMA_ENUM_DECLARE_BEGIN_END(ID)
};
friend const char* operator *(OrderBy order_by) // operator* to stringify enum OrderBy
/** To help stringify enum OrderBy */
friend const char* operator *(OrderBy order_by)
{
#define CASE_STR(e) case OrderBy::e: return #e
switch (order_by)
Expand All @@ -60,14 +63,16 @@ class ENIGMA_API Database final
}
return os;
}
/** Encryption Table order column */
enum class Order : byte
{
Ascending,
Descending,

ENIGMA_ENUM_DECLARE_BEGIN_END(Ascending)
};
friend const char* operator *(Order order) // operator* to stringify enum Order
/** To help stringify enum Order */
friend const char* operator *(Order order)
{
#define CASE_STR(e) case Order::e: return #e
switch (order)
Expand All @@ -84,23 +89,25 @@ class ENIGMA_API Database final
}

public:
/** Initializes SQLite database connection */
static void Initialize();
/** Shuts down SQLite connection */
static void Shutdown();

public: // Encryption Operations
// Add Encryption to Encryptions table, returns true on success
/** Add Encryption to Encryptions table, returns true on success */
static bool AddEncryption(const std::unique_ptr<Encryption>& e);

// Returns cipher from database by encryption id
/** Returns cipher from database by encryption id */
static std::unique_ptr<Cipher> GetCipherByEncryptionID(const i64 ide);

// Delete Encryption record by id, returns true if successfully deleted
/** Delete Encryption record by id, returns true if successfully deleted */
static bool DeleteEncryption(const i64 ide);

// Delete all saved encryptions from the database (with their cipher)
/** Delete all saved encryptions from the database (with their cipher) */
static bool DeleteAllEncryptions();

// Returns how many encryption records are saved
/** Returns how many encryption records are saved */
static i64 GetEncryptionsCount();

#if 0
Expand Down Expand Up @@ -157,7 +164,7 @@ class ENIGMA_API Database final
}
#endif

// Get an Encyrption by id with desired columns for optimization
/** Get an Encyrption by id with desired columns for optimization */
template<const bool title, const bool cipher, const bool date_time, const bool size, const bool is_file>
inline static std::unique_ptr<Encryption> GetEncryptionByID(const i64 ide)
{
Expand Down Expand Up @@ -214,7 +221,7 @@ class ENIGMA_API Database final
}
}

// Get all Encryptions with desired columns for optimization
/** Get all Encryptions with desired columns for optimization */
template<const bool title, const bool cipher, const bool date_time, const bool size, const bool is_file>
inline static std::vector<std::unique_ptr<Encryption>> GetAllEncryptions(OrderBy order_by = OrderBy::ID, Order order = Order::Descending)
{
Expand Down Expand Up @@ -275,7 +282,7 @@ class ENIGMA_API Database final
}


// Search Encryptions by title using keyword LIKE %QUERY%
/** Search Encryptions by title using keyword LIKE %QUERY% */
template<const bool title, const bool cipher, const bool date_time, const bool size, const bool is_file> // select which columns to return (for optimization)
inline static std::vector<std::unique_ptr<Encryption>> SearchEncryptionsByTitle(const String& qtitle, OrderBy order_by = OrderBy::ID, Order order = Order::Descending)
{
Expand Down Expand Up @@ -337,15 +344,17 @@ class ENIGMA_API Database final


public: // Accessors
/** Returns SQLite database connection instance */
static const std::unique_ptr<SQLite::Database>& GetInstance() noexcept { return m_database; }


public: // Modifiers
/*
* https://www.sqlitetutorial.net/sqlite-vacuum/
/**
* Cleans up allocated disk space for deleted data, blob...
*
* When you insert or delete data from the tables, the indexes and tables become fragmented,
* especially for the database that has a high number of inserts, updates, and deletes.
* @note https://www.sqlitetutorial.net/sqlite-vacuum/
*/
static void Vacuum() noexcept
{
Expand All @@ -361,20 +370,20 @@ class ENIGMA_API Database final
}
//else
// ENIGMA_INFO("No database changes were made, skipping vacuum disk optimization.");


}



private:
inline static std::unique_ptr<SQLite::Database> m_database{ nullptr }; // Database connection configuered on Initialize()
inline static std::unique_ptr<SQLite::Database> m_database{ nullptr }; /**< Database connection configuered on Initialize() */
};

/*
Notes:
for bind, use index starts by 1
for getColumn, use index starts by 0
*/

NS_ENIGMA_END
#endif // !ENIGMA_DATABASE_H

10 changes: 6 additions & 4 deletions Source/Database/Models/Cipher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

NS_ENIGMA_BEGIN

// Cipher Model | table: Cipher
/**
* Cipher Model | table: Cipher
*/
struct Cipher
{
i64 idc{}; // auto incremental id
String data{}; // BLOB compressed text or file binary cipher
i64 ide{}; // foreign key references Encryption(id)
i64 idc{}; /**< auto incremental id */
String data{}; /**< BLOB compressed text or file binary cipher */
i64 ide{}; /**< foreign key references Encryption(id) */

~Cipher() noexcept
{
Expand Down
16 changes: 9 additions & 7 deletions Source/Database/Models/Encryption.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@

NS_ENIGMA_BEGIN

// Encryption Model | table: Encryption
/**
* Encryption Model | Table: Encryption
*/
struct Encryption
{
i64 ide{}; // auto incremental id 0 -> SIZE_MAX
String title{}; // E.G: "this is my gmail password"
Cipher cipher{};
String date_time{}; // date & time saved by sqlite3
i64 size{}; // size of compressed cipher in bytes
bool is_file{}; // whether its a text or file encryption
i64 ide{}; /**< auto incremental id in range [0, SIZE_MAX] */
String title{}; /**< encryption title, e.g: "this is my gmail password" */
Cipher cipher{}; /**< encryption encrypted data, aka cipher. from another table for perfermance reasons */
String date_time{}; /**< date & time saved by sqlite3 */
i64 size{}; /**< size of compressed cipher in bytes */
bool is_file{}; /**< whether its a text or file encryption */

~Encryption() noexcept
{
Expand Down
3 changes: 0 additions & 3 deletions Source/Enigma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#include <Config/Config.hpp>
//

// Enigma Language Translator
//#include <Translation/Translation.hpp>
//

// System Dialogs, Notification, Clipboard, Environment Variable
#include <System/Dialogs/MessageBox.hpp>
Expand Down
11 changes: 11 additions & 0 deletions Source/Events/ApplicationEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

NS_ENIGMA_BEGIN

/** Window size changed Event */
class WindowResizeEvent : public Event
{
public:
Expand All @@ -37,6 +38,7 @@ class WindowResizeEvent : public Event
i32 m_width, m_height;
};

/** Frame buffer size changed Event */
class FrameBufferResizeEvent : public Event
{
public:
Expand All @@ -63,6 +65,7 @@ class FrameBufferResizeEvent : public Event
i32 m_width, m_height;
};

/** Window position changed Event */
class WindowMoveEvent : public Event
{
public:
Expand All @@ -88,6 +91,7 @@ class WindowMoveEvent : public Event
i32 m_xPos, m_yPos;
};

/** Window maximized Event */
class WindowMaximizedEvent : public Event
{
public:
Expand All @@ -111,6 +115,7 @@ class WindowMaximizedEvent : public Event
bool m_isMaximized;
};

/** Window lost focus Event */
class WindowFocusLostEvent : public Event
{
public:
Expand All @@ -119,6 +124,7 @@ class WindowFocusLostEvent : public Event
EVENT_CLASS_CATEGORY(EventCategory::APPLICATION);
};

/** Window gain focus Event */
class WindowFocusEvent : public Event
{
public:
Expand All @@ -127,6 +133,7 @@ class WindowFocusEvent : public Event
EVENT_CLASS_CATEGORY(EventCategory::APPLICATION);
};

/** Window close button pressed Event */
class WindowCloseEvent : public Event
{
public:
Expand All @@ -136,6 +143,7 @@ class WindowCloseEvent : public Event
EVENT_CLASS_CATEGORY(EventCategory::APPLICATION);
};

/** Files dropped over window Event */
class WindowFileDropEvent : public Event
{
public:
Expand All @@ -153,6 +161,7 @@ class WindowFileDropEvent : public Event
std::vector<fs::path> m_filenames;
};

/** Application main loop tick Update Event */
class AppUpdateEvent : public Event
{
public:
Expand All @@ -162,6 +171,7 @@ class AppUpdateEvent : public Event
EVENT_CLASS_CATEGORY(EventCategory::APPLICATION);
};

/** Application main loop tick Draw Event */
class AppRenderEvent : public Event
{
public:
Expand All @@ -171,6 +181,7 @@ class AppRenderEvent : public Event
EVENT_CLASS_CATEGORY(EventCategory::APPLICATION);
};

/** Application main loop tick Event */
class AppTickEvent : public Event
{
public:
Expand Down
2 changes: 2 additions & 0 deletions Source/Events/EventDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Event.hpp"

NS_ENIGMA_BEGIN

/** Event dispatcher to dispatch specific desired events */
class ENIGMA_API EventDispatcher
{
template<typename T>
Expand Down
4 changes: 4 additions & 0 deletions Source/Events/KeyEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

NS_ENIGMA_BEGIN

/** Keyboard buttons Event */
class KeyEvent : public Event
{
public:
Expand All @@ -26,6 +27,7 @@ class KeyEvent : public Event
KeyCode m_key_code;
};

/** Keyboard button press Event */
class KeyPressedEvent : public KeyEvent
{
public:
Expand All @@ -49,6 +51,7 @@ class KeyPressedEvent : public KeyEvent
ui16 m_repeat_count;
};

/** Keyboard button release Event */
class KeyReleasedEvent : public KeyEvent
{
public:
Expand All @@ -67,6 +70,7 @@ class KeyReleasedEvent : public KeyEvent
EVENT_CLASS_TYPE(EventType::KEY_RELEASED)
};

/** Keyboard button type Event */
class KeyTypedEvent : public KeyEvent
{
public:
Expand Down
Loading

0 comments on commit 128cf1c

Please sign in to comment.