From b265a6cd3524f77a1378a959fe9982d57d72a9ad Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 30 Mar 2015 11:57:23 -0400 Subject: Update the internal version number handling for backwards compatibility checks. This is just to future-proof the routine - now each version number piece can be anywhere from 0->999 (instead of the old limitation of 0->9). --- lumina-desktop/LSession.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'lumina-desktop/LSession.cpp') diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index b472a60a..bce1d607 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -171,6 +171,20 @@ void LSession::CleanupSession(){ for(int i=0; i<20; i++){ LSession::processEvents(); usleep(25); } //1/2 second pause } +int LSession::VersionStringToNumber(QString version){ + version = version.section("-",0,0); //trim any extra labels off the end + int maj, mid, min; //major/middle/minor version numbers (..) + maj = mid = min = 0; + bool ok = true; + maj = version.section(".",0,0).toInt(&ok); + if(ok){ mid = version.section(".",1,1).toInt(&ok); }else{ maj = 0; } + if(ok){ min = version.section(".",2,2).toInt(&ok); }else{ mid = 0; } + if(!ok){ min = 0; } + //Now assemble the number + //NOTE: This format allows numbers to be anywhere from 0->999 without conflict + return (maj*1000000 + mid*1000 + min); +} + void LSession::launchStartupApps(){ //First start any system-defined startups, then do user defined qDebug() << "Launching startup applications"; @@ -252,15 +266,16 @@ void LSession::watcherChange(QString changed){ } void LSession::checkUserFiles(){ - //version conversion examples: [1.0.0 -> 100], [1.2.0 -> 120], [0.6.0 -> 60] - int oldversion = sessionsettings->value("DesktopVersion","0").toString().section("-",0,0).remove(".").toInt(); - bool newversion = ( oldversion < this->applicationVersion().remove(".").toInt() ); + //internal version conversion examples: + // [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001] + int oldversion = VersionStringToNumber(sessionsettings->value("DesktopVersion","0").toString()); + bool newversion = ( oldversion < VersionStringToNumber(this->applicationVersion()) ); //Check for the desktop settings file QString dset = QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf"; bool firstrun = false; - if(!QFile::exists(dset) || oldversion < 50){ - if( oldversion < 50 ){ QFile::remove(dset); qDebug() << "Current desktop settings obsolete: Re-implementing defaults"; } + if(!QFile::exists(dset) || oldversion < 5000){ + if( oldversion < 5000 ){ QFile::remove(dset); qDebug() << "Current desktop settings obsolete: Re-implementing defaults"; } else{ firstrun = true; } /*if(QFile::exists(LOS::LuminaShare()+"desktopsettings.conf")){ if( QFile::copy(LOS::LuminaShare()+"desktopsettings.conf", dset) ){ @@ -269,10 +284,10 @@ void LSession::checkUserFiles(){ }*/ LUtils::LoadSystemDefaults(); } - if(oldversion <= 83){ - //Convert the old->new favorites framework + /*if(oldversion <= 8003){ + //Convert the old->new favorites framework (Not implemented yet) - } + }*/ //Check for the default applications file for lumina-open dset = QDir::homePath()+"/.lumina/LuminaDE/lumina-open.conf"; -- cgit