Reactivate VPNC plugin

pull/1/head
Timothy Pearson 12 years ago
parent 441c9f0207
commit 2027fb3d61

@ -72,7 +72,7 @@ bool VPNConfigWidget::isValid(TQStringList& /*err_msg*/)
}
/******************************
* class VPNAuthentiactionWidget
* class VPNAuthenticationWidget
******************************/
VPNAuthenticationWidget::VPNAuthenticationWidget(TQWidget* parent, const char* name)

@ -25,6 +25,10 @@
#ifndef VPN_TRAY_COMPONENT_H
#define VPN_TRAY_COMPONENT_H
// TDE includes
#include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
// TDENM includes
#include "traycomponent.h"

@ -38,6 +38,6 @@ set( ${target}_SRCS
tde_add_kpart( ${target} AUTOMOC
SOURCES ${${target}_SRCS}
LINK tdeinit_kded-shared
LINK tdeinit_kded-shared tdeinit_tdenetworkmanager-shared
DESTINATION ${PLUGIN_INSTALL_DIR}
)

@ -44,7 +44,7 @@
using namespace std;
typedef KGenericFactory<VPNCPlugin> VPNCPluginFactory;
K_EXPORT_COMPONENT_FACTORY( knetworkmanager_vpnc, VPNCPluginFactory("knetworkmanager_vpnc"));
K_EXPORT_COMPONENT_FACTORY( tdenetman_vpnc, VPNCPluginFactory("tdenetman_vpnc"));
#define NAT_MODE_CISCO 0
#define NAT_MODE_NATT 1
@ -112,7 +112,7 @@ void VPNCConfig::languageChange()
}
int VPNCConfig::getFileConfig(char *parameter, char *line) {
int VPNCConfig::getFileConfig(const char *parameter, char *line) {
int i;
if (strstr(line, parameter) != NULL) {
@ -140,7 +140,6 @@ void VPNCConfig::pcfImport()
{
const TQString& pcf_file = TQString(_vpncWidget->editPCF->url());
printf("Asked for PCF import from file %s\n\r", pcf_file.ascii());
int i;
FILE *file = fopen ( pcf_file.ascii(), "r" );
if ( file != NULL ) {
@ -191,7 +190,9 @@ void VPNCConfig::pcfImport()
printf("Group password decrypt error\n\r");
}
else {
fgets(decrypted_result, 2048, pipe_decrypt);
if (fgets(decrypted_result, 2048, pipe_decrypt) == NULL) {
printf("Error reading from decryption program\n\r");
}
pclose(pipe_decrypt);
for (i=0;i<2048;i++) {
if (decrypted_result[i] == 0) {
@ -214,11 +215,13 @@ void VPNCConfig::pcfImport()
}
}
void VPNCConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties)
void VPNCConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
{
m_vpnProperties = properties;
m_vpnSecrets = secrets;
// fill up our inputfields (only textfields atm)
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
{
for (TDENetworkSettingsMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) {
TQString entry = it.key();
TQString value = it.data();
@ -273,56 +276,86 @@ void VPNCConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQ
if (!routes.empty())
{
_vpncWidget->chkIPAdresses->setChecked(true);
_vpncWidget->routes->setText(routes.join(" "));
TQStringList routesText;
for (TDENetworkSingleRouteConfigurationList::Iterator it = routes.begin(); it != routes.end(); ++it) {
routesText.append(TQString("%1/%2").arg((*it).ipAddress.toString()).arg((*it).networkMask.toCIDRMask()));
}
_vpncWidget->routes->setText(routesText.join(" "));
}
}
TQMap<TQString, TQString> VPNCConfig::getVPNProperties()
{
// build a StingList of properties
TQMap<TQString, TQString> strlist;
strlist.insert("IPSec gateway", TQString(_vpncWidget->IPSec_gateway->text()));
strlist.insert("IPSec ID", TQString(_vpncWidget->IPSec_ID->text()));
TDENetworkSettingsMap VPNCConfig::getVPNProperties() {
// Build a list of properties
m_vpnProperties.insert("IPSec gateway", TQString(_vpncWidget->IPSec_gateway->text()));
m_vpnProperties.insert("IPSec ID", TQString(_vpncWidget->IPSec_ID->text()));
//if (_vpncWidget->chkOverrideUsername->isChecked())
strlist.insert("Xauth username", TQString(_vpncWidget->Xauth_username->text()));
// if (_vpncWidget->chkOverrideUsername->isChecked()) {
m_vpnProperties.insert("Xauth username", TQString(_vpncWidget->Xauth_username->text()));
// }
if (_vpncWidget->chkUseDomain->isChecked())
strlist.insert("Domain", TQString(_vpncWidget->Domain->text()));
if (_vpncWidget->chkUseDomain->isChecked()) {
m_vpnProperties.insert("Domain", TQString(_vpncWidget->Domain->text()));
}
else {
m_vpnProperties.remove("Domain");
}
if (_vpncWidget->chkUseKeepAlive->isChecked())
strlist.insert("NAT-Keepalive packet interval", TQString(_vpncWidget->nat_keep_alive_interval->text()));
if (_vpncWidget->chkUseKeepAlive->isChecked()) {
m_vpnProperties.insert("NAT-Keepalive packet interval", TQString(_vpncWidget->nat_keep_alive_interval->text()));
}
else {
m_vpnProperties.remove("NAT-Keepalive packet interval");
}
switch (_vpncWidget->cboNAT->currentItem())
{
switch (_vpncWidget->cboNAT->currentItem()) {
case NAT_MODE_CISCO:
strlist.insert("NAT Traversal Mode", "cisco-udp");
m_vpnProperties.insert("NAT Traversal Mode", "cisco-udp");
break;
case NAT_MODE_NATT:
strlist.insert("NAT Traversal Mode", "natt");
m_vpnProperties.insert("NAT Traversal Mode", "natt");
break;
case NAT_MODE_DISABLED:
default:
strlist.insert("NAT Traversal Mode", "none");
m_vpnProperties.insert("NAT Traversal Mode", "none");
break;
}
if (_vpncWidget->chkSingleDES->isChecked())
strlist.insert("Enable Single DES", "yes");
else
strlist.insert("Enable Single DES", "no");
if (_vpncWidget->chkSingleDES->isChecked()) {
m_vpnProperties.insert("Enable Single DES", "yes");
}
else {
m_vpnProperties.insert("Enable Single DES", "no");
}
return strlist;
return m_vpnProperties;
}
TQStringList VPNCConfig::getVPNRoutes()
TDENetworkSettingsMap VPNCConfig::getVPNSecrets() {
// Build a list of secrets
// FIXME
return m_vpnSecrets;
}
TDENetworkSingleRouteConfigurationList VPNCConfig::getVPNRoutes()
{
TDENetworkSingleRouteConfigurationList ret;
TQStringList strlist;
if(_vpncWidget->chkIPAdresses->isChecked())
{
if(_vpncWidget->chkIPAdresses->isChecked()) {
strlist = TQStringList::split(" ", _vpncWidget->routes->text());
}
return strlist;
for (TQStringList::Iterator it = strlist.begin(); it != strlist.end(); ++it) {
TQStringList pieces = TQStringList::split("/", (*it));
TDENetworkSingleRouteConfiguration routeconfig;
routeconfig.ipAddress.setAddress(pieces[0]);
if (pieces.count() > 1) {
routeconfig.networkMask.fromCIDRMask(pieces[1].toUInt());
}
ret.append(routeconfig);
}
return ret;
}
@ -355,9 +388,9 @@ VPNCAuthentication::~VPNCAuthentication()
}
TQMap<TQString, TQString> VPNCAuthentication::getPasswords()
TDENetworkSettingsMap VPNCAuthentication::getPasswords()
{
TQMap<TQString, TQString> pwds;
TDENetworkSettingsMap pwds;
pwds.insert("Xauth password", TQString(_vpncAuth->editUserPassword->password()));
if (_vpncAuth->chkObfusticated->isChecked()) {
// Decrypt the obfusticated password with /usr/lib/vpnc/cisco-decrypt
@ -373,7 +406,9 @@ TQMap<TQString, TQString> VPNCAuthentication::getPasswords()
printf("Group password decrypt error\n\r");
}
else {
fgets(decrypted_result, 2048, pipe_decrypt);
if (fgets(decrypted_result, 2048, pipe_decrypt) == NULL) {
printf("Error reading from decryption program\n\r");
}
pclose(pipe_decrypt);
for (i=0;i<2048;i++) {
if (decrypted_result[i] == 0) {
@ -391,13 +426,15 @@ TQMap<TQString, TQString> VPNCAuthentication::getPasswords()
return pwds;
}
void VPNCAuthentication::setPasswords(TQString name, TQString value) {
if (name == TQString("Xauth password")) {
void VPNCAuthentication::setPasswords(TDENetworkSettingsMap secrets) {
if (secrets.contains("Xauth password")) {
_vpncAuth->editUserPassword->erase();
_vpncAuth->editUserPassword->insert(value);
_vpncAuth->editUserPassword->insert(secrets["Xauth password"]);
}
else if (name == TQString("IPSec secret")) {
else if (secrets.contains("IPSec secret")) {
_vpncAuth->editGroupPassword->erase();
_vpncAuth->editGroupPassword->insert(value);
_vpncAuth->editGroupPassword->insert(secrets["IPSec secret"]);
}
}
#include "tdenetman-vpnc.moc"

@ -31,7 +31,7 @@
#include <tqwidget.h>
#include <tqlayout.h>
#include "knetworkmanager-vpnplugin.h"
#include "tdenetman-vpnplugin.h"
#include "vpncprop.h"
#include "vpncauth.h"
@ -55,7 +55,7 @@ class VPNCConfig : public VPNConfigWidget
void setVPNData(TDENetworkSingleRouteConfigurationList&, TDENetworkSettingsMap&, TDENetworkSettingsMap&);
TDENetworkSettingsMap getVPNProperties();
TDENetworkSettingsMap getVPNSecrets();
TQStringList getVPNRoutes();
TDENetworkSingleRouteConfigurationList getVPNRoutes();
bool hasChanged();
bool isValid(TQStringList&);
@ -67,7 +67,10 @@ class VPNCConfig : public VPNConfigWidget
private:
VPNCConfigWidget* _vpncWidget;
int getFileConfig(char *parameter, char *line);
int getFileConfig(const char *parameter, char *line);
TDENetworkSettingsMap m_vpnProperties;
TDENetworkSettingsMap m_vpnSecrets;
protected slots:
void languageChange();

Loading…
Cancel
Save