From 83d474a1924cec8f67227cc689711bc92272f8b0 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 21 Nov 2024 12:40:11 +0200 Subject: [PATCH] add import identity option --- src/app/browser/window/tab/item/identity/gemini.rs | 10 +++++++++- .../tab/item/identity/gemini/widget/form/list/item.rs | 5 ++++- .../identity/gemini/widget/form/list/item/value.rs | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/browser/window/tab/item/identity/gemini.rs b/src/app/browser/window/tab/item/identity/gemini.rs index 63214f53..b32e186e 100644 --- a/src/app/browser/window/tab/item/identity/gemini.rs +++ b/src/app/browser/window/tab/item/identity/gemini.rs @@ -43,8 +43,15 @@ impl Gemini { "Generate long-term certificate", ); + // Add import existing identity option + widget.form.list.append( + Value::IMPORT_PEM, + "Import identity", + "Use existing certificate", + ); + // Collect additional options from database - let mut i = 1; // start from 2'th + let mut i = 2; // start from 3'th match profile.identity.gemini.database.records() { Ok(identities) => { for identity in identities { @@ -118,6 +125,7 @@ impl Gemini { .create(None, &widget.form.name.value().unwrap()) .unwrap(), // @TODO handle result, ), + Value::IMPORT_PEM => Some(0), // @TODO }; // Apply diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs index 1a24c7c1..6ad863b3 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs @@ -11,7 +11,8 @@ glib::wrapper! { // C-type property `value` conversion for `Item` // * values > 0 reserved for `profile_identity_gemini_id` const G_VALUE_GENERATE_NEW_AUTH: i64 = 0; -const G_VALUE_USE_GUEST_SESSION: i64 = -1; +const G_VALUE_IMPORT_PEM: i64 = -1; +const G_VALUE_USE_GUEST_SESSION: i64 = -2; impl Item { // Constructors @@ -23,6 +24,7 @@ impl Item { "value", match value { Value::GENERATE_NEW_AUTH => G_VALUE_GENERATE_NEW_AUTH, + Value::IMPORT_PEM => G_VALUE_IMPORT_PEM, Value::USE_GUEST_SESSION => G_VALUE_USE_GUEST_SESSION, Value::PROFILE_IDENTITY_GEMINI_ID(value) => value, }, @@ -38,6 +40,7 @@ impl Item { pub fn value_enum(&self) -> Value { match self.value() { G_VALUE_GENERATE_NEW_AUTH => Value::GENERATE_NEW_AUTH, + G_VALUE_IMPORT_PEM => Value::IMPORT_PEM, G_VALUE_USE_GUEST_SESSION => Value::USE_GUEST_SESSION, value => Value::PROFILE_IDENTITY_GEMINI_ID(value), } diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs index 08552ce7..90a63ffa 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs @@ -1,6 +1,7 @@ #[derive(Debug)] pub enum Value { GENERATE_NEW_AUTH, - USE_GUEST_SESSION, + IMPORT_PEM, PROFILE_IDENTITY_GEMINI_ID(i64), + USE_GUEST_SESSION, }