subbrute_main_view.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #pragma once
  2. #include "../subbrute_custom_event.h"
  3. #include "../subbrute_protocols.h"
  4. #include <gui/view.h>
  5. #include <input/input.h>
  6. #include <gui/elements.h>
  7. typedef void (*SubBruteMainViewCallback)(SubBruteCustomEvent event, void* context);
  8. typedef struct SubBruteMainView SubBruteMainView;
  9. /**
  10. * @brief Sets the callback function and context for the SubBruteMainView instance.
  11. *
  12. * This function sets the callback function and context for the SubBruteMainView instance. The callback function will be
  13. * invoked when specific events occur in the SubBruteMainView. The context parameter allows passing additional data
  14. * to the callback function.
  15. *
  16. * @param instance Pointer to the SubBruteMainView instance.
  17. * @param callback Pointer to the callback function.
  18. * @param context Pointer to the context data.
  19. */
  20. void subbrute_main_view_set_callback(
  21. SubBruteMainView* instance,
  22. SubBruteMainViewCallback callback,
  23. void* context);
  24. /**
  25. * @brief Allocates memory for a new instance of SubBruteMainView.
  26. *
  27. * @return A pointer to the newly allocated SubBruteMainView object.
  28. * @note The caller is responsible for freeing the allocated memory using the `subbrute_main_view_free` function.
  29. */
  30. SubBruteMainView* subbrute_main_view_alloc();
  31. /**
  32. * @brief Frees the memory allocated for a SubBruteMainView instance.
  33. *
  34. * This function frees all the memory allocated for the given SubBruteMainView instance,
  35. * including its internal data structures.
  36. *
  37. * @param instance The SubBruteMainView instance to be freed.
  38. */
  39. void subbrute_main_view_free(SubBruteMainView* instance);
  40. /**
  41. * @brief Get the view associated with the SubBruteMainView instance.
  42. *
  43. * This function returns the view associated with the given SubBruteMainView instance.
  44. *
  45. * @param instance The SubBruteMainView instance.
  46. * @return A pointer to the View object.
  47. */
  48. View* subbrute_main_view_get_view(SubBruteMainView* instance);
  49. /**
  50. * @brief Sets the index and other parameters for the SubBruteMainView instance.
  51. *
  52. * @param instance The SubBruteMainView instance.
  53. * @param idx The index value to be set.
  54. * @param repeats Pointer to an array of repeat values.
  55. * @param is_select_byte Select byte value true or false.
  56. * @param two_bytes Two bytes value true or false.
  57. * @param key_from_file The key value from file.
  58. */
  59. void subbrute_main_view_set_index(
  60. SubBruteMainView* instance,
  61. uint8_t idx,
  62. const uint8_t* repeats,
  63. bool is_select_byte,
  64. bool two_bytes,
  65. uint64_t key_from_file);
  66. /**
  67. * @brief Get the index of the current subview in the main view.
  68. *
  69. * This function retrieves the index of the current subview within the main view. The current
  70. * subview is represented by a SubBruteMainView instance.
  71. *
  72. * @param instance A pointer to the SubBruteMainView instance.
  73. * @return The index of the current subview.
  74. */
  75. SubBruteAttacks subbrute_main_view_get_index(SubBruteMainView* instance);
  76. /**
  77. * @brief Retrieves the repeats of the main view in the SubBrute application.
  78. *
  79. * This function returns the repeats of the main view in the SubBrute application as a constant pointer to an array of uint8_t values.
  80. *
  81. * @param instance A pointer to the SubBruteMainView instance.
  82. * @return A constant pointer to an array of uint8_t values representing the repeats of the main view.
  83. */
  84. const uint8_t* subbrute_main_view_get_repeats(SubBruteMainView* instance);
  85. /**
  86. * @brief Retrieves two bytes from the SubBruteMainView instance.
  87. *
  88. * This function retrieves two bytes from the SubBruteMainView instance.
  89. * It returns a boolean value indicating the success of the operation.
  90. *
  91. * @param instance The SubBruteMainView instance from which to retrieve two bytes.
  92. *
  93. * @return true if the bytes were successfully retrieved, false otherwise.
  94. */
  95. bool subbrute_main_view_get_two_bytes(SubBruteMainView* instance);
  96. /**
  97. * @brief The function handles the entry point for the brute force attack view.
  98. *
  99. * This function is responsible for handling the entry point for the brute force
  100. * attack view. It takes a void pointer to the context data as an argument.
  101. *
  102. * @param context A void pointer to the context data.
  103. */
  104. void subbrute_attack_view_enter(void* context);
  105. /**
  106. * @brief Function to exit the subbrute attack view.
  107. *
  108. * This function is used to exit the subbrute attack view, by performing any necessary clean
  109. * up operations and freeing up any allocated memory.
  110. *
  111. * @param context A pointer to the context of the subbrute attack view.
  112. * This context contains all the necessary data and variables required by the view.
  113. * It should not be NULL.
  114. */
  115. void subbrute_attack_view_exit(void* context);
  116. /**
  117. * @brief View input handler for subbrute attack.
  118. *
  119. * This function processes an input event and performs the appropriate action
  120. * for the subbrute attack view. It is called by the main event loop.
  121. *
  122. * @param event The input event to be processed.
  123. * @param context A pointer to the context data for the subbrute attack view.
  124. * @return Boolean indicating whether the input event was handled successfully.
  125. * True if the event was handled successfully, false otherwise.
  126. */
  127. bool subbrute_attack_view_input(InputEvent* event, void* context);
  128. /**
  129. * @brief Draws a subbrute attack view on the given canvas.
  130. *
  131. * This function is responsible for drawing the subbrute attack view on the canvas.
  132. * The provided canvas should already be initialized and in a valid state.
  133. *
  134. * @param canvas The canvas on which the view should be drawn.
  135. * @param context A pointer to any additional context or data that may be needed for drawing.
  136. */
  137. void subbrute_attack_view_draw(Canvas* canvas, void* context);