Removed archive functionality (BROKEN)

This commit is contained in:
Maddox Werts 2024-09-16 01:20:43 -04:00
parent 288200c1a6
commit 416fd516de
13 changed files with 5 additions and 404 deletions

View file

@ -1,60 +0,0 @@
// Header
#include "archive.h"
// Functions
bool archive_import(Manager* manager) {
// Loading the file
char* data = store_load(Store_File_Path_Archive, "Data");
// Did we fail to load the data?
if (!data) {return false;}
// Splitting the string up
int count = 0;
char** split = split_string(data, F_DELIMITER, &count);
// Free data after split
free(data);
// Going through all passwords
for (int i = 0; i < count; i++) {
// Skipping to each password
if (i % 4 == 0) {
// DEBUG
FURI_LOG_D(TAG, "(%i, %s) Adding password.", i, split[i]);
// Allocating memory for a password
Password* new_password = pass_init(
split[i],
split[i+1],
split[i+2],
0
);
// Saving the new password
manager_savepass(manager, new_password);
// Freeing that password
pass_free(new_password);
}
}
// Wiping the original file
store_save(Store_File_Path_Archive, "Data", "Done.");
// Cleanup
free(split);
// Return result
return true;
}
bool archive_export(Manager* manager) {
// Result
bool result = true;
// UNUSED variable
UNUSED(manager);
// Return result
return result;
}

View file

@ -1,13 +0,0 @@
// Define once
#ifndef H_ARCHIVE
#define H_ARCHIVE
// Libraries
#include "base.h"
#include "manager.h"
// Functions
bool archive_import(Manager* manager);
bool archive_export(Manager* manager);
#endif

View file

@ -7,9 +7,8 @@
#define DIR EXT_PATH("apps_data/fpass")
#define F_DATA EXT_PATH("apps_data/fpass/data.bin")
#define F_ARCHIVE EXT_PATH("apps_data/fpass/archive.txt")
#define F_DELIMITER '\r'
#define F_DELIMITER '\a'
// Functions
char** split_string(const char* str, char delimiter, int* count);

View file

@ -32,9 +32,6 @@ char* store_load(Store_File_Path path, char* type) {
case Store_File_Path_Data:
file_path = F_DATA;
break;
case Store_File_Path_Archive:
file_path = F_ARCHIVE;
break;
}
// Init Folders
@ -106,9 +103,6 @@ void store_save(Store_File_Path path, char* type, char* data) {
case Store_File_Path_Data:
file_path = F_DATA;
break;
case Store_File_Path_Archive:
file_path = F_ARCHIVE;
break;
}
// Creating new file

View file

@ -8,8 +8,7 @@
// Enums
typedef enum {
Store_File_Path_Data,
Store_File_Path_Archive
Store_File_Path_Data
} Store_File_Path;
// Functions

View file

@ -38,8 +38,6 @@ typedef enum {
FP_Scene_Send,
FP_Scene_Create,
FP_Scene_Type,
FP_Scene_Archive,
FP_Scene_Import,
FP_Scene_About,
FP_Scene_Count // Last Index, says how many scenes there are
} FP_Scene;

View file

@ -1,78 +0,0 @@
// Header
#include "archive.h"
// Structures
typedef enum {
FP_Scene_Archive_Event_Import,
FP_Scene_Archive_Event_Export
} FP_Scene_Archive_Event;
// Functions
void FP_Scene_Callback_Archive(void* context, uint32_t index){
// Setting context
FP_App* app = context;
// Sending it to the scene manager
scene_manager_handle_custom_event(app->scene_manager, index);
}
void FP_Scene_Enter_Archive(void* context){
// Setting the context
FP_App* app = context;
// Reset view
submenu_reset(app->submenu);
// Adding some stuff
submenu_add_item(
app->submenu,
"Import Archive",
FP_Scene_Archive_Event_Import,
FP_Scene_Callback_Archive,
app
);
submenu_add_item(
app->submenu,
"Export Archive",
FP_Scene_Archive_Event_Export,
FP_Scene_Callback_Archive,
app
);
// Send view to Flipper
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_Submenu);
}
void FP_Scene_Exit_Archive(void* context){
// Setting context
FP_App* app = context;
// Reset menu
submenu_reset(app->submenu);
}
bool FP_Scene_Event_Archive(void* context, SceneManagerEvent event){
// Setting context
FP_App* app = context;
bool consumed = false;
// Switching based on event
if (event.type == SceneManagerEventTypeCustom) {
// We consumed it
consumed = true;
// What did we choose?
switch (event.event) {
case FP_Scene_Archive_Event_Import:
scene_manager_next_scene(
app->scene_manager,
FP_Scene_Import
);
break;
case FP_Scene_Archive_Event_Export:
break;
}
} else {
consumed = false;
}
// Return result
return consumed;
}

