[FL-976] Removing lambdas (#1849)
* Removing lambdas... * Wake the fk up, Gordon! We have a citadel to burn! * Here comes the Nihilanth * Lambda documentation Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -80,20 +80,20 @@ DictAttack* dict_attack_alloc() {
|
||||
view_set_input_callback(dict_attack->view, dict_attack_input_callback);
|
||||
view_set_context(dict_attack->view, dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
model->header = furi_string_alloc();
|
||||
return false;
|
||||
});
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{ model->header = furi_string_alloc(); },
|
||||
false);
|
||||
return dict_attack;
|
||||
}
|
||||
|
||||
void dict_attack_free(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
furi_string_free(model->header);
|
||||
return false;
|
||||
});
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{ furi_string_free(model->header); },
|
||||
false);
|
||||
view_free(dict_attack->view);
|
||||
free(dict_attack);
|
||||
}
|
||||
@@ -101,7 +101,9 @@ void dict_attack_free(DictAttack* dict_attack) {
|
||||
void dict_attack_reset(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
model->state = DictAttackStateRead;
|
||||
model->type = MfClassicType1k;
|
||||
model->sectors_total = 0;
|
||||
@@ -112,8 +114,8 @@ void dict_attack_reset(DictAttack* dict_attack) {
|
||||
model->dict_keys_total = 0;
|
||||
model->dict_keys_current = 0;
|
||||
furi_string_reset(model->header);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
false);
|
||||
}
|
||||
|
||||
View* dict_attack_get_view(DictAttack* dict_attack) {
|
||||
@@ -133,99 +135,103 @@ void dict_attack_set_header(DictAttack* dict_attack, const char* header) {
|
||||
furi_assert(header);
|
||||
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
furi_string_set(model->header, header);
|
||||
return true;
|
||||
});
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{ furi_string_set(model->header, header); },
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
model->state = DictAttackStateRead;
|
||||
model->sectors_total = mf_classic_get_total_sectors_num(type);
|
||||
model->keys_total = model->sectors_total * 2;
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_set_card_removed(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
model->state = DictAttackStateCardRemoved;
|
||||
return true;
|
||||
});
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{ model->state = DictAttackStateCardRemoved; },
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
model->sectors_read = sec_read;
|
||||
return true;
|
||||
});
|
||||
dict_attack->view, DictAttackViewModel * model, { model->sectors_read = sec_read; }, true);
|
||||
}
|
||||
|
||||
void dict_attack_set_keys_found(DictAttack* dict_attack, uint8_t keys_found) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
model->keys_found = keys_found;
|
||||
return true;
|
||||
});
|
||||
dict_attack->view, DictAttackViewModel * model, { model->keys_found = keys_found; }, true);
|
||||
}
|
||||
|
||||
void dict_attack_set_current_sector(DictAttack* dict_attack, uint8_t curr_sec) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
model->sector_current = curr_sec;
|
||||
model->dict_keys_current = 0;
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_inc_current_sector(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
if(model->sector_current < model->sectors_total) {
|
||||
model->sector_current++;
|
||||
model->dict_keys_current = 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_inc_keys_found(DictAttack* dict_attack) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
if(model->keys_found < model->keys_total) {
|
||||
model->keys_found++;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_set_total_dict_keys(DictAttack* dict_attack, uint16_t dict_keys_total) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
model->dict_keys_total = dict_keys_total;
|
||||
return true;
|
||||
});
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{ model->dict_keys_total = dict_keys_total; },
|
||||
true);
|
||||
}
|
||||
|
||||
void dict_attack_inc_current_dict_key(DictAttack* dict_attack, uint16_t keys_tried) {
|
||||
furi_assert(dict_attack);
|
||||
with_view_model(
|
||||
dict_attack->view, (DictAttackViewModel * model) {
|
||||
dict_attack->view,
|
||||
DictAttackViewModel * model,
|
||||
{
|
||||
if(model->dict_keys_current + keys_tried < model->dict_keys_total) {
|
||||
model->dict_keys_current += keys_tried;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user