Package: system-config-printer / 1.5.11-4

define-classes-for-Secret-only-when-libsecret-is-installe.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Thu, 30 Aug 2018 11:52:48 +0200
Subject: 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 16b2030..86f5fea 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: