aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings.cpp1288
-rw-r--r--src/Bindings.h180
-rw-r--r--src/GraphemeCountValidator.cpp42
-rw-r--r--src/GraphemeCountValidator.h26
-rw-r--r--src/PassFish.cpp28
-rw-r--r--src/pwm_qhash.cpp22
6 files changed, 1586 insertions, 0 deletions
diff --git a/src/Bindings.cpp b/src/Bindings.cpp
new file mode 100644
index 0000000..a673895
--- /dev/null
+++ b/src/Bindings.cpp
@@ -0,0 +1,1288 @@
+/* generated by rust_qt_binding_generator */
+/* Beware: a lot of const pointers mentioned in this file are mutating data on the Rust side. */
+#include "Bindings.h"
+
+namespace {
+
+ struct option_quint32 {
+ public:
+ quint32 value;
+ bool some;
+ operator QVariant() const {
+ if (some) {
+ return QVariant::fromValue(value);
+ }
+ return QVariant();
+ }
+ };
+ static_assert(std::is_pod<option_quint32>::value, "option_quint32 must be a POD type.");
+
+ struct option_quintptr {
+ public:
+ quintptr value;
+ bool some;
+ operator QVariant() const {
+ if (some) {
+ return QVariant::fromValue(value);
+ }
+ return QVariant();
+ }
+ };
+ static_assert(std::is_pod<option_quintptr>::value, "option_quintptr must be a POD type.");
+
+ typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
+ void set_qstring(QString* val, const char* utf8, int nbytes) {
+ *val = QString::fromUtf8(utf8, nbytes);
+ }
+
+ struct qmodelindex_t {
+ int row;
+ quintptr id;
+ };
+ inline QVariant cleanNullQVariant(const QVariant& v) {
+ return (v.isNull()) ?QVariant() :v;
+ }
+ inline void passwordMakerGenerated_passwordChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->generated_passwordChanged();
+ }
+ inline void passwordMakerGenerator_stateChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->generator_stateChanged();
+ }
+ inline void passwordMakerI_say_sexy_things_to_myself_while_im_dancingChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->i_say_sexy_things_to_myself_while_im_dancingChanged();
+ }
+ inline void passwordMakerMaster_passwordChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->master_passwordChanged();
+ }
+ inline void passwordMakerUrlChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->urlChanged();
+ }
+ inline void passwordMakerUsed_textChanged(PasswordMaker* o)
+ {
+ Q_EMIT o->used_textChanged();
+ }
+ inline void profilesCurrent_profileChanged(Profiles* o)
+ {
+ Q_EMIT o->current_profileChanged();
+ }
+ inline void profilesCurrent_profile_nameChanged(Profiles* o)
+ {
+ Q_EMIT o->current_profile_nameChanged();
+ }
+ inline void settingsClear_generated_password_secondsChanged(Settings* o)
+ {
+ Q_EMIT o->clear_generated_password_secondsChanged();
+ }
+ inline void settingsClear_master_password_secondsChanged(Settings* o)
+ {
+ Q_EMIT o->clear_master_password_secondsChanged();
+ }
+ inline void settingsHide_generated_passwordChanged(Settings* o)
+ {
+ Q_EMIT o->hide_generated_passwordChanged();
+ }
+}
+extern "C" {
+ PasswordMaker::Private* password_maker_new(PasswordMaker*, void (*)(PasswordMaker*), void (*)(PasswordMaker*), void (*)(PasswordMaker*), void (*)(PasswordMaker*), Profiles*, void (*)(Profiles*), void (*)(Profiles*),
+ void (*)(const Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*, quintptr, quintptr),
+ void (*)(Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int, int),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int),
+ void (*)(Profiles*), Settings*, void (*)(Settings*), void (*)(Settings*), void (*)(Settings*), void (*)(PasswordMaker*), void (*)(PasswordMaker*));
+ void password_maker_free(PasswordMaker::Private*);
+ void password_maker_generated_password_get(const PasswordMaker::Private*, QString*, qstring_set);
+ quint8 password_maker_generator_state_get(const PasswordMaker::Private*);
+ bool password_maker_i_say_sexy_things_to_myself_while_im_dancing_get(const PasswordMaker::Private*);
+ void password_maker_i_say_sexy_things_to_myself_while_im_dancing_set(const PasswordMaker::Private*, bool);
+ void password_maker_master_password_get(const PasswordMaker::Private*, QString*, qstring_set);
+ void password_maker_master_password_set(const PasswordMaker::Private*, const ushort *str, int len);
+ const Profiles::Private* password_maker_profiles_get(const PasswordMaker::Private*);
+ const Settings::Private* password_maker_settings_get(const PasswordMaker::Private*);
+ void password_maker_url_get(const PasswordMaker::Private*, QString*, qstring_set);
+ void password_maker_url_set(const PasswordMaker::Private*, const ushort *str, int len);
+ void password_maker_used_text_get(const PasswordMaker::Private*, QString*, qstring_set);
+ void password_maker_used_text_set(const PasswordMaker::Private*, const ushort *str, int len);
+ void password_maker_profile_changed(const PasswordMaker::Private*);
+ bool password_maker_store_settings(const PasswordMaker::Private*);
+};
+
+extern "C" {
+ void profiles_data_characters(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_characters(const Profiles::Private*, int, const ushort* s, int len);
+ quint8 profiles_data_hash_algorithm(const Profiles::Private*, int);
+ bool profiles_set_data_hash_algorithm(const Profiles::Private*, int, quint8);
+ quint8 profiles_data_leet_level(const Profiles::Private*, int);
+ bool profiles_set_data_leet_level(const Profiles::Private*, int, quint8);
+ void profiles_data_modifier(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_modifier(const Profiles::Private*, int, const ushort* s, int len);
+ void profiles_data_name(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_name(const Profiles::Private*, int, const ushort* s, int len);
+ quint32 profiles_data_password_length(const Profiles::Private*, int);
+ bool profiles_set_data_password_length(const Profiles::Private*, int, quint32);
+ void profiles_data_prefix(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_prefix(const Profiles::Private*, int, const ushort* s, int len);
+ void profiles_data_suffix(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_suffix(const Profiles::Private*, int, const ushort* s, int len);
+ bool profiles_data_use_domain(const Profiles::Private*, int);
+ bool profiles_set_data_use_domain(const Profiles::Private*, int, bool);
+ quint8 profiles_data_use_leet(const Profiles::Private*, int);
+ bool profiles_set_data_use_leet(const Profiles::Private*, int, quint8);
+ bool profiles_data_use_port_path(const Profiles::Private*, int);
+ bool profiles_set_data_use_port_path(const Profiles::Private*, int, bool);
+ bool profiles_data_use_protocol(const Profiles::Private*, int);
+ bool profiles_set_data_use_protocol(const Profiles::Private*, int, bool);
+ bool profiles_data_use_subdomains(const Profiles::Private*, int);
+ bool profiles_set_data_use_subdomains(const Profiles::Private*, int, bool);
+ bool profiles_data_use_undefined_as_protocol_fallback(const Profiles::Private*, int);
+ bool profiles_set_data_use_undefined_as_protocol_fallback(const Profiles::Private*, int, bool);
+ bool profiles_data_use_user_info(const Profiles::Private*, int);
+ bool profiles_set_data_use_user_info(const Profiles::Private*, int, bool);
+ void profiles_data_username(const Profiles::Private*, int, QString*, qstring_set);
+ bool profiles_set_data_username(const Profiles::Private*, int, const ushort* s, int len);
+ void profiles_sort(const Profiles::Private*, unsigned char column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ int profiles_row_count(const Profiles::Private*);
+ bool profiles_insert_rows(const Profiles::Private*, int, int);
+ bool profiles_remove_rows(const Profiles::Private*, int, int);
+ bool profiles_can_fetch_more(const Profiles::Private*);
+ void profiles_fetch_more(const Profiles::Private*);
+}
+int Profiles::columnCount(const QModelIndex &parent) const
+{
+ return (parent.isValid()) ? 0 : 16;
+}
+
+bool Profiles::hasChildren(const QModelIndex &parent) const
+{
+ return rowCount(parent) > 0;
+}
+
+int Profiles::rowCount(const QModelIndex &parent) const
+{
+ return (parent.isValid()) ? 0 : profiles_row_count(m_d);
+}
+
+bool Profiles::insertRows(int row, int count, const QModelIndex &)
+{
+ return profiles_insert_rows(m_d, row, count);
+}
+
+bool Profiles::removeRows(int row, int count, const QModelIndex &)
+{
+ return profiles_remove_rows(m_d, row, count);
+}
+
+QModelIndex Profiles::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!parent.isValid() && row >= 0 && row < rowCount(parent) && column >= 0 && column < 16) {
+ return createIndex(row, column, (quintptr)row);
+ }
+ return QModelIndex();
+}
+
+QModelIndex Profiles::parent(const QModelIndex &) const
+{
+ return QModelIndex();
+}
+
+bool Profiles::canFetchMore(const QModelIndex &parent) const
+{
+ return (parent.isValid()) ? 0 : profiles_can_fetch_more(m_d);
+}
+
+void Profiles::fetchMore(const QModelIndex &parent)
+{
+ if (!parent.isValid()) {
+ profiles_fetch_more(m_d);
+ }
+}
+void Profiles::updatePersistentIndexes() {}
+
+void Profiles::sort(int column, Qt::SortOrder order)
+{
+ profiles_sort(m_d, column, order);
+}
+Qt::ItemFlags Profiles::flags(const QModelIndex &i) const
+{
+ auto flags = QAbstractItemModel::flags(i);
+ if (i.column() == 0) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 1) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 2) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 3) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 4) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 5) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 6) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 7) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 8) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 9) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 10) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 11) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 12) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 13) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 14) {
+ flags |= Qt::ItemIsEditable;
+ }
+ if (i.column() == 15) {
+ flags |= Qt::ItemIsEditable;
+ }
+ return flags;
+}
+
+QString Profiles::characters(int row) const
+{
+ QString s;
+ profiles_data_characters(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setCharacters(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_characters(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+quint8 Profiles::hash_algorithm(int row) const
+{
+ return profiles_data_hash_algorithm(m_d, row);
+}
+
+bool Profiles::setHash_algorithm(int row, quint8 value)
+{
+ bool set = false;
+ set = profiles_set_data_hash_algorithm(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+quint8 Profiles::leet_level(int row) const
+{
+ return profiles_data_leet_level(m_d, row);
+}
+
+bool Profiles::setLeet_level(int row, quint8 value)
+{
+ bool set = false;
+ set = profiles_set_data_leet_level(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QString Profiles::modifier(int row) const
+{
+ QString s;
+ profiles_data_modifier(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setModifier(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_modifier(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QString Profiles::name(int row) const
+{
+ QString s;
+ profiles_data_name(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setName(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_name(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+quint32 Profiles::password_length(int row) const
+{
+ return profiles_data_password_length(m_d, row);
+}
+
+bool Profiles::setPassword_length(int row, quint32 value)
+{
+ bool set = false;
+ set = profiles_set_data_password_length(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QString Profiles::prefix(int row) const
+{
+ QString s;
+ profiles_data_prefix(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setPrefix(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_prefix(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QString Profiles::suffix(int row) const
+{
+ QString s;
+ profiles_data_suffix(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setSuffix(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_suffix(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_domain(int row) const
+{
+ return profiles_data_use_domain(m_d, row);
+}
+
+bool Profiles::setUse_domain(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_domain(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+quint8 Profiles::use_leet(int row) const
+{
+ return profiles_data_use_leet(m_d, row);
+}
+
+bool Profiles::setUse_leet(int row, quint8 value)
+{
+ bool set = false;
+ set = profiles_set_data_use_leet(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_port_path(int row) const
+{
+ return profiles_data_use_port_path(m_d, row);
+}
+
+bool Profiles::setUse_port_path(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_port_path(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_protocol(int row) const
+{
+ return profiles_data_use_protocol(m_d, row);
+}
+
+bool Profiles::setUse_protocol(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_protocol(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_subdomains(int row) const
+{
+ return profiles_data_use_subdomains(m_d, row);
+}
+
+bool Profiles::setUse_subdomains(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_subdomains(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_undefined_as_protocol_fallback(int row) const
+{
+ return profiles_data_use_undefined_as_protocol_fallback(m_d, row);
+}
+
+bool Profiles::setUse_undefined_as_protocol_fallback(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_undefined_as_protocol_fallback(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+bool Profiles::use_user_info(int row) const
+{
+ return profiles_data_use_user_info(m_d, row);
+}
+
+bool Profiles::setUse_user_info(int row, bool value)
+{
+ bool set = false;
+ set = profiles_set_data_use_user_info(m_d, row, value);
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QString Profiles::username(int row) const
+{
+ QString s;
+ profiles_data_username(m_d, row, &s, set_qstring);
+ return s;
+}
+
+bool Profiles::setUsername(int row, const QString& value)
+{
+ bool set = false;
+ set = profiles_set_data_username(m_d, row, value.utf16(), value.length());
+ if (set) {
+ QModelIndex index = createIndex(row, 0, row);
+ Q_EMIT dataChanged(index, index);
+ }
+ return set;
+}
+
+QVariant Profiles::data(const QModelIndex &index, int role) const
+{
+ Q_ASSERT(rowCount(index.parent()) > index.row());
+ switch (index.column()) {
+ case 0:
+ switch (role) {
+ case Qt::UserRole + 0:
+ return QVariant::fromValue(characters(index.row()));
+ case Qt::UserRole + 1:
+ return QVariant::fromValue(hash_algorithm(index.row()));
+ case Qt::UserRole + 2:
+ return QVariant::fromValue(leet_level(index.row()));
+ case Qt::UserRole + 3:
+ return QVariant::fromValue(modifier(index.row()));
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 4:
+ return QVariant::fromValue(name(index.row()));
+ case Qt::UserRole + 5:
+ return QVariant::fromValue(password_length(index.row()));
+ case Qt::UserRole + 6:
+ return QVariant::fromValue(prefix(index.row()));
+ case Qt::UserRole + 7:
+ return QVariant::fromValue(suffix(index.row()));
+ case Qt::UserRole + 8:
+ return QVariant::fromValue(use_domain(index.row()));
+ case Qt::UserRole + 9:
+ return QVariant::fromValue(use_leet(index.row()));
+ case Qt::UserRole + 10:
+ return QVariant::fromValue(use_port_path(index.row()));
+ case Qt::UserRole + 11:
+ return QVariant::fromValue(use_protocol(index.row()));
+ case Qt::UserRole + 12:
+ return QVariant::fromValue(use_subdomains(index.row()));
+ case Qt::UserRole + 13:
+ return QVariant::fromValue(use_undefined_as_protocol_fallback(index.row()));
+ case Qt::UserRole + 14:
+ return QVariant::fromValue(use_user_info(index.row()));
+ case Qt::UserRole + 15:
+ return QVariant::fromValue(username(index.row()));
+ }
+ break;
+ case 1:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 11:
+ return QVariant::fromValue(use_protocol(index.row()));
+ }
+ break;
+ case 2:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 12:
+ return QVariant::fromValue(use_subdomains(index.row()));
+ }
+ break;
+ case 3:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 8:
+ return QVariant::fromValue(use_domain(index.row()));
+ }
+ break;
+ case 4:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 10:
+ return QVariant::fromValue(use_port_path(index.row()));
+ }
+ break;
+ case 5:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 14:
+ return QVariant::fromValue(use_user_info(index.row()));
+ }
+ break;
+ case 6:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 13:
+ return QVariant::fromValue(use_undefined_as_protocol_fallback(index.row()));
+ }
+ break;
+ case 7:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 5:
+ return QVariant::fromValue(password_length(index.row()));
+ }
+ break;
+ case 8:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 1:
+ return QVariant::fromValue(hash_algorithm(index.row()));
+ }
+ break;
+ case 9:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 9:
+ return QVariant::fromValue(use_leet(index.row()));
+ }
+ break;
+ case 10:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 2:
+ return QVariant::fromValue(leet_level(index.row()));
+ }
+ break;
+ case 11:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 0:
+ return QVariant::fromValue(characters(index.row()));
+ }
+ break;
+ case 12:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 15:
+ return QVariant::fromValue(username(index.row()));
+ }
+ break;
+ case 13:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 3:
+ return QVariant::fromValue(modifier(index.row()));
+ }
+ break;
+ case 14:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 6:
+ return QVariant::fromValue(prefix(index.row()));
+ }
+ break;
+ case 15:
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::UserRole + 7:
+ return QVariant::fromValue(suffix(index.row()));
+ }
+ break;
+ }
+ return QVariant();
+}
+
+int Profiles::role(const char* name) const {
+ auto names = roleNames();
+ auto i = names.constBegin();
+ while (i != names.constEnd()) {
+ if (i.value() == name) {
+ return i.key();
+ }
+ ++i;
+ }
+ return -1;
+}
+QHash<int, QByteArray> Profiles::roleNames() const {
+ QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
+ names.insert(Qt::UserRole + 0, "characters");
+ names.insert(Qt::UserRole + 1, "hash_algorithm");
+ names.insert(Qt::UserRole + 2, "leet_level");
+ names.insert(Qt::UserRole + 3, "modifier");
+ names.insert(Qt::UserRole + 4, "name");
+ names.insert(Qt::UserRole + 5, "password_length");
+ names.insert(Qt::UserRole + 6, "prefix");
+ names.insert(Qt::UserRole + 7, "suffix");
+ names.insert(Qt::UserRole + 8, "use_domain");
+ names.insert(Qt::UserRole + 9, "use_leet");
+ names.insert(Qt::UserRole + 10, "use_port_path");
+ names.insert(Qt::UserRole + 11, "use_protocol");
+ names.insert(Qt::UserRole + 12, "use_subdomains");
+ names.insert(Qt::UserRole + 13, "use_undefined_as_protocol_fallback");
+ names.insert(Qt::UserRole + 14, "use_user_info");
+ names.insert(Qt::UserRole + 15, "username");
+ return names;
+}
+QVariant Profiles::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation != Qt::Horizontal) {
+ return QVariant();
+ }
+ return m_headerData.value(qMakePair(section, (Qt::ItemDataRole)role), role == Qt::DisplayRole ?QString::number(section + 1) :QVariant());
+}
+
+bool Profiles::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
+{
+ if (orientation != Qt::Horizontal) {
+ return false;
+ }
+ m_headerData.insert(qMakePair(section, (Qt::ItemDataRole)role), value);
+ return true;
+}
+
+bool Profiles::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.column() == 0) {
+ if (role == Qt::UserRole + 0) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setCharacters(index.row(), value.value<QString>());
+ }
+ }
+ if (role == Qt::UserRole + 1) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setHash_algorithm(index.row(), value.value<quint8>());
+ }
+ }
+ if (role == Qt::UserRole + 2) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setLeet_level(index.row(), value.value<quint8>());
+ }
+ }
+ if (role == Qt::UserRole + 3) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setModifier(index.row(), value.value<QString>());
+ }
+ }
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 4) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setName(index.row(), value.value<QString>());
+ }
+ }
+ if (role == Qt::UserRole + 5) {
+ if (value.canConvert(qMetaTypeId<quint32>())) {
+ return setPassword_length(index.row(), value.value<quint32>());
+ }
+ }
+ if (role == Qt::UserRole + 6) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setPrefix(index.row(), value.value<QString>());
+ }
+ }
+ if (role == Qt::UserRole + 7) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setSuffix(index.row(), value.value<QString>());
+ }
+ }
+ if (role == Qt::UserRole + 8) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_domain(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 9) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setUse_leet(index.row(), value.value<quint8>());
+ }
+ }
+ if (role == Qt::UserRole + 10) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_port_path(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 11) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_protocol(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 12) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_subdomains(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 13) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_undefined_as_protocol_fallback(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 14) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_user_info(index.row(), value.value<bool>());
+ }
+ }
+ if (role == Qt::UserRole + 15) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setUsername(index.row(), value.value<QString>());
+ }
+ }
+ }
+ if (index.column() == 1) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 11) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_protocol(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 2) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 12) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_subdomains(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 3) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 8) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_domain(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 4) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 10) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_port_path(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 5) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 14) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_user_info(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 6) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 13) {
+ if (value.canConvert(qMetaTypeId<bool>())) {
+ return setUse_undefined_as_protocol_fallback(index.row(), value.value<bool>());
+ }
+ }
+ }
+ if (index.column() == 7) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 5) {
+ if (value.canConvert(qMetaTypeId<quint32>())) {
+ return setPassword_length(index.row(), value.value<quint32>());
+ }
+ }
+ }
+ if (index.column() == 8) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 1) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setHash_algorithm(index.row(), value.value<quint8>());
+ }
+ }
+ }
+ if (index.column() == 9) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 9) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setUse_leet(index.row(), value.value<quint8>());
+ }
+ }
+ }
+ if (index.column() == 10) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 2) {
+ if (value.canConvert(qMetaTypeId<quint8>())) {
+ return setLeet_level(index.row(), value.value<quint8>());
+ }
+ }
+ }
+ if (index.column() == 11) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 0) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setCharacters(index.row(), value.value<QString>());
+ }
+ }
+ }
+ if (index.column() == 12) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 15) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setUsername(index.row(), value.value<QString>());
+ }
+ }
+ }
+ if (index.column() == 13) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 3) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setModifier(index.row(), value.value<QString>());
+ }
+ }
+ }
+ if (index.column() == 14) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 6) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setPrefix(index.row(), value.value<QString>());
+ }
+ }
+ }
+ if (index.column() == 15) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole + 7) {
+ if (value.canConvert(qMetaTypeId<QString>())) {
+ return setSuffix(index.row(), value.value<QString>());
+ }
+ }
+ }
+ return false;
+}
+
+extern "C" {
+ Profiles::Private* profiles_new(Profiles*, void (*)(Profiles*), void (*)(Profiles*),
+ void (*)(const Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*, quintptr, quintptr),
+ void (*)(Profiles*),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int, int),
+ void (*)(Profiles*),
+ void (*)(Profiles*, int, int),
+ void (*)(Profiles*));
+ void profiles_free(Profiles::Private*);
+ quint32 profiles_current_profile_get(const Profiles::Private*);
+ void profiles_current_profile_set(const Profiles::Private*, quint32);
+ void profiles_current_profile_name_get(const Profiles::Private*, QString*, qstring_set);
+ bool profiles_store(const Profiles::Private*);
+};
+
+extern "C" {
+ Settings::Private* settings_new(Settings*, void (*)(Settings*), void (*)(Settings*), void (*)(Settings*));
+ void settings_free(Settings::Private*);
+ option_quint32 settings_clear_generated_password_seconds_get(const Settings::Private*);
+ void settings_clear_generated_password_seconds_set(const Settings::Private*, quint32);
+ void settings_clear_generated_password_seconds_set_none(const Settings::Private*);
+ option_quint32 settings_clear_master_password_seconds_get(const Settings::Private*);
+ void settings_clear_master_password_seconds_set(const Settings::Private*, quint32);
+ void settings_clear_master_password_seconds_set_none(const Settings::Private*);
+ bool settings_hide_generated_password_get(const Settings::Private*);
+ void settings_hide_generated_password_set(const Settings::Private*, bool);
+};
+
+PasswordMaker::PasswordMaker(bool /*owned*/, QObject *parent):
+ QObject(parent),
+ m_profiles(new Profiles(false, this)),
+ m_settings(new Settings(false, this)),
+ m_d(nullptr),
+ m_d_owned(nullptr)
+{
+}
+
+PasswordMaker::PasswordMaker(QObject *parent):
+ QObject(parent),
+ m_profiles(new Profiles(false, this)),
+ m_settings(new Settings(false, this)),
+ m_d(nullptr),
+ m_d_owned(password_maker_new(this,
+ passwordMakerGenerated_passwordChanged,
+ passwordMakerGenerator_stateChanged,
+ passwordMakerI_say_sexy_things_to_myself_while_im_dancingChanged,
+ passwordMakerMaster_passwordChanged, m_profiles,
+ profilesCurrent_profileChanged,
+ profilesCurrent_profile_nameChanged,
+ [](const Profiles* o) {
+ Q_EMIT o->newDataReady(QVariant());
+ },
+ [](Profiles* o) {
+ Q_EMIT o->layoutAboutToBeChanged();
+ },
+ [](Profiles* o) {
+ o->updatePersistentIndexes();
+ Q_EMIT o->layoutChanged();
+ },
+ [](Profiles* o, quintptr first, quintptr last) {
+ o->dataChanged(o->createIndex(first, 0, first),
+ o->createIndex(last, 15, last));
+ },
+ [](Profiles* o) {
+ o->beginResetModel();
+ },
+ [](Profiles* o) {
+ o->endResetModel();
+ },
+ [](Profiles* o, int first, int last) {
+ o->beginInsertRows(QModelIndex(), first, last);
+ },
+ [](Profiles* o) {
+ o->endInsertRows();
+ },
+ [](Profiles* o, int first, int last, int destination) {
+ o->beginMoveRows(QModelIndex(), first, last, QModelIndex(), destination);
+ },
+ [](Profiles* o) {
+ o->endMoveRows();
+ },
+ [](Profiles* o, int first, int last) {
+ o->beginRemoveRows(QModelIndex(), first, last);
+ },
+ [](Profiles* o) {
+ o->endRemoveRows();
+ }
+, m_settings,
+ settingsClear_generated_password_secondsChanged,
+ settingsClear_master_password_secondsChanged,
+ settingsHide_generated_passwordChanged,
+ passwordMakerUrlChanged,
+ passwordMakerUsed_textChanged))
+{
+ m_d = m_d_owned;
+ m_profiles->m_d = password_maker_profiles_get(m_d);
+ m_settings->m_d = password_maker_settings_get(m_d);
+ connect(this->m_profiles, &Profiles::newDataReady, this->m_profiles, [this](const QVariant& v) {
+ this->m_profiles->fetchMore(QModelIndex());
+ }, Qt::QueuedConnection);
+}
+
+PasswordMaker::~PasswordMaker() {
+ if (m_d_owned) {
+ password_maker_free(m_d_owned);
+ }
+}
+QString PasswordMaker::generated_password() const
+{
+ QString v;
+ password_maker_generated_password_get(m_d, &v, set_qstring);
+ return v;
+}
+quint8 PasswordMaker::generator_state() const
+{
+ return password_maker_generator_state_get(m_d);
+}
+bool PasswordMaker::i_say_sexy_things_to_myself_while_im_dancing() const
+{
+ return password_maker_i_say_sexy_things_to_myself_while_im_dancing_get(m_d);
+}
+void PasswordMaker::setI_say_sexy_things_to_myself_while_im_dancing(bool v) {
+ password_maker_i_say_sexy_things_to_myself_while_im_dancing_set(m_d, v);
+}
+QString PasswordMaker::master_password() const
+{
+ QString v;
+ password_maker_master_password_get(m_d, &v, set_qstring);
+ return v;
+}
+void PasswordMaker::setMaster_password(const QString& v) {
+ password_maker_master_password_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
+}
+const Profiles* PasswordMaker::profiles() const
+{
+ return m_profiles;
+}
+Profiles* PasswordMaker::profiles()
+{
+ return m_profiles;
+}
+const Settings* PasswordMaker::settings() const
+{
+ return m_settings;
+}
+Settings* PasswordMaker::settings()
+{
+ return m_settings;
+}
+QString PasswordMaker::url() const
+{
+ QString v;
+ password_maker_url_get(m_d, &v, set_qstring);
+ return v;
+}
+void PasswordMaker::setUrl(const QString& v) {
+ password_maker_url_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
+}
+QString PasswordMaker::used_text() const
+{
+ QString v;
+ password_maker_used_text_get(m_d, &v, set_qstring);
+ return v;
+}
+void PasswordMaker::setUsed_text(const QString& v) {
+ password_maker_used_text_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
+}
+void PasswordMaker::profile_changed() const
+{
+ return password_maker_profile_changed(m_d);
+}
+bool PasswordMaker::store_settings() const
+{
+ return password_maker_store_settings(m_d);
+}
+Profiles::Profiles(bool /*owned*/, QObject *parent):
+ QAbstractItemModel(parent),
+ m_d(nullptr),
+ m_d_owned(nullptr)
+{
+ initHeaderData();
+}
+
+Profiles::Profiles(QObject *parent):
+ QAbstractItemModel(parent),
+ m_d(nullptr),
+ m_d_owned(profiles_new(this,
+ profilesCurrent_profileChanged,
+ profilesCurrent_profile_nameChanged,
+ [](const Profiles* o) {
+ Q_EMIT o->newDataReady(QVariant());
+ },
+ [](Profiles* o) {
+ Q_EMIT o->layoutAboutToBeChanged();
+ },
+ [](Profiles* o) {
+ o->updatePersistentIndexes();
+ Q_EMIT o->layoutChanged();
+ },
+ [](Profiles* o, quintptr first, quintptr last) {
+ o->dataChanged(o->createIndex(first, 0, first),
+ o->createIndex(last, 15, last));
+ },
+ [](Profiles* o) {
+ o->beginResetModel();
+ },
+ [](Profiles* o) {
+ o->endResetModel();
+ },
+ [](Profiles* o, int first, int last) {
+ o->beginInsertRows(QModelIndex(), first, last);
+ },
+ [](Profiles* o) {
+ o->endInsertRows();
+ },
+ [](Profiles* o, int first, int last, int destination) {
+ o->beginMoveRows(QModelIndex(), first, last, QModelIndex(), destination);
+ },
+ [](Profiles* o) {
+ o->endMoveRows();
+ },
+ [](Profiles* o, int first, int last) {
+ o->beginRemoveRows(QModelIndex(), first, last);
+ },
+ [](Profiles* o) {
+ o->endRemoveRows();
+ }
+))
+{
+ m_d = m_d_owned;
+ connect(this, &Profiles::newDataReady, this, [this](const QVariant& v) {
+ this->fetchMore(QModelIndex());
+ }, Qt::QueuedConnection);
+ initHeaderData();
+}
+
+Profiles::~Profiles() {
+ if (m_d_owned) {
+ profiles_free(m_d_owned);
+ }
+}
+void Profiles::initHeaderData() {
+ m_headerData.insert(qMakePair(0, Qt::DisplayRole), QVariant("name"));
+ m_headerData.insert(qMakePair(1, Qt::DisplayRole), QVariant("use_protocol"));
+ m_headerData.insert(qMakePair(2, Qt::DisplayRole), QVariant("use_subdomains"));
+ m_headerData.insert(qMakePair(3, Qt::DisplayRole), QVariant("use_domain"));
+ m_headerData.insert(qMakePair(4, Qt::DisplayRole), QVariant("use_port_path"));
+ m_headerData.insert(qMakePair(5, Qt::DisplayRole), QVariant("use_user_info"));
+ m_headerData.insert(qMakePair(6, Qt::DisplayRole), QVariant("use_undefined_as_protocol_fallback"));
+ m_headerData.insert(qMakePair(7, Qt::DisplayRole), QVariant("password_length"));
+ m_headerData.insert(qMakePair(8, Qt::DisplayRole), QVariant("hash_algorithm"));
+ m_headerData.insert(qMakePair(9, Qt::DisplayRole), QVariant("use_leet"));
+ m_headerData.insert(qMakePair(10, Qt::DisplayRole), QVariant("leet_level"));
+ m_headerData.insert(qMakePair(11, Qt::DisplayRole), QVariant("characters"));
+ m_headerData.insert(qMakePair(12, Qt::DisplayRole), QVariant("username"));
+ m_headerData.insert(qMakePair(13, Qt::DisplayRole), QVariant("modifier"));
+ m_headerData.insert(qMakePair(14, Qt::DisplayRole), QVariant("prefix"));
+ m_headerData.insert(qMakePair(15, Qt::DisplayRole), QVariant("suffix"));
+}
+quint32 Profiles::current_profile() const
+{
+ return profiles_current_profile_get(m_d);
+}
+void Profiles::setCurrent_profile(quint32 v) {
+ profiles_current_profile_set(m_d, v);
+}
+QString Profiles::current_profile_name() const
+{
+ QString v;
+ profiles_current_profile_name_get(m_d, &v, set_qstring);
+ return v;
+}
+bool Profiles::store() const
+{
+ return profiles_store(m_d);
+}
+Settings::Settings(bool /*owned*/, QObject *parent):
+ QObject(parent),
+ m_d(nullptr),
+ m_d_owned(nullptr)
+{
+}
+
+Settings::Settings(QObject *parent):
+ QObject(parent),
+ m_d(nullptr),
+ m_d_owned(settings_new(this,
+ settingsClear_generated_password_secondsChanged,
+ settingsClear_master_password_secondsChanged,
+ settingsHide_generated_passwordChanged))
+{
+ m_d = m_d_owned;
+}
+
+Settings::~Settings() {
+ if (m_d_owned) {
+ settings_free(m_d_owned);
+ }
+}
+QVariant Settings::clear_generated_password_seconds() const
+{
+ QVariant v;
+ auto r = settings_clear_generated_password_seconds_get(m_d);
+ if (r.some) {
+ v.setValue(r.value);
+ }
+ return r;
+}
+void Settings::setClear_generated_password_seconds(const QVariant& v) {
+ if (v.isNull() || !v.canConvert<quint32>()) {
+ settings_clear_generated_password_seconds_set_none(m_d);
+ } else {
+ settings_clear_generated_password_seconds_set(m_d, v.value<quint32>());
+ }
+}
+QVariant Settings::clear_master_password_seconds() const
+{
+ QVariant v;
+ auto r = settings_clear_master_password_seconds_get(m_d);
+ if (r.some) {
+ v.setValue(r.value);
+ }
+ return r;
+}
+void Settings::setClear_master_password_seconds(const QVariant& v) {
+ if (v.isNull() || !v.canConvert<quint32>()) {
+ settings_clear_master_password_seconds_set_none(m_d);
+ } else {
+ settings_clear_master_password_seconds_set(m_d, v.value<quint32>());
+ }
+}
+bool Settings::hide_generated_password() const
+{
+ return settings_hide_generated_password_get(m_d);
+}
+void Settings::setHide_generated_password(bool v) {
+ settings_hide_generated_password_set(m_d, v);
+}
diff --git a/src/Bindings.h b/src/Bindings.h
new file mode 100644
index 0000000..3aa3e77
--- /dev/null
+++ b/src/Bindings.h
@@ -0,0 +1,180 @@
+/* generated by rust_qt_binding_generator */
+/* Beware: a lot of const pointers mentioned in this file are mutating data on the Rust side. */
+#ifndef BINDINGS_H
+#define BINDINGS_H
+
+#include <QtCore/QObject>
+#include <QtCore/QAbstractItemModel>
+
+class PasswordMaker;
+class Profiles;
+class Settings;
+
+class PasswordMaker : public QObject
+{
+ Q_OBJECT
+public:
+ class Private;
+private:
+ Profiles* const m_profiles;
+ Settings* const m_settings;
+ const Private * m_d;
+ Private * const m_d_owned;
+ Q_PROPERTY(QString generated_password READ generated_password NOTIFY generated_passwordChanged FINAL)
+ Q_PROPERTY(quint8 generator_state READ generator_state NOTIFY generator_stateChanged FINAL)
+ Q_PROPERTY(bool i_say_sexy_things_to_myself_while_im_dancing READ i_say_sexy_things_to_myself_while_im_dancing WRITE setI_say_sexy_things_to_myself_while_im_dancing NOTIFY i_say_sexy_things_to_myself_while_im_dancingChanged FINAL)
+ Q_PROPERTY(QString master_password READ master_password WRITE setMaster_password NOTIFY master_passwordChanged FINAL)
+ Q_PROPERTY(Profiles* profiles READ profiles NOTIFY profilesChanged FINAL)
+ Q_PROPERTY(Settings* settings READ settings NOTIFY settingsChanged FINAL)
+ Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged FINAL)
+ Q_PROPERTY(QString used_text READ used_text WRITE setUsed_text NOTIFY used_textChanged FINAL)
+ explicit PasswordMaker(bool owned, QObject *parent);
+public:
+ explicit PasswordMaker(QObject *parent = nullptr);
+ ~PasswordMaker();
+ QString generated_password() const;
+ quint8 generator_state() const;
+ bool i_say_sexy_things_to_myself_while_im_dancing() const;
+ void setI_say_sexy_things_to_myself_while_im_dancing(bool v);
+ QString master_password() const;
+ void setMaster_password(const QString& v);
+ const Profiles* profiles() const;
+ Profiles* profiles();
+ const Settings* settings() const;
+ Settings* settings();
+ QString url() const;
+ void setUrl(const QString& v);
+ QString used_text() const;
+ void setUsed_text(const QString& v);
+ Q_INVOKABLE void profile_changed() const;
+ Q_INVOKABLE bool store_settings() const;
+Q_SIGNALS:
+ void generated_passwordChanged();
+ void generator_stateChanged();
+ void i_say_sexy_things_to_myself_while_im_dancingChanged();
+ void master_passwordChanged();
+ void profilesChanged();
+ void settingsChanged();
+ void urlChanged();
+ void used_textChanged();
+};
+
+class Profiles : public QAbstractItemModel
+{
+ Q_OBJECT
+ friend class PasswordMaker;
+public:
+ class Private;
+private:
+ const Private * m_d;
+ Private * const m_d_owned;
+ Q_PROPERTY(quint32 current_profile READ current_profile WRITE setCurrent_profile NOTIFY current_profileChanged FINAL)
+ Q_PROPERTY(QString current_profile_name READ current_profile_name NOTIFY current_profile_nameChanged FINAL)
+ explicit Profiles(bool owned, QObject *parent);
+public:
+ explicit Profiles(QObject *parent = nullptr);
+ ~Profiles();
+ quint32 current_profile() const;
+ void setCurrent_profile(quint32 v);
+ QString current_profile_name() const;
+ Q_INVOKABLE bool store() const;
+
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ bool canFetchMore(const QModelIndex &parent) const override;
+ void fetchMore(const QModelIndex &parent) override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
+ int role(const char* name) const;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
+ Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
+ Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+ Q_INVOKABLE QString characters(int row) const;
+ Q_INVOKABLE bool setCharacters(int row, const QString& value);
+ Q_INVOKABLE quint8 hash_algorithm(int row) const;
+ Q_INVOKABLE bool setHash_algorithm(int row, quint8 value);
+ Q_INVOKABLE quint8 leet_level(int row) const;
+ Q_INVOKABLE bool setLeet_level(int row, quint8 value);
+ Q_INVOKABLE QString modifier(int row) const;
+ Q_INVOKABLE bool setModifier(int row, const QString& value);
+ Q_INVOKABLE QString name(int row) const;
+ Q_INVOKABLE bool setName(int row, const QString& value);
+ Q_INVOKABLE quint32 password_length(int row) const;
+ Q_INVOKABLE bool setPassword_length(int row, quint32 value);
+ Q_INVOKABLE QString prefix(int row) const;
+ Q_INVOKABLE bool setPrefix(int row, const QString& value);
+ Q_INVOKABLE QString suffix(int row) const;
+ Q_INVOKABLE bool setSuffix(int row, const QString& value);
+ Q_INVOKABLE bool use_domain(int row) const;
+ Q_INVOKABLE bool setUse_domain(int row, bool value);
+ Q_INVOKABLE quint8 use_leet(int row) const;
+ Q_INVOKABLE bool setUse_leet(int row, quint8 value);
+ Q_INVOKABLE bool use_port_path(int row) const;
+ Q_INVOKABLE bool setUse_port_path(int row, bool value);
+ Q_INVOKABLE bool use_protocol(int row) const;
+ Q_INVOKABLE bool setUse_protocol(int row, bool value);
+ Q_INVOKABLE bool use_subdomains(int row) const;
+ Q_INVOKABLE bool setUse_subdomains(int row, bool value);
+ Q_INVOKABLE bool use_undefined_as_protocol_fallback(int row) const;
+ Q_INVOKABLE bool setUse_undefined_as_protocol_fallback(int row, bool value);
+ Q_INVOKABLE bool use_user_info(int row) const;
+ Q_INVOKABLE bool setUse_user_info(int row, bool value);
+ Q_INVOKABLE QString username(int row) const;
+ Q_INVOKABLE bool setUsername(int row, const QString& value);
+
+Q_SIGNALS:
+ // new data is ready to be made available to the model with fetchMore()
+ // the passed QVariant contains a quintptr which is the internal id.
+ // This is the same index that the fetch_more function typically expects on the Rust side.
+ // Previously this Signal sent a QModelIndex, but that was changed due to threading issues.
+ // If you need to create a QModelIndex from the internal id, you can expose the profiles_row() method
+ // on the underlying Rust object as a function and use it. Just beware that this Signal is
+ // typically sent from arbitrary threads, so compute the index at the Slot side.
+ // While speaking of threads: Make sure the internal ID of your model entries is stable.
+ // If it can change, it's up to you to ensure that it does not do so between sending this
+ // signal and receiving the corresponding fetchMore() call on the other side of the Connection.
+ void newDataReady(const QVariant &parent) const;
+private:
+ QHash<QPair<int,Qt::ItemDataRole>, QVariant> m_headerData;
+ void initHeaderData();
+ void updatePersistentIndexes();
+Q_SIGNALS:
+ void current_profileChanged();
+ void current_profile_nameChanged();
+};
+
+class Settings : public QObject
+{
+ Q_OBJECT
+ friend class PasswordMaker;
+public:
+ class Private;
+private:
+ const Private * m_d;
+ Private * const m_d_owned;
+ Q_PROPERTY(QVariant clear_generated_password_seconds READ clear_generated_password_seconds WRITE setClear_generated_password_seconds NOTIFY clear_generated_password_secondsChanged FINAL)
+ Q_PROPERTY(QVariant clear_master_password_seconds READ clear_master_password_seconds WRITE setClear_master_password_seconds NOTIFY clear_master_password_secondsChanged FINAL)
+ Q_PROPERTY(bool hide_generated_password READ hide_generated_password WRITE setHide_generated_password NOTIFY hide_generated_passwordChanged FINAL)
+ explicit Settings(bool owned, QObject *parent);
+public:
+ explicit Settings(QObject *parent = nullptr);
+ ~Settings();
+ QVariant clear_generated_password_seconds() const;
+ void setClear_generated_password_seconds(const QVariant& v);
+ QVariant clear_master_password_seconds() const;
+ void setClear_master_password_seconds(const QVariant& v);
+ bool hide_generated_password() const;
+ void setHide_generated_password(bool v);
+Q_SIGNALS:
+ void clear_generated_password_secondsChanged();
+ void clear_master_password_secondsChanged();
+ void hide_generated_passwordChanged();
+};
+#endif // BINDINGS_H
diff --git a/src/GraphemeCountValidator.cpp b/src/GraphemeCountValidator.cpp
new file mode 100644
index 0000000..9fc6436
--- /dev/null
+++ b/src/GraphemeCountValidator.cpp
@@ -0,0 +1,42 @@
+#include "GraphemeCountValidator.h"
+#include <QTextBoundaryFinder>
+
+GraphemeCountValidator::GraphemeCountValidator(QObject *parent)
+ : GraphemeCountValidator(0, parent)
+{}
+
+GraphemeCountValidator::GraphemeCountValidator(uint min_count, QObject *parent)
+ : QValidator(parent)
+ , minCount(min_count)
+{}
+
+uint GraphemeCountValidator::minGraphemeCount() const
+{
+ return minCount;
+}
+
+void GraphemeCountValidator::setMinGraphemeCount(uint c)
+{
+ if(minCount != c)
+ {
+ minCount = c;
+ emit minGraphemeCountChanged(minCount);
+ emit changed();
+ }
+}
+
+QValidator::State GraphemeCountValidator::validate(QString & text, int&) const
+{
+ //One could write Rust FFI bindings and do this in Rust.
+ //But that would be way more work for no gain.
+ QTextBoundaryFinder boundsFinder{
+ QTextBoundaryFinder::BoundaryType::Grapheme,
+ text
+ };
+ int requiredBoundary = 0;
+ for(uint i = 0; i < minCount; ++i)
+ requiredBoundary = boundsFinder.toNextBoundary();
+ return requiredBoundary >= 0
+ ? QValidator::State::Acceptable
+ : QValidator::State::Intermediate;
+}
diff --git a/src/GraphemeCountValidator.h b/src/GraphemeCountValidator.h
new file mode 100644
index 0000000..e2a5dc7
--- /dev/null
+++ b/src/GraphemeCountValidator.h
@@ -0,0 +1,26 @@
+#ifndef GRAPHEMECOUNTVALIDATOR_H
+#define GRAPHEMECOUNTVALIDATOR_H
+
+#include <QValidator>
+
+class Q_GUI_EXPORT GraphemeCountValidator : public QValidator
+{
+ Q_OBJECT
+ Q_PROPERTY(uint minGraphemeCount READ minGraphemeCount WRITE setMinGraphemeCount NOTIFY minGraphemeCountChanged)
+public:
+ explicit GraphemeCountValidator(QObject *parent = nullptr);
+ explicit GraphemeCountValidator(uint min_count, QObject *parent = nullptr);
+ virtual QValidator::State validate(QString &, int &) const override;
+
+ uint minGraphemeCount() const;
+ void setMinGraphemeCount(uint c);
+
+
+Q_SIGNALS:
+ void minGraphemeCountChanged(uint minGraphemeCount);
+
+private:
+ uint minCount;
+};
+
+#endif // GRAPHEMECOUNTVALIDATOR_H
diff --git a/src/PassFish.cpp b/src/PassFish.cpp
new file mode 100644
index 0000000..80eef2a
--- /dev/null
+++ b/src/PassFish.cpp
@@ -0,0 +1,28 @@
+#include <QtQuick>
+#include <sailfishapp.h>
+#include <stdio.h>
+#include "Bindings.h"
+#include "GraphemeCountValidator.h"
+
+Q_DECL_EXPORT int main(int argc, char *argv[])
+{
+ QScopedPointer<QGuiApplication> app{SailfishApp::application(argc,argv)};
+ QScopedPointer<QQuickView> view{SailfishApp::createView()};
+
+ qmlRegisterType<GraphemeCountValidator>("PWM", 1, 0, "GraphemeCountValidator");
+
+ PasswordMaker maker;
+ view->rootContext()->setContextProperty("passwordmaker",&maker);
+ QObject::connect(&maker,
+ &PasswordMaker::i_say_sexy_things_to_myself_while_im_dancingChanged,
+ &maker,
+ [&]() {maker.setI_say_sexy_things_to_myself_while_im_dancing(true);},
+ (Qt::ConnectionType)(Qt::AutoConnection | Qt::UniqueConnection)
+ );
+
+ view->setSource(SailfishApp::pathTo(QString("qml/PassFish.qml")));
+ view->show();
+
+ return app->exec();
+}
+
diff --git a/src/pwm_qhash.cpp b/src/pwm_qhash.cpp
new file mode 100644
index 0000000..f9528d4
--- /dev/null
+++ b/src/pwm_qhash.cpp
@@ -0,0 +1,22 @@
+#include <QCryptographicHash>
+
+extern "C" {
+ /**
+ * Forwards the call to QCryptographicHash::hash() and copies the output into the provided buffer.
+ * Returns zero on error (unsupported hash type or insufficient output_capacity). Number of written output bytes otherwise.
+ */
+ Q_DECL_EXPORT size_t pwm_qhash(size_t algorithm, const unsigned char * input, size_t input_length, unsigned char * output, size_t output_capacity)
+ {
+ if(algorithm > 6)
+ return 0; //failed.
+ const auto algo{static_cast<QCryptographicHash::Algorithm>(algorithm)};
+ QCryptographicHash hasher{algo};
+ hasher.addData(reinterpret_cast<const char *>(input), input_length);
+ const auto hash{hasher.result()};
+ const auto count_as_size{static_cast<size_t>(hash.length())};
+ if(count_as_size > output_capacity)
+ return 0;
+ memcpy(output,hash.constData(),count_as_size);
+ return count_as_size;
+ }
+}