Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Move INSTALL, LICENSE, README, THANKS and TODO into root directory
[xestiaab/.git] / source / frmMain.mm
1 // frmMain.mm - OS X specific functions for frmMain
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #import <Foundation/Foundation.h>
20 #import <SecurityInterface/SFCertificatePanel.h>
22 #include "frmMain.h"
24 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SecTrustRef SecurityTrustObject){
25     
26         // Delete existing data.
27     
28         AccountTrustData.erase(AccountID);
29         AccountSSLResult.erase(AccountID);
30     
31         // Insert new data.
32     
33         AccountTrustData.insert(std::make_pair(AccountID, SecurityTrustObject));
34         AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
35     
36 }
38 void frmMain::DisplayCertificate(SecTrustRef SecurityTrustObject){
39         
40         SFCertificatePanel *SecCertPanel = [[SFCertificatePanel alloc] init];
41         
42         [SecCertPanel setParentWindow:(NSWindow*)this->GetHandle()];
43         [SecCertPanel setDefaultButtonTitle:@"Close"];
44         
45         [SecCertPanel runModalForTrust:SecurityTrustObject showGroup:YES];
46         
47 }
49 void frmMain::DisplayTrustPanel( wxCommandEvent &event ){
50         
51         SSLInvalidTrustNotifObj *SSLITNObj = (SSLInvalidTrustNotifObj*)event.GetClientData();
52         
53         NSInteger ResultValue;
54         
55         SFCertificateTrustPanel *secpanel = [SFCertificateTrustPanel sharedCertificateTrustPanel];
56         
57         [secpanel setDefaultButtonTitle:@"Accept"];
58         [secpanel setAlternateButtonTitle:@"Cancel"];
59         [secpanel setInformativeText: @"This certificate is not trusted. Someone could be trying to eavesdrop on your connection. Do you want to accept this certificate anyway?\n\nAccept and trusting the certificate will fetch and process information as required.\nCancel will close the connection."];
60         [secpanel setShowsHelp:YES];
61         
62         [secpanel setParentWindow:(NSWindow*)this->GetHandle()];
63         
64         ResultValue = [secpanel runModalForTrust:SSLITNObj->SecurityTrustObject message:@"Certificate not trusted"];
66         *SSLITNObj->ResultValue = (int)ResultValue;
67         *SSLITNObj->PausePtr = FALSE;
68         
69 }
71 void frmMain::DisplayHelpBrowser()
72 {
73         /* Replace with modern API when deployment target is 10.13+ in the future */
74         
75         /* Replace with NSWorkspace */
76         
77         NSString *language = [[NSLocale currentLocale] localeIdentifier];
78         NSString *documentationFilename = [NSString stringWithFormat:@"Documentation (%@)", language];
79         NSString *helpBrowserDocumentationPath = [[NSBundle mainBundle] pathForResource:documentationFilename ofType:@"fodt"];
80         
81         if (helpBrowserDocumentationPath == nil)
82         {
83                 helpBrowserDocumentationPath = [[NSBundle mainBundle] pathForResource:@"Documentation (en_GB)" ofType:@"fodt"];
84         }
85         
86         NSURL *helpBrowserExecutableURL = [[NSBundle mainBundle] URLForResource:@"ODTHelpBrowser" withExtension:@"app"];
88         NSArray *args = [NSArray arrayWithObjects:@"-d", helpBrowserDocumentationPath, nil];
89         NSDictionary *helpBrowserArguments = [NSDictionary dictionaryWithObject:args
90                                                             forKey:NSWorkspaceLaunchConfigurationArguments];
91         
92         helpBrowserProcess = [[NSWorkspace sharedWorkspace] launchApplicationAtURL:helpBrowserExecutableURL options:NSWorkspaceLaunchAndHide configuration:helpBrowserArguments error: nil];
93         
94         [helpBrowserProcess activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
95 }
97 void frmMain::TerminateHelpBrowserProcess()
98 {
99         if (helpBrowserProcess != nil)
100         {
101                 [helpBrowserProcess terminate];
102         }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy