summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.c33
-rw-r--r--src/app.h1
-rw-r--r--src/gmcerts.c22
-rw-r--r--src/gmcerts.h2
-rw-r--r--src/ui/sidebarwidget.c5
5 files changed, 60 insertions, 3 deletions
diff --git a/src/app.c b/src/app.c
index 78aae9a9..b8909306 100644
--- a/src/app.c
+++ b/src/app.c
@@ -812,3 +812,36 @@ void openInDefaultBrowser_App(const iString *url) {
812 start_Process(proc); 812 start_Process(proc);
813 iRelease(proc); 813 iRelease(proc);
814} 814}
815
816void revealPath_App(const iString *path) {
817#if defined (iPlatformApple)
818 const char *scriptPath = concatPath_CStr(dataDir_App_, "revealfile.scpt");
819 iFile *f = newCStr_File(scriptPath);
820 if (open_File(f, writeOnly_FileMode | text_FileMode)) {
821 /* AppleScript to select a specific file. */
822 write_File(f, collect_Block(newCStr_Block("on run argv\n"
823 " tell application \"Finder\"\n"
824 " activate\n"
825 " reveal POSIX file (item 1 of argv) as text\n"
826 " end tell\n"
827 "end run\n")));
828 close_File(f);
829 iProcess *proc = new_Process();
830 setArguments_Process(
831 proc,
832 iClob(newStringsCStr_StringList(
833 "/usr/bin/osascript", scriptPath, cstr_String(path), NULL)));
834 start_Process(proc);
835 iRelease(proc);
836 }
837 iRelease(f);
838#elif defined (iPlatformLinux)
839 {
840 String path = (fileOrFolder.isDirectory() ? fileOrFolder.toString()
841 : fileOrFolder.fileNamePath().toString());
842 CommandLine({"/usr/bin/xdg-open", path}).execute();
843 }
844#else
845 iAssert(0 /* File revealing not implemented on this platform */);
846#endif
847}
diff --git a/src/app.h b/src/app.h
index 1a6b7fe5..09c60c0f 100644
--- a/src/app.h
+++ b/src/app.h
@@ -76,3 +76,4 @@ iLocalDef void postCommandString_App(const iString *command) {
76} 76}
77 77
78void openInDefaultBrowser_App (const iString *url); 78void openInDefaultBrowser_App (const iString *url);
79void revealPath_App (const iString *path);
diff --git a/src/gmcerts.c b/src/gmcerts.c
index 3c10fff2..09728414 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -448,11 +448,18 @@ iGmIdentity *newIdentity_GmCerts(iGmCerts *d, int flags, iDate validUntil, const
448 return id; 448 return id;
449} 449}
450 450
451void deleteIdentity_GmCerts(iGmCerts *d, iGmIdentity *identity) { 451static const char *certPath_GmCerts_(const iGmCerts *d, const iGmIdentity *identity) {
452 /* Only delete the files if we created them. */
453 if (!(identity->flags & (temporary_GmIdentityFlag | imported_GmIdentityFlag))) { 452 if (!(identity->flags & (temporary_GmIdentityFlag | imported_GmIdentityFlag))) {
454 const char *finger = cstrCollect_String(hexEncode_Block(&identity->fingerprint)); 453 const char *finger = cstrCollect_String(hexEncode_Block(&identity->fingerprint));
455 const char *filename = concatPath_CStr(cstr_String(&d->saveDir), format_CStr("idents/%s", finger)); 454 return concatPath_CStr(cstr_String(&d->saveDir), format_CStr("idents/%s", finger));
455 }
456 return NULL;
457}
458
459void deleteIdentity_GmCerts(iGmCerts *d, iGmIdentity *identity) {
460 /* Only delete the files if we created them. */
461 const char *filename = certPath_GmCerts_(d, identity);
462 if (filename) {
456 remove(format_CStr("%s.crt", filename)); 463 remove(format_CStr("%s.crt", filename));
457 remove(format_CStr("%s.key", filename)); 464 remove(format_CStr("%s.key", filename));
458 } 465 }
@@ -460,6 +467,15 @@ void deleteIdentity_GmCerts(iGmCerts *d, iGmIdentity *identity) {
460 collect_GmIdentity(identity); 467 collect_GmIdentity(identity);
461} 468}
462 469
470const iString *certificatePath_GmCerts(const iGmCerts *d, const iGmIdentity *identity) {
471 const char *filename = certPath_GmCerts_(d, identity);
472 if (filename) {
473 return collectNewFormat_String("%s.crt", filename);
474 }
475 return NULL;
476}
477
463const iPtrArray *identities_GmCerts(const iGmCerts *d) { 478const iPtrArray *identities_GmCerts(const iGmCerts *d) {
464 return &d->idents; 479 return &d->idents;
465} 480}
481
diff --git a/src/gmcerts.h b/src/gmcerts.h
index 37419b9e..db1a6200 100644
--- a/src/gmcerts.h
+++ b/src/gmcerts.h
@@ -75,6 +75,8 @@ iGmIdentity * newIdentity_GmCerts (iGmCerts *, int flags, iDate validU
75 75
76void deleteIdentity_GmCerts (iGmCerts *, iGmIdentity *identity); 76void deleteIdentity_GmCerts (iGmCerts *, iGmIdentity *identity);
77 77
78const iString * certificatePath_GmCerts (const iGmCerts *, const iGmIdentity *identity);
79
78iGmIdentity * identity_GmCerts (iGmCerts *, unsigned int id); 80iGmIdentity * identity_GmCerts (iGmCerts *, unsigned int id);
79const iGmIdentity * constIdentity_GmCerts (const iGmCerts *, unsigned int id); 81const iGmIdentity * constIdentity_GmCerts (const iGmCerts *, unsigned int id);
80const iGmIdentity * identityForUrl_GmCerts (const iGmCerts *, const iString *url); 82const iGmIdentity * identityForUrl_GmCerts (const iGmCerts *, const iString *url);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 19886964..25fa3f6a 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -635,6 +635,11 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
635 return iTrue; 635 return iTrue;
636 } 636 }
637 else if (isCommand_Widget(w, ev, "ident.reveal")) { 637 else if (isCommand_Widget(w, ev, "ident.reveal")) {
638 const iString *crtPath =
639 certificatePath_GmCerts(certs_App(), constHoverIdentity_SidebarWidget_(d));
640 if (crtPath) {
641 revealPath_App(crtPath);
642 }
638 return iTrue; 643 return iTrue;
639 } 644 }
640 else if (equal_Command(cmd, "ident.delete")) { 645 else if (equal_Command(cmd, "ident.delete")) {