PhishingCheckCard.hpp

PhishingCheckCard.hpp – Technical Description


1. Overview

The PhishingCheckCard.hpp header defines the PhishingCheckCard class, a GTKmm (GTK4) reusable UI component designed to provide a compact phishing analysis input card. Its purpose is to collect a URL from the user, validate the input format, and emit a signal when an analysis request is triggered.

Functionally, PhishingCheckCard provides:

  • A structured card-like GTK widget for phishing URL submission
  • Customizable title, description, placeholder, and action button text
  • User feedback messaging for validation or analysis status
  • URL getter/setter helpers for integration with external workflows
  • A signal-based mechanism to notify parent components when analysis is requested

2. Dependencies and Includes

#include <gtkmm.h>
#include <sigc++/sigc++.h>
  • gtkmm.h – GTK4 C++ widgets, containers, labels, buttons, images, and entries
  • sigc++/sigc++.h – signal/slot support for emitting and connecting analysis requests

3. Class Declaration and Scope

class PhishingCheckCard : public Gtk::Box

The class derives from Gtk::Box, making it a composite container widget that can be embedded in larger application layouts such as pages, panels, dialogs, or dashboard sections.

The component is self-contained and exposes a high-level interface for configuring text content, reading/writing the current URL, and reacting to user actions through a custom signal.


4. Public Interface

4.1 Constructor and Destructor

PhishingCheckCard();
virtual ~PhishingCheckCard() = default;

The constructor initializes the widget hierarchy, configures the card layout, and prepares the internal UI elements and action bindings. The destructor is virtual and defaulted, allowing safe cleanup when the widget is used polymorphically.


4.2 Analysis Signal Access

sigc::signal<void(const Glib::ustring&)>& signal_analyze_requested();

Returns a reference to the internal signal emitted when the user requests phishing analysis. The signal carries the submitted URL as a Glib::ustring, allowing external controllers or parent widgets to connect business logic without tightly coupling it to the card.


4.3 UI Text Configuration

void set_title(const Glib::ustring& text);
void set_description(const Glib::ustring& text);
void set_placeholder(const Glib::ustring& text);
void set_button_label(const Glib::ustring& text);

These methods allow runtime customization of the card’s visible text elements:

  • set_title() – sets the main title displayed on the card
  • set_description() – sets the explanatory or instructional text
  • set_placeholder() – defines the placeholder shown inside the URL entry field
  • set_button_label() – updates the action button caption

4.4 Feedback Handling

void set_feedback(const Glib::ustring& text, bool is_error = false);
void clear_feedback();

These methods control the feedback label used to display validation, status, or error messages:

  • set_feedback() – shows a feedback message; the optional is_error flag indicates whether the message should be presented as an error state
  • clear_feedback() – clears any currently displayed feedback text

4.5 URL Accessors

Glib::ustring get_url() const;
void set_url(const Glib::ustring& url);

These accessors provide controlled read/write access to the URL entry field:

  • get_url() – retrieves the current URL entered by the user
  • set_url() – programmatically fills the entry field with a URL value

5. UI Components

PhishingCheckCard is composed of multiple nested GTK containers and widgets arranged to form a card-like interface with icon, descriptive content, input field, action button, and feedback label.

5.1 Main Layout Containers

Gtk::Box root_box_{Gtk::Orientation::HORIZONTAL, 16};
Gtk::Box icon_box_{Gtk::Orientation::VERTICAL, 0};
Gtk::Box content_box_{Gtk::Orientation::VERTICAL, 8};
Gtk::Box action_row_{Gtk::Orientation::HORIZONTAL, 12};
  • root_box_ – top-level horizontal container for the full card layout
  • icon_box_ – vertical container dedicated to the card icon
  • content_box_ – vertical container for title, description, entry, and feedback
  • action_row_ – horizontal row containing the URL entry and analyze button

5.2 Visual and Text Elements

Gtk::Image icon_;
Gtk::Label lbl_title_;
Gtk::Label lbl_description_;
Gtk::Label lbl_feedback_;

These widgets provide the visual identity and user-facing text of the component:

  • icon_ – graphical element representing the phishing/security action
  • lbl_title_ – primary heading of the card
  • lbl_description_ – descriptive helper text explaining the feature
  • lbl_feedback_ – dynamic label for validation or status feedback

5.3 Input and Action Widgets

Gtk::Entry entry_url_;
Gtk::Button btn_analyze_;
  • entry_url_ – text entry field where the user provides the URL to inspect
  • btn_analyze_ – action button that triggers phishing analysis request handling

6. Internal State and Signal Model

sigc::signal<void(const Glib::ustring&)> signal_analyze_requested_;

The component stores an internal signal used to notify external listeners when the analyze action is requested. This design follows GTKmm/sigc++ event-driven patterns and cleanly separates presentation logic from phishing analysis implementation.

No standalone domain model is declared in the header; instead, the widget operates directly on the state held by its UI controls and emits the submitted URL outward when needed.


7. User Actions (Callbacks)

void on_analyze_clicked();

Handles the analyze button click event. This callback is expected to:

  • Read the current value from entry_url_
  • Validate the URL format
  • Update feedback state if input is invalid
  • Emit signal_analyze_requested_ when validation succeeds

8. Internal Validation Logic

bool is_valid_url(const Glib::ustring& url) const;

Performs URL validation before an analysis request is emitted. The exact validation policy is implementation-defined, but it is intended to ensure that only properly formed and acceptable URL values are passed to downstream phishing analysis logic.

This method is central to maintaining input quality and preventing accidental or malformed submissions from propagating through the application workflow.


9. Widget Composition and Interaction Model

The class is designed as a reusable UI card rather than a full page. It can therefore be embedded inside larger GTKmm views that orchestrate broader phishing detection workflows, such as:

  • security dashboards
  • URL inspection tools
  • browser protection panels
  • threat analysis pages

The signal-based API allows parent components to react to user input without directly depending on the internal widget tree, improving modularity and making the card suitable for reuse across multiple contexts.


10. Runtime and Security Considerations

  • Input validation: URL validation should reject malformed or incomplete values before analysis is triggered.
  • Feedback clarity: messages shown through lbl_feedback_ should be concise, actionable, and visually distinguish errors from neutral or successful states.
  • UI responsiveness: the card should emit the analysis request quickly and leave any heavy phishing detection logic to asynchronous or external handlers.
  • Separation of concerns: the widget should remain focused on presentation, validation, and signaling, while networking or threat-analysis engines are handled elsewhere.
  • Unicode-safe text handling: use of Glib::ustring ensures proper handling of UTF-8 text in titles, descriptions, feedback, and URL input.