summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-02-09 22:16:16 +0100
committerSebastian Reichel <sre@ring0.de>2013-02-09 22:16:16 +0100
commit53372774d71b5fa937470812b5345b6cb046f350 (patch)
tree8c5b8f2effcfdbfc8bace09bb3e37e06c7f6919c
parente6468b3514d51256259cc20d2bea3bb4edb67ff5 (diff)
downloadserial-barcode-scanner-53372774d71b5fa937470812b5345b6cb046f350.tar.bz2
implement import_archive()
-rw-r--r--src/admin.vala19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/admin.vala b/src/admin.vala
index c37c761..de123e1 100644
--- a/src/admin.vala
+++ b/src/admin.vala
@@ -106,7 +106,8 @@ public class PGPKeyArchive {
gpg.set_armor(true);
}
- public void read() {
+ public string[] import_archive(uint8[] data) {
+ string[] result = {};
unowned Archive.Entry entry;
var archive = new Archive.Read();
@@ -115,9 +116,8 @@ public class PGPKeyArchive {
archive.support_format_all();
/* load test archive for now */
- /* TODO: use archive.open_memory(void *buffer, size_t size) */
- if(archive.open_filename("pgp-test.tar.gz", 4096) != Archive.Result.OK)
- return;
+ if(archive.open_memory(data, data.length) != Archive.Result.OK)
+ return result;
while(archive.next_header(out entry) == Archive.Result.OK) {
var name = entry.pathname();
@@ -142,8 +142,19 @@ public class PGPKeyArchive {
/* import keys */
gpg.op_import(gpgdata);
+
+ /* get result */
+ unowned GPG.ImportResult importresult = gpg.op_import_result();
+
+ /* add imported fingerprints to result */
+ for(unowned GPG.ImportStatus st = importresult.imports; st != null; st = st.next) {
+ if(!(st.fpr in result) && (st.status & GPG.ImportStatusFlags.NEW) != 0)
+ result += st.fpr;
+ }
}
}
+
+ return result;
}
public string[] list_keys() {