add import identity option

This commit is contained in:
yggverse 2024-11-21 12:40:11 +02:00
parent 896fdc6a1a
commit 83d474a192
3 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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),
}

View File

@ -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,
}