Paging through passwords
This commit is contained in:
parent
ef43aecaf0
commit
5d2fba270d
4 changed files with 27 additions and 12 deletions
|
@ -41,16 +41,15 @@ Manager* manager_create() {
|
||||||
// Creating result in memory
|
// Creating result in memory
|
||||||
Manager* result = malloc(sizeof(Manager));
|
Manager* result = malloc(sizeof(Manager));
|
||||||
|
|
||||||
|
// Storing password
|
||||||
|
result->page = 0;
|
||||||
|
|
||||||
// Returning manager
|
// Returning manager
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
void manager_loadnames(Manager* manager, int page){
|
void manager_loadnames(Manager* manager, int page){
|
||||||
// Relieving unused parameters
|
|
||||||
UNUSED(manager);
|
|
||||||
UNUSED(page);
|
|
||||||
|
|
||||||
// Loading the next four passwords
|
// Loading the next four passwords
|
||||||
char* data = store_load("Data");
|
char* data = store_load("Data");
|
||||||
|
|
||||||
|
@ -59,15 +58,29 @@ void manager_loadnames(Manager* manager, int page){
|
||||||
char** split = split_string(data, '|', &count);
|
char** split = split_string(data, '|', &count);
|
||||||
|
|
||||||
// Temporary variables
|
// Temporary variables
|
||||||
|
int i_pass = 0;
|
||||||
|
int i_name = 0;
|
||||||
|
|
||||||
// Going through split string
|
// Going through split string
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
// Checking if it's the 4th number
|
// Checking if it's the 4th number
|
||||||
if (i % 4 == 0) {
|
if (i % 4 == 0) {
|
||||||
FURI_LOG_I(TAG, "\nName:");
|
// It's another password!
|
||||||
}
|
i_pass++;
|
||||||
|
|
||||||
FURI_LOG_I(TAG, "(%i): %s", i, split[i]);
|
// Is it on our page?
|
||||||
|
if (i_pass > page * 4
|
||||||
|
&& i_pass <= (page * 4) + 4) {
|
||||||
|
// Adding it to the array!
|
||||||
|
manager->names[i_name] = split[i];
|
||||||
|
|
||||||
|
// Increasing name index
|
||||||
|
i_name++;
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
FURI_LOG_I(TAG, "Added %s to names", split[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -75,5 +88,6 @@ void manager_loadnames(Manager* manager, int page){
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
void manager_delete(Manager* manager) {
|
void manager_delete(Manager* manager) {
|
||||||
|
free(manager->names);
|
||||||
free(manager);
|
free(manager);
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@
|
||||||
// Structures
|
// Structures
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* names[4];
|
char* names[4];
|
||||||
|
int page;
|
||||||
} Manager;
|
} Manager;
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
|
@ -6,10 +6,6 @@ UIManager* ui_create() {
|
||||||
// Creating the UI Manager
|
// Creating the UI Manager
|
||||||
UIManager* result = malloc(sizeof(UIManager));
|
UIManager* result = malloc(sizeof(UIManager));
|
||||||
|
|
||||||
// Creating the manager
|
|
||||||
result->manager = manager_create();
|
|
||||||
manager_loadnames(result->manager, result->page);
|
|
||||||
|
|
||||||
// Defining basic variables
|
// Defining basic variables
|
||||||
result->running = true;
|
result->running = true;
|
||||||
result->selection = 0;
|
result->selection = 0;
|
||||||
|
@ -27,6 +23,10 @@ UIManager* ui_create() {
|
||||||
view_port_input_callback_set(result->canvas, ui_input, result);
|
view_port_input_callback_set(result->canvas, ui_input, result);
|
||||||
gui_add_view_port(result->gui, result->canvas, GuiLayerFullscreen);
|
gui_add_view_port(result->gui, result->canvas, GuiLayerFullscreen);
|
||||||
|
|
||||||
|
// Creating the manager
|
||||||
|
result->manager = manager_create();
|
||||||
|
manager_loadnames(result->manager, result->manager->page);
|
||||||
|
|
||||||
// Returning the UI Manager
|
// Returning the UI Manager
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ int32_t flippypass_app(void* p) {
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
|
|
||||||
// Saving to a default file:
|
// Saving to a default file:
|
||||||
store_save("Data", "Apple|example@objnull.net|password|0|Microsoft|person@objnull.net|password|0");
|
store_save("Data", "Apple|example@objnull.net|password|0|Microsoft|person@objnull.net|password|0|Google|user1@objnull.net|password|0|Facebook|user2@objnull.net|password|0|Twitter|user3@objnull.net|password|0|Instagram|user4@objnull.net|password|0|LinkedIn|user5@objnull.net|password|0|GitHub|user6@objnull.net|password|0|Reddit|user7@objnull.net|password|0|Spotify|user8@objnull.net|password|0|Netflix|user9@objnull.net|password|0|Dropbox|user10@objnull.net|password|0");
|
||||||
|
|
||||||
// Creating the UI struct
|
// Creating the UI struct
|
||||||
UIManager* ui = ui_create();
|
UIManager* ui = ui_create();
|
||||||
|
|
Loading…
Reference in a new issue