system-config-printer/0001-define-classes-for-Secret-only-when-libsecret-is-ins.patch
2018-10-15 17:39:39 +02:00

149 lines
5.7 KiB
Diff

From 42d95b7560c26f0fdf3b4f46823843861948c136 Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Thu, 30 Aug 2018 11:52:48 +0200
Subject: [PATCH] define classes for Secret only when libsecret is installed
(https://github.com/zdohnal/system-config-printer/issues/118,
https://github.com/zdohnal/system-config-printer/issues/115)
---
jobviewer.py | 123 ++++++++++++++++++++++++++-------------------------
1 file changed, 62 insertions(+), 61 deletions(-)
diff --git a/jobviewer.py b/jobviewer.py
index 16b20300..86f5feaf 100644
--- a/jobviewer.py
+++ b/jobviewer.py
@@ -73,67 +73,68 @@ SEARCHING_ICON="document-print-preview"
# We need to call Notify.init before we can check the server for caps
Notify.init('System Config Printer Notification')
-NETWORK_PASSWORD = Secret.Schema.new("org.system.config.printer.store", Secret.SchemaFlags.NONE,
- {
- "user": Secret.SchemaAttributeType.STRING,
- "domain": Secret.SchemaAttributeType.STRING,
- "object": Secret.SchemaAttributeType.STRING,
- "protocol": Secret.SchemaAttributeType.STRING,
- "port": Secret.SchemaAttributeType.INTEGER,
- "server": Secret.SchemaAttributeType.STRING,
- "authtype": Secret.SchemaAttributeType.STRING,
- "uri": Secret.SchemaAttributeType.STRING,
- }
- )
-
-
-class ServiceGet:
- service = Secret.Service()
-
- def on_get_service(self, source, result, unused):
- service = Secret.Service.get_finish(result)
-
- def __init__(self):
- Secret.Service.get(0,
- None,
- self.on_get_service,
- None)
-
- def get_service(self):
- return ServiceGet.service
-
-
-class ItemSearch:
- items = list()
-
- def on_search_item(self, source, result, unused):
- items = Secret.Service.search_finish(None, result)
-
- def __init__(self, service, attrs):
- Secret.Service.search(service,
- NETWORK_PASSWORD,
- attrs,
- Secret.SearchFlags.LOAD_SECRETS,
- None,
- self.on_search_item,
- None)
-
- def get_items(self):
- return ItemSearch.items
-
-
-class PasswordStore:
- def __init__(self, attrs, name, secret):
- Secret.password_store(NETWORK_PASSWORD,
- attrs,
- Secret.COLLECTION_DEFAULT,
- name,
- secret,
- None,
- self.on_password_stored)
-
- def on_password_stored(self, source, result, unused):
- Secret.password_store_finish(result)
+if USE_SECRET:
+ NETWORK_PASSWORD = Secret.Schema.new("org.system.config.printer.store", Secret.SchemaFlags.NONE,
+ {
+ "user": Secret.SchemaAttributeType.STRING,
+ "domain": Secret.SchemaAttributeType.STRING,
+ "object": Secret.SchemaAttributeType.STRING,
+ "protocol": Secret.SchemaAttributeType.STRING,
+ "port": Secret.SchemaAttributeType.INTEGER,
+ "server": Secret.SchemaAttributeType.STRING,
+ "authtype": Secret.SchemaAttributeType.STRING,
+ "uri": Secret.SchemaAttributeType.STRING,
+ }
+ )
+
+
+ class ServiceGet:
+ service = Secret.Service()
+
+ def on_get_service(self, source, result, unused):
+ service = Secret.Service.get_finish(result)
+
+ def __init__(self):
+ Secret.Service.get(0,
+ None,
+ self.on_get_service,
+ None)
+
+ def get_service(self):
+ return ServiceGet.service
+
+
+ class ItemSearch:
+ items = list()
+
+ def on_search_item(self, source, result, unused):
+ items = Secret.Service.search_finish(None, result)
+
+ def __init__(self, service, attrs):
+ Secret.Service.search(service,
+ NETWORK_PASSWORD,
+ attrs,
+ Secret.SearchFlags.LOAD_SECRETS,
+ None,
+ self.on_search_item,
+ None)
+
+ def get_items(self):
+ return ItemSearch.items
+
+
+ class PasswordStore:
+ def __init__(self, attrs, name, secret):
+ Secret.password_store(NETWORK_PASSWORD,
+ attrs,
+ Secret.COLLECTION_DEFAULT,
+ name,
+ secret,
+ None,
+ self.on_password_stored)
+
+ def on_password_stored(self, source, result, unused):
+ Secret.password_store_finish(result)
class PrinterURIIndex:
--
2.17.2