Clean up the code slightly

pull/1/head
Timothy Pearson 12 years ago
parent b99db6aa82
commit 94881634c4

@ -1,2 +1,4 @@
VPN support Prompt user when connection fails
Tell the user when he/she enters an invalid setting
Better VPN support; there should be a visual indication of VPN status in the tray icon
Translations Translations

@ -60,22 +60,18 @@ VPNWidgetImpl::Init()
// fill in all possible VPN services // fill in all possible VPN services
VPNServiceList list = VPNManager::getVPNServices(); VPNServiceList list = VPNManager::getVPNServices();
if (list.isEmpty()) if (list.isEmpty()) {
{
// FIXME Do something useful here // FIXME Do something useful here
} }
else else {
{
int index = 0; int index = 0;
for (VPNServiceList::Iterator it = list.begin(); it != list.end(); ++it) for (VPNServiceList::Iterator it = list.begin(); it != list.end(); ++it) {
{
TQString icon; TQString icon;
TQString disp_name; TQString disp_name;
// get service icon and display name // get service icon and display name
VPNService* service = *it; VPNService* service = *it;
if (service) if (service) {
{
icon = service->getIcon(); icon = service->getIcon();
disp_name = service->getDisplayName(); disp_name = service->getDisplayName();
} }
@ -99,14 +95,14 @@ VPNWidgetImpl::Init()
} }
// no special icon for this service, use default // no special icon for this service, use default
if (icon.isEmpty()) if (icon.isEmpty()) {
icon = "encrypted"; icon = "encrypted";
}
_mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index); _mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index);
_mapServiceCombo.insert(index++, *it); _mapServiceCombo.insert(index++, *it);
if (service->getService() == _vpnsetting->vpnPluginID) if (service->getService() == _vpnsetting->vpnPluginID) {
{
// preselect the correct service // preselect the correct service
_mainWid->cboServices->setCurrentItem(index - 1); _mainWid->cboServices->setCurrentItem(index - 1);
slotServiceComboActivated(index - 1); slotServiceComboActivated(index - 1);
@ -115,10 +111,10 @@ VPNWidgetImpl::Init()
} }
// lock the combo when editing an already existing connection // lock the combo when editing an already existing connection
if (!_new_conn) if (!_new_conn) {
_mainWid->cboServices->setEnabled(false); _mainWid->cboServices->setEnabled(false);
else }
{ else {
// preselect the correct service // preselect the correct service
_mainWid->cboServices->setCurrentItem(0); _mainWid->cboServices->setCurrentItem(0);
slotServiceComboActivated(0); slotServiceComboActivated(0);
@ -135,17 +131,14 @@ VPNWidgetImpl::Init()
VPNConfigWidget* VPNConfigWidget*
VPNWidgetImpl::getVPNConfigWidget(VPNService* service) VPNWidgetImpl::getVPNConfigWidget(VPNService* service)
{ {
if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) {
{
// return the already available config widget // return the already available config widget
return *_mapServiceWidget.find(service); return *_mapServiceWidget.find(service);
} }
else else {
{
// we have to create a new one // we have to create a new one
VPNPlugin* plugin = service->getVPNPlugin(); VPNPlugin* plugin = service->getVPNPlugin();
if (plugin) if (plugin) {
{
VPNConfigWidget* config = plugin->CreateConfigWidget(_mainWid->widgetStack); VPNConfigWidget* config = plugin->CreateConfigWidget(_mainWid->widgetStack);
_mapServiceWidget.insert(service, config); _mapServiceWidget.insert(service, config);
return config; return config;
@ -159,19 +152,16 @@ void
VPNWidgetImpl::slotServiceComboActivated(int index) VPNWidgetImpl::slotServiceComboActivated(int index)
{ {
VPNService* service; VPNService* service;
if (_mapServiceCombo.find(index) != _mapServiceCombo.end()) if (_mapServiceCombo.find(index) != _mapServiceCombo.end()) {
{
service = *_mapServiceCombo.find(index); service = *_mapServiceCombo.find(index);
if (service) if (service) {
{
VPNConfigWidget* config = getVPNConfigWidget(service); VPNConfigWidget* config = getVPNConfigWidget(service);
_mainWid->widgetStack->raiseWidget(config); _mainWid->widgetStack->raiseWidget(config);
config->setVPNData(_vpnsetting->ipConfig.routeConfigurations, _vpnsetting->pluginData, _vpnsetting->pluginSecrets); config->setVPNData(_vpnsetting->ipConfig.routeConfigurations, _vpnsetting->pluginData, _vpnsetting->pluginSecrets);
} }
} }
else else {
{
//FIXME - do something useful here //FIXME - do something useful here
} }
} }
@ -181,14 +171,12 @@ VPNWidgetImpl::Deactivate()
{ {
// update the setting from the currently selected vpn service // update the setting from the currently selected vpn service
VPNService* service = *_mapServiceCombo.find(_mainWid->cboServices->currentItem()); VPNService* service = *_mapServiceCombo.find(_mainWid->cboServices->currentItem());
if (service) if (service) {
{
// set the correct service type // set the correct service type
_vpnsetting->vpnPluginID = service->getService(); _vpnsetting->vpnPluginID = service->getService();
VPNConfigWidget* config = *_mapServiceWidget.find(service); VPNConfigWidget* config = *_mapServiceWidget.find(service);
if (config) if (config) {
{
// update the vpn properties // update the vpn properties
_vpnsetting->pluginData = config->getVPNProperties(); _vpnsetting->pluginData = config->getVPNProperties();
// update the vpn secrets // update the vpn secrets

@ -68,9 +68,9 @@ class ConnectionListViewItem : public KListViewItem
else if (_conn->type() == TDENetworkConnectionType::WiFi) { else if (_conn->type() == TDENetworkConnectionType::WiFi) {
setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small)); setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small));
} }
// else if (_conn->type() == TDENetworkConnectionType::VPN) { else if (_conn->type() == TDENetworkConnectionType::VPN) {
// setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small)); setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small));
// } }
else { else {
setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small)); setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small));
} }

@ -119,39 +119,32 @@ void StrongswanConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes
m_vpnSecrets = secrets; m_vpnSecrets = secrets;
// fill up our inputfields (only textfields atm) // fill up our inputfields (only textfields atm)
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) for(TDENetworkSettingsMap::iterator it = properties.begin(); it != properties.end(); ++it) {
{
TQString entry = it.key(); TQString entry = it.key();
TQString value = it.data(); TQString value = it.data();
if (entry == "gateway") if (entry == "gateway") {
{
_strongswanWidget->gateway->setText(value); _strongswanWidget->gateway->setText(value);
} }
else if (entry == "certificate") else if (entry == "certificate") {
{
_strongswanWidget->certificate->setURL(value); _strongswanWidget->certificate->setURL(value);
} }
else if (entry == "username") else if (entry == "username") {
{
_strongswanWidget->username->setText(value); _strongswanWidget->username->setText(value);
} }
else if (entry == "method") else if (entry == "method") {
{ StrongswanConnectionType::CONNECTIONTYPE type = StrongswanConnectionType::mapString2ConnectionType(value.toInt());
StrongswanConnectionType::CONNECTIONTYPE type = StrongswanConnectionType::mapString2ConnectionType(value.toInt());
_strongswanWidget->authtype->setCurrentItem(type); _strongswanWidget->authtype->setCurrentItem(type);
} }
// Options // Options
else if (entry == "chkUDPenc") else if (entry == "chkUDPenc") {
{
_strongswanWidget->chkUDPenc->setChecked(value == "true"); _strongswanWidget->chkUDPenc->setChecked(value == "true");
} }
else if (entry == "chkIPcomp") else if (entry == "chkIPcomp") {
{
_strongswanWidget->chkIPcomp->setChecked(value == "true"); _strongswanWidget->chkIPcomp->setChecked(value == "true");
} }
else if (entry == "chkIPinner") else if (entry == "chkIPinner") {
{
_strongswanWidget->chkIPinner->setChecked(value == "true"); _strongswanWidget->chkIPinner->setChecked(value == "true");
} }
} }

Loading…
Cancel
Save