File: rc_export.cpp

package info (click to toggle)
fwknop-gui 1.3%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 504 kB
  • ctags: 241
  • sloc: cpp: 2,116; xml: 27; makefile: 3
file content (124 lines) | stat: -rw-r--r-- 4,726 bytes parent folder | 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
/* rc_export.cpp
 * Copyright (C) 2016  Jonathan Bennett
 * RC export class
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include "rc_export.h"

rc_export::rc_export(const wxString & title, const Config *selectedConfig)
       : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(900, 330))
{
    wxString configBuf = wxT("");
    wxPanel *panel = new wxPanel(this, -1);

    wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
    //wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
//    hbox->Add(okButton, 1);
//    hbox->Add(copyButton, 1);

    tc = new wxTextCtrl(panel, -1, wxT(""),
      wxPoint(15, 80), wxSize(875, 200), wxTE_MULTILINE | wxTE_READONLY);
    tc->SetFont(wxFont(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));

    configBuf = wxT("[");
    configBuf.Append(selectedConfig->NICK_NAME);
    configBuf.Append(wxT("]"));
    configBuf.Append(wxT("\nSPA_SERVER          "));
    configBuf.Append(selectedConfig->SERVER_IP);
    if (selectedConfig->LEGACY)
        configBuf.Append(wxT("\nENCRYPTION_MODE     legacy"));

    if (selectedConfig->SERVER_PORT.CmpNoCase(_("random")) == 0) {
        configBuf.Append(wxT("\nRAND_PORT           Y"));
    } else {
        configBuf.Append(wxT("\nSPA_SERVER_PORT     "));
        configBuf.Append(selectedConfig->SERVER_PORT);
    }
    configBuf.Append(wxT("\nSPA_SERVER_PROTO    "));
    configBuf.Append(selectedConfig->PROTOCOL);
    configBuf.Append(wxT("\nDIGEST_TYPE         "));
    configBuf.Append(selectedConfig->DIGEST_TYPE);
    configBuf.Append(wxT("\nHMAC_DIGEST_TYPE    "));
    configBuf.Append(selectedConfig->HMAC_TYPE);

    if (!selectedConfig->HMAC.IsEmpty()) {
        configBuf.Append(wxT("\nUSE_HMAC            Y"));
        if (selectedConfig->HMAC_BASE64)
            configBuf.Append(wxT("\nHMAC_KEY_BASE64     "));
        else
            configBuf.Append(wxT("\nHMAC_KEY            "));
        configBuf.Append(selectedConfig->HMAC);
    }

    if (!selectedConfig->KEY.IsEmpty()) {
        if (selectedConfig->KEY_BASE64)
            configBuf.Append(wxT("\nKEY_BASE64          "));
        else
            configBuf.Append(wxT("\nKEY                 "));
        configBuf.Append(selectedConfig->KEY);
    }

    if (selectedConfig->MESS_TYPE.CmpNoCase(_("Server Command")) == 0) { // fwknoprc seems not to have support for server commands

    } else if (selectedConfig->MESS_TYPE.CmpNoCase(_("Open Port")) == 0) {
        configBuf.Append(wxT("\nACCESS              "));
        configBuf.Append(selectedConfig->PORTS);
        if(!selectedConfig->SERVER_TIMEOUT.IsEmpty()) {
            configBuf.Append(wxT("\nCLIENT_TIMEOUT      "));
            configBuf.Append(selectedConfig->SERVER_TIMEOUT);
        }
    } else if (selectedConfig->MESS_TYPE.CmpNoCase(_("Nat Access")) == 0) {
        configBuf.Append(wxT("\nACCESS              "));
        configBuf.Append(selectedConfig->PORTS);
        configBuf.Append(wxT("\nNAT_ACCESS          "));
        configBuf.Append(selectedConfig->NAT_IP);
        configBuf.Append(wxT(","));
        configBuf.Append(selectedConfig->NAT_PORT);

        if(!selectedConfig->SERVER_TIMEOUT.IsEmpty()) {
            configBuf.Append(wxT("\nCLIENT_TIMEOUT      "));
            configBuf.Append(selectedConfig->SERVER_TIMEOUT);
        }
    }  else if (selectedConfig->MESS_TYPE.CmpNoCase(_("Local Nat Access")) == 0) {
        configBuf.Append(wxT("\nACCESS              "));
        configBuf.Append(selectedConfig->PORTS);
        configBuf.Append(wxT("\nNAT_LOCAL           Y"));
        configBuf.Append(wxT("\nNAT_PORT            "));
        configBuf.Append(selectedConfig->NAT_PORT);

        if(!selectedConfig->SERVER_TIMEOUT.IsEmpty()) {
            configBuf.Append(wxT("\nCLIENT_TIMEOUT      "));
            configBuf.Append(selectedConfig->SERVER_TIMEOUT);
        }
    }



    tc->ChangeValue(configBuf);
    vbox->Add(panel, 1);
    //vbox->Add(hbox, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);

    SetSizer(vbox);



    Centre();

    ShowModal();

    Destroy();
}