View file

@ -1,14 +0,0 @@
// Define once
#ifndef H_S_ARCHIVE
#define H_S_ARCHIVE
// Libraries
#include "../app.h"
// Functions
void FP_Scene_Callback_Archive(void* context, uint32_t index);
void FP_Scene_Enter_Archive(void* context);
void FP_Scene_Exit_Archive(void* context);
bool FP_Scene_Event_Archive(void* context, SceneManagerEvent event);
#endif

View file

@ -1,127 +0,0 @@
// Header
#include "import.h"
// Others
#include "../../backend/archive.h"
// Functions
void FP_Scene_Callback_Import(DialogExResult result, void* context){
// Setting context
FP_App* app = context;
// Sending it to the scene manager
scene_manager_handle_custom_event(app->scene_manager, result);
}
void FP_Scene_Enter_Import(void* context){
// Setting context
FP_App* app = context;
// Setting selection
app->selection = 0;
// Resetting scene
dialog_ex_reset(app->dialog);
// Setting dialog content
dialog_ex_set_header(
app->dialog,
"Import Archive",
0, 0,
AlignLeft, AlignTop
);
dialog_ex_set_text(
app->dialog,
"Are you sure you want to import: /ext/apps_data/fpass/archive.txt?",
5, 15,
AlignLeft, AlignTop
);
dialog_ex_set_center_button_text(
app->dialog,
"Yes"
);
dialog_ex_set_left_button_text(
app->dialog,
"No"
);
// Setting callback
dialog_ex_set_result_callback(
app->dialog,
FP_Scene_Callback_Import
);
dialog_ex_set_context(
app->dialog,
app
);
// Sending view to Flipper
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_Dialog);
}
void FP_Scene_Exit_Import(void* context){
// Setting context
FP_App* app = context;
// Reset menu
submenu_reset(app->submenu);
}
bool FP_Scene_Event_Import(void* context, SceneManagerEvent event){
// Setting context
FP_App* app = context;
bool consumed = false;
// Switching based on event
if (event.type == SceneManagerEventTypeCustom) {
// We consumed it
consumed = true;
// Are we already good?
if (app->selection >= 1) {
scene_manager_previous_scene(
app->scene_manager
);
}
// What should we do?
switch (event.event) {
case DialogExResultCenter: // Yes
// Importing the passwords
bool success = archive_import(app->manager);
// Telling the user it worked!
if (success) {
dialog_ex_set_text(
app->dialog,
"Imported Successfully.",
5, 15,
AlignLeft, AlignTop
);
} else {
dialog_ex_set_text(
app->dialog,
"Failed to import passwords",
5, 15,
AlignLeft, AlignTop
);
}
dialog_ex_set_center_button_text(
app->dialog,
"Okay"
);
dialog_ex_set_left_button_text(
app->dialog,
NULL
);
app->selection++;
break;
case DialogExResultLeft: // No
scene_manager_previous_scene(app->scene_manager);
break;
}
} else {
consumed = false;
}
// Return result
return consumed;
}

View file

@ -1,14 +0,0 @@
// Define once
#ifndef H_S_IMPORT
#define H_S_IMPORT
// Libraries
#include "../app.h"
// Functions
void FP_Scene_Callback_Import(DialogExResult result, void* context);
void FP_Scene_Enter_Import(void* context);
void FP_Scene_Exit_Import(void* context);
bool FP_Scene_Event_Import(void* context, SceneManagerEvent event);
#endif

View file

@ -5,7 +5,6 @@
typedef enum {
FP_Scene_MainMenu_Event_View,
FP_Scene_MainMenu_Event_Create,
FP_Scene_MainMenu_Event_Archive,
FP_Scene_MainMenu_Event_About
} FP_Scene_MainMenu_Event;
@ -39,13 +38,6 @@ void FP_Scene_Enter_MainMenu(void* context) {
FP_Scene_Callback_MainMenu,
app
);
submenu_add_item(
app->submenu,
"Archive Actions",
FP_Scene_MainMenu_Event_Archive,
FP_Scene_Callback_MainMenu,
app
);
submenu_add_item(
app->submenu,
"About",
@ -82,9 +74,6 @@ bool FP_Scene_Event_MainMenu(void* context, SceneManagerEvent event) {
case FP_Scene_MainMenu_Event_Create:
scene_manager_next_scene(app->scene_manager, FP_Scene_Create);
break;
case FP_Scene_MainMenu_Event_Archive:
scene_manager_next_scene(app->scene_manager, FP_Scene_Archive);
break;
case FP_Scene_MainMenu_Event_About:
scene_manager_next_scene(app->scene_manager, FP_Scene_About);
break;

View file

@ -10,8 +10,6 @@
#include "scenes/send.h"
#include "scenes/create.h"
#include "scenes/type.h"
#include "scenes/archive.h"
#include "scenes/import.h"
// Handlers
void (*const FP_Scene_Enter_Handlers[])(void*) = {
@ -22,9 +20,7 @@ void (*const FP_Scene_Enter_Handlers[])(void*) = {
FP_Scene_Enter_Cred,
FP_Scene_Enter_Send,
FP_Scene_Enter_Create,
FP_Scene_Enter_Type,
FP_Scene_Enter_Archive,
FP_Scene_Enter_Import
FP_Scene_Enter_Type
};
bool (*const FP_Scene_Event_Handlers[])(void*, SceneManagerEvent) = {
FP_Scene_Event_Auth,
@ -34,9 +30,7 @@ bool (*const FP_Scene_Event_Handlers[])(void*, SceneManagerEvent) = {
FP_Scene_Event_Cred,
FP_Scene_Event_Send,
FP_Scene_Event_Create,
FP_Scene_Event_Type,
FP_Scene_Event_Archive,
FP_Scene_Event_Import
FP_Scene_Event_Type
};
void (*const FP_Scene_Exit_Handlers[])(void*) = {
FP_Scene_Exit_Auth,
@ -46,9 +40,7 @@ void (*const FP_Scene_Exit_Handlers[])(void*) = {
FP_Scene_Exit_Cred,
FP_Scene_Exit_Send,
FP_Scene_Exit_Create,
FP_Scene_Exit_Type,
FP_Scene_Exit_Archive,
FP_Scene_Exit_Import
FP_Scene_Exit_Type
};
// Main Handler

View file

@ -1,64 +0,0 @@
"""
ARHIVE for FlipypPass
This will prepare your passwords for Import with FlippyPass
Excuse that this is written in Python...
"""
# Libraries
import sys
import json
# Variables
file_delimiter = '\r'
all_passwords = ""
# Functions
def load_json():
# Getting file path
file_path = sys.argv[1]
# Opening file
f_file = open(file_path)
f_data = f_file.read()
# Parsing json
return json.loads(f_data)
def insert_passwords(json_data):
# Global
global all_passwords
# Going through items
for item in json_data["items"]:
# Is it not valid?
if not "login" in item:
continue
# Getting important data from each
name = item["name"]
username = item["login"]["username"]
password = item["login"]["password"]
# Adding it into our password array
all_passwords += name + file_delimiter + username + file_delimiter + password + file_delimiter + "0" + file_delimiter
def save_data():
# Global
global all_passwords
# Opening file
file_data = open('archive.txt', 'w')
file_data.write("Data: " + all_passwords)
file_data.close()
def main():
# Loading json
json_data = load_json()
# Going through all passwords
insert_passwords(json_data)
# Saving the passwords
save_data()
# Entry point
main()