summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-08 21:10:55 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-08 21:10:55 -0500
commit7d8a74d0f9922463f3c6e12d8ea46762f5c8bb10 (patch)
tree2d4cc46b2151babe71bfc144e3f41390b4b9097b
parent4f60eb94d17ce7d0ce51df30c80812c6ce763545 (diff)
downloadtdelibs-7d8a74d0f9922463f3c6e12d8ea46762f5c8bb10.tar.gz
tdelibs-7d8a74d0f9922463f3c6e12d8ea46762f5c8bb10.zip
Automatically generate UUID when needed
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.cpp60
-rw-r--r--tdecore/networkbackends/network-manager/network-manager_p.h1
-rw-r--r--tdecore/tdenetworkconnections.cpp7
3 files changed, 53 insertions, 15 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp
index 105c8e332..a46144ea2 100644
--- a/tdecore/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/networkbackends/network-manager/network-manager.cpp
@@ -56,14 +56,44 @@ TQT_DBusData convertDBUSDataToVariantData(TQT_DBusData object) {
return TQT_DBusData::fromVariant(variant);
}
-void printDBUSObjectStructure(TQT_DBusData object, int level=0) {
+void printDBUSObjectStructure(TQT_DBusData object, int level=0, TQString mapKey=TQString::null) {
int i;
TQString levelIndent = "";
for (i=0; i<level; i++) {
levelIndent = levelIndent + " ";
}
TQCString signature = object.buildDBusSignature();
- printf("%s%s\n\r", levelIndent.ascii(), signature.data()); fflush(stdout);
+
+ if (object.type() == TQT_DBusData::String) {
+ printf("%s%s\t%s%s'%s'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toString().ascii()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Bool) {
+ printf("%s%s\t%s%s'%s'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", (object.toBool())?"true":"false"); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Byte) {
+ printf("%s%s\t%s%s'%d'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toByte()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int16) {
+ printf("%s%s\t%s%s'%d'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt16()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt16) {
+ printf("%s%s\t%s%s'%d'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt16()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int32) {
+ printf("%s%s\t%s%s'%d'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt32()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt32) {
+ printf("%s%s\t%s%s'%d'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt32()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int64) {
+ printf("%s%s\t%s%s'%lld'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt64()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt64) {
+ printf("%s%s\t%s%s'%lld'\n\r", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt64()); fflush(stdout);
+ }
+ else {
+ printf("%s%s\n\r", levelIndent.ascii(), signature.data()); fflush(stdout);
+ }
if (object.type() == TQT_DBusData::Map) {
// HACK
@@ -71,10 +101,10 @@ void printDBUSObjectStructure(TQT_DBusData object, int level=0) {
TQMap<TQString, TQT_DBusData> outerMap = object.toStringKeyMap().toTQMap();
TQMap<TQString, TQT_DBusData>::const_iterator it;
for (it = outerMap.begin(); it != outerMap.end(); ++it) {
- printDBUSObjectStructure(*it, level+1);
+ printDBUSObjectStructure(*it, level+1, it.key());
}
}
- if (object.type() == TQT_DBusData::List) {
+ else if (object.type() == TQT_DBusData::List) {
TQT_DBusDataValueList valueList = object.toTQValueList();
TQT_DBusDataValueList::const_iterator it;
for (it = valueList.begin(); it != valueList.end(); ++it) {
@@ -84,7 +114,7 @@ void printDBUSObjectStructure(TQT_DBusData object, int level=0) {
else if (object.type() == TQT_DBusData::Variant) {
TQT_DBusVariant dataValueVariant = object.toVariant();
TQT_DBusData dataValue = dataValueVariant.value;
- printDBUSObjectStructure(dataValue, level+1);
+ printDBUSObjectStructure(dataValue, level+1, mapKey);
}
}
@@ -2749,12 +2779,26 @@ bool TDENetworkConnectionManager_BackendNM::loadConnectionSecretsForGroup(TQStri
}
bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* connection) {
- // Find path for connection with specified UUID, if it exists
- // This is so that any settings that we are not aware of can be loaded now and preserved through the update operation
if (!connection) {
PRINT_ERROR(TQString("connection cannot be NULL!"));
return FALSE;
}
+
+ // If the UUID is blank, generate a new UUID for this connection and also guarantee that it it truly unique
+ if (connection->UUID == "") {
+ bool unique = false;
+ while (!unique) {
+ connection->UUID = TQUuid::createUuid().toString();
+ connection->UUID.replace("{", "");
+ connection->UUID.replace("}", "");
+ if (!findConnectionByUUID(connection->UUID)) {
+ unique = true;
+ }
+ }
+ }
+
+ // Find path for connection with specified UUID, if it exists
+ // This is so that any settings that we are not aware of can be loaded now and preserved through the update operation
TDEWiredEthernetConnection* ethernetConnection = dynamic_cast<TDEWiredEthernetConnection*>(connection);
TDEWiredInfinibandConnection* infinibandConnection = dynamic_cast<TDEWiredInfinibandConnection*>(connection);
TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
@@ -2848,7 +2892,7 @@ bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection*
}
settingsMap["autoconnect"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->autoConnect));
settingsMap["read-only"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->readOnly));
- settingsMap["master"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->masterConnectionUUID));
+ UPDATE_STRING_SETTING_IF_VALID(connection->masterConnectionUUID, "master", settingsMap)
{
TQString slaveType = tdeSlaveTypeToNMSlaveType(connection->slaveType);
if (slaveType != "") settingsMap["slave-type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(slaveType));
diff --git a/tdecore/networkbackends/network-manager/network-manager_p.h b/tdecore/networkbackends/network-manager/network-manager_p.h
index 728b1ac52..758e7fe77 100644
--- a/tdecore/networkbackends/network-manager/network-manager_p.h
+++ b/tdecore/networkbackends/network-manager/network-manager_p.h
@@ -23,6 +23,7 @@
#include <tqvaluelist.h>
#include <tqapplication.h>
#include <tqtimer.h>
+#include <tquuid.h>
/* TDE headers */
#include <kdebug.h>
diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp
index 3891f1ff7..6139bd49f 100644
--- a/tdecore/tdenetworkconnections.cpp
+++ b/tdecore/tdenetworkconnections.cpp
@@ -21,8 +21,6 @@
#include "config.h"
-#include <tquuid.h>
-
#include <klocale.h>
#ifdef WITH_NETWORK_MANAGER_BACKEND
@@ -501,11 +499,6 @@ TDENetworkConnection::TDENetworkConnection() {
requireIPV4 = false;
requireIPV6 = false;
mtu = 0;
-
- // Create a UUID for the new connection
- // This may be overridden later on if connection information
- // is loaded into this object from another source
- UUID = TQUuid::createUuid().toString();
}
TDENetworkConnection::~TDENetworkConnection() {